Noncollinear Perpendicular Microcrystalline

    @mohalla-tech/xss-safeguard
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.3 • Public • Published
    Anurag Garg

    XSS Safeguard

    Performance oriented safeguard for all possible XSS attacks

    Made with ❤️ by developers for developers

    build build build build

    Want to show your love?

    Click on 🌟 button.

    Table of Contents

    Installation

    $ yarn add @mohalla-tech/xss-safeguard

    OR

    $ npm i @mohalla-tech/xss-safeguard --save

    Features

    • URL sanitization (With express middleware for SSR) 💯
    • Query Param Sanitization (Client Side) 💯
    • String Sanitization 💯
    • Input Sanitization 💯

    Usage

    Express Middleware for SSR

    import express from 'express';
    import { secure } from '@mohalla-tech/xss-safeguard';
    
    const app = express();
    
    // Default configuration
    app.use(secure());
    
    // Callback on xss attack
    app.use(secure({ callback: () => {} }));
    
    // Custom response handler when xss attack happens
    app.use(
      secure({
        handleResponseCustom: res => {
          res.redirect('/error');
        },
      })
    );

    Query Param Sanitization

    import { getSafeSearchParam } from '@mohalla-tech/xss-safeguard';
    
    // URL : https://sharechat.com?language=en
    const sanitizedString = getSafeSearchParam('language');
    console.log(sanitizedString); // en
    
    // URL : https://sharechat.com?language=<script>alert("Hello")</script>
    const sanitizedString = getSafeSearchParam('language');
    console.log(sanitizedString); // scriptalertHello/script

    String Sanitization

    import { sanitizeString } from '@mohalla-tech/xss-safeguard';
    
    const sanitizedString = sanitizeString('<script>Hello</script>');
    console.log(sanitizedString);

    FAQ

    Is it supported and tested both on web and mobile?

    Yes

    Contributing

    To get started...

    Step 1

    • Option 1

      • 🍴 Fork this repo!
    • Option 2

      • 👯 Clone this repo to your local machine using https://github.com/ShareChat/xss-safeguard

    Step 2

    • HACK AWAY! 🔨🔨🔨

    Step 3

    Support

    Reach out to one of the following:

    License

    License

    Install

    npm i @mohalla-tech/xss-safeguard

    DownloadsWeekly Downloads

    109

    Version

    0.1.3

    License

    MIT

    Unpacked Size

    30.5 kB

    Total Files

    15

    Last publish

    Collaborators

    • sumit7sinha
    • garganurag99
    • kiranjavvajisc
    • vinodsai-a
    • amit_shukla
    • aloksingh3112
    • ashutoshtanwar
    • shivani-sehgal
    • ashishkothari
    • hdwivedi9
    • prarabdhb
    • shivamrr9
    • mohalla-tech-web
    • webos002
    • bhupali-sharechat