typescript-security
Secure coding practices for building safe TypeScript applications.
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
TypeScript Security
Priority: P0 (CRITICAL)
Security standards for TypeScript applications based on OWASP guidelines.
Implementation Guidelines
-
Validation: Validate all inputs with
zod/joi/class-validator. -
Sanitization: Use
DOMPurifyfor HTML. Prevent XSS. - Secrets: Use env vars. Never hardcode.
- SQL Injection: Use parameterized queries or ORMs (Prisma/TypeORM).
-
Auth: Use
bcryptfor hashing. Implement strict RBAC. -
HTTPS: Enforce HTTPS. Set
secure,httpOnly,sameSitecookies. - Rate Limit: Prevent brute-force/DDoS.
-
Deps: Audit with
npm audit.
Anti-Patterns
-
No
eval(): Avoid dynamic execution. - No Plaintext: Never commit secrets.
- No Trust: Validate everything server-side.
Code
// Validation (Zod)
const UserSchema = z.object({
email: z.string().email(),
password: z.string().min(8),
});
// Secure Cookie
const cookieOpts = {
httpOnly: true,
secure: process.env.NODE_ENV === 'prod',
sameSite: 'strict' as const,
};
Reference & Examples
For authentication patterns and security headers: See references/REFERENCE.md.
Related Topics
common/security-standards | best-practices | language
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!