@ohos-ports/html2canvas-pro 0.0.0-stage → 2.3.2-beta.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.
- package/LICENSE +21 -0
- package/README.md +86 -2
- package/dist/html2canvas-pro.cjs +11191 -0
- package/dist/html2canvas-pro.cjs.map +1 -0
- package/dist/html2canvas-pro.esm.js +11182 -0
- package/dist/html2canvas-pro.esm.js.map +1 -0
- package/dist/html2canvas-pro.js +11196 -0
- package/dist/html2canvas-pro.js.map +1 -0
- package/dist/html2canvas-pro.min.js +10 -0
- package/dist/lib/config.js +49 -0
- package/dist/lib/core/abort-helper.js +20 -0
- package/dist/lib/core/background-parser.js +41 -0
- package/dist/lib/core/bitwise.js +5 -0
- package/dist/lib/core/cache-storage.js +268 -0
- package/dist/lib/core/config-assembler.js +88 -0
- package/dist/lib/core/constants.js +25 -0
- package/dist/lib/core/context.js +19 -0
- package/dist/lib/core/debugger.js +27 -0
- package/dist/lib/core/features.js +190 -0
- package/dist/lib/core/logger.js +56 -0
- package/dist/lib/core/lru-map.js +66 -0
- package/dist/lib/core/origin-checker.js +53 -0
- package/dist/lib/core/performance-monitor.js +185 -0
- package/dist/lib/core/render-element.js +132 -0
- package/dist/lib/core/util.js +4 -0
- package/dist/lib/core/validator.js +500 -0
- package/dist/lib/css/grouped/background-styles.js +36 -0
- package/dist/lib/css/grouped/border-styles.js +75 -0
- package/dist/lib/css/grouped/font-styles.js +93 -0
- package/dist/lib/css/grouped/layout-styles.js +127 -0
- package/dist/lib/css/index.js +330 -0
- package/dist/lib/css/layout/bounds.js +52 -0
- package/dist/lib/css/layout/text.js +133 -0
- package/dist/lib/css/property-descriptor.js +2 -0
- package/dist/lib/css/property-descriptors/background-blend-mode.js +41 -0
- package/dist/lib/css/property-descriptors/background-clip.js +23 -0
- package/dist/lib/css/property-descriptors/background-color.js +10 -0
- package/dist/lib/css/property-descriptors/background-image.js +24 -0
- package/dist/lib/css/property-descriptors/background-origin.js +23 -0
- package/dist/lib/css/property-descriptors/background-position.js +19 -0
- package/dist/lib/css/property-descriptors/background-repeat.js +33 -0
- package/dist/lib/css/property-descriptors/background-size.js +23 -0
- package/dist/lib/css/property-descriptors/border-color.js +14 -0
- package/dist/lib/css/property-descriptors/border-image-repeat.js +42 -0
- package/dist/lib/css/property-descriptors/border-image-slice.js +45 -0
- package/dist/lib/css/property-descriptors/border-image-source.js +22 -0
- package/dist/lib/css/property-descriptors/border-radius.js +15 -0
- package/dist/lib/css/property-descriptors/border-style.js +26 -0
- package/dist/lib/css/property-descriptors/border-width.js +20 -0
- package/dist/lib/css/property-descriptors/box-decoration-break.js +18 -0
- package/dist/lib/css/property-descriptors/box-shadow.js +54 -0
- package/dist/lib/css/property-descriptors/clip-path.js +189 -0
- package/dist/lib/css/property-descriptors/color.js +10 -0
- package/dist/lib/css/property-descriptors/content.js +19 -0
- package/dist/lib/css/property-descriptors/counter-increment.js +35 -0
- package/dist/lib/css/property-descriptors/counter-reset.js +18 -0
- package/dist/lib/css/property-descriptors/direction.js +18 -0
- package/dist/lib/css/property-descriptors/display.js +81 -0
- package/dist/lib/css/property-descriptors/duration.js +14 -0
- package/dist/lib/css/property-descriptors/filter.js +76 -0
- package/dist/lib/css/property-descriptors/float.js +22 -0
- package/dist/lib/css/property-descriptors/font-family.js +32 -0
- package/dist/lib/css/property-descriptors/font-size.js +10 -0
- package/dist/lib/css/property-descriptors/font-style.js +20 -0
- package/dist/lib/css/property-descriptors/font-variant-ligatures.js +34 -0
- package/dist/lib/css/property-descriptors/font-variant.js +13 -0
- package/dist/lib/css/property-descriptors/font-weight.js +25 -0
- package/dist/lib/css/property-descriptors/image-rendering.js +33 -0
- package/dist/lib/css/property-descriptors/letter-spacing.js +21 -0
- package/dist/lib/css/property-descriptors/line-break.js +23 -0
- package/dist/lib/css/property-descriptors/line-height.js +24 -0
- package/dist/lib/css/property-descriptors/list-style-image.js +17 -0
- package/dist/lib/css/property-descriptors/list-style-position.js +18 -0
- package/dist/lib/css/property-descriptors/list-style-type.js +122 -0
- package/dist/lib/css/property-descriptors/margin.js +13 -0
- package/dist/lib/css/property-descriptors/mix-blend-mode.js +31 -0
- package/dist/lib/css/property-descriptors/object-fit.js +28 -0
- package/dist/lib/css/property-descriptors/object-position.js +42 -0
- package/dist/lib/css/property-descriptors/opacity.js +16 -0
- package/dist/lib/css/property-descriptors/overflow-wrap.js +18 -0
- package/dist/lib/css/property-descriptors/overflow.js +27 -0
- package/dist/lib/css/property-descriptors/padding.js +14 -0
- package/dist/lib/css/property-descriptors/paint-order.js +33 -0
- package/dist/lib/css/property-descriptors/position.js +22 -0
- package/dist/lib/css/property-descriptors/quotes.js +41 -0
- package/dist/lib/css/property-descriptors/rotate.js +27 -0
- package/dist/lib/css/property-descriptors/text-align.js +21 -0
- package/dist/lib/css/property-descriptors/text-decoration-color.js +10 -0
- package/dist/lib/css/property-descriptors/text-decoration-line.js +28 -0
- package/dist/lib/css/property-descriptors/text-decoration-style.js +24 -0
- package/dist/lib/css/property-descriptors/text-decoration-thickness.js +26 -0
- package/dist/lib/css/property-descriptors/text-overflow.js +18 -0
- package/dist/lib/css/property-descriptors/text-shadow.js +46 -0
- package/dist/lib/css/property-descriptors/text-transform.js +20 -0
- package/dist/lib/css/property-descriptors/text-underline-offset.js +23 -0
- package/dist/lib/css/property-descriptors/transform-origin.js +24 -0
- package/dist/lib/css/property-descriptors/transform.js +57 -0
- package/dist/lib/css/property-descriptors/visibility.js +20 -0
- package/dist/lib/css/property-descriptors/webkit-line-clamp.js +26 -0
- package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js +10 -0
- package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js +16 -0
- package/dist/lib/css/property-descriptors/word-break.js +26 -0
- package/dist/lib/css/property-descriptors/writing-mode.js +28 -0
- package/dist/lib/css/property-descriptors/z-index.js +19 -0
- package/dist/lib/css/property-descriptors/zoom.js +18 -0
- package/dist/lib/css/syntax/parser.js +140 -0
- package/dist/lib/css/syntax/token-constants.js +214 -0
- package/dist/lib/css/syntax/token-singletons.js +36 -0
- package/dist/lib/css/syntax/token-types.js +10 -0
- package/dist/lib/css/syntax/tokenizer.js +502 -0
- package/dist/lib/css/type-descriptor.js +2 -0
- package/dist/lib/css/types/angle.js +80 -0
- package/dist/lib/css/types/color-math.js +25 -0
- package/dist/lib/css/types/color-spaces/a98.js +78 -0
- package/dist/lib/css/types/color-spaces/p3.js +86 -0
- package/dist/lib/css/types/color-spaces/pro-photo.js +83 -0
- package/dist/lib/css/types/color-spaces/rec2020.js +85 -0
- package/dist/lib/css/types/color-spaces/srgb.js +79 -0
- package/dist/lib/css/types/color-utilities.js +342 -0
- package/dist/lib/css/types/color.js +400 -0
- package/dist/lib/css/types/functions/-prefix-linear-gradient.js +32 -0
- package/dist/lib/css/types/functions/-prefix-radial-gradient.js +83 -0
- package/dist/lib/css/types/functions/-webkit-gradient.js +59 -0
- package/dist/lib/css/types/functions/counter.js +367 -0
- package/dist/lib/css/types/functions/gradient.js +163 -0
- package/dist/lib/css/types/functions/linear-gradient.js +27 -0
- package/dist/lib/css/types/functions/radial-gradient.js +90 -0
- package/dist/lib/css/types/functions/repeating-linear-gradient.js +9 -0
- package/dist/lib/css/types/image.js +62 -0
- package/dist/lib/css/types/index.js +2 -0
- package/dist/lib/css/types/length-percentage.js +197 -0
- package/dist/lib/css/types/length.js +5 -0
- package/dist/lib/css/types/safe-eval.js +80 -0
- package/dist/lib/css/types/time.js +17 -0
- package/dist/lib/dom/document-cloner.js +597 -0
- package/dist/lib/dom/dom-normalizer.js +115 -0
- package/dist/lib/dom/element-container.js +56 -0
- package/dist/lib/dom/elements/li-element-container.js +11 -0
- package/dist/lib/dom/elements/ol-element-container.js +12 -0
- package/dist/lib/dom/elements/select-element-container.js +12 -0
- package/dist/lib/dom/elements/textarea-element-container.js +11 -0
- package/dist/lib/dom/node-parser.js +112 -0
- package/dist/lib/dom/node-type-guards.js +81 -0
- package/dist/lib/dom/replaced-elements/canvas-element-container.js +13 -0
- package/dist/lib/dom/replaced-elements/iframe-element-container.js +38 -0
- package/dist/lib/dom/replaced-elements/image-element-container.js +14 -0
- package/dist/lib/dom/replaced-elements/index.js +2 -0
- package/dist/lib/dom/replaced-elements/input-element-container.js +89 -0
- package/dist/lib/dom/replaced-elements/svg-element-container.js +19 -0
- package/dist/lib/dom/slot-cloner.js +176 -0
- package/dist/lib/dom/text-container.js +35 -0
- package/dist/lib/index.js +49 -0
- package/dist/lib/options.js +2 -0
- package/dist/lib/render/background.js +188 -0
- package/dist/lib/render/bezier-curve.js +34 -0
- package/dist/lib/render/border.js +104 -0
- package/dist/lib/render/bound-curves.js +188 -0
- package/dist/lib/render/box-sizing.js +20 -0
- package/dist/lib/render/canvas/background-renderer.js +327 -0
- package/dist/lib/render/canvas/border-image-renderer.js +153 -0
- package/dist/lib/render/canvas/border-renderer.js +184 -0
- package/dist/lib/render/canvas/canvas-path.js +25 -0
- package/dist/lib/render/canvas/canvas-renderer.js +312 -0
- package/dist/lib/render/canvas/content-renderer.js +204 -0
- package/dist/lib/render/canvas/effects-renderer.js +171 -0
- package/dist/lib/render/canvas/font-utils.js +29 -0
- package/dist/lib/render/canvas/foreignobject-renderer.js +38 -0
- package/dist/lib/render/canvas/text/text-decoration-renderer.js +99 -0
- package/dist/lib/render/canvas/text-renderer.js +485 -0
- package/dist/lib/render/effects.js +231 -0
- package/dist/lib/render/font-metrics.js +53 -0
- package/dist/lib/render/object-fit.js +91 -0
- package/dist/lib/render/path.js +26 -0
- package/dist/lib/render/renderer-interface.js +2 -0
- package/dist/lib/render/stacking-context.js +340 -0
- package/dist/lib/render/vector.js +16 -0
- package/dist/types/config.d.ts +44 -0
- package/dist/types/core/abort-helper.d.ts +12 -0
- package/dist/types/core/background-parser.d.ts +16 -0
- package/dist/types/core/bitwise.d.ts +1 -0
- package/dist/types/core/cache-storage.d.ts +68 -0
- package/dist/types/core/config-assembler.d.ts +28 -0
- package/dist/types/core/constants.d.ts +22 -0
- package/dist/types/core/context.d.ts +22 -0
- package/dist/types/core/debugger.d.ts +8 -0
- package/dist/types/core/features.d.ts +12 -0
- package/dist/types/core/logger.d.ts +18 -0
- package/dist/types/core/lru-map.d.ts +37 -0
- package/dist/types/core/origin-checker.d.ts +33 -0
- package/dist/types/core/performance-monitor.d.ts +120 -0
- package/dist/types/core/render-element.d.ts +3 -0
- package/dist/types/core/util.d.ts +1 -0
- package/dist/types/core/validator.d.ts +130 -0
- package/dist/types/css/grouped/background-styles.d.ts +16 -0
- package/dist/types/css/grouped/border-styles.d.ts +31 -0
- package/dist/types/css/grouped/font-styles.d.ts +35 -0
- package/dist/types/css/grouped/layout-styles.d.ts +46 -0
- package/dist/types/css/index.d.ts +185 -0
- package/dist/types/css/layout/bounds.d.ts +14 -0
- package/dist/types/css/layout/text.d.ts +10 -0
- package/dist/types/css/property-descriptor.d.ts +40 -0
- package/dist/types/css/property-descriptors/background-blend-mode.d.ts +23 -0
- package/dist/types/css/property-descriptors/background-clip.d.ts +8 -0
- package/dist/types/css/property-descriptors/background-color.d.ts +2 -0
- package/dist/types/css/property-descriptors/background-image.d.ts +3 -0
- package/dist/types/css/property-descriptors/background-origin.d.ts +8 -0
- package/dist/types/css/property-descriptors/background-position.d.ts +5 -0
- package/dist/types/css/property-descriptors/background-repeat.d.ts +9 -0
- package/dist/types/css/property-descriptors/background-size.d.ts +11 -0
- package/dist/types/css/property-descriptors/border-color.d.ts +5 -0
- package/dist/types/css/property-descriptors/border-image-repeat.d.ts +12 -0
- package/dist/types/css/property-descriptors/border-image-slice.d.ts +10 -0
- package/dist/types/css/property-descriptors/border-image-source.d.ts +4 -0
- package/dist/types/css/property-descriptors/border-radius.d.ts +7 -0
- package/dist/types/css/property-descriptors/border-style.d.ts +12 -0
- package/dist/types/css/property-descriptors/border-width.d.ts +5 -0
- package/dist/types/css/property-descriptors/box-decoration-break.d.ts +6 -0
- package/dist/types/css/property-descriptors/box-shadow.d.ts +14 -0
- package/dist/types/css/property-descriptors/clip-path.d.ts +62 -0
- package/dist/types/css/property-descriptors/color.d.ts +2 -0
- package/dist/types/css/property-descriptors/content.d.ts +4 -0
- package/dist/types/css/property-descriptors/counter-increment.d.ts +10 -0
- package/dist/types/css/property-descriptors/counter-reset.d.ts +7 -0
- package/dist/types/css/property-descriptors/direction.d.ts +6 -0
- package/dist/types/css/property-descriptors/display.d.ts +35 -0
- package/dist/types/css/property-descriptors/duration.d.ts +2 -0
- package/dist/types/css/property-descriptors/filter.d.ts +3 -0
- package/dist/types/css/property-descriptors/float.d.ts +9 -0
- package/dist/types/css/property-descriptors/font-family.d.ts +4 -0
- package/dist/types/css/property-descriptors/font-size.d.ts +2 -0
- package/dist/types/css/property-descriptors/font-style.d.ts +7 -0
- package/dist/types/css/property-descriptors/font-variant-ligatures.d.ts +14 -0
- package/dist/types/css/property-descriptors/font-variant.d.ts +2 -0
- package/dist/types/css/property-descriptors/font-weight.d.ts +2 -0
- package/dist/types/css/property-descriptors/image-rendering.d.ts +8 -0
- package/dist/types/css/property-descriptors/letter-spacing.d.ts +2 -0
- package/dist/types/css/property-descriptors/line-break.d.ts +6 -0
- package/dist/types/css/property-descriptors/line-height.d.ts +4 -0
- package/dist/types/css/property-descriptors/list-style-image.d.ts +3 -0
- package/dist/types/css/property-descriptors/list-style-position.d.ts +6 -0
- package/dist/types/css/property-descriptors/list-style-type.d.ts +58 -0
- package/dist/types/css/property-descriptors/margin.d.ts +5 -0
- package/dist/types/css/property-descriptors/mix-blend-mode.d.ts +21 -0
- package/dist/types/css/property-descriptors/object-fit.d.ts +10 -0
- package/dist/types/css/property-descriptors/object-position.d.ts +4 -0
- package/dist/types/css/property-descriptors/opacity.d.ts +2 -0
- package/dist/types/css/property-descriptors/overflow-wrap.d.ts +6 -0
- package/dist/types/css/property-descriptors/overflow.d.ts +9 -0
- package/dist/types/css/property-descriptors/padding.d.ts +5 -0
- package/dist/types/css/property-descriptors/paint-order.d.ts +8 -0
- package/dist/types/css/property-descriptors/position.d.ts +9 -0
- package/dist/types/css/property-descriptors/quotes.d.ts +8 -0
- package/dist/types/css/property-descriptors/rotate.d.ts +3 -0
- package/dist/types/css/property-descriptors/text-align.d.ts +7 -0
- package/dist/types/css/property-descriptors/text-decoration-color.d.ts +2 -0
- package/dist/types/css/property-descriptors/text-decoration-line.d.ts +10 -0
- package/dist/types/css/property-descriptors/text-decoration-style.d.ts +9 -0
- package/dist/types/css/property-descriptors/text-decoration-thickness.d.ts +3 -0
- package/dist/types/css/property-descriptors/text-overflow.d.ts +6 -0
- package/dist/types/css/property-descriptors/text-shadow.d.ts +12 -0
- package/dist/types/css/property-descriptors/text-transform.d.ts +8 -0
- package/dist/types/css/property-descriptors/text-underline-offset.d.ts +3 -0
- package/dist/types/css/property-descriptors/transform-origin.d.ts +4 -0
- package/dist/types/css/property-descriptors/transform.d.ts +4 -0
- package/dist/types/css/property-descriptors/visibility.d.ts +7 -0
- package/dist/types/css/property-descriptors/webkit-line-clamp.d.ts +7 -0
- package/dist/types/css/property-descriptors/webkit-text-stroke-color.d.ts +2 -0
- package/dist/types/css/property-descriptors/webkit-text-stroke-width.d.ts +2 -0
- package/dist/types/css/property-descriptors/word-break.d.ts +7 -0
- package/dist/types/css/property-descriptors/writing-mode.d.ts +11 -0
- package/dist/types/css/property-descriptors/z-index.d.ts +7 -0
- package/dist/types/css/property-descriptors/zoom.d.ts +3 -0
- package/dist/types/css/syntax/parser.d.ts +34 -0
- package/dist/types/css/syntax/token-constants.d.ts +74 -0
- package/dist/types/css/syntax/token-singletons.d.ts +22 -0
- package/dist/types/css/syntax/token-types.d.ts +72 -0
- package/dist/types/css/syntax/tokenizer.d.ts +32 -0
- package/dist/types/css/type-descriptor.d.ts +6 -0
- package/dist/types/css/types/angle.d.ts +7 -0
- package/dist/types/css/types/color-math.d.ts +12 -0
- package/dist/types/css/types/color-spaces/a98.d.ts +39 -0
- package/dist/types/css/types/color-spaces/p3.d.ts +45 -0
- package/dist/types/css/types/color-spaces/pro-photo.d.ts +45 -0
- package/dist/types/css/types/color-spaces/rec2020.d.ts +45 -0
- package/dist/types/css/types/color-spaces/srgb.d.ts +38 -0
- package/dist/types/css/types/color-utilities.d.ts +107 -0
- package/dist/types/css/types/color.d.ts +8 -0
- package/dist/types/css/types/functions/-prefix-linear-gradient.d.ts +4 -0
- package/dist/types/css/types/functions/-prefix-radial-gradient.d.ts +4 -0
- package/dist/types/css/types/functions/-webkit-gradient.d.ts +4 -0
- package/dist/types/css/types/functions/counter.d.ts +10 -0
- package/dist/types/css/types/functions/gradient.d.ts +7 -0
- package/dist/types/css/types/functions/linear-gradient.d.ts +4 -0
- package/dist/types/css/types/functions/radial-gradient.d.ts +12 -0
- package/dist/types/css/types/functions/repeating-linear-gradient.d.ts +4 -0
- package/dist/types/css/types/image.d.ts +56 -0
- package/dist/types/css/types/index.d.ts +1 -0
- package/dist/types/css/types/length-percentage.d.ts +62 -0
- package/dist/types/css/types/length.d.ts +4 -0
- package/dist/types/css/types/safe-eval.d.ts +8 -0
- package/dist/types/css/types/time.d.ts +2 -0
- package/dist/types/dom/document-cloner.d.ts +57 -0
- package/dist/types/dom/dom-normalizer.d.ts +62 -0
- package/dist/types/dom/element-container.d.ts +31 -0
- package/dist/types/dom/elements/li-element-container.d.ts +6 -0
- package/dist/types/dom/elements/ol-element-container.d.ts +7 -0
- package/dist/types/dom/elements/select-element-container.d.ts +6 -0
- package/dist/types/dom/elements/textarea-element-container.d.ts +6 -0
- package/dist/types/dom/node-parser.d.ts +3 -0
- package/dist/types/dom/node-type-guards.d.ts +32 -0
- package/dist/types/dom/replaced-elements/canvas-element-container.d.ts +8 -0
- package/dist/types/dom/replaced-elements/iframe-element-container.d.ts +14 -0
- package/dist/types/dom/replaced-elements/image-element-container.d.ts +8 -0
- package/dist/types/dom/replaced-elements/index.d.ts +4 -0
- package/dist/types/dom/replaced-elements/input-element-container.d.ts +14 -0
- package/dist/types/dom/replaced-elements/svg-element-container.d.ts +8 -0
- package/dist/types/dom/slot-cloner.d.ts +66 -0
- package/dist/types/dom/text-container.d.ts +8 -0
- package/dist/types/index.d.ts +36 -0
- package/dist/types/options.d.ts +62 -0
- package/dist/types/render/background.d.ts +16 -0
- package/dist/types/render/bezier-curve.d.ts +14 -0
- package/dist/types/render/border.d.ts +6 -0
- package/dist/types/render/bound-curves.d.ts +32 -0
- package/dist/types/render/box-sizing.d.ts +4 -0
- package/dist/types/render/canvas/background-renderer.d.ts +94 -0
- package/dist/types/render/canvas/border-image-renderer.d.ts +18 -0
- package/dist/types/render/canvas/border-renderer.d.ts +67 -0
- package/dist/types/render/canvas/canvas-path.d.ts +3 -0
- package/dist/types/render/canvas/canvas-renderer.d.ts +60 -0
- package/dist/types/render/canvas/content-renderer.d.ts +43 -0
- package/dist/types/render/canvas/effects-renderer.d.ts +90 -0
- package/dist/types/render/canvas/font-utils.d.ts +19 -0
- package/dist/types/render/canvas/foreignobject-renderer.d.ts +10 -0
- package/dist/types/render/canvas/text/text-decoration-renderer.d.ts +18 -0
- package/dist/types/render/canvas/text-renderer.d.ts +103 -0
- package/dist/types/render/effects.d.ts +112 -0
- package/dist/types/render/font-metrics.d.ts +11 -0
- package/dist/types/render/object-fit.d.ts +19 -0
- package/dist/types/render/path.d.ts +13 -0
- package/dist/types/render/renderer-interface.d.ts +28 -0
- package/dist/types/render/stacking-context.d.ts +49 -0
- package/dist/types/render/vector.d.ts +9 -0
- package/package.json +139 -4
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Input Validator
|
|
4
|
+
*
|
|
5
|
+
* Provides validation and sanitization for user inputs to prevent security vulnerabilities
|
|
6
|
+
* including SSRF, XSS, and injection attacks.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.Validator = void 0;
|
|
10
|
+
exports.createDefaultValidator = createDefaultValidator;
|
|
11
|
+
exports.createStrictValidator = createStrictValidator;
|
|
12
|
+
/**
|
|
13
|
+
* Input Validator
|
|
14
|
+
*
|
|
15
|
+
* Validates and sanitizes user inputs for security and correctness.
|
|
16
|
+
*/
|
|
17
|
+
class Validator {
|
|
18
|
+
constructor(config = {}) {
|
|
19
|
+
this.config = {
|
|
20
|
+
maxImageTimeout: 300000, // 5 minutes default
|
|
21
|
+
allowDataUrls: true,
|
|
22
|
+
...config
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validate a URL
|
|
27
|
+
*
|
|
28
|
+
* @param url - URL to validate
|
|
29
|
+
* @param context - Context for validation (e.g., 'proxy', 'image')
|
|
30
|
+
* @returns Validation result
|
|
31
|
+
*/
|
|
32
|
+
validateUrl(url, context = 'general') {
|
|
33
|
+
if (!url || typeof url !== 'string') {
|
|
34
|
+
return {
|
|
35
|
+
valid: false,
|
|
36
|
+
error: 'URL must be a non-empty string'
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Check for data URLs
|
|
40
|
+
if (url.startsWith('data:')) {
|
|
41
|
+
if (!this.config.allowDataUrls) {
|
|
42
|
+
return {
|
|
43
|
+
valid: false,
|
|
44
|
+
error: 'Data URLs are not allowed'
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return { valid: true, sanitized: url };
|
|
48
|
+
}
|
|
49
|
+
// Check for blob URLs
|
|
50
|
+
if (url.startsWith('blob:')) {
|
|
51
|
+
return { valid: true, sanitized: url };
|
|
52
|
+
}
|
|
53
|
+
// Validate URL format
|
|
54
|
+
try {
|
|
55
|
+
const parsedUrl = new URL(url);
|
|
56
|
+
// Only allow http and https protocols
|
|
57
|
+
if (!['http:', 'https:'].includes(parsedUrl.protocol)) {
|
|
58
|
+
return {
|
|
59
|
+
valid: false,
|
|
60
|
+
error: `Protocol ${parsedUrl.protocol} is not allowed. Only http and https are permitted.`
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// For proxy URLs, check domain whitelist
|
|
64
|
+
if (context === 'proxy' && this.config.allowedProxyDomains && this.config.allowedProxyDomains.length > 0) {
|
|
65
|
+
const hostname = parsedUrl.hostname.toLowerCase();
|
|
66
|
+
const isAllowed = this.config.allowedProxyDomains.some((domain) => {
|
|
67
|
+
const normalizedDomain = domain.toLowerCase();
|
|
68
|
+
return hostname === normalizedDomain || hostname.endsWith('.' + normalizedDomain);
|
|
69
|
+
});
|
|
70
|
+
if (!isAllowed) {
|
|
71
|
+
return {
|
|
72
|
+
valid: false,
|
|
73
|
+
error: `Proxy domain ${parsedUrl.hostname} is not in the allowed list`
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Check for localhost/private IPs to prevent SSRF (skip when allowLocalhostProxy for dev/test)
|
|
78
|
+
if (context === 'proxy') {
|
|
79
|
+
if (!this.config.allowLocalhostProxy) {
|
|
80
|
+
const hostname = parsedUrl.hostname.toLowerCase();
|
|
81
|
+
// Check for localhost
|
|
82
|
+
if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1') {
|
|
83
|
+
return {
|
|
84
|
+
valid: false,
|
|
85
|
+
error: 'Localhost is not allowed for proxy URLs'
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// For private IP ranges (simplified check)
|
|
89
|
+
if (this.isPrivateIP(hostname)) {
|
|
90
|
+
return {
|
|
91
|
+
valid: false,
|
|
92
|
+
error: 'Private IP addresses are not allowed for proxy URLs'
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// For link-local addresses
|
|
96
|
+
if (hostname.startsWith('169.254.') || hostname.startsWith('fe80:')) {
|
|
97
|
+
return {
|
|
98
|
+
valid: false,
|
|
99
|
+
error: 'Link-local addresses are not allowed for proxy URLs'
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// For proxy URLs, mark that runtime validation is recommended
|
|
104
|
+
// to prevent DNS rebinding attacks
|
|
105
|
+
return {
|
|
106
|
+
valid: true,
|
|
107
|
+
sanitized: url,
|
|
108
|
+
requiresRuntimeCheck: true
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return { valid: true, sanitized: url };
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
return {
|
|
115
|
+
valid: false,
|
|
116
|
+
error: `Invalid URL format: ${e instanceof Error ? e.message : 'Unknown error'}`
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Check if a hostname is a private IP address
|
|
122
|
+
*/
|
|
123
|
+
isPrivateIP(hostname) {
|
|
124
|
+
// IPv4 private ranges
|
|
125
|
+
const privateIPv4Patterns = [
|
|
126
|
+
/^0\./, // 0.0.0.0/8 (This network)
|
|
127
|
+
/^10\./, // 10.0.0.0/8 (Private)
|
|
128
|
+
/^100\.(6[4-9]|[7-9][0-9]|1[0-1][0-9]|12[0-7])\./, // 100.64.0.0/10 (CGNAT)
|
|
129
|
+
/^127\./, // 127.0.0.0/8 (Loopback)
|
|
130
|
+
/^169\.254\./, // 169.254.0.0/16 (Link-local)
|
|
131
|
+
/^172\.(1[6-9]|2[0-9]|3[0-1])\./, // 172.16.0.0/12 (Private)
|
|
132
|
+
/^192\.0\.0\./, // 192.0.0.0/24 (IETF Protocol Assignments)
|
|
133
|
+
/^192\.0\.2\./, // 192.0.2.0/24 (TEST-NET-1)
|
|
134
|
+
/^192\.168\./, // 192.168.0.0/16 (Private)
|
|
135
|
+
/^198\.(1[8-9])\./, // 198.18.0.0/15 (Network benchmark)
|
|
136
|
+
/^198\.51\.100\./, // 198.51.100.0/24 (TEST-NET-2)
|
|
137
|
+
/^203\.0\.113\./, // 203.0.113.0/24 (TEST-NET-3)
|
|
138
|
+
/^2(2[4-9]|3[0-9])\./, // 224.0.0.0/4 (Multicast)
|
|
139
|
+
/^24[0-9]\./, // 240.0.0.0/4 (Reserved)
|
|
140
|
+
/^255\.255\.255\.255$/ // 255.255.255.255/32 (Broadcast)
|
|
141
|
+
];
|
|
142
|
+
// Check IPv4
|
|
143
|
+
if (privateIPv4Patterns.some((pattern) => pattern.test(hostname))) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
// IPv6 private ranges and special addresses
|
|
147
|
+
if (hostname.includes(':')) {
|
|
148
|
+
return this.isPrivateIPv6(hostname);
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Check if an IPv6 address is private or special
|
|
154
|
+
* Handles compressed IPv6 addresses (e.g., ::1, fc00::1)
|
|
155
|
+
*/
|
|
156
|
+
isPrivateIPv6(hostname) {
|
|
157
|
+
const normalizedHost = hostname.toLowerCase().trim();
|
|
158
|
+
// Remove square brackets if present (e.g., [::1])
|
|
159
|
+
const addr = normalizedHost.replace(/^\[|\]$/g, '');
|
|
160
|
+
// Remove zone ID if present (e.g., fe80::1%eth0)
|
|
161
|
+
const addrWithoutZone = addr.split('%')[0];
|
|
162
|
+
// Loopback ::1 (also matches 0:0:0:0:0:0:0:1)
|
|
163
|
+
if (/^(0:){7}1$/.test(addrWithoutZone) || addrWithoutZone === '::1') {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
// Unspecified address :: (also matches 0:0:0:0:0:0:0:0)
|
|
167
|
+
if (/^(0:){7}0$/.test(addrWithoutZone) || addrWithoutZone === '::') {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
// Expand :: compression to check prefixes
|
|
171
|
+
// This handles cases like fc00::1, fe80::, etc.
|
|
172
|
+
const expandedAddr = this.expandIPv6(addrWithoutZone);
|
|
173
|
+
if (!expandedAddr) {
|
|
174
|
+
// If we can't expand it, fall back to prefix matching
|
|
175
|
+
return this.isPrivateIPv6Prefix(addrWithoutZone);
|
|
176
|
+
}
|
|
177
|
+
// fc00::/7 (Unique Local Address)
|
|
178
|
+
// Check if first byte is in range fc00-fdff
|
|
179
|
+
const firstByte = parseInt(expandedAddr.substring(0, 2), 16);
|
|
180
|
+
if (firstByte >= 0xfc && firstByte <= 0xfd) {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
// fe80::/10 (Link-local)
|
|
184
|
+
// First 10 bits should be 1111 1110 10
|
|
185
|
+
if (firstByte === 0xfe) {
|
|
186
|
+
const secondByte = parseInt(expandedAddr.substring(2, 4), 16);
|
|
187
|
+
// Check if bits 11-12 are 10 (0x80-0xbf)
|
|
188
|
+
if (secondByte >= 0x80 && secondByte <= 0xbf) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// ff00::/8 (Multicast)
|
|
193
|
+
if (firstByte === 0xff) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Expand compressed IPv6 address to full form
|
|
200
|
+
* e.g., "::1" -> "0000:0000:0000:0000:0000:0000:0000:0001"
|
|
201
|
+
*/
|
|
202
|
+
expandIPv6(addr) {
|
|
203
|
+
try {
|
|
204
|
+
// Handle :: compression
|
|
205
|
+
if (addr.includes('::')) {
|
|
206
|
+
const parts = addr.split('::');
|
|
207
|
+
if (parts.length > 2) {
|
|
208
|
+
return null; // Invalid: more than one ::
|
|
209
|
+
}
|
|
210
|
+
const leftParts = parts[0] ? parts[0].split(':') : [];
|
|
211
|
+
const rightParts = parts[1] ? parts[1].split(':') : [];
|
|
212
|
+
const missingParts = 8 - leftParts.length - rightParts.length;
|
|
213
|
+
if (missingParts < 0) {
|
|
214
|
+
return null; // Invalid
|
|
215
|
+
}
|
|
216
|
+
const middleParts = Array(missingParts).fill('0000');
|
|
217
|
+
const allParts = [...leftParts, ...middleParts, ...rightParts];
|
|
218
|
+
return allParts.map((p) => p.padStart(4, '0')).join(':');
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
// No compression, just normalize
|
|
222
|
+
const parts = addr.split(':');
|
|
223
|
+
if (parts.length !== 8) {
|
|
224
|
+
return null; // Invalid
|
|
225
|
+
}
|
|
226
|
+
return parts.map((p) => p.padStart(4, '0')).join(':');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Fallback prefix matching for IPv6 when expansion fails
|
|
235
|
+
*/
|
|
236
|
+
isPrivateIPv6Prefix(addr) {
|
|
237
|
+
// fc00::/7 (Unique Local Address)
|
|
238
|
+
if (/^fc[0-9a-f]{0,2}:?/i.test(addr) || /^fd[0-9a-f]{0,2}:?/i.test(addr)) {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
// fe80::/10 (Link-local)
|
|
242
|
+
if (/^fe[89ab][0-9a-f]:?/i.test(addr)) {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
// ff00::/8 (Multicast)
|
|
246
|
+
if (/^ff[0-9a-f]{0,2}:?/i.test(addr)) {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Validate CSP nonce
|
|
253
|
+
*
|
|
254
|
+
* @param nonce - CSP nonce to validate
|
|
255
|
+
* @returns Validation result
|
|
256
|
+
*/
|
|
257
|
+
validateCspNonce(nonce) {
|
|
258
|
+
if (!nonce || typeof nonce !== 'string') {
|
|
259
|
+
return {
|
|
260
|
+
valid: false,
|
|
261
|
+
error: 'CSP nonce must be a non-empty string'
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
// Basic format validation - nonce should be base64-like
|
|
265
|
+
// Typical format: base64 string, often 32+ characters
|
|
266
|
+
if (nonce.length < 16) {
|
|
267
|
+
return {
|
|
268
|
+
valid: false,
|
|
269
|
+
error: 'CSP nonce is too short (minimum 16 characters recommended)'
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
// Check for suspicious characters
|
|
273
|
+
if (!/^[A-Za-z0-9+/=_-]+$/.test(nonce)) {
|
|
274
|
+
return {
|
|
275
|
+
valid: false,
|
|
276
|
+
error: 'CSP nonce contains invalid characters'
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
return { valid: true, sanitized: nonce };
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Validate image timeout
|
|
283
|
+
*
|
|
284
|
+
* @param timeout - Timeout in milliseconds
|
|
285
|
+
* @returns Validation result
|
|
286
|
+
*/
|
|
287
|
+
validateImageTimeout(timeout) {
|
|
288
|
+
if (typeof timeout !== 'number' || isNaN(timeout)) {
|
|
289
|
+
return {
|
|
290
|
+
valid: false,
|
|
291
|
+
error: 'Image timeout must be a number'
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
if (timeout < 0) {
|
|
295
|
+
return {
|
|
296
|
+
valid: false,
|
|
297
|
+
error: 'Image timeout cannot be negative'
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
if (this.config.maxImageTimeout && timeout > this.config.maxImageTimeout) {
|
|
301
|
+
return {
|
|
302
|
+
valid: false,
|
|
303
|
+
error: `Image timeout ${timeout}ms exceeds maximum allowed ${this.config.maxImageTimeout}ms`
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
return { valid: true, sanitized: timeout };
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Validate window dimensions
|
|
310
|
+
*
|
|
311
|
+
* @param width - Window width
|
|
312
|
+
* @param height - Window height
|
|
313
|
+
* @returns Validation result
|
|
314
|
+
*/
|
|
315
|
+
validateDimensions(width, height) {
|
|
316
|
+
if (typeof width !== 'number' || typeof height !== 'number') {
|
|
317
|
+
return {
|
|
318
|
+
valid: false,
|
|
319
|
+
error: 'Dimensions must be numbers'
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
if (isNaN(width) || isNaN(height)) {
|
|
323
|
+
return {
|
|
324
|
+
valid: false,
|
|
325
|
+
error: 'Dimensions cannot be NaN'
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
if (width <= 0 || height <= 0) {
|
|
329
|
+
return {
|
|
330
|
+
valid: false,
|
|
331
|
+
error: 'Dimensions must be positive'
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
// Reasonable maximum to prevent memory issues
|
|
335
|
+
const MAX_DIMENSION = 32767; // Common canvas limit
|
|
336
|
+
if (width > MAX_DIMENSION || height > MAX_DIMENSION) {
|
|
337
|
+
return {
|
|
338
|
+
valid: false,
|
|
339
|
+
error: `Dimensions exceed maximum allowed (${MAX_DIMENSION}px)`
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
return { valid: true, sanitized: { width, height } };
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Validate scale factor
|
|
346
|
+
*
|
|
347
|
+
* @param scale - Scale factor
|
|
348
|
+
* @returns Validation result
|
|
349
|
+
*/
|
|
350
|
+
validateScale(scale) {
|
|
351
|
+
if (typeof scale !== 'number' || isNaN(scale)) {
|
|
352
|
+
return {
|
|
353
|
+
valid: false,
|
|
354
|
+
error: 'Scale must be a number'
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
if (scale <= 0) {
|
|
358
|
+
return {
|
|
359
|
+
valid: false,
|
|
360
|
+
error: 'Scale must be positive'
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
// Reasonable scale limits
|
|
364
|
+
if (scale > 10) {
|
|
365
|
+
return {
|
|
366
|
+
valid: false,
|
|
367
|
+
error: 'Scale factor too large (maximum 10x)'
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
return { valid: true, sanitized: scale };
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Validate HTML element
|
|
374
|
+
*
|
|
375
|
+
* @param element - Element to validate
|
|
376
|
+
* @returns Validation result
|
|
377
|
+
*/
|
|
378
|
+
validateElement(element) {
|
|
379
|
+
if (!element) {
|
|
380
|
+
return {
|
|
381
|
+
valid: false,
|
|
382
|
+
error: 'Element is required'
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (typeof element !== 'object') {
|
|
386
|
+
return {
|
|
387
|
+
valid: false,
|
|
388
|
+
error: 'Element must be an object'
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
// Accept real HTMLElement, or any element-like object with the minimal shape
|
|
392
|
+
// required by the implementation (ownerDocument + defaultView) for backward
|
|
393
|
+
// compatibility and test environments.
|
|
394
|
+
const el = element;
|
|
395
|
+
if (typeof HTMLElement !== 'undefined' && element instanceof HTMLElement) {
|
|
396
|
+
// Real DOM element
|
|
397
|
+
if (!element.ownerDocument) {
|
|
398
|
+
return { valid: false, error: 'Element must be attached to a document' };
|
|
399
|
+
}
|
|
400
|
+
return { valid: true };
|
|
401
|
+
}
|
|
402
|
+
// Duck-typing: accept object with ownerDocument and defaultView (minimal contract)
|
|
403
|
+
if (!el.ownerDocument) {
|
|
404
|
+
return {
|
|
405
|
+
valid: false,
|
|
406
|
+
error: 'Element must be attached to a document (ownerDocument required)'
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
if (!el.ownerDocument.defaultView) {
|
|
410
|
+
return {
|
|
411
|
+
valid: false,
|
|
412
|
+
error: 'Document must be attached to a window (ownerDocument.defaultView required)'
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
return { valid: true };
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Validate entire options object
|
|
419
|
+
*
|
|
420
|
+
* @param options - Options to validate
|
|
421
|
+
* @returns Validation result with all errors
|
|
422
|
+
*/
|
|
423
|
+
validateOptions(options) {
|
|
424
|
+
const errors = [];
|
|
425
|
+
const proxyUrl = options.proxy;
|
|
426
|
+
if (proxyUrl !== undefined && proxyUrl !== null && typeof proxyUrl === 'string' && proxyUrl.length > 0) {
|
|
427
|
+
const proxyResult = this.validateUrl(proxyUrl, 'proxy');
|
|
428
|
+
if (!proxyResult.valid) {
|
|
429
|
+
errors.push(`Proxy: ${proxyResult.error}`);
|
|
430
|
+
}
|
|
431
|
+
// Note: Proxy URLs are marked with requiresRuntimeCheck to prevent DNS rebinding
|
|
432
|
+
// Consider implementing runtime IP validation in production environments
|
|
433
|
+
}
|
|
434
|
+
// Validate image timeout
|
|
435
|
+
if (options.imageTimeout !== undefined) {
|
|
436
|
+
const timeoutResult = this.validateImageTimeout(options.imageTimeout);
|
|
437
|
+
if (!timeoutResult.valid) {
|
|
438
|
+
errors.push(`Image timeout: ${timeoutResult.error}`);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
// Validate dimensions
|
|
442
|
+
if (options.width !== undefined || options.height !== undefined) {
|
|
443
|
+
const width = options.width ?? 800;
|
|
444
|
+
const height = options.height ?? 600;
|
|
445
|
+
const dimensionsResult = this.validateDimensions(width, height);
|
|
446
|
+
if (!dimensionsResult.valid) {
|
|
447
|
+
errors.push(`Dimensions: ${dimensionsResult.error}`);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
// Validate scale
|
|
451
|
+
if (options.scale !== undefined) {
|
|
452
|
+
const scaleResult = this.validateScale(options.scale);
|
|
453
|
+
if (!scaleResult.valid) {
|
|
454
|
+
errors.push(`Scale: ${scaleResult.error}`);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
// Validate CSP nonce
|
|
458
|
+
if (options.cspNonce !== undefined) {
|
|
459
|
+
const nonceResult = this.validateCspNonce(options.cspNonce);
|
|
460
|
+
if (!nonceResult.valid) {
|
|
461
|
+
errors.push(`CSP nonce: ${nonceResult.error}`);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
// Custom validation
|
|
465
|
+
if (this.config.customValidator) {
|
|
466
|
+
const customResult = this.config.customValidator(options, 'options');
|
|
467
|
+
if (!customResult.valid) {
|
|
468
|
+
errors.push(`Custom validation: ${customResult.error}`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (errors.length > 0) {
|
|
472
|
+
return {
|
|
473
|
+
valid: false,
|
|
474
|
+
error: errors.join('; ')
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
return { valid: true };
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
exports.Validator = Validator;
|
|
481
|
+
/**
|
|
482
|
+
* Create a default validator instance
|
|
483
|
+
*/
|
|
484
|
+
function createDefaultValidator(config = {}) {
|
|
485
|
+
return new Validator({
|
|
486
|
+
allowDataUrls: true,
|
|
487
|
+
maxImageTimeout: 300000, // 5 minutes
|
|
488
|
+
...config
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Create a strict validator with security-focused settings
|
|
493
|
+
*/
|
|
494
|
+
function createStrictValidator(allowedProxyDomains) {
|
|
495
|
+
return new Validator({
|
|
496
|
+
allowedProxyDomains,
|
|
497
|
+
allowDataUrls: false,
|
|
498
|
+
maxImageTimeout: 60000 // 1 minute
|
|
499
|
+
});
|
|
500
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackgroundStyles = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Read-only grouped accessor for background-related CSS properties.
|
|
6
|
+
*/
|
|
7
|
+
class BackgroundStyles {
|
|
8
|
+
constructor(styles) {
|
|
9
|
+
this.styles = styles;
|
|
10
|
+
}
|
|
11
|
+
get color() {
|
|
12
|
+
return this.styles.backgroundColor;
|
|
13
|
+
}
|
|
14
|
+
get image() {
|
|
15
|
+
return this.styles.backgroundImage;
|
|
16
|
+
}
|
|
17
|
+
get clip() {
|
|
18
|
+
return this.styles.backgroundClip;
|
|
19
|
+
}
|
|
20
|
+
get origin() {
|
|
21
|
+
return this.styles.backgroundOrigin;
|
|
22
|
+
}
|
|
23
|
+
get position() {
|
|
24
|
+
return this.styles.backgroundPosition;
|
|
25
|
+
}
|
|
26
|
+
get repeat() {
|
|
27
|
+
return this.styles.backgroundRepeat;
|
|
28
|
+
}
|
|
29
|
+
get size() {
|
|
30
|
+
return this.styles.backgroundSize;
|
|
31
|
+
}
|
|
32
|
+
get blendMode() {
|
|
33
|
+
return this.styles.backgroundBlendMode;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.BackgroundStyles = BackgroundStyles;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BorderStyles = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Read-only grouped accessor for border-related CSS properties.
|
|
6
|
+
*
|
|
7
|
+
* Provides structured access: `styles.border.topColor` as an alternative
|
|
8
|
+
* to the flat `styles.borderTopColor`. Both forms remain valid.
|
|
9
|
+
*/
|
|
10
|
+
class BorderStyles {
|
|
11
|
+
constructor(styles) {
|
|
12
|
+
this.styles = styles;
|
|
13
|
+
}
|
|
14
|
+
get topColor() {
|
|
15
|
+
return this.styles.borderTopColor;
|
|
16
|
+
}
|
|
17
|
+
get rightColor() {
|
|
18
|
+
return this.styles.borderRightColor;
|
|
19
|
+
}
|
|
20
|
+
get bottomColor() {
|
|
21
|
+
return this.styles.borderBottomColor;
|
|
22
|
+
}
|
|
23
|
+
get leftColor() {
|
|
24
|
+
return this.styles.borderLeftColor;
|
|
25
|
+
}
|
|
26
|
+
get topStyle() {
|
|
27
|
+
return this.styles.borderTopStyle;
|
|
28
|
+
}
|
|
29
|
+
get rightStyle() {
|
|
30
|
+
return this.styles.borderRightStyle;
|
|
31
|
+
}
|
|
32
|
+
get bottomStyle() {
|
|
33
|
+
return this.styles.borderBottomStyle;
|
|
34
|
+
}
|
|
35
|
+
get leftStyle() {
|
|
36
|
+
return this.styles.borderLeftStyle;
|
|
37
|
+
}
|
|
38
|
+
get topWidth() {
|
|
39
|
+
return this.styles.borderTopWidth;
|
|
40
|
+
}
|
|
41
|
+
get rightWidth() {
|
|
42
|
+
return this.styles.borderRightWidth;
|
|
43
|
+
}
|
|
44
|
+
get bottomWidth() {
|
|
45
|
+
return this.styles.borderBottomWidth;
|
|
46
|
+
}
|
|
47
|
+
get leftWidth() {
|
|
48
|
+
return this.styles.borderLeftWidth;
|
|
49
|
+
}
|
|
50
|
+
get topLeftRadius() {
|
|
51
|
+
return this.styles.borderTopLeftRadius;
|
|
52
|
+
}
|
|
53
|
+
get topRightRadius() {
|
|
54
|
+
return this.styles.borderTopRightRadius;
|
|
55
|
+
}
|
|
56
|
+
get bottomRightRadius() {
|
|
57
|
+
return this.styles.borderBottomRightRadius;
|
|
58
|
+
}
|
|
59
|
+
get bottomLeftRadius() {
|
|
60
|
+
return this.styles.borderBottomLeftRadius;
|
|
61
|
+
}
|
|
62
|
+
get imageSource() {
|
|
63
|
+
return this.styles.borderImageSource;
|
|
64
|
+
}
|
|
65
|
+
get imageSlice() {
|
|
66
|
+
return this.styles.borderImageSlice;
|
|
67
|
+
}
|
|
68
|
+
get imageRepeat() {
|
|
69
|
+
return this.styles.borderImageRepeat;
|
|
70
|
+
}
|
|
71
|
+
get boxShadow() {
|
|
72
|
+
return this.styles.boxShadow;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.BorderStyles = BorderStyles;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FontStyles = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Read-only grouped accessor for font/text-related CSS properties.
|
|
6
|
+
*/
|
|
7
|
+
class FontStyles {
|
|
8
|
+
constructor(styles) {
|
|
9
|
+
this.styles = styles;
|
|
10
|
+
}
|
|
11
|
+
get family() {
|
|
12
|
+
return this.styles.fontFamily;
|
|
13
|
+
}
|
|
14
|
+
get size() {
|
|
15
|
+
return this.styles.fontSize;
|
|
16
|
+
}
|
|
17
|
+
get style() {
|
|
18
|
+
return this.styles.fontStyle;
|
|
19
|
+
}
|
|
20
|
+
get variant() {
|
|
21
|
+
return this.styles.fontVariant;
|
|
22
|
+
}
|
|
23
|
+
get weight() {
|
|
24
|
+
return this.styles.fontWeight;
|
|
25
|
+
}
|
|
26
|
+
get ligatures() {
|
|
27
|
+
return this.styles.fontVariantLigatures;
|
|
28
|
+
}
|
|
29
|
+
get color() {
|
|
30
|
+
return this.styles.color;
|
|
31
|
+
}
|
|
32
|
+
get letterSpacing() {
|
|
33
|
+
return this.styles.letterSpacing;
|
|
34
|
+
}
|
|
35
|
+
get lineHeight() {
|
|
36
|
+
return this.styles.lineHeight;
|
|
37
|
+
}
|
|
38
|
+
get textAlign() {
|
|
39
|
+
return this.styles.textAlign;
|
|
40
|
+
}
|
|
41
|
+
get textTransform() {
|
|
42
|
+
return this.styles.textTransform;
|
|
43
|
+
}
|
|
44
|
+
get textOverflow() {
|
|
45
|
+
return this.styles.textOverflow;
|
|
46
|
+
}
|
|
47
|
+
get textShadow() {
|
|
48
|
+
return this.styles.textShadow;
|
|
49
|
+
}
|
|
50
|
+
get textDecorationColor() {
|
|
51
|
+
return this.styles.textDecorationColor;
|
|
52
|
+
}
|
|
53
|
+
get textDecorationLine() {
|
|
54
|
+
return this.styles.textDecorationLine;
|
|
55
|
+
}
|
|
56
|
+
get textDecorationStyle() {
|
|
57
|
+
return this.styles.textDecorationStyle;
|
|
58
|
+
}
|
|
59
|
+
get textDecorationThickness() {
|
|
60
|
+
return this.styles.textDecorationThickness;
|
|
61
|
+
}
|
|
62
|
+
get textUnderlineOffset() {
|
|
63
|
+
return this.styles.textUnderlineOffset;
|
|
64
|
+
}
|
|
65
|
+
get wordBreak() {
|
|
66
|
+
return this.styles.wordBreak;
|
|
67
|
+
}
|
|
68
|
+
get lineBreak() {
|
|
69
|
+
return this.styles.lineBreak;
|
|
70
|
+
}
|
|
71
|
+
get overflowWrap() {
|
|
72
|
+
return this.styles.overflowWrap;
|
|
73
|
+
}
|
|
74
|
+
get writingMode() {
|
|
75
|
+
return this.styles.writingMode;
|
|
76
|
+
}
|
|
77
|
+
get direction() {
|
|
78
|
+
return this.styles.direction;
|
|
79
|
+
}
|
|
80
|
+
get webkitTextStrokeColor() {
|
|
81
|
+
return this.styles.webkitTextStrokeColor;
|
|
82
|
+
}
|
|
83
|
+
get webkitTextStrokeWidth() {
|
|
84
|
+
return this.styles.webkitTextStrokeWidth;
|
|
85
|
+
}
|
|
86
|
+
get webkitLineClamp() {
|
|
87
|
+
return this.styles.webkitLineClamp;
|
|
88
|
+
}
|
|
89
|
+
get paintOrder() {
|
|
90
|
+
return this.styles.paintOrder;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.FontStyles = FontStyles;
|