@tpsdev-ai/flair 0.3.8 → 0.3.9

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/dist/cli.js +25 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -60,12 +60,36 @@ async function api(method, path, body) {
60
60
  }
61
61
  catch { /* ignore config read errors */ }
62
62
  const base = process.env.FLAIR_URL || defaultUrl;
63
+ // Auth resolution order:
64
+ // 1. FLAIR_TOKEN env → Bearer token (backward compat)
65
+ // 2. FLAIR_AGENT_ID env + key file → Ed25519 signature (standard)
66
+ // 3. --agent flag extracted from body.agentId + key file → Ed25519 signature
67
+ // 4. No auth (will 401 on any authenticated endpoint)
68
+ let authHeader;
63
69
  const token = process.env.FLAIR_TOKEN;
70
+ if (token) {
71
+ authHeader = `Bearer ${token}`;
72
+ }
73
+ else {
74
+ const agentId = process.env.FLAIR_AGENT_ID || (body && typeof body === "object" ? body.agentId : undefined);
75
+ if (agentId) {
76
+ const keyPath = resolveKeyPath(agentId);
77
+ if (keyPath) {
78
+ try {
79
+ authHeader = buildEd25519Auth(agentId, method, path, keyPath);
80
+ }
81
+ catch (err) {
82
+ // Key exists but auth build failed — warn and continue without auth
83
+ console.error(`Warning: Ed25519 auth failed for agent '${agentId}': ${err.message}`);
84
+ }
85
+ }
86
+ }
87
+ }
64
88
  const res = await fetch(`${base}${path}`, {
65
89
  method,
66
90
  headers: {
67
91
  "content-type": "application/json",
68
- ...(token ? { authorization: `Bearer ${token}` } : {}),
92
+ ...(authHeader ? { authorization: authHeader } : {}),
69
93
  },
70
94
  body: body ? JSON.stringify(body) : undefined,
71
95
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpsdev-ai/flair",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Identity, memory, and soul for AI agents. Cryptographic identity (Ed25519), semantic memory with local embeddings, and persistent personality — all in a single process.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",