@faable/faable 4.15.0 → 4.17.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/LICENSE +21 -0
- package/dist/api/FaableApi.js +8 -2
- package/dist/commands/deploy/waf/add_rule.js +15 -0
- package/dist/commands/deploy/waf/allow.js +58 -0
- package/dist/commands/deploy/waf/format.js +3 -1
- package/dist/commands/deploy/waf/index.js +3 -1
- package/dist/commands/deploy/waf/rm.js +1 -1
- package/dist/mcp/http.js +9 -0
- package/dist/mcp/tools.js +5 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Faable Cloud SLU
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/api/FaableApi.js
CHANGED
|
@@ -95,7 +95,9 @@ class FaableApi {
|
|
|
95
95
|
? 'This Faable API key is invalid or was revoked. Create a new one in the dashboard (project settings → API Keys).'
|
|
96
96
|
: 'Your Faable session has expired or is invalid. Run `faable login` to sign in again.', { cause: error });
|
|
97
97
|
expired.status = 401;
|
|
98
|
-
expired.code = by_key
|
|
98
|
+
expired.code = by_key
|
|
99
|
+
? 'apikey_invalid'
|
|
100
|
+
: 'session_expired';
|
|
99
101
|
throw expired;
|
|
100
102
|
}
|
|
101
103
|
const serverMessage = res.data?.message || res.statusText || 'Unknown Error';
|
|
@@ -157,7 +159,11 @@ class FaableApi {
|
|
|
157
159
|
async listProjects(params) {
|
|
158
160
|
const { q, user_id, ...page } = params;
|
|
159
161
|
return data(this.client.get(`/project`, {
|
|
160
|
-
params: {
|
|
162
|
+
params: {
|
|
163
|
+
...page_params(page),
|
|
164
|
+
...(q ? { q } : {}),
|
|
165
|
+
...(user_id ? { user_id } : {})
|
|
166
|
+
}
|
|
161
167
|
}));
|
|
162
168
|
}
|
|
163
169
|
async getProject(project_id) {
|
|
@@ -62,6 +62,21 @@ const add_rule = async (opts) => {
|
|
|
62
62
|
}
|
|
63
63
|
if (json)
|
|
64
64
|
return waf;
|
|
65
|
+
if (action === 'allow') {
|
|
66
|
+
// The one rule that opens instead of closing: say exactly what it opens.
|
|
67
|
+
log.info(`🔓 ${describe_selector(want)} → reaches your app`);
|
|
68
|
+
log.info(` for ${app_name} (${app_id}), even where Faable blocks it for every app`);
|
|
69
|
+
log.info(` (archives like .zip or .tar.gz, dotfiles, config files).`);
|
|
70
|
+
log.info(``);
|
|
71
|
+
log.info(`Your own block and sink rules still win over it, and certificate checks,`);
|
|
72
|
+
log.info(`/.faable/* and /_next/* are never affected.`);
|
|
73
|
+
log.info(``);
|
|
74
|
+
log.info(`It takes about 20s to reach the edge. Then check it with:`);
|
|
75
|
+
log.info(` curl -s -o /dev/null -w '%{http_code}\\n' https://${app_url}<path>`);
|
|
76
|
+
log.info(``);
|
|
77
|
+
log.info(`Undo: faable deploy waf rm ${undo_args(want)} --action allow -a ${app_id}`);
|
|
78
|
+
return waf;
|
|
79
|
+
}
|
|
65
80
|
const answer = action === 'deny' ? '403' : '404';
|
|
66
81
|
log.info(`🛡️ ${describe_selector(want)} → ${answer} at the edge`);
|
|
67
82
|
log.info(` for ${app_name} (${app_id}).`);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { requireApi } from '../../../api/context.js';
|
|
2
|
+
import { print_json, json_option } from '../../../lib/listing.js';
|
|
3
|
+
import { resolve_app_id } from '../resolve_app_id.js';
|
|
4
|
+
import { add_rule } from './add_rule.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The one WAF rule that opens instead of closing: paths of THIS app that Faable
|
|
8
|
+
* blocks for every app (archives, dotfiles, config files) and that this app
|
|
9
|
+
* really serves — a `.zip` download, say. Path only: a user-agent or query
|
|
10
|
+
* exception could be claimed by anyone sending that header.
|
|
11
|
+
*/
|
|
12
|
+
const waf_allow = {
|
|
13
|
+
command: 'allow <pattern>',
|
|
14
|
+
describe: 'Let a path Faable blocks for every app (e.g. *.zip) reach your app',
|
|
15
|
+
builder: yargs => json_option(yargs)
|
|
16
|
+
.positional('pattern', {
|
|
17
|
+
type: 'string',
|
|
18
|
+
demandOption: true,
|
|
19
|
+
description: 'Anchored path regex, e.g. ^/downloads/.*\\.zip$ (quote it in your shell)'
|
|
20
|
+
})
|
|
21
|
+
.option('app', {
|
|
22
|
+
alias: 'a',
|
|
23
|
+
type: 'string',
|
|
24
|
+
description: 'App id, name or slug (defaults to the linked app)'
|
|
25
|
+
})
|
|
26
|
+
.option('description', {
|
|
27
|
+
alias: 'd',
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'Why this rule exists (shown in `waf list`)'
|
|
30
|
+
})
|
|
31
|
+
.example("$0 deploy waf allow '^/downloads/.*\\.zip$'", 'Serve the .zip files under /downloads that Faable would otherwise refuse')
|
|
32
|
+
.epilogue('Faable refuses some paths for every app before they reach it — ' +
|
|
33
|
+
'archives like .zip or .tar.gz, dotfiles, config files — because ' +
|
|
34
|
+
'scanners request them by the thousand. If your app really serves ' +
|
|
35
|
+
'one, allow exactly that path. Keep the pattern narrow: your own ' +
|
|
36
|
+
'block and sink rules still win over it, and it can never cover ' +
|
|
37
|
+
'/.well-known/acme-challenge, /.faable or /_next.')
|
|
38
|
+
.showHelpOnFail(false),
|
|
39
|
+
handler: async (args) => {
|
|
40
|
+
const ctx = await requireApi();
|
|
41
|
+
const app_id = await resolve_app_id(args.app, ctx.appId, ctx.api);
|
|
42
|
+
const app = await ctx.api.getApp(app_id);
|
|
43
|
+
const waf = await add_rule({
|
|
44
|
+
api: ctx.api,
|
|
45
|
+
app_id,
|
|
46
|
+
app_name: app.name,
|
|
47
|
+
app_url: app.url,
|
|
48
|
+
pattern: args.pattern,
|
|
49
|
+
action: 'allow',
|
|
50
|
+
description: args.description,
|
|
51
|
+
json: args.json
|
|
52
|
+
});
|
|
53
|
+
if (args.json)
|
|
54
|
+
print_json(waf);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { waf_allow };
|
|
@@ -5,7 +5,9 @@ const action_label = (action) => action === 'sink'
|
|
|
5
5
|
? '403 (blocked at the edge)'
|
|
6
6
|
: action === 'probe'
|
|
7
7
|
? 'answered by Faable, app not woken (uptime monitors)'
|
|
8
|
-
: action
|
|
8
|
+
: action === 'allow'
|
|
9
|
+
? 'allowed (reaches your app where Faable blocks it for every app)'
|
|
10
|
+
: action;
|
|
9
11
|
/**
|
|
10
12
|
* Render the effective WAF of an app.
|
|
11
13
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { waf_allow } from './allow.js';
|
|
1
2
|
import { waf_block } from './block.js';
|
|
2
3
|
import { waf_list } from './list.js';
|
|
3
4
|
import { waf_rm } from './rm.js';
|
|
@@ -10,8 +11,9 @@ const waf = {
|
|
|
10
11
|
.command(waf_list)
|
|
11
12
|
.command(waf_block)
|
|
12
13
|
.command(waf_sink)
|
|
14
|
+
.command(waf_allow)
|
|
13
15
|
.command(waf_rm)
|
|
14
|
-
.demandCommand(1, 'Specify a waf command: list, block, sink or rm'),
|
|
16
|
+
.demandCommand(1, 'Specify a waf command: list, block, sink, allow or rm'),
|
|
15
17
|
handler: () => {
|
|
16
18
|
// Unreachable: demandCommand(1) either routes to a subcommand or fails
|
|
17
19
|
// through the global .fail() in src/index.ts.
|
package/dist/mcp/http.js
CHANGED
|
@@ -233,6 +233,15 @@ const create_http_server = (opts) => {
|
|
|
233
233
|
if (req.method === 'GET' && url.pathname === '/llms.txt') {
|
|
234
234
|
return send(res, 200, llms_txt(base), 'text/plain; charset=utf-8');
|
|
235
235
|
}
|
|
236
|
+
// ChatGPT app submission proves domain ownership by fetching this file;
|
|
237
|
+
// the token comes from the OpenAI platform, set as a secret of the app.
|
|
238
|
+
if (req.method === 'GET' &&
|
|
239
|
+
url.pathname === '/.well-known/openai-apps-challenge') {
|
|
240
|
+
const token = process.env.OPENAI_APPS_CHALLENGE?.trim();
|
|
241
|
+
return token
|
|
242
|
+
? send(res, 200, token, 'text/plain; charset=utf-8')
|
|
243
|
+
: send(res, 404, { error: 'not_found' });
|
|
244
|
+
}
|
|
236
245
|
// RFC 9728: at the root and with the resource path inserted (what MCP
|
|
237
246
|
// clients derive from https://mcp.faable.com/mcp). Only with OAuth on.
|
|
238
247
|
if (req.method === 'GET' &&
|
package/dist/mcp/tools.js
CHANGED
|
@@ -16,7 +16,11 @@ const target = (a) => ['--app', a.app, ...scope(a)];
|
|
|
16
16
|
const opt = (flag, value) => value === undefined || value === null || value === ''
|
|
17
17
|
? []
|
|
18
18
|
: [flag, String(value)];
|
|
19
|
-
const READ = {
|
|
19
|
+
const READ = {
|
|
20
|
+
readOnlyHint: true,
|
|
21
|
+
destructiveHint: false,
|
|
22
|
+
openWorldHint: true
|
|
23
|
+
};
|
|
20
24
|
// A value as a double-quoted .env value, escaping exactly what parse_env
|
|
21
25
|
// (src/commands/deploy/secrets/parse_env.ts) unescapes — no more: JSON's
|
|
22
26
|
// \b, \f or \uXXXX would arrive as literal text.
|