@faable/faable 4.38.0 → 4.38.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.
@@ -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
@@ -627,9 +627,15 @@ const TOOLS = [
627
627
  ...user_row(u),
628
628
  phone: u.phone,
629
629
  last_ip: u.last_ip,
630
+ // `auth users get --json` rows: { connection, connection_name,
631
+ // identity_id, profile_data } — the provider account behind the user.
630
632
  identities: (u.identities ?? []).map((i) => ({
631
- provider: i.provider ?? i.connection_type,
632
- user_id: i.user_id ?? i.provider_user_id
633
+ connection: i.connection_name ?? i.connection,
634
+ identity_id: i.identity_id,
635
+ login: i.profile_data?.login,
636
+ profile_url: i.profile_data?.html_url,
637
+ account_created_at: i.profile_data?.created_at,
638
+ provider_email: i.profile_data?.email
633
639
  })),
634
640
  credentials: (u.credentials ?? []).map((c) => ({
635
641
  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.38.1",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Marc Pomar <marc@faable.com>",