Use ctxProtect helper in your Handlebars template to use ctx on secrets:
{{ ctxProtect 'a secret' 'an origin' }}}
secret is a string containing the secret that needs to be protected and
origin is a string uniquely identifying the CTX origin for the secret.
Add the ctxPermutations helper in your Handlebars template
to include the used permutations for each origin:
{{ ctxPermutations }}
The ctxPermutations helper needs to be included after all ctxProtect
helpers that use an origin for the first time. It is proposed that it is
included before the
HTML tag.
Include the client ctx script tag before the HTML tag:
Use ctxProtect to your pug templates to use ctx on secrets:
div ctxProtect('a secret' 'an origin')
secret is a string containing the secret that needs to be protected and
origin is a string uniquely identifying the CTX origin for the secret.
Add the ctxPermutations to your pug templates to
to include the used permutations for each origin:
div=ctxPermutations()
The ctxPermutations helper needs to be included after all ctxProtect
helpers that use an origin for the first time. It is proposed that it is
included before the HTML tag.
Html
Head
title pug ctx exapmle
Body
div secret1 from user1
div!=ctxProtect('lorem ipsum', 'user1')
div secret1 from user1
div!=ctxProtect('dolor sit amet', 'user1')
div secret2 from user2
div!=ctxProtect('Lorem ipsum dolor sit amet',o 'user2')
div!=ctxPermutations()
Basic Usage in Express/EJS projects
Import nodejs-ctx-defense to your Express/EJS project, initialise ctxObject and
add ctxProtect and ctxPermutations in your app.locals,
as decribed for the Express/Jade projects.
Add ctxProtect tag in your EJS template
<%- ctxProtect('secret', 'origin') %>
and ctxPermutations tag before
<%- ctxPermutations() %>
Basic Usage in Koa/koa-pug projects
Import nodejs-ctx-defense to your Koa/koa-pug project,