
Research
/Security News
Chrome and Firefox Extensions Posing as Free VPNs Add Clipboard Stealers via Malicious Updates
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.
najm-cookies
Advanced tools
Cookie handling plugin for Najm API framework. Provides both property-level service injection and parameter-level cookie extraction.
bun add najm-cookies
import { Server } from 'najm-core';
import { cookies } from 'najm-cookies';
new Server()
.use(cookies({
prefix: 'app_',
secure: true,
}))
.load(YourController)
.listen(3000);
Quick read-only access to cookie values in method parameters.
import { Cookie } from 'najm-cookies';
class UserController {
@Get('/profile')
getProfile(
@Cookie() allCookies: Record<string, string>, // All cookies
@Cookie('sessionId') sessionId: string // Specific cookie
) {
return { sessionId, allCookies };
}
@Get('/check')
checkAuth(@Cookie('token') token: string) {
return { authenticated: !!token };
}
}
Full CookieService injection for read/write operations.
import { Cookies, CookieService } from 'najm-cookies';
class AuthController {
@Cookies()
private cookies!: CookieService;
// With options
@Cookies({ prefix: 'auth_', secret: 'my-secret' })
private authCookies!: CookieService;
@Post('/login')
login() {
this.cookies.set('token', 'abc123');
this.authCookies.setSigned('session', 'data', 'secret');
return { success: true };
}
@Post('/logout')
logout() {
this.cookies.delete('token');
return { success: true };
}
}
| Scenario | Decorator |
|---|---|
| Read cookie in handler params | @Cookie('name') |
| Read all cookies | @Cookie() |
| Set/Delete cookies | @Cookies() |
| Signed cookies | @Cookies() |
| JSON cookies | @Cookies() |
| Cookie prefixing | @Cookies({ prefix: 'x_' }) |
get(name): Get cookie valueset(name, value, options?): Set cookie valuedelete(name, options?): Delete cookiehas(name): Check if cookie existsgetAll(): Get all cookiessetSecure(name, value, options?): Set with httpOnly, secure, sameSite=StrictsetSession(name, value, options?): Session cookie (no maxAge/expires)setPersistent(name, value, days?, options?): Persistent cookie with expirygetSigned(name, secret): Get and verify signed cookiesetSigned(name, value, secret, options?): Set signed cookiegetJSON<T>(name): Get and parse JSON cookiesetJSON(name, value, options?): Set JSON cookiecookies({
httpOnly: true, // Default: true
secure: true, // Default: true in production
sameSite: 'Lax', // 'Strict' | 'Lax' | 'None'
path: '/', // Cookie path
domain: 'example.com', // Cookie domain
maxAge: 86400, // Max age in seconds
prefix: 'app_', // Prefix for all cookie names
})
import { Cookie, Cookies, CookieService } from 'najm-cookies';
class SessionController {
@Cookies({ prefix: 'sess_' })
private cookies!: CookieService;
@Post('/login')
login() {
// Use CookieService to SET cookies
this.cookies.set('token', 'jwt-value');
this.cookies.setJSON('user', { id: 1, role: 'admin' });
return { success: true };
}
@Get('/me')
getMe(
@Cookie('sess_token') token: string, // Quick read via param
) {
// Use @Cookie for quick reads
if (!token) return { error: 'Not authenticated' };
return { token };
}
@Post('/logout')
logout() {
// Use CookieService to DELETE cookies
this.cookies.delete('token');
this.cookies.delete('user');
return { success: true };
}
}
MIT
FAQs
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.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.