cryptoserve 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,183 @@
1
+ # CryptoServe CLI (Node.js)
2
+
3
+ Zero-dependency CLI for cryptographic scanning, post-quantum readiness analysis, encryption, and local key management.
4
+
5
+ ```bash
6
+ npx cryptoserve pqc
7
+ ```
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ # Run without installing
13
+ npx cryptoserve help
14
+
15
+ # Or install globally
16
+ npm install -g cryptoserve
17
+ ```
18
+
19
+ Requires Node.js 18 or later. No dependencies — uses only Node.js built-in modules (`node:crypto`, `node:fs`, `node:https`).
20
+
21
+ ## Commands
22
+
23
+ | Command | Description |
24
+ |---------|-------------|
25
+ | `scan [path]` | Scan project for crypto libraries, hardcoded secrets, and weak patterns |
26
+ | `pqc` | Post-quantum readiness analysis with SNDL risk assessment |
27
+ | `encrypt` / `decrypt` | Password-based encryption (strings and files) |
28
+ | `context list` / `show` | List and inspect context-aware algorithm presets |
29
+ | `hash-password` | scrypt / PBKDF2 password hashing |
30
+ | `vault` | Encrypted local secret storage with env injection |
31
+ | `init` | Set up master key + AI tool protection |
32
+ | `login` / `status` | Connect to a CryptoServe server |
33
+
34
+ ## Scan
35
+
36
+ Detect crypto libraries, algorithm usage, hardcoded secrets, and certificate files in JavaScript/TypeScript projects.
37
+
38
+ ```bash
39
+ cryptoserve scan .
40
+ cryptoserve scan ./src --format json
41
+ ```
42
+
43
+ Detects 20+ crypto packages (`jsonwebtoken`, `node-forge`, `@noble/curves`, etc.), `node:crypto` API usage, algorithm string literals, weak patterns (MD5, DES, ECB, `createCipher`), and hardcoded API keys (AWS, OpenAI, Anthropic, GitHub, Stripe, and more).
44
+
45
+ ## PQC Analysis
46
+
47
+ Offline post-quantum readiness assessment. Evaluates your project's cryptographic posture against quantum threat timelines.
48
+
49
+ ```bash
50
+ cryptoserve pqc
51
+ cryptoserve pqc --profile healthcare
52
+ cryptoserve pqc --profile national_security --verbose
53
+ cryptoserve pqc --format json
54
+ ```
55
+
56
+ **Profiles:** `general`, `national_security`, `healthcare`, `financial`, `intellectual_property`, `legal`, `authentication`, `session_tokens`, `ephemeral`
57
+
58
+ Output includes quantum readiness score (0-100), SNDL risk assessment, KEM/signature recommendations (ML-KEM, ML-DSA, SLH-DSA), migration plan, and compliance references (CNSA 2.0, NIST SP 800-208, BSI, ANSSI).
59
+
60
+ ## Encrypt / Decrypt
61
+
62
+ AES-256-GCM, AES-128-GCM, and ChaCha20-Poly1305 encryption with password-based key derivation (scrypt).
63
+
64
+ ```bash
65
+ # Text
66
+ cryptoserve encrypt "sensitive data" --password mypassword
67
+ cryptoserve decrypt "<base64 output>" --password mypassword
68
+
69
+ # Files
70
+ cryptoserve encrypt --file report.pdf --output report.enc --password mypassword
71
+ cryptoserve decrypt --file report.enc --output report.pdf --password mypassword
72
+
73
+ # Choose algorithm
74
+ cryptoserve encrypt "data" --algorithm ChaCha20-Poly1305 --password mypassword
75
+
76
+ # Context-aware (auto-selects algorithm based on data sensitivity)
77
+ cryptoserve encrypt "SSN: 123-45-6789" --context user-pii --password mypassword
78
+ ```
79
+
80
+ ### Cross-SDK Compatibility
81
+
82
+ The encrypted blob format is byte-identical between the Python and Node.js SDKs. Data encrypted by one can be decrypted by the other:
83
+
84
+ ```
85
+ [header_len: 2 bytes][JSON header][ciphertext + auth tag]
86
+ ```
87
+
88
+ ## Context-Aware Encryption
89
+
90
+ A 5-layer algorithm resolver selects the optimal encryption algorithm based on data sensitivity, compliance requirements, threat model, and access patterns.
91
+
92
+ ```bash
93
+ # List available contexts
94
+ cryptoserve context list
95
+
96
+ # Show full resolution rationale
97
+ cryptoserve context show user-pii --verbose
98
+
99
+ # Encrypt with automatic algorithm selection
100
+ cryptoserve encrypt "patient diagnosis" --context health-data --password mypassword
101
+ ```
102
+
103
+ ### Built-in Contexts
104
+
105
+ | Context | Sensitivity | Algorithm | Compliance |
106
+ |---------|------------|-----------|------------|
107
+ | `user-pii` | High | AES-256-GCM | GDPR |
108
+ | `payment-data` | Critical | AES-256-GCM | PCI-DSS |
109
+ | `session-tokens` | Medium | AES-128-GCM | OWASP |
110
+ | `health-data` | Critical | AES-256-GCM | HIPAA |
111
+ | `general` | Medium | AES-128-GCM | — |
112
+
113
+ ### Custom Contexts
114
+
115
+ Add project-specific contexts in `.cryptoserve.json`:
116
+
117
+ ```json
118
+ {
119
+ "contexts": {
120
+ "audit-logs": {
121
+ "displayName": "Audit Logs",
122
+ "sensitivity": "high",
123
+ "compliance": ["SOX"],
124
+ "adversaries": ["insider"],
125
+ "protectionYears": 7,
126
+ "usage": "at_rest",
127
+ "frequency": "high"
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ ## Password Hashing
134
+
135
+ ```bash
136
+ cryptoserve hash-password
137
+ cryptoserve hash-password --algorithm pbkdf2
138
+ ```
139
+
140
+ Outputs `$scrypt$...` or `$pbkdf2-sha256$...` format strings.
141
+
142
+ ## Vault
143
+
144
+ Encrypted local secret storage using AES-256-GCM. Secrets are stored at `~/.cryptoserve/vault.enc`.
145
+
146
+ ```bash
147
+ cryptoserve vault init
148
+ cryptoserve vault set DATABASE_URL "postgres://..."
149
+ cryptoserve vault set API_KEY "sk-..."
150
+ cryptoserve vault get DATABASE_URL
151
+ cryptoserve vault list
152
+
153
+ # Run a command with secrets injected as environment variables
154
+ cryptoserve vault run -- node server.js
155
+
156
+ # Import from .env file
157
+ cryptoserve vault import .env
158
+ ```
159
+
160
+ ## Init
161
+
162
+ Set up master key storage and AI tool protection in one command.
163
+
164
+ ```bash
165
+ cryptoserve init
166
+ ```
167
+
168
+ This generates a master key (stored in OS keychain on macOS/Linux, encrypted file fallback), detects AI coding tools (Claude Code, Cursor, Copilot, Windsurf, Cline, Aider), and configures deny rules to prevent them from reading `.env`, `.pem`, `.key`, and other sensitive files.
169
+
170
+ ## Programmatic Usage
171
+
172
+ All modules are importable as ES modules:
173
+
174
+ ```javascript
175
+ import { encrypt, decrypt, encryptString, decryptString } from 'cryptoserve/lib/local-crypto.mjs';
176
+ import { analyzeOffline } from 'cryptoserve/lib/pqc-engine.mjs';
177
+ import { scanProject } from 'cryptoserve/lib/scanner.mjs';
178
+ import { resolveContext } from 'cryptoserve/lib/context-resolver.mjs';
179
+ ```
180
+
181
+ ## License
182
+
183
+ Apache-2.0