@pan-sec/notebooklm-mcp 1.4.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 +21 -0
- package/README.md +289 -0
- package/SECURITY.md +539 -0
- package/dist/auth/auth-manager.d.ts +137 -0
- package/dist/auth/auth-manager.d.ts.map +1 -0
- package/dist/auth/auth-manager.js +984 -0
- package/dist/auth/auth-manager.js.map +1 -0
- package/dist/auth/mcp-auth.d.ts +102 -0
- package/dist/auth/mcp-auth.d.ts.map +1 -0
- package/dist/auth/mcp-auth.js +286 -0
- package/dist/auth/mcp-auth.js.map +1 -0
- package/dist/config.d.ts +89 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +216 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +41 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +371 -0
- package/dist/index.js.map +1 -0
- package/dist/library/notebook-library.d.ts +70 -0
- package/dist/library/notebook-library.d.ts.map +1 -0
- package/dist/library/notebook-library.js +279 -0
- package/dist/library/notebook-library.js.map +1 -0
- package/dist/library/types.d.ts +67 -0
- package/dist/library/types.d.ts.map +1 -0
- package/dist/library/types.js +8 -0
- package/dist/library/types.js.map +1 -0
- package/dist/resources/resource-handlers.d.ts +22 -0
- package/dist/resources/resource-handlers.d.ts.map +1 -0
- package/dist/resources/resource-handlers.js +216 -0
- package/dist/resources/resource-handlers.js.map +1 -0
- package/dist/session/browser-session.d.ts +108 -0
- package/dist/session/browser-session.d.ts.map +1 -0
- package/dist/session/browser-session.js +621 -0
- package/dist/session/browser-session.js.map +1 -0
- package/dist/session/session-manager.d.ts +77 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manager.js +314 -0
- package/dist/session/session-manager.js.map +1 -0
- package/dist/session/session-timeout.d.ts +122 -0
- package/dist/session/session-timeout.d.ts.map +1 -0
- package/dist/session/session-timeout.js +281 -0
- package/dist/session/session-timeout.js.map +1 -0
- package/dist/session/shared-context-manager.d.ts +107 -0
- package/dist/session/shared-context-manager.d.ts.map +1 -0
- package/dist/session/shared-context-manager.js +447 -0
- package/dist/session/shared-context-manager.js.map +1 -0
- package/dist/tools/definitions/ask-question.d.ts +8 -0
- package/dist/tools/definitions/ask-question.d.ts.map +1 -0
- package/dist/tools/definitions/ask-question.js +211 -0
- package/dist/tools/definitions/ask-question.js.map +1 -0
- package/dist/tools/definitions/notebook-management.d.ts +3 -0
- package/dist/tools/definitions/notebook-management.d.ts.map +1 -0
- package/dist/tools/definitions/notebook-management.js +243 -0
- package/dist/tools/definitions/notebook-management.js.map +1 -0
- package/dist/tools/definitions/session-management.d.ts +3 -0
- package/dist/tools/definitions/session-management.d.ts.map +1 -0
- package/dist/tools/definitions/session-management.js +41 -0
- package/dist/tools/definitions/session-management.js.map +1 -0
- package/dist/tools/definitions/system.d.ts +3 -0
- package/dist/tools/definitions/system.d.ts.map +1 -0
- package/dist/tools/definitions/system.js +143 -0
- package/dist/tools/definitions/system.js.map +1 -0
- package/dist/tools/definitions.d.ts +12 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +26 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/handlers.d.ts +213 -0
- package/dist/tools/handlers.d.ts.map +1 -0
- package/dist/tools/handlers.js +813 -0
- package/dist/tools/handlers.js.map +1 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +8 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types.d.ts +82 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/audit-logger.d.ts +140 -0
- package/dist/utils/audit-logger.d.ts.map +1 -0
- package/dist/utils/audit-logger.js +361 -0
- package/dist/utils/audit-logger.js.map +1 -0
- package/dist/utils/cert-pinning.d.ts +97 -0
- package/dist/utils/cert-pinning.d.ts.map +1 -0
- package/dist/utils/cert-pinning.js +328 -0
- package/dist/utils/cert-pinning.js.map +1 -0
- package/dist/utils/cleanup-manager.d.ts +133 -0
- package/dist/utils/cleanup-manager.d.ts.map +1 -0
- package/dist/utils/cleanup-manager.js +673 -0
- package/dist/utils/cleanup-manager.js.map +1 -0
- package/dist/utils/cli-handler.d.ts +16 -0
- package/dist/utils/cli-handler.d.ts.map +1 -0
- package/dist/utils/cli-handler.js +102 -0
- package/dist/utils/cli-handler.js.map +1 -0
- package/dist/utils/crypto.d.ts +175 -0
- package/dist/utils/crypto.d.ts.map +1 -0
- package/dist/utils/crypto.js +612 -0
- package/dist/utils/crypto.js.map +1 -0
- package/dist/utils/logger.d.ts +61 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +92 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/page-utils.d.ts +54 -0
- package/dist/utils/page-utils.d.ts.map +1 -0
- package/dist/utils/page-utils.js +405 -0
- package/dist/utils/page-utils.js.map +1 -0
- package/dist/utils/response-validator.d.ts +98 -0
- package/dist/utils/response-validator.d.ts.map +1 -0
- package/dist/utils/response-validator.js +352 -0
- package/dist/utils/response-validator.js.map +1 -0
- package/dist/utils/secrets-scanner.d.ts +126 -0
- package/dist/utils/secrets-scanner.d.ts.map +1 -0
- package/dist/utils/secrets-scanner.js +443 -0
- package/dist/utils/secrets-scanner.js.map +1 -0
- package/dist/utils/secure-memory.d.ts +130 -0
- package/dist/utils/secure-memory.d.ts.map +1 -0
- package/dist/utils/secure-memory.js +279 -0
- package/dist/utils/secure-memory.js.map +1 -0
- package/dist/utils/security.d.ts +83 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +272 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/settings-manager.d.ts +37 -0
- package/dist/utils/settings-manager.d.ts.map +1 -0
- package/dist/utils/settings-manager.js +125 -0
- package/dist/utils/settings-manager.js.map +1 -0
- package/dist/utils/stealth-utils.d.ts +135 -0
- package/dist/utils/stealth-utils.d.ts.map +1 -0
- package/dist/utils/stealth-utils.js +398 -0
- package/dist/utils/stealth-utils.js.map +1 -0
- package/dist/utils/tool-validation.d.ts +93 -0
- package/dist/utils/tool-validation.d.ts.map +1 -0
- package/dist/utils/tool-validation.js +277 -0
- package/dist/utils/tool-validation.js.map +1 -0
- package/docs/SECURITY_IMPLEMENTATION_PLAN.md +437 -0
- package/docs/configuration.md +94 -0
- package/docs/tools.md +34 -0
- package/docs/troubleshooting.md +59 -0
- package/docs/usage-guide.md +245 -0
- package/package.json +82 -0
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-Quantum Cryptographic Utilities for NotebookLM MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Provides quantum-resistant encryption at rest using hybrid encryption:
|
|
5
|
+
* - ML-KEM-768 (Kyber) for post-quantum key encapsulation
|
|
6
|
+
* - ChaCha20-Poly1305 for symmetric encryption (NOT AES-GCM)
|
|
7
|
+
* - PBKDF2 for key derivation from passwords
|
|
8
|
+
* - Machine-derived keys (fallback)
|
|
9
|
+
*
|
|
10
|
+
* Why ChaCha20-Poly1305 over AES-GCM:
|
|
11
|
+
* - Constant-time by design (no cache timing side-channels)
|
|
12
|
+
* - Faster in software without hardware AES-NI
|
|
13
|
+
* - Simpler construction, less prone to implementation errors
|
|
14
|
+
* - Used by Google, Cloudflare for TLS
|
|
15
|
+
*
|
|
16
|
+
* This hybrid approach ensures:
|
|
17
|
+
* 1. Current security via ChaCha20-Poly1305
|
|
18
|
+
* 2. Future quantum resistance via ML-KEM-768
|
|
19
|
+
*
|
|
20
|
+
* Added by Pantheon Security for hardened fork.
|
|
21
|
+
*/
|
|
22
|
+
import crypto from "crypto";
|
|
23
|
+
import fs from "fs";
|
|
24
|
+
import path from "path";
|
|
25
|
+
import os from "os";
|
|
26
|
+
import { ml_kem768 } from "@noble/post-quantum/ml-kem";
|
|
27
|
+
import { log } from "./logger.js";
|
|
28
|
+
import { audit } from "./audit-logger.js";
|
|
29
|
+
/**
|
|
30
|
+
* Constants
|
|
31
|
+
*/
|
|
32
|
+
const ALGORITHM = "chacha20-poly1305";
|
|
33
|
+
const PQ_ALGORITHM = "ML-KEM-768";
|
|
34
|
+
const KEY_LENGTH = 32; // 256 bits
|
|
35
|
+
const NONCE_LENGTH = 12; // 96 bits for ChaCha20
|
|
36
|
+
const SALT_LENGTH = 32;
|
|
37
|
+
const CURRENT_VERSION = 3; // Version 3 = Post-Quantum + ChaCha20-Poly1305
|
|
38
|
+
const CLASSICAL_VERSION = 2; // Version 2 = ChaCha20-Poly1305 classical
|
|
39
|
+
// Legacy versions for migration (detected by presence of 'iv' and 'tag' fields)
|
|
40
|
+
// LEGACY_PQ_VERSION = 2 (old PQ with AES-GCM)
|
|
41
|
+
// LEGACY_CLASSICAL_VERSION = 1 (old classical with AES-GCM)
|
|
42
|
+
/**
|
|
43
|
+
* Get encryption configuration from environment
|
|
44
|
+
*/
|
|
45
|
+
function getEncryptionConfig() {
|
|
46
|
+
return {
|
|
47
|
+
enabled: process.env.NLMCP_ENCRYPTION_ENABLED !== "false",
|
|
48
|
+
key: process.env.NLMCP_ENCRYPTION_KEY,
|
|
49
|
+
keyFile: process.env.NLMCP_ENCRYPTION_KEY_FILE,
|
|
50
|
+
useMachineKey: process.env.NLMCP_USE_MACHINE_KEY !== "false",
|
|
51
|
+
pbkdf2Iterations: parseInt(process.env.NLMCP_PBKDF2_ITERATIONS || "100000", 10),
|
|
52
|
+
usePostQuantum: process.env.NLMCP_USE_POST_QUANTUM !== "false",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Derive a key from a passphrase using PBKDF2
|
|
57
|
+
*/
|
|
58
|
+
export function deriveKey(passphrase, salt, iterations = 100000) {
|
|
59
|
+
return crypto.pbkdf2Sync(passphrase, salt, iterations, KEY_LENGTH, "sha256");
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Generate a machine-derived key based on hardware/OS identifiers
|
|
63
|
+
*
|
|
64
|
+
* Note: This provides obscurity, not true security. It's a fallback
|
|
65
|
+
* when no user key is provided.
|
|
66
|
+
*/
|
|
67
|
+
export function getMachineKey() {
|
|
68
|
+
const components = [
|
|
69
|
+
os.hostname(),
|
|
70
|
+
os.platform(),
|
|
71
|
+
os.arch(),
|
|
72
|
+
os.cpus()[0]?.model || "unknown",
|
|
73
|
+
os.homedir(),
|
|
74
|
+
];
|
|
75
|
+
// Create a deterministic key from machine components
|
|
76
|
+
const combined = components.join("|");
|
|
77
|
+
const hash = crypto.createHash("sha256").update(combined).digest("hex");
|
|
78
|
+
return hash;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Generate ML-KEM key pair for post-quantum encryption
|
|
82
|
+
*/
|
|
83
|
+
export function generatePQKeyPair() {
|
|
84
|
+
const keys = ml_kem768.keygen();
|
|
85
|
+
return {
|
|
86
|
+
publicKey: keys.publicKey,
|
|
87
|
+
secretKey: keys.secretKey,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Encrypt data using hybrid post-quantum encryption
|
|
92
|
+
* ML-KEM-768 + ChaCha20-Poly1305
|
|
93
|
+
*
|
|
94
|
+
* Process:
|
|
95
|
+
* 1. Encapsulate a shared secret using recipient's public key (ML-KEM-768)
|
|
96
|
+
* 2. Derive ChaCha20 key from shared secret + salt
|
|
97
|
+
* 3. Encrypt data with ChaCha20-Poly1305 (AEAD)
|
|
98
|
+
*/
|
|
99
|
+
export function encryptPQ(data, recipientPublicKey) {
|
|
100
|
+
// Step 1: Encapsulate a shared secret using ML-KEM
|
|
101
|
+
const { cipherText: encapsulatedKey, sharedSecret } = ml_kem768.encapsulate(recipientPublicKey);
|
|
102
|
+
// Step 2: Generate nonce and salt
|
|
103
|
+
const salt = crypto.randomBytes(SALT_LENGTH);
|
|
104
|
+
const nonce = crypto.randomBytes(NONCE_LENGTH);
|
|
105
|
+
// Step 3: Derive ChaCha20 key from shared secret + salt
|
|
106
|
+
const chachaKey = crypto.createHash("sha256")
|
|
107
|
+
.update(Buffer.from(sharedSecret))
|
|
108
|
+
.update(salt)
|
|
109
|
+
.digest();
|
|
110
|
+
// Step 4: Encrypt with ChaCha20-Poly1305
|
|
111
|
+
const cipher = crypto.createCipheriv(ALGORITHM, chachaKey, nonce, {
|
|
112
|
+
authTagLength: 16,
|
|
113
|
+
});
|
|
114
|
+
const dataBuffer = Buffer.isBuffer(data) ? data : Buffer.from(data, "utf-8");
|
|
115
|
+
const encrypted = Buffer.concat([cipher.update(dataBuffer), cipher.final()]);
|
|
116
|
+
const authTag = cipher.getAuthTag();
|
|
117
|
+
// Combine ciphertext + auth tag (standard practice for ChaCha20-Poly1305)
|
|
118
|
+
const ciphertextWithTag = Buffer.concat([encrypted, authTag]);
|
|
119
|
+
// Clear sensitive data from memory
|
|
120
|
+
chachaKey.fill(0);
|
|
121
|
+
return {
|
|
122
|
+
version: CURRENT_VERSION,
|
|
123
|
+
algorithm: ALGORITHM,
|
|
124
|
+
pqAlgorithm: PQ_ALGORITHM,
|
|
125
|
+
encapsulatedKey: Buffer.from(encapsulatedKey).toString("base64"),
|
|
126
|
+
nonce: nonce.toString("base64"),
|
|
127
|
+
salt: salt.toString("base64"),
|
|
128
|
+
ciphertext: ciphertextWithTag.toString("base64"),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Decrypt data using hybrid post-quantum decryption
|
|
133
|
+
* ML-KEM-768 + ChaCha20-Poly1305
|
|
134
|
+
*/
|
|
135
|
+
export function decryptPQ(encryptedData, recipientSecretKey) {
|
|
136
|
+
if (encryptedData.version !== CURRENT_VERSION) {
|
|
137
|
+
throw new Error(`Unsupported PQ encryption version: ${encryptedData.version}`);
|
|
138
|
+
}
|
|
139
|
+
// Step 1: Decapsulate the shared secret
|
|
140
|
+
const encapsulatedKey = new Uint8Array(Buffer.from(encryptedData.encapsulatedKey, "base64"));
|
|
141
|
+
const sharedSecret = ml_kem768.decapsulate(encapsulatedKey, recipientSecretKey);
|
|
142
|
+
// Step 2: Derive ChaCha20 key
|
|
143
|
+
const salt = Buffer.from(encryptedData.salt, "base64");
|
|
144
|
+
const chachaKey = crypto.createHash("sha256")
|
|
145
|
+
.update(Buffer.from(sharedSecret))
|
|
146
|
+
.update(salt)
|
|
147
|
+
.digest();
|
|
148
|
+
// Step 3: Split ciphertext and auth tag
|
|
149
|
+
const ciphertextWithTag = Buffer.from(encryptedData.ciphertext, "base64");
|
|
150
|
+
const ciphertext = ciphertextWithTag.subarray(0, -16);
|
|
151
|
+
const authTag = ciphertextWithTag.subarray(-16);
|
|
152
|
+
// Step 4: Decrypt with ChaCha20-Poly1305
|
|
153
|
+
const nonce = Buffer.from(encryptedData.nonce, "base64");
|
|
154
|
+
const decipher = crypto.createDecipheriv(ALGORITHM, chachaKey, nonce, {
|
|
155
|
+
authTagLength: 16,
|
|
156
|
+
});
|
|
157
|
+
decipher.setAuthTag(authTag);
|
|
158
|
+
const decrypted = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
159
|
+
// Clear sensitive data from memory
|
|
160
|
+
chachaKey.fill(0);
|
|
161
|
+
return decrypted;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Classical ChaCha20-Poly1305 encryption (fallback)
|
|
165
|
+
*/
|
|
166
|
+
export function encryptClassical(data, key) {
|
|
167
|
+
const nonce = crypto.randomBytes(NONCE_LENGTH);
|
|
168
|
+
const salt = crypto.randomBytes(SALT_LENGTH);
|
|
169
|
+
const cipher = crypto.createCipheriv(ALGORITHM, key, nonce, {
|
|
170
|
+
authTagLength: 16,
|
|
171
|
+
});
|
|
172
|
+
const dataBuffer = Buffer.isBuffer(data) ? data : Buffer.from(data, "utf-8");
|
|
173
|
+
const encrypted = Buffer.concat([cipher.update(dataBuffer), cipher.final()]);
|
|
174
|
+
const authTag = cipher.getAuthTag();
|
|
175
|
+
// Combine ciphertext + auth tag
|
|
176
|
+
const ciphertextWithTag = Buffer.concat([encrypted, authTag]);
|
|
177
|
+
return {
|
|
178
|
+
version: CLASSICAL_VERSION,
|
|
179
|
+
algorithm: ALGORITHM,
|
|
180
|
+
nonce: nonce.toString("base64"),
|
|
181
|
+
salt: salt.toString("base64"),
|
|
182
|
+
ciphertext: ciphertextWithTag.toString("base64"),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Classical ChaCha20-Poly1305 decryption (fallback)
|
|
187
|
+
*/
|
|
188
|
+
export function decryptClassical(encryptedData, key) {
|
|
189
|
+
if (encryptedData.version !== CLASSICAL_VERSION) {
|
|
190
|
+
throw new Error(`Unsupported classical encryption version: ${encryptedData.version}`);
|
|
191
|
+
}
|
|
192
|
+
const nonce = Buffer.from(encryptedData.nonce, "base64");
|
|
193
|
+
const ciphertextWithTag = Buffer.from(encryptedData.ciphertext, "base64");
|
|
194
|
+
const ciphertext = ciphertextWithTag.subarray(0, -16);
|
|
195
|
+
const authTag = ciphertextWithTag.subarray(-16);
|
|
196
|
+
const decipher = crypto.createDecipheriv(ALGORITHM, key, nonce, {
|
|
197
|
+
authTagLength: 16,
|
|
198
|
+
});
|
|
199
|
+
decipher.setAuthTag(authTag);
|
|
200
|
+
const decrypted = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
201
|
+
return decrypted;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Decrypt legacy AES-GCM encrypted data (for migration)
|
|
205
|
+
*/
|
|
206
|
+
function decryptLegacyAES(encryptedData, key, pqSecretKey) {
|
|
207
|
+
let aesKey;
|
|
208
|
+
// Check if this is PQ encrypted (has encapsulatedKey)
|
|
209
|
+
if (encryptedData.encapsulatedKey && pqSecretKey) {
|
|
210
|
+
const encapsulatedKey = new Uint8Array(Buffer.from(encryptedData.encapsulatedKey, "base64"));
|
|
211
|
+
const sharedSecret = ml_kem768.decapsulate(encapsulatedKey, pqSecretKey);
|
|
212
|
+
const salt = Buffer.from(encryptedData.salt, "base64");
|
|
213
|
+
aesKey = crypto.createHash("sha256")
|
|
214
|
+
.update(Buffer.from(sharedSecret))
|
|
215
|
+
.update(salt)
|
|
216
|
+
.digest();
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
aesKey = key;
|
|
220
|
+
}
|
|
221
|
+
const iv = Buffer.from(encryptedData.iv, "base64");
|
|
222
|
+
const tag = Buffer.from(encryptedData.tag, "base64");
|
|
223
|
+
const ciphertext = Buffer.from(encryptedData.ciphertext, "base64");
|
|
224
|
+
const decipher = crypto.createDecipheriv("aes-256-gcm", aesKey, iv, {
|
|
225
|
+
authTagLength: 16,
|
|
226
|
+
});
|
|
227
|
+
decipher.setAuthTag(tag);
|
|
228
|
+
const decrypted = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
229
|
+
// Clear key if we derived it
|
|
230
|
+
if (encryptedData.encapsulatedKey) {
|
|
231
|
+
aesKey.fill(0);
|
|
232
|
+
}
|
|
233
|
+
return decrypted;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Check if encrypted data is legacy AES-GCM format
|
|
237
|
+
*/
|
|
238
|
+
function isLegacyFormat(data) {
|
|
239
|
+
return data && data.iv !== undefined && data.tag !== undefined;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Post-Quantum Secure Storage Class
|
|
243
|
+
*
|
|
244
|
+
* Provides encrypted file storage using hybrid post-quantum encryption
|
|
245
|
+
* with ChaCha20-Poly1305 (NOT AES-GCM).
|
|
246
|
+
*/
|
|
247
|
+
export class SecureStorage {
|
|
248
|
+
config;
|
|
249
|
+
classicalKey = null;
|
|
250
|
+
pqKeyPair = null;
|
|
251
|
+
initialized = false;
|
|
252
|
+
keyStorePath;
|
|
253
|
+
constructor(config) {
|
|
254
|
+
this.config = { ...getEncryptionConfig(), ...config };
|
|
255
|
+
this.keyStorePath = path.join(process.env.NLMCP_CONFIG_DIR || path.join(os.homedir(), ".notebooklm-mcp"), "pq-keys.enc");
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Initialize the secure storage (derive/load keys)
|
|
259
|
+
*/
|
|
260
|
+
async initialize() {
|
|
261
|
+
if (this.initialized)
|
|
262
|
+
return;
|
|
263
|
+
if (!this.config.enabled) {
|
|
264
|
+
log.info("🔓 Encryption is disabled");
|
|
265
|
+
this.initialized = true;
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
log.info("🔐 Initializing post-quantum secure storage (ChaCha20-Poly1305)...");
|
|
269
|
+
try {
|
|
270
|
+
// Initialize classical key for backward compatibility
|
|
271
|
+
await this.initializeClassicalKey();
|
|
272
|
+
// Initialize post-quantum keys if enabled
|
|
273
|
+
if (this.config.usePostQuantum) {
|
|
274
|
+
await this.initializePQKeys();
|
|
275
|
+
}
|
|
276
|
+
this.initialized = true;
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
log.error(` ❌ Failed to initialize encryption: ${error}`);
|
|
280
|
+
this.config.enabled = false;
|
|
281
|
+
await audit.security("encryption_init_failed", "error", { error: String(error) });
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Initialize classical encryption key
|
|
286
|
+
*/
|
|
287
|
+
async initializeClassicalKey() {
|
|
288
|
+
// Priority 1: Environment variable key
|
|
289
|
+
if (this.config.key) {
|
|
290
|
+
this.classicalKey = Buffer.from(this.config.key, "base64");
|
|
291
|
+
if (this.classicalKey.length !== KEY_LENGTH) {
|
|
292
|
+
throw new Error(`Invalid key length: expected ${KEY_LENGTH} bytes, got ${this.classicalKey.length}`);
|
|
293
|
+
}
|
|
294
|
+
log.success(" ✅ Using classical key from environment");
|
|
295
|
+
await audit.security("encryption_init", "info", { key_source: "environment", algorithm: ALGORITHM });
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
// Priority 2: Key file
|
|
299
|
+
if (this.config.keyFile && fs.existsSync(this.config.keyFile)) {
|
|
300
|
+
const keyBase64 = fs.readFileSync(this.config.keyFile, "utf-8").trim();
|
|
301
|
+
this.classicalKey = Buffer.from(keyBase64, "base64");
|
|
302
|
+
if (this.classicalKey.length !== KEY_LENGTH) {
|
|
303
|
+
throw new Error(`Invalid key length in file: expected ${KEY_LENGTH} bytes`);
|
|
304
|
+
}
|
|
305
|
+
log.success(" ✅ Using classical key from file");
|
|
306
|
+
await audit.security("encryption_init", "info", { key_source: "file", algorithm: ALGORITHM });
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
// Priority 3: Machine-derived key (fallback)
|
|
310
|
+
if (this.config.useMachineKey) {
|
|
311
|
+
const machineKey = getMachineKey();
|
|
312
|
+
const salt = Buffer.from("notebooklm-mcp-secure-salt-v3", "utf-8");
|
|
313
|
+
this.classicalKey = deriveKey(machineKey, salt, this.config.pbkdf2Iterations);
|
|
314
|
+
log.warning(" ⚠️ Using machine-derived classical key (less secure)");
|
|
315
|
+
log.info(" Set NLMCP_ENCRYPTION_KEY for better security");
|
|
316
|
+
await audit.security("encryption_init", "warning", { key_source: "machine_derived", algorithm: ALGORITHM });
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
// No key available
|
|
320
|
+
log.warning(" ⚠️ No classical encryption key available");
|
|
321
|
+
this.config.enabled = false;
|
|
322
|
+
await audit.security("encryption_disabled", "warning", { reason: "no_key_available" });
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Initialize post-quantum keys
|
|
326
|
+
*/
|
|
327
|
+
async initializePQKeys() {
|
|
328
|
+
// Try to load existing PQ keys (may be in legacy or new format)
|
|
329
|
+
if (fs.existsSync(this.keyStorePath) && this.classicalKey) {
|
|
330
|
+
try {
|
|
331
|
+
const content = fs.readFileSync(this.keyStorePath, "utf-8");
|
|
332
|
+
const encrypted = JSON.parse(content);
|
|
333
|
+
let decrypted;
|
|
334
|
+
// Check if legacy AES-GCM format
|
|
335
|
+
if (isLegacyFormat(encrypted)) {
|
|
336
|
+
log.info(" 🔄 Migrating PQ keys from AES-GCM to ChaCha20-Poly1305...");
|
|
337
|
+
decrypted = decryptLegacyAES(encrypted, this.classicalKey);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
decrypted = decryptClassical(encrypted, this.classicalKey);
|
|
341
|
+
}
|
|
342
|
+
const keys = JSON.parse(decrypted.toString("utf-8"));
|
|
343
|
+
this.pqKeyPair = {
|
|
344
|
+
publicKey: new Uint8Array(Buffer.from(keys.publicKey, "base64")),
|
|
345
|
+
secretKey: new Uint8Array(Buffer.from(keys.secretKey, "base64")),
|
|
346
|
+
};
|
|
347
|
+
// Re-save with new format if it was legacy
|
|
348
|
+
if (isLegacyFormat(encrypted)) {
|
|
349
|
+
await this.savePQKeys();
|
|
350
|
+
log.success(" ✅ PQ keys migrated to ChaCha20-Poly1305");
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
log.success(" ✅ Loaded existing ML-KEM-768 key pair");
|
|
354
|
+
}
|
|
355
|
+
await audit.security("pq_keys_loaded", "info", { algorithm: ALGORITHM });
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
log.warning(` ⚠️ Failed to load PQ keys, generating new: ${error}`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
// Generate new PQ key pair
|
|
363
|
+
log.info(" 🔑 Generating new ML-KEM-768 key pair...");
|
|
364
|
+
this.pqKeyPair = generatePQKeyPair();
|
|
365
|
+
// Save encrypted PQ keys
|
|
366
|
+
await this.savePQKeys();
|
|
367
|
+
log.success(" ✅ Generated and saved ML-KEM-768 key pair");
|
|
368
|
+
await audit.security("pq_keys_generated", "info", { algorithm: ALGORITHM });
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Save PQ keys with ChaCha20-Poly1305 encryption
|
|
372
|
+
*/
|
|
373
|
+
async savePQKeys() {
|
|
374
|
+
if (!this.classicalKey || !this.pqKeyPair)
|
|
375
|
+
return;
|
|
376
|
+
const keysJson = JSON.stringify({
|
|
377
|
+
publicKey: Buffer.from(this.pqKeyPair.publicKey).toString("base64"),
|
|
378
|
+
secretKey: Buffer.from(this.pqKeyPair.secretKey).toString("base64"),
|
|
379
|
+
});
|
|
380
|
+
const encrypted = encryptClassical(keysJson, this.classicalKey);
|
|
381
|
+
const dir = path.dirname(this.keyStorePath);
|
|
382
|
+
if (!fs.existsSync(dir)) {
|
|
383
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
384
|
+
}
|
|
385
|
+
fs.writeFileSync(this.keyStorePath, JSON.stringify(encrypted, null, 2), {
|
|
386
|
+
mode: 0o600,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Save data to an encrypted file
|
|
391
|
+
*/
|
|
392
|
+
async save(filePath, data) {
|
|
393
|
+
await this.initialize();
|
|
394
|
+
const dataStr = typeof data === "string" ? data : JSON.stringify(data, null, 2);
|
|
395
|
+
const dir = path.dirname(filePath);
|
|
396
|
+
// Ensure directory exists
|
|
397
|
+
if (!fs.existsSync(dir)) {
|
|
398
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
399
|
+
}
|
|
400
|
+
if (!this.config.enabled) {
|
|
401
|
+
// Save unencrypted
|
|
402
|
+
fs.writeFileSync(filePath, dataStr, { mode: 0o600 });
|
|
403
|
+
log.info(`📝 Saved (unencrypted): ${path.basename(filePath)}`);
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
let encrypted;
|
|
407
|
+
let encryptedPath;
|
|
408
|
+
// Use post-quantum encryption if available
|
|
409
|
+
if (this.config.usePostQuantum && this.pqKeyPair) {
|
|
410
|
+
encrypted = encryptPQ(dataStr, this.pqKeyPair.publicKey);
|
|
411
|
+
encryptedPath = filePath + ".pqenc";
|
|
412
|
+
log.info(`🔐 Saved with ML-KEM-768 + ChaCha20-Poly1305: ${path.basename(encryptedPath)}`);
|
|
413
|
+
}
|
|
414
|
+
else if (this.classicalKey) {
|
|
415
|
+
encrypted = encryptClassical(dataStr, this.classicalKey);
|
|
416
|
+
encryptedPath = filePath + ".enc";
|
|
417
|
+
log.info(`🔐 Saved with ChaCha20-Poly1305: ${path.basename(encryptedPath)}`);
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
// Save unencrypted as fallback
|
|
421
|
+
fs.writeFileSync(filePath, dataStr, { mode: 0o600 });
|
|
422
|
+
log.warning(`⚠️ Saved unencrypted (no keys): ${path.basename(filePath)}`);
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
fs.writeFileSync(encryptedPath, JSON.stringify(encrypted, null, 2), {
|
|
426
|
+
mode: 0o600,
|
|
427
|
+
});
|
|
428
|
+
// Remove unencrypted and other encrypted versions if they exist
|
|
429
|
+
const extensions = ["", ".enc", ".pqenc"];
|
|
430
|
+
for (const ext of extensions) {
|
|
431
|
+
const oldPath = filePath + ext;
|
|
432
|
+
if (oldPath !== encryptedPath && fs.existsSync(oldPath)) {
|
|
433
|
+
fs.unlinkSync(oldPath);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Load data from an encrypted file
|
|
439
|
+
*/
|
|
440
|
+
async load(filePath) {
|
|
441
|
+
await this.initialize();
|
|
442
|
+
// Check for PQ encrypted version first
|
|
443
|
+
const pqEncryptedPath = filePath + ".pqenc";
|
|
444
|
+
if (this.pqKeyPair && fs.existsSync(pqEncryptedPath)) {
|
|
445
|
+
try {
|
|
446
|
+
const content = fs.readFileSync(pqEncryptedPath, "utf-8");
|
|
447
|
+
const encrypted = JSON.parse(content);
|
|
448
|
+
let decrypted;
|
|
449
|
+
// Check if legacy AES-GCM format
|
|
450
|
+
if (isLegacyFormat(encrypted)) {
|
|
451
|
+
log.info(`🔄 Migrating ${path.basename(pqEncryptedPath)} from AES-GCM to ChaCha20-Poly1305...`);
|
|
452
|
+
decrypted = decryptLegacyAES(encrypted, this.classicalKey, this.pqKeyPair.secretKey);
|
|
453
|
+
// Re-save with new format
|
|
454
|
+
await this.save(filePath, decrypted.toString("utf-8"));
|
|
455
|
+
log.success(` ✅ Migration complete`);
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
decrypted = decryptPQ(encrypted, this.pqKeyPair.secretKey);
|
|
459
|
+
}
|
|
460
|
+
log.info(`🔓 Loaded (ML-KEM-768 + ChaCha20): ${path.basename(pqEncryptedPath)}`);
|
|
461
|
+
return decrypted.toString("utf-8");
|
|
462
|
+
}
|
|
463
|
+
catch (error) {
|
|
464
|
+
log.error(`❌ Failed to decrypt ${pqEncryptedPath}: ${error}`);
|
|
465
|
+
await audit.security("decryption_failed", "error", {
|
|
466
|
+
file: pqEncryptedPath,
|
|
467
|
+
type: "post-quantum",
|
|
468
|
+
error: String(error),
|
|
469
|
+
});
|
|
470
|
+
return null;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
// Check for classical encrypted version
|
|
474
|
+
const classicalEncryptedPath = filePath + ".enc";
|
|
475
|
+
if (this.classicalKey && fs.existsSync(classicalEncryptedPath)) {
|
|
476
|
+
try {
|
|
477
|
+
const content = fs.readFileSync(classicalEncryptedPath, "utf-8");
|
|
478
|
+
const encrypted = JSON.parse(content);
|
|
479
|
+
let decrypted;
|
|
480
|
+
// Check if legacy AES-GCM format
|
|
481
|
+
if (isLegacyFormat(encrypted)) {
|
|
482
|
+
log.info(`🔄 Migrating ${path.basename(classicalEncryptedPath)} from AES-GCM to ChaCha20-Poly1305...`);
|
|
483
|
+
decrypted = decryptLegacyAES(encrypted, this.classicalKey);
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
decrypted = decryptClassical(encrypted, this.classicalKey);
|
|
487
|
+
}
|
|
488
|
+
log.info(`🔓 Loaded (ChaCha20-Poly1305): ${path.basename(classicalEncryptedPath)}`);
|
|
489
|
+
// Migrate to PQ encryption if enabled
|
|
490
|
+
if (this.config.usePostQuantum && this.pqKeyPair) {
|
|
491
|
+
log.info(`🔄 Upgrading ${path.basename(filePath)} to post-quantum encryption`);
|
|
492
|
+
await this.save(filePath, decrypted.toString("utf-8"));
|
|
493
|
+
}
|
|
494
|
+
else if (isLegacyFormat(encrypted)) {
|
|
495
|
+
// Re-save with ChaCha20-Poly1305 if it was legacy AES
|
|
496
|
+
await this.save(filePath, decrypted.toString("utf-8"));
|
|
497
|
+
log.success(` ✅ Migration complete`);
|
|
498
|
+
}
|
|
499
|
+
return decrypted.toString("utf-8");
|
|
500
|
+
}
|
|
501
|
+
catch (error) {
|
|
502
|
+
log.error(`❌ Failed to decrypt ${classicalEncryptedPath}: ${error}`);
|
|
503
|
+
await audit.security("decryption_failed", "error", {
|
|
504
|
+
file: classicalEncryptedPath,
|
|
505
|
+
type: "classical",
|
|
506
|
+
error: String(error),
|
|
507
|
+
});
|
|
508
|
+
return null;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
// Fall back to unencrypted version
|
|
512
|
+
if (fs.existsSync(filePath)) {
|
|
513
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
514
|
+
log.info(`📝 Loaded (unencrypted): ${path.basename(filePath)}`);
|
|
515
|
+
// Migrate to encrypted storage if enabled
|
|
516
|
+
if (this.config.enabled && (this.pqKeyPair || this.classicalKey)) {
|
|
517
|
+
log.info(`🔄 Encrypting ${path.basename(filePath)} with ChaCha20-Poly1305`);
|
|
518
|
+
await this.save(filePath, content);
|
|
519
|
+
}
|
|
520
|
+
return content;
|
|
521
|
+
}
|
|
522
|
+
return null;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Load JSON data from an encrypted file
|
|
526
|
+
*/
|
|
527
|
+
async loadJSON(filePath) {
|
|
528
|
+
const content = await this.load(filePath);
|
|
529
|
+
if (!content)
|
|
530
|
+
return null;
|
|
531
|
+
try {
|
|
532
|
+
return JSON.parse(content);
|
|
533
|
+
}
|
|
534
|
+
catch (error) {
|
|
535
|
+
log.error(`❌ Failed to parse JSON from ${filePath}: ${error}`);
|
|
536
|
+
return null;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Delete an encrypted file
|
|
541
|
+
*/
|
|
542
|
+
async delete(filePath) {
|
|
543
|
+
let deleted = false;
|
|
544
|
+
const extensions = ["", ".enc", ".pqenc"];
|
|
545
|
+
for (const ext of extensions) {
|
|
546
|
+
const fullPath = filePath + ext;
|
|
547
|
+
if (fs.existsSync(fullPath)) {
|
|
548
|
+
fs.unlinkSync(fullPath);
|
|
549
|
+
deleted = true;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return deleted;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Check if a file exists (any encrypted or unencrypted version)
|
|
556
|
+
*/
|
|
557
|
+
exists(filePath) {
|
|
558
|
+
return (fs.existsSync(filePath) ||
|
|
559
|
+
fs.existsSync(filePath + ".enc") ||
|
|
560
|
+
fs.existsSync(filePath + ".pqenc"));
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Get encryption status
|
|
564
|
+
*/
|
|
565
|
+
getStatus() {
|
|
566
|
+
let classicalKeySource = "none";
|
|
567
|
+
if (this.config.enabled && this.classicalKey) {
|
|
568
|
+
if (this.config.key)
|
|
569
|
+
classicalKeySource = "environment";
|
|
570
|
+
else if (this.config.keyFile)
|
|
571
|
+
classicalKeySource = "file";
|
|
572
|
+
else
|
|
573
|
+
classicalKeySource = "machine_derived";
|
|
574
|
+
}
|
|
575
|
+
return {
|
|
576
|
+
enabled: this.config.enabled,
|
|
577
|
+
classicalKeySource,
|
|
578
|
+
postQuantumEnabled: this.config.usePostQuantum && this.pqKeyPair !== null,
|
|
579
|
+
algorithm: ALGORITHM,
|
|
580
|
+
pqAlgorithm: this.pqKeyPair ? PQ_ALGORITHM : null,
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Generate a new random encryption key (classical)
|
|
585
|
+
*/
|
|
586
|
+
static generateKey() {
|
|
587
|
+
const key = crypto.randomBytes(KEY_LENGTH);
|
|
588
|
+
return key.toString("base64");
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Export public key for sharing (e.g., for external encryption)
|
|
592
|
+
*/
|
|
593
|
+
getPublicKey() {
|
|
594
|
+
if (!this.pqKeyPair)
|
|
595
|
+
return null;
|
|
596
|
+
return Buffer.from(this.pqKeyPair.publicKey).toString("base64");
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Global secure storage instance
|
|
601
|
+
*/
|
|
602
|
+
let globalSecureStorage = null;
|
|
603
|
+
/**
|
|
604
|
+
* Get or create the global secure storage
|
|
605
|
+
*/
|
|
606
|
+
export function getSecureStorage() {
|
|
607
|
+
if (!globalSecureStorage) {
|
|
608
|
+
globalSecureStorage = new SecureStorage();
|
|
609
|
+
}
|
|
610
|
+
return globalSecureStorage;
|
|
611
|
+
}
|
|
612
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA4D1C;;GAEG;AACH,MAAM,SAAS,GAAG,mBAAmB,CAAC;AACtC,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,UAAU,GAAG,EAAE,CAAC,CAAC,WAAW;AAClC,MA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