leizongmin / js-xss

Sanitize untrusted HTML (to prevent XSS) with a configuration specified by a Whitelist
http://jsxss.com
Other
5.2k stars 629 forks source link

Reorganised typings to expose the filterXSS function #155

Closed marekdedic closed 5 years ago

marekdedic commented 5 years ago

Fixes #154 Maybe breaks something else. I haven't yet figured out, how to run the typings tests.

leizongmin commented 5 years ago

Thanks. I have published a new version xss@1.0.4.

leizongmin commented 5 years ago

I found that is some problems. So please try the newest version xss@1.0.5, it exports an filterXSS function. See https://github.com/leizongmin/js-xss/commit/ad46d0aa0e1ce4d07ac9139ae14ed37c278a09a3

marekdedic commented 5 years ago

Hi, thanks, the typings for the filterXSS function are available now. However, I cannot access IFilterXSSOptions now - I think if they were to be moved to the declare global block, they would be available, but maybe they really should be namespaced to not pollute the global namespace. I don't know...

Anyway, thank you...

leizongmin commented 5 years ago

You can try this:

import * as xss from "xss";

const options: xss.IFilterXSSOptions = {}
leizongmin commented 5 years ago

I just add the global XSS namespace back, please try xss@1.0.6:

// interface or type don't required to import "xss" module, just use "XSS" namespace
// but filterXSS function still need to import "xss" module
const options: XSS.IFilterXSSOptions = {}
marekdedic commented 5 years ago

Hey, I've tried it and it all works now, thanks a lot. I used the XSS namespace, because I'm not using imports...

Done and thank you.