@faable/faable 4.38.0 → 4.39.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.
@@ -1,7 +1,7 @@
1
1
  import { withAuthHints, requireAuthAdmin } from '../../../api/auth_admin.js';
2
+ import { json_option, fetch_page, from_paginator, print_json } from '../../../lib/listing.js';
2
3
  import { log } from '../../../log.js';
3
4
  import { tenant_options } from '../options.js';
4
- import { json_option, fetch_page, from_paginator, print_json } from '../../../lib/listing.js';
5
5
  import { yes_no, when } from '../render.js';
6
6
  import { resolve_user_ref } from './resolve.js';
7
7
 
@@ -11,6 +11,20 @@ const sanitize_identity = (i) => {
11
11
  const { access_token: _a, access_token_secret: _s, refresh_token: _r, ...safe } = i;
12
12
  return safe;
13
13
  };
14
+ // An expanded `connection` ({ id, connection_name, … }) — or a bare id when
15
+ // the server did not expand it — as the id plus a readable name.
16
+ const connection_ref = (c) => {
17
+ if (c && typeof c === 'object') {
18
+ const o = c;
19
+ const id = String(o.id ?? '');
20
+ return {
21
+ connection: id,
22
+ connection_name: o.connection_name ?? o.connection_type ?? id
23
+ };
24
+ }
25
+ const id = String(c ?? '');
26
+ return { connection: id, connection_name: id };
27
+ };
14
28
  const users_get = {
15
29
  command: 'get <user_id>',
16
30
  describe: 'Show a user (by id or email), their federated identities and their database login identifiers',
@@ -28,42 +42,32 @@ const users_get = {
28
42
  // Federated identities (GitHub, Google…): who this user IS at the
29
43
  // provider — the piece the abuse playbook keeps needing (a Faable email
30
44
  // rarely matches the GitHub handle that owns the deployed repos).
45
+ // `expand=connection` brings the connection's name in the same call.
31
46
  // Best-effort: a tenant where the session can't read /identity still
32
47
  // renders the user card.
33
- const identities = await fetch_page(from_paginator(api.identityList({ query: `user:${user_id}` })), { limit: 200, all: true })
34
- .then(r => r.data.map(i => sanitize_identity(i)))
48
+ const identities = await fetch_page(from_paginator(api.identityList({ query: `user:${user_id}`, expand: ['connection'] })), { limit: 200, all: true })
49
+ .then(r => r.data.map(i => {
50
+ const safe = sanitize_identity(i);
51
+ return {
52
+ ...safe,
53
+ ...connection_ref(safe.connection)
54
+ };
55
+ }))
35
56
  .catch(() => []);
36
57
  // Database-connection credentials: the email/username the user actually
37
58
  // TYPES to log in. Distinct from `user.email` (the profile email), which
38
59
  // is NOT what the password login matches — the gap that otherwise sends
39
60
  // you to the dashboard to find out why a login keeps failing. Best-effort.
40
- const credentials = await fetch_page(from_paginator(api.credentialsList({ user: user_id })), { limit: 200, all: true })
61
+ const credentials = await fetch_page(from_paginator(api.credentialsList({ user: user_id, expand: ['connection'] })), { limit: 200, all: true })
41
62
  .then(r => r.data.map(c => ({
42
63
  id: String(c.id ?? ''),
43
- connection: String(c.connection ?? ''),
64
+ ...connection_ref(c.connection),
44
65
  email: c.email,
45
66
  username: c.username
46
67
  })))
47
68
  .catch(() => []);
48
- // Resolve connection ids to names ("github", "default") once per distinct
49
- // id — identities and credentials alike.
50
- const connection_names = new Map();
51
- for (const id of new Set([
52
- ...identities.map(i => String(i.connection ?? '')),
53
- ...credentials.map(c => c.connection)
54
- ].filter(Boolean))) {
55
- const conn = (await api.connectionGet(id).catch(() => null));
56
- connection_names.set(id, conn?.connection_name ?? conn?.connection_type ?? id);
57
- }
58
69
  if (args.json)
59
- return print_json({
60
- ...user,
61
- identities,
62
- credentials: credentials.map(c => ({
63
- ...c,
64
- connection_name: connection_names.get(c.connection) ?? c.connection
65
- }))
66
- });
70
+ return print_json({ ...user, identities, credentials });
67
71
  log.info(`👤 ${user.id}`);
68
72
  log.info(` Email: ${user.email ?? '-'} (verified: ${yes_no(user.email_verified)})`);
69
73
  log.info(` Name: ${user.name ?? '-'}`);
@@ -72,7 +76,7 @@ const users_get = {
72
76
  // profile email above, in which case that mismatch is the bug.
73
77
  const ids = credentials
74
78
  .map(c => {
75
- const conn = connection_names.get(c.connection) ?? (c.connection || 'default');
79
+ const conn = c.connection_name || 'default';
76
80
  return `${c.email ?? c.username ?? '-'} (${conn})`;
77
81
  })
78
82
  .join(', ');
@@ -96,7 +100,7 @@ const users_get = {
96
100
  if (identities.length > 0) {
97
101
  log.info(` Identities:`);
98
102
  for (const identity of identities) {
99
- const conn = connection_names.get(String(identity.connection ?? '')) ?? '-';
103
+ const conn = String(identity.connection_name ?? '-');
100
104
  const pd = (identity.profile_data ?? {});
101
105
  const bits = [
102
106
  pd.login ?? String(identity.identity_id ?? '-'),
@@ -104,7 +108,9 @@ const users_get = {
104
108
  // Provider-account age is triage gold: a repo pushed from a
105
109
  // years-old GitHub account reads differently than one created
106
110
  // this morning.
107
- pd.created_at ? `account since ${String(pd.created_at).slice(0, 10)}` : undefined,
111
+ pd.created_at
112
+ ? `account since ${String(pd.created_at).slice(0, 10)}`
113
+ : undefined,
108
114
  pd.email && pd.email !== user.email ? `email ${pd.email}` : undefined,
109
115
  pd.location ? `location ${pd.location}` : undefined
110
116
  ].filter(Boolean);
package/dist/mcp/tools.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { version } from '../config.js';
2
3
 
3
4
  const project = z
4
5
  .string()
@@ -186,10 +187,11 @@ const TOOLS = [
186
187
  {
187
188
  name: 'whoami',
188
189
  title: 'Who is logged in',
189
- description: 'The Faable account this server acts as, the active project and its Auth tenant. Use it first when unsure whether the user is logged in or which project is active.',
190
+ description: 'The Faable account this server acts as, the active project and its Auth tenant, and `server_version` — the Faable CLI version this MCP server runs. Use it first when unsure whether the user is logged in or which project is active, or to check which version is serving.',
190
191
  input: {},
191
192
  command: ['whoami'],
192
193
  flags: () => [],
194
+ shape: (d) => ({ ...d, server_version: version }),
193
195
  annotations: READ,
194
196
  example: {}
195
197
  },
@@ -627,9 +629,15 @@ const TOOLS = [
627
629
  ...user_row(u),
628
630
  phone: u.phone,
629
631
  last_ip: u.last_ip,
632
+ // `auth users get --json` rows: { connection, connection_name,
633
+ // identity_id, profile_data } — the provider account behind the user.
630
634
  identities: (u.identities ?? []).map((i) => ({
631
- provider: i.provider ?? i.connection_type,
632
- user_id: i.user_id ?? i.provider_user_id
635
+ connection: i.connection_name ?? i.connection,
636
+ identity_id: i.identity_id,
637
+ login: i.profile_data?.login,
638
+ profile_url: i.profile_data?.html_url,
639
+ account_created_at: i.profile_data?.created_at,
640
+ provider_email: i.profile_data?.email
633
641
  })),
634
642
  credentials: (u.credentials ?? []).map((c) => ({
635
643
  connection: c.connection_name ?? c.connection,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faable/faable",
3
- "version": "4.38.0",
3
+ "version": "4.39.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Marc Pomar <marc@faable.com>",