@faable/faable 4.42.0 → 4.43.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.
package/README.md CHANGED
@@ -48,7 +48,7 @@ faable deploy status
48
48
  | `faable deploy waf` | Edge rules: `block` (403), `sink` (404 without waking the app), `list`, `rm` | [Edge rules](https://faable.com/docs/cli#edge-rules-waf) |
49
49
  | `faable auth users` | `list` (FaableQL filters), `get` (federated identities included), `suspend`, `reinstate` | [Users](https://faable.com/docs/cli#users) |
50
50
  | `faable auth actions` | Login-flow hooks: `list`, `get --code`, `create`, `update`, `rm` | [Actions](https://faable.com/docs/cli#actions) |
51
- | `faable auth clients` | OAuth clients: `list`, `get --secret`, `create`, `rm` | [OAuth clients](https://faable.com/docs/cli#oauth-clients) |
51
+ | `faable auth clients` | OAuth clients: `list`, `get --secret`, `create`, `update` (URLs, profile fields, login methods, `--signup-protection off\|on_risk\|always`), `rm` | [OAuth clients](https://faable.com/docs/cli#oauth-clients) |
52
52
  | `faable auth logs` | Audit log (read-only): `list` with filters, `get` | [Audit logs](https://faable.com/docs/cli#audit-logs) |
53
53
 
54
54
  Every command has `--help` and `--json`. `--app` takes an app id, name or slug.
@@ -125,6 +125,7 @@ faable auth users list --suspended --json | jq -r '.data[].id' | faable auth use
125
125
 
126
126
  faable auth actions create -n add-claims -t post-login -f ./claims.js
127
127
  faable auth clients create -n my-app --callback https://app.example.com/callback
128
+ faable auth clients update my-app --signup-protection always # bot check on every signup
128
129
  faable auth logs list --origin oauth --status failed --since 2026-08-01
129
130
  ```
130
131
 
@@ -3,6 +3,7 @@ import { log } from '../../../log.js';
3
3
  import { tenant_options } from '../options.js';
4
4
  import { json_option, print_json } from '../../../lib/listing.js';
5
5
  import { CLIENT_TYPES, client_type_patch, is_public_client } from './client_type.js';
6
+ import { SIGNUP_PROTECTION_HELP, SIGNUP_PROTECTION_MODES, signup_protection_patch, effective_signup_protection } from './signup_protection.js';
6
7
 
7
8
  const clients_create = {
8
9
  command: 'create',
@@ -39,6 +40,10 @@ const clients_create = {
39
40
  type: 'string',
40
41
  array: true,
41
42
  description: 'Allowed web origin (CORS) — repeatable'
43
+ })
44
+ .option('signup-protection', {
45
+ choices: SIGNUP_PROTECTION_MODES,
46
+ description: `${SIGNUP_PROTECTION_HELP}. Default: on_risk`
42
47
  })
43
48
  .example('$0 auth clients create -n my-app --callback https://app.example.com/callback', 'Create a client with one redirect URL')
44
49
  .example('$0 auth clients create -n my-spa -t spa --callback https://app.example.com/ --web-origin https://app.example.com', 'Create a single-page app (public client, no secret)')
@@ -50,7 +55,8 @@ const clients_create = {
50
55
  ...(args.description ? { description: args.description } : {}),
51
56
  ...(args.callback?.length ? { callbacks: args.callback } : {}),
52
57
  ...(args.logoutUrl?.length ? { logout_urls: args.logoutUrl } : {}),
53
- ...(args.webOrigin?.length ? { web_origins: args.webOrigin } : {})
58
+ ...(args.webOrigin?.length ? { web_origins: args.webOrigin } : {}),
59
+ ...signup_protection_patch(args.signupProtection)
54
60
  });
55
61
  const patch = client_type_patch(args.type);
56
62
  const client = patch
@@ -67,6 +73,7 @@ const clients_create = {
67
73
  }
68
74
  log.info(`✅ Created client "${client.name}" (${client.id})`);
69
75
  log.info(` Client ID: ${client.client_id}`);
76
+ log.info(` Signup protection: ${effective_signup_protection(client)}`);
70
77
  if (public_client) {
71
78
  log.info(` Type: ${args.type} — public client: PKCE, no secret (safe to ship in the app)`);
72
79
  return;
@@ -4,6 +4,7 @@ import { tenant_options } from '../options.js';
4
4
  import { json_option, print_json } from '../../../lib/listing.js';
5
5
  import { format_field } from './profile_fields.js';
6
6
  import { resolve_client } from './resolve.js';
7
+ import { effective_signup_protection } from './signup_protection.js';
7
8
 
8
9
  const clients_get = {
9
10
  command: 'get <client_id>',
@@ -42,6 +43,7 @@ const clients_get = {
42
43
  }
43
44
  const fields = client.profile_fields;
44
45
  log.info(` Fields: ${fields ? (fields.length ? fields.map(format_field).join(', ') : 'none') : 'inherited from the tenant'}`);
46
+ log.info(` Signup protection: ${effective_signup_protection(client)}`);
45
47
  log.info(` Created: ${client.createdAt ?? '-'}`);
46
48
  })
47
49
  };
@@ -3,6 +3,7 @@ import { log } from '../../../log.js';
3
3
  import { list_options, fetch_page, from_paginator, print_json, table_lines, print, more_hint } from '../../../lib/listing.js';
4
4
  import { tenant_options } from '../options.js';
5
5
  import { truncate, when } from '../render.js';
6
+ import { effective_signup_protection } from './signup_protection.js';
6
7
 
7
8
  const clients_list = {
8
9
  command: 'list',
@@ -27,9 +28,10 @@ const clients_list = {
27
28
  c.client_id ?? '-',
28
29
  truncate(c.name, 28),
29
30
  String(c.callbacks?.length ?? 0),
31
+ effective_signup_protection(c),
30
32
  when(c.createdAt)
31
33
  ]);
32
- for (const line of table_lines(['CLIENT_ID', 'NAME', 'CALLBACKS', 'CREATED'], rows)) {
34
+ for (const line of table_lines(['CLIENT_ID', 'NAME', 'CALLBACKS', 'SIGNUP_PROTECTION', 'CREATED'], rows)) {
33
35
  print(line);
34
36
  }
35
37
  const hint = more_hint(page);
@@ -0,0 +1,14 @@
1
+ // Bot protection of a client's signups and passwordless codes (auth
2
+ // SignupProtection, backlog §543). `off`: only Actions stop a signup;
3
+ // `on_risk`: a proof-of-work challenge when the request looks automated;
4
+ // `always`: every signup and OTP to a new address solves it, and client
5
+ // libraries older than @faable/auth-js 3.4.0 are refused. Clients created
6
+ // before the field existed have none, which the server reads as `off`; new
7
+ // clients are created `on_risk`.
8
+ const SIGNUP_PROTECTION_MODES = ['off', 'on_risk', 'always'];
9
+ const SIGNUP_PROTECTION_HELP = 'Bot protection for signups and email codes: off (Actions only), on_risk (proof-of-work when the request looks automated), always (every signup; auth-js < 3.4.0 is refused)';
10
+ const effective_signup_protection = (client) => client
11
+ ?.signup_protection ?? 'off';
12
+ const signup_protection_patch = (mode) => mode ? { signup_protection: mode } : {};
13
+
14
+ export { SIGNUP_PROTECTION_HELP, SIGNUP_PROTECTION_MODES, effective_signup_protection, signup_protection_patch };
@@ -5,6 +5,7 @@ import { json_option, print_json } from '../../../lib/listing.js';
5
5
  import { parse_field_spec, parse_fields_json, apply_field_changes, format_field } from './profile_fields.js';
6
6
  import { has_login_method_changes, apply_login_method_changes, effective_login_methods } from './login_methods.js';
7
7
  import { resolve_client } from './resolve.js';
8
+ import { SIGNUP_PROTECTION_HELP, SIGNUP_PROTECTION_MODES, signup_protection_patch, effective_signup_protection } from './signup_protection.js';
8
9
 
9
10
  // The update route replaces each list whole, so every list change here is a
10
11
  // read-modify-write of what the client has now: adding a callback never drops
@@ -20,7 +21,7 @@ const edit_list = (current, add = [], remove = []) => {
20
21
  };
21
22
  const clients_update = {
22
23
  command: 'update <client_id>',
23
- describe: 'Update an OAuth client (name, URLs, profile fields, login methods)',
24
+ describe: 'Update an OAuth client (name, URLs, profile fields, login methods, signup protection)',
24
25
  builder: yargs => json_option(tenant_options(yargs))
25
26
  .positional('client_id', {
26
27
  type: 'string',
@@ -107,6 +108,10 @@ const clients_update = {
107
108
  .option('inherit-login-methods', {
108
109
  type: 'boolean',
109
110
  description: "Drop this client's own login methods and follow the tenant's again"
111
+ })
112
+ .option('signup-protection', {
113
+ choices: SIGNUP_PROTECTION_MODES,
114
+ description: SIGNUP_PROTECTION_HELP
110
115
  })
111
116
  .conflicts('fields-json', ['add-field', 'remove-field', 'inherit-fields'])
112
117
  .conflicts('inherit-fields', ['add-field', 'remove-field'])
@@ -120,6 +125,7 @@ const clients_update = {
120
125
  .example('$0 auth clients update my-admin --only-connections OTP --passkey-login on', 'Sign in to my-admin only with a passkey or an email code')
121
126
  .example('$0 auth clients update my-app --add-field profile:enum:student,teacher', 'Let users of my-app pick their profile with auth-js updateProfile')
122
127
  .example('$0 auth clients update my-app --remove-field school', 'Stop accepting a field')
128
+ .example('$0 auth clients update my-app --signup-protection always', 'Make every signup of my-app solve the proof-of-work challenge')
123
129
  .example('$0 auth clients update my-app --add-callback https://app.example.com/cb', 'Allow one more redirect URL, keeping the others')
124
130
  .showHelpOnFail(false),
125
131
  handler: withAuthHints(async (args) => {
@@ -173,15 +179,19 @@ const clients_update = {
173
179
  ...(logout_urls ? { logout_urls } : {}),
174
180
  ...(web_origins ? { web_origins } : {}),
175
181
  ...(profile_fields !== undefined ? { profile_fields } : {}),
176
- ...(login_methods !== undefined ? { login_methods } : {})
182
+ ...(login_methods !== undefined ? { login_methods } : {}),
183
+ ...signup_protection_patch(args.signupProtection)
177
184
  };
178
185
  if (Object.keys(patch).length === 0) {
179
- throw new Error('Nothing to update — pass a --name, --description, an --add-*/--remove-* option, --fields-json, --inherit-fields or a login-method option');
186
+ throw new Error('Nothing to update — pass a --name, --description, an --add-*/--remove-* option, --fields-json, --inherit-fields, a login-method option or --signup-protection');
180
187
  }
181
188
  const updated = await api.clientUpdate(client.id, patch);
182
189
  if (args.json)
183
190
  return print_json(updated);
184
191
  log.info(`✅ Updated client "${updated.name}" (${updated.client_id})`);
192
+ if (args.signupProtection !== undefined) {
193
+ log.info(` Signup protection: ${effective_signup_protection(updated)}`);
194
+ }
185
195
  if (login_methods !== undefined) {
186
196
  const now = effective_login_methods(updated
187
197
  .login_methods, tenant_login, connections);
package/dist/mcp/tools.js CHANGED
@@ -803,7 +803,7 @@ const TOOLS = [
803
803
  {
804
804
  name: 'list_auth_clients',
805
805
  title: 'List Auth applications',
806
- description: 'The applications (OAuth clients) of the Auth tenant: web apps, SPAs, native apps and machine-to-machine clients.',
806
+ description: 'The applications (OAuth clients) of the Auth tenant: web apps, SPAs, native apps and machine-to-machine clients, with the signup bot protection each one applies (`signup_protection`).',
807
807
  input: { search: z.string().optional(), tenant, project },
808
808
  command: ['auth', 'clients', 'list'],
809
809
  flags: a => [...opt('-q', a.search), '--limit', '100', ...auth_scope(a)],
@@ -812,7 +812,9 @@ const TOOLS = [
812
812
  client_id: c.client_id,
813
813
  name: c.name,
814
814
  application_type: c.application_type,
815
- grant_types: c.grant_types
815
+ grant_types: c.grant_types,
816
+ // Absent on clients created before the setting existed: those are off.
817
+ signup_protection: c.signup_protection ?? 'off'
816
818
  })),
817
819
  annotations: AUTH_READ,
818
820
  example: { search: 'web', tenant: 'account_1' }
@@ -1636,6 +1638,37 @@ const TOOLS = [
1636
1638
  passkey: 'on'
1637
1639
  }
1638
1640
  },
1641
+ {
1642
+ name: 'update_auth_client_signup_protection',
1643
+ title: "Change an app's signup bot protection",
1644
+ description: "Set how one Auth application protects its signups and passwordless codes from bots: `off` relies on Actions only; `on_risk` asks for a proof-of-work challenge when the request looks automated (Tor, datacenter, odd user agent); `always` makes every signup and code to a new address solve it, and refuses client libraries older than @faable/auth-js 3.4.0 — check the app's auth-js version before choosing it. Nothing else on the app changes.",
1645
+ input: {
1646
+ client: z
1647
+ .string()
1648
+ .describe('The application: client resource id (client_…) or OAuth client_id'),
1649
+ mode: z
1650
+ .enum(['off', 'on_risk', 'always'])
1651
+ .describe('off, on_risk (new apps start here) or always'),
1652
+ tenant,
1653
+ project
1654
+ },
1655
+ command: ['auth', 'clients', 'update'],
1656
+ flags: a => [
1657
+ a.client,
1658
+ '--signup-protection',
1659
+ a.mode,
1660
+ ...auth_scope(a)
1661
+ ],
1662
+ shape: (c) => ({
1663
+ id: c.id,
1664
+ client_id: c.client_id,
1665
+ name: c.name,
1666
+ signup_protection: c.signup_protection ?? 'off'
1667
+ }),
1668
+ write: true,
1669
+ annotations: AUTH_WRITE,
1670
+ example: { client: 'client_1', mode: 'always' }
1671
+ },
1639
1672
  {
1640
1673
  name: 'send_password_setup',
1641
1674
  title: 'Send a password setup email',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faable/faable",
3
- "version": "4.42.0",
3
+ "version": "4.43.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Marc Pomar <marc@faable.com>",