Skip to content

Commit 7ab9ae4

Browse files
committed
chore: wip
1 parent b917d08 commit 7ab9ae4

1 file changed

Lines changed: 105 additions & 0 deletions

File tree

.cursor/rules/readme.mdc

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,108 @@ description: General information based on the latest ./README.md content
33
globs:
44
---
55
# ts-security
6+
7+
> A comprehensive TypeScript security library providing cryptographic primitives and utilities with a focus on type safety, security, performance, and modern best practices.
8+
9+
## Features
10+
11+
- 🔒 **Cryptographic Primitives**
12+
- AES encryption _(128/192/256-bit)_ with multiple modes _(ECB, CBC, CFB, OFB, CTR, GCM)_
13+
- SHA-2 family hash functions _(SHA-256, SHA-384, SHA-512)_
14+
- HMAC message authentication
15+
- RSA encryption and signing
16+
- Ed25519 digital signatures
17+
18+
- 🛡️ **Secure Random Number Generation**
19+
- Fortuna CSPRNG implementation
20+
- Multiple entropy sources
21+
- Automatic reseeding
22+
- Browser and Node.js support
23+
24+
- 📜 **Certificate Management**
25+
- X.509 certificate handling
26+
- PEM encoding/decoding
27+
- Certificate signing request _(CSR)_ creation
28+
- Certificate chain validation
29+
30+
- 🔐 **TLS/SSL Support**
31+
- TLS protocol implementation
32+
- Secure socket connections
33+
- Certificate-based authentication
34+
- Modern cipher suite support
35+
36+
- 🎯 **Type Safety**
37+
- Full TypeScript support
38+
- Comprehensive type definitions
39+
- Strict type checking
40+
- Modern ES6+ features
41+
42+
- 🧰 **Utilities**
43+
- Base-N encoding _(Base64, Base58, etc.)_
44+
- ASN.1 encoding/decoding
45+
- BigInteger arithmetic
46+
- Buffer manipulation
47+
48+
## Install
49+
50+
```bash
51+
# bun
52+
bun install ts-security
53+
54+
# npm
55+
npm install ts-security
56+
57+
# pnpm
58+
pnpm install ts-security
59+
```
60+
61+
## Get Started
62+
63+
After installing the package, you can import and use the various cryptographic functions:
64+
65+
```ts
66+
import {
67+
aes,
68+
sha256,
69+
sha512,
70+
random,
71+
hmac,
72+
rsa,
73+
ed25519,
74+
pki,
75+
tls
76+
} from 'ts-security'
77+
78+
// AES Encryption
79+
const cipher = aes.createCipher('AES-GCM', key)
80+
cipher.start({ iv: iv })
81+
cipher.update(data)
82+
const encrypted = cipher.finish()
83+
84+
// SHA-256 Hashing
85+
const md = sha256.create()
86+
md.update('Hello, World!')
87+
const hash = md.digest().toHex()
88+
89+
// Secure Random Numbers
90+
const bytes = random.getBytesSync(32)
91+
92+
// RSA Key Generation
93+
const keypair = rsa.generateKeyPair({ bits: 2048 })
94+
95+
// Digital Signatures
96+
const signature = ed25519.sign(message, privateKey)
97+
const isValid = ed25519.verify(signature, message, publicKey)
98+
99+
// Certificate Operations
100+
const cert = pki.createCertificate()
101+
cert.publicKey = keypair.publicKey
102+
cert.sign(keypair.privateKey)
103+
104+
// TLS Connections
105+
const connection = tls.connect({
106+
server: host,
107+
port: 443,
108+
caStore: [/* trusted certificates */]
109+
})
110+
```

0 commit comments

Comments
 (0)