diff --git a/.gitignore b/.gitignore index 53a81ed..1862975 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ node_modules/ *.db-wal *.db cloudflared.exe +scratch/ + diff --git a/package-lock.json b/package-lock.json index f741f37..bb24228 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "jsqr": "^1.4.0", "mailparser": "^3.9.36", "pg": "^8.23.1", + "puppeteer-core": "^25.12.0", "qrcode": "^1.5.4", "synckit": "^0.11.13", "web-push": "^3.6.7" @@ -33,6 +34,195 @@ "url": "https://opencollective.com/pkgr" } }, + "node_modules/@puppeteer/browsers": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.2.3.tgz", + "integrity": "sha512-2Bt3m6dDAJqmZehn0wiXSYyQmuhyiHHZ7FjvrVaS1W2RoFGV6eCK71UvKYkNJjkwC1Q9nobjhvTMhLQztFVINA==", + "license": "Apache-2.0", + "dependencies": { + "modern-tar": "^0.8.4", + "yargs": "^18.0.0" + }, + "bin": { + "browsers": "lib/main-cli.js" + }, + "engines": { + "node": ">=22.12.0" + }, + "peerDependencies": { + "proxy-agent": ">=8.0.1", + "yauzl": "^2.10.0 || ^3.4.0" + }, + "peerDependenciesMeta": { + "proxy-agent": { + "optional": true + }, + "yauzl": { + "optional": true + } + } + }, + "node_modules/@puppeteer/browsers/node_modules/ansi-regex": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", + "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@puppeteer/browsers/node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@puppeteer/browsers/node_modules/cliui": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", + "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", + "license": "ISC", + "dependencies": { + "string-width": "^7.2.0", + "strip-ansi": "^7.1.0", + "wrap-ansi": "^9.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@puppeteer/browsers/node_modules/cliui/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@puppeteer/browsers/node_modules/emoji-regex": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", + "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", + "license": "MIT" + }, + "node_modules/@puppeteer/browsers/node_modules/string-width": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", + "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", + "license": "MIT", + "dependencies": { + "get-east-asian-width": "^1.5.0", + "strip-ansi": "^7.1.2" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@puppeteer/browsers/node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@puppeteer/browsers/node_modules/wrap-ansi": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/@puppeteer/browsers/node_modules/wrap-ansi/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@puppeteer/browsers/node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/@puppeteer/browsers/node_modules/yargs": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz", + "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==", + "license": "MIT", + "dependencies": { + "cliui": "^9.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "string-width": "^8.2.1", + "y18n": "^5.0.5", + "yargs-parser": "^22.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, + "node_modules/@puppeteer/browsers/node_modules/yargs-parser": { + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", + "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", + "license": "ISC", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, "node_modules/@selderee/plugin-htmlparser2": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.12.0.tgz", @@ -226,6 +416,22 @@ "node": ">=6" } }, + "node_modules/chromium-bidi": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-17.0.2.tgz", + "integrity": "sha512-5v9GQFhTktFvotn/OFNJBmKLKRAb6n9r0bVCwf7sHgWc3/JryK0bj1nn93L3pHFrfgcsu6Be6EWsDi+1XHTGDg==", + "license": "Apache-2.0", + "dependencies": { + "mitt": "^3.0.1", + "zod": "^3.24.1" + }, + "engines": { + "node": ">=20.19.0 <22.0.0 || >=22.12.0" + }, + "peerDependencies": { + "devtools-protocol": "*" + } + }, "node_modules/cliui": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", @@ -372,6 +578,12 @@ "node": ">= 0.8" } }, + "node_modules/devtools-protocol": { + "version": "0.0.1687809", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1687809.tgz", + "integrity": "sha512-t7kSb+UKYdyxcmqy98U2P86ne6rCve3DIJ4+lp54i/hhClgFuG35JrLj23rO14Jw3sWDsp7i+22QhNU0+/qk8g==", + "license": "BSD-3-Clause" + }, "node_modules/dijkstrajs": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", @@ -528,6 +740,15 @@ "node": ">= 0.4" } }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -656,6 +877,18 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/get-east-asian-width": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", + "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/get-intrinsic": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", @@ -1109,6 +1342,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/mitt": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", + "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", + "license": "MIT" + }, + "node_modules/modern-tar": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.8.5.tgz", + "integrity": "sha512-snEhs+6G5Tjd4I7tLCDOaoln2RgE0bD19RzEKgvgK2hZ5VKy3MpLhLTZ2fWpXSTg4K2cyPwp+VHATFJhxfnOeA==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -1484,6 +1732,23 @@ "node": ">=6" } }, + "node_modules/puppeteer-core": { + "version": "25.12.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-25.12.0.tgz", + "integrity": "sha512-z6LQUt5SH7jwGtGA+nMtJuEjZIsqPiwQ+EFHCYuVDQrJpvifNmmGuyDvTzAKPyFzihxgHc5f3aMzu2kn8Ps37A==", + "license": "Apache-2.0", + "dependencies": { + "@puppeteer/browsers": "3.2.3", + "chromium-bidi": "17.0.2", + "devtools-protocol": "0.0.1687809", + "typed-query-selector": "^2.12.2", + "webdriver-bidi-protocol": "0.4.3", + "ws": "^8.21.3" + }, + "engines": { + "node": ">=22.12.0" + } + }, "node_modules/qrcode": { "version": "1.5.4", "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz", @@ -1890,6 +2155,12 @@ "url": "https://opencollective.com/express" } }, + "node_modules/typed-query-selector": { + "version": "2.12.3", + "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.3.tgz", + "integrity": "sha512-/dtuMZyutHLlrxWhhC1uib00ELUr2dZ8C9B8YzZYsJmeE3V56OxRblrSM2UaF142pcMtak7ehZ6+poWGeehNIg==", + "license": "MIT" + }, "node_modules/uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", @@ -1952,6 +2223,12 @@ "node": ">= 16" } }, + "node_modules/webdriver-bidi-protocol": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/webdriver-bidi-protocol/-/webdriver-bidi-protocol-0.4.3.tgz", + "integrity": "sha512-uuN0goWfxP22B7J/uAgBpOYNPttC+XVseYE+rSY5+rQ+YBeVz/VORw8WbmLVcqW78zNg5A4qnjNXYUWR3il2ig==", + "license": "Apache-2.0" + }, "node_modules/which-module": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", @@ -1978,6 +2255,27 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "license": "ISC" }, + "node_modules/ws": { + "version": "8.22.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", + "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", @@ -2027,6 +2325,15 @@ "engines": { "node": ">=6" } + }, + "node_modules/zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/package.json b/package.json index 1230e1f..3bbf6d2 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "jsqr": "^1.4.0", "mailparser": "^3.9.36", "pg": "^8.23.1", + "puppeteer-core": "^25.12.0", "qrcode": "^1.5.4", "synckit": "^0.11.13", "web-push": "^3.6.7" diff --git a/public/templates/preview-login-clasico.html b/public/templates/preview-login-clasico.html new file mode 100644 index 0000000..e0278e5 --- /dev/null +++ b/public/templates/preview-login-clasico.html @@ -0,0 +1,167 @@ + + + + + + SiboPay - Inicio de Sesión Clásico con Roles + + + + + + +
+
+ + + + + + +
+ + + + + + + +
+ + + +
+
+ + + + diff --git a/screenshots/apple_app_store/ipad_pro_12_9_inch/01_Bienvenida_Login_SiboPay.png b/screenshots/apple_app_store/ipad_pro_12_9_inch/01_Bienvenida_Login_SiboPay.png new file mode 100644 index 0000000..260318f Binary files /dev/null and b/screenshots/apple_app_store/ipad_pro_12_9_inch/01_Bienvenida_Login_SiboPay.png differ diff --git a/screenshots/apple_app_store/ipad_pro_12_9_inch/02_Acceso_Seguro_BottomSheet.png b/screenshots/apple_app_store/ipad_pro_12_9_inch/02_Acceso_Seguro_BottomSheet.png new file mode 100644 index 0000000..5972f31 Binary files /dev/null and b/screenshots/apple_app_store/ipad_pro_12_9_inch/02_Acceso_Seguro_BottomSheet.png differ diff --git a/screenshots/apple_app_store/ipad_pro_12_9_inch/03_Carne_Digital_QR_Estudiante.png b/screenshots/apple_app_store/ipad_pro_12_9_inch/03_Carne_Digital_QR_Estudiante.png new file mode 100644 index 0000000..972255f Binary files /dev/null and b/screenshots/apple_app_store/ipad_pro_12_9_inch/03_Carne_Digital_QR_Estudiante.png differ diff --git a/screenshots/apple_app_store/ipad_pro_12_9_inch/04_Catalogo_Soda_Escolar.png b/screenshots/apple_app_store/ipad_pro_12_9_inch/04_Catalogo_Soda_Escolar.png new file mode 100644 index 0000000..a40d1e0 Binary files /dev/null and b/screenshots/apple_app_store/ipad_pro_12_9_inch/04_Catalogo_Soda_Escolar.png differ diff --git a/screenshots/apple_app_store/ipad_pro_12_9_inch/05_Portal_Padres_Monitoreo.png b/screenshots/apple_app_store/ipad_pro_12_9_inch/05_Portal_Padres_Monitoreo.png new file mode 100644 index 0000000..e95ad42 Binary files /dev/null and b/screenshots/apple_app_store/ipad_pro_12_9_inch/05_Portal_Padres_Monitoreo.png differ diff --git a/screenshots/apple_app_store/ipad_pro_12_9_inch/05_Portal_Padres_Recarga_SINPE.png b/screenshots/apple_app_store/ipad_pro_12_9_inch/05_Portal_Padres_Recarga_SINPE.png new file mode 100644 index 0000000..1e84755 Binary files /dev/null and b/screenshots/apple_app_store/ipad_pro_12_9_inch/05_Portal_Padres_Recarga_SINPE.png differ diff --git a/screenshots/apple_app_store/ipad_pro_12_9_inch/06_Punto_Venta_POS_Soda.png b/screenshots/apple_app_store/ipad_pro_12_9_inch/06_Punto_Venta_POS_Soda.png new file mode 100644 index 0000000..f715762 Binary files /dev/null and b/screenshots/apple_app_store/ipad_pro_12_9_inch/06_Punto_Venta_POS_Soda.png differ diff --git a/screenshots/apple_app_store/ipad_pro_12_9_inch/06_Recarga_SINPE_Movil.png b/screenshots/apple_app_store/ipad_pro_12_9_inch/06_Recarga_SINPE_Movil.png new file mode 100644 index 0000000..23020cf Binary files /dev/null and b/screenshots/apple_app_store/ipad_pro_12_9_inch/06_Recarga_SINPE_Movil.png differ diff --git a/screenshots/apple_app_store/ipad_pro_12_9_inch/07_Terminal_POS_Caja_Soda.png b/screenshots/apple_app_store/ipad_pro_12_9_inch/07_Terminal_POS_Caja_Soda.png new file mode 100644 index 0000000..6f11989 Binary files /dev/null and b/screenshots/apple_app_store/ipad_pro_12_9_inch/07_Terminal_POS_Caja_Soda.png differ diff --git a/screenshots/apple_app_store/iphone_6_5_inch/01_Bienvenida_Login_SiboPay.png b/screenshots/apple_app_store/iphone_6_5_inch/01_Bienvenida_Login_SiboPay.png new file mode 100644 index 0000000..9b04d2e Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_5_inch/01_Bienvenida_Login_SiboPay.png differ diff --git a/screenshots/apple_app_store/iphone_6_5_inch/02_Acceso_Seguro_BottomSheet.png b/screenshots/apple_app_store/iphone_6_5_inch/02_Acceso_Seguro_BottomSheet.png new file mode 100644 index 0000000..f84d6ed Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_5_inch/02_Acceso_Seguro_BottomSheet.png differ diff --git a/screenshots/apple_app_store/iphone_6_5_inch/03_Carne_Digital_QR_Estudiante.png b/screenshots/apple_app_store/iphone_6_5_inch/03_Carne_Digital_QR_Estudiante.png new file mode 100644 index 0000000..0d0c509 Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_5_inch/03_Carne_Digital_QR_Estudiante.png differ diff --git a/screenshots/apple_app_store/iphone_6_5_inch/04_Catalogo_Soda_Escolar.png b/screenshots/apple_app_store/iphone_6_5_inch/04_Catalogo_Soda_Escolar.png new file mode 100644 index 0000000..b5a8017 Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_5_inch/04_Catalogo_Soda_Escolar.png differ diff --git a/screenshots/apple_app_store/iphone_6_5_inch/05_Portal_Padres_Monitoreo.png b/screenshots/apple_app_store/iphone_6_5_inch/05_Portal_Padres_Monitoreo.png new file mode 100644 index 0000000..8138c0c Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_5_inch/05_Portal_Padres_Monitoreo.png differ diff --git a/screenshots/apple_app_store/iphone_6_5_inch/05_Portal_Padres_Recarga_SINPE.png b/screenshots/apple_app_store/iphone_6_5_inch/05_Portal_Padres_Recarga_SINPE.png new file mode 100644 index 0000000..b385d23 Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_5_inch/05_Portal_Padres_Recarga_SINPE.png differ diff --git a/screenshots/apple_app_store/iphone_6_5_inch/06_Punto_Venta_POS_Soda.png b/screenshots/apple_app_store/iphone_6_5_inch/06_Punto_Venta_POS_Soda.png new file mode 100644 index 0000000..8bfa966 Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_5_inch/06_Punto_Venta_POS_Soda.png differ diff --git a/screenshots/apple_app_store/iphone_6_5_inch/06_Recarga_SINPE_Movil.png b/screenshots/apple_app_store/iphone_6_5_inch/06_Recarga_SINPE_Movil.png new file mode 100644 index 0000000..4b80081 Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_5_inch/06_Recarga_SINPE_Movil.png differ diff --git a/screenshots/apple_app_store/iphone_6_5_inch/07_Terminal_POS_Caja_Soda.png b/screenshots/apple_app_store/iphone_6_5_inch/07_Terminal_POS_Caja_Soda.png new file mode 100644 index 0000000..399134a Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_5_inch/07_Terminal_POS_Caja_Soda.png differ diff --git a/screenshots/apple_app_store/iphone_6_7_inch/01_Bienvenida_Login_SiboPay.png b/screenshots/apple_app_store/iphone_6_7_inch/01_Bienvenida_Login_SiboPay.png new file mode 100644 index 0000000..3a81d6f Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_7_inch/01_Bienvenida_Login_SiboPay.png differ diff --git a/screenshots/apple_app_store/iphone_6_7_inch/02_Acceso_Seguro_BottomSheet.png b/screenshots/apple_app_store/iphone_6_7_inch/02_Acceso_Seguro_BottomSheet.png new file mode 100644 index 0000000..a989a24 Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_7_inch/02_Acceso_Seguro_BottomSheet.png differ diff --git a/screenshots/apple_app_store/iphone_6_7_inch/03_Carne_Digital_QR_Estudiante.png b/screenshots/apple_app_store/iphone_6_7_inch/03_Carne_Digital_QR_Estudiante.png new file mode 100644 index 0000000..349ac63 Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_7_inch/03_Carne_Digital_QR_Estudiante.png differ diff --git a/screenshots/apple_app_store/iphone_6_7_inch/04_Catalogo_Soda_Escolar.png b/screenshots/apple_app_store/iphone_6_7_inch/04_Catalogo_Soda_Escolar.png new file mode 100644 index 0000000..8b492bc Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_7_inch/04_Catalogo_Soda_Escolar.png differ diff --git a/screenshots/apple_app_store/iphone_6_7_inch/05_Portal_Padres_Monitoreo.png b/screenshots/apple_app_store/iphone_6_7_inch/05_Portal_Padres_Monitoreo.png new file mode 100644 index 0000000..d90134c Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_7_inch/05_Portal_Padres_Monitoreo.png differ diff --git a/screenshots/apple_app_store/iphone_6_7_inch/05_Portal_Padres_Recarga_SINPE.png b/screenshots/apple_app_store/iphone_6_7_inch/05_Portal_Padres_Recarga_SINPE.png new file mode 100644 index 0000000..fc6e213 Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_7_inch/05_Portal_Padres_Recarga_SINPE.png differ diff --git a/screenshots/apple_app_store/iphone_6_7_inch/06_Punto_Venta_POS_Soda.png b/screenshots/apple_app_store/iphone_6_7_inch/06_Punto_Venta_POS_Soda.png new file mode 100644 index 0000000..bb2702e Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_7_inch/06_Punto_Venta_POS_Soda.png differ diff --git a/screenshots/apple_app_store/iphone_6_7_inch/06_Recarga_SINPE_Movil.png b/screenshots/apple_app_store/iphone_6_7_inch/06_Recarga_SINPE_Movil.png new file mode 100644 index 0000000..684372c Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_7_inch/06_Recarga_SINPE_Movil.png differ diff --git a/screenshots/apple_app_store/iphone_6_7_inch/07_Terminal_POS_Caja_Soda.png b/screenshots/apple_app_store/iphone_6_7_inch/07_Terminal_POS_Caja_Soda.png new file mode 100644 index 0000000..fe4c593 Binary files /dev/null and b/screenshots/apple_app_store/iphone_6_7_inch/07_Terminal_POS_Caja_Soda.png differ diff --git a/screenshots/desktop_preview/Login_Desktop_Fondo_Animado.png b/screenshots/desktop_preview/Login_Desktop_Fondo_Animado.png new file mode 100644 index 0000000..1826881 Binary files /dev/null and b/screenshots/desktop_preview/Login_Desktop_Fondo_Animado.png differ diff --git a/screenshots/google_play_store/phone_1080x2400/01_Bienvenida_Login_SiboPay.png b/screenshots/google_play_store/phone_1080x2400/01_Bienvenida_Login_SiboPay.png new file mode 100644 index 0000000..6814fc7 Binary files /dev/null and b/screenshots/google_play_store/phone_1080x2400/01_Bienvenida_Login_SiboPay.png differ diff --git a/screenshots/google_play_store/phone_1080x2400/02_Acceso_Seguro_BottomSheet.png b/screenshots/google_play_store/phone_1080x2400/02_Acceso_Seguro_BottomSheet.png new file mode 100644 index 0000000..b2a7421 Binary files /dev/null and b/screenshots/google_play_store/phone_1080x2400/02_Acceso_Seguro_BottomSheet.png differ diff --git a/screenshots/google_play_store/phone_1080x2400/03_Carne_Digital_QR_Estudiante.png b/screenshots/google_play_store/phone_1080x2400/03_Carne_Digital_QR_Estudiante.png new file mode 100644 index 0000000..2a8814d Binary files /dev/null and b/screenshots/google_play_store/phone_1080x2400/03_Carne_Digital_QR_Estudiante.png differ diff --git a/screenshots/google_play_store/phone_1080x2400/04_Catalogo_Soda_Escolar.png b/screenshots/google_play_store/phone_1080x2400/04_Catalogo_Soda_Escolar.png new file mode 100644 index 0000000..fedef22 Binary files /dev/null and b/screenshots/google_play_store/phone_1080x2400/04_Catalogo_Soda_Escolar.png differ diff --git a/screenshots/google_play_store/phone_1080x2400/05_Portal_Padres_Monitoreo.png b/screenshots/google_play_store/phone_1080x2400/05_Portal_Padres_Monitoreo.png new file mode 100644 index 0000000..c693680 Binary files /dev/null and b/screenshots/google_play_store/phone_1080x2400/05_Portal_Padres_Monitoreo.png differ diff --git a/screenshots/google_play_store/phone_1080x2400/05_Portal_Padres_Recarga_SINPE.png b/screenshots/google_play_store/phone_1080x2400/05_Portal_Padres_Recarga_SINPE.png new file mode 100644 index 0000000..86c3c93 Binary files /dev/null and b/screenshots/google_play_store/phone_1080x2400/05_Portal_Padres_Recarga_SINPE.png differ diff --git a/screenshots/google_play_store/phone_1080x2400/06_Punto_Venta_POS_Soda.png b/screenshots/google_play_store/phone_1080x2400/06_Punto_Venta_POS_Soda.png new file mode 100644 index 0000000..315ce0e Binary files /dev/null and b/screenshots/google_play_store/phone_1080x2400/06_Punto_Venta_POS_Soda.png differ diff --git a/screenshots/google_play_store/phone_1080x2400/06_Recarga_SINPE_Movil.png b/screenshots/google_play_store/phone_1080x2400/06_Recarga_SINPE_Movil.png new file mode 100644 index 0000000..88da01b Binary files /dev/null and b/screenshots/google_play_store/phone_1080x2400/06_Recarga_SINPE_Movil.png differ diff --git a/screenshots/google_play_store/phone_1080x2400/07_Terminal_POS_Caja_Soda.png b/screenshots/google_play_store/phone_1080x2400/07_Terminal_POS_Caja_Soda.png new file mode 100644 index 0000000..60a031b Binary files /dev/null and b/screenshots/google_play_store/phone_1080x2400/07_Terminal_POS_Caja_Soda.png differ diff --git a/screenshots/login_clasico_roles/Login_Clasico_Rol_Estudiante.png b/screenshots/login_clasico_roles/Login_Clasico_Rol_Estudiante.png new file mode 100644 index 0000000..ab80774 Binary files /dev/null and b/screenshots/login_clasico_roles/Login_Clasico_Rol_Estudiante.png differ diff --git a/screenshots/login_clasico_roles/Login_Clasico_Rol_Personal_Cocina.png b/screenshots/login_clasico_roles/Login_Clasico_Rol_Personal_Cocina.png new file mode 100644 index 0000000..d72aef8 Binary files /dev/null and b/screenshots/login_clasico_roles/Login_Clasico_Rol_Personal_Cocina.png differ diff --git a/screenshots/login_clasico_roles/Login_Clasico_Roles_Padre_Estudiante_Personal.png b/screenshots/login_clasico_roles/Login_Clasico_Roles_Padre_Estudiante_Personal.png new file mode 100644 index 0000000..3a39e6a Binary files /dev/null and b/screenshots/login_clasico_roles/Login_Clasico_Roles_Padre_Estudiante_Personal.png differ diff --git a/scripts/capture_classic_login.js b/scripts/capture_classic_login.js new file mode 100644 index 0000000..3222eb9 --- /dev/null +++ b/scripts/capture_classic_login.js @@ -0,0 +1,45 @@ +const fs = require('fs'); +const path = require('path'); +const puppeteer = require('puppeteer-core'); + +const CHROME_PATH = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'; +const PREVIEW_URL = 'http://localhost:3030/templates/preview-login-clasico.html'; +const OUT_DIR = path.join(__dirname, '../screenshots/login_clasico_roles'); + +async function run() { + if (!fs.existsSync(OUT_DIR)) fs.mkdirSync(OUT_DIR, { recursive: true }); + + const browser = await puppeteer.launch({ + executablePath: CHROME_PATH, + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'] + }); + + const page = await browser.newPage(); + + // 1. Captura en resolución móvil moderna (1080 x 2400 px) + await page.setViewport({ width: 360, height: 800, deviceScaleFactor: 3 }); + await page.goto(PREVIEW_URL, { waitUntil: 'networkidle2' }); + const outMobile = path.join(OUT_DIR, 'Login_Clasico_Roles_Padre_Estudiante_Personal.png'); + await page.screenshot({ path: outMobile, type: 'png' }); + console.log('✓ Guardado screenshot móvil:', outMobile); + + // 2. Captura con rol Estudiante seleccionado + await page.evaluate(() => selectLoginRole('estudiante')); + await new Promise(r => setTimeout(r, 400)); + const outEstudiante = path.join(OUT_DIR, 'Login_Clasico_Rol_Estudiante.png'); + await page.screenshot({ path: outEstudiante, type: 'png' }); + console.log('✓ Guardado screenshot estudiante:', outEstudiante); + + // 3. Captura con rol Personal de cocina seleccionado + await page.evaluate(() => selectLoginRole('personal')); + await new Promise(r => setTimeout(r, 400)); + const outPersonal = path.join(OUT_DIR, 'Login_Clasico_Rol_Personal_Cocina.png'); + await page.screenshot({ path: outPersonal, type: 'png' }); + console.log('✓ Guardado screenshot personal cocina:', outPersonal); + + await browser.close(); + console.log('¡Capturas del inicio de sesión clásico generadas con éxito!'); +} + +run().catch(console.error); diff --git a/scripts/generate_store_screenshots.js b/scripts/generate_store_screenshots.js new file mode 100644 index 0000000..f8086c6 --- /dev/null +++ b/scripts/generate_store_screenshots.js @@ -0,0 +1,264 @@ +const fs = require('fs'); +const path = require('path'); +const puppeteer = require('puppeteer-core'); + +const CHROME_PATH = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'; +const APP_URL = 'http://localhost:3030/app'; +const POS_URL = 'http://localhost:3030/pos.html'; + +const BASE_OUT_DIR = path.join(__dirname, '../screenshots'); + +// Especificaciones oficiales exigidas por Apple App Store Connect y Google Play Console +const PRESETS = [ + { + name: 'apple_app_store/iphone_6_7_inch', + description: 'iPhone 6.7" (iPhone 16 / 15 / 14 Pro Max) - 1290 x 2796 px', + width: 430, + height: 932, + scale: 3, + expectedRes: '1290 x 2796' + }, + { + name: 'apple_app_store/iphone_6_5_inch', + description: 'iPhone 6.5" (iPhone 11 Pro Max / XS Max / XR) - 1242 x 2688 px', + width: 414, + height: 896, + scale: 3, + expectedRes: '1242 x 2688' + }, + { + name: 'google_play_store/phone_1080x2400', + description: 'Android Phone Google Play (FHD+ 20:9) - 1080 x 2400 px', + width: 360, + height: 800, + scale: 3, + expectedRes: '1080 x 2400' + }, + { + name: 'apple_app_store/ipad_pro_12_9_inch', + description: 'iPad Pro 12.9" (App Store Tablet) - 2048 x 2732 px', + width: 1024, + height: 1366, + scale: 2, + expectedRes: '2048 x 2732' + } +]; + +const sleep = (ms) => new Promise(r => setTimeout(r, ms)); + +// Sanitización y anonimización de nombres reales para screenshots oficiales de tiendas +async function anonymizeNamesInPage(page) { + await page.evaluate(() => { + const walkTextNodes = (root) => { + const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null, false); + let node; + while ((node = walker.nextNode())) { + if (!node.nodeValue) continue; + let txt = node.nodeValue; + txt = txt.replace(/Mateo Alvarado Castro/gi, 'Nombre del Estudiante'); + txt = txt.replace(/Mateo Castro Alvarado/gi, 'Nombre del Estudiante'); + txt = txt.replace(/Carlos Alvarado \(Papá\)/gi, 'Nombre de los Padres'); + txt = txt.replace(/Carlos Alvarado/gi, 'Nombre del Padre'); + txt = txt.replace(/QR-MATEO-/gi, 'QR-ESTUDIANTE-'); + if (txt !== node.nodeValue) { + node.nodeValue = txt; + } + } + }; + + // 1. Reemplazos globales en todos los nodos de texto + walkTextNodes(document.body); + + // 2. Tarjeta del Estudiante en Menú Principal + const walletName = document.getElementById('walletName'); + if (walletName) walletName.textContent = 'Nombre del Estudiante'; + + const walletAvatar = document.getElementById('walletAvatar'); + if (walletAvatar) walletAvatar.textContent = 'NE'; + + // 3. Modal de Carné QR + const qrCardTitle = document.querySelector('.qr-card-header-title'); + if (qrCardTitle) { + let sub = document.getElementById('qrStudentNameHeader'); + if (!sub) { + sub = document.createElement('div'); + sub.id = 'qrStudentNameHeader'; + sub.style.cssText = 'font-size: 0.95rem; font-weight: 800; color: #0284c7; margin-top: 4px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;'; + qrCardTitle.parentNode.insertBefore(sub, qrCardTitle.nextSibling); + } + sub.textContent = 'Nombre del Estudiante'; + } + + const qrToken = document.getElementById('qrTokenDisplay'); + if (qrToken) { + qrToken.textContent = qrToken.textContent.replace(/MATEO/g, 'ESTUDIANTE'); + } + + // 4. Portal de Padres: Cabecera + const parentLoggedName = document.getElementById('parentLoggedName'); + if (parentLoggedName) { + parentLoggedName.textContent = 'Nombre de los Padres (Padre/Madre)'; + } + + // 5. Portal de Padres: Estudiante seleccionado + const parentActiveChildName = document.getElementById('parentActiveChildName'); + if (parentActiveChildName) { + parentActiveChildName.textContent = 'Nombre del Estudiante'; + } + + // 6. Portal de Padres: Fichas de Hijos e iniciales + document.querySelectorAll('#viewPadres div, #viewPadres span, #viewPadres strong, #viewPadres h4').forEach(el => { + if (el.children.length === 0 && el.textContent.trim() === 'MA') { + el.textContent = 'NE'; + } + }); + + document.querySelectorAll('#parentHijosList > div, .parent-child-card').forEach(card => { + const strong = card.querySelector('strong'); + if (strong && (strong.textContent.includes('Mateo') || strong.textContent.includes('Alvarado'))) { + strong.textContent = 'Nombre del Estudiante'; + } + }); + + // 7. Subvista SINPE Móvil + const sinpeBanner = document.querySelector('#parentSubViewSinpe'); + if (sinpeBanner) { + walkTextNodes(sinpeBanner); + sinpeBanner.querySelectorAll('div, span, button').forEach(el => { + if (el.textContent.trim() === 'MA') el.textContent = 'NE'; + }); + } + + // Pasada final de seguridad + walkTextNodes(document.body); + }); +} + +async function captureScreen(page, outPath) { + const dir = path.dirname(outPath); + if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true }); + await page.screenshot({ path: outPath, type: 'png' }); + const buf = fs.readFileSync(outPath); + const w = buf.readUInt32BE(16); + const h = buf.readUInt32BE(20); + const kb = Math.round(buf.length / 1024); + console.log(` ✓ Guardado: ${path.basename(outPath)} (${w}x${h} px, ${kb} KB)`); +} + +async function run() { + console.log('========================================================================'); + console.log('📸 GENERADOR DE SCREENSHOTS OFICIALES ANONIMIZADOS (APPLE & GOOGLE STORE)'); + console.log('========================================================================\n'); + + const browser = await puppeteer.launch({ + executablePath: CHROME_PATH, + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox', '--hide-scrollbars'] + }); + + for (const preset of PRESETS) { + console.log(`\n📱 Procesando preset: ${preset.description}`); + const outDir = path.join(BASE_OUT_DIR, preset.name); + if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true }); + + const page = await browser.newPage(); + await page.setViewport({ + width: preset.width, + height: preset.height, + deviceScaleFactor: preset.scale + }); + + // ------------------------------------------------------------- + // 1. PANTALLA DE BIENVENIDA / SPLASH LOGIN + // ------------------------------------------------------------- + await page.goto(APP_URL, { waitUntil: 'networkidle2' }); + await page.evaluate(() => localStorage.clear()); + await page.reload({ waitUntil: 'networkidle2' }); + await sleep(700); + await anonymizeNamesInPage(page); + await captureScreen(page, path.join(outDir, '01_Bienvenida_Login_SiboPay.png')); + + // ------------------------------------------------------------- + // 2. MODAL INFERIOR (BOTTOM SHEET) INICIO DE SESIÓN + // ------------------------------------------------------------- + await page.evaluate(() => { + if (typeof openLoginSheet === 'function') openLoginSheet('login'); + }); + await sleep(600); + await anonymizeNamesInPage(page); + await captureScreen(page, path.join(outDir, '02_Acceso_Seguro_BottomSheet.png')); + + // ------------------------------------------------------------- + // 3. MONEDERO ESTUDIANTIL & CARNÉ QR (ANONIMIZADO) + // ------------------------------------------------------------- + await page.evaluate(async () => { + document.getElementById('loginUsername').value = 'mateo'; + document.getElementById('loginPassword').value = '1234'; + await handleLoginSubmit(); + }); + await sleep(1500); + + // Abrir Modal de Carné QR + await page.evaluate(() => { + if (typeof openQrModal === 'function') openQrModal(); + }); + await sleep(800); + await anonymizeNamesInPage(page); + await captureScreen(page, path.join(outDir, '03_Carne_Digital_QR_Estudiante.png')); + + // ------------------------------------------------------------- + // 4. CATÁLOGO DE LA SODA ESCOLAR & PRODUCTOS (ANONIMIZADO) + // ------------------------------------------------------------- + await page.evaluate(() => { + if (typeof closeQrModal === 'function') closeQrModal(); + }); + await sleep(600); + await anonymizeNamesInPage(page); + await captureScreen(page, path.join(outDir, '04_Catalogo_Soda_Escolar.png')); + + // ------------------------------------------------------------- + // 5. PORTAL PARENTAL (MONITOREO DE HIJOS Y SALDOS ANONIMIZADOS) + // ------------------------------------------------------------- + await page.evaluate(() => localStorage.clear()); + await page.reload({ waitUntil: 'networkidle2' }); + await page.evaluate(async () => { + document.getElementById('loginUsername').value = 'padre'; + document.getElementById('loginPassword').value = 'padre123'; + await handleLoginSubmit(); + }); + await sleep(1800); + await anonymizeNamesInPage(page); + await captureScreen(page, path.join(outDir, '05_Portal_Padres_Monitoreo.png')); + + // ------------------------------------------------------------- + // 6. RECARGA OFICIAL POR SINPE MÓVIL (ANONIMIZADO) + // ------------------------------------------------------------- + await page.evaluate(() => { + if (typeof openParentSubView === 'function') openParentSubView('sinpe'); + }); + await sleep(800); + await anonymizeNamesInPage(page); + await captureScreen(page, path.join(outDir, '06_Recarga_SINPE_Movil.png')); + + // ------------------------------------------------------------- + // 7. TERMINAL POS Y CAJA RÁPIDA DE LA SODA ESCOLAR + // ------------------------------------------------------------- + await page.goto(POS_URL, { waitUntil: 'networkidle2' }); + await sleep(1200); + await anonymizeNamesInPage(page); + await captureScreen(page, path.join(outDir, '07_Terminal_POS_Caja_Soda.png')); + + await page.close(); + } + + await browser.close(); + console.log('\n========================================================================'); + console.log('🎉 ¡TODOS LOS SCREENSHOTS ANONIMIZADOS FUERON GENERADOS CON ÉXITO!'); + console.log(`📁 Carpeta principal: ${BASE_OUT_DIR}`); + console.log('========================================================================\n'); +} + +run().catch(err => { + console.error('Error fatal durante la generación de screenshots:', err); + process.exit(1); +}); diff --git a/scripts/migrate_sqlite.js b/scripts/migrate_sqlite.js new file mode 100644 index 0000000..22e2df4 --- /dev/null +++ b/scripts/migrate_sqlite.js @@ -0,0 +1,39 @@ +const db = require('../server/db'); + +try { + db.db.exec(` + CREATE TABLE IF NOT EXISTS escuelas ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + codigo TEXT UNIQUE NOT NULL, + nombre TEXT NOT NULL, + telefono_sinpe TEXT DEFAULT '8888-8888', + nombre_sinpe TEXT DEFAULT 'Soda Central', + concesionario TEXT, + activo INTEGER DEFAULT 1, + creado_en DATETIME DEFAULT CURRENT_TIMESTAMP + ); + INSERT OR IGNORE INTO escuelas (id, codigo, nombre, telefono_sinpe, nombre_sinpe, concesionario, activo) + VALUES (1, 'ESC01', 'Soda Escolar Central', '8888-8888', 'Soda Central', 'Concesionario Central', 1); + `); + + // Column additions if missing + const cols = [ + { table: 'estudiantes', col: 'escuela_id', type: 'INTEGER DEFAULT 1' }, + { table: 'productos', col: 'escuela_id', type: 'INTEGER DEFAULT 1' }, + { table: 'ordenes', col: 'escuela_id', type: 'INTEGER DEFAULT 1' }, + { table: 'usuarios', col: 'escuela_id', type: 'INTEGER DEFAULT 1' }, + { table: 'solicitudes_recarga_sinpe', col: 'escuela_id', type: 'INTEGER DEFAULT 1' } + ]; + + for (const c of cols) { + try { + db.db.exec(`ALTER TABLE ${c.table} ADD COLUMN ${c.col} ${c.type};`); + } catch (e) { + // Column might already exist + } + } + + console.log('SQLite local database migration completed successfully!'); +} catch (err) { + console.error('Migration error:', err); +} diff --git a/scripts/test_desktop_animated_login.js b/scripts/test_desktop_animated_login.js new file mode 100644 index 0000000..5d04340 --- /dev/null +++ b/scripts/test_desktop_animated_login.js @@ -0,0 +1,58 @@ +const path = require('path'); +const puppeteer = require('puppeteer-core'); +const express = require('express'); + +const CHROME_PATH = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'; +const PORT = 3033; +const OUT_DIR = path.join(__dirname, '../screenshots/desktop_preview'); + +async function main() { + const fs = require('fs'); + if (!fs.existsSync(OUT_DIR)) fs.mkdirSync(OUT_DIR, { recursive: true }); + + const app = express(); + app.use(express.static(path.join(__dirname, '../public'))); + + const server = app.listen(PORT, async () => { + console.log(`Server listening on port ${PORT}`); + try { + const browser = await puppeteer.launch({ + executablePath: CHROME_PATH, + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'] + }); + + const page = await browser.newPage(); + await page.setViewport({ width: 1920, height: 1080, deviceScaleFactor: 1 }); + await page.goto(`http://localhost:${PORT}/index.html`, { waitUntil: 'networkidle2' }); + + // Verify computed style of .splash-doodle-bg + const animInfo = await page.evaluate(() => { + const el = document.querySelector('.splash-doodle-bg'); + if (!el) return null; + const style = window.getComputedStyle(el); + return { + animation: style.animation, + animationName: style.animationName, + animationDuration: style.animationDuration, + backgroundSize: style.backgroundSize + }; + }); + console.log('Animation Info:', animInfo); + + const outPath = path.join(OUT_DIR, 'Login_Desktop_Fondo_Animado.png'); + await page.screenshot({ path: outPath, type: 'png' }); + console.log('✓ Guardado screenshot desktop:', outPath); + + await browser.close(); + server.close(); + process.exit(0); + } catch (err) { + console.error(err); + server.close(); + process.exit(1); + } + }); +} + +main(); diff --git a/server/sinpeImapService.js b/server/sinpeImapService.js new file mode 100644 index 0000000..48f604f --- /dev/null +++ b/server/sinpeImapService.js @@ -0,0 +1,189 @@ +/** + * Servicio de Lectura y Conciliación IMAP de Notificaciones SINPE Móvil para SiboPay + */ + +const imapSimple = require('imap-simple'); +const { simpleParser } = require('mailparser'); +const { parseSinpeEmail, normalizarCodigoDetalle } = require('./sinpeParser'); + +let isChecking = false; + +const getImapConfig = () => { + const cleanPassword = (process.env.SINPE_EMAIL_PASSWORD || '').replace(/\s+/g, ''); + return { + imap: { + user: process.env.SINPE_EMAIL_USER || '', + password: cleanPassword, + host: process.env.SINPE_IMAP_HOST || 'imap.gmail.com', + port: parseInt(process.env.SINPE_IMAP_PORT || '993', 10), + tls: true, + authTimeout: 10000, + tlsOptions: { rejectUnauthorized: false } + } + }; +}; + +/** + * Escanea la bandeja de entrada buscando los correos más recientes de notificación SINPE + * y los guarda en la base de datos de transacciones. + */ +async function checkSinpeEmailsOnce(db) { + if (isChecking) return { scanned: 0, status: 'already_running' }; + + const user = process.env.SINPE_EMAIL_USER; + const pass = process.env.SINPE_EMAIL_PASSWORD; + const isEnabled = process.env.SINPE_IMAP_ENABLED === 'true' || process.env.SINPE_IMAP_ENABLED === '1'; + + if (!isEnabled || !user || !pass) { + return { scanned: 0, status: 'disabled_or_unconfigured' }; + } + + isChecking = true; + let connection = null; + let savedCount = 0; + + try { + const config = getImapConfig(); + connection = await imapSimple.connect(config); + const box = await connection.openBox('INBOX'); + + const totalMessages = (box && box.messages && box.messages.total) || 0; + if (totalMessages === 0) { + return { scanned: 0, status: 'empty_inbox' }; + } + + // Consultar los últimos 25 correos + const startSeq = Math.max(1, totalMessages - 24); + const searchCriteria = [`${startSeq}:${totalMessages}`]; + const fetchOptions = { + bodies: ['HEADER', 'TEXT', ''], + markSeen: false, + struct: true + }; + + const messages = await connection.search(searchCriteria, fetchOptions); + + if (messages && messages.length > 0) { + for (const msg of messages) { + try { + const headerPart = msg.parts.find(p => p.which === 'HEADER'); + const rawHeader = headerPart ? headerPart.body : {}; + let subject = Array.isArray(rawHeader.subject) ? rawHeader.subject[0] : (rawHeader.subject || ''); + let from = Array.isArray(rawHeader.from) ? rawHeader.from[0] : (rawHeader.from || ''); + + const allPart = msg.parts.find(p => p.which === '' || p.which === 'TEXT'); + let bodyText = ''; + let bodyHtml = ''; + + if (allPart && allPart.body) { + const parsed = await simpleParser(allPart.body); + bodyText = parsed.text || ''; + bodyHtml = parsed.html || ''; + if (parsed.subject) subject = parsed.subject; + if (parsed.from && parsed.from.text) from = parsed.from.text; + } + + const parsedSinpe = parseSinpeEmail(subject, bodyText, bodyHtml, from); + + if (parsedSinpe.isSinpe && parsedSinpe.amountCrc > 0) { + const txId = `sinpe_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`; + const normCod = parsedSinpe.codigoDetalleNormalizado || ''; + const refNum = parsedSinpe.referenceNumber || (normCod ? `REF-${normCod}` : `TX-${Date.now()}`); + + // Insertar o ignorar si ya existe + try { + if (db) { + const existing = db.prepare(` + SELECT id FROM sinpe_transacciones_banco + WHERE (codigo_detalle_norm = ? AND codigo_detalle_norm IS NOT NULL AND codigo_detalle_norm != '') + OR (reference_number = ? AND reference_number IS NOT NULL AND reference_number != '') + LIMIT 1 + `).get(normCod || '__none__', refNum); + + if (!existing) { + db.prepare(` + INSERT INTO sinpe_transacciones_banco + (id, reference_number, codigo_detalle, codigo_detalle_norm, amount_crc, sender_phone, sender_name, origin_bank, status, raw_data) + VALUES + (?, ?, ?, ?, ?, ?, ?, ?, 'unclaimed', ?) + `).run( + txId, + refNum, + parsedSinpe.codigoDetalle || null, + normCod || null, + parsedSinpe.amountCrc, + parsedSinpe.senderPhone || null, + parsedSinpe.senderName || 'Cliente SINPE', + parsedSinpe.originBank || 'SINPE Móvil', + JSON.stringify({ from, subject, summary: parsedSinpe.rawSummary }) + ); + savedCount++; + console.log(`💵 [SINPE IMAP] Notificación registrada: ₡${parsedSinpe.amountCrc} | Código: ${parsedSinpe.codigoDetalle || 'N/A'} | Ref: #${refNum} | Banco: ${parsedSinpe.originBank}`); + } + } + } catch (dbErr) { + console.warn('⚠️ [SINPE IMAP] Error al persistir en BD:', dbErr.message); + } + } + } catch (msgErr) { + console.warn('⚠️ [SINPE IMAP] Error procesando correo:', msgErr.message); + } + } + } + + return { scanned: messages ? messages.length : 0, saved: savedCount, status: 'ok' }; + } catch (err) { + console.error('❌ [SINPE IMAP] Error de conexión:', err.message); + return { scanned: 0, status: 'error', error: err.message }; + } finally { + if (connection) { + try { connection.end(); } catch (_) {} + } + isChecking = false; + } +} + +/** + * Inserta manualmente una transacción simulada (útil para pruebas inmediatas en QA o sin transferir dinero real) + */ +function simularSinpeEmail(db, { codigo, codigoDetalle, monto, banco, remitente, telefono, comprobante }) { + if (!db) throw new Error('DB no inicializada'); + const txId = `sim_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`; + const rawCod = codigo || codigoDetalle || null; + const cleanCod = rawCod ? String(rawCod).trim() : null; + const normCod = cleanCod ? normalizarCodigoDetalle(cleanCod) : null; + const refNum = comprobante ? String(comprobante).trim() : (normCod ? `REF-${normCod}` : `SIM-${Date.now()}`); + const montoNum = parseInt(monto, 10) || 1000; + + db.prepare(` + INSERT INTO sinpe_transacciones_banco + (id, reference_number, codigo_detalle, codigo_detalle_norm, amount_crc, sender_phone, sender_name, origin_bank, status, raw_data) + VALUES + (?, ?, ?, ?, ?, ?, ?, ?, 'unclaimed', ?) + `).run( + txId, + refNum, + cleanCod, + normCod, + montoNum, + telefono || '8888-1122', + remitente || 'Padre de Familia', + banco || 'BAC Credomatic', + JSON.stringify({ simulado: true, fecha: new Date().toISOString() }) + ); + + return { + id: txId, + codigo_detalle: cleanCod, + codigo_detalle_norm: normCod, + reference_number: refNum, + amount_crc: montoNum, + origin_bank: banco || 'BAC Credomatic', + sender_name: remitente || 'Padre de Familia' + }; +} + +module.exports = { + checkSinpeEmailsOnce, + simularSinpeEmail +}; diff --git a/server/sinpeParser.js b/server/sinpeParser.js new file mode 100644 index 0000000..abccec1 --- /dev/null +++ b/server/sinpeParser.js @@ -0,0 +1,184 @@ +/** + * Parser de Notificaciones Bancarias de SINPE Móvil (Costa Rica) para SiboPay + * Extrae: + * - Códigos de detalle SiboPay (SIBO-XXXX o SIBOXXXX) con tolerancia total a guiones/espacios/mayúsculas + * - Montos en colones (₡ / CRC) + * - Números de comprobante / referencia bancaria + * - Banco de origen (BAC, BCR, BNCR, Promerica, Davivienda, Scotiabank, etc.) + * - Teléfono y nombre del remitente + */ + +function stripHtml(html = '') { + return String(html) + .replace(/]*>[\s\S]*?<\/style>/gi, '') + .replace(/]*>[\s\S]*?<\/script>/gi, '') + .replace(/<[^>]+>/g, ' ') + .replace(/ /gi, ' ') + .replace(/&/gi, '&') + .replace(/</gi, '<') + .replace(/>/gi, '>') + .replace(/\s+/g, ' ') + .trim(); +} + +/** + * Normaliza un código de SINPE para comparación tolerante + * Ejemplos: "SIBO-7K9M", "sibo7k9m", "SIBO 7k9m", "sibo-7k9m" -> "SIBO7K9M" + */ +function normalizarCodigoDetalle(codigo = '') { + if (!codigo) return ''; + const str = String(codigo).trim(); + const match = str.match(/\bSIBO[\s\-_]?([A-Za-z0-9]{3,8})\b/i) || str.match(/SIBO[\s\-_]?([A-Za-z0-9]{3,8})/i); + if (match) { + return `SIBO${match[1].toUpperCase()}`; + } + return str.replace(/[\s\-_]/g, '').toUpperCase(); +} + +function parseSinpeEmail(arg1 = '', bodyText = '', bodyHtml = '', from = '') { + let subject = ''; + let text = ''; + let html = ''; + let cleanFrom = ''; + + if (typeof arg1 === 'object' && arg1 !== null) { + subject = arg1.subject || ''; + text = arg1.text || arg1.bodyText || ''; + html = arg1.html || arg1.bodyHtml || ''; + cleanFrom = String(arg1.from || '').toLowerCase(); + } else { + subject = String(arg1 || ''); + text = String(bodyText || ''); + html = String(bodyHtml || ''); + cleanFrom = String(from || '').toLowerCase(); + } + + const fullText = `${subject}\n${text}\n${stripHtml(html)}`.trim(); + const lowerText = fullText.toLowerCase(); + + // 1. Detección de Banco de Costa Rica + let originBank = 'SINPE Móvil CR'; + if (cleanFrom.includes('bac') || lowerText.includes('bac credomatic') || lowerText.includes('bac san jose')) { + originBank = 'BAC Credomatic'; + } else if (cleanFrom.includes('bncr') || lowerText.includes('banco nacional') || lowerText.includes('bn móvil') || lowerText.includes('bn movil')) { + originBank = 'Banco Nacional (BNCR)'; + } else if (cleanFrom.includes('bancobcr') || cleanFrom.includes('bcr') || lowerText.includes('banco de costa rica')) { + originBank = 'Banco de Costa Rica (BCR)'; + } else if (cleanFrom.includes('promerica') || lowerText.includes('promerica')) { + originBank = 'Banco Promerica'; + } else if (cleanFrom.includes('scotiabank') || lowerText.includes('scotiabank')) { + originBank = 'Scotiabank'; + } else if (cleanFrom.includes('davivienda') || lowerText.includes('davivienda')) { + originBank = 'Davivienda'; + } else if (cleanFrom.includes('wink') || cleanFrom.includes('coopenae') || lowerText.includes('wink')) { + originBank = 'Wink (Coopenae)'; + } else if (cleanFrom.includes('sibopay') || cleanFrom.includes('simulad')) { + originBank = 'SiboPay Direct'; + } + + // 2. Extraer Código de Detalle SiboPay (Tolerancia total a guión, espacios o todo pegado) + let codigoDetalle = null; + const codigoRegex = /\bSIBO[\s\-_]?([A-Za-z0-9]{3,8})\b/i; + const matchCodigo = fullText.match(codigoRegex) || fullText.match(/SIBO[\s\-_]?([A-Za-z0-9]{3,8})/i); + if (matchCodigo) { + codigoDetalle = `SIBO-${matchCodigo[1].toUpperCase()}`; + } + + // 3. Extraer Monto en Colones (₡ / CRC / ¢) + let amountCrc = 0; + const amountPatterns = [ + /(?:monto|importe|valor|suma|por concepto de|total|cr[eé]dito|acreditad[oa]|recibid[oa]|transferid[oa])\s*(?:de|por)?\s*[:#=\-]?\s*(?:₡|¢|CRC)?\s*([0-9]+(?:[,.\s][0-9]+)*)\s*(?:colones|crc|¢|₡)?/i, + /(?:₡|¢|CRC)\s*[:#=\-]?\s*([0-9]+(?:[,.\s][0-9]+)*)/i, + /([0-9]+(?:[,.\s][0-9]+)*)\s*(?:colones|crc|¢|₡)/i, + /(?:crc|colones)\s*[:#=\-]?\s*([0-9]+(?:[,.\s][0-9]+)*)/i + ]; + + for (const regex of amountPatterns) { + const match = fullText.match(regex); + if (match && match[1]) { + let numStr = match[1].trim().replace(/\s+/g, ''); + if (numStr.includes('.') && numStr.includes(',')) { + if (numStr.indexOf('.') < numStr.indexOf(',')) { + numStr = numStr.replace(/\./g, '').replace(',', '.'); + } else { + numStr = numStr.replace(/,/g, ''); + } + } else if (numStr.includes(',')) { + const parts = numStr.split(','); + if (parts[1] && parts[1].length === 2) { + numStr = parts[0] + '.' + parts[1]; + } else { + numStr = numStr.replace(/,/g, ''); + } + } + const parsedNum = parseFloat(numStr); + if (!isNaN(parsedNum) && parsedNum > 0) { + amountCrc = Math.round(parsedNum); + break; + } + } + } + + // 4. Extraer Teléfono Emisor (8 dígitos) + let senderPhone = null; + const phonePatterns = [ + /(?:tel[eé]fono|origen|celular|m[oó]vil|remitente|emisor)\s*[:#=\-]?\s*(?:\+?506\s*[-.]?)?([245678]\d{3}[-\s.]?\d{4})/i, + /(?:\+?506\s*[-.]?)?([245678]\d{3}[-\s.]?\d{4})/i + ]; + for (const regex of phonePatterns) { + const match = fullText.match(regex); + if (match && match[1]) { + const digits = match[1].replace(/\D/g, ''); + if (digits.length === 8) { + senderPhone = `${digits.slice(0, 4)}-${digits.slice(4)}`; + break; + } + } + } + + // 5. Extraer Número de Comprobante / Referencia Bancaria + let referenceNumber = null; + const refPatterns = [ + /(?:n[uú]mero\s*(?:de\s*)?|n[o°º]\.?\s*(?:de\s*)?|c[oó]digo\s*(?:de\s*)?)?(?:comprobante|referencia|transacci[oó]n|autorizaci[oó]n|operaci[oó]n|documento|folio|confirmaci[oó]n|trf|ref|doc|aut)(?:\s+de\s+(?:transferencia|pago|operaci[oó]n|dep[oó]sito|transacci[oó]n))?\s*[:#=\.\-]?\s*([A-Za-z0-9\-_]{4,35})/i, + /#\s*([A-Za-z0-9\-_]{4,24})/, + /(?:SINPE|TRF|DOC|REF|AUT)[-_]?([0-9]{4,20})/i + ]; + for (const regex of refPatterns) { + const match = fullText.match(regex); + if (match && match[1]) { + const clean = match[1].trim(); + if (!clean.toUpperCase().startsWith('SIBO') && clean.length >= 4) { + referenceNumber = clean; + break; + } + } + } + + // 6. Nombre del remitente si está disponible + let senderName = null; + const nameMatch = fullText.match(/(?:de|de parte de|remitente|ordenante|cliente|titular)\s*[:#=\-]?\s*([A-Za-zÀ-ÿ\s]{4,40})(?:\n|\r|\.|,|-)/i); + if (nameMatch && nameMatch[1]) { + const cand = nameMatch[1].trim(); + if (!cand.toLowerCase().includes('banco') && !cand.toLowerCase().includes('sinpe')) { + senderName = cand; + } + } + + return { + isSinpe: Boolean(amountCrc > 0 && (codigoDetalle || referenceNumber || originBank !== 'SINPE Móvil CR')), + codigoDetalle, + codigoDetalleNormalizado: codigoDetalle ? normalizarCodigoDetalle(codigoDetalle) : null, + amount: amountCrc, + amountCrc, + referenceNumber: referenceNumber || (codigoDetalle ? `REF-${codigoDetalle.replace(/[^A-Za-z0-9]/g, '')}` : null), + senderPhone: senderPhone || '', + senderName: senderName || 'Cliente SINPE', + originBank, + rawSummary: subject || '' + }; +} + +module.exports = { + parseSinpeEmail, + normalizarCodigoDetalle +};