agentgate-mcp 0.2.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/ARCHITECTURE.md +56 -0
- package/MCP_TOOLS.md +45 -0
- package/README.md +142 -0
- package/package.json +51 -0
- package/services/_template.service.json +34 -0
- package/src/browser-runtime.js +411 -0
- package/src/cli.js +117 -0
- package/src/config.js +49 -0
- package/src/db.js +89 -0
- package/src/integrations/captcha-solver.js +128 -0
- package/src/integrations/gmail-watcher.js +129 -0
- package/src/logger.js +120 -0
- package/src/mcp-server.js +204 -0
- package/src/orchestrator.js +107 -0
- package/src/playwright-engine.js +391 -0
- package/src/registry.js +47 -0
- package/src/scaffold.js +103 -0
- package/src/setup.js +109 -0
- package/src/signup-engine.js +24 -0
- package/src/vault.js +105 -0
package/src/vault.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
|
|
4
|
+
const ALGO = 'aes-256-gcm';
|
|
5
|
+
|
|
6
|
+
export class Vault {
|
|
7
|
+
constructor({ vaultFile, keyringFile }) {
|
|
8
|
+
this.vaultFile = vaultFile;
|
|
9
|
+
this.keyringFile = keyringFile;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
initialize() {
|
|
13
|
+
if (!fs.existsSync(this.keyringFile)) {
|
|
14
|
+
const masterKey = crypto.randomBytes(32).toString('base64');
|
|
15
|
+
fs.writeFileSync(this.keyringFile, JSON.stringify({ masterKey }, null, 2), {
|
|
16
|
+
mode: 0o600
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!fs.existsSync(this.vaultFile)) {
|
|
21
|
+
this.writePayload({
|
|
22
|
+
google: {
|
|
23
|
+
email: null,
|
|
24
|
+
cookies: null,
|
|
25
|
+
gmailOAuthToken: null
|
|
26
|
+
},
|
|
27
|
+
billing: {
|
|
28
|
+
cardHolder: null,
|
|
29
|
+
cardNumber: null,
|
|
30
|
+
cardLast4: null,
|
|
31
|
+
cardExpMonth: null,
|
|
32
|
+
cardExpYear: null,
|
|
33
|
+
cardCvc: null,
|
|
34
|
+
cardZip: null
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
fs.chmodSync(this.vaultFile, 0o600);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getPayload() {
|
|
42
|
+
return this.readPayload();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setGoogleAccount({ email, cookies, gmailOAuthToken }) {
|
|
46
|
+
const payload = this.readPayload();
|
|
47
|
+
payload.google = { email, cookies, gmailOAuthToken };
|
|
48
|
+
this.writePayload(payload);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setBilling(billingPatch) {
|
|
52
|
+
const payload = this.readPayload();
|
|
53
|
+
payload.billing = {
|
|
54
|
+
...payload.billing,
|
|
55
|
+
...billingPatch
|
|
56
|
+
};
|
|
57
|
+
this.writePayload(payload);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
readPayload() {
|
|
61
|
+
const encrypted = JSON.parse(fs.readFileSync(this.vaultFile, 'utf8'));
|
|
62
|
+
const key = this.getMasterKey();
|
|
63
|
+
const iv = Buffer.from(encrypted.iv, 'base64');
|
|
64
|
+
const authTag = Buffer.from(encrypted.authTag, 'base64');
|
|
65
|
+
const ciphertext = Buffer.from(encrypted.ciphertext, 'base64');
|
|
66
|
+
|
|
67
|
+
const decipher = crypto.createDecipheriv(ALGO, key, iv);
|
|
68
|
+
decipher.setAuthTag(authTag);
|
|
69
|
+
|
|
70
|
+
const plaintext = Buffer.concat([
|
|
71
|
+
decipher.update(ciphertext),
|
|
72
|
+
decipher.final()
|
|
73
|
+
]).toString('utf8');
|
|
74
|
+
|
|
75
|
+
return JSON.parse(plaintext);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
writePayload(payload) {
|
|
79
|
+
const key = this.getMasterKey();
|
|
80
|
+
const iv = crypto.randomBytes(12);
|
|
81
|
+
const cipher = crypto.createCipheriv(ALGO, key, iv);
|
|
82
|
+
|
|
83
|
+
const ciphertext = Buffer.concat([
|
|
84
|
+
cipher.update(JSON.stringify(payload), 'utf8'),
|
|
85
|
+
cipher.final()
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
const authTag = cipher.getAuthTag();
|
|
89
|
+
const output = {
|
|
90
|
+
iv: iv.toString('base64'),
|
|
91
|
+
authTag: authTag.toString('base64'),
|
|
92
|
+
ciphertext: ciphertext.toString('base64')
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
fs.writeFileSync(this.vaultFile, JSON.stringify(output, null, 2), {
|
|
96
|
+
mode: 0o600
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
getMasterKey() {
|
|
101
|
+
const raw = fs.readFileSync(this.keyringFile, 'utf8');
|
|
102
|
+
const parsed = JSON.parse(raw);
|
|
103
|
+
return Buffer.from(parsed.masterKey, 'base64');
|
|
104
|
+
}
|
|
105
|
+
}
|