Allow default imports in TS
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"module": "commonjs"
|
"module": "commonjs",
|
||||||
|
"esModuleInterop": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
5
typings/xss-default-import.ts
Normal file
5
typings/xss-default-import.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/// <reference path="./xss.d.ts" />
|
||||||
|
|
||||||
|
import xss from "xss";
|
||||||
|
|
||||||
|
console.log(xss("<script>alert('xss');</script>"));
|
||||||
330
typings/xss.d.ts
vendored
330
typings/xss.d.ts
vendored
@@ -4,186 +4,190 @@
|
|||||||
* @author Zongmin Lei<leizongmin@gmail.com>
|
* @author Zongmin Lei<leizongmin@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare global {
|
declare module "xss" {
|
||||||
function filterXSS(html: string, options?: IFilterXSSOptions): string;
|
global {
|
||||||
|
function filterXSS(html: string, options?: IFilterXSSOptions): string;
|
||||||
|
|
||||||
namespace XSS {
|
namespace XSS {
|
||||||
export interface IFilterXSSOptions {
|
export interface IFilterXSSOptions {
|
||||||
whiteList?: IWhiteList;
|
whiteList?: IWhiteList;
|
||||||
onTag?: OnTagHandler;
|
onTag?: OnTagHandler;
|
||||||
onTagAttr?: OnTagAttrHandler;
|
onTagAttr?: OnTagAttrHandler;
|
||||||
onIgnoreTag?: OnTagHandler;
|
onIgnoreTag?: OnTagHandler;
|
||||||
onIgnoreTagAttr?: OnTagAttrHandler;
|
onIgnoreTagAttr?: OnTagAttrHandler;
|
||||||
safeAttrValue?: SafeAttrValueHandler;
|
safeAttrValue?: SafeAttrValueHandler;
|
||||||
escapeHtml?: EscapeHandler;
|
escapeHtml?: EscapeHandler;
|
||||||
stripIgnoreTag?: boolean;
|
stripIgnoreTag?: boolean;
|
||||||
stripIgnoreTagBody?: boolean | string[];
|
stripIgnoreTagBody?: boolean | string[];
|
||||||
allowCommentTag?: boolean;
|
allowCommentTag?: boolean;
|
||||||
stripBlankChar?: boolean;
|
stripBlankChar?: boolean;
|
||||||
css?: {} | boolean;
|
css?: {} | boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IWhiteList {
|
interface IWhiteList {
|
||||||
a?: string[];
|
a?: string[];
|
||||||
abbr?: string[];
|
abbr?: string[];
|
||||||
address?: string[];
|
address?: string[];
|
||||||
area?: string[];
|
area?: string[];
|
||||||
article?: string[];
|
article?: string[];
|
||||||
aside?: string[];
|
aside?: string[];
|
||||||
audio?: string[];
|
audio?: string[];
|
||||||
b?: string[];
|
b?: string[];
|
||||||
bdi?: string[];
|
bdi?: string[];
|
||||||
bdo?: string[];
|
bdo?: string[];
|
||||||
big?: string[];
|
big?: string[];
|
||||||
blockquote?: string[];
|
blockquote?: string[];
|
||||||
br?: string[];
|
br?: string[];
|
||||||
caption?: string[];
|
caption?: string[];
|
||||||
center?: string[];
|
center?: string[];
|
||||||
cite?: string[];
|
cite?: string[];
|
||||||
code?: string[];
|
code?: string[];
|
||||||
col?: string[];
|
col?: string[];
|
||||||
colgroup?: string[];
|
colgroup?: string[];
|
||||||
dd?: string[];
|
dd?: string[];
|
||||||
del?: string[];
|
del?: string[];
|
||||||
details?: string[];
|
details?: string[];
|
||||||
div?: string[];
|
div?: string[];
|
||||||
dl?: string[];
|
dl?: string[];
|
||||||
dt?: string[];
|
dt?: string[];
|
||||||
em?: string[];
|
em?: string[];
|
||||||
font?: string[];
|
font?: string[];
|
||||||
footer?: string[];
|
footer?: string[];
|
||||||
h1?: string[];
|
h1?: string[];
|
||||||
h2?: string[];
|
h2?: string[];
|
||||||
h3?: string[];
|
h3?: string[];
|
||||||
h4?: string[];
|
h4?: string[];
|
||||||
h5?: string[];
|
h5?: string[];
|
||||||
h6?: string[];
|
h6?: string[];
|
||||||
header?: string[];
|
header?: string[];
|
||||||
hr?: string[];
|
hr?: string[];
|
||||||
i?: string[];
|
i?: string[];
|
||||||
img?: string[];
|
img?: string[];
|
||||||
ins?: string[];
|
ins?: string[];
|
||||||
li?: string[];
|
li?: string[];
|
||||||
mark?: string[];
|
mark?: string[];
|
||||||
nav?: string[];
|
nav?: string[];
|
||||||
ol?: string[];
|
ol?: string[];
|
||||||
p?: string[];
|
p?: string[];
|
||||||
pre?: string[];
|
pre?: string[];
|
||||||
s?: string[];
|
s?: string[];
|
||||||
section?: string[];
|
section?: string[];
|
||||||
small?: string[];
|
small?: string[];
|
||||||
span?: string[];
|
span?: string[];
|
||||||
sub?: string[];
|
sub?: string[];
|
||||||
sup?: string[];
|
sup?: string[];
|
||||||
strong?: string[];
|
strong?: string[];
|
||||||
table?: string[];
|
table?: string[];
|
||||||
tbody?: string[];
|
tbody?: string[];
|
||||||
td?: string[];
|
td?: string[];
|
||||||
tfoot?: string[];
|
tfoot?: string[];
|
||||||
th?: string[];
|
th?: string[];
|
||||||
thead?: string[];
|
thead?: string[];
|
||||||
tr?: string[];
|
tr?: string[];
|
||||||
tt?: string[];
|
tt?: string[];
|
||||||
u?: string[];
|
u?: string[];
|
||||||
ul?: string[];
|
ul?: string[];
|
||||||
video?: string[];
|
video?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
type OnTagHandler = (
|
type OnTagHandler = (
|
||||||
tag: string,
|
tag: string,
|
||||||
html: string,
|
html: string,
|
||||||
options: {}
|
options: {}
|
||||||
) => string | void;
|
) => string | void;
|
||||||
|
|
||||||
type OnTagAttrHandler = (
|
type OnTagAttrHandler = (
|
||||||
tag: string,
|
tag: string,
|
||||||
name: string,
|
name: string,
|
||||||
value: string,
|
value: string,
|
||||||
isWhiteAttr: boolean
|
isWhiteAttr: boolean
|
||||||
) => string | void;
|
) => string | void;
|
||||||
|
|
||||||
type SafeAttrValueHandler = (
|
type SafeAttrValueHandler = (
|
||||||
tag: string,
|
tag: string,
|
||||||
name: string,
|
name: string,
|
||||||
value: string,
|
value: string,
|
||||||
cssFilter: ICSSFilter
|
cssFilter: ICSSFilter
|
||||||
) => string;
|
) => string;
|
||||||
|
|
||||||
type EscapeHandler = (str: string) => string;
|
type EscapeHandler = (str: string) => string;
|
||||||
|
|
||||||
interface ICSSFilter {
|
interface ICSSFilter {
|
||||||
process(value: string): string;
|
process(value: string): string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
export interface IFilterXSSOptions extends XSS.IFilterXSSOptions {}
|
||||||
|
|
||||||
export interface IFilterXSSOptions extends XSS.IFilterXSSOptions {}
|
export interface IWhiteList extends XSS.IWhiteList {}
|
||||||
|
|
||||||
export interface IWhiteList extends XSS.IWhiteList {}
|
export type OnTagHandler = XSS.OnTagHandler;
|
||||||
|
|
||||||
export type OnTagHandler = XSS.OnTagHandler;
|
export type OnTagAttrHandler = XSS.OnTagAttrHandler;
|
||||||
|
|
||||||
export type OnTagAttrHandler = XSS.OnTagAttrHandler;
|
export type SafeAttrValueHandler = XSS.SafeAttrValueHandler;
|
||||||
|
|
||||||
export type SafeAttrValueHandler = XSS.SafeAttrValueHandler;
|
export type EscapeHandler = XSS.EscapeHandler;
|
||||||
|
|
||||||
export type EscapeHandler = XSS.EscapeHandler;
|
export interface ICSSFilter extends XSS.ICSSFilter {}
|
||||||
|
|
||||||
export interface ICSSFilter extends XSS.ICSSFilter {}
|
export function StripTagBody(
|
||||||
|
tags: string[],
|
||||||
|
next: () => void
|
||||||
|
): {
|
||||||
|
onIgnoreTag(
|
||||||
|
tag: string,
|
||||||
|
html: string,
|
||||||
|
options: {
|
||||||
|
position: number;
|
||||||
|
isClosing: boolean;
|
||||||
|
}
|
||||||
|
): string;
|
||||||
|
remove(html: string): string;
|
||||||
|
};
|
||||||
|
|
||||||
export function StripTagBody(
|
export class FilterXSS {
|
||||||
tags: string[],
|
constructor(options?: IFilterXSSOptions);
|
||||||
next: () => void
|
process(html: string): string;
|
||||||
): {
|
}
|
||||||
onIgnoreTag(
|
|
||||||
tag: string,
|
export function filterXSS(html: string, options?: IFilterXSSOptions): string;
|
||||||
|
export function parseTag(
|
||||||
html: string,
|
html: string,
|
||||||
options: {
|
onTag: (
|
||||||
position: number;
|
sourcePosition: number,
|
||||||
isClosing: boolean;
|
position: number,
|
||||||
}
|
tag: string,
|
||||||
|
html: string,
|
||||||
|
isClosing: boolean
|
||||||
|
) => string,
|
||||||
|
escapeHtml: EscapeHandler
|
||||||
): string;
|
): string;
|
||||||
remove(html: string): string;
|
export function parseAttr(
|
||||||
};
|
|
||||||
|
|
||||||
export class FilterXSS {
|
|
||||||
constructor(options?: IFilterXSSOptions);
|
|
||||||
process(html: string): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function filterXSS(html: string, options?: IFilterXSSOptions): string;
|
|
||||||
export function parseTag(
|
|
||||||
html: string,
|
|
||||||
onTag: (
|
|
||||||
sourcePosition: number,
|
|
||||||
position: number,
|
|
||||||
tag: string,
|
|
||||||
html: string,
|
html: string,
|
||||||
isClosing: boolean
|
onAttr: (name: string, value: string) => string
|
||||||
) => string,
|
): string;
|
||||||
escapeHtml: EscapeHandler
|
export const whiteList: IWhiteList;
|
||||||
): string;
|
export function getDefaultWhiteList(): IWhiteList;
|
||||||
export function parseAttr(
|
export const onTag: OnTagHandler;
|
||||||
html: string,
|
export const onIgnoreTag: OnTagHandler;
|
||||||
onAttr: (name: string, value: string) => string
|
export const onTagAttr: OnTagAttrHandler;
|
||||||
): string;
|
export const onIgnoreTagAttr: OnTagAttrHandler;
|
||||||
export const whiteList: IWhiteList;
|
export const safeAttrValue: SafeAttrValueHandler;
|
||||||
export function getDefaultWhiteList(): IWhiteList;
|
export const escapeHtml: EscapeHandler;
|
||||||
export const onTag: OnTagHandler;
|
export const escapeQuote: EscapeHandler;
|
||||||
export const onIgnoreTag: OnTagHandler;
|
export const unescapeQuote: EscapeHandler;
|
||||||
export const onTagAttr: OnTagAttrHandler;
|
export const escapeHtmlEntities: EscapeHandler;
|
||||||
export const onIgnoreTagAttr: OnTagAttrHandler;
|
export const escapeDangerHtml5Entities: EscapeHandler;
|
||||||
export const safeAttrValue: SafeAttrValueHandler;
|
export const clearNonPrintableCharacter: EscapeHandler;
|
||||||
export const escapeHtml: EscapeHandler;
|
export const friendlyAttrValue: EscapeHandler;
|
||||||
export const escapeQuote: EscapeHandler;
|
export const escapeAttrValue: EscapeHandler;
|
||||||
export const unescapeQuote: EscapeHandler;
|
export function onIgnoreTagStripAll(): string;
|
||||||
export const escapeHtmlEntities: EscapeHandler;
|
export const stripCommentTag: EscapeHandler;
|
||||||
export const escapeDangerHtml5Entities: EscapeHandler;
|
export const stripBlankChar: EscapeHandler;
|
||||||
export const clearNonPrintableCharacter: EscapeHandler;
|
export const cssFilter: ICSSFilter;
|
||||||
export const friendlyAttrValue: EscapeHandler;
|
export function getDefaultCSSWhiteList(): ICSSFilter;
|
||||||
export const escapeAttrValue: EscapeHandler;
|
|
||||||
export function onIgnoreTagStripAll(): string;
|
const xss: (html: string, options?: IFilterXSSOptions) => string;
|
||||||
export const stripCommentTag: EscapeHandler;
|
export default xss;
|
||||||
export const stripBlankChar: EscapeHandler;
|
}
|
||||||
export const cssFilter: ICSSFilter;
|
|
||||||
export function getDefaultCSSWhiteList(): ICSSFilter;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user