@bmfk/api 0.0.0-stage → 1.0.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/CHANGELOG.md +90 -0
- package/LICENSE +21 -0
- package/README.md +1293 -2
- package/dist/apiServer/APIService.d.ts +125 -0
- package/dist/apiServer/APIService.js +769 -0
- package/dist/apiServer/BaseEndpoint.d.ts +90 -0
- package/dist/apiServer/BaseEndpoint.js +314 -0
- package/dist/apiServer/BaseService.d.ts +17 -0
- package/dist/apiServer/BaseService.js +39 -0
- package/dist/apiServer/DBService.d.ts +131 -0
- package/dist/apiServer/DBService.js +290 -0
- package/dist/apiServer/DocumentService.d.ts +9 -0
- package/dist/apiServer/DocumentService.js +65 -0
- package/dist/apiServer/LocalRequest.d.ts +3 -0
- package/dist/apiServer/LocalRequest.js +6 -0
- package/dist/apiServer/LogService.d.ts +78 -0
- package/dist/apiServer/LogService.js +349 -0
- package/dist/apiServer/MonitorService.d.ts +102 -0
- package/dist/apiServer/MonitorService.js +615 -0
- package/dist/apiServer/StatService.d.ts +4 -0
- package/dist/apiServer/StatService.js +10 -0
- package/dist/apiServer/TimeframeService.d.ts +28 -0
- package/dist/apiServer/TimeframeService.js +97 -0
- package/dist/apiServer/WebSocketServer.d.ts +39 -0
- package/dist/apiServer/WebSocketServer.js +173 -0
- package/dist/apiServer/db/IDBAdapter.d.ts +14 -0
- package/dist/apiServer/db/IDBAdapter.js +2 -0
- package/dist/apiServer/db/MysqlAdapter.d.ts +72 -0
- package/dist/apiServer/db/MysqlAdapter.js +869 -0
- package/dist/apiServer/db/PostgresAdapter.d.ts +41 -0
- package/dist/apiServer/db/PostgresAdapter.js +73 -0
- package/dist/apiServer/deployment/AccessConfigWizard.d.ts +5 -0
- package/dist/apiServer/deployment/AccessConfigWizard.js +254 -0
- package/dist/apiServer/deployment/Activate.d.ts +4 -0
- package/dist/apiServer/deployment/Activate.js +124 -0
- package/dist/apiServer/deployment/BackupManager.d.ts +33 -0
- package/dist/apiServer/deployment/BackupManager.js +174 -0
- package/dist/apiServer/deployment/Backups.d.ts +2 -0
- package/dist/apiServer/deployment/Backups.js +44 -0
- package/dist/apiServer/deployment/BlueGreenState.d.ts +31 -0
- package/dist/apiServer/deployment/BlueGreenState.js +150 -0
- package/dist/apiServer/deployment/Bundler.d.ts +12 -0
- package/dist/apiServer/deployment/Bundler.js +178 -0
- package/dist/apiServer/deployment/ConfigService.d.ts +203 -0
- package/dist/apiServer/deployment/ConfigService.js +195 -0
- package/dist/apiServer/deployment/Deploy.d.ts +4 -0
- package/dist/apiServer/deployment/Deploy.js +404 -0
- package/dist/apiServer/deployment/DeployKeyWizard.d.ts +2 -0
- package/dist/apiServer/deployment/DeployKeyWizard.js +84 -0
- package/dist/apiServer/deployment/Deployer.d.ts +13 -0
- package/dist/apiServer/deployment/Deployer.js +96 -0
- package/dist/apiServer/deployment/DeployerInit.d.ts +25 -0
- package/dist/apiServer/deployment/DeployerInit.js +214 -0
- package/dist/apiServer/deployment/DeployerService.d.ts +378 -0
- package/dist/apiServer/deployment/DeployerService.js +1553 -0
- package/dist/apiServer/deployment/HashPassword.d.ts +3 -0
- package/dist/apiServer/deployment/HashPassword.js +126 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.d.ts +1 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.js +202 -0
- package/dist/apiServer/deployment/MigrateProject.d.ts +31 -0
- package/dist/apiServer/deployment/MigrateProject.js +335 -0
- package/dist/apiServer/deployment/NginxHelper.d.ts +10 -0
- package/dist/apiServer/deployment/NginxHelper.js +111 -0
- package/dist/apiServer/deployment/Notifier.d.ts +30 -0
- package/dist/apiServer/deployment/Notifier.js +82 -0
- package/dist/apiServer/deployment/ProjectConfigWizard.d.ts +1 -0
- package/dist/apiServer/deployment/ProjectConfigWizard.js +148 -0
- package/dist/apiServer/deployment/Restore.d.ts +2 -0
- package/dist/apiServer/deployment/Restore.js +89 -0
- package/dist/apiServer/deployment/ReviewStore.d.ts +62 -0
- package/dist/apiServer/deployment/ReviewStore.js +186 -0
- package/dist/apiServer/deployment/SecretsInjector.d.ts +21 -0
- package/dist/apiServer/deployment/SecretsInjector.js +189 -0
- package/dist/apiServer/deployment/SetupConfigWizard.d.ts +1 -0
- package/dist/apiServer/deployment/SetupConfigWizard.js +238 -0
- package/dist/apiServer/deployment/Status.d.ts +2 -0
- package/dist/apiServer/deployment/Status.js +83 -0
- package/dist/apiServer/deployment/TelegramNotifier.d.ts +8 -0
- package/dist/apiServer/deployment/TelegramNotifier.js +23 -0
- package/dist/apiServer/deployment/Watchdog.d.ts +15 -0
- package/dist/apiServer/deployment/Watchdog.js +65 -0
- package/dist/apiServer/deployment/Wizards.d.ts +1 -0
- package/dist/apiServer/deployment/Wizards.js +83 -0
- package/dist/apiServer/deployment/cli.d.ts +2 -0
- package/dist/apiServer/deployment/cli.js +224 -0
- package/dist/apiServer/deployment/cliCommon.d.ts +27 -0
- package/dist/apiServer/deployment/cliCommon.js +110 -0
- package/dist/apiServer/deployment/cliPrompt.d.ts +5 -0
- package/dist/apiServer/deployment/cliPrompt.js +38 -0
- package/dist/apiServer/deployment/resolveConfig.d.ts +19 -0
- package/dist/apiServer/deployment/resolveConfig.js +139 -0
- package/dist/apiServer/documentation/Documentation.d.ts +18 -0
- package/dist/apiServer/documentation/Documentation.js +143 -0
- package/dist/apiServer/documentation/index.html +460 -0
- package/dist/apiServer/external/MicroserviceClient.d.ts +28 -0
- package/dist/apiServer/external/MicroserviceClient.js +144 -0
- package/dist/apiServer/external/MicroserviceHost.d.ts +52 -0
- package/dist/apiServer/external/MicroserviceHost.js +183 -0
- package/dist/apiServer/external/MicroserviceHostController.d.ts +6 -0
- package/dist/apiServer/external/MicroserviceHostController.js +65 -0
- package/dist/apiServer/helper/AppDataPath.d.ts +9 -0
- package/dist/apiServer/helper/AppDataPath.js +81 -0
- package/dist/apiServer/helper/ClientIp.d.ts +3 -0
- package/dist/apiServer/helper/ClientIp.js +33 -0
- package/dist/apiServer/helper/DataProvider.d.ts +18 -0
- package/dist/apiServer/helper/DataProvider.js +57 -0
- package/dist/apiServer/helper/IpAllowList.d.ts +8 -0
- package/dist/apiServer/helper/IpAllowList.js +40 -0
- package/dist/apiServer/helper/JSONStableStringify.d.ts +1 -0
- package/dist/apiServer/helper/JSONStableStringify.js +15 -0
- package/dist/apiServer/helper/PasswordHash.d.ts +5 -0
- package/dist/apiServer/helper/PasswordHash.js +52 -0
- package/dist/apiServer/helper/Sleep.d.ts +1 -0
- package/dist/apiServer/helper/Sleep.js +5 -0
- package/dist/apiServer/helper/Trace.d.ts +8 -0
- package/dist/apiServer/helper/Trace.js +30 -0
- package/dist/apiServer/helper/UID.d.ts +16 -0
- package/dist/apiServer/helper/UID.js +98 -0
- package/dist/apiServer/helper/Validator.d.ts +86 -0
- package/dist/apiServer/helper/Validator.js +560 -0
- package/dist/apiServer/helper/YYYYMMDDHH.d.ts +2 -0
- package/dist/apiServer/helper/YYYYMMDDHH.js +31 -0
- package/dist/apiServer/helper/ZipUtils.d.ts +6 -0
- package/dist/apiServer/helper/ZipUtils.js +28 -0
- package/dist/apiServer/http/Http.d.ts +183 -0
- package/dist/apiServer/http/Http.js +627 -0
- package/dist/apiServer/interceptors/InterceptorPayAuth.d.ts +19 -0
- package/dist/apiServer/interceptors/InterceptorPayAuth.js +124 -0
- package/dist/apiServer/interceptors/InterceptorSignedAuth.d.ts +40 -0
- package/dist/apiServer/interceptors/InterceptorSignedAuth.js +150 -0
- package/dist/apiServer/monitor/AccessStore.d.ts +27 -0
- package/dist/apiServer/monitor/AccessStore.js +163 -0
- package/dist/apiServer/monitor/LogFiles.d.ts +34 -0
- package/dist/apiServer/monitor/LogFiles.js +109 -0
- package/dist/apiServer/monitor/Monitor.d.ts +54 -0
- package/dist/apiServer/monitor/Monitor.js +447 -0
- package/dist/apiServer/monitor/MonitorAuth.d.ts +87 -0
- package/dist/apiServer/monitor/MonitorAuth.js +474 -0
- package/dist/apiServer/monitor/ProcessMonitor.d.ts +177 -0
- package/dist/apiServer/monitor/ProcessMonitor.js +468 -0
- package/dist/apiServer/monitor/SystemInfo.d.ts +70 -0
- package/dist/apiServer/monitor/SystemInfo.js +217 -0
- package/dist/apiServer/monitor/ThreatMonitor.d.ts +73 -0
- package/dist/apiServer/monitor/ThreatMonitor.js +239 -0
- package/dist/apiServer/monitor/index.html +591 -0
- package/dist/apiServer/review/Review.d.ts +23 -0
- package/dist/apiServer/review/Review.js +149 -0
- package/dist/apiServer/review/ReviewAuth.d.ts +56 -0
- package/dist/apiServer/review/ReviewAuth.js +147 -0
- package/dist/apiServer/review/ReviewDiff.d.ts +43 -0
- package/dist/apiServer/review/ReviewDiff.js +175 -0
- package/dist/apiServer/review/index.html +501 -0
- package/dist/apiServer/routes/Liveness.d.ts +7 -0
- package/dist/apiServer/routes/Liveness.js +27 -0
- package/dist/apiServer/routes/Readiness.d.ts +13 -0
- package/dist/apiServer/routes/Readiness.js +20 -0
- package/dist/apiServer/security/BlockedIps.d.ts +46 -0
- package/dist/apiServer/security/BlockedIps.js +185 -0
- package/dist/apiServer/structures/DefaultErrors.d.ts +36 -0
- package/dist/apiServer/structures/DefaultErrors.js +52 -0
- package/dist/apiServer/structures/HTTPStatus.d.ts +7 -0
- package/dist/apiServer/structures/HTTPStatus.js +11 -0
- package/dist/apiServer/structures/Interfaces.d.ts +55 -0
- package/dist/apiServer/structures/Interfaces.js +2 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +110 -0
- package/dist/signal/Signal.d.ts +23 -0
- package/dist/signal/Signal.js +85 -0
- package/package.json +88 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.1 — 2026-11-24
|
|
4
|
+
|
|
5
|
+
### Release process
|
|
6
|
+
|
|
7
|
+
- Published from CI through an npm Trusted Publisher (OIDC): no npm token exists anywhere. The release
|
|
8
|
+
workflow checks that npm supports it (11.5.1+) and waits for approval on the `npm` environment.
|
|
9
|
+
|
|
10
|
+
## 1.0.0 — 2026-11-23
|
|
11
|
+
|
|
12
|
+
First release of `@bmfk/api`: a TypeScript framework for HTTP API services on Node.js, built so that a
|
|
13
|
+
service written with it holds up in a PCI DSS assessment without extra plumbing. One `npm install` brings
|
|
14
|
+
the HTTP server, the database adapters, an operations console, API documentation and a deployer.
|
|
15
|
+
|
|
16
|
+
### Requirements
|
|
17
|
+
|
|
18
|
+
- Node.js 24 or later (the supported LTS lines; tested on 24 and 26).
|
|
19
|
+
- One entry point: everything is imported from `@bmfk/api`. Paths inside the package (`@bmfk/api/dist/…`)
|
|
20
|
+
are closed by `exports`.
|
|
21
|
+
- On servers, a data folder `/var/bmfk/<project>/` owned by the service user (override: `BMFK_DATA_DIR`).
|
|
22
|
+
Without it the service falls back to a folder beside the code and says so at startup.
|
|
23
|
+
|
|
24
|
+
### What is in it
|
|
25
|
+
|
|
26
|
+
- **Endpoints.** Express 5 under the hood, endpoints declared as classes, request and response types
|
|
27
|
+
`IRequest` / `IResponse`, file uploads, raw responses, interceptors for authentication, and a trace id
|
|
28
|
+
on every response (`X-Request-Id` and `traceId`).
|
|
29
|
+
- **Validation models.** A model is a sample object with typed fields, `min` / `max`, allowed values,
|
|
30
|
+
optional fields and nested objects. A number sample is only the type; bounds are always explicit.
|
|
31
|
+
- **Databases.** `MysqlAdapter` and `PostgresAdapter`, both drivers included; queries go through `REQ_DB`.
|
|
32
|
+
- **Signed microservice calls.** Each service has an Ed25519 key pair (`bmfk ms-key`). The caller signs
|
|
33
|
+
every request, and the host signs every answer, bound to that request. Hosts list their callers and what
|
|
34
|
+
each may call, optionally limited by address. An operation id runs an operation once across retries.
|
|
35
|
+
Signed calls go over https only (plain http only to localhost).
|
|
36
|
+
- **Signals.** `Signal` and `Req` for messages and requests inside a service. A subscriber that throws does
|
|
37
|
+
not stop the others.
|
|
38
|
+
- **Outgoing HTTP client.** `Http` with timeouts and latency metrics per host. Requests are not retried
|
|
39
|
+
unless a call asks for it, so a payment is never sent twice by accident. `skipLogging` records a call
|
|
40
|
+
with its origin only, for requests whose URL or body must not reach the journal.
|
|
41
|
+
- **Logging and redaction.** Card numbers, CVVs, passwords, tokens and keys are redacted before anything is
|
|
42
|
+
written or shortened, in the log, the request journal and the outgoing request journal. Logged objects
|
|
43
|
+
are never modified.
|
|
44
|
+
- **Operations console** (`sm/html`). Metrics that survive restarts and deploys, logs, request journals
|
|
45
|
+
searchable by trace id, threats, blocked IPs, and restart. Sign-in with a password hash and mandatory
|
|
46
|
+
TOTP, roles, short sessions and lockout. Users live in `access.json`, re-read on change.
|
|
47
|
+
- **API documentation** (`doc/html`) for partners, generated from the endpoints and their models. Same
|
|
48
|
+
sign-in as the console: password hash, TOTP enrolled at the first sign-in, 15-minute idle and 8-hour
|
|
49
|
+
sessions, lockout.
|
|
50
|
+
- **WebSocket server** on the same port, with origin checks, authorization within a time limit, and limits
|
|
51
|
+
on message size, rate and connections.
|
|
52
|
+
- **IP blocking** and threat monitoring that records probing clients.
|
|
53
|
+
- **Deployer.** Deploys signed with Ed25519 (the server keeps only public keys), blue-green releases with
|
|
54
|
+
liveness checks and rollback, backups and restore, optional deploy review by a second person, secrets
|
|
55
|
+
injected on the server so they never live in the repository, `npm ci --omit=dev`, Telegram
|
|
56
|
+
notifications and an audit trail. `bmfk deployer-init` sets up a deployer on a server in one
|
|
57
|
+
interactive run.
|
|
58
|
+
- **CLI** `bmfk`: deploy, activate, status, backups, restore, key and token generation, password hashing,
|
|
59
|
+
config wizards (`bmfk wizards`), `deployer-init`, and `migrate` for projects on the legacy server.
|
|
60
|
+
|
|
61
|
+
### Secure by default
|
|
62
|
+
|
|
63
|
+
- CORS allows only the API's own origin until you list others. `"*"` means any origin, never with
|
|
64
|
+
credentials.
|
|
65
|
+
- Production mode unless `NODE_ENV=development`.
|
|
66
|
+
- A failure returns only a code and a generic message to the client; the cause and the stack stay in the
|
|
67
|
+
log under the same trace id.
|
|
68
|
+
- Passwords and tokens in configs must be hashes (salted scrypt); plain text is refused. Comparisons run in
|
|
69
|
+
constant time.
|
|
70
|
+
- The deployer accepts signed requests only.
|
|
71
|
+
- A WebSocket server does not start without `onAuthorize`, unless it is declared `public: true`.
|
|
72
|
+
- Proxy headers are trusted only from `trustedProxies` (loopback by default).
|
|
73
|
+
- Uploads go to `/var/bmfk/<project>/uploads` with mode 0700, not to `/tmp`.
|
|
74
|
+
- The console and the documentation are closed until `access.json` exists; by default it is read from
|
|
75
|
+
`/var/bmfk/<project>/access.json`.
|
|
76
|
+
|
|
77
|
+
### Supply chain
|
|
78
|
+
|
|
79
|
+
- Published only from CI, from a release tag, with npm provenance. Each GitHub release carries a CycloneDX
|
|
80
|
+
SBOM.
|
|
81
|
+
- `npm audit`: 0 vulnerabilities. `esbuild` and `@babel/parser` are optional peer dependencies, loaded only
|
|
82
|
+
by `bundle`.
|
|
83
|
+
|
|
84
|
+
### Coming from the legacy server (6.x)
|
|
85
|
+
|
|
86
|
+
1.0 is a new product, not an upgrade: it does not talk to 6.x services or deployers, and it does not read
|
|
87
|
+
their files. `npx bmfk migrate` rewrites a project's imports, scripts and validation models and lists what
|
|
88
|
+
is left to do by hand. Read the
|
|
89
|
+
[migration guide](https://github.com/bmfk-api/core/blob/main/docs/migration-from-legacy.md) before
|
|
90
|
+
moving a service.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2026 Igor Bloom
|
|
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.
|