@aethermind/setup 0.1.0 → 0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/validate.js +16 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aethermind/setup",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI setup tool for Aethermind AgentOS — configures your project with one command",
5
5
  "bin": {
6
6
  "aethermind-setup": "./bin/setup.js"
package/src/validate.js CHANGED
@@ -4,17 +4,18 @@ const https = require('https');
4
4
  const http = require('http');
5
5
  const { ok, fail } = require('./ui.js');
6
6
 
7
+ const API_BASE = 'https://aethermind-agentos-production.up.railway.app';
8
+
7
9
  function validateApiKey(apiKey) {
8
10
  return new Promise((resolve, reject) => {
9
- const url = new URL('https://aethermind-agent-os.vercel.app/api/client/me');
11
+ const url = new URL(`${API_BASE}/v1/validate`);
10
12
  const client = url.protocol === 'https:' ? https : http;
11
13
 
12
14
  const req = client.get(
13
15
  url.href,
14
16
  {
15
17
  headers: {
16
- Authorization: `Bearer ${apiKey}`,
17
- 'Content-Type': 'application/json',
18
+ 'X-API-Key': apiKey,
18
19
  },
19
20
  },
20
21
  (res) => {
@@ -24,16 +25,23 @@ function validateApiKey(apiKey) {
24
25
  if (res.statusCode === 200) {
25
26
  try {
26
27
  const data = JSON.parse(body);
27
- const email = data.email || data.user?.email || 'usuario verificado';
28
- ok(`API key valida — conectado como ${email}`);
29
- resolve(data);
28
+ if (data.valid) {
29
+ ok(`API key valida — organizacion: ${data.organization}`);
30
+ resolve(data);
31
+ } else {
32
+ fail('API key invalida');
33
+ reject(new Error('API key invalida. Verifica tu AETHERMIND_API_KEY.'));
34
+ }
30
35
  } catch (_) {
31
36
  ok('API key valida');
32
37
  resolve({});
33
38
  }
39
+ } else if (res.statusCode === 401 || res.statusCode === 403) {
40
+ fail('API key invalida o inactiva');
41
+ reject(new Error('API key invalida. Verifica tu AETHERMIND_API_KEY.'));
34
42
  } else {
35
- fail(`API key invalida (HTTP ${res.statusCode})`);
36
- reject(new Error(`API key invalida. Verifica tu AETHERMIND_API_KEY.`));
43
+ fail(`Error validando API key (HTTP ${res.statusCode})`);
44
+ reject(new Error(`Error del servidor (HTTP ${res.statusCode}). Intenta de nuevo.`));
37
45
  }
38
46
  });
39
47
  }