@neuctra/notlix-mcp 1.0.0 → 2.0.1

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/src/seal.js DELETED
@@ -1,32 +0,0 @@
1
- // Encrypts an item to the inbox's public key (ECDH P-256 + AES-GCM, a new key
2
- // pair per item). Only the user's browser holds the private key; it opens
3
- // items with openInboxItem in the Notlix client (lib/security/inboxCrypto.js).
4
-
5
- const EC = { name: "ECDH", namedCurve: "P-256" };
6
-
7
- function toBase64(bytes) {
8
- let binary = "";
9
- for (const byte of new Uint8Array(bytes)) binary += String.fromCharCode(byte);
10
- return btoa(binary);
11
- }
12
-
13
- /** Returns `{ x, y, iv, cipher }`, the shape the Notlix server stores. */
14
- export async function seal(publicKey, item) {
15
- const recipient = await crypto.subtle.importKey("jwk", publicKey, EC, false, []);
16
- const ephemeral = await crypto.subtle.generateKey(EC, true, ["deriveKey"]);
17
- const key = await crypto.subtle.deriveKey(
18
- { name: "ECDH", public: recipient },
19
- ephemeral.privateKey,
20
- { name: "AES-GCM", length: 256 },
21
- false,
22
- ["encrypt"],
23
- );
24
- const iv = crypto.getRandomValues(new Uint8Array(12));
25
- const cipher = await crypto.subtle.encrypt(
26
- { name: "AES-GCM", iv },
27
- key,
28
- new TextEncoder().encode(JSON.stringify(item)),
29
- );
30
- const { x, y } = await crypto.subtle.exportKey("jwk", ephemeral.publicKey);
31
- return { x, y, iv: toBase64(iv), cipher: toBase64(cipher) };
32
- }