@totalreclaw/mcp-server 3.2.1 → 3.3.0-rc.2
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/SKILL.md +203 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -1
- package/dist/pair-crypto.d.ts +95 -0
- package/dist/pair-crypto.d.ts.map +1 -0
- package/dist/pair-crypto.js +223 -0
- package/dist/pair-crypto.js.map +1 -0
- package/dist/pair-remote-client.d.ts +78 -0
- package/dist/pair-remote-client.d.ts.map +1 -0
- package/dist/pair-remote-client.js +355 -0
- package/dist/pair-remote-client.js.map +1 -0
- package/dist/prompts.d.ts +1 -0
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +12 -1
- package/dist/prompts.js.map +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +7 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/pair.d.ts +118 -0
- package/dist/tools/pair.d.ts.map +1 -0
- package/dist/tools/pair.js +399 -0
- package/dist/tools/pair.js.map +1 -0
- package/dist/trajectory-poller.d.ts +148 -0
- package/dist/trajectory-poller.d.ts.map +1 -0
- package/dist/trajectory-poller.js +304 -0
- package/dist/trajectory-poller.js.map +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pair-crypto — gateway-side cryptographic primitives for the relay-brokered
|
|
3
|
+
* pair flow.
|
|
4
|
+
*
|
|
5
|
+
* NOTE — this is a port of the plugin's `skill/plugin/pair-crypto.ts`
|
|
6
|
+
* (TotalReclaw plugin v3.3.1-rc.12+). Wire formats (base64url + AES-256-GCM
|
|
7
|
+
* + HKDF-SHA256 + x25519 ECDH) are byte-for-byte compatible with the plugin
|
|
8
|
+
* and the Hermes Python implementation, so all three gateway flavors talk to
|
|
9
|
+
* the same browser pair-page and the same `totalreclaw-relay` endpoints.
|
|
10
|
+
*
|
|
11
|
+
* Ported into mcp-server 3.3.0-rc.1 to enable the MCP-only install path:
|
|
12
|
+
* users add the MCP server, agent calls `totalreclaw_pair` tool, browser
|
|
13
|
+
* generates phrase, encrypted phrase flows back to the MCP process which
|
|
14
|
+
* decrypts and writes credentials.json — phrase NEVER crosses LLM context.
|
|
15
|
+
*
|
|
16
|
+
* Cipher suite (matches plugin / Hermes):
|
|
17
|
+
* - x25519 ECDH for key agreement
|
|
18
|
+
* - HKDF-SHA256 (info = "totalreclaw-pair-v2") for symmetric-key derivation
|
|
19
|
+
* - AES-256-GCM AEAD with 12-byte nonce, 16-byte tag, sid as AD
|
|
20
|
+
*
|
|
21
|
+
* Phrase-safety invariants:
|
|
22
|
+
* - This module ONLY runs on the gateway (MCP server) host.
|
|
23
|
+
* - No `fs.*` calls, no env-var reads, no network primitives.
|
|
24
|
+
* - Public surface emits only base64url-encoded raw 32-byte public keys.
|
|
25
|
+
*
|
|
26
|
+
* Future cleanup: pull `pair-crypto.ts` + `pair-remote-client.ts` into a
|
|
27
|
+
* shared `@totalreclaw/pair-client` package so plugin + mcp-server can share
|
|
28
|
+
* one source of truth. For now this is a verbatim copy — keep in sync with
|
|
29
|
+
* the plugin manually until the shared-package work lands.
|
|
30
|
+
*/
|
|
31
|
+
export declare const HKDF_INFO = "totalreclaw-pair-v2";
|
|
32
|
+
export declare const AEAD_KEY_BYTES = 32;
|
|
33
|
+
export declare const AEAD_NONCE_BYTES = 12;
|
|
34
|
+
export declare const AEAD_TAG_BYTES = 16;
|
|
35
|
+
export declare const X25519_KEY_BYTES = 32;
|
|
36
|
+
export type PublicKeyB64 = string;
|
|
37
|
+
export type PrivateKeyB64 = string;
|
|
38
|
+
export type NonceB64 = string;
|
|
39
|
+
export type CiphertextB64 = string;
|
|
40
|
+
export interface GatewayKeypair {
|
|
41
|
+
skB64: PrivateKeyB64;
|
|
42
|
+
pkB64: PublicKeyB64;
|
|
43
|
+
}
|
|
44
|
+
export interface SessionKeys {
|
|
45
|
+
kEnc: Buffer;
|
|
46
|
+
}
|
|
47
|
+
export interface DecryptInputs {
|
|
48
|
+
skGatewayB64: PrivateKeyB64;
|
|
49
|
+
pkDeviceB64: PublicKeyB64;
|
|
50
|
+
sid: string;
|
|
51
|
+
nonceB64: NonceB64;
|
|
52
|
+
ciphertextB64: CiphertextB64;
|
|
53
|
+
}
|
|
54
|
+
export interface EncryptInputs {
|
|
55
|
+
skLocalB64: PrivateKeyB64;
|
|
56
|
+
pkRemoteB64: PublicKeyB64;
|
|
57
|
+
sid: string;
|
|
58
|
+
plaintext: Buffer | Uint8Array;
|
|
59
|
+
nonceB64?: NonceB64;
|
|
60
|
+
}
|
|
61
|
+
export interface EncryptOutput {
|
|
62
|
+
nonceB64: NonceB64;
|
|
63
|
+
ciphertextB64: CiphertextB64;
|
|
64
|
+
}
|
|
65
|
+
export declare function generateGatewayKeypair(): GatewayKeypair;
|
|
66
|
+
export declare function derivePublicFromPrivate(skB64: PrivateKeyB64): PublicKeyB64;
|
|
67
|
+
export declare function computeSharedSecret(opts: {
|
|
68
|
+
skLocalB64: PrivateKeyB64;
|
|
69
|
+
pkRemoteB64: PublicKeyB64;
|
|
70
|
+
}): Buffer;
|
|
71
|
+
export declare function deriveSessionKeys(opts: {
|
|
72
|
+
sharedSecret: Buffer;
|
|
73
|
+
sid: string;
|
|
74
|
+
}): SessionKeys;
|
|
75
|
+
export declare function deriveAeadKeyFromEcdh(opts: {
|
|
76
|
+
skLocalB64: PrivateKeyB64;
|
|
77
|
+
pkRemoteB64: PublicKeyB64;
|
|
78
|
+
sid: string;
|
|
79
|
+
}): SessionKeys;
|
|
80
|
+
export declare function aeadDecrypt(opts: {
|
|
81
|
+
kEnc: Buffer;
|
|
82
|
+
nonceB64: NonceB64;
|
|
83
|
+
sid: string;
|
|
84
|
+
ciphertextB64: CiphertextB64;
|
|
85
|
+
}): Buffer;
|
|
86
|
+
export declare function decryptPairingPayload(inputs: DecryptInputs): Buffer;
|
|
87
|
+
export declare function aeadEncryptWithSessionKey(opts: {
|
|
88
|
+
kEnc: Buffer;
|
|
89
|
+
sid: string;
|
|
90
|
+
plaintext: Buffer | Uint8Array;
|
|
91
|
+
nonceB64?: NonceB64;
|
|
92
|
+
}): EncryptOutput;
|
|
93
|
+
export declare function encryptPairingPayload(inputs: EncryptInputs): EncryptOutput;
|
|
94
|
+
export declare function compareSecondaryCodesCT(a: string, b: string): boolean;
|
|
95
|
+
//# sourceMappingURL=pair-crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pair-crypto.d.ts","sourceRoot":"","sources":["../src/pair-crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAkBH,eAAO,MAAM,SAAS,wBAAwB,CAAC;AAC/C,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAMnC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AACnC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,aAAa,CAAC;IAC5B,WAAW,EAAE,YAAY,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,aAAa,CAAC;IAC1B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qB,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAY1E;AAED,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAWrE"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* pair-crypto — gateway-side cryptographic primitives for the relay-brokered
|
|
4
|
+
* pair flow.
|
|
5
|
+
*
|
|
6
|
+
* NOTE — this is a port of the plugin's `skill/plugin/pair-crypto.ts`
|
|
7
|
+
* (TotalReclaw plugin v3.3.1-rc.12+). Wire formats (base64url + AES-256-GCM
|
|
8
|
+
* + HKDF-SHA256 + x25519 ECDH) are byte-for-byte compatible with the plugin
|
|
9
|
+
* and the Hermes Python implementation, so all three gateway flavors talk to
|
|
10
|
+
* the same browser pair-page and the same `totalreclaw-relay` endpoints.
|
|
11
|
+
*
|
|
12
|
+
* Ported into mcp-server 3.3.0-rc.1 to enable the MCP-only install path:
|
|
13
|
+
* users add the MCP server, agent calls `totalreclaw_pair` tool, browser
|
|
14
|
+
* generates phrase, encrypted phrase flows back to the MCP process which
|
|
15
|
+
* decrypts and writes credentials.json — phrase NEVER crosses LLM context.
|
|
16
|
+
*
|
|
17
|
+
* Cipher suite (matches plugin / Hermes):
|
|
18
|
+
* - x25519 ECDH for key agreement
|
|
19
|
+
* - HKDF-SHA256 (info = "totalreclaw-pair-v2") for symmetric-key derivation
|
|
20
|
+
* - AES-256-GCM AEAD with 12-byte nonce, 16-byte tag, sid as AD
|
|
21
|
+
*
|
|
22
|
+
* Phrase-safety invariants:
|
|
23
|
+
* - This module ONLY runs on the gateway (MCP server) host.
|
|
24
|
+
* - No `fs.*` calls, no env-var reads, no network primitives.
|
|
25
|
+
* - Public surface emits only base64url-encoded raw 32-byte public keys.
|
|
26
|
+
*
|
|
27
|
+
* Future cleanup: pull `pair-crypto.ts` + `pair-remote-client.ts` into a
|
|
28
|
+
* shared `@totalreclaw/pair-client` package so plugin + mcp-server can share
|
|
29
|
+
* one source of truth. For now this is a verbatim copy — keep in sync with
|
|
30
|
+
* the plugin manually until the shared-package work lands.
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.X25519_KEY_BYTES = exports.AEAD_TAG_BYTES = exports.AEAD_NONCE_BYTES = exports.AEAD_KEY_BYTES = exports.HKDF_INFO = void 0;
|
|
34
|
+
exports.generateGatewayKeypair = generateGatewayKeypair;
|
|
35
|
+
exports.derivePublicFromPrivate = derivePublicFromPrivate;
|
|
36
|
+
exports.computeSharedSecret = computeSharedSecret;
|
|
37
|
+
exports.deriveSessionKeys = deriveSessionKeys;
|
|
38
|
+
exports.deriveAeadKeyFromEcdh = deriveAeadKeyFromEcdh;
|
|
39
|
+
exports.aeadDecrypt = aeadDecrypt;
|
|
40
|
+
exports.decryptPairingPayload = decryptPairingPayload;
|
|
41
|
+
exports.aeadEncryptWithSessionKey = aeadEncryptWithSessionKey;
|
|
42
|
+
exports.encryptPairingPayload = encryptPairingPayload;
|
|
43
|
+
exports.compareSecondaryCodesCT = compareSecondaryCodesCT;
|
|
44
|
+
const node_crypto_1 = require("node:crypto");
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Constants
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
exports.HKDF_INFO = 'totalreclaw-pair-v2';
|
|
49
|
+
exports.AEAD_KEY_BYTES = 32;
|
|
50
|
+
exports.AEAD_NONCE_BYTES = 12;
|
|
51
|
+
exports.AEAD_TAG_BYTES = 16;
|
|
52
|
+
exports.X25519_KEY_BYTES = 32;
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
// Key generation / conversion
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
function generateGatewayKeypair() {
|
|
57
|
+
const { publicKey, privateKey } = (0, node_crypto_1.generateKeyPairSync)('x25519');
|
|
58
|
+
return {
|
|
59
|
+
skB64: extractRawPrivate(privateKey),
|
|
60
|
+
pkB64: extractRawPublic(publicKey),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function publicKeyFromB64(pkB64) {
|
|
64
|
+
const raw = Buffer.from(pkB64, 'base64url');
|
|
65
|
+
if (raw.length !== exports.X25519_KEY_BYTES) {
|
|
66
|
+
throw new Error(`pair-crypto: public key must be ${exports.X25519_KEY_BYTES} bytes (got ${raw.length})`);
|
|
67
|
+
}
|
|
68
|
+
return (0, node_crypto_1.createPublicKey)({
|
|
69
|
+
key: { kty: 'OKP', crv: 'X25519', x: raw.toString('base64url') },
|
|
70
|
+
format: 'jwk',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function privateKeyFromB64(skB64) {
|
|
74
|
+
const raw = Buffer.from(skB64, 'base64url');
|
|
75
|
+
if (raw.length !== exports.X25519_KEY_BYTES) {
|
|
76
|
+
throw new Error(`pair-crypto: private key must be ${exports.X25519_KEY_BYTES} bytes (got ${raw.length})`);
|
|
77
|
+
}
|
|
78
|
+
const tempPriv = (0, node_crypto_1.createPrivateKey)({
|
|
79
|
+
key: { kty: 'OKP', crv: 'X25519', d: raw.toString('base64url'), x: '' },
|
|
80
|
+
format: 'jwk',
|
|
81
|
+
});
|
|
82
|
+
const pubObj = (0, node_crypto_1.createPublicKey)(tempPriv);
|
|
83
|
+
const pubJwk = pubObj.export({ format: 'jwk' });
|
|
84
|
+
return (0, node_crypto_1.createPrivateKey)({
|
|
85
|
+
key: { kty: 'OKP', crv: 'X25519', d: raw.toString('base64url'), x: pubJwk.x },
|
|
86
|
+
format: 'jwk',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function extractRawPublic(pk) {
|
|
90
|
+
const jwk = pk.export({ format: 'jwk' });
|
|
91
|
+
if (!jwk.x)
|
|
92
|
+
throw new Error('pair-crypto: public key JWK is missing the x field');
|
|
93
|
+
return jwk.x;
|
|
94
|
+
}
|
|
95
|
+
function extractRawPrivate(sk) {
|
|
96
|
+
const jwk = sk.export({ format: 'jwk' });
|
|
97
|
+
if (!jwk.d)
|
|
98
|
+
throw new Error('pair-crypto: private key JWK is missing the d field');
|
|
99
|
+
return jwk.d;
|
|
100
|
+
}
|
|
101
|
+
function derivePublicFromPrivate(skB64) {
|
|
102
|
+
const sk = privateKeyFromB64(skB64);
|
|
103
|
+
const pk = (0, node_crypto_1.createPublicKey)(sk);
|
|
104
|
+
return extractRawPublic(pk);
|
|
105
|
+
}
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
// ECDH + HKDF
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
function computeSharedSecret(opts) {
|
|
110
|
+
const sk = privateKeyFromB64(opts.skLocalB64);
|
|
111
|
+
const pk = publicKeyFromB64(opts.pkRemoteB64);
|
|
112
|
+
const shared = (0, node_crypto_1.diffieHellman)({ privateKey: sk, publicKey: pk });
|
|
113
|
+
if (shared.length !== exports.X25519_KEY_BYTES) {
|
|
114
|
+
throw new Error(`pair-crypto: ECDH output wrong length (got ${shared.length}, expected ${exports.X25519_KEY_BYTES})`);
|
|
115
|
+
}
|
|
116
|
+
return shared;
|
|
117
|
+
}
|
|
118
|
+
function deriveSessionKeys(opts) {
|
|
119
|
+
if (opts.sharedSecret.length !== exports.X25519_KEY_BYTES) {
|
|
120
|
+
throw new Error('pair-crypto: shared secret must be 32 bytes');
|
|
121
|
+
}
|
|
122
|
+
if (typeof opts.sid !== 'string' || opts.sid.length === 0) {
|
|
123
|
+
throw new Error('pair-crypto: sid is required for HKDF salt binding');
|
|
124
|
+
}
|
|
125
|
+
const salt = Buffer.from(opts.sid, 'utf-8');
|
|
126
|
+
const info = Buffer.from(exports.HKDF_INFO, 'utf-8');
|
|
127
|
+
const okm = (0, node_crypto_1.hkdfSync)('sha256', opts.sharedSecret, salt, info, exports.AEAD_KEY_BYTES);
|
|
128
|
+
return { kEnc: Buffer.from(okm) };
|
|
129
|
+
}
|
|
130
|
+
function deriveAeadKeyFromEcdh(opts) {
|
|
131
|
+
const shared = computeSharedSecret({
|
|
132
|
+
skLocalB64: opts.skLocalB64,
|
|
133
|
+
pkRemoteB64: opts.pkRemoteB64,
|
|
134
|
+
});
|
|
135
|
+
return deriveSessionKeys({ sharedSecret: shared, sid: opts.sid });
|
|
136
|
+
}
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
// AEAD
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
function aeadDecrypt(opts) {
|
|
141
|
+
const nonce = Buffer.from(opts.nonceB64, 'base64url');
|
|
142
|
+
if (nonce.length !== exports.AEAD_NONCE_BYTES) {
|
|
143
|
+
throw new Error(`pair-crypto: nonce must be ${exports.AEAD_NONCE_BYTES} bytes (got ${nonce.length})`);
|
|
144
|
+
}
|
|
145
|
+
if (opts.kEnc.length !== exports.AEAD_KEY_BYTES) {
|
|
146
|
+
throw new Error(`pair-crypto: AEAD key must be ${exports.AEAD_KEY_BYTES} bytes`);
|
|
147
|
+
}
|
|
148
|
+
const combined = Buffer.from(opts.ciphertextB64, 'base64url');
|
|
149
|
+
if (combined.length < exports.AEAD_TAG_BYTES) {
|
|
150
|
+
throw new Error('pair-crypto: ciphertext too short to contain tag');
|
|
151
|
+
}
|
|
152
|
+
const ct = combined.subarray(0, combined.length - exports.AEAD_TAG_BYTES);
|
|
153
|
+
const tag = combined.subarray(combined.length - exports.AEAD_TAG_BYTES);
|
|
154
|
+
const decipher = (0, node_crypto_1.createDecipheriv)('aes-256-gcm', opts.kEnc, nonce, {
|
|
155
|
+
authTagLength: exports.AEAD_TAG_BYTES,
|
|
156
|
+
});
|
|
157
|
+
decipher.setAAD(Buffer.from(opts.sid, 'utf-8'), { plaintextLength: ct.length });
|
|
158
|
+
decipher.setAuthTag(tag);
|
|
159
|
+
const pt1 = decipher.update(ct);
|
|
160
|
+
const pt2 = decipher.final();
|
|
161
|
+
return Buffer.concat([pt1, pt2]);
|
|
162
|
+
}
|
|
163
|
+
function decryptPairingPayload(inputs) {
|
|
164
|
+
const { kEnc } = deriveAeadKeyFromEcdh({
|
|
165
|
+
skLocalB64: inputs.skGatewayB64,
|
|
166
|
+
pkRemoteB64: inputs.pkDeviceB64,
|
|
167
|
+
sid: inputs.sid,
|
|
168
|
+
});
|
|
169
|
+
return aeadDecrypt({
|
|
170
|
+
kEnc,
|
|
171
|
+
nonceB64: inputs.nonceB64,
|
|
172
|
+
sid: inputs.sid,
|
|
173
|
+
ciphertextB64: inputs.ciphertextB64,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function aeadEncryptWithSessionKey(opts) {
|
|
177
|
+
if (opts.kEnc.length !== exports.AEAD_KEY_BYTES) {
|
|
178
|
+
throw new Error(`pair-crypto: AEAD key must be ${exports.AEAD_KEY_BYTES} bytes`);
|
|
179
|
+
}
|
|
180
|
+
const nonceBuf = opts.nonceB64 !== undefined
|
|
181
|
+
? Buffer.from(opts.nonceB64, 'base64url')
|
|
182
|
+
: (0, node_crypto_1.randomBytes)(exports.AEAD_NONCE_BYTES);
|
|
183
|
+
if (nonceBuf.length !== exports.AEAD_NONCE_BYTES) {
|
|
184
|
+
throw new Error(`pair-crypto: nonce must be ${exports.AEAD_NONCE_BYTES} bytes`);
|
|
185
|
+
}
|
|
186
|
+
const pt = Buffer.isBuffer(opts.plaintext) ? opts.plaintext : Buffer.from(opts.plaintext);
|
|
187
|
+
const cipher = (0, node_crypto_1.createCipheriv)('aes-256-gcm', opts.kEnc, nonceBuf, {
|
|
188
|
+
authTagLength: exports.AEAD_TAG_BYTES,
|
|
189
|
+
});
|
|
190
|
+
cipher.setAAD(Buffer.from(opts.sid, 'utf-8'), { plaintextLength: pt.length });
|
|
191
|
+
const ct = Buffer.concat([cipher.update(pt), cipher.final()]);
|
|
192
|
+
const tag = cipher.getAuthTag();
|
|
193
|
+
return {
|
|
194
|
+
nonceB64: nonceBuf.toString('base64url'),
|
|
195
|
+
ciphertextB64: Buffer.concat([ct, tag]).toString('base64url'),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function encryptPairingPayload(inputs) {
|
|
199
|
+
const { kEnc } = deriveAeadKeyFromEcdh({
|
|
200
|
+
skLocalB64: inputs.skLocalB64,
|
|
201
|
+
pkRemoteB64: inputs.pkRemoteB64,
|
|
202
|
+
sid: inputs.sid,
|
|
203
|
+
});
|
|
204
|
+
return aeadEncryptWithSessionKey({
|
|
205
|
+
kEnc,
|
|
206
|
+
sid: inputs.sid,
|
|
207
|
+
plaintext: inputs.plaintext,
|
|
208
|
+
nonceB64: inputs.nonceB64,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function compareSecondaryCodesCT(a, b) {
|
|
212
|
+
const aBuf = Buffer.from(a, 'utf-8');
|
|
213
|
+
const bBuf = Buffer.from(b, 'utf-8');
|
|
214
|
+
const lenMatch = aBuf.length === bBuf.length;
|
|
215
|
+
const max = Math.max(aBuf.length, bBuf.length, 6);
|
|
216
|
+
const aPad = Buffer.alloc(max);
|
|
217
|
+
const bPad = Buffer.alloc(max);
|
|
218
|
+
aBuf.copy(aPad);
|
|
219
|
+
bBuf.copy(bPad);
|
|
220
|
+
const byteMatch = (0, node_crypto_1.timingSafeEqual)(aPad, bPad);
|
|
221
|
+
return lenMatch && byteMatch;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=pair-crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pair-crypto.js","sourceRoot":"","sources":["../src/pair-crypto.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAmEH,wDAMC;AA0CD,0DAIC;AAMD,kDAaC;AAED,8CAcC;AAED,sDAUC;AAMD,kCA6BC;AAED,sDAYC;AAED,8DA4BC;AAED,sDAYC;AAED,0DAWC;AA9QD,6CAUqB;AAErB,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAEjE,QAAA,SAAS,GAAG,qBAAqB,CAAC;AAClC,QAAA,cAAc,GAAG,EAAE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W;QAC/B,GAAG,EAAE,MAAM,CAAC,GAAG;KAChB,CAAC,CAAC;IACH,OAAO,yBAAyB,CAAC;QAC/B,IAAI;QACJ,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;KAC1B,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,uBAAuB,CAAC,CAAS,EAAE,CAAS;IAC1D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,MAAM,SAAS,GAAG,IAAA,6BAAe,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9C,OAAO,QAAQ,IAAI,SAAS,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pair-remote-client — gateway-side WebSocket client for the relay-brokered
|
|
3
|
+
* pair flow.
|
|
4
|
+
*
|
|
5
|
+
* Ported from the plugin's `skill/plugin/pair-remote-client.ts` (TotalReclaw
|
|
6
|
+
* plugin v3.3.1-rc.11+) so the MCP server's `totalreclaw_pair` tool emits the
|
|
7
|
+
* same URL/PIN format the browser pair-page already understands.
|
|
8
|
+
*
|
|
9
|
+
* Flow (gateway side):
|
|
10
|
+
* 1. Generate ephemeral x25519 keypair.
|
|
11
|
+
* 2. Open WS to `wss://<relay>/pair/session/open`.
|
|
12
|
+
* 3. Send `{type:"open", gateway_pubkey, pin, client_id, mode}`.
|
|
13
|
+
* 4. Receive `{type:"opened", token, expires_at}` — build the user URL.
|
|
14
|
+
* 5. Block on the WS until the relay pushes `{type:"forward", client_pubkey, nonce, ciphertext}`.
|
|
15
|
+
* 6. Decrypt locally via x25519 ECDH + AES-256-GCM.
|
|
16
|
+
* 7. Hand the decrypted phrase to the caller's completePairing handler
|
|
17
|
+
* (writes credentials.json) and ack/nack the relay.
|
|
18
|
+
*
|
|
19
|
+
* Phrase-safety:
|
|
20
|
+
* - Relay sees only ciphertext.
|
|
21
|
+
* - Phrase NEVER touches logs / stdout / agent context.
|
|
22
|
+
* - PIN is on the tool return payload (required for the user to type into
|
|
23
|
+
* the browser) but is never logged.
|
|
24
|
+
*
|
|
25
|
+
* Scope:
|
|
26
|
+
* - No `fs.*` calls — caller passes a completePairing handler.
|
|
27
|
+
* - No env-var reads — caller passes the relay base URL.
|
|
28
|
+
*
|
|
29
|
+
* See pair-crypto.ts for the cipher-suite header comment.
|
|
30
|
+
*/
|
|
31
|
+
import WebSocket from 'ws';
|
|
32
|
+
import { type GatewayKeypair } from './pair-crypto.js';
|
|
33
|
+
export declare const DEFAULT_RELAY_URL = "wss://api.totalreclaw.xyz";
|
|
34
|
+
export type PairRelayMode = 'generate' | 'import' | 'either';
|
|
35
|
+
export interface RemotePairSession {
|
|
36
|
+
url: string;
|
|
37
|
+
pin: string;
|
|
38
|
+
token: string;
|
|
39
|
+
expiresAt: string;
|
|
40
|
+
keypair: GatewayKeypair;
|
|
41
|
+
mode: PairRelayMode;
|
|
42
|
+
_ws: WebSocket;
|
|
43
|
+
}
|
|
44
|
+
export interface RelayCompletionResult {
|
|
45
|
+
state: 'active' | 'error';
|
|
46
|
+
accountId?: string;
|
|
47
|
+
error?: string;
|
|
48
|
+
}
|
|
49
|
+
export type RelayCompletePairingHandler = (inputs: {
|
|
50
|
+
mnemonic: string;
|
|
51
|
+
session: RemotePairSession;
|
|
52
|
+
}) => Promise<RelayCompletionResult>;
|
|
53
|
+
export type PhraseValidator = (phrase: string) => boolean;
|
|
54
|
+
export interface OpenRemotePairOptions {
|
|
55
|
+
relayBaseUrl?: string;
|
|
56
|
+
pin?: string;
|
|
57
|
+
clientId?: string;
|
|
58
|
+
mode?: PairRelayMode;
|
|
59
|
+
keypair?: GatewayKeypair;
|
|
60
|
+
webSocketImpl?: typeof WebSocket;
|
|
61
|
+
now?: () => number;
|
|
62
|
+
}
|
|
63
|
+
export interface AwaitPhraseUploadOptions {
|
|
64
|
+
completePairing: RelayCompletePairingHandler;
|
|
65
|
+
phraseValidator?: PhraseValidator;
|
|
66
|
+
timeoutMs?: number;
|
|
67
|
+
}
|
|
68
|
+
export declare function openRemotePairSession(opts?: OpenRemotePairOptions): Promise<RemotePairSession>;
|
|
69
|
+
export declare function awaitPhraseUpload(session: RemotePairSession, opts: AwaitPhraseUploadOptions): Promise<RelayCompletionResult>;
|
|
70
|
+
export declare function pairViaRelay(opts: {
|
|
71
|
+
completePairing: RelayCompletePairingHandler;
|
|
72
|
+
relayBaseUrl?: string;
|
|
73
|
+
pin?: string;
|
|
74
|
+
mode?: PairRelayMode;
|
|
75
|
+
phraseValidator?: PhraseValidator;
|
|
76
|
+
timeoutMs?: number;
|
|
77
|
+
}): Promise<RelayCompletionResult>;
|
|
78
|
+
//# sourceMappingURL=pair-remote-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pair-remote-client.d.ts","sourceRoot":"","sources":["../src/pair-remote-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,SAAS,MAAM,IAAI,CAAC;AAE3B,OAAO,EAGL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