securegate-cli-tool 2.0.4 → 2.1.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/package.json +5 -4
- package/scripts/postinstall.js +37 -37
- package/src/api.js +213 -205
- package/src/commands/connect.js +102 -102
- package/src/commands/keys.js +280 -232
- package/src/commands/login.js +191 -60
- package/src/commands/providers.js +51 -51
- package/src/commands/status.js +78 -78
- package/src/config.js +85 -82
- package/src/index.js +165 -187
- package/templates/SKILL.md +59 -62
- package/templates/AGENTCONNECT.md +0 -66
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securegate-cli-tool",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "SecureGate CLI — Secure your AI agent API keys from the terminal",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"ai-agent",
|
|
19
19
|
"security-key",
|
|
20
20
|
"device-lock",
|
|
21
|
-
"mcp",
|
|
22
21
|
"cli"
|
|
23
22
|
],
|
|
24
23
|
"author": "SecureGate",
|
|
@@ -27,9 +26,11 @@
|
|
|
27
26
|
"node": ">=16"
|
|
28
27
|
},
|
|
29
28
|
"dependencies": {
|
|
29
|
+
"@supabase/supabase-js": "^2.97.0",
|
|
30
|
+
"chalk": "^4.1.2",
|
|
30
31
|
"commander": "^12.1.0",
|
|
31
32
|
"inquirer": "^8.2.6",
|
|
32
|
-
"
|
|
33
|
+
"open": "^11.0.0",
|
|
33
34
|
"ora": "^5.4.1"
|
|
34
35
|
}
|
|
35
|
-
}
|
|
36
|
+
}
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
const homeDir = os.homedir();
|
|
9
|
-
const openClawPath = path.join(homeDir, '.openclaw');
|
|
10
|
-
const skillsDir = path.join(openClawPath, 'skills');
|
|
11
|
-
const targetDir = path.join(skillsDir, 'securegate');
|
|
12
|
-
const templatePath = path.join(__dirname, '../templates/SKILL.md');
|
|
13
|
-
|
|
14
|
-
// Only proceed if .openclaw config directory exists (implies usage)
|
|
15
|
-
// Or if the user wants to force it? No, auto-detect is safer.
|
|
16
|
-
if (fs.existsSync(openClawPath)) {
|
|
17
|
-
console.log('OpenClaw detected. Installing SecureGate skill...');
|
|
18
|
-
|
|
19
|
-
// Ensure directories exist
|
|
20
|
-
if (!fs.existsSync(skillsDir)) {
|
|
21
|
-
fs.mkdirSync(skillsDir, { recursive: true });
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (!fs.existsSync(targetDir)) {
|
|
25
|
-
fs.mkdirSync(targetDir, { recursive: true });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Copy skill file
|
|
29
|
-
fs.copyFileSync(templatePath, path.join(targetDir, 'SKILL.md'));
|
|
30
|
-
|
|
31
|
-
console.log('✅ SecureGate skill installed to ~/.openclaw/skills/securegate/SKILL.md');
|
|
32
|
-
}
|
|
33
|
-
} catch (error) {
|
|
34
|
-
// Silently fail or log warning - we don't want to break the install just for this
|
|
35
|
-
console.warn('Note: Could not auto-install OpenClaw skill (optional step).');
|
|
36
|
-
// console.warn(error.message);
|
|
37
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const homeDir = os.homedir();
|
|
9
|
+
const openClawPath = path.join(homeDir, '.openclaw');
|
|
10
|
+
const skillsDir = path.join(openClawPath, 'skills');
|
|
11
|
+
const targetDir = path.join(skillsDir, 'securegate');
|
|
12
|
+
const templatePath = path.join(__dirname, '../templates/SKILL.md');
|
|
13
|
+
|
|
14
|
+
// Only proceed if .openclaw config directory exists (implies usage)
|
|
15
|
+
// Or if the user wants to force it? No, auto-detect is safer.
|
|
16
|
+
if (fs.existsSync(openClawPath)) {
|
|
17
|
+
console.log('OpenClaw detected. Installing SecureGate skill...');
|
|
18
|
+
|
|
19
|
+
// Ensure directories exist
|
|
20
|
+
if (!fs.existsSync(skillsDir)) {
|
|
21
|
+
fs.mkdirSync(skillsDir, { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!fs.existsSync(targetDir)) {
|
|
25
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Copy skill file
|
|
29
|
+
fs.copyFileSync(templatePath, path.join(targetDir, 'SKILL.md'));
|
|
30
|
+
|
|
31
|
+
console.log('✅ SecureGate skill installed to ~/.openclaw/skills/securegate/SKILL.md');
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
// Silently fail or log warning - we don't want to break the install just for this
|
|
35
|
+
console.warn('Note: Could not auto-install OpenClaw skill (optional step).');
|
|
36
|
+
// console.warn(error.message);
|
|
37
|
+
}
|
package/src/api.js
CHANGED
|
@@ -1,205 +1,213 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SecureGate CLI — API Client
|
|
3
|
-
* Wraps all Supabase Edge Function calls
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const https = require('https');
|
|
7
|
-
const http = require('http');
|
|
8
|
-
const { SUPABASE_URL, SUPABASE_ANON_KEY, getAuth, setAuth } = require('./config');
|
|
9
|
-
|
|
10
|
-
// ── HTTP Helper ──────────────────────────────────────────────────────────────
|
|
11
|
-
|
|
12
|
-
function httpRequest(url, options = {}) {
|
|
13
|
-
return new Promise((resolve, reject) => {
|
|
14
|
-
const urlObj = new URL(url);
|
|
15
|
-
const lib = urlObj.protocol === 'https:' ? https : http;
|
|
16
|
-
|
|
17
|
-
const req = lib.request(url, {
|
|
18
|
-
method: options.method || 'GET',
|
|
19
|
-
headers: options.headers || {},
|
|
20
|
-
}, (res) => {
|
|
21
|
-
let data = '';
|
|
22
|
-
res.on('data', chunk => data += chunk);
|
|
23
|
-
res.on('end', () => {
|
|
24
|
-
try {
|
|
25
|
-
resolve({ status: res.statusCode, data: JSON.parse(data) });
|
|
26
|
-
} catch {
|
|
27
|
-
resolve({ status: res.statusCode, data });
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
req.on('error', reject);
|
|
33
|
-
if (options.body) req.write(options.body);
|
|
34
|
-
req.end();
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ── Auth Helpers ─────────────────────────────────────────────────────────────
|
|
39
|
-
|
|
40
|
-
async function login(email, password) {
|
|
41
|
-
const res = await httpRequest(`${SUPABASE_URL}/auth/v1/token?grant_type=password`, {
|
|
42
|
-
method: 'POST',
|
|
43
|
-
headers: {
|
|
44
|
-
'Content-Type': 'application/json',
|
|
45
|
-
'apikey': SUPABASE_ANON_KEY,
|
|
46
|
-
},
|
|
47
|
-
body: JSON.stringify({ email, password }),
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
if (res.status !== 200) {
|
|
51
|
-
throw new Error(res.data?.error_description || res.data?.msg || 'Login failed');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
setAuth({
|
|
55
|
-
access_token: res.data.access_token,
|
|
56
|
-
refresh_token: res.data.refresh_token,
|
|
57
|
-
user: {
|
|
58
|
-
id: res.data.user?.id,
|
|
59
|
-
email: res.data.user?.email,
|
|
60
|
-
},
|
|
61
|
-
expires_at: Date.now() + (res.data.expires_in * 1000),
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
return res.data;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async function refreshToken() {
|
|
68
|
-
const auth = getAuth();
|
|
69
|
-
if (!auth?.refresh_token) throw new Error('Not logged in. Run: securegate login');
|
|
70
|
-
|
|
71
|
-
const res = await httpRequest(`${SUPABASE_URL}/auth/v1/token?grant_type=refresh_token`, {
|
|
72
|
-
method: 'POST',
|
|
73
|
-
headers: {
|
|
74
|
-
'Content-Type': 'application/json',
|
|
75
|
-
'apikey': SUPABASE_ANON_KEY,
|
|
76
|
-
},
|
|
77
|
-
body: JSON.stringify({ refresh_token: auth.refresh_token }),
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
if (res.status !== 200) {
|
|
81
|
-
throw new Error('Session expired. Please run: securegate login');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
setAuth({
|
|
85
|
-
access_token: res.data.access_token,
|
|
86
|
-
refresh_token: res.data.refresh_token,
|
|
87
|
-
user: auth.user,
|
|
88
|
-
expires_at: Date.now() + (res.data.expires_in * 1000),
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
return res.data.access_token;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function getValidToken() {
|
|
95
|
-
const auth = getAuth();
|
|
96
|
-
if (!auth) throw new Error('Not logged in. Run: securegate login');
|
|
97
|
-
|
|
98
|
-
// Refresh if expires within 5 minutes
|
|
99
|
-
if (auth.expires_at && (Date.now() > auth.expires_at - 300000)) {
|
|
100
|
-
return await refreshToken();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return auth.access_token;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// ── Edge Function Wrappers ───────────────────────────────────────────────────
|
|
107
|
-
|
|
108
|
-
async function authedRequest(functionName, body = null, method = 'POST') {
|
|
109
|
-
const token = await getValidToken();
|
|
110
|
-
|
|
111
|
-
const options = {
|
|
112
|
-
method,
|
|
113
|
-
headers: {
|
|
114
|
-
'Authorization': `Bearer ${token}`,
|
|
115
|
-
'Content-Type': 'application/json',
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
if (body) options.body = JSON.stringify(body);
|
|
120
|
-
|
|
121
|
-
const res = await httpRequest(`${SUPABASE_URL}/functions/v1/${functionName}`, options);
|
|
122
|
-
|
|
123
|
-
if (res.status === 403) {
|
|
124
|
-
throw new Error('Unauthorized. Your session may have expired. Run: securegate login');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return res;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async function listConnections() {
|
|
131
|
-
return authedRequest('list-connections', null, 'GET');
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async function getConnection(connectionId) {
|
|
135
|
-
return authedRequest(`get-connection?connection_id=${connectionId}`, null, 'GET');
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async function createConnection({ provider, apiKey, customName, baseUrl }) {
|
|
139
|
-
return authedRequest('create-connection', {
|
|
140
|
-
provider,
|
|
141
|
-
api_key: apiKey,
|
|
142
|
-
custom_name: customName,
|
|
143
|
-
base_url: baseUrl,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async function generateKey(connectionId, label) {
|
|
148
|
-
const os = require('os');
|
|
149
|
-
const crypto = require('crypto');
|
|
150
|
-
|
|
151
|
-
// Generate device fingerprint
|
|
152
|
-
const networkInterfaces = os.networkInterfaces();
|
|
153
|
-
let mac = '';
|
|
154
|
-
for (const [, interfaces] of Object.entries(networkInterfaces)) {
|
|
155
|
-
for (const iface of interfaces) {
|
|
156
|
-
if (iface.mac && iface.mac !== '00:00:00:00:00:00') {
|
|
157
|
-
mac = iface.mac;
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (mac) break;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const fingerprint = [
|
|
165
|
-
os.hostname(), os.platform(), os.arch(),
|
|
166
|
-
os.cpus()[0]?.model || 'unknown', mac,
|
|
167
|
-
os.totalmem().toString(),
|
|
168
|
-
].join('|');
|
|
169
|
-
|
|
170
|
-
const deviceFingerprint = crypto.createHash('sha256').update(fingerprint).digest('hex').substring(0, 32);
|
|
171
|
-
|
|
172
|
-
return authedRequest('generate-key', {
|
|
173
|
-
connection_id: connectionId,
|
|
174
|
-
device_fingerprint: deviceFingerprint,
|
|
175
|
-
label: label || `${os.hostname()} (${os.platform()})`,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
async function deleteKey(keyId) {
|
|
180
|
-
return authedRequest('delete-key', { key_id: keyId });
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
async function lockKey(keyId, ip) {
|
|
184
|
-
return authedRequest('update-key', {
|
|
185
|
-
key_id: keyId,
|
|
186
|
-
update_data: { bound_ip: ip }
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
async function
|
|
191
|
-
return authedRequest('
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
1
|
+
/**
|
|
2
|
+
* SecureGate CLI — API Client
|
|
3
|
+
* Wraps all Supabase Edge Function calls
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const https = require('https');
|
|
7
|
+
const http = require('http');
|
|
8
|
+
const { SUPABASE_URL, SUPABASE_ANON_KEY, getAuth, setAuth } = require('./config');
|
|
9
|
+
|
|
10
|
+
// ── HTTP Helper ──────────────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
function httpRequest(url, options = {}) {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const urlObj = new URL(url);
|
|
15
|
+
const lib = urlObj.protocol === 'https:' ? https : http;
|
|
16
|
+
|
|
17
|
+
const req = lib.request(url, {
|
|
18
|
+
method: options.method || 'GET',
|
|
19
|
+
headers: options.headers || {},
|
|
20
|
+
}, (res) => {
|
|
21
|
+
let data = '';
|
|
22
|
+
res.on('data', chunk => data += chunk);
|
|
23
|
+
res.on('end', () => {
|
|
24
|
+
try {
|
|
25
|
+
resolve({ status: res.statusCode, data: JSON.parse(data) });
|
|
26
|
+
} catch {
|
|
27
|
+
resolve({ status: res.statusCode, data });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
req.on('error', reject);
|
|
33
|
+
if (options.body) req.write(options.body);
|
|
34
|
+
req.end();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ── Auth Helpers ─────────────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
async function login(email, password) {
|
|
41
|
+
const res = await httpRequest(`${SUPABASE_URL}/auth/v1/token?grant_type=password`, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
'apikey': SUPABASE_ANON_KEY,
|
|
46
|
+
},
|
|
47
|
+
body: JSON.stringify({ email, password }),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (res.status !== 200) {
|
|
51
|
+
throw new Error(res.data?.error_description || res.data?.msg || 'Login failed');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setAuth({
|
|
55
|
+
access_token: res.data.access_token,
|
|
56
|
+
refresh_token: res.data.refresh_token,
|
|
57
|
+
user: {
|
|
58
|
+
id: res.data.user?.id,
|
|
59
|
+
email: res.data.user?.email,
|
|
60
|
+
},
|
|
61
|
+
expires_at: Date.now() + (res.data.expires_in * 1000),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return res.data;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function refreshToken() {
|
|
68
|
+
const auth = getAuth();
|
|
69
|
+
if (!auth?.refresh_token) throw new Error('Not logged in. Run: securegate login');
|
|
70
|
+
|
|
71
|
+
const res = await httpRequest(`${SUPABASE_URL}/auth/v1/token?grant_type=refresh_token`, {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: {
|
|
74
|
+
'Content-Type': 'application/json',
|
|
75
|
+
'apikey': SUPABASE_ANON_KEY,
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify({ refresh_token: auth.refresh_token }),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (res.status !== 200) {
|
|
81
|
+
throw new Error('Session expired. Please run: securegate login');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setAuth({
|
|
85
|
+
access_token: res.data.access_token,
|
|
86
|
+
refresh_token: res.data.refresh_token,
|
|
87
|
+
user: auth.user,
|
|
88
|
+
expires_at: Date.now() + (res.data.expires_in * 1000),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return res.data.access_token;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function getValidToken() {
|
|
95
|
+
const auth = getAuth();
|
|
96
|
+
if (!auth) throw new Error('Not logged in. Run: securegate login');
|
|
97
|
+
|
|
98
|
+
// Refresh if expires within 5 minutes
|
|
99
|
+
if (auth.expires_at && (Date.now() > auth.expires_at - 300000)) {
|
|
100
|
+
return await refreshToken();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return auth.access_token;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ── Edge Function Wrappers ───────────────────────────────────────────────────
|
|
107
|
+
|
|
108
|
+
async function authedRequest(functionName, body = null, method = 'POST') {
|
|
109
|
+
const token = await getValidToken();
|
|
110
|
+
|
|
111
|
+
const options = {
|
|
112
|
+
method,
|
|
113
|
+
headers: {
|
|
114
|
+
'Authorization': `Bearer ${token}`,
|
|
115
|
+
'Content-Type': 'application/json',
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
if (body) options.body = JSON.stringify(body);
|
|
120
|
+
|
|
121
|
+
const res = await httpRequest(`${SUPABASE_URL}/functions/v1/${functionName}`, options);
|
|
122
|
+
|
|
123
|
+
if (res.status === 403) {
|
|
124
|
+
throw new Error('Unauthorized. Your session may have expired. Run: securegate login');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return res;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function listConnections() {
|
|
131
|
+
return authedRequest('list-connections', null, 'GET');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function getConnection(connectionId) {
|
|
135
|
+
return authedRequest(`get-connection?connection_id=${connectionId}`, null, 'GET');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function createConnection({ provider, apiKey, customName, baseUrl }) {
|
|
139
|
+
return authedRequest('create-connection', {
|
|
140
|
+
provider,
|
|
141
|
+
api_key: apiKey,
|
|
142
|
+
custom_name: customName,
|
|
143
|
+
base_url: baseUrl,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function generateKey(connectionId, label) {
|
|
148
|
+
const os = require('os');
|
|
149
|
+
const crypto = require('crypto');
|
|
150
|
+
|
|
151
|
+
// Generate device fingerprint
|
|
152
|
+
const networkInterfaces = os.networkInterfaces();
|
|
153
|
+
let mac = '';
|
|
154
|
+
for (const [, interfaces] of Object.entries(networkInterfaces)) {
|
|
155
|
+
for (const iface of interfaces) {
|
|
156
|
+
if (iface.mac && iface.mac !== '00:00:00:00:00:00') {
|
|
157
|
+
mac = iface.mac;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (mac) break;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const fingerprint = [
|
|
165
|
+
os.hostname(), os.platform(), os.arch(),
|
|
166
|
+
os.cpus()[0]?.model || 'unknown', mac,
|
|
167
|
+
os.totalmem().toString(),
|
|
168
|
+
].join('|');
|
|
169
|
+
|
|
170
|
+
const deviceFingerprint = crypto.createHash('sha256').update(fingerprint).digest('hex').substring(0, 32);
|
|
171
|
+
|
|
172
|
+
return authedRequest('generate-key', {
|
|
173
|
+
connection_id: connectionId,
|
|
174
|
+
device_fingerprint: deviceFingerprint,
|
|
175
|
+
label: label || `${os.hostname()} (${os.platform()})`,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function deleteKey(keyId) {
|
|
180
|
+
return authedRequest('delete-key', { key_id: keyId });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function lockKey(keyId, ip) {
|
|
184
|
+
return authedRequest('update-key', {
|
|
185
|
+
key_id: keyId,
|
|
186
|
+
update_data: { bound_ip: ip }
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async function updateKey(keyId, updateData) {
|
|
191
|
+
return authedRequest('update-key', {
|
|
192
|
+
key_id: keyId,
|
|
193
|
+
update_data: updateData
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async function getProfile() {
|
|
198
|
+
return authedRequest('get-profile', null, 'GET');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
module.exports = {
|
|
202
|
+
login,
|
|
203
|
+
refreshToken,
|
|
204
|
+
getValidToken,
|
|
205
|
+
listConnections,
|
|
206
|
+
getConnection,
|
|
207
|
+
createConnection,
|
|
208
|
+
generateKey,
|
|
209
|
+
deleteKey,
|
|
210
|
+
lockKey,
|
|
211
|
+
updateKey,
|
|
212
|
+
getProfile,
|
|
213
|
+
};
|