pixivflow 2.31.0 → 2.32.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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "commonjs",
3
3
  "name": "pixivflow",
4
- "version": "2.31.0",
4
+ "version": "2.32.0",
5
5
  "private": true
6
6
  }
package/dist/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BUILD = void 0;
4
4
  // GENERATED by scripts/write-version.js — do not edit manually.
5
- exports.BUILD = { version: '2.31.0', commit: '4642dce0724a' };
5
+ exports.BUILD = { version: '2.32.0', commit: 'db267d3a1a13' };
6
6
  //# sourceMappingURL=version.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "commonjs",
3
3
  "name": "pixivflow-webui-backend",
4
- "version": "2.31.0",
4
+ "version": "2.32.0",
5
5
  "description": "PixivFlow WebUI Backend - CommonJS module"
6
6
  }
@@ -1,6 +1,13 @@
1
1
  import { Express } from 'express';
2
2
  /**
3
- * Setup static file serving for SPA frontend
3
+ * Inject a one-time dismissal security notice into the served SPA index.html
4
+ * when WebUI basic auth is NOT configured (WEBUI_USERNAME / WEBUI_PASSWORD).
5
+ * First local start needs no credentials; the banner only reminds operators
6
+ * to set them before exposing the server beyond localhost.
4
7
  */
5
- export declare function setupStaticFiles(app: Express, staticPath?: string): void;
8
+ export declare function injectAuthBanner(indexHtml: string, basicAuthEnabled: boolean): string;
9
+ /**
10
+ * Setup static file serving for SPA frontend (injects auth-disabled notice when basic auth is off).
11
+ */
12
+ export declare function setupStaticFiles(app: Express, staticPath?: string, basicAuthEnabled?: boolean): void;
6
13
  //# sourceMappingURL=server-static.d.ts.map
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.injectAuthBanner = injectAuthBanner;
6
7
  exports.setupStaticFiles = setupStaticFiles;
7
8
  const express_1 = __importDefault(require("express"));
8
9
  const path_1 = __importDefault(require("path"));
@@ -70,9 +71,27 @@ function getPackageVersion() {
70
71
  return 'unknown';
71
72
  }
72
73
  /**
73
- * Setup static file serving for SPA frontend
74
+ * Inject a one-time dismissal security notice into the served SPA index.html
75
+ * when WebUI basic auth is NOT configured (WEBUI_USERNAME / WEBUI_PASSWORD).
76
+ * First local start needs no credentials; the banner only reminds operators
77
+ * to set them before exposing the server beyond localhost.
74
78
  */
75
- function setupStaticFiles(app, staticPath) {
79
+ function injectAuthBanner(indexHtml, basicAuthEnabled) {
80
+ if (basicAuthEnabled || indexHtml.includes('pixivflow-auth-banner')) {
81
+ return indexHtml;
82
+ }
83
+ const banner = [
84
+ '<div id="pixivflow-auth-banner" style="position:sticky;top:0;z-index:9999;display:flex;align-items:center;gap:12px;padding:8px 16px;background:#fff7e0;border-bottom:1px solid #f0d99a;color:#6b5300;font:14px/1.5 -apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;">',
85
+ ' <span>⚠️ <strong>安全提醒 / Security:</strong> WebUI 认证未启用(WEBUI_USERNAME / WEBUI_PASSWORD 未设置)。首次本地使用无需设置;若需对外暴露,请先设置用户名密码并重启服务。</span>',
86
+ ' <button type="button" title="知道了 / Got it" style="margin-left:auto;border:0;background:transparent;color:#6b5300;cursor:pointer;font-size:18px;line-height:1;" onclick="this.parentElement.remove()">✕</button>',
87
+ '</div>',
88
+ ].join('\n');
89
+ return indexHtml.replace('</body>', banner + '\n</body>');
90
+ }
91
+ /**
92
+ * Setup static file serving for SPA frontend (injects auth-disabled notice when basic auth is off).
93
+ */
94
+ function setupStaticFiles(app, staticPath, basicAuthEnabled = false) {
76
95
  if (!staticPath) {
77
96
  // Root path handler when static files are not configured
78
97
  app.get('/', (req, res) => {
@@ -95,6 +114,7 @@ function setupStaticFiles(app, staticPath) {
95
114
  }
96
115
  const resolvedStaticPath = path_1.default.resolve(staticPath);
97
116
  const indexPath = path_1.default.join(resolvedStaticPath, 'index.html');
117
+ let servedIndexHtml = null;
98
118
  // Verify static path and index.html exist
99
119
  if (!fs_1.default.existsSync(resolvedStaticPath)) {
100
120
  logger_1.logger.warn('Static path does not exist', { path: resolvedStaticPath });
@@ -107,6 +127,7 @@ function setupStaticFiles(app, staticPath) {
107
127
  }
108
128
  else {
109
129
  logger_1.logger.info('Serving static files', { path: resolvedStaticPath });
130
+ servedIndexHtml = injectAuthBanner(fs_1.default.readFileSync(indexPath, 'utf8'), basicAuthEnabled);
110
131
  }
111
132
  // Serve static files (CSS, JS, images, etc.)
112
133
  app.use(express_1.default.static(resolvedStaticPath, {
@@ -116,15 +137,7 @@ function setupStaticFiles(app, staticPath) {
116
137
  // Explicitly handle root path first
117
138
  app.get('/', (req, res, next) => {
118
139
  if (fs_1.default.existsSync(indexPath)) {
119
- res.sendFile(indexPath, (err) => {
120
- if (err) {
121
- logger_1.logger.error('Failed to send index.html for root path', {
122
- error: err.message,
123
- path: indexPath,
124
- });
125
- next(err);
126
- }
127
- });
140
+ res.type('html').send(servedIndexHtml);
128
141
  }
129
142
  else {
130
143
  logger_1.logger.warn('index.html not found, cannot serve frontend', {
@@ -145,16 +158,7 @@ function setupStaticFiles(app, staticPath) {
145
158
  }
146
159
  // Send index.html for all other routes (SPA routing)
147
160
  if (fs_1.default.existsSync(indexPath)) {
148
- res.sendFile(indexPath, (err) => {
149
- if (err) {
150
- logger_1.logger.error('Failed to send index.html for SPA route', {
151
- error: err.message,
152
- path: indexPath,
153
- requestedPath: req.path,
154
- });
155
- next(err);
156
- }
157
- });
161
+ res.type('html').send(servedIndexHtml);
158
162
  }
159
163
  else {
160
164
  next();
@@ -97,7 +97,7 @@ class WebUIServer {
97
97
  // Setup API routes
98
98
  (0, server_routes_1.setupRoutes)(this.app);
99
99
  // Setup static file serving
100
- (0, server_static_1.setupStaticFiles)(this.app, options.staticPath);
100
+ (0, server_static_1.setupStaticFiles)(this.app, options.staticPath, this.basicAuthEnabled);
101
101
  // Error handler (must be last)
102
102
  this.app.use(server_middleware_1.errorHandler);
103
103
  // Create HTTP or HTTPS server (TLS opt-in via WEBUI_TLS_CERT/KEY)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixivflow",
3
- "version": "2.31.0",
3
+ "version": "2.32.0",
4
4
  "description": "🎨 Pixiv 下载、筛选与自动收集工具 - 批量下载插画和小说、按标签/热度/日期筛选、定时任务与可靠 HTTP 交付 | Pixiv downloader and automation toolkit with filtering, scheduling and reliable HTTP delivery",
5
5
  "repository": {
6
6
  "type": "git",