mirror of
https://github.com/Silentely/eSIM-Tools.git
synced 2026-09-06 07:47:27 +08:00
问题: - 用户完成 eSIM 激活后,因外部二维码服务不可用导致页面空白 - Session 恢复时未调用 showESimResult() 显示二维码和 LPA 信息 解决方案: 1. 新增通用二维码生成模块 (src/js/modules/qrcode-generator.js) - 实现三层降级策略:本地 CDN → 后端 Function → 文本提示 - 消除对外部服务的依赖,提升隐私保护 2. 新增后端 Function (netlify/functions/qrcode-generate.js) - POST /bff/qrcode-generate 接口 - 返回 base64 编码的 PNG 二维码 - withAuth 中间件保护 + 输入验证 3. 重构前端二维码生成逻辑 - Giffgaff/Simyo 统一使用 generateQRCodeWithFallback() - 保留并发调用防护和 tooltip 交互 - 使用 i18n 翻译替代硬编码错误提示 4. 修复 Session 恢复逻辑 - 在 handleSessionRestore() 中调用 showESimResult() - 确保刷新页面后二维码和 LPA 正常显示 技术改进: - 懒加载 qrcode.js(~13KB gzip),仅在首次调用时加载 - 完整的测试覆盖(前端单元测试 + 后端安全测试) - 更新 BFF 路由配置(Edge Function + 本地开发服务器) Closes #75
42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
jest.mock('cheerio', () => ({
|
|
load: () => ({})
|
|
}));
|
|
|
|
describe('Local server route coverage', () => {
|
|
const originalEnv = process.env;
|
|
|
|
beforeEach(() => {
|
|
jest.resetModules();
|
|
process.env = {
|
|
...originalEnv,
|
|
ACCESS_KEY: 'test-access-key',
|
|
ALLOWED_ORIGIN: 'https://esim.cosr.eu.org',
|
|
SIMYO_CLIENT_TOKEN: 'test-simyo-token'
|
|
};
|
|
});
|
|
|
|
afterEach(() => {
|
|
process.env = originalEnv;
|
|
jest.restoreAllMocks();
|
|
});
|
|
|
|
it('exposes the same BFF targets locally as the production allowlist', () => {
|
|
const app = require('../../server.js');
|
|
const routes = app.locals.bffRoutes;
|
|
|
|
const expectedRoutes = [
|
|
'/bff/giffgaff-token-exchange',
|
|
'/bff/giffgaff-graphql',
|
|
'/bff/giffgaff-mfa-challenge',
|
|
'/bff/giffgaff-mfa-validation',
|
|
'/bff/giffgaff-sms-activate',
|
|
'/bff/auto-activate-esim',
|
|
'/bff/qrcode-generate',
|
|
'/bff/verify-cookie',
|
|
'/bff/public-config'
|
|
];
|
|
|
|
expect([...routes].sort()).toEqual([...expectedRoutes].sort());
|
|
});
|
|
});
|