@bquery/bquery 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +44 -19
  2. package/dist/{a11y-DG2i4iZN.js → a11y-DgUQ8-fI.js} +1 -1
  3. package/dist/{a11y-DG2i4iZN.js.map → a11y-DgUQ8-fI.js.map} +1 -1
  4. package/dist/a11y.es.mjs +1 -1
  5. package/dist/{component-DRotf1hl.js → component-D8ydhe58.js} +2 -2
  6. package/dist/{component-DRotf1hl.js.map → component-D8ydhe58.js.map} +1 -1
  7. package/dist/component.es.mjs +1 -1
  8. package/dist/concurrency-BU1wPEsZ.js.map +1 -1
  9. package/dist/{constraints-CqjhmpZC.js → constraints-Dlbx_m1b.js} +1 -1
  10. package/dist/{constraints-CqjhmpZC.js.map → constraints-Dlbx_m1b.js.map} +1 -1
  11. package/dist/{core-EMYSLzaT.js → core-tOP6QOrY.js} +2 -2
  12. package/dist/{core-EMYSLzaT.js.map → core-tOP6QOrY.js.map} +1 -1
  13. package/dist/core.es.mjs +1 -1
  14. package/dist/{custom-directives-BjFzFhuf.js → custom-directives-5DlKqvd2.js} +1 -1
  15. package/dist/{custom-directives-BjFzFhuf.js.map → custom-directives-5DlKqvd2.js.map} +1 -1
  16. package/dist/{devtools-C5FExMwv.js → devtools-QosAqo0T.js} +2 -2
  17. package/dist/{devtools-C5FExMwv.js.map → devtools-QosAqo0T.js.map} +1 -1
  18. package/dist/devtools.es.mjs +1 -1
  19. package/dist/{dnd-BAqzPlSo.js → dnd-d2OU4len.js} +1 -1
  20. package/dist/{dnd-BAqzPlSo.js.map → dnd-d2OU4len.js.map} +1 -1
  21. package/dist/dnd.es.mjs +1 -1
  22. package/dist/{forms-Dx1Scvh0.js → forms-BLx4ZzT7.js} +1 -1
  23. package/dist/{forms-Dx1Scvh0.js.map → forms-BLx4ZzT7.js.map} +1 -1
  24. package/dist/forms.es.mjs +1 -1
  25. package/dist/full.d.ts +4 -2
  26. package/dist/full.d.ts.map +1 -1
  27. package/dist/full.es.mjs +258 -219
  28. package/dist/full.iife.js +41 -37
  29. package/dist/full.iife.js.map +1 -1
  30. package/dist/full.umd.js +41 -37
  31. package/dist/full.umd.js.map +1 -1
  32. package/dist/{i18n-Cazyk9RD.js → i18n--p7PM-9r.js} +1 -1
  33. package/dist/{i18n-Cazyk9RD.js.map → i18n--p7PM-9r.js.map} +1 -1
  34. package/dist/i18n.es.mjs +1 -1
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.es.mjs +291 -252
  38. package/dist/match-CrZRVC4z.js +174 -0
  39. package/dist/match-CrZRVC4z.js.map +1 -0
  40. package/dist/{media-dAKIGPk3.js → media-gjbWNq50.js} +1 -1
  41. package/dist/{media-dAKIGPk3.js.map → media-gjbWNq50.js.map} +1 -1
  42. package/dist/media.es.mjs +1 -1
  43. package/dist/motion-BBMso9Ir.js.map +1 -1
  44. package/dist/{mount-C8O2vXkQ.js → mount-0A9qtcRJ.js} +3 -3
  45. package/dist/{mount-C8O2vXkQ.js.map → mount-0A9qtcRJ.js.map} +1 -1
  46. package/dist/platform-BPHIXbw8.js.map +1 -1
  47. package/dist/{plugin-DjTqWg-P.js → plugin-SZEirbwq.js} +2 -2
  48. package/dist/{plugin-DjTqWg-P.js.map → plugin-SZEirbwq.js.map} +1 -1
  49. package/dist/plugin.es.mjs +1 -1
  50. package/dist/reactive-BAd2hfl8.js.map +1 -1
  51. package/dist/{registry-Cr6VH8CR.js → registry-jpUQHf4E.js} +1 -1
  52. package/dist/{registry-Cr6VH8CR.js.map → registry-jpUQHf4E.js.map} +1 -1
  53. package/dist/router-C4weu0QL.js +333 -0
  54. package/dist/router-C4weu0QL.js.map +1 -0
  55. package/dist/router.es.mjs +1 -1
  56. package/dist/{sanitize-B1V4JswB.js → sanitize-DOMkRO9G.js} +12 -7
  57. package/dist/{sanitize-B1V4JswB.js.map → sanitize-DOMkRO9G.js.map} +1 -1
  58. package/dist/security.es.mjs +1 -1
  59. package/dist/server/create-server.d.ts +25 -0
  60. package/dist/server/create-server.d.ts.map +1 -0
  61. package/dist/server/index.d.ts +11 -0
  62. package/dist/server/index.d.ts.map +1 -0
  63. package/dist/server/types.d.ts +396 -0
  64. package/dist/server/types.d.ts.map +1 -0
  65. package/dist/server-QdyKtCS1.js +349 -0
  66. package/dist/server-QdyKtCS1.js.map +1 -0
  67. package/dist/server.es.mjs +6 -0
  68. package/dist/ssr/adapters.d.ts +74 -0
  69. package/dist/ssr/adapters.d.ts.map +1 -0
  70. package/dist/ssr/async.d.ts +40 -0
  71. package/dist/ssr/async.d.ts.map +1 -0
  72. package/dist/ssr/config.d.ts +60 -0
  73. package/dist/ssr/config.d.ts.map +1 -0
  74. package/dist/ssr/context.d.ts +73 -0
  75. package/dist/ssr/context.d.ts.map +1 -0
  76. package/dist/ssr/defer-brand.d.ts +5 -0
  77. package/dist/ssr/defer-brand.d.ts.map +1 -0
  78. package/dist/ssr/escape.d.ts +17 -0
  79. package/dist/ssr/escape.d.ts.map +1 -0
  80. package/dist/ssr/expression.d.ts +44 -0
  81. package/dist/ssr/expression.d.ts.map +1 -0
  82. package/dist/ssr/hash.d.ts +39 -0
  83. package/dist/ssr/hash.d.ts.map +1 -0
  84. package/dist/ssr/head.d.ts +102 -0
  85. package/dist/ssr/head.d.ts.map +1 -0
  86. package/dist/ssr/html-parser.d.ts +58 -0
  87. package/dist/ssr/html-parser.d.ts.map +1 -0
  88. package/dist/ssr/index.d.ts +49 -43
  89. package/dist/ssr/index.d.ts.map +1 -1
  90. package/dist/ssr/mismatch.d.ts +60 -0
  91. package/dist/ssr/mismatch.d.ts.map +1 -0
  92. package/dist/ssr/render-async.d.ts +84 -0
  93. package/dist/ssr/render-async.d.ts.map +1 -0
  94. package/dist/ssr/render.d.ts.map +1 -1
  95. package/dist/ssr/renderer.d.ts +25 -0
  96. package/dist/ssr/renderer.d.ts.map +1 -0
  97. package/dist/ssr/resumability.d.ts +65 -0
  98. package/dist/ssr/resumability.d.ts.map +1 -0
  99. package/dist/ssr/router-bridge.d.ts +101 -0
  100. package/dist/ssr/router-bridge.d.ts.map +1 -0
  101. package/dist/ssr/runtime.d.ts +63 -0
  102. package/dist/ssr/runtime.d.ts.map +1 -0
  103. package/dist/ssr/serialize.d.ts.map +1 -1
  104. package/dist/ssr/store-snapshot.d.ts +87 -0
  105. package/dist/ssr/store-snapshot.d.ts.map +1 -0
  106. package/dist/ssr/strategies.d.ts +43 -0
  107. package/dist/ssr/strategies.d.ts.map +1 -0
  108. package/dist/ssr/suspense.d.ts +47 -0
  109. package/dist/ssr/suspense.d.ts.map +1 -0
  110. package/dist/ssr/types.d.ts +17 -0
  111. package/dist/ssr/types.d.ts.map +1 -1
  112. package/dist/ssr-Bt6BQA3J.js +2127 -0
  113. package/dist/ssr-Bt6BQA3J.js.map +1 -0
  114. package/dist/ssr.es.mjs +42 -7
  115. package/dist/{store-CjmEeX9-.js → store-DnXuu6Li.js} +2 -2
  116. package/dist/{store-CjmEeX9-.js.map → store-DnXuu6Li.js.map} +1 -1
  117. package/dist/store.es.mjs +2 -2
  118. package/dist/storybook.es.mjs +1 -1
  119. package/dist/{testing-TdfaL7VE.js → testing-CeMUwrRD.js} +2 -2
  120. package/dist/{testing-TdfaL7VE.js.map → testing-CeMUwrRD.js.map} +1 -1
  121. package/dist/testing.es.mjs +1 -1
  122. package/dist/view.es.mjs +1 -1
  123. package/package.json +17 -12
  124. package/src/full.ts +99 -0
  125. package/src/index.ts +3 -0
  126. package/src/server/create-server.ts +754 -0
  127. package/src/server/index.ts +33 -0
  128. package/src/server/types.ts +490 -0
  129. package/src/ssr/adapters.ts +330 -0
  130. package/src/ssr/async.ts +125 -0
  131. package/src/ssr/config.ts +86 -0
  132. package/src/ssr/context.ts +245 -0
  133. package/src/ssr/defer-brand.ts +3 -0
  134. package/src/ssr/escape.ts +25 -0
  135. package/src/ssr/expression.ts +669 -0
  136. package/src/ssr/hash.ts +71 -0
  137. package/src/ssr/head.ts +240 -0
  138. package/src/ssr/html-parser.ts +387 -0
  139. package/src/ssr/index.ts +136 -43
  140. package/src/ssr/mismatch.ts +110 -0
  141. package/src/ssr/render-async.ts +286 -0
  142. package/src/ssr/render.ts +130 -59
  143. package/src/ssr/renderer.ts +453 -0
  144. package/src/ssr/resumability.ts +142 -0
  145. package/src/ssr/router-bridge.ts +177 -0
  146. package/src/ssr/runtime.ts +131 -0
  147. package/src/ssr/serialize.ts +1 -27
  148. package/src/ssr/store-snapshot.ts +209 -0
  149. package/src/ssr/strategies.ts +245 -0
  150. package/src/ssr/suspense.ts +504 -0
  151. package/src/ssr/types.ts +18 -0
  152. package/dist/router-CCepRMpC.js +0 -493
  153. package/dist/router-CCepRMpC.js.map +0 -1
  154. package/dist/ssr-D-1IPcfw.js +0 -248
  155. package/dist/ssr-D-1IPcfw.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize-B1V4JswB.js","names":[],"sources":["../src/security/constants.ts","../src/security/sanitize-core.ts","../src/security/trusted-html.ts","../src/security/csp.ts","../src/security/trusted-types.ts","../src/security/sanitize.ts"],"sourcesContent":["/**\n * Security constants and safe lists.\n *\n * @module bquery/security\n */\n\n/**\n * Trusted Types policy name.\n */\nexport const POLICY_NAME = 'bquery-sanitizer';\n\n/**\n * Default allowed HTML tags considered safe.\n */\nexport const DEFAULT_ALLOWED_TAGS = new Set([\n 'a',\n 'abbr',\n 'address',\n 'article',\n 'aside',\n 'b',\n 'bdi',\n 'bdo',\n 'blockquote',\n 'br',\n 'button',\n 'caption',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'header',\n 'hgroup',\n 'hr',\n 'i',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'main',\n 'mark',\n 'nav',\n 'ol',\n 'optgroup',\n 'option',\n 'p',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'u',\n 'ul',\n 'var',\n 'wbr',\n]);\n\n/**\n * Explicitly dangerous tags that should never be allowed.\n * These are checked even if somehow added to allowTags.\n */\nexport const DANGEROUS_TAGS = new Set([\n 'script',\n 'iframe',\n 'frame',\n 'frameset',\n 'object',\n 'embed',\n 'applet',\n 'link',\n 'meta',\n 'style',\n 'base',\n 'template',\n // 'slot' is intentionally excluded here so component shadow markup can opt in\n // via sanitizeHtml(..., { allowTags: ['slot'] }). It remains disallowed by default\n // for general HTML writes, because DEFAULT_ALLOWED_TAGS does not include it.\n 'math',\n 'svg',\n 'foreignobject',\n 'noscript',\n]);\n\n/**\n * Reserved IDs that could cause DOM clobbering attacks.\n * These are prevented to avoid overwriting global browser objects.\n */\nexport const RESERVED_IDS = new Set([\n // Global objects\n 'document',\n 'window',\n 'location',\n 'top',\n 'self',\n 'parent',\n 'frames',\n 'history',\n 'navigator',\n 'screen',\n // Dangerous functions\n 'alert',\n 'confirm',\n 'prompt',\n 'eval',\n 'function',\n // Document properties\n 'cookie',\n 'domain',\n 'referrer',\n 'body',\n 'head',\n 'forms',\n 'images',\n 'links',\n 'scripts',\n // DOM traversal properties\n 'children',\n 'parentnode',\n 'firstchild',\n 'lastchild',\n // Content manipulation\n 'innerhtml',\n 'outerhtml',\n 'textcontent',\n]);\n\n/**\n * Default allowed attributes considered safe.\n * Note: 'style' is excluded by default because inline CSS can be abused for:\n * - UI redressing attacks\n * - Data exfiltration via url() in CSS\n * - CSS injection vectors\n * If you need to allow inline styles, add 'style' to allowAttributes in your\n * sanitizeHtml options, but ensure you implement proper CSS value validation.\n */\nexport const DEFAULT_ALLOWED_ATTRIBUTES = new Set([\n 'alt',\n 'class',\n 'dir',\n 'height',\n 'hidden',\n 'href',\n 'id',\n 'lang',\n 'loading',\n 'name',\n 'rel',\n 'role',\n 'src',\n 'srcset',\n 'tabindex',\n 'target',\n 'title',\n 'type',\n 'width',\n 'aria-*',\n]);\n\n/**\n * Dangerous attribute prefixes to always remove.\n */\nexport const DANGEROUS_ATTR_PREFIXES = ['on', 'formaction', 'xlink:', 'xmlns:'];\n\n/**\n * Dangerous URL protocols to block.\n */\nexport const DANGEROUS_PROTOCOLS = ['javascript:', 'data:', 'vbscript:', 'file:'];\n","/**\n * Core HTML sanitization logic.\n *\n * @module bquery/security\n * @internal\n */\n\nimport {\n DANGEROUS_ATTR_PREFIXES,\n DANGEROUS_PROTOCOLS,\n DANGEROUS_TAGS,\n DEFAULT_ALLOWED_ATTRIBUTES,\n DEFAULT_ALLOWED_TAGS,\n RESERVED_IDS,\n} from './constants';\nimport type { SanitizeOptions } from './types';\n\n/**\n * Check if an attribute name is allowed.\n * @internal\n */\nconst isAllowedAttribute = (\n name: string,\n allowedSet: Set<string>,\n allowDataAttrs: boolean\n): boolean => {\n const lowerName = name.toLowerCase();\n\n // Check dangerous prefixes\n for (const prefix of DANGEROUS_ATTR_PREFIXES) {\n if (lowerName.startsWith(prefix)) return false;\n }\n\n // Check data attributes\n if (allowDataAttrs && lowerName.startsWith('data-')) return true;\n\n // Check aria attributes (allowed by default)\n if (lowerName.startsWith('aria-')) return true;\n\n // Check explicit allow list\n return allowedSet.has(lowerName);\n};\n\n/**\n * Check if an ID/name value could cause DOM clobbering.\n * @internal\n */\nconst isSafeIdOrName = (value: string): boolean => {\n const lowerValue = value.toLowerCase().trim();\n return !RESERVED_IDS.has(lowerValue);\n};\n\n/**\n * Normalize URL by removing control characters, whitespace, and Unicode tricks.\n * Enhanced to prevent various bypass techniques.\n * @internal\n */\nconst normalizeUrl = (value: string): string =>\n value\n // Remove null bytes and control characters\n .replace(/[\\u0000-\\u001F\\u007F]+/g, '')\n // Remove zero-width characters that could hide malicious content\n .replace(/[\\u200B-\\u200D\\uFEFF\\u2028\\u2029]+/g, '')\n // Remove escaped Unicode sequences\n .replace(/\\\\u[\\da-fA-F]{4}/g, '')\n // Remove whitespace\n .replace(/\\s+/g, '')\n // Normalize case\n .toLowerCase();\n\n/**\n * Check if a URL value is safe.\n * @internal\n */\nconst isSafeUrl = (value: string): boolean => {\n const normalized = normalizeUrl(value);\n for (const protocol of DANGEROUS_PROTOCOLS) {\n if (normalized.startsWith(protocol)) return false;\n }\n return true;\n};\n\n/**\n * Check if a srcset attribute value is safe.\n * srcset contains comma-separated entries of \"url [descriptor]\".\n * Each individual URL must be validated.\n * @internal\n */\nconst isSafeSrcset = (value: string): boolean => {\n const entries = value.split(',');\n for (const entry of entries) {\n const url = entry.trim().split(/\\s+/)[0];\n if (url && !isSafeUrl(url)) return false;\n }\n return true;\n};\n\n/**\n * Check if a URL is external (different origin).\n * @internal\n */\nconst isExternalUrl = (url: string): boolean => {\n try {\n // Normalize URL by trimming whitespace\n const trimmedUrl = url.trim();\n\n // Protocol-relative URLs (//example.com) are always external.\n // CRITICAL: This check must run before the relative-URL check below;\n // otherwise, a protocol-relative URL like \"//evil.com\" would be treated\n // as a non-http(s) relative URL and incorrectly classified as same-origin.\n // Handling them up front guarantees correct security classification.\n if (trimmedUrl.startsWith('//')) {\n return true;\n }\n\n // Normalize URL for case-insensitive protocol checks\n const lowerUrl = trimmedUrl.toLowerCase();\n\n // Check for non-http(s) protocols which are considered external/special\n // (mailto:, tel:, ftp:, etc.)\n const hasProtocol = /^[a-z][a-z0-9+.-]*:/i.test(trimmedUrl);\n if (hasProtocol && !lowerUrl.startsWith('http://') && !lowerUrl.startsWith('https://')) {\n // These are special protocols, not traditional \"external\" links\n // but we treat them as external for security consistency\n return true;\n }\n\n // Relative URLs are not external\n if (!lowerUrl.startsWith('http://') && !lowerUrl.startsWith('https://')) {\n return false;\n }\n\n // In non-browser environments (e.g., Node.js), treat all absolute URLs as external\n if (typeof window === 'undefined' || !window.location) {\n return true;\n }\n\n const urlObj = new URL(trimmedUrl, window.location.href);\n return urlObj.origin !== window.location.origin;\n } catch {\n // If URL parsing fails, treat as potentially external for safety\n return true;\n }\n};\n\n/**\n * Parse an HTML string into a Document using DOMParser.\n * This helper is intentionally separated to make the control-flow around HTML parsing\n * explicit for static analysis tools. It should ONLY be called when the input is\n * known to contain HTML syntax (angle brackets).\n *\n * DOMParser creates an inert document where scripts don't execute, making it safe\n * for parsing untrusted HTML that will subsequently be sanitized.\n *\n * @param htmlContent - A string that is known to contain HTML markup (has < or >)\n * @returns The parsed Document\n * @internal\n */\nconst parseHtmlDocument = (htmlContent: string): Document => {\n const parser = new DOMParser();\n // Parse as a full HTML document in an inert context; scripts won't execute\n return parser.parseFromString(htmlContent, 'text/html');\n};\n\n/**\n * Safely parse HTML string into a DocumentFragment using DOMParser.\n * DOMParser is preferred over innerHTML for security as it creates an inert document\n * where scripts don't execute and provides better static analysis recognition.\n *\n * This function includes input normalization to satisfy static analysis tools:\n * - Coerces input to string and trims whitespace\n * - For plain text (no HTML tags), creates a Text node directly without parsing\n * - Only invokes DOMParser for actual HTML-like content via parseHtmlDocument\n *\n * The separation between plain text handling and HTML parsing is intentional:\n * DOM text that contains no HTML syntax is never fed into an HTML parser,\n * preventing \"DOM text reinterpreted as HTML\" issues.\n *\n * @internal\n */\nconst parseHtmlSafely = (html: string): DocumentFragment => {\n // Step 1: Normalize input - coerce to string and trim\n // This defensive check handles edge cases even though TypeScript says it's a string\n const normalizedHtml = (typeof html === 'string' ? html : String(html ?? '')).trim();\n\n // Step 2: Create the fragment that will hold our result\n const fragment = document.createDocumentFragment();\n\n // Step 3: Early return for empty input\n if (normalizedHtml.length === 0) {\n return fragment;\n }\n\n // Step 4: If input contains no angle brackets, it's plain text - no HTML parsing needed.\n // Plain text is handled as a Text node, never passed to an HTML parser.\n // This explicitly prevents \"DOM text reinterpreted as HTML\" for purely textual inputs.\n const containsHtmlSyntax = normalizedHtml.includes('<') || normalizedHtml.includes('>');\n if (!containsHtmlSyntax) {\n fragment.appendChild(document.createTextNode(normalizedHtml));\n return fragment;\n }\n\n // Step 5: Input contains HTML syntax - parse it via the dedicated HTML parsing helper.\n // This separation makes the data-flow explicit: only strings with HTML syntax\n // are passed to DOMParser, satisfying static analysis requirements.\n const doc = parseHtmlDocument(normalizedHtml);\n\n // Move all children from the document body into the fragment.\n // This avoids interpolating untrusted HTML into an outer wrapper string.\n const body = doc.body;\n\n if (!body) {\n return fragment;\n }\n\n while (body.firstChild) {\n fragment.appendChild(body.firstChild);\n }\n\n return fragment;\n};\n\n/**\n * Core sanitization logic (without Trusted Types wrapper).\n * @internal\n */\nexport const sanitizeHtmlCore = (html: string, options: SanitizeOptions = {}): string => {\n const {\n allowTags = [],\n allowAttributes = [],\n allowDataAttributes = true,\n stripAllTags = false,\n } = options;\n\n // Build combined allow sets (excluding dangerous tags even if specified)\n const allowedTags = new Set(\n [...DEFAULT_ALLOWED_TAGS, ...allowTags.map((t) => t.toLowerCase())].filter(\n (tag) => !DANGEROUS_TAGS.has(tag)\n )\n );\n const allowedAttrs = new Set([\n ...DEFAULT_ALLOWED_ATTRIBUTES,\n ...allowAttributes.map((a) => a.toLowerCase()),\n ]);\n\n // Use DOMParser for safe HTML parsing (inert context, no script execution)\n const fragment = parseHtmlSafely(html);\n\n if (stripAllTags) {\n return fragment.textContent ?? '';\n }\n\n // Walk the DOM tree\n const walker = document.createTreeWalker(fragment, NodeFilter.SHOW_ELEMENT);\n\n const toRemove: Element[] = [];\n\n while (walker.nextNode()) {\n const el = walker.currentNode as Element;\n const tagName = el.tagName.toLowerCase();\n\n // Remove explicitly dangerous tags even if in allow list\n if (DANGEROUS_TAGS.has(tagName)) {\n toRemove.push(el);\n continue;\n }\n\n // Remove disallowed tags entirely\n if (!allowedTags.has(tagName)) {\n toRemove.push(el);\n continue;\n }\n\n // Process attributes\n const attrsToRemove: string[] = [];\n for (const attr of Array.from(el.attributes)) {\n const attrName = attr.name.toLowerCase();\n\n // Check if attribute is allowed\n if (!isAllowedAttribute(attrName, allowedAttrs, allowDataAttributes)) {\n attrsToRemove.push(attr.name);\n continue;\n }\n\n // Check for DOM clobbering on id and name attributes\n if ((attrName === 'id' || attrName === 'name') && !isSafeIdOrName(attr.value)) {\n attrsToRemove.push(attr.name);\n continue;\n }\n\n // Validate URL attributes\n if (\n (attrName === 'href' || attrName === 'src' || attrName === 'action') &&\n !isSafeUrl(attr.value)\n ) {\n attrsToRemove.push(attr.name);\n continue;\n }\n\n // Validate srcset URLs individually\n if (attrName === 'srcset' && !isSafeSrcset(attr.value)) {\n attrsToRemove.push(attr.name);\n }\n }\n\n // Remove disallowed attributes\n for (const attrName of attrsToRemove) {\n el.removeAttribute(attrName);\n }\n\n // Add rel=\"noopener noreferrer\" to external links for security\n if (tagName === 'a') {\n const href = el.getAttribute('href');\n const target = el.getAttribute('target');\n const hasTargetBlank = target?.toLowerCase() === '_blank';\n const isExternal = href && isExternalUrl(href);\n\n // Add security attributes to links opening in new window or external links\n if (hasTargetBlank || isExternal) {\n const existingRel = el.getAttribute('rel');\n const relValues = new Set(existingRel ? existingRel.split(/\\s+/).filter(Boolean) : []);\n\n // Add noopener and noreferrer\n relValues.add('noopener');\n relValues.add('noreferrer');\n\n el.setAttribute('rel', Array.from(relValues).join(' '));\n }\n }\n }\n\n // Remove disallowed elements\n for (const el of toRemove) {\n el.remove();\n }\n\n // Serialize the sanitized fragment to HTML string.\n // We use a temporary container to get the innerHTML of the fragment.\n const serializeFragment = (frag: DocumentFragment): string => {\n const container = document.createElement('div');\n container.appendChild(frag.cloneNode(true));\n return container.innerHTML;\n };\n\n // Double-parse to prevent mutation XSS (mXSS).\n // Browsers may normalize HTML during serialization in ways that could create\n // new dangerous content when re-parsed. By re-parsing the sanitized output\n // and verifying stability, we ensure the final HTML is safe.\n const firstPass = serializeFragment(fragment);\n\n // Re-parse through DOMParser for mXSS detection.\n // Using DOMParser instead of innerHTML for security.\n const verifyFragment = parseHtmlSafely(firstPass);\n const secondPass = serializeFragment(verifyFragment);\n\n // Verify stability: if content mutates between parses, it indicates mXSS attempt\n if (firstPass !== secondPass) {\n // Content mutated during re-parse - potential mXSS detected.\n // Return safely escaped text content as fallback.\n return fragment.textContent ?? '';\n }\n\n return secondPass;\n};\n","declare const sanitizedHtmlBrand: unique symbol;\nconst trustedHtmlBrand: unique symbol = Symbol('bquery.trusted-html.brand');\nconst TRUSTED_HTML_VALUE = Symbol('bquery.trusted-html');\n\n/**\n * Branded HTML string produced by bQuery's sanitization or escaping template helpers.\n *\n * Values returned from {@link sanitizeHtml} carry sanitized markup. Values returned from\n * {@link safeHtml} preserve the template's static markup while escaping normal interpolations\n * and splicing {@link trusted} fragments verbatim. This brand is not intended for arbitrary\n * strings or manual concatenation outside those helpers.\n */\nexport type SanitizedHtml = string & { readonly [sanitizedHtmlBrand]: true };\n\n/**\n * Marker object that safeHtml can splice into templates without escaping again.\n */\nexport type TrustedHtml = { readonly [trustedHtmlBrand]: true; toString(): string };\n\ntype TrustedHtmlValue = TrustedHtml & { readonly [TRUSTED_HTML_VALUE]: string };\n\n/**\n * Apply the internal {@link SanitizedHtml} brand to helper output.\n *\n * @internal\n */\nexport const toSanitizedHtml = (html: string): SanitizedHtml => html as SanitizedHtml;\n\n/**\n * Mark a sanitized HTML string for verbatim splicing into safeHtml templates.\n *\n * @param html - HTML previously produced by sanitizeHtml, safeHtml, or another trusted bQuery helper\n * @returns Trusted HTML marker object for safeHtml interpolations\n *\n * @example\n * ```ts\n * const badge = trusted(sanitizeHtml('<strong onclick=\"alert(1)\">New</strong>'));\n * const markup = safeHtml`<span>${badge}</span>`;\n * ```\n */\nexport const trusted = (html: SanitizedHtml): TrustedHtml => {\n const value = String(html);\n return Object.freeze({\n [trustedHtmlBrand]: true as const,\n [TRUSTED_HTML_VALUE]: value,\n toString: () => value,\n });\n};\n\n/**\n * Check whether a value is a trusted HTML marker created by trusted().\n *\n * @internal\n */\nexport const isTrustedHtml = (value: unknown): value is TrustedHtml => {\n return (\n typeof value === 'object' &&\n value !== null &&\n trustedHtmlBrand in value &&\n TRUSTED_HTML_VALUE in value\n );\n};\n\n/**\n * Unwrap the raw HTML string stored inside a trusted HTML marker.\n *\n * @internal\n */\nexport const unwrapTrustedHtml = (value: TrustedHtml): string => {\n return (value as TrustedHtmlValue)[TRUSTED_HTML_VALUE];\n};\n","/**\n * Content Security Policy helpers.\n *\n * @module bquery/security\n */\n\n/** Maximum allowed nonce length to prevent memory issues */\nconst MAX_NONCE_LENGTH = 1024;\n\n/** Chunk size for building strings to avoid argument limit in String.fromCharCode */\nconst CHUNK_SIZE = 8192;\n\n/**\n * Generate a nonce for inline scripts/styles.\n * Use with Content-Security-Policy nonce directives.\n *\n * @param length - Nonce length in bytes (default: 16, max: 1024)\n * @returns Cryptographically random nonce string\n * @throws {Error} If crypto.getRandomValues or btoa are not available\n * @throws {RangeError} If length is invalid (negative, non-integer, or exceeds maximum)\n */\nexport const generateNonce = (length: number = 16): string => {\n // Validate length parameter\n if (!Number.isInteger(length) || length < 1) {\n throw new RangeError('generateNonce length must be a positive integer');\n }\n if (length > MAX_NONCE_LENGTH) {\n throw new RangeError(`generateNonce length must not exceed ${MAX_NONCE_LENGTH}`);\n }\n\n // Check for required globals in browser/crypto environments\n if (\n typeof globalThis.crypto === 'undefined' ||\n typeof globalThis.crypto.getRandomValues !== 'function'\n ) {\n throw new Error(\n 'generateNonce requires crypto.getRandomValues (not available in this environment)'\n );\n }\n if (typeof globalThis.btoa !== 'function') {\n throw new Error('generateNonce requires btoa (not available in this environment)');\n }\n\n const array = new Uint8Array(length);\n globalThis.crypto.getRandomValues(array);\n\n // Build string in chunks to avoid argument limit in String.fromCharCode\n let binaryString = '';\n for (let i = 0; i < array.length; i += CHUNK_SIZE) {\n const chunk = array.subarray(i, Math.min(i + CHUNK_SIZE, array.length));\n binaryString += String.fromCharCode(...chunk);\n }\n\n return globalThis.btoa(binaryString).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n};\n\n/**\n * Check if a CSP header is present with specific directive.\n * Useful for feature detection and fallback strategies.\n *\n * @param directive - The CSP directive to check (e.g., 'script-src')\n * @returns True if the directive appears to be enforced\n */\nexport const hasCSPDirective = (directive: string): boolean => {\n // Guard for non-DOM environments (SSR, tests, etc.)\n if (typeof document === 'undefined') {\n return false;\n }\n\n // Check meta tag\n const meta = document.querySelector('meta[http-equiv=\"Content-Security-Policy\"]');\n if (meta) {\n const content = meta.getAttribute('content') ?? '';\n return content.includes(directive);\n }\n return false;\n};\n","/**\n * Trusted Types helpers for CSP compatibility.\n *\n * @module bquery/security\n */\n\nimport { POLICY_NAME } from './constants';\nimport { sanitizeHtmlCore } from './sanitize-core';\nimport type { TrustedHTML, TrustedTypePolicy, TrustedTypesWindow } from './types';\n\n/** Cached Trusted Types policy */\nlet cachedPolicy: TrustedTypePolicy | null = null;\n\n/** Whether policy initialization has been attempted (to avoid retry spam) */\nlet policyInitAttempted = false;\n\n/**\n * Check if Trusted Types API is available.\n * @returns True if Trusted Types are supported\n */\nexport const isTrustedTypesSupported = (): boolean => {\n return (\n typeof window !== 'undefined' &&\n typeof (window as TrustedTypesWindow).trustedTypes !== 'undefined'\n );\n};\n\n/**\n * Get or create the bQuery Trusted Types policy.\n * @returns The Trusted Types policy or null if unsupported\n */\nexport const getTrustedTypesPolicy = (): TrustedTypePolicy | null => {\n if (cachedPolicy) return cachedPolicy;\n if (policyInitAttempted) return null;\n\n if (typeof window === 'undefined') return null;\n\n const win = window as TrustedTypesWindow;\n if (!win.trustedTypes) return null;\n\n policyInitAttempted = true;\n\n try {\n cachedPolicy = win.trustedTypes.createPolicy(POLICY_NAME, {\n createHTML: (input: string) => sanitizeHtmlCore(input),\n });\n return cachedPolicy;\n } catch (error) {\n // Policy may already exist or be blocked by CSP\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.warn(`bQuery: Could not create Trusted Types policy \"${POLICY_NAME}\": ${errorMessage}`);\n return null;\n }\n};\n\n/**\n * Create a Trusted HTML value for use with Trusted Types-enabled sites.\n * Falls back to regular string when Trusted Types are unavailable.\n *\n * @param html - The HTML string to wrap\n * @returns Trusted HTML value or sanitized string\n */\nexport const createTrustedHtml = (html: string): TrustedHTML | string => {\n const policy = getTrustedTypesPolicy();\n if (policy) {\n return policy.createHTML(html);\n }\n return sanitizeHtmlCore(html);\n};\n","/**\n * Security utilities for HTML sanitization.\n * All DOM writes are sanitized by default to prevent XSS attacks.\n *\n * @module bquery/security\n */\n\nimport { sanitizeHtmlCore } from './sanitize-core';\nimport { toSanitizedHtml } from './trusted-html';\nimport type { SanitizedHtml } from './trusted-html';\nimport type { SanitizeOptions } from './types';\nexport { generateNonce } from './csp';\nexport { isTrustedTypesSupported } from './trusted-types';\nexport { trusted } from './trusted-html';\nexport type { SanitizedHtml, TrustedHtml } from './trusted-html';\n\n/**\n * Sanitize HTML string, removing dangerous elements and attributes.\n * Uses Trusted Types when available for CSP compliance.\n *\n * @param html - The HTML string to sanitize\n * @param options - Sanitization options\n * @returns Sanitized HTML string\n *\n * @example\n * ```ts\n * const safe = sanitizeHtml('<div onclick=\"alert(1)\">Hello</div>');\n * // Returns: '<div>Hello</div>'\n * ```\n */\nexport const sanitizeHtml = (html: string, options: SanitizeOptions = {}): SanitizedHtml => {\n return toSanitizedHtml(sanitizeHtmlCore(html, options));\n};\n\n/**\n * Escape HTML entities to prevent XSS.\n * Use this for displaying user content as text.\n *\n * @param text - The text to escape\n * @returns Escaped HTML string\n *\n * @example\n * ```ts\n * escapeHtml('<script>alert(1)</script>');\n * // Returns: '&lt;script&gt;alert(1)&lt;/script&gt;'\n * ```\n */\nexport const escapeHtml = (text: string): string => {\n const escapeMap: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#x27;',\n '`': '&#x60;',\n };\n return text.replace(/[&<>\"'`]/g, (char) => escapeMap[char]);\n};\n\n/**\n * Strip all HTML tags and return plain text.\n *\n * @param html - The HTML string to strip\n * @returns Plain text content\n */\nexport const stripTags = (html: string): string => {\n return sanitizeHtmlCore(html, { stripAllTags: true });\n};\n\nexport type { SanitizeOptions } from './types';\n"],"mappings":"AASA,IAAa,IAAc,oBAKd,IAAuB,oBAAI,IAAI;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;CACD,GAMY,IAAiB,oBAAI,IAAI;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA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AAGzB,MAFI,KAEA,OAAO,SAAW,IAAa,QAAO;AAE1C,QAAM,IAAM;AACZ,MAAI,CAAC,EAAI,aAAc,QAAO;AAE9B,EAAA,IAAsB;AAEtB,MAAI;AACF,WAAA,IAAe,EAAI,aAAa,aAAa,GAAa,EACxD,YAAA,CAAa,MAAkB,EAAiB,CAAA,EAAM,CACvD,GACM;AAAA,WACA,GAAO;AAEd,UAAM,IAAe,aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAA;AACrE,mBAAQ,KAAK,kDAAkD,CAAA,MAAiB,CAAA,EAAA,GACzE;AAAA;GAWE,IAAA,CAAqB,MAAuC;AACvE,QAAM,IAAS,EAAA;AACf,SAAI,IACK,EAAO,WAAW,CAAA,IAEpB,EAAiB,CAAA;GCrCb,IAAA,CAAgB,GAAc,IAA2B,CAAA,MAC7D,EAAgB,EAAiB,GAAM,CAAA,CAAQ,GAgB3C,KAAA,CAAc,MAAyB;AAClD,QAAM,IAAoC;AAAA,IACxC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA;AAEP,SAAO,EAAK,QAAQ,aAAA,CAAc,MAAS,EAAU,CAAA,CAAA;GAS1C,KAAA,CAAa,MACjB,EAAiB,GAAM,EAAE,cAAc,GAAA,CAAM"}
1
+ {"version":3,"file":"sanitize-DOMkRO9G.js","names":[],"sources":["../src/security/constants.ts","../src/security/sanitize-core.ts","../src/security/trusted-html.ts","../src/security/csp.ts","../src/security/trusted-types.ts","../src/security/sanitize.ts"],"sourcesContent":["/**\n * Security constants and safe lists.\n *\n * @module bquery/security\n */\n\n/**\n * Trusted Types policy name.\n */\nexport const POLICY_NAME = 'bquery-sanitizer';\n\n/**\n * Default allowed HTML tags considered safe.\n */\nexport const DEFAULT_ALLOWED_TAGS = new Set([\n 'a',\n 'abbr',\n 'address',\n 'article',\n 'aside',\n 'b',\n 'bdi',\n 'bdo',\n 'blockquote',\n 'br',\n 'button',\n 'caption',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'header',\n 'hgroup',\n 'hr',\n 'i',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'main',\n 'mark',\n 'nav',\n 'ol',\n 'optgroup',\n 'option',\n 'p',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'u',\n 'ul',\n 'var',\n 'wbr',\n]);\n\n/**\n * Explicitly dangerous tags that should never be allowed.\n * These are checked even if somehow added to allowTags.\n */\nexport const DANGEROUS_TAGS = new Set([\n 'script',\n 'iframe',\n 'frame',\n 'frameset',\n 'object',\n 'embed',\n 'applet',\n 'link',\n 'meta',\n 'style',\n 'base',\n 'template',\n // 'slot' is intentionally excluded here so component shadow markup can opt in\n // via sanitizeHtml(..., { allowTags: ['slot'] }). It remains disallowed by default\n // for general HTML writes, because DEFAULT_ALLOWED_TAGS does not include it.\n 'math',\n 'svg',\n 'foreignobject',\n 'noscript',\n]);\n\n/**\n * Reserved IDs that could cause DOM clobbering attacks.\n * These are prevented to avoid overwriting global browser objects.\n */\nexport const RESERVED_IDS = new Set([\n // Global objects\n 'document',\n 'window',\n 'location',\n 'top',\n 'self',\n 'parent',\n 'frames',\n 'history',\n 'navigator',\n 'screen',\n // Dangerous functions\n 'alert',\n 'confirm',\n 'prompt',\n 'eval',\n 'function',\n // Document properties\n 'cookie',\n 'domain',\n 'referrer',\n 'body',\n 'head',\n 'forms',\n 'images',\n 'links',\n 'scripts',\n // DOM traversal properties\n 'children',\n 'parentnode',\n 'firstchild',\n 'lastchild',\n // Content manipulation\n 'innerhtml',\n 'outerhtml',\n 'textcontent',\n]);\n\n/**\n * Default allowed attributes considered safe.\n * Note: 'style' is excluded by default because inline CSS can be abused for:\n * - UI redressing attacks\n * - Data exfiltration via url() in CSS\n * - CSS injection vectors\n * If you need to allow inline styles, add 'style' to allowAttributes in your\n * sanitizeHtml options, but ensure you implement proper CSS value validation.\n */\nexport const DEFAULT_ALLOWED_ATTRIBUTES = new Set([\n 'alt',\n 'class',\n 'dir',\n 'height',\n 'hidden',\n 'href',\n 'id',\n 'lang',\n 'loading',\n 'name',\n 'rel',\n 'role',\n 'src',\n 'srcset',\n 'tabindex',\n 'target',\n 'title',\n 'type',\n 'width',\n 'aria-*',\n]);\n\n/**\n * Dangerous attribute prefixes to always remove.\n */\nexport const DANGEROUS_ATTR_PREFIXES = ['on', 'formaction', 'xlink:', 'xmlns:'];\n\n/**\n * Dangerous URL protocols to block.\n */\nexport const DANGEROUS_PROTOCOLS = ['javascript:', 'data:', 'vbscript:', 'file:'];\n","/**\n * Core HTML sanitization logic.\n *\n * @module bquery/security\n * @internal\n */\n\nimport {\n DANGEROUS_ATTR_PREFIXES,\n DANGEROUS_PROTOCOLS,\n DANGEROUS_TAGS,\n DEFAULT_ALLOWED_ATTRIBUTES,\n DEFAULT_ALLOWED_TAGS,\n RESERVED_IDS,\n} from './constants';\nimport type { SanitizeOptions } from './types';\n\n/**\n * Check if an attribute name is allowed.\n * @internal\n */\nconst isAllowedAttribute = (\n name: string,\n allowedSet: Set<string>,\n allowDataAttrs: boolean\n): boolean => {\n const lowerName = name.toLowerCase();\n\n // Check dangerous prefixes\n for (const prefix of DANGEROUS_ATTR_PREFIXES) {\n if (lowerName.startsWith(prefix)) return false;\n }\n\n // Check data attributes\n if (allowDataAttrs && lowerName.startsWith('data-')) return true;\n\n // Check aria attributes (allowed by default)\n if (lowerName.startsWith('aria-')) return true;\n\n // Check explicit allow list\n return allowedSet.has(lowerName);\n};\n\n/**\n * Check if an ID/name value could cause DOM clobbering.\n * @internal\n */\nconst isSafeIdOrName = (value: string): boolean => {\n const lowerValue = value.toLowerCase().trim();\n return !RESERVED_IDS.has(lowerValue);\n};\n\n/**\n * Normalize URL by removing control characters, whitespace, and Unicode tricks.\n * Enhanced to prevent various bypass techniques.\n * @internal\n */\nconst normalizeUrl = (value: string): string =>\n value\n // Remove null bytes and control characters\n .replace(/[\\u0000-\\u001F\\u007F]+/g, '')\n // Remove zero-width characters that could hide malicious content\n .replace(/[\\u200B-\\u200D\\uFEFF\\u2028\\u2029]+/g, '')\n // Remove escaped Unicode sequences\n .replace(/\\\\u[\\da-fA-F]{4}/g, '')\n // Remove whitespace\n .replace(/\\s+/g, '')\n // Normalize case\n .toLowerCase();\n\n/**\n * Check if a URL value is safe.\n * @internal\n */\nconst isSafeUrl = (value: string): boolean => {\n const normalized = normalizeUrl(value);\n for (const protocol of DANGEROUS_PROTOCOLS) {\n if (normalized.startsWith(protocol)) return false;\n }\n return true;\n};\n\n/**\n * Check if a srcset attribute value is safe.\n * srcset contains comma-separated entries of \"url [descriptor]\".\n * Each individual URL must be validated.\n * @internal\n */\nconst isSafeSrcset = (value: string): boolean => {\n const entries = value.split(',');\n for (const entry of entries) {\n const url = entry.trim().split(/\\s+/)[0];\n if (url && !isSafeUrl(url)) return false;\n }\n return true;\n};\n\n/**\n * Check if a URL is external (different origin).\n * @internal\n */\nconst isExternalUrl = (url: string): boolean => {\n try {\n // Normalize URL by trimming whitespace\n const trimmedUrl = url.trim();\n\n // Protocol-relative URLs (//example.com) are always external.\n // CRITICAL: This check must run before the relative-URL check below;\n // otherwise, a protocol-relative URL like \"//evil.com\" would be treated\n // as a non-http(s) relative URL and incorrectly classified as same-origin.\n // Handling them up front guarantees correct security classification.\n if (trimmedUrl.startsWith('//')) {\n return true;\n }\n\n // Normalize URL for case-insensitive protocol checks\n const lowerUrl = trimmedUrl.toLowerCase();\n\n // Check for non-http(s) protocols which are considered external/special\n // (mailto:, tel:, ftp:, etc.)\n const hasProtocol = /^[a-z][a-z0-9+.-]*:/i.test(trimmedUrl);\n if (hasProtocol && !lowerUrl.startsWith('http://') && !lowerUrl.startsWith('https://')) {\n // These are special protocols, not traditional \"external\" links\n // but we treat them as external for security consistency\n return true;\n }\n\n // Relative URLs are not external\n if (!lowerUrl.startsWith('http://') && !lowerUrl.startsWith('https://')) {\n return false;\n }\n\n // In non-browser environments (e.g., Node.js), treat all absolute URLs as external\n if (typeof window === 'undefined' || !window.location) {\n return true;\n }\n\n const urlObj = new URL(trimmedUrl, window.location.href);\n return urlObj.origin !== window.location.origin;\n } catch {\n // If URL parsing fails, treat as potentially external for safety\n return true;\n }\n};\n\n/**\n * Parse an HTML string into a Document using DOMParser.\n * This helper is intentionally separated to make the control-flow around HTML parsing\n * explicit for static analysis tools. It should ONLY be called when the input is\n * known to contain HTML syntax (angle brackets).\n *\n * DOMParser creates an inert document where scripts don't execute, making it safe\n * for parsing untrusted HTML that will subsequently be sanitized.\n *\n * @param htmlContent - A string that is known to contain HTML markup (has < or >)\n * @returns The parsed Document\n * @internal\n */\nconst parseHtmlDocument = (htmlContent: string): Document => {\n const parser = new DOMParser();\n // Parse as a full HTML document in an inert context; scripts won't execute\n return parser.parseFromString(htmlContent, 'text/html');\n};\n\n/**\n * Safely parse HTML string into a DocumentFragment using DOMParser.\n * DOMParser is preferred over innerHTML for security as it creates an inert document\n * where scripts don't execute and provides better static analysis recognition.\n *\n * This function includes input normalization to satisfy static analysis tools:\n * - Coerces input to string and trims whitespace\n * - For plain text (no HTML tags), creates a Text node directly without parsing\n * - Only invokes DOMParser for actual HTML-like content via parseHtmlDocument\n *\n * The separation between plain text handling and HTML parsing is intentional:\n * DOM text that contains no HTML syntax is never fed into an HTML parser,\n * preventing \"DOM text reinterpreted as HTML\" issues.\n *\n * @internal\n */\nconst parseHtmlSafely = (html: string): DocumentFragment => {\n // Step 1: Normalize input - coerce to string and trim\n // This defensive check handles edge cases even though TypeScript says it's a string\n const normalizedHtml = (typeof html === 'string' ? html : String(html ?? '')).trim();\n\n // Step 2: Create the fragment that will hold our result\n const fragment = document.createDocumentFragment();\n\n // Step 3: Early return for empty input\n if (normalizedHtml.length === 0) {\n return fragment;\n }\n\n // Step 4: If input contains no angle brackets, it's plain text - no HTML parsing needed.\n // Plain text is handled as a Text node, never passed to an HTML parser.\n // This explicitly prevents \"DOM text reinterpreted as HTML\" for purely textual inputs.\n const containsHtmlSyntax = normalizedHtml.includes('<') || normalizedHtml.includes('>');\n if (!containsHtmlSyntax) {\n fragment.appendChild(document.createTextNode(normalizedHtml));\n return fragment;\n }\n\n // Step 5: Input contains HTML syntax - parse it via the dedicated HTML parsing helper.\n // This separation makes the data-flow explicit: only strings with HTML syntax\n // are passed to DOMParser, satisfying static analysis requirements.\n const doc = parseHtmlDocument(normalizedHtml);\n\n // Move all children from the document body into the fragment.\n // This avoids interpolating untrusted HTML into an outer wrapper string.\n const body = doc.body;\n\n if (!body) {\n return fragment;\n }\n\n while (body.firstChild) {\n fragment.appendChild(body.firstChild);\n }\n\n return fragment;\n};\n\n/**\n * Core sanitization logic (without Trusted Types wrapper).\n * @internal\n */\nexport const sanitizeHtmlCore = (html: string, options: SanitizeOptions = {}): string => {\n const {\n allowTags = [],\n allowAttributes = [],\n allowDataAttributes = true,\n stripAllTags = false,\n } = options;\n\n // Build combined allow sets (excluding dangerous tags even if specified)\n const allowedTags = new Set(\n [...DEFAULT_ALLOWED_TAGS, ...allowTags.map((t) => t.toLowerCase())].filter(\n (tag) => !DANGEROUS_TAGS.has(tag)\n )\n );\n const allowedAttrs = new Set([\n ...DEFAULT_ALLOWED_ATTRIBUTES,\n ...allowAttributes.map((a) => a.toLowerCase()),\n ]);\n\n // Use DOMParser for safe HTML parsing (inert context, no script execution)\n const fragment = parseHtmlSafely(html);\n\n if (stripAllTags) {\n return fragment.textContent ?? '';\n }\n\n // Walk the DOM tree\n const walker = document.createTreeWalker(fragment, NodeFilter.SHOW_ELEMENT);\n\n const toRemove: Element[] = [];\n\n while (walker.nextNode()) {\n const el = walker.currentNode as Element;\n const tagName = el.tagName.toLowerCase();\n\n // Remove explicitly dangerous tags even if in allow list\n if (DANGEROUS_TAGS.has(tagName)) {\n toRemove.push(el);\n continue;\n }\n\n // Remove disallowed tags entirely\n if (!allowedTags.has(tagName)) {\n toRemove.push(el);\n continue;\n }\n\n // Process attributes\n const attrsToRemove: string[] = [];\n for (const attr of Array.from(el.attributes)) {\n const attrName = attr.name.toLowerCase();\n\n // Check if attribute is allowed\n if (!isAllowedAttribute(attrName, allowedAttrs, allowDataAttributes)) {\n attrsToRemove.push(attr.name);\n continue;\n }\n\n // Check for DOM clobbering on id and name attributes\n if ((attrName === 'id' || attrName === 'name') && !isSafeIdOrName(attr.value)) {\n attrsToRemove.push(attr.name);\n continue;\n }\n\n // Validate URL attributes\n if (\n (attrName === 'href' || attrName === 'src' || attrName === 'action') &&\n !isSafeUrl(attr.value)\n ) {\n attrsToRemove.push(attr.name);\n continue;\n }\n\n // Validate srcset URLs individually\n if (attrName === 'srcset' && !isSafeSrcset(attr.value)) {\n attrsToRemove.push(attr.name);\n }\n }\n\n // Remove disallowed attributes\n for (const attrName of attrsToRemove) {\n el.removeAttribute(attrName);\n }\n\n // Add rel=\"noopener noreferrer\" to external links for security\n if (tagName === 'a') {\n const href = el.getAttribute('href');\n const target = el.getAttribute('target');\n const hasTargetBlank = target?.toLowerCase() === '_blank';\n const isExternal = href && isExternalUrl(href);\n\n // Add security attributes to links opening in new window or external links\n if (hasTargetBlank || isExternal) {\n const existingRel = el.getAttribute('rel');\n const relValues = new Set(existingRel ? existingRel.split(/\\s+/).filter(Boolean) : []);\n\n // Add noopener and noreferrer\n relValues.add('noopener');\n relValues.add('noreferrer');\n\n el.setAttribute('rel', Array.from(relValues).join(' '));\n }\n }\n }\n\n // Remove disallowed elements\n for (const el of toRemove) {\n el.remove();\n }\n\n // Serialize the sanitized fragment to HTML string.\n // We use a temporary container to get the innerHTML of the fragment.\n const serializeFragment = (frag: DocumentFragment): string => {\n const container = document.createElement('div');\n container.appendChild(frag.cloneNode(true));\n return container.innerHTML;\n };\n\n // Double-parse to prevent mutation XSS (mXSS).\n // Browsers may normalize HTML during serialization in ways that could create\n // new dangerous content when re-parsed. By re-parsing the sanitized output\n // and verifying stability, we ensure the final HTML is safe.\n const firstPass = serializeFragment(fragment);\n\n // Re-parse through DOMParser for mXSS detection.\n // Using DOMParser instead of innerHTML for security.\n const verifyFragment = parseHtmlSafely(firstPass);\n const secondPass = serializeFragment(verifyFragment);\n\n // Verify stability: if content mutates between parses, it indicates mXSS attempt\n if (firstPass !== secondPass) {\n // Content mutated during re-parse - potential mXSS detected.\n // Return safely escaped text content as fallback.\n return fragment.textContent ?? '';\n }\n\n return secondPass;\n};\n","declare const sanitizedHtmlBrand: unique symbol;\nconst trustedHtmlBrand: unique symbol = Symbol('bquery.trusted-html.brand');\nconst TRUSTED_HTML_VALUE = Symbol('bquery.trusted-html');\n\n/**\n * Branded HTML string produced by bQuery's sanitization or escaping template helpers.\n *\n * Values returned from {@link sanitizeHtml} carry sanitized markup. Values returned from\n * {@link safeHtml} preserve the template's static markup while escaping normal interpolations\n * and splicing {@link trusted} fragments verbatim. This brand is not intended for arbitrary\n * strings or manual concatenation outside those helpers.\n */\nexport type SanitizedHtml = string & { readonly [sanitizedHtmlBrand]: true };\n\n/**\n * Marker object that safeHtml can splice into templates without escaping again.\n */\nexport type TrustedHtml = { readonly [trustedHtmlBrand]: true; toString(): string };\n\ntype TrustedHtmlValue = TrustedHtml & { readonly [TRUSTED_HTML_VALUE]: string };\n\n/**\n * Apply the internal {@link SanitizedHtml} brand to helper output.\n *\n * @internal\n */\nexport const toSanitizedHtml = (html: string): SanitizedHtml => html as SanitizedHtml;\n\n/**\n * Mark a sanitized HTML string for verbatim splicing into safeHtml templates.\n *\n * @param html - HTML previously produced by sanitizeHtml, safeHtml, or another trusted bQuery helper\n * @returns Trusted HTML marker object for safeHtml interpolations\n *\n * @example\n * ```ts\n * const badge = trusted(sanitizeHtml('<strong onclick=\"alert(1)\">New</strong>'));\n * const markup = safeHtml`<span>${badge}</span>`;\n * ```\n */\nexport const trusted = (html: SanitizedHtml): TrustedHtml => {\n const value = String(html);\n return Object.freeze({\n [trustedHtmlBrand]: true as const,\n [TRUSTED_HTML_VALUE]: value,\n toString: () => value,\n });\n};\n\n/**\n * Check whether a value is a trusted HTML marker created by trusted().\n *\n * @internal\n */\nexport const isTrustedHtml = (value: unknown): value is TrustedHtml => {\n return (\n typeof value === 'object' &&\n value !== null &&\n trustedHtmlBrand in value &&\n TRUSTED_HTML_VALUE in value\n );\n};\n\n/**\n * Unwrap the raw HTML string stored inside a trusted HTML marker.\n *\n * @internal\n */\nexport const unwrapTrustedHtml = (value: TrustedHtml): string => {\n return (value as TrustedHtmlValue)[TRUSTED_HTML_VALUE];\n};\n","/**\n * Content Security Policy helpers.\n *\n * @module bquery/security\n */\n\n/** Maximum allowed nonce length to prevent memory issues */\nconst MAX_NONCE_LENGTH = 1024;\n\n/** Chunk size for building strings to avoid argument limit in String.fromCharCode */\nconst CHUNK_SIZE = 8192;\n\n/**\n * Generate a nonce for inline scripts/styles.\n * Use with Content-Security-Policy nonce directives.\n *\n * @param length - Nonce length in bytes (default: 16, max: 1024)\n * @returns Cryptographically random nonce string\n * @throws {Error} If crypto.getRandomValues or btoa are not available\n * @throws {RangeError} If length is invalid (negative, non-integer, or exceeds maximum)\n */\nexport const generateNonce = (length: number = 16): string => {\n // Validate length parameter\n if (!Number.isInteger(length) || length < 1) {\n throw new RangeError('generateNonce length must be a positive integer');\n }\n if (length > MAX_NONCE_LENGTH) {\n throw new RangeError(`generateNonce length must not exceed ${MAX_NONCE_LENGTH}`);\n }\n\n // Check for required globals in browser/crypto environments\n if (\n typeof globalThis.crypto === 'undefined' ||\n typeof globalThis.crypto.getRandomValues !== 'function'\n ) {\n throw new Error(\n 'generateNonce requires crypto.getRandomValues (not available in this environment)'\n );\n }\n if (typeof globalThis.btoa !== 'function') {\n throw new Error('generateNonce requires btoa (not available in this environment)');\n }\n\n const array = new Uint8Array(length);\n globalThis.crypto.getRandomValues(array);\n\n // Build string in chunks to avoid argument limit in String.fromCharCode\n let binaryString = '';\n for (let i = 0; i < array.length; i += CHUNK_SIZE) {\n const chunk = array.subarray(i, Math.min(i + CHUNK_SIZE, array.length));\n binaryString += String.fromCharCode(...chunk);\n }\n\n return globalThis.btoa(binaryString).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n};\n\n/**\n * Check if a CSP header is present with specific directive.\n * Useful for feature detection and fallback strategies.\n *\n * @param directive - The CSP directive to check (e.g., 'script-src')\n * @returns True if the directive appears to be enforced\n */\nexport const hasCSPDirective = (directive: string): boolean => {\n // Guard for non-DOM environments (SSR, tests, etc.)\n if (typeof document === 'undefined') {\n return false;\n }\n\n // Check meta tag\n const meta = document.querySelector('meta[http-equiv=\"Content-Security-Policy\"]');\n if (meta) {\n const content = meta.getAttribute('content') ?? '';\n return content.includes(directive);\n }\n return false;\n};\n","/**\n * Trusted Types helpers for CSP compatibility.\n *\n * @module bquery/security\n */\n\nimport { POLICY_NAME } from './constants';\nimport { sanitizeHtmlCore } from './sanitize-core';\nimport type { TrustedHTML, TrustedTypePolicy, TrustedTypesWindow } from './types';\n\n/** Cached Trusted Types policy */\nlet cachedPolicy: TrustedTypePolicy | null = null;\n\n/** Whether policy initialization has been attempted (to avoid retry spam) */\nlet policyInitAttempted = false;\n\n/**\n * Check if Trusted Types API is available.\n * @returns True if Trusted Types are supported\n */\nexport const isTrustedTypesSupported = (): boolean => {\n return (\n typeof window !== 'undefined' &&\n typeof (window as TrustedTypesWindow).trustedTypes !== 'undefined'\n );\n};\n\n/**\n * Get or create the bQuery Trusted Types policy.\n * @returns The Trusted Types policy or null if unsupported\n */\nexport const getTrustedTypesPolicy = (): TrustedTypePolicy | null => {\n if (cachedPolicy) return cachedPolicy;\n if (policyInitAttempted) return null;\n\n if (typeof window === 'undefined') return null;\n\n const win = window as TrustedTypesWindow;\n if (!win.trustedTypes) return null;\n\n policyInitAttempted = true;\n\n try {\n cachedPolicy = win.trustedTypes.createPolicy(POLICY_NAME, {\n createHTML: (input: string) => sanitizeHtmlCore(input),\n });\n return cachedPolicy;\n } catch (error) {\n // Policy may already exist or be blocked by CSP\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.warn(`bQuery: Could not create Trusted Types policy \"${POLICY_NAME}\": ${errorMessage}`);\n return null;\n }\n};\n\n/**\n * Create a Trusted HTML value for use with Trusted Types-enabled sites.\n * Falls back to regular string when Trusted Types are unavailable.\n *\n * @param html - The HTML string to wrap\n * @returns Trusted HTML value or sanitized string\n */\nexport const createTrustedHtml = (html: string): TrustedHTML | string => {\n const policy = getTrustedTypesPolicy();\n if (policy) {\n return policy.createHTML(html);\n }\n return sanitizeHtmlCore(html);\n};\n","/**\n * Security utilities for HTML sanitization.\n * All DOM writes are sanitized by default to prevent XSS attacks.\n *\n * @module bquery/security\n */\n\nimport { sanitizeHtmlCore } from './sanitize-core';\nimport { toSanitizedHtml } from './trusted-html';\nimport type { SanitizedHtml } from './trusted-html';\nimport type { SanitizeOptions } from './types';\nexport { generateNonce } from './csp';\nexport { isTrustedTypesSupported } from './trusted-types';\nexport { trusted } from './trusted-html';\nexport type { SanitizedHtml, TrustedHtml } from './trusted-html';\n\n/**\n * Sanitize HTML string, removing dangerous elements and attributes.\n * Uses Trusted Types when available for CSP compliance.\n *\n * @param html - The HTML string to sanitize\n * @param options - Sanitization options\n * @returns Sanitized HTML string\n *\n * @example\n * ```ts\n * const safe = sanitizeHtml('<div onclick=\"alert(1)\">Hello</div>');\n * // Returns: '<div>Hello</div>'\n * ```\n */\nexport const sanitizeHtml = (html: string, options: SanitizeOptions = {}): SanitizedHtml => {\n return toSanitizedHtml(sanitizeHtmlCore(html, options));\n};\n\n/**\n * Escape HTML entities to prevent XSS.\n * Use this for displaying user content as text.\n *\n * @param text - The text to escape\n * @returns Escaped HTML string\n *\n * @example\n * ```ts\n * escapeHtml('<script>alert(1)</script>');\n * // Returns: '&lt;script&gt;alert(1)&lt;/script&gt;'\n * ```\n */\nexport const escapeHtml = (text: string): string => {\n const escapeMap: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#x27;',\n '`': '&#x60;',\n };\n return text.replace(/[&<>\"'`]/g, (char) => escapeMap[char]);\n};\n\n/**\n * Strip all HTML tags and return plain text.\n *\n * @param html - The HTML string to strip\n * @returns Plain text content\n */\nexport const stripTags = (html: string): string => {\n return sanitizeHtmlCore(html, { stripAllTags: true });\n};\n\nexport type { SanitizeOptions } from './types';\n"],"mappings":"AASA,IAAa,IAAc,oBAKd,IAAuB,oBAAI,IAAI;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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D,MAAI,OAAO,WAAa,IACtB,QAAO;AAIT,QAAM,IAAO,SAAS,cAAc,4CAAA;AACpC,SAAI,KACc,EAAK,aAAa,SAAA,KAAc,IACjC,SAAS,CAAA,IAEnB;GChEL,IAAyC,MAGzC,IAAsB,IAMb,IAAA,MAET,OAAO,SAAW,OAClB,OAAQ,OAA8B,eAAiB,KAQ9C,IAAA,MAAwD;AACnE,MAAI,EAAc,QAAO;AAGzB,MAFI,KAEA,OAAO,SAAW,IAAa,QAAO;AAE1C,QAAM,IAAM;AACZ,MAAI,CAAC,EAAI,aAAc,QAAO;AAE9B,EAAA,IAAsB;AAEtB,MAAI;AACF,WAAA,IAAe,EAAI,aAAa,aAAa,GAAa,EACxD,YAAA,CAAa,MAAkB,EAAiB,CAAA,EAAM,CACvD,GACM;AAAA,WACA,GAAO;AAEd,UAAM,IAAe,aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAA;AACrE,mBAAQ,KAAK,kDAAkD,CAAA,MAAiB,CAAA,EAAA,GACzE;AAAA;GAWE,IAAA,CAAqB,MAAuC;AACvE,QAAM,IAAS,EAAA;AACf,SAAI,IACK,EAAO,WAAW,CAAA,IAEpB,EAAiB,CAAA;GCrCb,IAAA,CAAgB,GAAc,IAA2B,CAAA,MAC7D,EAAgB,EAAiB,GAAM,CAAA,CAAQ,GAgB3C,KAAA,CAAc,MAAyB;AAClD,QAAM,IAAoC;AAAA,IACxC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA;AAEP,SAAO,EAAK,QAAQ,aAAA,CAAc,MAAS,EAAU,CAAA,CAAA;GAS1C,KAAA,CAAa,MACjB,EAAiB,GAAM,EAAE,cAAc,GAAA,CAAM"}
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, d as a, i as r, n as i, o as p, r as o, s as c, t as d } from "./sanitize-B1V4JswB.js";
1
+ import { a as e, c as t, d as a, i as r, n as i, o as p, r as o, s as c, t as d } from "./sanitize-DOMkRO9G.js";
2
2
  export {
3
3
  r as createTrustedHtml,
4
4
  d as escapeHtml,
@@ -0,0 +1,25 @@
1
+ import type { CreateServerOptions, ServerApp, ServerWebSocketSession } from './types';
2
+ /**
3
+ * Returns `true` when the request is a WebSocket upgrade handshake.
4
+ */
5
+ export declare const isWebSocketRequest: (request: Request) => boolean;
6
+ /**
7
+ * Type guard for values returned by `handleWebSocket()`.
8
+ */
9
+ export declare const isServerWebSocketSession: (value: unknown) => value is ServerWebSocketSession;
10
+ /**
11
+ * Create a lightweight, Express-inspired request pipeline for SSR-aware
12
+ * backends without introducing runtime dependencies.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { createServer } from '@bquery/bquery/server';
17
+ *
18
+ * const app = createServer();
19
+ * app.get('/health', (ctx) => ctx.json({ ok: true }));
20
+ *
21
+ * const response = await app.handle('/health');
22
+ * ```
23
+ */
24
+ export declare const createServer: (options?: CreateServerOptions) => ServerApp;
25
+ //# sourceMappingURL=create-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../../src/server/create-server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,SAAS,EAkBT,sBAAsB,EACvB,MAAM,SAAS,CAAC;AA+PjB;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,OAAO,KAAG,OA0BrD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,sBAYlE,CAAC;AA8NF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GAAI,UAAS,mBAAwB,KAAG,SAgMhE,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Lightweight backend helpers for bQuery.js.
3
+ *
4
+ * Provides an Express-inspired middleware and routing layer that stays
5
+ * dependency-free, tree-shakeable, and SSR-aware.
6
+ *
7
+ * @module bquery/server
8
+ */
9
+ export { createServer, isServerWebSocketSession, isWebSocketRequest } from './create-server';
10
+ export type { CreateServerOptions, ServerApp, ServerContext, ServerHandler, ServerResult, ServerHtmlResponseInit, ServerMiddleware, ServerNext, ServerQuery, ServerRenderResponseOptions, ServerRequestInit, ServerResponseInit, ServerRoute, ServerWebSocketConnection, ServerWebSocketData, ServerWebSocketHandlerSet, ServerWebSocketMiddleware, ServerWebSocketNext, ServerWebSocketPeer, ServerWebSocketRouteHandler, ServerWebSocketSession, } from './types';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,YAAY,EACV,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,2BAA2B,EAC3B,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,396 @@
1
+ import type { RenderOptions } from '../ssr/index';
2
+ import type { BindingContext } from '../view/index';
3
+ /**
4
+ * Repeated query parameters are represented as arrays.
5
+ */
6
+ export interface ServerQuery {
7
+ [key: string]: string | string[] | undefined;
8
+ }
9
+ /**
10
+ * Lightweight request input accepted by `handle()`.
11
+ */
12
+ export interface ServerRequestInit {
13
+ /**
14
+ * Request URL or path.
15
+ *
16
+ * Relative paths are resolved against `CreateServerOptions.baseUrl`.
17
+ */
18
+ url: string | URL;
19
+ /**
20
+ * HTTP method.
21
+ * @default 'GET'
22
+ */
23
+ method?: string;
24
+ /**
25
+ * Request headers.
26
+ */
27
+ headers?: HeadersInit;
28
+ /**
29
+ * Optional request body.
30
+ */
31
+ body?: BodyInit | null;
32
+ }
33
+ /**
34
+ * Shared response options used by server helpers.
35
+ */
36
+ export interface ServerResponseInit extends ResponseInit {
37
+ headers?: HeadersInit;
38
+ }
39
+ /**
40
+ * HTML response options.
41
+ */
42
+ export interface ServerHtmlResponseInit extends ServerResponseInit {
43
+ /**
44
+ * When `true`, the HTML string is assumed to be already safe and is returned
45
+ * without additional sanitization.
46
+ * @default false
47
+ */
48
+ trusted?: boolean;
49
+ }
50
+ /**
51
+ * SSR response options.
52
+ */
53
+ export interface ServerRenderResponseOptions extends RenderOptions {
54
+ /**
55
+ * HTTP status to use for the response.
56
+ * @default 200
57
+ */
58
+ status?: number;
59
+ /**
60
+ * Additional response headers.
61
+ */
62
+ headers?: HeadersInit;
63
+ }
64
+ /**
65
+ * Binary/text payloads accepted by server-side WebSocket peers and sessions.
66
+ *
67
+ * Use this for raw frames sent through `socket.send(...)`.
68
+ */
69
+ export type ServerWebSocketData = string | Blob | ArrayBufferLike | ArrayBufferView;
70
+ /**
71
+ * Minimal runtime WebSocket peer shape consumed by server-side WebSocket sessions.
72
+ */
73
+ export interface ServerWebSocketPeer {
74
+ /**
75
+ * Negotiated sub-protocol, when available.
76
+ */
77
+ protocol?: string;
78
+ /**
79
+ * Current readyState, when the runtime exposes it.
80
+ */
81
+ readyState?: number;
82
+ /**
83
+ * Remote URL, when the runtime exposes it.
84
+ */
85
+ url?: string;
86
+ /**
87
+ * Send a raw payload to the connected peer.
88
+ */
89
+ send(data: ServerWebSocketData): void;
90
+ /**
91
+ * Close the connection.
92
+ */
93
+ close(code?: number, reason?: string): void;
94
+ }
95
+ /**
96
+ * Wrapped WebSocket connection exposed to route handlers.
97
+ */
98
+ export interface ServerWebSocketConnection extends ServerWebSocketPeer {
99
+ /**
100
+ * Serialize a value with `JSON.stringify()` and send it to the peer.
101
+ */
102
+ sendJson(data: unknown): void;
103
+ }
104
+ /**
105
+ * Request/response context passed through the server pipeline.
106
+ */
107
+ export interface ServerContext {
108
+ /**
109
+ * Normalized `Request` instance.
110
+ */
111
+ request: Request;
112
+ /**
113
+ * Parsed URL for the current request.
114
+ */
115
+ url: URL;
116
+ /**
117
+ * Uppercase HTTP method.
118
+ */
119
+ method: string;
120
+ /**
121
+ * Pathname without query string.
122
+ */
123
+ path: string;
124
+ /**
125
+ * Route params captured from `:param` path segments.
126
+ */
127
+ params: Record<string, string>;
128
+ /**
129
+ * Parsed query object. Repeated keys become arrays.
130
+ */
131
+ query: ServerQuery;
132
+ /**
133
+ * Per-request mutable state bag for middleware communication.
134
+ */
135
+ state: Record<string, unknown>;
136
+ /**
137
+ * Create a raw `Response`.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * return ctx.response('Created', { status: 201 });
142
+ * ```
143
+ */
144
+ response(body?: BodyInit | null, init?: ServerResponseInit): Response;
145
+ /**
146
+ * Create a plain-text response.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * return ctx.text('ok');
151
+ * ```
152
+ */
153
+ text(body: string, init?: ServerResponseInit): Response;
154
+ /**
155
+ * Create a sanitized HTML response by default.
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * return ctx.html('<h1>Hello</h1>');
160
+ * ```
161
+ */
162
+ html(body: string, init?: ServerHtmlResponseInit): Response;
163
+ /**
164
+ * Create a JSON response.
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * return ctx.json({ ok: true });
169
+ * ```
170
+ */
171
+ json(data: unknown, init?: ServerResponseInit): Response;
172
+ /**
173
+ * Create a redirect response.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * return ctx.redirect('/login', 302);
178
+ * ```
179
+ */
180
+ redirect(location: string | URL, status?: number): Response;
181
+ /**
182
+ * Render a bQuery SSR template into an HTML response.
183
+ *
184
+ * @example
185
+ * ```ts
186
+ * return ctx.render('<h1 bq-text="title"></h1>', { title: 'Dashboard' });
187
+ * ```
188
+ */
189
+ render(template: string, data: BindingContext, options?: ServerRenderResponseOptions): Response;
190
+ /**
191
+ * `true` when the incoming request is a WebSocket upgrade handshake.
192
+ */
193
+ isWebSocketRequest: boolean;
194
+ }
195
+ /**
196
+ * Final request handler.
197
+ */
198
+ export interface ServerHandler {
199
+ (context: ServerContext): Response | Promise<Response>;
200
+ }
201
+ /**
202
+ * WebSocket route lifecycle callbacks.
203
+ */
204
+ export interface ServerWebSocketHandlerSet<TReceive = unknown> {
205
+ /**
206
+ * Requested sub-protocols for the handshake.
207
+ */
208
+ protocols?: string | string[];
209
+ /**
210
+ * Additional handshake headers used by compatible runtimes.
211
+ */
212
+ headers?: HeadersInit;
213
+ /**
214
+ * Deserialize incoming WebSocket messages.
215
+ *
216
+ * Defaults to JSON.parse for string payloads with a raw-string fallback.
217
+ */
218
+ deserialize?: (event: MessageEvent) => TReceive;
219
+ /**
220
+ * Called after the runtime accepts the upgrade.
221
+ */
222
+ onOpen?: (socket: ServerWebSocketConnection, context: ServerContext) => void | Promise<void>;
223
+ /**
224
+ * Called for each incoming message after deserialization.
225
+ */
226
+ onMessage?: (data: TReceive, socket: ServerWebSocketConnection, context: ServerContext, event: MessageEvent) => void | Promise<void>;
227
+ /**
228
+ * Called when the connection closes.
229
+ */
230
+ onClose?: (event: CloseEvent, socket: ServerWebSocketConnection, context: ServerContext) => void | Promise<void>;
231
+ /**
232
+ * Called when the runtime reports a socket error.
233
+ */
234
+ onError?: (event: Event, socket: ServerWebSocketConnection, context: ServerContext) => void | Promise<void>;
235
+ }
236
+ /**
237
+ * WebSocket route definition or per-request factory.
238
+ */
239
+ export type ServerWebSocketRouteHandler<TReceive = unknown> = ServerWebSocketHandlerSet<TReceive> | ((context: ServerContext) => ServerWebSocketHandlerSet<TReceive> | Promise<ServerWebSocketHandlerSet<TReceive>>);
240
+ /**
241
+ * Runtime-agnostic WebSocket session returned by `handleWebSocket()`.
242
+ */
243
+ export interface ServerWebSocketSession {
244
+ /**
245
+ * Request context captured during route matching and middleware execution.
246
+ */
247
+ context: ServerContext;
248
+ /**
249
+ * Normalized requested sub-protocols.
250
+ */
251
+ protocols: string[];
252
+ /**
253
+ * Additional handshake headers requested by the route.
254
+ */
255
+ headers?: HeadersInit;
256
+ /**
257
+ * Notify the session that the runtime accepted the connection.
258
+ */
259
+ open(socket: ServerWebSocketPeer): Promise<void>;
260
+ /**
261
+ * Deliver an incoming message event to the session.
262
+ */
263
+ message(socket: ServerWebSocketPeer, event: MessageEvent): Promise<void>;
264
+ /**
265
+ * Notify the session about a close event.
266
+ */
267
+ close(socket: ServerWebSocketPeer, event: CloseEvent): Promise<void>;
268
+ /**
269
+ * Notify the session about a socket error.
270
+ */
271
+ error(socket: ServerWebSocketPeer, event: Event): Promise<void>;
272
+ }
273
+ /**
274
+ * Result type used by middleware and WebSocket handling.
275
+ */
276
+ export type ServerResult = Response | ServerWebSocketSession | null;
277
+ /**
278
+ * Middleware continuation callback.
279
+ */
280
+ export interface ServerNext {
281
+ (): Promise<Response>;
282
+ }
283
+ /**
284
+ * Express-inspired middleware for request pipelines.
285
+ */
286
+ export interface ServerMiddleware {
287
+ (context: ServerContext, next: ServerNext): Response | Promise<Response>;
288
+ }
289
+ /**
290
+ * WebSocket middleware continuation callback.
291
+ */
292
+ export interface ServerWebSocketNext {
293
+ (): Promise<ServerResult>;
294
+ }
295
+ /**
296
+ * Middleware used by WebSocket routes.
297
+ */
298
+ export interface ServerWebSocketMiddleware {
299
+ (context: ServerContext, next: ServerWebSocketNext): ServerResult | Promise<ServerResult>;
300
+ }
301
+ /**
302
+ * Route definition used by `add()`.
303
+ */
304
+ export interface ServerRoute {
305
+ /**
306
+ * Route path. Supports static segments, `:params`, and terminal `*`.
307
+ */
308
+ path: string;
309
+ /**
310
+ * One or many HTTP methods. Omit for "all methods".
311
+ */
312
+ method?: string | string[];
313
+ /**
314
+ * Optional route-scoped middleware.
315
+ */
316
+ middlewares?: ServerMiddleware[];
317
+ /**
318
+ * Final route handler.
319
+ */
320
+ handler: ServerHandler;
321
+ }
322
+ /**
323
+ * Configures a server instance.
324
+ */
325
+ export interface CreateServerOptions {
326
+ /**
327
+ * Base URL used to resolve relative request paths.
328
+ * @default 'http://localhost'
329
+ */
330
+ baseUrl?: string;
331
+ /**
332
+ * Global middleware applied to every request.
333
+ */
334
+ middlewares?: ServerMiddleware[];
335
+ /**
336
+ * Custom 404 handler.
337
+ */
338
+ notFound?: ServerHandler;
339
+ /**
340
+ * Custom error handler.
341
+ */
342
+ onError?: (error: unknown, context: ServerContext) => Response | Promise<Response>;
343
+ }
344
+ /**
345
+ * Express-inspired app-like server handle.
346
+ */
347
+ export interface ServerApp {
348
+ /**
349
+ * Register global middleware.
350
+ */
351
+ use(middleware: ServerMiddleware): ServerApp;
352
+ /**
353
+ * Add a fully specified route.
354
+ */
355
+ add(route: ServerRoute): ServerApp;
356
+ /**
357
+ * Register a GET route.
358
+ */
359
+ get(path: string, handler: ServerHandler, middlewares?: ServerMiddleware[]): ServerApp;
360
+ /**
361
+ * Register a POST route.
362
+ */
363
+ post(path: string, handler: ServerHandler, middlewares?: ServerMiddleware[]): ServerApp;
364
+ /**
365
+ * Register a PUT route.
366
+ */
367
+ put(path: string, handler: ServerHandler, middlewares?: ServerMiddleware[]): ServerApp;
368
+ /**
369
+ * Register a PATCH route.
370
+ */
371
+ patch(path: string, handler: ServerHandler, middlewares?: ServerMiddleware[]): ServerApp;
372
+ /**
373
+ * Register a DELETE route.
374
+ */
375
+ delete(path: string, handler: ServerHandler, middlewares?: ServerMiddleware[]): ServerApp;
376
+ /**
377
+ * Register a route that matches any method.
378
+ */
379
+ all(path: string, handler: ServerHandler, middlewares?: ServerMiddleware[]): ServerApp;
380
+ /**
381
+ * Register a WebSocket route.
382
+ */
383
+ ws<TReceive = unknown>(path: string, handler: ServerWebSocketRouteHandler<TReceive>, middlewares?: ServerWebSocketMiddleware[]): ServerApp;
384
+ /**
385
+ * Handle a normalized request.
386
+ */
387
+ handle(input: Request | string | URL | ServerRequestInit): Promise<Response>;
388
+ /**
389
+ * Resolve a WebSocket upgrade request into a runtime-agnostic session.
390
+ *
391
+ * Returns `null` when the request is not a WebSocket handshake or no matching
392
+ * WebSocket route exists. Middleware may also short-circuit with a `Response`.
393
+ */
394
+ handleWebSocket(input: Request | string | URL | ServerRequestInit): Promise<ServerResult>;
395
+ }
396
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,aAAa;IAChE;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,IAAI,GAA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