@allsecurex-quantum/crypto-shim 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AllSecureX
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,261 @@
1
+ # @quantumvault/crypto-shim
2
+
3
+ <p align="center">
4
+ <strong>A Product of <a href="https://allsecurex.com">AllSecureX</a></strong><br>
5
+ Enterprise-Grade Post-Quantum Cryptography
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="https://github.com/AllSecureX-Quantum/crypto-shim-nodejs/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
10
+ <a href="https://www.npmjs.com/package/@quantumvault/crypto-shim"><img src="https://img.shields.io/npm/v/@quantumvault/crypto-shim.svg" alt="npm version"></a>
11
+ </p>
12
+
13
+ ---
14
+
15
+ **Drop-in quantum-safe upgrade for Node.js applications - zero code changes required.**
16
+
17
+ This package transparently upgrades your Node.js application's cryptographic operations to quantum-safe alternatives. Simply install and configure at application startup - all existing crypto code continues to work while being protected against quantum computer attacks.
18
+
19
+ ## Features
20
+
21
+ - **Zero Code Changes**: Works with existing `crypto` module usage
22
+ - **Automatic Upgrades**: RSA/ECDSA signatures upgraded to ML-DSA hybrids
23
+ - **Multiple Modes**: Monitor, hybrid, or pure post-quantum
24
+ - **Analytics**: Track all crypto operations via QuantumVault dashboard
25
+ - **Gradual Rollout**: Start in monitor mode, then progressively upgrade
26
+ - **Fallback Safety**: Automatic fallback to classical crypto on errors
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ npm install @quantumvault/crypto-shim
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ Add this at the **very top** of your application entry point (before any other imports):
37
+
38
+ ```javascript
39
+ // Must be the FIRST line of your application
40
+ require('@quantumvault/crypto-shim').install({
41
+ apiKey: process.env.QUANTUMVAULT_API_KEY,
42
+ mode: 'hybrid' // Start with 'monitor' to observe without changes
43
+ });
44
+
45
+ // Now all your existing code is quantum-safe!
46
+ const crypto = require('crypto');
47
+
48
+ // This RSA signature is automatically upgraded to ML-DSA-65 hybrid
49
+ const sign = crypto.createSign('RSA-SHA256');
50
+ sign.update('data to sign');
51
+ const signature = sign.sign(privateKey);
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ ```javascript
57
+ require('@quantumvault/crypto-shim').install({
58
+ // Required: Your QuantumVault API key
59
+ apiKey: 'qvp_...',
60
+
61
+ // Optional: Plugin ID for analytics (get from QuantumVault dashboard)
62
+ pluginId: 'plugin_abc123',
63
+
64
+ // Optional: API endpoint (defaults to production)
65
+ endpoint: 'https://api.quantumvault.io',
66
+
67
+ // Mode: 'monitor' | 'hybrid' | 'pq_only' | 'intercept'
68
+ // - monitor: Log only, no changes (safe to start with)
69
+ // - hybrid: Use classical + quantum-safe combined (recommended)
70
+ // - pq_only: Pure post-quantum (future-proof but may have compatibility issues)
71
+ // - intercept: Upgrade classical to PQ transparently
72
+ mode: 'hybrid',
73
+
74
+ // Fallback behavior on errors
75
+ fallback: {
76
+ onError: 'use_classical', // 'use_classical' | 'fail'
77
+ timeout_ms: 5000
78
+ },
79
+
80
+ // Logging
81
+ logging: {
82
+ enabled: true,
83
+ level: 'info' // 'debug' | 'info' | 'warn' | 'error'
84
+ }
85
+ });
86
+ ```
87
+
88
+ ## Algorithm Mappings
89
+
90
+ | Classical Algorithm | Quantum-Safe Upgrade | Hybrid Option |
91
+ |---------------------|----------------------|---------------|
92
+ | RSA-SHA256 | ML-DSA-65 | RSA-SHA256 + ML-DSA-65 |
93
+ | RSA-SHA384 | ML-DSA-65 | RSA-SHA384 + ML-DSA-65 |
94
+ | RSA-SHA512 | ML-DSA-87 | RSA-SHA512 + ML-DSA-87 |
95
+ | ECDSA-P256 | ML-DSA-44 | ECDSA-P256 + ML-DSA-44 |
96
+ | ECDSA-P384 | ML-DSA-65 | ECDSA-P384 + ML-DSA-65 |
97
+ | Ed25519 | ML-DSA-44 | Ed25519 + ML-DSA-44 |
98
+ | RSA (keygen) | ML-KEM-768 | RSA-2048 + ML-KEM-768 |
99
+ | ECDH-P256 | ML-KEM-768 | ECDH-P256 + ML-KEM-768 |
100
+ | X25519 | ML-KEM-768 | X25519 + ML-KEM-768 |
101
+
102
+ ## API Reference
103
+
104
+ ### `install(config)`
105
+
106
+ Install the crypto shim. Must be called before any crypto operations.
107
+
108
+ ### `uninstall()`
109
+
110
+ Remove the shim and restore original crypto functions.
111
+
112
+ ### `isActive()`
113
+
114
+ Returns `true` if the shim is currently installed.
115
+
116
+ ### `status()`
117
+
118
+ Get current shim status and statistics:
119
+
120
+ ```javascript
121
+ const { status } = require('@quantumvault/crypto-shim');
122
+
123
+ console.log(status());
124
+ // {
125
+ // installed: true,
126
+ // mode: 'hybrid',
127
+ // stats: {
128
+ // totalOperations: 150,
129
+ // upgradedOperations: 142,
130
+ // classicalOperations: 8,
131
+ // failedOperations: 0,
132
+ // byAlgorithm: Map { 'RSA-SHA256' => { upgraded: 100, classical: 0 }, ... }
133
+ // }
134
+ // }
135
+ ```
136
+
137
+ ### `getMappings()`
138
+
139
+ Get all algorithm mappings.
140
+
141
+ ### `addMapping(mapping)`
142
+
143
+ Add a custom algorithm mapping:
144
+
145
+ ```javascript
146
+ const { addMapping } = require('@quantumvault/crypto-shim');
147
+
148
+ addMapping({
149
+ classical: 'CUSTOM-ALGO',
150
+ quantum_safe: 'ML-DSA-87',
151
+ hybrid_option: 'CUSTOM-ALGO + ML-DSA-87'
152
+ });
153
+ ```
154
+
155
+ ## Migration Guide
156
+
157
+ ### Step 1: Monitor Mode (Week 1)
158
+
159
+ Start with monitor mode to understand your crypto usage:
160
+
161
+ ```javascript
162
+ require('@quantumvault/crypto-shim').install({
163
+ apiKey: process.env.QUANTUMVAULT_API_KEY,
164
+ mode: 'monitor',
165
+ logging: { enabled: true, level: 'info' }
166
+ });
167
+ ```
168
+
169
+ ### Step 2: Review Analytics
170
+
171
+ Check your QuantumVault dashboard to see:
172
+ - Which algorithms are being used
173
+ - Operation frequency and latency
174
+ - Potential compatibility issues
175
+
176
+ ### Step 3: Enable Hybrid Mode (Week 2+)
177
+
178
+ Once confident, switch to hybrid mode:
179
+
180
+ ```javascript
181
+ require('@quantumvault/crypto-shim').install({
182
+ apiKey: process.env.QUANTUMVAULT_API_KEY,
183
+ mode: 'hybrid'
184
+ });
185
+ ```
186
+
187
+ ### Step 4: Pure Post-Quantum (Optional)
188
+
189
+ For maximum future-proofing:
190
+
191
+ ```javascript
192
+ require('@quantumvault/crypto-shim').install({
193
+ apiKey: process.env.QUANTUMVAULT_API_KEY,
194
+ mode: 'pq_only'
195
+ });
196
+ ```
197
+
198
+ ## Supported Operations
199
+
200
+ | Operation | Supported | Notes |
201
+ |-----------|-----------|-------|
202
+ | `createSign()` | Yes | Signature algorithms upgraded |
203
+ | `createVerify()` | Yes | Verification algorithms upgraded |
204
+ | `generateKeyPair()` | Yes | Key types upgraded |
205
+ | `generateKeyPairSync()` | Yes | Key types upgraded |
206
+ | `publicEncrypt()` | Coming soon | Key encapsulation |
207
+ | `privateDecrypt()` | Coming soon | Key decapsulation |
208
+ | `createCipheriv()` | N/A | AES-256 already quantum-safe |
209
+ | `createDecipheriv()` | N/A | AES-256 already quantum-safe |
210
+ | `createHash()` | N/A | SHA-256+ already quantum-safe |
211
+
212
+ ## TypeScript Support
213
+
214
+ Full TypeScript support with type definitions included:
215
+
216
+ ```typescript
217
+ import { install, status, ShimConfig } from '@quantumvault/crypto-shim';
218
+
219
+ const config: ShimConfig = {
220
+ apiKey: process.env.QUANTUMVAULT_API_KEY!,
221
+ mode: 'hybrid'
222
+ };
223
+
224
+ install(config);
225
+ ```
226
+
227
+ ## Troubleshooting
228
+
229
+ ### "Crypto shim is already installed"
230
+
231
+ The shim can only be installed once. If you need to reconfigure, call `uninstall()` first.
232
+
233
+ ### Operations not being upgraded
234
+
235
+ 1. Check that `install()` is called before any crypto imports
236
+ 2. Verify the algorithm is in the mappings list
237
+ 3. Check that mode is set to 'hybrid' or 'pq_only'
238
+
239
+ ### Performance concerns
240
+
241
+ The shim adds minimal overhead (~1-2ms per operation). For high-throughput applications, consider:
242
+ - Using 'monitor' mode initially
243
+ - Batching operations where possible
244
+ - Caching signatures for repeated data
245
+
246
+ ## License
247
+
248
+ MIT
249
+
250
+ ## Support
251
+
252
+ - Documentation: https://docs.quantumvault.io
253
+ - Issues: https://github.com/AllSecureX-Quantum/crypto-shim-nodejs/issues
254
+ - Email: support@allsecurex.com
255
+
256
+ ## About AllSecureX
257
+
258
+ AllSecureX provides enterprise-grade post-quantum cryptography solutions. QuantumVault is our flagship product for NIST-standardized quantum-resistant algorithms (FIPS 203, 204, 205).
259
+
260
+ - Website: https://allsecurex.com
261
+ - GitHub: https://github.com/AllSecureX-Quantum
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @quantumvault/crypto-shim
3
+ * Drop-in quantum-safe upgrade for Node.js crypto module
4
+ *
5
+ * Usage:
6
+ * // At the VERY TOP of your application entry point
7
+ * require('@quantumvault/crypto-shim').install({
8
+ * apiKey: process.env.QUANTUMVAULT_API_KEY,
9
+ * mode: 'hybrid' // 'hybrid' | 'pq_only' | 'monitor'
10
+ * });
11
+ *
12
+ * // Now all crypto operations are automatically upgraded
13
+ * const crypto = require('crypto');
14
+ * crypto.createSign('RSA-SHA256') // Uses ML-DSA-65 hybrid
15
+ */
16
+ export type ShimMode = 'hybrid' | 'pq_only' | 'intercept' | 'monitor';
17
+ export interface ShimConfig {
18
+ apiKey: string;
19
+ pluginId?: string;
20
+ endpoint?: string;
21
+ mode?: ShimMode;
22
+ fallback?: {
23
+ onError: 'use_classical' | 'fail';
24
+ timeout_ms?: number;
25
+ };
26
+ logging?: {
27
+ enabled?: boolean;
28
+ level?: 'debug' | 'info' | 'warn' | 'error';
29
+ };
30
+ }
31
+ export interface AlgorithmMapping {
32
+ classical: string;
33
+ quantum_safe: string;
34
+ hybrid_option?: string;
35
+ }
36
+ declare const stats: {
37
+ totalOperations: number;
38
+ upgradedOperations: number;
39
+ classicalOperations: number;
40
+ failedOperations: number;
41
+ byAlgorithm: Map<string, {
42
+ upgraded: number;
43
+ classical: number;
44
+ }>;
45
+ };
46
+ /**
47
+ * Install the QuantumVault crypto shim
48
+ * Call this at the very top of your application entry point
49
+ */
50
+ export declare function install(config: ShimConfig): void;
51
+ /**
52
+ * Uninstall the crypto shim and restore original functions
53
+ */
54
+ export declare function uninstall(): void;
55
+ /**
56
+ * Check if the shim is currently installed
57
+ */
58
+ export declare function isActive(): boolean;
59
+ /**
60
+ * Get current shim status
61
+ */
62
+ export declare function status(): {
63
+ installed: boolean;
64
+ mode: ShimMode | null;
65
+ stats: typeof stats;
66
+ };
67
+ /**
68
+ * Get algorithm mappings
69
+ */
70
+ export declare function getMappings(): AlgorithmMapping[];
71
+ /**
72
+ * Add custom algorithm mapping
73
+ */
74
+ export declare function addMapping(mapping: AlgorithmMapping): void;
75
+ export {};
76
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAEtE,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE;QACT,OAAO,EAAE,eAAe,GAAG,MAAM,CAAC;QAClC,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;KAC7C,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAuDD,QAAA,MAAM,KAAK;;;;;;kBAKgC,MAAM;mBAAa,MAAM;;CACnE,CAAC;AA8PF;;;GAGG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CA6ChD;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAiBhC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAElC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,OAAO,KAAK,CAAC;CACrB,CAYA;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,gBAAgB,EAAE,CAEhD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAG1D"}