2.1.0 • Published 6 years ago

safe-json-globals v2.1.0

Weekly downloads
52
License
-
Repository
github
Last release
6 years ago

safe-json-globals

build status dependency status

Safely embed serialized JSON in a page as temporary global data. HTML tags are sanitized.

Example for the server

var JSONGlobals = require("safe-json-globals")

function (req, res) {
    getUser(req, res, function (userRecord) {
        var globalsMarkup = JSONGlobals({
          user: userRecord,
          potentialMaliciousContent: "</script><script>alert('hack')"
        })

        var html = "" // whatever html

        html += globalsMarkup

        res.end(html)
    })
}

Example for the client

var JSONGlobals = require("safe-json-globals/get")

var user = JSONGlobals("user")

Installation

npm install safe-json-globals

Contributors

  • Raynos
  • lxe

MIT Licenced

2.1.0

6 years ago

3.1.0

6 years ago

3.0.0

7 years ago

2.0.3-alpha0.1

8 years ago

1.0.2

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago