Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@valora/express-siwe
Advanced tools
Readme
SIWE middlewares for express applications
import express from 'express'
import Session from 'express-session'
import { loginHandler, authMiddleware, SiweError } from '@valora/express-siwe'
// initialize express app and include session and json body parser middlewares
const app = express()
app.use(
Session({
secret: 'secret',
}),
)
app.use(express.json())
// add login route
app.use(
'/auth/login',
loginHandler({
sessionDurationMs: 3600000,
validateNonce: async (nonce: string) => {
/* validate nonce, ensure it isn't already used and return true / false */
},
markNonceAsUsed: async (nonce: string, expirationTime: Date) => {
/* save nonce to some store */
},
chainId: 1,
domain: 'foo.com',
}),
)
// include auth middleware for secure routes
app.get('/some/secure/route', authMiddleware, (req, res) => {
/* handle request */
})
// error handler
app.use((err, req, res, next) => {
if (err instanceof SiweError) {
/* handle siwe error and return appropriate error codes */
}
/* handle other errors */
})
Creates an express router with a single post route /
that handles a SIWE login
request. The route expects a JSON body with shape:
{
"message": "<the serialized SIWE message>",
"signature": "<the SIWE signature>"
}
On a successful SIWE login, the route returns a 200
response with a session
cookie. On any error, the route invokes the express next
function with a
SiweRequestError
with appropriate SiweRequestErrorType
.
Login Options:
validateNonce: (nonce: string) => Promise<boolean>
, required
markNonceAsUsed: (nonce: string, expirationTime: Date) => Promise<void>
, required
sessionDurationMs: number
, required
chainId: number
, optional
domain: string
, optional
An express middleware that validates whether a SIWE session exists. Invokes
next
with no args if a valid session exists. Otherwise, invokes next
with a
SiweRequestError
of type SiweRequestErrorType.UNAUTHORIZED
.
FAQs
SIWE middlewares for express applications
The npm package @valora/express-siwe receives a total of 173 weekly downloads. As such, @valora/express-siwe popularity was classified as not popular.
We found that @valora/express-siwe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.