@faable/faable 4.23.0 → 4.24.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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// What `--type` makes of a new client. `web` is the server-rendered app that
|
|
2
|
+
// keeps a secret; `spa` and `native` run where a secret cannot be kept, so they
|
|
3
|
+
// are public clients: PKCE, `token_endpoint_auth_method: none`, no secret. The
|
|
4
|
+
// create route takes neither field (auth ClientCreate), so the CLI sets them
|
|
5
|
+
// with an update right after creating the client.
|
|
6
|
+
const CLIENT_TYPES = ['web', 'spa', 'native'];
|
|
7
|
+
const is_public_client = (type) => type !== 'web';
|
|
8
|
+
const client_type_patch = (type) => is_public_client(type)
|
|
9
|
+
? { application_type: type, token_endpoint_auth_method: 'none' }
|
|
10
|
+
: null;
|
|
11
|
+
|
|
12
|
+
export { CLIENT_TYPES, client_type_patch, is_public_client };
|
|
@@ -2,6 +2,7 @@ import { withAuthHints, requireAuthAdmin } from '../../../api/auth_admin.js';
|
|
|
2
2
|
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
|
+
import { CLIENT_TYPES, client_type_patch, is_public_client } from './client_type.js';
|
|
5
6
|
|
|
6
7
|
const clients_create = {
|
|
7
8
|
command: 'create',
|
|
@@ -17,6 +18,12 @@ const clients_create = {
|
|
|
17
18
|
alias: 'd',
|
|
18
19
|
type: 'string',
|
|
19
20
|
description: 'Client description'
|
|
21
|
+
})
|
|
22
|
+
.option('type', {
|
|
23
|
+
alias: 't',
|
|
24
|
+
choices: CLIENT_TYPES,
|
|
25
|
+
default: 'web',
|
|
26
|
+
description: 'web: a server app that keeps a secret. spa / native: a browser or mobile app, a public client with PKCE and no secret'
|
|
20
27
|
})
|
|
21
28
|
.option('callback', {
|
|
22
29
|
type: 'string',
|
|
@@ -34,20 +41,36 @@ const clients_create = {
|
|
|
34
41
|
description: 'Allowed web origin (CORS) — repeatable'
|
|
35
42
|
})
|
|
36
43
|
.example('$0 auth clients create -n my-app --callback https://app.example.com/callback', 'Create a client with one redirect URL')
|
|
44
|
+
.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)')
|
|
37
45
|
.showHelpOnFail(false),
|
|
38
46
|
handler: withAuthHints(async (args) => {
|
|
39
47
|
const api = await requireAuthAdmin(args);
|
|
40
|
-
const
|
|
48
|
+
const created = await api.clientCreate({
|
|
41
49
|
name: args.name,
|
|
42
50
|
...(args.description ? { description: args.description } : {}),
|
|
43
51
|
...(args.callback?.length ? { callbacks: args.callback } : {}),
|
|
44
52
|
...(args.logoutUrl?.length ? { logout_urls: args.logoutUrl } : {}),
|
|
45
53
|
...(args.webOrigin?.length ? { web_origins: args.webOrigin } : {})
|
|
46
54
|
});
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
const patch = client_type_patch(args.type);
|
|
56
|
+
const client = patch
|
|
57
|
+
? { ...created, ...(await api.clientUpdate(created.id, patch)) }
|
|
58
|
+
: created;
|
|
59
|
+
const public_client = is_public_client(args.type);
|
|
60
|
+
// A public client never uses its secret: printing one would only invite
|
|
61
|
+
// someone to ship it in a bundle.
|
|
62
|
+
if (args.json) {
|
|
63
|
+
if (!public_client)
|
|
64
|
+
return print_json(client);
|
|
65
|
+
const { client_secret: _secret, ...rest } = client;
|
|
66
|
+
return print_json(rest);
|
|
67
|
+
}
|
|
49
68
|
log.info(`✅ Created client "${client.name}" (${client.id})`);
|
|
50
69
|
log.info(` Client ID: ${client.client_id}`);
|
|
70
|
+
if (public_client) {
|
|
71
|
+
log.info(` Type: ${args.type} — public client: PKCE, no secret (safe to ship in the app)`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
51
74
|
log.info(` Client secret: ${client.client_secret}`);
|
|
52
75
|
log.info(' ⚠️ Store the secret now — treat it like a password.');
|
|
53
76
|
})
|
package/dist/mcp/tools.js
CHANGED
|
@@ -1020,6 +1020,9 @@ const TOOLS = [
|
|
|
1020
1020
|
...auth_scope(a)
|
|
1021
1021
|
],
|
|
1022
1022
|
write: true,
|
|
1023
|
+
// Role writes hand permissions to end users: never on the hosted
|
|
1024
|
+
// server, whose token only reads roles (api tenant_access.ts).
|
|
1025
|
+
local_only: true,
|
|
1023
1026
|
annotations: { ...AUTH_WRITE, idempotentHint: false },
|
|
1024
1027
|
example: { name: 'support', description: 'Support staff' }
|
|
1025
1028
|
},
|
|
@@ -1047,6 +1050,9 @@ const TOOLS = [
|
|
|
1047
1050
|
...auth_scope(a)
|
|
1048
1051
|
],
|
|
1049
1052
|
write: true,
|
|
1053
|
+
// Role writes hand permissions to end users: never on the hosted
|
|
1054
|
+
// server, whose token only reads roles (api tenant_access.ts).
|
|
1055
|
+
local_only: true,
|
|
1050
1056
|
shape: (rows) => (Array.isArray(rows) ? rows : []).map((p) => ({
|
|
1051
1057
|
value: p.value,
|
|
1052
1058
|
api: p.api_identifier
|
|
@@ -1081,6 +1087,9 @@ const TOOLS = [
|
|
|
1081
1087
|
...auth_scope(a)
|
|
1082
1088
|
],
|
|
1083
1089
|
write: true,
|
|
1090
|
+
// Role writes hand permissions to end users: never on the hosted
|
|
1091
|
+
// server, whose token only reads roles (api tenant_access.ts).
|
|
1092
|
+
local_only: true,
|
|
1084
1093
|
shape: (rows) => (Array.isArray(rows) ? rows : []).map((r) => ({
|
|
1085
1094
|
id: r.id,
|
|
1086
1095
|
name: r.name
|