Skillshub typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/HoangNguyen0403/agent-skills-standard/typescript-security" ~/.claude/skills/comeonoliver-skillshub-typescript-security-89f1ae && rm -rf "$T"
manifest:
skills/HoangNguyen0403/agent-skills-standard/typescript-security/SKILL.mdsource content
TypeScript Security
Priority: P0 (CRITICAL)
Security standards for TypeScript applications based on OWASP guidelines.
Implementation Guidelines
- Validation: Use
,Zod
, orJoi
at the API boundary. Alwaysclass-validator
and validateparse
before using. Useuser-controlled input
for error handling without throwing. ReturnsafeParse
on failure.400 with structured errors - Sanitization: Use
for HTML sanitization to prevent Cross-Site Scripting (XSS).DOMPurify - Secrets: Store secrets in
(e.g.,.env
) or Secret Managers. NEVER commit them to Git.JWT_SECRET - Vulnerabilities: Prevent SQL Injection using Parameterized Queries (e.g.,
) or Type-safe ORMs (pool.query('... WHERE id = $1', [id])
/Prisma
). UseTypeORM
for raw queries.Prisma.sql - Authentication: Use
for password hashing. ImplementArgon2id
(viaJWT
orjsonwebtoken
) withjose
andHttpOnly
cookies. UseSecure
for public/private key pairs and implementRS256
.Refresh Token rotation - CORS: Configure
with Strict Origin Whitelisting. AvoidCORS
.origin: '*' - Encryption: Use
(Node.js) orcrypto
for sensitive data. Avoid legacy algorithms like MD5/SHA1.Web Crypto API - Input Filtering: Sanitize
before using it in file paths or OS commands (Command Injection).user-controlled input
Verification
After typing validation schemas (Zod/joi) or auth guards, call
getDiagnostics (typescript-lsp) to confirm type narrowing is correct before finalizing.
Anti-Patterns
- No
: Avoid dynamic execution.eval() - No Plaintext: Never commit secrets.
- No Trust: Validate everything server-side.
References
See references/REFERENCE.md for Zod validation, secure cookie setup, JWT auth, security headers, and RBAC patterns.