@totalreclaw/mcp-server 1.6.3 → 1.6.5

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.
Files changed (52) hide show
  1. package/dist/cli/setup.js +0 -0
  2. package/dist/client-id.d.ts +3 -0
  3. package/dist/client-id.d.ts.map +1 -0
  4. package/dist/client-id.js +16 -0
  5. package/dist/client-id.js.map +1 -0
  6. package/dist/index.js +178 -4
  7. package/dist/index.js.map +1 -1
  8. package/dist/prompts.d.ts +4 -2
  9. package/dist/prompts.d.ts.map +1 -1
  10. package/dist/prompts.js +42 -2
  11. package/dist/prompts.js.map +1 -1
  12. package/dist/subgraph/crypto.d.ts +30 -50
  13. package/dist/subgraph/crypto.d.ts.map +1 -1
  14. package/dist/subgraph/crypto.js +90 -168
  15. package/dist/subgraph/crypto.js.map +1 -1
  16. package/dist/subgraph/lsh.d.ts +9 -61
  17. package/dist/subgraph/lsh.d.ts.map +1 -1
  18. package/dist/subgraph/lsh.js +17 -169
  19. package/dist/subgraph/lsh.js.map +1 -1
  20. package/dist/subgraph/search.d.ts +11 -0
  21. package/dist/subgraph/search.d.ts.map +1 -1
  22. package/dist/subgraph/search.js +43 -1
  23. package/dist/subgraph/search.js.map +1 -1
  24. package/dist/subgraph/store.d.ts.map +1 -1
  25. package/dist/subgraph/store.js +3 -2
  26. package/dist/subgraph/store.js.map +1 -1
  27. package/dist/tools/account.d.ts +32 -0
  28. package/dist/tools/account.d.ts.map +1 -0
  29. package/dist/tools/account.js +99 -0
  30. package/dist/tools/account.js.map +1 -0
  31. package/dist/tools/debrief.d.ts +74 -0
  32. package/dist/tools/debrief.d.ts.map +1 -0
  33. package/dist/tools/debrief.js +189 -0
  34. package/dist/tools/debrief.js.map +1 -0
  35. package/dist/tools/index.d.ts +3 -0
  36. package/dist/tools/index.d.ts.map +1 -1
  37. package/dist/tools/index.js +12 -1
  38. package/dist/tools/index.js.map +1 -1
  39. package/dist/tools/migrate.d.ts.map +1 -1
  40. package/dist/tools/migrate.js +3 -2
  41. package/dist/tools/migrate.js.map +1 -1
  42. package/dist/tools/status.d.ts.map +1 -1
  43. package/dist/tools/status.js +2 -1
  44. package/dist/tools/status.js.map +1 -1
  45. package/dist/tools/support.d.ts +31 -0
  46. package/dist/tools/support.d.ts.map +1 -0
  47. package/dist/tools/support.js +83 -0
  48. package/dist/tools/support.js.map +1 -0
  49. package/dist/tools/upgrade.d.ts.map +1 -1
  50. package/dist/tools/upgrade.js +2 -1
  51. package/dist/tools/upgrade.js.map +1 -1
  52. package/package.json +2 -1
package/dist/prompts.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // Returned in the MCP `initialize` response. Clients SHOULD inject this into the
4
4
  // system prompt, giving the LLM persistent behavioral guidance for the session.
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PROMPT_DEFINITIONS = exports.IMPORT_TOOL_DESCRIPTION = exports.IMPORT_FROM_TOOL_DESCRIPTION = exports.MIGRATE_TOOL_DESCRIPTION = exports.UPGRADE_TOOL_DESCRIPTION = exports.STATUS_TOOL_DESCRIPTION = exports.EXPORT_TOOL_DESCRIPTION = exports.FORGET_TOOL_DESCRIPTION = exports.RECALL_TOOL_DESCRIPTION = exports.REMEMBER_TOOL_DESCRIPTION = exports.SYSTEM_PROMPT_FRAGMENT = exports.SERVER_INSTRUCTIONS = void 0;
6
+ exports.PROMPT_DEFINITIONS = exports.ACCOUNT_TOOL_DESCRIPTION = exports.SUPPORT_TOOL_DESCRIPTION = exports.IMPORT_TOOL_DESCRIPTION = exports.IMPORT_FROM_TOOL_DESCRIPTION = exports.MIGRATE_TOOL_DESCRIPTION = exports.UPGRADE_TOOL_DESCRIPTION = exports.STATUS_TOOL_DESCRIPTION = exports.EXPORT_TOOL_DESCRIPTION = exports.FORGET_TOOL_DESCRIPTION = exports.RECALL_TOOL_DESCRIPTION = exports.REMEMBER_TOOL_DESCRIPTION = exports.SYSTEM_PROMPT_FRAGMENT = exports.SERVER_INSTRUCTIONS = void 0;
7
7
  exports.getPromptMessages = getPromptMessages;
8
8
  exports.SERVER_INSTRUCTIONS = `
9
9
  You have access to TotalReclaw, a persistent encrypted memory system. You SHOULD use these tools PROACTIVELY -- do not wait for the user to say "remember this" or "recall that."
@@ -55,7 +55,7 @@ Call totalreclaw_recall proactively when:
55
55
  - Extract atomic facts: "User prefers dark mode" not "User said they prefer dark mode and also use VS Code"
56
56
 
57
57
  ### Billing & Quota
58
- The free tier offers unlimited memories and reads, but memories are stored on a test network and may be reset. Pro ($5/month) stores memories permanently on-chain. Do NOT guess or invent quota numbers — use totalreclaw_status to check exact usage. For pricing details, refer users to https://totalreclaw.xyz
58
+ The free tier offers unlimited memories and reads, but memories are stored on a test network and may be reset. Pro stores memories permanently on-chain. Do NOT guess or hardcode pricing — use totalreclaw_status to check exact usage and current pricing. For pricing details, refer users to https://totalreclaw.xyz/pricing
59
59
 
60
60
  When a totalreclaw_remember call fails with "quota_exceeded":
61
61
  1. Inform the user they've hit a usage limit
@@ -73,6 +73,19 @@ API keys provided by the user are used only for the import and are never stored.
73
73
  - If your agent supports background routines or scheduled tasks, set up a routine to call totalreclaw_remember after conversations to ensure nothing is missed.
74
74
  - If your agent supports a credential vault or secret store, the user's TOTALRECLAW_RECOVERY_PHRASE should be stored there instead of as a plaintext environment variable.
75
75
  - TotalReclaw memories are fully portable -- they work across OpenClaw, IronClaw, Claude Desktop, Cursor, NanoClaw, and any MCP-compatible agent.
76
+
77
+ ### End of Conversation
78
+ When a substantive conversation is ending (the user says goodbye, the topic is resolved,
79
+ or the conversation naturally concludes), call totalreclaw_debrief with the key takeaways.
80
+
81
+ Focus on what individual memory storage missed:
82
+ - What was the conversation about overall?
83
+ - What was decided or resolved?
84
+ - What approaches were tried and what was the outcome?
85
+ - What's left unfinished?
86
+
87
+ Do NOT debrief casual conversations (greetings, simple Q&A, small talk).
88
+ Max 5 items, each 1-3 sentences, type "summary" or "context", importance 7-8.
76
89
  `;
77
90
  // Keep backward-compat export name (some callers may still reference it)
78
91
  exports.SYSTEM_PROMPT_FRAGMENT = exports.SERVER_INSTRUCTIONS;
@@ -226,6 +239,33 @@ PARAMETERS:
226
239
  - format: Format of content "markdown" or "json" (auto-detected if not specified)
227
240
  - merge_strategy: How to handle conflicts (default: skip_existing)
228
241
  - validate_only: Parse and validate without importing (dry-run)`;
242
+ exports.SUPPORT_TOOL_DESCRIPTION = `Get TotalReclaw support information and troubleshooting help.
243
+
244
+ Returns:
245
+ - Contact email (pre-filled with your wallet address)
246
+ - Documentation and issue tracker links
247
+ - Troubleshooting guide for common issues (lost phrase, slow recall, quota, import)
248
+
249
+ Use this when:
250
+ - User asks for help or how to contact support
251
+ - User encounters an issue and needs troubleshooting steps
252
+ - User asks about documentation or where to report bugs
253
+
254
+ Works even when TotalReclaw is not yet configured.`;
255
+ exports.ACCOUNT_TOOL_DESCRIPTION = `View your TotalReclaw account details at a glance.
256
+
257
+ Shows:
258
+ - Wallet address and subscription tier
259
+ - Write usage (used / limit / remaining)
260
+ - Total facts stored in your vault
261
+ - Feature flags enabled for your tier
262
+ - Recovery phrase hint (first and last word only)
263
+
264
+ Use this when:
265
+ - User asks about their account or profile
266
+ - User wants a comprehensive overview of their TotalReclaw setup
267
+ - User asks "what's my wallet" or "how many memories do I have"
268
+ - User wants to verify their recovery phrase (hint only, never the full phrase)`;
229
269
  // ── Layer 5: Prompt Fallback Templates ───────────────────────────────────────
230
270
  exports.PROMPT_DEFINITIONS = [
231
271
  {
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,iFAAiF;AACjF,gFAAgF;;;AAoQhF,8CAwCC;AA1SY,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoElC,CAAC;AAEF,yEAAyE;AAC5D,QAAA,sBAAsB,GAAG,2BAAmB,CAAC;AAE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AM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
@@ -1,26 +1,34 @@
1
1
  /**
2
- * TotalReclaw MCP - Crypto Operations
2
+ * TotalReclaw MCP - Crypto Operations (WASM-backed)
3
3
  *
4
- * All cryptographic primitives used by the MCP server. These must
5
- * produce byte-for-byte identical output to the TotalReclaw client library
6
- * (`client/src/crypto/`) so that memories written by one can be read by
7
- * the other.
4
+ * Thin wrappers over `@totalreclaw/core` WASM module. Same function
5
+ * signatures as the previous pure-TS implementation so callers don't
6
+ * need to change.
8
7
  *
9
- * Key derivation chain:
10
- * master_password + salt
11
- * -> Argon2id(t=3, m=65536, p=4, dkLen=32) -> masterKey
12
- * -> HKDF-SHA256(masterKey, salt, "totalreclaw-auth-key-v1", 32) -> authKey
13
- * -> HKDF-SHA256(masterKey, salt, "totalreclaw-encryption-key-v1", 32) -> encryptionKey
14
- * -> HKDF-SHA256(masterKey, salt, "openmemory-dedup-v1", 32) -> dedupKey
8
+ * The WASM module handles BIP-39 key derivation, AES-256-GCM encrypt/
9
+ * decrypt, SHA-256 blind indices, HMAC-SHA256 content fingerprints,
10
+ * and LSH seed derivation.
15
11
  *
16
- * Encryption: AES-256-GCM (12-byte IV, 16-byte tag)
17
- * Blind indices: SHA-256 of lowercase tokens
18
- * Content fingerprint: HMAC-SHA256(dedupKey, normalizeText(plaintext))
12
+ * The legacy Argon2id path (arbitrary password, not a BIP-39 mnemonic)
13
+ * is kept in TypeScript because the WASM module only supports BIP-39.
14
+ *
15
+ * Key derivation chain (BIP-39 path — handled by WASM):
16
+ * mnemonic -> BIP-39 PBKDF2 -> 512-bit seed
17
+ * -> HKDF-SHA256(seed, salt, "totalreclaw-auth-key-v1", 32) -> authKey
18
+ * -> HKDF-SHA256(seed, salt, "totalreclaw-encryption-key-v1", 32) -> encryptionKey
19
+ * -> HKDF-SHA256(seed, salt, "openmemory-dedup-v1", 32) -> dedupKey
20
+ *
21
+ * Key derivation chain (Argon2id legacy path — kept in TS):
22
+ * password + salt -> Argon2id(t=3, m=65536, p=4, dkLen=32) -> masterKey
23
+ * -> HKDF-SHA256 per sub-key (same info strings as above)
19
24
  */
25
+ import { validateMnemonic } from '@scure/bip39';
26
+ export { validateMnemonic };
20
27
  /**
21
28
  * Derive encryption keys from a BIP-39 mnemonic.
22
- * Uses the 512-bit BIP-39 seed as HKDF input (NOT the derived private key)
23
- * for proper key separation from the Ethereum signing key.
29
+ *
30
+ * Delegates to the WASM module which performs BIP-39 seed derivation
31
+ * and HKDF key separation.
24
32
  */
25
33
  export declare function deriveKeysFromMnemonic(mnemonic: string): {
26
34
  authKey: Buffer;
@@ -32,14 +40,7 @@ export declare function deriveKeysFromMnemonic(mnemonic: string): {
32
40
  * Derive auth, encryption, and dedup keys from a recovery phrase.
33
41
  *
34
42
  * If the password is a valid BIP-39 mnemonic (12 or 24 words), keys are
35
- * derived from the 512-bit BIP-39 seed via HKDF. Otherwise, the legacy
36
- * Argon2id path is used.
37
- *
38
- * For the Argon2id path: if no salt is provided a fresh 32-byte random salt
39
- * is generated. Pass an existing salt when restoring a previously-registered
40
- * account so that the derived keys match the original registration.
41
- *
42
- * @returns Object containing authKey, encryptionKey, dedupKey, and salt (all Buffers).
43
+ * derived via the WASM module. Otherwise, the legacy Argon2id path is used.
43
44
  */
44
45
  export declare function deriveKeys(password: string, existingSalt?: Buffer): {
45
46
  authKey: Buffer;
@@ -48,22 +49,14 @@ export declare function deriveKeys(password: string, existingSalt?: Buffer): {
48
49
  salt: Buffer;
49
50
  };
50
51
  /**
51
- * Derive a 32-byte seed for the LSH hasher from the master key derivation
52
- * chain.
53
- *
54
- * Call this once during initialization and pass the result to `new LSHHasher(seed, dims)`.
52
+ * Derive a 32-byte seed for the LSH hasher.
55
53
  *
56
- * For the BIP-39 path we use the full 512-bit BIP-39 seed as IKM; for the
57
- * Argon2id path we use the 32-byte Argon2id-derived master key. In both
58
- * cases the salt from `deriveKeys()` is reused for domain separation.
54
+ * For the BIP-39 path, delegates to the WASM module. For the Argon2id
55
+ * legacy path, stays in TypeScript.
59
56
  */
60
57
  export declare function deriveLshSeed(password: string, salt: Buffer): Uint8Array;
61
58
  /**
62
59
  * Compute the SHA-256 hash of the auth key.
63
- *
64
- * The server stores SHA256(authKey) during registration and uses it to look
65
- * up users on every request. The hex string returned here is what the plugin
66
- * sends to `/v1/register` as `auth_key_hash`.
67
60
  */
68
61
  export declare function computeAuthKeyHash(authKey: Buffer): string;
69
62
  /**
@@ -71,35 +64,22 @@ export declare function computeAuthKeyHash(authKey: Buffer): string;
71
64
  *
72
65
  * Wire format (base64-encoded):
73
66
  * [iv: 12 bytes][tag: 16 bytes][ciphertext: variable]
74
- *
75
- * This matches `serializeEncryptedData` in `client/src/crypto/aes.ts`.
76
67
  */
77
68
  export declare function encrypt(plaintext: string, encryptionKey: Buffer): string;
78
69
  /**
79
70
  * Decrypt a base64-encoded AES-256-GCM blob back to a UTF-8 string.
80
- *
81
- * Expects the wire format produced by `encrypt()` above.
82
71
  */
83
72
  export declare function decrypt(encryptedBase64: string, encryptionKey: Buffer): string;
84
73
  /**
85
74
  * Generate blind indices (SHA-256 hashes of tokens) for a text string.
86
75
  *
87
- * Tokenization rules (must match `client/src/crypto/blind.ts#tokenize`):
88
- * 1. Lowercase
89
- * 2. Remove punctuation (keep Unicode letters, numbers, whitespace)
90
- * 3. Split on whitespace
91
- * 4. Filter tokens shorter than 2 characters
92
- *
93
- * Each surviving token is SHA-256 hashed and returned as a hex string.
94
- * The returned array is deduplicated.
76
+ * Delegates to the WASM module which performs tokenization, stemming,
77
+ * and SHA-256 hashing.
95
78
  */
96
79
  export declare function generateBlindIndices(text: string): string[];
97
80
  /**
98
81
  * Compute an HMAC-SHA256 content fingerprint for exact-duplicate detection.
99
82
  *
100
- * The server stores this fingerprint and uses it to reject duplicate writes
101
- * without ever seeing the plaintext.
102
- *
103
83
  * @returns 64-character hex string.
104
84
  */
105
85
  export declare function generateContentFingerprint(plaintext: string, dedupKey: Buffer): string;
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/subgraph/crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAwCH;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAuB5E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM,GACpB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAiC5E;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,UAAU,CAkBZ;AAMD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D;AAMD;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAgBxE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAsB9E;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAkC3D;AAuBD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKtF"}
1
+ {"version":3,"file":"crypto.d.ts","sour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2
  /**
3
- * TotalReclaw MCP - Crypto Operations
3
+ * TotalReclaw MCP - Crypto Operations (WASM-backed)
4
4
  *
5
- * All cryptographic primitives used by the MCP server. These must
6
- * produce byte-for-byte identical output to the TotalReclaw client library
7
- * (`client/src/crypto/`) so that memories written by one can be read by
8
- * the other.
5
+ * Thin wrappers over `@totalreclaw/core` WASM module. Same function
6
+ * signatures as the previous pure-TS implementation so callers don't
7
+ * need to change.
9
8
  *
10
- * Key derivation chain:
11
- * master_password + salt
12
- * -> Argon2id(t=3, m=65536, p=4, dkLen=32) -> masterKey
13
- * -> HKDF-SHA256(masterKey, salt, "totalreclaw-auth-key-v1", 32) -> authKey
14
- * -> HKDF-SHA256(masterKey, salt, "totalreclaw-encryption-key-v1", 32) -> encryptionKey
15
- * -> HKDF-SHA256(masterKey, salt, "openmemory-dedup-v1", 32) -> dedupKey
9
+ * The WASM module handles BIP-39 key derivation, AES-256-GCM encrypt/
10
+ * decrypt, SHA-256 blind indices, HMAC-SHA256 content fingerprints,
11
+ * and LSH seed derivation.
16
12
  *
17
- * Encryption: AES-256-GCM (12-byte IV, 16-byte tag)
18
- * Blind indices: SHA-256 of lowercase tokens
19
- * Content fingerprint: HMAC-SHA256(dedupKey, normalizeText(plaintext))
13
+ * The legacy Argon2id path (arbitrary password, not a BIP-39 mnemonic)
14
+ * is kept in TypeScript because the WASM module only supports BIP-39.
15
+ *
16
+ * Key derivation chain (BIP-39 path — handled by WASM):
17
+ * mnemonic -> BIP-39 PBKDF2 -> 512-bit seed
18
+ * -> HKDF-SHA256(seed, salt, "totalreclaw-auth-key-v1", 32) -> authKey
19
+ * -> HKDF-SHA256(seed, salt, "totalreclaw-encryption-key-v1", 32) -> encryptionKey
20
+ * -> HKDF-SHA256(seed, salt, "openmemory-dedup-v1", 32) -> dedupKey
21
+ *
22
+ * Key derivation chain (Argon2id legacy path — kept in TS):
23
+ * password + salt -> Argon2id(t=3, m=65536, p=4, dkLen=32) -> masterKey
24
+ * -> HKDF-SHA256 per sub-key (same info strings as above)
20
25
  */
26
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
27
+ if (k2 === undefined) k2 = k;
28
+ var desc = Object.getOwnPropertyDescriptor(m, k);
29
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
30
+ desc = { enumerable: true, get: function() { return m[k]; } };
31
+ }
32
+ Object.defineProperty(o, k2, desc);
33
+ }) : (function(o, m, k, k2) {
34
+ if (k2 === undefined) k2 = k;
35
+ o[k2] = m[k];
36
+ }));
37
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
38
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
39
+ }) : function(o, v) {
40
+ o["default"] = v;
41
+ });
42
+ var __importStar = (this && this.__importStar) || (function () {
43
+ var ownKeys = function(o) {
44
+ ownKeys = Object.getOwnPropertyNames || function (o) {
45
+ var ar = [];
46
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
47
+ return ar;
48
+ };
49
+ return ownKeys(o);
50
+ };
51
+ return function (mod) {
52
+ if (mod && mod.__esModule) return mod;
53
+ var result = {};
54
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
55
+ __setModuleDefault(result, mod);
56
+ return result;
57
+ };
58
+ })();
21
59
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
60
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
61
  };
24
62
  Object.defineProperty(exports, "__esModule", { value: true });
63
+ exports.validateMnemonic = void 0;
25
64
  exports.deriveKeysFromMnemonic = deriveKeysFromMnemonic;
26
65
  exports.deriveKeys = deriveKeys;
27
66
  exports.deriveLshSeed = deriveLshSeed;
@@ -33,29 +72,27 @@ exports.generateContentFingerprint = generateContentFingerprint;
33
72
  const argon2_js_1 = require("@noble/hashes/argon2.js");
34
73
  const hkdf_js_1 = require("@noble/hashes/hkdf.js");
35
74
  const sha2_js_1 = require("@noble/hashes/sha2.js");
36
- const hmac_js_1 = require("@noble/hashes/hmac.js");
37
75
  const bip39_1 = require("@scure/bip39");
76
+ Object.defineProperty(exports, "validateMnemonic", { enumerable: true, get: function () { return bip39_1.validateMnemonic; } });
38
77
  const english_js_1 = require("@scure/bip39/wordlists/english.js");
39
- const porter_stemmer_1 = require("porter-stemmer");
40
78
  const node_crypto_1 = __importDefault(require("node:crypto"));
79
+ const wasm = __importStar(require("@totalreclaw/core"));
41
80
  // ---------------------------------------------------------------------------
42
- // Key Derivation
81
+ // Constants (only needed for the Argon2id legacy path)
43
82
  // ---------------------------------------------------------------------------
44
- /** HKDF context strings -- must match client/src/crypto/kdf.ts exactly. */
45
83
  const AUTH_KEY_INFO = 'totalreclaw-auth-key-v1';
46
84
  const ENCRYPTION_KEY_INFO = 'totalreclaw-encryption-key-v1';
47
85
  const DEDUP_KEY_INFO = 'openmemory-dedup-v1';
48
- /** Argon2id parameters -- OWASP recommendations, matching client defaults. */
49
86
  const ARGON2_TIME_COST = 3;
50
- const ARGON2_MEMORY_COST = 65536; // 64 MB in KiB
87
+ const ARGON2_MEMORY_COST = 65536;
51
88
  const ARGON2_PARALLELISM = 4;
52
89
  const ARGON2_DK_LEN = 32;
53
- /** AES-256-GCM constants. */
54
- const IV_LENGTH = 12;
55
- const TAG_LENGTH = 16;
56
- const KEY_LENGTH = 32;
90
+ // ---------------------------------------------------------------------------
91
+ // Helpers
92
+ // ---------------------------------------------------------------------------
57
93
  /**
58
- * Check if the input looks like a BIP-39 mnemonic (12 or 24 words from the BIP-39 English wordlist).
94
+ * Check if the input looks like a BIP-39 mnemonic (12 or 24 words from
95
+ * the BIP-39 English wordlist).
59
96
  */
60
97
  function isBip39Mnemonic(input) {
61
98
  const words = input.trim().split(/\s+/);
@@ -63,52 +100,37 @@ function isBip39Mnemonic(input) {
63
100
  return false;
64
101
  return (0, bip39_1.validateMnemonic)(input.trim(), english_js_1.wordlist);
65
102
  }
103
+ // ---------------------------------------------------------------------------
104
+ // Key Derivation
105
+ // ---------------------------------------------------------------------------
66
106
  /**
67
107
  * Derive encryption keys from a BIP-39 mnemonic.
68
- * Uses the 512-bit BIP-39 seed as HKDF input (NOT the derived private key)
69
- * for proper key separation from the Ethereum signing key.
108
+ *
109
+ * Delegates to the WASM module which performs BIP-39 seed derivation
110
+ * and HKDF key separation.
70
111
  */
71
112
  function deriveKeysFromMnemonic(mnemonic) {
72
- // BIP-39: mnemonic -> 512-bit seed via PBKDF2(mnemonic, "mnemonic", 2048 rounds)
73
- const seed = (0, bip39_1.mnemonicToSeedSync)(mnemonic.trim());
74
- // Use first 32 bytes of seed as deterministic salt for HKDF
75
- // (BIP-39 mnemonics are self-salting via PBKDF2, no random salt needed)
76
- const salt = Buffer.from(seed.slice(0, 32));
77
- // HKDF-SHA256 from the full 512-bit seed, using distinct info strings
78
- const enc = (s) => Buffer.from(s, 'utf8');
79
- const seedBuf = Buffer.from(seed);
80
- const authKey = Buffer.from((0, hkdf_js_1.hkdf)(sha2_js_1.sha256, seedBuf, salt, enc(AUTH_KEY_INFO), 32));
81
- const encryptionKey = Buffer.from((0, hkdf_js_1.hkdf)(sha2_js_1.sha256, seedBuf, salt, enc(ENCRYPTION_KEY_INFO), 32));
82
- const dedupKey = Buffer.from((0, hkdf_js_1.hkdf)(sha2_js_1.sha256, seedBuf, salt, enc(DEDUP_KEY_INFO), 32));
83
- return { authKey, encryptionKey, dedupKey, salt };
113
+ const result = wasm.deriveKeysFromMnemonic(mnemonic.trim());
114
+ return {
115
+ authKey: Buffer.from(result.auth_key, 'hex'),
116
+ encryptionKey: Buffer.from(result.encryption_key, 'hex'),
117
+ dedupKey: Buffer.from(result.dedup_key, 'hex'),
118
+ salt: Buffer.from(result.salt, 'hex'),
119
+ };
84
120
  }
85
121
  /**
86
122
  * Derive auth, encryption, and dedup keys from a recovery phrase.
87
123
  *
88
124
  * If the password is a valid BIP-39 mnemonic (12 or 24 words), keys are
89
- * derived from the 512-bit BIP-39 seed via HKDF. Otherwise, the legacy
90
- * Argon2id path is used.
91
- *
92
- * For the Argon2id path: if no salt is provided a fresh 32-byte random salt
93
- * is generated. Pass an existing salt when restoring a previously-registered
94
- * account so that the derived keys match the original registration.
95
- *
96
- * @returns Object containing authKey, encryptionKey, dedupKey, and salt (all Buffers).
125
+ * derived via the WASM module. Otherwise, the legacy Argon2id path is used.
97
126
  */
98
127
  function deriveKeys(password, existingSalt) {
99
- // Auto-detect BIP-39 mnemonic vs arbitrary password
100
128
  if (isBip39Mnemonic(password)) {
101
- // BIP-39 path: mnemonic is self-salting, existingSalt is ignored for derivation
102
- // but we still return the deterministic salt for server registration
103
129
  return deriveKeysFromMnemonic(password);
104
130
  }
105
- // Legacy path: arbitrary password via Argon2id
131
+ // Legacy path: arbitrary password via Argon2id (not in WASM)
106
132
  const salt = existingSalt ?? node_crypto_1.default.randomBytes(32);
107
- // Step 1 -- Argon2id to derive a 32-byte master key.
108
- // @noble/hashes argon2id accepts Uint8Array for both password and salt.
109
133
  const masterKey = (0, argon2_js_1.argon2id)(Buffer.from(password, 'utf8'), salt, { t: ARGON2_TIME_COST, m: ARGON2_MEMORY_COST, p: ARGON2_PARALLELISM, dkLen: ARGON2_DK_LEN });
110
- // Step 2 -- HKDF-SHA256 for each sub-key using distinct info strings.
111
- // @noble/hashes v2 requires Uint8Array for info param.
112
134
  const enc = (s) => Buffer.from(s, 'utf8');
113
135
  const authKey = Buffer.from((0, hkdf_js_1.hkdf)(sha2_js_1.sha256, masterKey, salt, enc(AUTH_KEY_INFO), 32));
114
136
  const encryptionKey = Buffer.from((0, hkdf_js_1.hkdf)(sha2_js_1.sha256, masterKey, salt, enc(ENCRYPTION_KEY_INFO), 32));
@@ -119,32 +141,18 @@ function deriveKeys(password, existingSalt) {
119
141
  // LSH Seed Derivation
120
142
  // ---------------------------------------------------------------------------
121
143
  /**
122
- * HKDF context string for LSH seed derivation.
123
- *
124
- * The LSH hasher needs a deterministic seed so that the same master key
125
- * always generates the same random hyperplane matrices. We derive this seed
126
- * from the master key using HKDF with a unique info string.
144
+ * Derive a 32-byte seed for the LSH hasher.
127
145
  *
128
- * For the BIP-39 path the HKDF input is the 512-bit BIP-39 seed; for the
129
- * Argon2id path it is the 32-byte master key.
130
- */
131
- const LSH_SEED_INFO = 'openmemory-lsh-seed-v1';
132
- /**
133
- * Derive a 32-byte seed for the LSH hasher from the master key derivation
134
- * chain.
135
- *
136
- * Call this once during initialization and pass the result to `new LSHHasher(seed, dims)`.
137
- *
138
- * For the BIP-39 path we use the full 512-bit BIP-39 seed as IKM; for the
139
- * Argon2id path we use the 32-byte Argon2id-derived master key. In both
140
- * cases the salt from `deriveKeys()` is reused for domain separation.
146
+ * For the BIP-39 path, delegates to the WASM module. For the Argon2id
147
+ * legacy path, stays in TypeScript.
141
148
  */
142
149
  function deriveLshSeed(password, salt) {
143
150
  if (isBip39Mnemonic(password)) {
144
- const seed = (0, bip39_1.mnemonicToSeedSync)(password.trim());
145
- return new Uint8Array((0, hkdf_js_1.hkdf)(sha2_js_1.sha256, Buffer.from(seed), salt, Buffer.from(LSH_SEED_INFO, 'utf8'), 32));
151
+ const seedHex = wasm.deriveLshSeed(password.trim(), salt.toString('hex'));
152
+ return new Uint8Array(Buffer.from(seedHex, 'hex'));
146
153
  }
147
154
  // Argon2id path: re-derive the master key, then HKDF with LSH info string.
155
+ const LSH_SEED_INFO = 'openmemory-lsh-seed-v1';
148
156
  const masterKey = (0, argon2_js_1.argon2id)(Buffer.from(password, 'utf8'), salt, { t: ARGON2_TIME_COST, m: ARGON2_MEMORY_COST, p: ARGON2_PARALLELISM, dkLen: ARGON2_DK_LEN });
149
157
  return new Uint8Array((0, hkdf_js_1.hkdf)(sha2_js_1.sha256, masterKey, salt, Buffer.from(LSH_SEED_INFO, 'utf8'), 32));
150
158
  }
@@ -153,13 +161,9 @@ function deriveLshSeed(password, salt) {
153
161
  // ---------------------------------------------------------------------------
154
162
  /**
155
163
  * Compute the SHA-256 hash of the auth key.
156
- *
157
- * The server stores SHA256(authKey) during registration and uses it to look
158
- * up users on every request. The hex string returned here is what the plugin
159
- * sends to `/v1/register` as `auth_key_hash`.
160
164
  */
161
165
  function computeAuthKeyHash(authKey) {
162
- return Buffer.from((0, sha2_js_1.sha256)(authKey)).toString('hex');
166
+ return wasm.computeAuthKeyHash(authKey.toString('hex'));
163
167
  }
164
168
  // ---------------------------------------------------------------------------
165
169
  // AES-256-GCM Encrypt / Decrypt
@@ -169,45 +173,15 @@ function computeAuthKeyHash(authKey) {
169
173
  *
170
174
  * Wire format (base64-encoded):
171
175
  * [iv: 12 bytes][tag: 16 bytes][ciphertext: variable]
172
- *
173
- * This matches `serializeEncryptedData` in `client/src/crypto/aes.ts`.
174
176
  */
175
177
  function encrypt(plaintext, encryptionKey) {
176
- if (encryptionKey.length !== KEY_LENGTH) {
177
- throw new Error(`Invalid key length: expected ${KEY_LENGTH}, got ${encryptionKey.length}`);
178
- }
179
- const iv = node_crypto_1.default.randomBytes(IV_LENGTH);
180
- const cipher = node_crypto_1.default.createCipheriv('aes-256-gcm', encryptionKey, iv, {
181
- authTagLength: TAG_LENGTH,
182
- });
183
- const ciphertext = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);
184
- const tag = cipher.getAuthTag();
185
- // Combine: iv || tag || ciphertext (same order as client library)
186
- const combined = Buffer.concat([iv, tag, ciphertext]);
187
- return combined.toString('base64');
178
+ return wasm.encrypt(plaintext, encryptionKey.toString('hex'));
188
179
  }
189
180
  /**
190
181
  * Decrypt a base64-encoded AES-256-GCM blob back to a UTF-8 string.
191
- *
192
- * Expects the wire format produced by `encrypt()` above.
193
182
  */
194
183
  function decrypt(encryptedBase64, encryptionKey) {
195
- if (encryptionKey.length !== KEY_LENGTH) {
196
- throw new Error(`Invalid key length: expected ${KEY_LENGTH}, got ${encryptionKey.length}`);
197
- }
198
- const combined = Buffer.from(encryptedBase64, 'base64');
199
- if (combined.length < IV_LENGTH + TAG_LENGTH) {
200
- throw new Error('Encrypted data too short');
201
- }
202
- const iv = combined.subarray(0, IV_LENGTH);
203
- const tag = combined.subarray(IV_LENGTH, IV_LENGTH + TAG_LENGTH);
204
- const ciphertext = combined.subarray(IV_LENGTH + TAG_LENGTH);
205
- const decipher = node_crypto_1.default.createDecipheriv('aes-256-gcm', encryptionKey, iv, {
206
- authTagLength: TAG_LENGTH,
207
- });
208
- decipher.setAuthTag(tag);
209
- const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
210
- return plaintext.toString('utf8');
184
+ return wasm.decrypt(encryptedBase64, encryptionKey.toString('hex'));
211
185
  }
212
186
  // ---------------------------------------------------------------------------
213
187
  // Blind Indices
@@ -215,73 +189,21 @@ function decrypt(encryptedBase64, encryptionKey) {
215
189
  /**
216
190
  * Generate blind indices (SHA-256 hashes of tokens) for a text string.
217
191
  *
218
- * Tokenization rules (must match `client/src/crypto/blind.ts#tokenize`):
219
- * 1. Lowercase
220
- * 2. Remove punctuation (keep Unicode letters, numbers, whitespace)
221
- * 3. Split on whitespace
222
- * 4. Filter tokens shorter than 2 characters
223
- *
224
- * Each surviving token is SHA-256 hashed and returned as a hex string.
225
- * The returned array is deduplicated.
192
+ * Delegates to the WASM module which performs tokenization, stemming,
193
+ * and SHA-256 hashing.
226
194
  */
227
195
  function generateBlindIndices(text) {
228
- const tokens = text
229
- .toLowerCase()
230
- .replace(/[^\p{L}\p{N}\s]/gu, ' ') // Remove punctuation, keep letters/numbers
231
- .split(/\s+/)
232
- .filter((t) => t.length >= 2);
233
- const seen = new Set();
234
- const indices = [];
235
- for (const token of tokens) {
236
- // Exact word hash (unchanged behavior).
237
- const hash = Buffer.from((0, sha2_js_1.sha256)(Buffer.from(token, 'utf8'))).toString('hex');
238
- if (!seen.has(hash)) {
239
- seen.add(hash);
240
- indices.push(hash);
241
- }
242
- // Stemmed word hash. The stem is prefixed with "stem:" before hashing
243
- // to avoid collisions between a word that happens to equal another
244
- // word's stem (e.g., the word "commun" vs the stem of "community").
245
- const stem = (0, porter_stemmer_1.stemmer)(token);
246
- if (stem.length >= 2 && stem !== token) {
247
- const stemHash = Buffer.from((0, sha2_js_1.sha256)(Buffer.from(`stem:${stem}`, 'utf8'))).toString('hex');
248
- if (!seen.has(stemHash)) {
249
- seen.add(stemHash);
250
- indices.push(stemHash);
251
- }
252
- }
253
- }
254
- return indices;
196
+ return wasm.generateBlindIndices(text);
255
197
  }
256
198
  // ---------------------------------------------------------------------------
257
199
  // Content Fingerprint (Dedup)
258
200
  // ---------------------------------------------------------------------------
259
- /**
260
- * Normalize text for deterministic fingerprinting.
261
- *
262
- * Steps (matching `client/src/crypto/fingerprint.ts#normalizeText`):
263
- * 1. Unicode NFC normalization
264
- * 2. Lowercase
265
- * 3. Collapse whitespace (spaces/tabs/newlines to single space)
266
- * 4. Trim leading/trailing whitespace
267
- */
268
- function normalizeText(text) {
269
- return text
270
- .normalize('NFC')
271
- .toLowerCase()
272
- .replace(/\s+/g, ' ')
273
- .trim();
274
- }
275
201
  /**
276
202
  * Compute an HMAC-SHA256 content fingerprint for exact-duplicate detection.
277
203
  *
278
- * The server stores this fingerprint and uses it to reject duplicate writes
279
- * without ever seeing the plaintext.
280
- *
281
204
  * @returns 64-character hex string.
282
205
  */
283
206
  function generateContentFingerprint(plaintext, dedupKey) {
284
- const normalized = normalizeText(plaintext);
285
- return Buffer.from((0, hmac_js_1.hmac)(sha2_js_1.sha256, dedupKey, Buffer.from(normalized, 'utf8'))).toString('hex');
207
+ return wasm.generateContentFingerprint(plaintext, dedupKey.toString('hex'));
286
208
  }
287
209
  //# sourceMappingURL=crypto.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/subgraph/crypto.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;AA6CH,wDAyBC;AAeD,gCAoCC;AA4BD,sCAqBC;AAaD,gDAEC;AAcD,0BAgBC;AAOD,0BAsBC;AAkBD,oDAkCC;AA+BD,gEAKC;AA1UD,uD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