Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
hapi-stateless-notifications
Advanced tools
A simple, explicit-state plugin to pass notices between pages.
A plugin to handle saving notifications to pass to a following page, so you can redirect after post and all those niceties without having to fall back to session-associated flash messages.
// step 0: set up a plugin that gives a request.redis property that's a
// client connection, ready to use for this request. We steal the
// connection from `catbox-redis`.
server.register({
register: require('hapi-stateless-notifications'),
options: {
queryParameter: 'notice',
prefix: 'notice:',
timeout: 3600
}
});
The options
are optional.
options.queryParameter
controls which query parameter will cause the plugin to look up a token and defaults to 'notice'
options.prefix
controls the key prefix in redis, and defaults to 'notice:'
options.timeout
controls the the expiration timeout of the key in redis, in seconds. The default is 3600
, that is, one hour.
Then in a handler:
reply.saveNotifications([
Promise.resolve('Success message here ...'),
Promise.reject(new Error('Error message here ...')),
]).then(function (token) {
// if there's a token, put it in the query of the page you load next as `notice={token}`
// Otherwise, there's nothing to do.
});
Or more completely:
reply.redirectAndNotify([
Promise.resolve('Success message here ...'),
Promise.reject(new Error('Error message here ...')),
], '/next-page')
or if the failure path leads a different place:
reply.redirectAndNotify([
Promise.resolve('Success message here ...'),
Promise.reject(new Error('Error message here ...')),
], { success: '/next-page', failure: '/this-page' })
FAQs
A simple, explicit-state plugin to pass notices between pages.
The npm package hapi-stateless-notifications receives a total of 3 weekly downloads. As such, hapi-stateless-notifications popularity was classified as not popular.
We found that hapi-stateless-notifications demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 20 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.