Files
eSIM-Tools/package.json
Neo Vern 7298ae4a0d feat: QR 码本地打包 + Edge Function 直接生成 (#86)
*  feat: 打包 qrcode-generator@1.4.4 到本地 ES 模块

* ♻️ refactor(qrcode): 移除 CDN 加载逻辑,改用本地 import 引入 qrcode-generator

* 🔧 chore: 移除 CDN preconnect 提示,QR 码库已内联

* 🔧 chore: 清理 CSP 配置,移除不再需要的 CDN 域名

*  feat: 将 QR 码生成迁移到 Edge Function,消除后端冷启动延迟

- 在 Edge Function 中内联 qrcode-generator 库(~20KB),直接生成 QR 码
- 删除废弃的 Netlify Function (qrcode-generate.js)
- 更新 server.js 移除对已删除函数的引用
- 更新测试文件适配新的 Edge 内联架构

* ♻️ refactor: 代码质量修复 — 移除死代码、消除变量遮蔽、添加交叉引用注释

* 🔧 chore: 修复非阻塞风险 — 补充 strict 模式、移除废弃 qrcode 依赖

- Edge Function qrcode-lib.js 补充 'use strict' 声明,与浏览器版保持一致
- 移除已废弃的 qrcode npm 依赖(原用于已删除的 Netlify Function)

* ♻️ refactor: 消除魔法数字、补充脆耦合和 async 技术债注释

- Edge Function 中 QR margin 魔法数字 8 替换为 QR_MARGIN_MODULES 常量
- generateQRCodeLocal 补充 async 无 await 的技术债说明
- error.message.startsWith 条件补充校验函数耦合关系注释

* 🐛 fix: 修复边界条件 — null JSON body、vendor 字符串异常、CDN preconnect 残留

- Edge Function: null JSON body 解构移到 try/catch 内,添加 null/非对象检查
- qrcode-generator: 库 throw 字符串时统一转换为 Error 对象,避免 .startsWith 崩溃
- index.html: 移除不再需要的 CDN preconnect 提示(jsdelivr/cdnjs)

* ♻️ refactor: 修复 CSP 恢复、异常归一化、自定义 Error 类、负面路径测试

- netlify.toml: 恢复 script-src 中 cdn.jsdelivr.net(Bootstrap JS 仍依赖)
- Edge Function catch: 归一化非 Error 异常(库可能 throw 字符串)
- Edge Function QR margin: createDataURL(cellSize, 2) → createDataURL(cellSize, cellSize * 2) 对齐模块边距
- Edge Function: 补充认证模型和 QR 格式变更注释
- qrcode-generator.js: 引入 QRCodeValidationError 替代 error.message.startsWith 脆耦合
- tests/bff-proxy: 添加 6 个 Edge QR 负面路径测试(无效 JSON、空/超长/非字符串 data、超范围 size)
- tests/qrcode-generator: 添加库 throw 字符串异常的测试
- scripts/sync-qrcode-lib.js: 新增库代码同步验证脚本

* 🐛 fix: 修复 server.js CSP 缺少 jsdelivr、同步脚本 CRLF 归一化、fallback 拦截校验错误

- server.js: 恢复 script-src 中 cdn.jsdelivr.net(本地开发 Bootstrap JS 依赖)
- sync-qrcode-lib.js: 归一化 CRLF 换行符避免跨平台误报
- qrcode-generator.js: generateQRCodeWithFallback 入口处拦截 QRCodeValidationError,避免无效输入触发无意义的后端降级
2026-06-25 22:15:17 +08:00

112 lines
3.3 KiB
JSON

{
"name": "esim-tools",
"version": "2.0.0",
"description": "专为Giffgaff和Simyo用户设计的eSIM管理工具集",
"main": "index.js",
"scripts": {
"hooks:install": "git config core.hooksPath .githooks",
"hooks:list": "ls -1 .githooks",
"precommit:check": "node scripts/pre-commit-check.js",
"prepush:check": "node scripts/pre-push-check.js --mode=full",
"prepush:check:fast": "node scripts/pre-push-check.js --mode=fast",
"commitmsg:lint": "node scripts/commit-msg-lint.js",
"prestart": "npm run build",
"predev": "npm run build",
"prenetlify-dev": "npm run build",
"start": "node server.js",
"dev": "nodemon server.js",
"build": "npm run build:static",
"build:static": "node scripts/build-static.js",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"netlify-dev": "npx --yes netlify-cli@latest dev",
"deploy": "npm run build && npx --yes netlify-cli@latest deploy --prod",
"optimize-images": "node scripts/optimize-images.js",
"compress": "node scripts/compress.js",
"security-check": "node scripts/security-check.js",
"quality-check": "node scripts/quality-check.js",
"deploy-prepare": "node scripts/deploy-prepare.js",
"deploy-analyze": "node scripts/deploy-analyze.js",
"deploy-test": "node scripts/test-deploy-config.js"
},
"keywords": [
"esim",
"giffgaff",
"simyo",
"mobile",
"sim-card",
"oauth",
"api"
],
"author": "eSIM Tools Team",
"license": "MIT",
"dependencies": {
"@netlify/blobs": "^8.0.0",
"@sentry/browser": "^10.30.0",
"@sentry/node": "^10.58.0",
"axios": "^1.16.0",
"cheerio": "^1.0.0-rc.12",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.22.2",
"helmet": "^7.1.0",
"morgan": "^1.10.0"
},
"devDependencies": {
"@babel/core": "^7.29.6",
"@babel/plugin-transform-runtime": "^7.28.0",
"@babel/preset-env": "^7.23.0",
"@babel/runtime": "^7.28.2",
"@sentry/webpack-plugin": "^4.6.1",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/user-event": "^14.5.1",
"autoprefixer": "^10.4.16",
"babel-loader": "^9.1.3",
"compression-webpack-plugin": "^10.0.0",
"core-js": "^3.45.0",
"css-loader": "^6.8.1",
"cssnano": "^6.0.1",
"esbuild": "^0.28.1",
"http-proxy-middleware": "^3.0.7",
"jest": "^30.3.0",
"jest-environment-jsdom": "^30.2.0",
"nodemon": "^3.0.2",
"on-headers": "^1.1.0",
"postcss": "^8.5.10",
"postcss-cli": "^11.0.1",
"postcss-loader": "^7.3.3",
"sharp": "^0.34.3",
"style-loader": "^3.3.3",
"terser-webpack-plugin": "^5.3.9",
"webpack": "^5.105.0",
"webpack-cli": "^5.1.4",
"workbox-webpack-plugin": "^7.0.0"
},
"browserslist": [
"defaults",
"Chrome >= 90",
"not dead"
],
"engines": {
"node": ">=18.0.0",
"npm": ">=8.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/Silentely/eSIM-Tools.git"
},
"bugs": {
"url": "https://github.com/Silentely/eSIM-Tools/issues"
},
"homepage": "https://esim.cosr.eu.org",
"overrides": {
"minimatch": "^10.2.3",
"glob": "^11.1.0",
"serialize-javascript": "^7.0.5",
"path-to-regexp": "^0.1.13",
"rollup": "^2.80.0",
"uuid": "^14.0.0"
}
}