iobroker.e-invoices 0.8.2 → 0.8.3
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 +38 -2
- package/build/lib/api-server.js +48 -1
- package/build/lib/api-server.js.map +2 -2
- package/build/lib/backup.js +73 -3
- package/build/lib/backup.js.map +2 -2
- package/build/lib/issue-service.js +30 -7
- package/build/lib/issue-service.js.map +2 -2
- package/build/main.js +6 -1
- package/build/main.js.map +2 -2
- package/io-package.json +14 -41
- package/package.json +1 -1
- package/www/assets/{index-Dpe2izSm.js → index-CYjFrm01.js} +261 -253
- package/www/assets/index-D1gjJXfv.css +1 -0
- package/www/index.html +2 -2
- package/www/sw.js +1 -1
- package/www/assets/index-B4qb37lK.css +0 -1
package/README.md
CHANGED
|
@@ -170,7 +170,11 @@ preview, backups, restore). With an API token configured, every route except
|
|
|
170
170
|
|
|
171
171
|
- **Token:** set `authToken` in the instance configuration. Every API route except
|
|
172
172
|
`/api/health` then requires `Authorization: Bearer <token>`; without a token the
|
|
173
|
-
API trusts every client that can reach the port.
|
|
173
|
+
API trusts every client that can reach the port. In that case it only answers
|
|
174
|
+
requests whose host name is an IP address or `localhost` (so a web page cannot
|
|
175
|
+
steer your browser to the adapter by DNS rebinding) and refuses writes that carry a
|
|
176
|
+
foreign `Origin`; reach the PWA by IP address, or set a token to use a host name.
|
|
177
|
+
Use a long random token (the adapter warns below 16 characters).
|
|
174
178
|
- **Bind address:** `bind` defaults to `127.0.0.1`, so only the host running the
|
|
175
179
|
adapter can reach the API. An unauthenticated bind to another interface is
|
|
176
180
|
logged as a warning on startup — use a token in that case.
|
|
@@ -183,6 +187,10 @@ preview, backups, restore). With an API token configured, every route except
|
|
|
183
187
|
`X-Forwarded-*` headers are not trusted (`trust proxy` disabled) — the adapter
|
|
184
188
|
is meant to be reached directly; put it behind a reverse proxy only with HTTPS
|
|
185
189
|
and a token.
|
|
190
|
+
- **Restore safety:** before a restore replaces the database, the current state is
|
|
191
|
+
written to `backups/e-invoices-prerestore-<time>.zip`; if that fails, nothing is
|
|
192
|
+
restored. Number counters are never lowered, and every restore is appended to
|
|
193
|
+
`backups/restore-log.jsonl`.
|
|
186
194
|
- **Restore limits:** a backup ZIP may be at most 512 MB and expand to at most
|
|
187
195
|
1 GB (`dump.json` at most 256 MB); a crafted archive is rejected before it is
|
|
188
196
|
unpacked. Entry paths, per-file checksums and the manifest are verified.
|
|
@@ -254,7 +262,35 @@ validation and hybrid embedding, `pdfkit`, `exceljs`, `jszip`,
|
|
|
254
262
|
Placeholder for the next version (at the beginning of the line):
|
|
255
263
|
### **WORK IN PROGRESS**
|
|
256
264
|
-->
|
|
257
|
-
###
|
|
265
|
+
### 0.8.3 (2026-10-02)
|
|
266
|
+
|
|
267
|
+
* (alex) The toolbar of the invoice and offer lists sits on two lines now: the filters above, the search and the buttons below, so it no longer wraps into a ragged shape on narrow screens.
|
|
268
|
+
* (alex) Three safeguards from the code review of 2 October 2026:
|
|
269
|
+
**Re-render** never overwrites an archive any more — every run keeps its own
|
|
270
|
+
`<number>.orig-<n>.pdf`, so the delivered original stays retrievable however often the
|
|
271
|
+
sight PDF is rendered again — and it embeds the XML as issued instead of generating it
|
|
272
|
+
anew, so database, `.xml` file and the XML inside the PDF cannot drift apart.
|
|
273
|
+
**Without an API token** the API now accepts only IP addresses and `localhost` as host
|
|
274
|
+
name and refuses cross-origin writes (DNS rebinding, CSRF); with a token nothing
|
|
275
|
+
changes. **Restore** saves the current state as `backups/e-invoices-prerestore-<time>.zip`
|
|
276
|
+
first (no safety copy, no restore), never moves a number counter backwards — an
|
|
277
|
+
invoice number is not issued twice after restoring an older backup — and appends
|
|
278
|
+
every restore to `backups/restore-log.jsonl`.
|
|
279
|
+
* (alex) The web app sources are linted now (R5.3): `src-www/src/**/*.ts` runs through the
|
|
280
|
+
same ESLint set as the adapter, with the browser globals and the `src-www` tsconfig, so
|
|
281
|
+
the PWA is no longer the one corner of the repository that no rule looks at. The first
|
|
282
|
+
run paid for itself: the wizard read its settings object before declaring it (the same
|
|
283
|
+
class of temporal-dead-zone bug as the wizard defect of September 2026 — the
|
|
284
|
+
declaration now sits above its use), the customer-number button printed
|
|
285
|
+
"[object Object] vergeben." instead of the count, and the two identical `FileReader`
|
|
286
|
+
copies in the backup and template views became one checked helper (`fileToBase64`),
|
|
287
|
+
which no longer turns a missing string into `[object ArrayBuffer]`. Only formatting
|
|
288
|
+
changed beyond that (Prettier, braces). `npm run lint` covers the PWA: 0 errors,
|
|
289
|
+
remaining warnings are JSDoc wishes, not defects.
|
|
290
|
+
* (alex) The invoice and offer lists lay their controls on two lines: the filters
|
|
291
|
+
(status, sort, sent) share the first line and the search sits on the second next
|
|
292
|
+
to the buttons ("+ Neu", Excel, CSV, DATEV, "Ausstellen"). One single row had
|
|
293
|
+
grown too crowded and wrapped into a ragged shape on a narrow screen.
|
|
258
294
|
|
|
259
295
|
### 0.8.2 (2026-10-01)
|
|
260
296
|
* (alex) The header bar carries the tabs and nothing else now: the "+ Neu" button
|
package/build/lib/api-server.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(api_server_exports, {
|
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(api_server_exports);
|
|
38
38
|
var import_node_crypto = require("node:crypto");
|
|
39
|
+
var import_node_net = require("node:net");
|
|
39
40
|
var import_express = __toESM(require("express"));
|
|
40
41
|
var import_node_fs = require("node:fs");
|
|
41
42
|
var import_node_path = require("node:path");
|
|
@@ -204,6 +205,38 @@ async function storeValidationReport(db, storage, log, invoice, result) {
|
|
|
204
205
|
return null;
|
|
205
206
|
}
|
|
206
207
|
}
|
|
208
|
+
function hostNameOf(host) {
|
|
209
|
+
const trimmed = host.trim().toLowerCase();
|
|
210
|
+
if (trimmed.startsWith("[")) {
|
|
211
|
+
return trimmed.slice(1, trimmed.indexOf("]"));
|
|
212
|
+
}
|
|
213
|
+
return trimmed.split(":")[0];
|
|
214
|
+
}
|
|
215
|
+
function untrustedRequestReason(req) {
|
|
216
|
+
var _a;
|
|
217
|
+
const host = (_a = req.headers.host) != null ? _a : "";
|
|
218
|
+
const name = hostNameOf(host);
|
|
219
|
+
if (!name || (0, import_node_net.isIP)(name) === 0 && name !== "localhost" && !name.endsWith(".localhost")) {
|
|
220
|
+
return "Host name not allowed without an API token - open the PWA by IP address or set an API token";
|
|
221
|
+
}
|
|
222
|
+
if (!["GET", "HEAD", "OPTIONS"].includes(req.method)) {
|
|
223
|
+
const origin = req.headers.origin;
|
|
224
|
+
if (origin !== void 0) {
|
|
225
|
+
let originHost = "";
|
|
226
|
+
try {
|
|
227
|
+
originHost = new URL(origin).host.toLowerCase();
|
|
228
|
+
} catch {
|
|
229
|
+
}
|
|
230
|
+
if (originHost !== host.trim().toLowerCase()) {
|
|
231
|
+
return "Cross-origin request refused";
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (req.headers["sec-fetch-site"] === "cross-site") {
|
|
235
|
+
return "Cross-site request refused";
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return void 0;
|
|
239
|
+
}
|
|
207
240
|
function secretEquals(provided, expected) {
|
|
208
241
|
const a = (0, import_node_crypto.createHash)("sha256").update(provided, "utf8").digest();
|
|
209
242
|
const b = (0, import_node_crypto.createHash)("sha256").update(expected, "utf8").digest();
|
|
@@ -279,6 +312,18 @@ function createApiServer(deps) {
|
|
|
279
312
|
res.set("Pragma", "no-cache");
|
|
280
313
|
next();
|
|
281
314
|
});
|
|
315
|
+
if (!authToken) {
|
|
316
|
+
app.use("/api", (req, res, next) => {
|
|
317
|
+
var _a2;
|
|
318
|
+
const reason = untrustedRequestReason(req);
|
|
319
|
+
if (reason) {
|
|
320
|
+
(_a2 = log.warn) == null ? void 0 : _a2.call(log, `Request refused: ${req.method} ${req.path} (${reason})`);
|
|
321
|
+
res.status(403).json({ error: reason });
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
next();
|
|
325
|
+
});
|
|
326
|
+
}
|
|
282
327
|
if (authToken) {
|
|
283
328
|
app.use("/api", (req, res, next) => {
|
|
284
329
|
if (req.path === "/health") {
|
|
@@ -1195,7 +1240,9 @@ ${(0, import_csv.renderDatevRows)(filteredInvoices(db, req.query, "invoice"))}`)
|
|
|
1195
1240
|
return;
|
|
1196
1241
|
}
|
|
1197
1242
|
try {
|
|
1198
|
-
res.json(
|
|
1243
|
+
res.json(
|
|
1244
|
+
await (0, import_backup.restoreBackup)(db, storage, data, log, void 0, { adapterVersion: version, source: "api" })
|
|
1245
|
+
);
|
|
1199
1246
|
} catch (error) {
|
|
1200
1247
|
res.status(400).json({ error: error.message });
|
|
1201
1248
|
}
|