4bnode 4.2.0 → 4.2.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.
- package/add-bonjour.js +29 -1
- package/add-email.js +33 -15
- package/add-serialport.js +133 -41
- package/index.js +3 -3
- package/lib/codegen.js +1442 -36
- package/lib/codegen.test.js +233 -13
- package/package.json +1 -1
- package/skeleton/.4bnode/assets/js/App.js +116 -7
- package/skeleton/.4bnode/assets/js/components/CommandPalette.js +165 -0
- package/skeleton/.4bnode/assets/js/components/SerialWorkspace.js +634 -0
- package/skeleton/.4bnode/assets/js/components/Sidebar.js +64 -64
- package/skeleton/.4bnode/assets/js/lib.js +76 -0
- package/skeleton/.4bnode/assets/js/pages/ApiTesterPage.js +113 -53
- package/skeleton/.4bnode/assets/js/pages/DashboardPage.js +240 -403
- package/skeleton/.4bnode/assets/js/pages/DiscoveryPage.js +52 -3
- package/skeleton/.4bnode/assets/js/pages/MailPage.js +37 -19
- package/skeleton/.4bnode/assets/js/pages/RoutesPage.js +1 -1
- package/skeleton/.4bnode/assets/js/pages/SchemasPage.js +5 -5
- package/skeleton/.4bnode/assets/js/pages/SecurityPage.js +154 -3
- package/skeleton/.4bnode/assets/js/pages/SerialPortPage.js +455 -139
- package/skeleton/.4bnode/codegen.js +1442 -36
- package/skeleton/.4bnode/dev-api.js +568 -95
- package/skeleton/.4bnode/ui.html +1241 -240
- package/skeleton/.env.example +23 -3
- package/skeleton/_gitignore +1 -0
- package/skeleton/index.js +8 -0
- package/skeleton/public/index.html +345 -237
- package/skeleton/src/discovery.js +128 -6
- package/skeleton/src/middleware/apiKey.js +63 -20
package/skeleton/.env.example
CHANGED
|
@@ -15,13 +15,25 @@ NODE_ENV=development
|
|
|
15
15
|
RATE_LIMIT_WINDOW_MS=900000
|
|
16
16
|
RATE_LIMIT_MAX=500
|
|
17
17
|
|
|
18
|
+
# ── API key gate ──
|
|
19
|
+
# Every API route (login and register included) needs a valid x-api-key header.
|
|
20
|
+
# Create / revoke keys in the /_dev dashboard → Security → API keys.
|
|
21
|
+
# API_KEY_REQUIRED: "off" disables the gate (default: on).
|
|
22
|
+
# API_KEY_PUBLIC_PATHS: comma-separated path prefixes that never need a key
|
|
23
|
+
# (/docs is always public), e.g. /health,/webhooks/stripe
|
|
24
|
+
# API_KEY_REQUIRED=on
|
|
25
|
+
# API_KEY_PUBLIC_PATHS=
|
|
26
|
+
|
|
18
27
|
# ── Bonjour / mDNS service discovery ──
|
|
19
28
|
# The app advertises itself on the local network so other devices can find it by
|
|
20
|
-
# name (http://<host>.local:<port>) without hard-coded IPs.
|
|
21
|
-
# BONJOUR_ENABLED: "
|
|
29
|
+
# name (http://<host>.local:<port>) without hard-coded IPs. Off by default.
|
|
30
|
+
# BONJOUR_ENABLED: "on" turns advertising on (it is OFF by default).
|
|
31
|
+
# BONJOUR_INTERFACE: network to advertise on when several are connected,
|
|
32
|
+
# e.g. en0 (Wi-Fi) or en7 (Ethernet). Blank = all networks.
|
|
22
33
|
# BONJOUR_NAME: custom service name shown to other devices (default: app + host).
|
|
23
34
|
# BONJOUR_TYPE: service type without the leading underscore (default: "http").
|
|
24
|
-
# BONJOUR_ENABLED=
|
|
35
|
+
# BONJOUR_ENABLED=on
|
|
36
|
+
# BONJOUR_INTERFACE=en0
|
|
25
37
|
# BONJOUR_NAME=My App
|
|
26
38
|
# BONJOUR_TYPE=http
|
|
27
39
|
|
|
@@ -33,3 +45,11 @@ RATE_LIMIT_MAX=500
|
|
|
33
45
|
# any hosted environment.
|
|
34
46
|
# _4BNODE_DASHBOARD=off
|
|
35
47
|
# _4BNODE_ALLOW_REMOTE=1
|
|
48
|
+
|
|
49
|
+
# ── Serial devices (Arduino / ESP32) ──
|
|
50
|
+
# Boards are detected when plugged in. An unknown board is added as a device
|
|
51
|
+
# automatically (opening a port resets most boards). Configure in the dashboard.
|
|
52
|
+
# SERIAL_AUTO_ADD: "off" only lists new boards, without adding them (default: on).
|
|
53
|
+
# SERIAL_DEFAULT_BAUD: baud rate used to identify and connect auto-added boards.
|
|
54
|
+
# SERIAL_AUTO_ADD=on
|
|
55
|
+
# SERIAL_DEFAULT_BAUD=115200
|
package/skeleton/_gitignore
CHANGED
package/skeleton/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import rateLimit from "express-rate-limit";
|
|
|
9
9
|
import { createInterface } from "readline";
|
|
10
10
|
import { notFound, errorHandler } from "./src/middleware/errorHandler.js";
|
|
11
11
|
import { startAdvertising, destroyDiscovery } from "./src/discovery.js";
|
|
12
|
+
import { apiKeyGate } from "./src/middleware/apiKey.js";
|
|
12
13
|
|
|
13
14
|
// ── Environment ─────────────────────────────────────
|
|
14
15
|
dotenv.config();
|
|
@@ -41,6 +42,8 @@ const dashboardEnabled =
|
|
|
41
42
|
if (dashboardEnabled) {
|
|
42
43
|
try {
|
|
43
44
|
const devApi = await import("./.4bnode/dev-api.js");
|
|
45
|
+
// In-memory request stats for the dashboard's live overview.
|
|
46
|
+
if (devApi.requestMetrics) app.use(devApi.requestMetrics);
|
|
44
47
|
app.use("/_dev", devApi.default);
|
|
45
48
|
} catch {}
|
|
46
49
|
}
|
|
@@ -84,6 +87,11 @@ app.use(apiLimiter);
|
|
|
84
87
|
// ── Static Files ────────────────────────────────────
|
|
85
88
|
app.use(express.static(path.join(__dirname, "public")));
|
|
86
89
|
|
|
90
|
+
// ── API key gate ────────────────────────────────────
|
|
91
|
+
// Every API route (login/register included) needs a valid x-api-key header.
|
|
92
|
+
// Manage keys in the /_dev dashboard → Security. API_KEY_REQUIRED=off disables.
|
|
93
|
+
app.use(apiKeyGate);
|
|
94
|
+
|
|
87
95
|
// ── Helpers ─────────────────────────────────────────
|
|
88
96
|
function getLocalNetworkIp() {
|
|
89
97
|
const interfaces = os.networkInterfaces();
|