@types/dompurify

  • Version 3.0.5
  • Published
  • 8.52 kB
  • 1 dependency
  • MIT license

Install

npm i @types/dompurify
yarn add @types/dompurify
pnpm add @types/dompurify

Overview

TypeScript definitions for dompurify

Index

Variables

variable DOMPurify

const DOMPurify: createDOMPurifyI;

    Interfaces

    interface Config

    interface Config {}

      property ADD_ATTR

      ADD_ATTR?: string[] | undefined;

        property ADD_DATA_URI_TAGS

        ADD_DATA_URI_TAGS?: string[] | undefined;

          property ADD_TAGS

          ADD_TAGS?: string[] | undefined;

            property ADD_URI_SAFE_ATTR

            ADD_URI_SAFE_ATTR?: string[] | undefined;

              property ALLOW_ARIA_ATTR

              ALLOW_ARIA_ATTR?: boolean | undefined;

                property ALLOW_DATA_ATTR

                ALLOW_DATA_ATTR?: boolean | undefined;

                  property ALLOW_SELF_CLOSE_IN_ATTR

                  ALLOW_SELF_CLOSE_IN_ATTR?: boolean | undefined;

                    property ALLOW_UNKNOWN_PROTOCOLS

                    ALLOW_UNKNOWN_PROTOCOLS?: boolean | undefined;

                      property ALLOWED_ATTR

                      ALLOWED_ATTR?: string[] | undefined;

                        property ALLOWED_NAMESPACES

                        ALLOWED_NAMESPACES?: string[] | undefined;

                          property ALLOWED_TAGS

                          ALLOWED_TAGS?: string[] | undefined;

                            property ALLOWED_URI_REGEXP

                            ALLOWED_URI_REGEXP?: RegExp | undefined;

                              property CUSTOM_ELEMENT_HANDLING

                              CUSTOM_ELEMENT_HANDLING?: {
                              tagNameCheck?: RegExp | ((tagName: string) => boolean) | null | undefined;
                              attributeNameCheck?:
                              | RegExp
                              | ((lcName: string) => boolean)
                              | null
                              | undefined;
                              allowCustomizedBuiltInElements?: boolean | undefined;
                              };

                                property FORBID_ATTR

                                FORBID_ATTR?: string[] | undefined;

                                  property FORBID_CONTENTS

                                  FORBID_CONTENTS?: string[] | undefined;

                                    property FORBID_TAGS

                                    FORBID_TAGS?: string[] | undefined;

                                      property FORCE_BODY

                                      FORCE_BODY?: boolean | undefined;

                                        property IN_PLACE

                                        IN_PLACE?: boolean | undefined;

                                          property KEEP_CONTENT

                                          KEEP_CONTENT?: boolean | undefined;

                                            property NAMESPACE

                                            NAMESPACE?: string | undefined;
                                            • change the default namespace from HTML to something different

                                            property PARSER_MEDIA_TYPE

                                            PARSER_MEDIA_TYPE?: string | undefined;

                                              property RETURN_DOM

                                              RETURN_DOM?: boolean | undefined;

                                                property RETURN_DOM_FRAGMENT

                                                RETURN_DOM_FRAGMENT?: boolean | undefined;

                                                  property RETURN_DOM_IMPORT

                                                  RETURN_DOM_IMPORT?: boolean | undefined;
                                                  • This defaults to true starting DOMPurify 2.2.0. Note that setting it to false might cause XSS from attacks hidden in closed shadowroots in case the browser supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/

                                                  property RETURN_TRUSTED_TYPE

                                                  RETURN_TRUSTED_TYPE?: boolean | undefined;

                                                    property SAFE_FOR_TEMPLATES

                                                    SAFE_FOR_TEMPLATES?: boolean | undefined;

                                                      property SANITIZE_DOM

                                                      SANITIZE_DOM?: boolean | undefined;

                                                        property SANITIZE_NAMED_PROPS

                                                        SANITIZE_NAMED_PROPS?: boolean | undefined;
                                                        • false

                                                        property USE_PROFILES

                                                        USE_PROFILES?:
                                                        | false
                                                        | {
                                                        mathMl?: boolean | undefined;
                                                        svg?: boolean | undefined;
                                                        svgFilters?: boolean | undefined;
                                                        html?: boolean | undefined;
                                                        }
                                                        | undefined;

                                                          property WHOLE_DOCUMENT

                                                          WHOLE_DOCUMENT?: boolean | undefined;

                                                            interface DOMPurifyI

                                                            interface DOMPurifyI {}

                                                              property isSupported

                                                              isSupported: boolean;

                                                                property removed

                                                                removed: any[];

                                                                  property version

                                                                  version: string;

                                                                    method addHook

                                                                    addHook: {
                                                                    (
                                                                    hook: 'uponSanitizeElement',
                                                                    cb: (
                                                                    currentNode: Element,
                                                                    data: SanitizeElementHookEvent,
                                                                    config: Config
                                                                    ) => void
                                                                    ): void;
                                                                    (
                                                                    hook: 'uponSanitizeAttribute',
                                                                    cb: (
                                                                    currentNode: Element,
                                                                    data: SanitizeAttributeHookEvent,
                                                                    config: Config
                                                                    ) => void
                                                                    ): void;
                                                                    (
                                                                    hook: HookName,
                                                                    cb: (currentNode: Element, data: HookEvent, config: Config) => void
                                                                    ): void;
                                                                    };

                                                                      method clearConfig

                                                                      clearConfig: () => void;

                                                                        method isValidAttribute

                                                                        isValidAttribute: (tag: string, attr: string, value: string) => boolean;

                                                                          method removeAllHooks

                                                                          removeAllHooks: () => void;

                                                                            method removeHook

                                                                            removeHook: (entryPoint: HookName) => void;

                                                                              method removeHooks

                                                                              removeHooks: (entryPoint: HookName) => void;

                                                                                method sanitize

                                                                                sanitize: {
                                                                                (source: string | Node): string;
                                                                                (
                                                                                source: string | Node,
                                                                                config: Config & { RETURN_TRUSTED_TYPE: true }
                                                                                ): TrustedHTML;
                                                                                (
                                                                                source: string | Node,
                                                                                config: Config & { RETURN_DOM_FRAGMENT?: false; RETURN_DOM?: false }
                                                                                ): string;
                                                                                (
                                                                                source: string | Node,
                                                                                config: Config & { RETURN_DOM_FRAGMENT: true }
                                                                                ): DocumentFragment;
                                                                                (source: string | Node, config: Config & { RETURN_DOM: true }): HTMLElement;
                                                                                (source: string | Node, config: Config):
                                                                                | string
                                                                                | DocumentFragment
                                                                                | HTMLElement;
                                                                                };

                                                                                  method setConfig

                                                                                  setConfig: (cfg: Config) => void;

                                                                                    interface SanitizeAttributeHookEvent

                                                                                    interface SanitizeAttributeHookEvent {}

                                                                                      property allowedAttributes

                                                                                      allowedAttributes: { [key: string]: boolean };

                                                                                        property attrName

                                                                                        attrName: string;

                                                                                          property attrValue

                                                                                          attrValue: string;

                                                                                            property forceKeepAttr

                                                                                            forceKeepAttr?: boolean | undefined;

                                                                                              property keepAttr

                                                                                              keepAttr: boolean;

                                                                                                interface SanitizeElementHookEvent

                                                                                                interface SanitizeElementHookEvent {}

                                                                                                  property allowedTags

                                                                                                  allowedTags: { [key: string]: boolean };

                                                                                                    property tagName

                                                                                                    tagName: string;

                                                                                                      Type Aliases

                                                                                                      type HookEvent

                                                                                                      type HookEvent = SanitizeElementHookEvent | SanitizeAttributeHookEvent | null;

                                                                                                        type HookName

                                                                                                        type HookName =
                                                                                                        | 'beforeSanitizeElements'
                                                                                                        | 'uponSanitizeElement'
                                                                                                        | 'afterSanitizeElements'
                                                                                                        | 'beforeSanitizeAttributes'
                                                                                                        | 'uponSanitizeAttribute'
                                                                                                        | 'afterSanitizeAttributes'
                                                                                                        | 'beforeSanitizeShadowDOM'
                                                                                                        | 'uponSanitizeShadowNode'
                                                                                                        | 'afterSanitizeShadowDOM';

                                                                                                          Package Files (1)

                                                                                                          Dependencies (1)

                                                                                                          Dev Dependencies (0)

                                                                                                          No dev dependencies.

                                                                                                          Peer Dependencies (0)

                                                                                                          No peer dependencies.

                                                                                                          Badge

                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/dompurify.

                                                                                                          • Markdown
                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/dompurify)
                                                                                                          • HTML
                                                                                                            <a href="https://www.jsdocs.io/package/@types/dompurify"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>