diff --git a/admin/package-lock.json b/admin/package-lock.json
index 7f9e31c..394c7d2 100644
--- a/admin/package-lock.json
+++ b/admin/package-lock.json
@@ -8,11 +8,13 @@
"name": "@mep/admin",
"version": "0.1.0",
"dependencies": {
+ "qrcode": "^1.5.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.30.6"
},
"devDependencies": {
+ "@types/qrcode": "^1.5.6",
"@types/react": "^18.3.31",
"@types/react-dom": "^18.3.7",
"@vitejs/plugin-react": "^4.7.0",
@@ -1220,6 +1222,16 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@types/node": {
+ "version": "26.6.4",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.4.tgz",
+ "integrity": "sha512-ldVPDCzj7fsaGZrLB0NuHuTvJcsNasysBAqMolr/cgxrLd1xbqxIr3XJiPnHHJUCxj5sNF1vnRj9aWnrVh5Jcg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "undici-types": "~8.9.0"
+ }
+ },
"node_modules/@types/prop-types": {
"version": "15.7.15",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz",
@@ -1227,6 +1239,16 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@types/qrcode": {
+ "version": "1.5.6",
+ "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz",
+ "integrity": "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@types/react": {
"version": "18.3.31",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.31.tgz",
@@ -1269,6 +1291,30 @@
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
}
},
+ "node_modules/ansi-regex": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
+ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/ansi-styles": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "license": "MIT",
+ "dependencies": {
+ "color-convert": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
"node_modules/baseline-browser-mapping": {
"version": "2.11.27",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.27.tgz",
@@ -1316,6 +1362,15 @@
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
}
},
+ "node_modules/camelcase": {
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
+ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/caniuse-lite": {
"version": "1.0.30001814",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001814.tgz",
@@ -1337,6 +1392,35 @@
],
"license": "CC-BY-4.0"
},
+ "node_modules/cliui": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
+ "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
+ "license": "ISC",
+ "dependencies": {
+ "string-width": "^4.2.0",
+ "strip-ansi": "^6.0.0",
+ "wrap-ansi": "^6.2.0"
+ }
+ },
+ "node_modules/color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "license": "MIT",
+ "dependencies": {
+ "color-name": "~1.1.4"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ }
+ },
+ "node_modules/color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "license": "MIT"
+ },
"node_modules/convert-source-map": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
@@ -1369,6 +1453,21 @@
}
}
},
+ "node_modules/decamelize": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
+ "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/dijkstrajs": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz",
+ "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==",
+ "license": "MIT"
+ },
"node_modules/electron-to-chromium": {
"version": "1.5.445",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.445.tgz",
@@ -1376,6 +1475,12 @@
"dev": true,
"license": "ISC"
},
+ "node_modules/emoji-regex": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
+ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
+ "license": "MIT"
+ },
"node_modules/esbuild": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
@@ -1425,6 +1530,19 @@
"node": ">=6"
}
},
+ "node_modules/find-up": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
+ "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
+ "license": "MIT",
+ "dependencies": {
+ "locate-path": "^5.0.0",
+ "path-exists": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@@ -1450,6 +1568,24 @@
"node": ">=6.9.0"
}
},
+ "node_modules/get-caller-file": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
+ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
+ "license": "ISC",
+ "engines": {
+ "node": "6.* || 8.* || >= 10.*"
+ }
+ },
+ "node_modules/is-fullwidth-code-point": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
+ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -1482,6 +1618,18 @@
"node": ">=6"
}
},
+ "node_modules/locate-path": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
+ "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
+ "license": "MIT",
+ "dependencies": {
+ "p-locate": "^4.1.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
@@ -1540,6 +1688,51 @@
"node": ">=18"
}
},
+ "node_modules/p-limit": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
+ "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
+ "license": "MIT",
+ "dependencies": {
+ "p-try": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/p-locate": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
+ "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
+ "license": "MIT",
+ "dependencies": {
+ "p-limit": "^2.2.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/p-try": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
+ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/path-exists": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
+ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
@@ -1547,6 +1740,15 @@
"dev": true,
"license": "ISC"
},
+ "node_modules/pngjs": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",
+ "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.13.0"
+ }
+ },
"node_modules/postcss": {
"version": "8.5.29",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.29.tgz",
@@ -1576,6 +1778,23 @@
"node": "^10 || ^12 || >=14"
}
},
+ "node_modules/qrcode": {
+ "version": "1.5.4",
+ "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",
+ "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==",
+ "license": "MIT",
+ "dependencies": {
+ "dijkstrajs": "^1.0.1",
+ "pngjs": "^5.0.0",
+ "yargs": "^15.3.1"
+ },
+ "bin": {
+ "qrcode": "bin/qrcode"
+ },
+ "engines": {
+ "node": ">=10.13.0"
+ }
+ },
"node_modules/react": {
"version": "18.3.1",
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
@@ -1643,6 +1862,21 @@
"react-dom": ">=16.8"
}
},
+ "node_modules/require-directory": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
+ "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/require-main-filename": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
+ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
+ "license": "ISC"
+ },
"node_modules/rollup": {
"version": "4.64.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.64.0.tgz",
@@ -1708,6 +1942,12 @@
"semver": "bin/semver.js"
}
},
+ "node_modules/set-blocking": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
+ "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
+ "license": "ISC"
+ },
"node_modules/source-map-js": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",
@@ -1718,6 +1958,32 @@
"node": ">=0.10.0"
}
},
+ "node_modules/string-width": {
+ "version": "4.2.3",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
+ "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
+ "license": "MIT",
+ "dependencies": {
+ "emoji-regex": "^8.0.0",
+ "is-fullwidth-code-point": "^3.0.0",
+ "strip-ansi": "^6.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/strip-ansi": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
+ "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
+ "license": "MIT",
+ "dependencies": {
+ "ansi-regex": "^5.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/typescript": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
@@ -1732,6 +1998,13 @@
"node": ">=14.17"
}
},
+ "node_modules/undici-types": {
+ "version": "8.9.0",
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz",
+ "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/update-browserslist-db": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz",
@@ -1823,12 +2096,73 @@
}
}
},
+ "node_modules/which-module": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz",
+ "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==",
+ "license": "ISC"
+ },
+ "node_modules/wrap-ansi": {
+ "version": "6.2.0",
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
+ "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
+ "license": "MIT",
+ "dependencies": {
+ "ansi-styles": "^4.0.0",
+ "string-width": "^4.1.0",
+ "strip-ansi": "^6.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/y18n": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
+ "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
+ "license": "ISC"
+ },
"node_modules/yallist": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
"dev": true,
"license": "ISC"
+ },
+ "node_modules/yargs": {
+ "version": "15.4.1",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
+ "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
+ "license": "MIT",
+ "dependencies": {
+ "cliui": "^6.0.0",
+ "decamelize": "^1.2.0",
+ "find-up": "^4.1.0",
+ "get-caller-file": "^2.0.1",
+ "require-directory": "^2.1.1",
+ "require-main-filename": "^2.0.0",
+ "set-blocking": "^2.0.0",
+ "string-width": "^4.2.0",
+ "which-module": "^2.0.0",
+ "y18n": "^4.0.0",
+ "yargs-parser": "^18.1.2"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/yargs-parser": {
+ "version": "18.1.3",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
+ "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
+ "license": "ISC",
+ "dependencies": {
+ "camelcase": "^5.0.0",
+ "decamelize": "^1.2.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
}
}
}
diff --git a/admin/package.json b/admin/package.json
index 767c536..2d282b8 100644
--- a/admin/package.json
+++ b/admin/package.json
@@ -10,11 +10,13 @@
"preview": "vite preview"
},
"dependencies": {
+ "qrcode": "^1.5.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.30.6"
},
"devDependencies": {
+ "@types/qrcode": "^1.5.6",
"@types/react": "^18.3.31",
"@types/react-dom": "^18.3.7",
"@vitejs/plugin-react": "^4.7.0",
diff --git a/admin/src/api.ts b/admin/src/api.ts
index 938071a..377c6dd 100644
--- a/admin/src/api.ts
+++ b/admin/src/api.ts
@@ -143,6 +143,8 @@ export interface StoreListItem extends Store {
export interface StoreDetail extends Store {
counts: { cards: number; staff: number; transactions: number };
subscription: { status: SubscriptionStatus } | null;
+ /** Lien encodé dans le QR d'inscription. */
+ enrollUrl: string;
}
export type PointsMode = 'AMOUNT' | 'STAMP';
diff --git a/admin/src/components/Poster.tsx b/admin/src/components/Poster.tsx
new file mode 100644
index 0000000..bdd400a
--- /dev/null
+++ b/admin/src/components/Poster.tsx
@@ -0,0 +1,76 @@
+import { useEffect, useState } from 'react';
+import QRCode from 'qrcode';
+
+export type PosterFormat = 'A5' | 'A6';
+
+export interface PosterProps {
+ format: PosterFormat;
+ url: string;
+ storeName: string;
+ programName: string;
+ logoUrl: string | null;
+ backgroundColor: string;
+ foregroundColor: string;
+ labelColor: string;
+}
+
+/** Dimensions en mm (impression) et tailles de texte, d'après la maquette « Affichette comptoir ». */
+const SIZES = {
+ A5: { w: 148, h: 210, pad: 12, logo: 14, store: 6, eyebrow: 3.8, title: 10, qr: 66, body: 4.5, small: 4 },
+ A6: { w: 105, h: 148, pad: 8, logo: 10, store: 4.5, eyebrow: 3, title: 7, qr: 46, body: 3.4, small: 3.1 },
+};
+
+export function Poster(p: PosterProps) {
+ const s = SIZES[p.format];
+ const [svg, setSvg] = useState('');
+
+ useEffect(() => {
+ // Correction d'erreur élevée : le QR reste lisible même un peu abîmé ou mal éclairé.
+ QRCode.toString(p.url, { type: 'svg', errorCorrectionLevel: 'Q', margin: 0, color: { dark: '#111111', light: '#FFFFFF' } }).then(setSvg);
+ }, [p.url]);
+
+ const mm = (v: number) => `${v}mm`;
+ return (
+
+
+ {p.logoUrl &&
}
+
{p.storeName}
+
+
+ {p.programName}
+
+ Scannez pour obtenir votre carte de fidélité
+
+
+
+
+ Ajoutez-la à Apple Wallet ou Google Wallet.
+ Gratuit, sans application à télécharger.
+
+
+ );
+}
diff --git a/admin/src/main.tsx b/admin/src/main.tsx
index d4b8408..8fe7a63 100644
--- a/admin/src/main.tsx
+++ b/admin/src/main.tsx
@@ -7,6 +7,7 @@ import { LoginPage } from './pages/LoginPage';
import { StoresPage } from './pages/StoresPage';
import { NewStorePage } from './pages/NewStorePage';
import { StorePage } from './pages/StorePage';
+import { PosterPage } from './pages/PosterPage';
import './styles.css';
function App() {
@@ -30,6 +31,7 @@ function App() {
}
return (
+ } />
}>
} />
} />
diff --git a/admin/src/pages/CardWizard.tsx b/admin/src/pages/CardWizard.tsx
index 366b868..d5c8269 100644
--- a/admin/src/pages/CardWizard.tsx
+++ b/admin/src/pages/CardWizard.tsx
@@ -1,6 +1,8 @@
import { ChangeEvent, useEffect, useState } from 'react';
import { api, assetUrl, CardDesign, Reward, StoreDetail } from '../api';
+import { Link } from 'react-router-dom';
import { ApplePreview, GooglePreview } from '../components/WalletPreview';
+import { Poster } from '../components/Poster';
import { contrast, dominantColor, prepareLogo, prepareStrip } from '../components/images';
const STEPS = ['Identité', 'Couleurs', 'Règle de points', 'Récompenses', 'Récapitulatif'];
@@ -230,10 +232,34 @@ export function CardWizard({ store, onSaved }: { store: StoreDetail; onSaved: ()
Récompenses : {draft.rewards.filter((r) => r.active !== false).map((r) => `${r.label} (${r.cost})`).join(', ') || 'aucune'}
Logo : {images.logoUrl ? 'oui' : manquant } · Bandeau : {images.stripUrl ? 'oui' : 'non'}
-
- Le QR d'inscription imprimable sera disponible ici dès que la page d'inscription client sera en place.
-
- {store.status === 'DRAFT' && Utilisez le bouton Activer en haut de la fiche pour ouvrir le programme.
}
+ Affichette du comptoir
+
+
+ {/* Aperçu réduit de l'affichette A5 (148 mm → 222 px) */}
+
+
+
+
Le QR mène à la page d'inscription :
+
{store.enrollUrl}
+
Imprimer l'affichette (A5 / A6)
+
+
+ {store.status === 'DRAFT' && (
+
+ Utilisez le bouton Activer en haut de la fiche pour ouvrir le programme (logo obligatoire).
+
+ )}
>
)}
diff --git a/admin/src/pages/PosterPage.tsx b/admin/src/pages/PosterPage.tsx
new file mode 100644
index 0000000..268b8c2
--- /dev/null
+++ b/admin/src/pages/PosterPage.tsx
@@ -0,0 +1,60 @@
+import { useEffect, useState } from 'react';
+import { Link, useParams, useSearchParams } from 'react-router-dom';
+import { api, assetUrl, CardDesign, StoreDetail } from '../api';
+import { Poster, PosterFormat } from '../components/Poster';
+
+/** Page d'impression de l'affichette, sans la mise en page de l'admin. */
+export function PosterPage() {
+ const { id } = useParams<{ id: string }>();
+ const [params, setParams] = useSearchParams();
+ const format: PosterFormat = params.get('format') === 'A6' ? 'A6' : 'A5';
+ const [store, setStore] = useState(null);
+ const [design, setDesign] = useState(null);
+ const [error, setError] = useState(null);
+
+ useEffect(() => {
+ Promise.all([api.get(`/api/admin/stores/${id}`), api.get(`/api/admin/stores/${id}/card-design`)])
+ .then(([s, d]) => {
+ setStore(s);
+ setDesign(d);
+ })
+ .catch((e) => setError(e.message));
+ }, [id]);
+
+ if (error) return {error}
;
+ if (!store) return Chargement…
;
+ if (!design) return Concevez d'abord la carte de fidélité.
;
+
+ return (
+
+
+
+
← Retour à la carte
+
+ {(['A5', 'A6'] as const).map((f) => (
+ setParams({ format: f })}>{f}
+ ))}
+ window.print()}>Imprimer
+
+
+ {store.status !== 'ACTIVE' && (
+
+ Le magasin n'est pas actif : le QR mène pour l'instant à une page « introuvable » ou « indisponible ».
+
+ )}
+
+
{store.enrollUrl}
+
+ );
+}
diff --git a/backend/.env.example b/backend/.env.example
index 788a03c..50fbb65 100644
--- a/backend/.env.example
+++ b/backend/.env.example
@@ -7,3 +7,25 @@ JWT_REFRESH_SECRET=dev-refresh-secret
CORS_ORIGINS=http://localhost:5173
SEED_ADMIN_EMAIL=
SEED_ADMIN_PASSWORD=
+
+# URL publique de l'API (QR d'inscription, liens e-mail, images Google Wallet) — HTTPS en production
+PUBLIC_URL=http://localhost:3100
+
+# Apple Wallet — fichiers PEM hors du dépôt (voir docs/wallet.md)
+APPLE_PASS_TYPE_ID=
+APPLE_TEAM_ID=
+APPLE_SIGNER_CERT=
+APPLE_SIGNER_KEY=
+APPLE_SIGNER_KEY_PASSPHRASE=
+APPLE_WWDR_CERT=
+
+# Google Wallet
+GOOGLE_WALLET_ISSUER_ID=
+GOOGLE_WALLET_SA_FILE=
+
+# E-mails (sans SMTP_HOST, les e-mails sont écrits dans les logs)
+SMTP_HOST=
+SMTP_PORT=587
+SMTP_USER=
+SMTP_PASS=
+MAIL_FROM="MonEspacePro "
diff --git a/backend/package-lock.json b/backend/package-lock.json
index dbb231e..8058880 100644
--- a/backend/package-lock.json
+++ b/backend/package-lock.json
@@ -22,6 +22,10 @@
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"helmet": "^8.3.0",
+ "jimp": "^1.6.1",
+ "jose": "^6.2.12",
+ "nodemailer": "^7.0.13",
+ "passkit-generator": "^3.6.1",
"passport": "^0.7.0",
"passport-jwt": "^4.0.1",
"reflect-metadata": "^0.2.2",
@@ -33,6 +37,7 @@
"@types/express": "^5.0.0",
"@types/multer": "^2.3.0",
"@types/node": "^22.7.4",
+ "@types/nodemailer": "^8.0.2",
"@types/passport-jwt": "^4.0.1",
"prisma": "^5.20.0",
"ts-node": "^10.9.2",
@@ -258,6 +263,21 @@
"node": ">=12"
}
},
+ "node_modules/@hapi/hoek": {
+ "version": "9.3.0",
+ "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz",
+ "integrity": "sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@hapi/topo": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.1.0.tgz",
+ "integrity": "sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@hapi/hoek": "^9.0.0"
+ }
+ },
"node_modules/@isaacs/cliui": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
@@ -361,6 +381,488 @@
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
+ "node_modules/@jimp/core": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/core/-/core-1.6.1.tgz",
+ "integrity": "sha512-+BoKC5G6hkrSy501zcJ2EpfnllP+avPevcBfRcZe/CW+EwEfY6X1EZ8QWyT7NpDIvEEJb1fdJnMMfUnFkxmw9A==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/file-ops": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "await-to-js": "^3.0.0",
+ "exif-parser": "^0.1.12",
+ "file-type": "^21.3.3",
+ "mime": "3"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/core/node_modules/@tokenizer/inflate": {
+ "version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/@tokenizer/inflate/-/inflate-0.4.1.tgz",
+ "integrity": "sha512-2mAv+8pkG6GIZiF1kNg1jAjh27IDxEPKwdGul3snfztFerfPGI1LjDezZp3i7BElXompqEtPmoPx6c2wgtWsOA==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "^4.4.3",
+ "token-types": "^6.1.1"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/Borewit"
+ }
+ },
+ "node_modules/@jimp/core/node_modules/debug": {
+ "version": "4.4.3",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
+ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "^2.1.3"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@jimp/core/node_modules/file-type": {
+ "version": "21.3.4",
+ "resolved": "https://registry.npmjs.org/file-type/-/file-type-21.3.4.tgz",
+ "integrity": "sha512-Ievi/yy8DS3ygGvT47PjSfdFoX+2isQueoYP1cntFW1JLYAuS4GD7NUPGg4zv2iZfV52uDyk5w5Z0TdpRS6Q1g==",
+ "license": "MIT",
+ "dependencies": {
+ "@tokenizer/inflate": "^0.4.1",
+ "strtok3": "^10.3.4",
+ "token-types": "^6.1.1",
+ "uint8array-extras": "^1.4.0"
+ },
+ "engines": {
+ "node": ">=20"
+ },
+ "funding": {
+ "url": "https://github.com/sindresorhus/file-type?sponsor=1"
+ }
+ },
+ "node_modules/@jimp/core/node_modules/mime": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz",
+ "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==",
+ "license": "MIT",
+ "bin": {
+ "mime": "cli.js"
+ },
+ "engines": {
+ "node": ">=10.0.0"
+ }
+ },
+ "node_modules/@jimp/core/node_modules/ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+ "license": "MIT"
+ },
+ "node_modules/@jimp/diff": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/diff/-/diff-1.6.1.tgz",
+ "integrity": "sha512-YkKDPdHjLgo1Api3+Bhc0GLAygldlpt97NfOKoNg1U6IUNXA6X2MgosCjPfSBiSvJvrrz1fsIR+/4cfYXBI/HQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/plugin-resize": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "pixelmatch": "^5.3.0"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/file-ops": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/file-ops/-/file-ops-1.6.1.tgz",
+ "integrity": "sha512-T+gX6osHjprbDRad0/B71Evyre7ZdVY1z/gFGEG9Z8KOtZPKboWvPeP2UjbZYWQLy9UKCPQX1FNAnDiOPkJL7w==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/js-bmp": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/js-bmp/-/js-bmp-1.6.1.tgz",
+ "integrity": "sha512-xzWzNT4/u5zGrTT3Tme9sGU7YzIKxi13+BCQwLqACbt5DXf9SAfdzRkopZQnmDko+6In5nqaT89Gjs43/WdnYQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "bmp-ts": "^1.0.9"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/js-gif": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/js-gif/-/js-gif-1.6.1.tgz",
+ "integrity": "sha512-YjY2W26rQa05XhanYhRZ7dingCiNN+T2Ymb1JiigIbABY0B28wHE3v3Cf1/HZPWGu0hOg36ylaKgV5KxF2M58w==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "gifwrap": "^0.10.1",
+ "omggif": "^1.0.10"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/js-jpeg": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/js-jpeg/-/js-jpeg-1.6.1.tgz",
+ "integrity": "sha512-HT9H3yOmlOFzYmdI15IYdfy6ggQhSRIaHeA+OTJSEORXBqEo97sUZu/DsgHIcX5NJ7TkJBTgZ9BZXsV6UbsyMg==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "jpeg-js": "^0.4.4"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/js-png": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/js-png/-/js-png-1.6.1.tgz",
+ "integrity": "sha512-SZ/KVhI5UjcSzzlXsXdIi/LhJ7UShf2NkMOtVrbZQcGzsqNtynAelrOXeoTxcanfVqmNhAoVHg8yR2cYoqrYjA==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "pngjs": "^7.0.0"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/js-tiff": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/js-tiff/-/js-tiff-1.6.1.tgz",
+ "integrity": "sha512-jDG/eJquID1M4MBlKMmDRBmz2TpXMv7TUyu2nIRUxhlUc2ogC82T+VQUkca9GJH1BBJ9dx5sSE5dGkWNjIbZxw==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "utif2": "^4.1.0"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-blit": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-blit/-/plugin-blit-1.6.1.tgz",
+ "integrity": "sha512-MwnI7C7K81uWddY9FLw1fCOIy6SsPIUftUz36Spt7jisCn8/40DhQMlSxpxTNelnZb/2SnloFimQfRZAmHLOqQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-blur": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-blur/-/plugin-blur-1.6.1.tgz",
+ "integrity": "sha512-lIo7Tzp5jQu30EFFSK/phXANK3citKVEjepDjQ6ljHoIFtuMRrnybnmI2Md24ulvWlDaz+hh3n6qrMb8ydwhZQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/utils": "1.6.1"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-circle": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-circle/-/plugin-circle-1.6.1.tgz",
+ "integrity": "sha512-kK1PavY6cKHNNKce37vdV4Tmpc1/zDKngGoeOV3j+EMatoHFZUinV3s6F9aWryPs3A0xhCLZgdJ6Zeea1d5LCQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/types": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-color": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-color/-/plugin-color-1.6.1.tgz",
+ "integrity": "sha512-LtUN1vAP+LRlZAtTNVhDRSiXx+26Kbz3zJaG6a5k59gQ95jgT5mknnF8lxkHcqJthM4MEk3/tPxkdJpEybyF/A==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "tinycolor2": "^1.6.0",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-contain": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-contain/-/plugin-contain-1.6.1.tgz",
+ "integrity": "sha512-m0qhrfA8jkTqretGv4w+T/ADFR4GwBpE0sCOC2uJ0dzr44/ddOMsIdrpi89kabqYiPYIrxkgdCVCLm3zn1Vkkg==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/plugin-blit": "1.6.1",
+ "@jimp/plugin-resize": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-cover": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-cover/-/plugin-cover-1.6.1.tgz",
+ "integrity": "sha512-hZytnsth0zoll6cPf434BrT+p/v569Wr5tyO6Dp0dH1IDPhzhB5F38sZGMLDo7bzQiN9JFVB3fxkcJ/WYCJ3Mg==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/plugin-crop": "1.6.1",
+ "@jimp/plugin-resize": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-crop": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-crop/-/plugin-crop-1.6.1.tgz",
+ "integrity": "sha512-EerRSLlclXyKDnYc/H9w/1amZW7b7v3OGi/VlerPd2M/pAu5X8TkyYWtfqYCXnNp1Ixtd8oCo9zGfY9zoXT4rg==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-displace": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-displace/-/plugin-displace-1.6.1.tgz",
+ "integrity": "sha512-K07QVl7xQwIfD6KfxRV/c3E9e7ZBXxUXdWuvoTWcKHL2qV48MOF5Nqbz/aJW4ThnQARIsxvYlZjPFiqkCjlU+g==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-dither": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-dither/-/plugin-dither-1.6.1.tgz",
+ "integrity": "sha512-+2V+GCV2WycMoX1/z977TkZ8Zq/4MVSKElHYatgUqtwXMi2fDK2gKYU2g9V39IqFvTJsTIsK0+58VFz/ROBVew==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/types": "1.6.1"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-fisheye": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-fisheye/-/plugin-fisheye-1.6.1.tgz",
+ "integrity": "sha512-XtS5ZyoZ0vxZxJ6gkqI63SivhtI58vX95foMPM+cyzYkRsJXMOYCr8DScxF5bp4Xr003NjYm/P+7+08tibwzHA==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-flip": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-flip/-/plugin-flip-1.6.1.tgz",
+ "integrity": "sha512-ws38W/sGj7LobNRayQ83garxiktOyWxM5vO/y4a/2cy9v65SLEUzVkrj+oeAaUSSObdz4HcCEla7XtGlnAGAaA==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/types": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-hash": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-hash/-/plugin-hash-1.6.1.tgz",
+ "integrity": "sha512-sZt6ZcMX6i8vFWb4GYnw0pR/o9++ef0dTVcboTB5B/g7nrxCODIB4wfEkJ/YqZM5wUvol77K1qeS0/rVO6z21A==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/js-bmp": "1.6.1",
+ "@jimp/js-jpeg": "1.6.1",
+ "@jimp/js-png": "1.6.1",
+ "@jimp/js-tiff": "1.6.1",
+ "@jimp/plugin-color": "1.6.1",
+ "@jimp/plugin-resize": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "any-base": "^1.1.0"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-mask": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-mask/-/plugin-mask-1.6.1.tgz",
+ "integrity": "sha512-SIG0/FcmEj3tkwFxc7fAGLO8o4uNzMpSOdQOhbCgxefQKq5wOVMk9BQx/sdMPBwtMLr9WLq0GzLA/rk6t2v20A==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/types": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-print": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-print/-/plugin-print-1.6.1.tgz",
+ "integrity": "sha512-BYVz/X3Xzv8XYilVeDy11NOp0h7BTDjlOtu0BekIFHP1yHVd24AXNzbOy52XlzYZWQ0Dl36HOHEpl/nSNrzc6w==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/js-jpeg": "1.6.1",
+ "@jimp/js-png": "1.6.1",
+ "@jimp/plugin-blit": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "parse-bmfont-ascii": "^1.0.6",
+ "parse-bmfont-binary": "^1.0.6",
+ "parse-bmfont-xml": "^1.1.6",
+ "simple-xml-to-json": "^1.2.2",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-quantize": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-quantize/-/plugin-quantize-1.6.1.tgz",
+ "integrity": "sha512-J2En9PLURfP+vwYDtuZ9T8yBW6BWYZBScydAjRiPBmJfEhTcNQqiiQODrZf7EqbbX/Sy5H6dAeRiqkgoV9N6Ww==",
+ "license": "MIT",
+ "dependencies": {
+ "image-q": "^4.0.0",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-resize": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-resize/-/plugin-resize-1.6.1.tgz",
+ "integrity": "sha512-CLkrtJoIz2HdWnpYiN6p8KYcPc00rCH/SUu6o+lfZL05Q4uhecJlnvXuj9x+U6mDn3ldPmJj6aZqMHuUJzdVqg==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-rotate": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-rotate/-/plugin-rotate-1.6.1.tgz",
+ "integrity": "sha512-nOjVjbbj705B02ksysKnh0POAwEBXZtJ9zQ5qC+X7Tavl3JNn+P3BzQovbBxLPSbUSld6XID9z5ijin4PtOAUg==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/plugin-crop": "1.6.1",
+ "@jimp/plugin-resize": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/plugin-threshold": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/plugin-threshold/-/plugin-threshold-1.6.1.tgz",
+ "integrity": "sha512-JOKv9F8s6tnVLf4sB/2fF0F339EFnHvgEdFYugO6VhowKLsap0pEZmLyE/DlRnYtIj2RddHZVxVMp/eKJ04l2Q==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/plugin-color": "1.6.1",
+ "@jimp/plugin-hash": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1",
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/types": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/types/-/types-1.6.1.tgz",
+ "integrity": "sha512-leI7YbveTNi565m910XgIOwXyuu074H5qazAD1357HImJSv2hqxnWXpwxQbadGWZ7goZRYBDZy5lpqud0p7q5w==",
+ "license": "MIT",
+ "dependencies": {
+ "zod": "^3.23.8"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jimp/utils": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@jimp/utils/-/utils-1.6.1.tgz",
+ "integrity": "sha512-veFPRd93FCnS7AgmCkPgARVGoDRrJ9cm1ujuNyA+UfQ5VKbED2002sm5XfFLFwTsKC8j04heTrwe+tU1dluXOw==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/types": "1.6.1",
+ "tinycolor2": "^1.6.0"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.13",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
@@ -806,6 +1308,27 @@
"@prisma/debug": "5.22.0"
}
},
+ "node_modules/@sideway/address": {
+ "version": "4.1.5",
+ "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.5.tgz",
+ "integrity": "sha512-IqO/DUQHUkPeixNQ8n0JA6102hT9CmaljNTPmQ1u8MEhBo/R4Q8eKLN/vGZxuebwOroDB4cbpjheD4+/sKFK4Q==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@hapi/hoek": "^9.0.0"
+ }
+ },
+ "node_modules/@sideway/formula": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/@sideway/formula/-/formula-3.0.1.tgz",
+ "integrity": "sha512-/poHZJJVjx3L+zVD6g9KgHfYnb443oi7wLu/XKojDviHy6HOEOA6z1Trk5aR1dGcmPenJEgb2sK2I80LeS3MIg==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@sideway/pinpoint": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz",
+ "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==",
+ "license": "BSD-3-Clause"
+ },
"node_modules/@tokenizer/inflate": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/@tokenizer/inflate/-/inflate-0.2.7.tgz",
@@ -998,6 +1521,16 @@
"undici-types": "~6.21.0"
}
},
+ "node_modules/@types/nodemailer": {
+ "version": "8.0.2",
+ "resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-8.0.2.tgz",
+ "integrity": "sha512-c7M5ox8p0nEOfbJ2E9Qcmt8/QCu/VzsiAhzBiZbvky2PhKZDHpKB3sQHBM5MEZNkCfBOaS6S9//AGPRTNB7IaA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@types/passport": {
"version": "1.0.17",
"resolved": "https://registry.npmjs.org/@types/passport/-/passport-1.0.17.tgz",
@@ -1384,6 +1917,12 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
+ "node_modules/any-base": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/any-base/-/any-base-1.1.0.tgz",
+ "integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg==",
+ "license": "MIT"
+ },
"node_modules/anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
@@ -1459,6 +1998,15 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/await-to-js": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/await-to-js/-/await-to-js-3.0.0.tgz",
+ "integrity": "sha512-zJAaP9zxTcvTHRlejau3ZOY4V7SRpiByf3/dxx2uyKxxor19tpmpV2QRsTKikckwhaPmr2dVpxxMr7jOCYVp5g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@@ -1525,6 +2073,12 @@
"readable-stream": "^3.4.0"
}
},
+ "node_modules/bmp-ts": {
+ "version": "1.0.9",
+ "resolved": "https://registry.npmjs.org/bmp-ts/-/bmp-ts-1.0.9.tgz",
+ "integrity": "sha512-cTEHk2jLrPyi+12M3dhpEbnnPOsaZuq7C45ylbbQIiWgDFZq4UVYPEY5mlqjvsj/6gJv9qX5sa+ebDzLXT28Vw==",
+ "license": "MIT"
+ },
"node_modules/body-parser": {
"version": "1.20.4",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz",
@@ -2137,6 +2691,12 @@
"node": ">=0.3.1"
}
},
+ "node_modules/do-not-zip": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/do-not-zip/-/do-not-zip-1.0.0.tgz",
+ "integrity": "sha512-Pgd81ET43bhAGaN2Hq1zluSX1FmD7kl7KcV9ER/lawiLsRUB9pRA5y8r6us29Xk6BrINZETO8TjhYwtwafWUww==",
+ "license": "MIT"
+ },
"node_modules/dotenv": {
"version": "16.4.5",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
@@ -2384,6 +2944,11 @@
"node": ">=0.8.x"
}
},
+ "node_modules/exif-parser": {
+ "version": "0.1.12",
+ "resolved": "https://registry.npmjs.org/exif-parser/-/exif-parser-0.1.12.tgz",
+ "integrity": "sha512-c2bQfLNbMzLPmzQuOr8fy0csy84WmwnER81W88DzTp9CYNPJ6yzOj2EZAh9pywYpqHnshVLHQJ8WzldAyfY+Iw=="
+ },
"node_modules/express": {
"version": "4.22.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz",
@@ -2705,6 +3270,16 @@
"node": ">= 0.4"
}
},
+ "node_modules/gifwrap": {
+ "version": "0.10.1",
+ "resolved": "https://registry.npmjs.org/gifwrap/-/gifwrap-0.10.1.tgz",
+ "integrity": "sha512-2760b1vpJHNmLzZ/ubTtNnEx5WApN/PYWJvXvgS+tL1egTTthayFYIQQNi136FLEDcN/IyEY2EcGpIITD6eYUw==",
+ "license": "MIT",
+ "dependencies": {
+ "image-q": "^4.0.0",
+ "omggif": "^1.0.10"
+ }
+ },
"node_modules/glob": {
"version": "10.4.5",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz",
@@ -2912,6 +3487,21 @@
],
"license": "BSD-3-Clause"
},
+ "node_modules/image-q": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/image-q/-/image-q-4.0.0.tgz",
+ "integrity": "sha512-PfJGVgIfKQJuq3s0tTDOKtztksibuUEbJQIYT3by6wctQo+Rdlh7ef4evJ5NCdxY4CfMbvFkocEwbl4BF8RlJw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "16.9.1"
+ }
+ },
+ "node_modules/image-q/node_modules/@types/node": {
+ "version": "16.9.1",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz",
+ "integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==",
+ "license": "MIT"
+ },
"node_modules/import-fresh": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
@@ -3120,6 +3710,72 @@
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
+ "node_modules/jimp": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/jimp/-/jimp-1.6.1.tgz",
+ "integrity": "sha512-hNQh6rZtWfSVWSNVmvq87N5BPJsNH7k7I7qyrXf9DOma9xATQk3fsyHazCQe51nCjdkoWdTmh0vD7bjVSLoxxw==",
+ "license": "MIT",
+ "dependencies": {
+ "@jimp/core": "1.6.1",
+ "@jimp/diff": "1.6.1",
+ "@jimp/js-bmp": "1.6.1",
+ "@jimp/js-gif": "1.6.1",
+ "@jimp/js-jpeg": "1.6.1",
+ "@jimp/js-png": "1.6.1",
+ "@jimp/js-tiff": "1.6.1",
+ "@jimp/plugin-blit": "1.6.1",
+ "@jimp/plugin-blur": "1.6.1",
+ "@jimp/plugin-circle": "1.6.1",
+ "@jimp/plugin-color": "1.6.1",
+ "@jimp/plugin-contain": "1.6.1",
+ "@jimp/plugin-cover": "1.6.1",
+ "@jimp/plugin-crop": "1.6.1",
+ "@jimp/plugin-displace": "1.6.1",
+ "@jimp/plugin-dither": "1.6.1",
+ "@jimp/plugin-fisheye": "1.6.1",
+ "@jimp/plugin-flip": "1.6.1",
+ "@jimp/plugin-hash": "1.6.1",
+ "@jimp/plugin-mask": "1.6.1",
+ "@jimp/plugin-print": "1.6.1",
+ "@jimp/plugin-quantize": "1.6.1",
+ "@jimp/plugin-resize": "1.6.1",
+ "@jimp/plugin-rotate": "1.6.1",
+ "@jimp/plugin-threshold": "1.6.1",
+ "@jimp/types": "1.6.1",
+ "@jimp/utils": "1.6.1"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/joi": {
+ "version": "17.13.4",
+ "resolved": "https://registry.npmjs.org/joi/-/joi-17.13.4.tgz",
+ "integrity": "sha512-1RuuER6kmt8K8I3nIWvPZKi5RQCb568ZPyY4Pwjlua+yo+63ZTmIwxLZH0heBmiKN4uxjvCiarDrjaeH84xicQ==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@hapi/hoek": "^9.3.0",
+ "@hapi/topo": "^5.1.0",
+ "@sideway/address": "^4.1.5",
+ "@sideway/formula": "^3.0.1",
+ "@sideway/pinpoint": "^2.0.0"
+ }
+ },
+ "node_modules/jose": {
+ "version": "6.2.12",
+ "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.12.tgz",
+ "integrity": "sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/panva"
+ }
+ },
+ "node_modules/jpeg-js": {
+ "version": "0.4.4",
+ "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.4.4.tgz",
+ "integrity": "sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==",
+ "license": "BSD-3-Clause"
+ },
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -3601,6 +4257,15 @@
}
}
},
+ "node_modules/node-forge": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.0.tgz",
+ "integrity": "sha512-LarFH0+6VfriEhqMMcLX2F7SwSXeWwnEAJEsYm5QKWchiVYVvJyV9v7UDvUv+w5HO23ZpQTXDv/GxdDdMyOuoQ==",
+ "license": "(BSD-3-Clause OR GPL-2.0)",
+ "engines": {
+ "node": ">= 6.13.0"
+ }
+ },
"node_modules/node-gyp-build": {
"version": "4.8.4",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz",
@@ -3622,6 +4287,15 @@
"node": ">=18"
}
},
+ "node_modules/nodemailer": {
+ "version": "7.0.13",
+ "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.13.tgz",
+ "integrity": "sha512-PNDFSJdP+KFgdsG3ZzMXCgquO7I6McjY2vlqILjtJd0hy8wEvtugS9xKRF2NWlPNGxvLCXlTNIae4serI7dinw==",
+ "license": "MIT-0",
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@@ -3653,6 +4327,12 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/omggif": {
+ "version": "1.0.10",
+ "resolved": "https://registry.npmjs.org/omggif/-/omggif-1.0.10.tgz",
+ "integrity": "sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw==",
+ "license": "MIT"
+ },
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
@@ -3722,6 +4402,12 @@
"dev": true,
"license": "BlueOak-1.0.0"
},
+ "node_modules/pako": {
+ "version": "1.0.11",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
+ "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==",
+ "license": "(MIT AND Zlib)"
+ },
"node_modules/parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
@@ -3735,6 +4421,28 @@
"node": ">=6"
}
},
+ "node_modules/parse-bmfont-ascii": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/parse-bmfont-ascii/-/parse-bmfont-ascii-1.0.6.tgz",
+ "integrity": "sha512-U4RrVsUFCleIOBsIGYOMKjn9PavsGOXxbvYGtMOEfnId0SVNsgehXh1DxUdVPLoxd5mvcEtvmKs2Mmf0Mpa1ZA==",
+ "license": "MIT"
+ },
+ "node_modules/parse-bmfont-binary": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/parse-bmfont-binary/-/parse-bmfont-binary-1.0.6.tgz",
+ "integrity": "sha512-GxmsRea0wdGdYthjuUeWTMWPqm2+FAd4GI8vCvhgJsFnoGhTrLhXDDupwTo7rXVAgaLIGoVHDZS9p/5XbSqeWA==",
+ "license": "MIT"
+ },
+ "node_modules/parse-bmfont-xml": {
+ "version": "1.1.6",
+ "resolved": "https://registry.npmjs.org/parse-bmfont-xml/-/parse-bmfont-xml-1.1.6.tgz",
+ "integrity": "sha512-0cEliVMZEhrFDwMh4SxIyVJpqYoOWDJ9P895tFuS+XuNzI5UBmBk5U5O4KuJdTnZpSBI4LFA2+ZiJaiwfSwlMA==",
+ "license": "MIT",
+ "dependencies": {
+ "xml-parse-from-string": "^1.0.0",
+ "xml2js": "^0.5.0"
+ }
+ },
"node_modules/parse-json": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz",
@@ -3763,6 +4471,21 @@
"node": ">= 0.8"
}
},
+ "node_modules/passkit-generator": {
+ "version": "3.6.1",
+ "resolved": "https://registry.npmjs.org/passkit-generator/-/passkit-generator-3.6.1.tgz",
+ "integrity": "sha512-HSAKRMtQydsP65fj09O+UuLlzQWfWlziUjpETTT7P7w/DAlSlC3iHPTrw58nNgFbMDN5lLj2VoI+NvJLGgXvOQ==",
+ "license": "MIT",
+ "dependencies": {
+ "do-not-zip": "^1.0.0",
+ "joi": "17.13.4",
+ "node-forge": "^1.4.0",
+ "tslib": "^2.7.0"
+ },
+ "engines": {
+ "node": ">=14.21.3"
+ }
+ },
"node_modules/passport": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/passport/-/passport-0.7.0.tgz",
@@ -3867,6 +4590,27 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
+ "node_modules/pixelmatch": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-5.3.0.tgz",
+ "integrity": "sha512-o8mkY4E/+LNUf6LzX96ht6k6CEDi65k9G2rjMtBe9Oo+VPKSvl+0GKHuH/AlG+GA5LPG/i5hrekkxUc3s2HU+Q==",
+ "license": "ISC",
+ "dependencies": {
+ "pngjs": "^6.0.0"
+ },
+ "bin": {
+ "pixelmatch": "bin/pixelmatch"
+ }
+ },
+ "node_modules/pixelmatch/node_modules/pngjs": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-6.0.0.tgz",
+ "integrity": "sha512-TRzzuFRRmEoSW/p1KVAmiOgPco2Irlah+bGFCeNfJXxxYGwSw7YwAOAcd7X28K/m5bjBWKsC29KyoMfHbypayg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.13.0"
+ }
+ },
"node_modules/pluralize": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz",
@@ -3877,6 +4621,15 @@
"node": ">=4"
}
},
+ "node_modules/pngjs": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-7.0.0.tgz",
+ "integrity": "sha512-LKWqWJRhstyYo9pGvgor/ivk2w94eSjE3RGVuzLGlr3NmD8bf7RcYGze1mNdEHRP6TRP6rMuDHk5t44hnTRyow==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=14.19.0"
+ }
+ },
"node_modules/prisma": {
"version": "5.22.0",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-5.22.0.tgz",
@@ -4105,6 +4858,15 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
+ "node_modules/sax": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/sax/-/sax-1.6.1.tgz",
+ "integrity": "sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==",
+ "license": "BlueOak-1.0.0",
+ "engines": {
+ "node": ">=11.0.0"
+ }
+ },
"node_modules/schema-utils": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz",
@@ -4347,6 +5109,15 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/simple-xml-to-json": {
+ "version": "1.2.7",
+ "resolved": "https://registry.npmjs.org/simple-xml-to-json/-/simple-xml-to-json-1.2.7.tgz",
+ "integrity": "sha512-mz9VXphOxQWX3eQ/uXCtm6upltoN0DLx8Zb5T4TFC4FHB7S9FDPGre8CfLWqPWQQH/GrQYd2AXhhVM5LDpYx6Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=20.12.2"
+ }
+ },
"node_modules/source-map": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz",
@@ -4684,6 +5455,12 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/tinycolor2": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz",
+ "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==",
+ "license": "MIT"
+ },
"node_modules/tmp": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
@@ -4970,6 +5747,15 @@
"punycode": "^2.1.0"
}
},
+ "node_modules/utif2": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/utif2/-/utif2-4.1.0.tgz",
+ "integrity": "sha512-+oknB9FHrJ7oW7A2WZYajOcv4FcDR4CfoGB0dPNfxbi4GO05RRnFmt5oa23+9w32EanrYcSJWspUiJkLMs+37w==",
+ "license": "MIT",
+ "dependencies": {
+ "pako": "^1.0.11"
+ }
+ },
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -5166,6 +5952,34 @@
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
+ "node_modules/xml-parse-from-string": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/xml-parse-from-string/-/xml-parse-from-string-1.0.1.tgz",
+ "integrity": "sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g==",
+ "license": "MIT"
+ },
+ "node_modules/xml2js": {
+ "version": "0.5.0",
+ "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz",
+ "integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==",
+ "license": "MIT",
+ "dependencies": {
+ "sax": ">=0.6.0",
+ "xmlbuilder": "~11.0.0"
+ },
+ "engines": {
+ "node": ">=4.0.0"
+ }
+ },
+ "node_modules/xmlbuilder": {
+ "version": "11.0.1",
+ "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
+ "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=4.0"
+ }
+ },
"node_modules/xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
@@ -5194,6 +6008,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/backend/package.json b/backend/package.json
index 4a976a4..44b5a6f 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -30,6 +30,10 @@
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"helmet": "^8.3.0",
+ "jimp": "^1.6.1",
+ "jose": "^6.2.12",
+ "nodemailer": "^7.0.13",
+ "passkit-generator": "^3.6.1",
"passport": "^0.7.0",
"passport-jwt": "^4.0.1",
"reflect-metadata": "^0.2.2",
@@ -41,6 +45,7 @@
"@types/express": "^5.0.0",
"@types/multer": "^2.3.0",
"@types/node": "^22.7.4",
+ "@types/nodemailer": "^8.0.2",
"@types/passport-jwt": "^4.0.1",
"prisma": "^5.20.0",
"ts-node": "^10.9.2",
diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma
index 718099b..9a97ade 100644
--- a/backend/prisma/schema.prisma
+++ b/backend/prisma/schema.prisma
@@ -129,6 +129,8 @@ model LoyaltyCard {
serial String @unique
/// Jeton d'authentification du service web Apple Wallet.
authToken String
+ /// Clé secrète des liens client (page de la carte, téléchargement du pass).
+ accessKey String @unique
balance Int @default(0)
lastCreditAt DateTime?
createdAt DateTime @default(now())
diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts
index 2d5bf68..fd11f93 100644
--- a/backend/src/app.module.ts
+++ b/backend/src/app.module.ts
@@ -6,6 +6,8 @@ import configuration from './config/configuration';
import { PrismaModule } from './prisma/prisma.module';
import { AuthModule } from './auth/auth.module';
import { AdminModule } from './admin.module';
+import { MailModule } from './mail/mail.service';
+import { EnrollmentModule } from './enrollment/enrollment.module';
import { HealthController } from './health.controller';
@Module({
@@ -15,6 +17,8 @@ import { HealthController } from './health.controller';
PrismaModule,
AuthModule,
AdminModule,
+ MailModule,
+ EnrollmentModule,
],
controllers: [HealthController],
providers: [{ provide: APP_GUARD, useClass: ThrottlerGuard }],
diff --git a/backend/src/config/configuration.ts b/backend/src/config/configuration.ts
index 4c9b0c8..62bf71f 100644
--- a/backend/src/config/configuration.ts
+++ b/backend/src/config/configuration.ts
@@ -1,6 +1,8 @@
export default () => ({
env: process.env.NODE_ENV ?? 'development',
port: parseInt(process.env.PORT ?? '3100', 10),
+ /** URL publique de l'API (liens e-mail, QR d'inscription, images Google Wallet). */
+ publicUrl: (process.env.PUBLIC_URL ?? 'http://localhost:3100').replace(/\/$/, ''),
cors: { origins: process.env.CORS_ORIGINS ?? '' },
jwt: {
accessSecret: process.env.JWT_ACCESS_SECRET ?? 'dev-access-secret',
@@ -8,4 +10,25 @@ export default () => ({
accessTtl: process.env.JWT_ACCESS_TTL ?? '15m',
refreshTtl: process.env.JWT_REFRESH_TTL ?? '30d',
},
+ apple: {
+ passTypeId: process.env.APPLE_PASS_TYPE_ID ?? '',
+ teamId: process.env.APPLE_TEAM_ID ?? '',
+ /** Chemins vers les fichiers PEM (hors du dépôt). */
+ signerCert: process.env.APPLE_SIGNER_CERT ?? '',
+ signerKey: process.env.APPLE_SIGNER_KEY ?? '',
+ signerKeyPassphrase: process.env.APPLE_SIGNER_KEY_PASSPHRASE || undefined,
+ wwdrCert: process.env.APPLE_WWDR_CERT ?? '',
+ },
+ google: {
+ issuerId: process.env.GOOGLE_WALLET_ISSUER_ID ?? '',
+ /** Chemin vers la clé JSON du compte de service. */
+ serviceAccountFile: process.env.GOOGLE_WALLET_SA_FILE ?? '',
+ },
+ mail: {
+ host: process.env.SMTP_HOST ?? '',
+ port: parseInt(process.env.SMTP_PORT ?? '587', 10),
+ user: process.env.SMTP_USER ?? '',
+ pass: process.env.SMTP_PASS ?? '',
+ from: process.env.MAIL_FROM ?? 'MonEspacePro ',
+ },
});
diff --git a/backend/src/enrollment/enrollment.controller.ts b/backend/src/enrollment/enrollment.controller.ts
new file mode 100644
index 0000000..98a65f8
--- /dev/null
+++ b/backend/src/enrollment/enrollment.controller.ts
@@ -0,0 +1,144 @@
+import {
+ Body,
+ Controller,
+ Delete,
+ Get,
+ Headers,
+ HttpCode,
+ NotFoundException,
+ Param,
+ Post,
+ Query,
+ Res,
+} from '@nestjs/common';
+import { Throttle } from '@nestjs/throttler';
+import { Response } from 'express';
+import { Transform } from 'class-transformer';
+import { Equals, IsEmail, IsString, Length } from 'class-validator';
+import { EnrollmentService } from './enrollment.service';
+import { ApplePassService } from '../wallet/apple-pass.service';
+import { GoogleWalletService } from '../wallet/google-wallet.service';
+import { cardPage, detectPlatform, enrollPage, notFoundPage, privacyPage, unavailablePage } from './pages';
+
+const trim = ({ value }: { value: unknown }) => (typeof value === 'string' ? value.trim() : value);
+
+class EnrollDto {
+ @Transform(trim) @IsString() @Length(1, 40)
+ firstName!: string;
+
+ @Transform(trim) @IsEmail()
+ email!: string;
+
+ /** Le consentement RGPD est obligatoire ; sa date est enregistrée. */
+ @Equals(true)
+ consent!: boolean;
+}
+
+class ResendDto {
+ @Transform(trim) @IsEmail()
+ email!: string;
+}
+
+function html(res: Response, body: string, status = 200) {
+ res.status(status).type('html').setHeader('Cache-Control', 'no-store').send(body);
+}
+
+/** Pages HTML publiques (hors préfixe /api : ce sont les URL imprimées et envoyées). */
+@Controller()
+export class EnrollmentPagesController {
+ constructor(
+ private enrollment: EnrollmentService,
+ private apple: ApplePassService,
+ private google: GoogleWalletService,
+ ) {}
+
+ @Get('c/:slug')
+ async enroll(@Param('slug') slug: string, @Res() res: Response) {
+ const store = await this.enrollment.findStore(slug);
+ if (!store || store.status === 'DRAFT') return html(res, notFoundPage(), 404);
+ if (store.status !== 'ACTIVE' || !store.cardDesign) return html(res, unavailablePage(store));
+ html(res, enrollPage(store));
+ }
+
+ @Get('c/:slug/confidentialite')
+ async privacy(@Param('slug') slug: string, @Res() res: Response) {
+ const store = await this.enrollment.findStore(slug);
+ if (!store) return html(res, notFoundPage(), 404);
+ html(res, privacyPage(store));
+ }
+
+ @Get('carte/:serial')
+ async card(
+ @Param('serial') serial: string,
+ @Query('k') key: string | undefined,
+ @Query('nouveau') isNew: string | undefined,
+ @Headers('user-agent') ua: string | undefined,
+ @Res() res: Response,
+ ) {
+ const card = await this.enrollment.findCard(serial, key);
+ if (!card) return html(res, notFoundPage(), 404);
+ // La clé du lien ne doit pas fuiter vers des tiers (polices Google, etc.).
+ res.setHeader('Referrer-Policy', 'no-referrer');
+ html(
+ res,
+ cardPage(card, {
+ platform: detectPlatform(ua),
+ isNew: isNew !== undefined,
+ apple: this.apple.enabled,
+ google: this.google.enabled,
+ }),
+ );
+ }
+}
+
+@Controller('public')
+export class EnrollmentApiController {
+ constructor(
+ private enrollment: EnrollmentService,
+ private apple: ApplePassService,
+ private google: GoogleWalletService,
+ ) {}
+
+ @Post('stores/:slug/enroll')
+ @HttpCode(200)
+ @Throttle({ default: { limit: 10, ttl: 60_000 } })
+ enroll(@Param('slug') slug: string, @Body() dto: EnrollDto) {
+ return this.enrollment.enroll(slug, dto.firstName, dto.email);
+ }
+
+ @Post('stores/:slug/resend')
+ @HttpCode(200)
+ @Throttle({ default: { limit: 3, ttl: 10 * 60_000 } })
+ async resend(@Param('slug') slug: string, @Body() dto: ResendDto) {
+ await this.enrollment.resend(slug, dto.email);
+ return { ok: true };
+ }
+
+ @Get('cards/:serial/apple')
+ async applePass(@Param('serial') serial: string, @Query('k') key: string | undefined, @Res() res: Response) {
+ const card = await this.enrollment.findCard(serial, key);
+ if (!card) throw new NotFoundException();
+ const pkpass = await this.apple.generate(card);
+ res
+ .status(200)
+ .type('application/vnd.apple.pkpass')
+ .setHeader('Content-Disposition', `attachment; filename="carte-${card.store.slug}.pkpass"`)
+ .setHeader('Cache-Control', 'no-store')
+ .send(pkpass);
+ }
+
+ @Get('cards/:serial/google')
+ async googlePass(@Param('serial') serial: string, @Query('k') key: string | undefined, @Res() res: Response) {
+ const card = await this.enrollment.findCard(serial, key);
+ if (!card) throw new NotFoundException();
+ res.redirect(302, await this.google.saveUrl(card));
+ }
+
+ @Delete('cards/:serial')
+ async remove(@Param('serial') serial: string, @Query('k') key: string | undefined) {
+ const card = await this.enrollment.findCard(serial, key);
+ if (!card) throw new NotFoundException();
+ await this.enrollment.deleteCard(card);
+ return { ok: true };
+ }
+}
diff --git a/backend/src/enrollment/enrollment.module.ts b/backend/src/enrollment/enrollment.module.ts
new file mode 100644
index 0000000..f99abaf
--- /dev/null
+++ b/backend/src/enrollment/enrollment.module.ts
@@ -0,0 +1,13 @@
+import { Module } from '@nestjs/common';
+import { EnrollmentApiController, EnrollmentPagesController } from './enrollment.controller';
+import { EnrollmentService } from './enrollment.service';
+import { ApplePassService } from '../wallet/apple-pass.service';
+import { GoogleWalletService } from '../wallet/google-wallet.service';
+
+/** Inscription des clients finaux et remise des cartes Wallet. */
+@Module({
+ controllers: [EnrollmentPagesController, EnrollmentApiController],
+ providers: [EnrollmentService, ApplePassService, GoogleWalletService],
+ exports: [ApplePassService, GoogleWalletService],
+})
+export class EnrollmentModule {}
diff --git a/backend/src/enrollment/enrollment.service.ts b/backend/src/enrollment/enrollment.service.ts
new file mode 100644
index 0000000..0ecb1b3
--- /dev/null
+++ b/backend/src/enrollment/enrollment.service.ts
@@ -0,0 +1,121 @@
+import { ConflictException, Injectable, Logger, NotFoundException } from '@nestjs/common';
+import { ConfigService } from '@nestjs/config';
+import { randomBytes, timingSafeEqual } from 'crypto';
+import { PrismaService } from '../prisma/prisma.service';
+import { MailService } from '../mail/mail.service';
+import { CARD_WITH_CONTEXT, CardWithContext } from '../wallet/wallet.types';
+import { escapeHtml } from './pages';
+
+/** Alphabet sans caractères ambigus : le numéro peut être lu à voix haute au comptoir. */
+const SERIAL_ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
+
+function randomSerial() {
+ const bytes = randomBytes(16);
+ return 'MEP' + [...bytes].map((b) => SERIAL_ALPHABET[b % SERIAL_ALPHABET.length]).join('');
+}
+
+const token = () => randomBytes(24).toString('base64url');
+
+/** « tony.prive@gmail.com » → « t•••@g•••.com » */
+export function maskEmail(email: string) {
+ const [user, domain = ''] = email.split('@');
+ const dot = domain.lastIndexOf('.');
+ const host = dot > 0 ? domain.slice(0, dot) : domain;
+ const tld = dot > 0 ? domain.slice(dot) : '';
+ return `${user[0]}•••@${host[0] ?? ''}•••${tld}`;
+}
+
+export type EnrollResult = { status: 'created'; cardUrl: string } | { status: 'exists'; maskedEmail: string };
+
+@Injectable()
+export class EnrollmentService {
+ private readonly logger = new Logger(EnrollmentService.name);
+
+ constructor(
+ private prisma: PrismaService,
+ private mail: MailService,
+ private config: ConfigService,
+ ) {}
+
+ findStore(slug: string) {
+ return this.prisma.store.findUnique({
+ where: { slug },
+ include: { cardDesign: { include: { rewards: { where: { active: true }, orderBy: { cost: 'asc' } } } } },
+ });
+ }
+
+ /** Inscription ouverte uniquement si le magasin est actif et sa carte conçue. */
+ private async openStore(slug: string) {
+ const store = await this.findStore(slug);
+ if (!store) throw new NotFoundException('Programme introuvable');
+ if (store.status !== 'ACTIVE' || !store.cardDesign) throw new ConflictException('Programme indisponible');
+ return store;
+ }
+
+ async enroll(slug: string, firstName: string, rawEmail: string): Promise {
+ const store = await this.openStore(slug);
+ const email = rawEmail.toLowerCase();
+ const existing = await this.findCardByEmail(store.id, email);
+ if (existing) return { status: 'exists', maskedEmail: maskEmail(email) };
+
+ const card = await this.prisma.loyaltyCard.create({
+ data: {
+ serial: randomSerial(),
+ authToken: token(),
+ accessKey: token(),
+ store: { connect: { id: store.id } },
+ customer: { create: { firstName, email, consentAt: new Date() } },
+ },
+ include: CARD_WITH_CONTEXT,
+ });
+ this.sendCardLink(card, true).catch((e) => this.logger.error(`E-mail d'inscription non envoyé : ${e.message}`));
+ return { status: 'created', cardUrl: this.cardUrl(card) };
+ }
+
+ /** Réponse identique que la carte existe ou non : rien n'est révélé. */
+ async resend(slug: string, rawEmail: string) {
+ const store = await this.findStore(slug);
+ if (!store) return;
+ const card = await this.findCardByEmail(store.id, rawEmail.toLowerCase());
+ if (card) await this.sendCardLink(card, false);
+ }
+
+ /** Carte accessible par son lien secret ; null si le lien est faux. */
+ async findCard(serial: string, key: string | undefined): Promise {
+ if (!key) return null;
+ const card = await this.prisma.loyaltyCard.findUnique({ where: { serial }, include: CARD_WITH_CONTEXT });
+ if (!card || card.store.status === 'CLOSED') return null;
+ const a = Buffer.from(card.accessKey);
+ const b = Buffer.from(key);
+ return a.length === b.length && timingSafeEqual(a, b) ? card : null;
+ }
+
+ /** Droit à l'effacement : la carte et les données du client disparaissent. */
+ async deleteCard(card: CardWithContext) {
+ await this.prisma.$transaction(async (tx) => {
+ await tx.loyaltyCard.delete({ where: { id: card.id } });
+ const others = await tx.loyaltyCard.count({ where: { customerId: card.customerId } });
+ if (others === 0) await tx.customer.delete({ where: { id: card.customerId } });
+ });
+ }
+
+ cardUrl(card: { serial: string; accessKey: string }) {
+ return `${this.config.get('publicUrl')}/carte/${card.serial}?k=${card.accessKey}`;
+ }
+
+ private findCardByEmail(storeId: string, email: string) {
+ return this.prisma.loyaltyCard.findFirst({ where: { storeId, customer: { email } }, include: CARD_WITH_CONTEXT });
+ }
+
+ private async sendCardLink(card: CardWithContext, isNew: boolean) {
+ const url = this.cardUrl(card);
+ const program = card.store.cardDesign?.programName ?? card.store.name;
+ const subject = isNew ? `Votre carte ${program}` : `Le lien de votre carte ${program}`;
+ const intro = isNew
+ ? `Bienvenue dans le programme ${program} de ${card.store.name} !`
+ : `Voici le lien de votre carte ${program}, comme demandé.`;
+ const text = `Bonjour ${card.customer.firstName},\n\n${intro}\n\nOuvrez ce lien sur votre téléphone pour ajouter la carte à Apple Wallet ou Google Wallet :\n${url}\n\nGardez cet e-mail : il vous permet de retrouver votre carte si vous changez de téléphone.\n\n${card.store.name}`;
+ const html = `Bonjour ${escapeHtml(card.customer.firstName)},
${escapeHtml(intro)}
Ajouter ma carte à mon téléphone
Gardez cet e-mail : il vous permet de retrouver votre carte si vous changez de téléphone.
${escapeHtml(card.store.name)}
`;
+ await this.mail.send(card.customer.email, subject, text, html);
+ }
+}
diff --git a/backend/src/enrollment/pages.ts b/backend/src/enrollment/pages.ts
new file mode 100644
index 0000000..fb5b34b
--- /dev/null
+++ b/backend/src/enrollment/pages.ts
@@ -0,0 +1,302 @@
+import type { CardDesign, Reward, Store } from '@prisma/client';
+import type { CardWithContext } from '../wallet/wallet.types';
+
+/** Pages publiques (clients finaux), rendues côté serveur aux couleurs du magasin. */
+
+export type StoreWithDesign = Store & { cardDesign: (CardDesign & { rewards: Reward[] }) | null };
+export type Platform = 'apple' | 'google' | 'other';
+
+export function escapeHtml(value: unknown) {
+ return String(value ?? '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+const e = escapeHtml;
+
+export function detectPlatform(userAgent = ''): Platform {
+ if (/iPhone|iPad|iPod|Macintosh/i.test(userAgent)) return 'apple';
+ if (/Android/i.test(userAgent)) return 'google';
+ return 'other';
+}
+
+/** « Boulangerie Le Fournil » → « de Boulangerie Le Fournil », « Atelier » → « d'Atelier ». */
+function de(name: string) {
+ return /^[aeiouyhàâéèêîôû]/i.test(name) ? `d’${name}` : `de ${name}`;
+}
+
+const SYMBOL = (size: number) =>
+ ` `;
+
+function theme(store: StoreWithDesign) {
+ const d = store.cardDesign;
+ return {
+ bg: d?.backgroundColor ?? '#1F2937',
+ fg: d?.foregroundColor ?? '#FFFFFF',
+ label: d?.labelColor ?? '#D1D5DB',
+ logo: d?.logoPath ? `/uploads/${d.logoPath}` : null,
+ strip: d?.stripPath ? `/uploads/${d.stripPath}` : null,
+ };
+}
+
+function layout(store: StoreWithDesign, title: string, body: string, script = '') {
+ const t = theme(store);
+ return `
+
+
+
+
+
+
+${e(title)}
+
+
+
+
+
+
+
+${t.strip ? ` ` : '
'}
+${t.logo ? ` ` : ''}
+
+
+${body}
+
+
+
+${script ? `` : ''}
+
+`;
+}
+
+function promises(store: StoreWithDesign) {
+ const d = store.cardDesign!;
+ const rule =
+ d.pointsMode === 'STAMP'
+ ? 'Un tampon à chaque passage'
+ : Number(d.pointsPerEuro) === 1
+ ? 'Gagnez 1 point par euro dépensé'
+ : `Gagnez ${Number(d.pointsPerEuro).toLocaleString('fr-FR')} points par euro dépensé`;
+ const unit = d.pointsMode === 'STAMP' ? 'tampons' : 'points';
+ const reward = d.rewards[0];
+ return `
+
${e(rule)}
+${reward ? `
${e(reward.label)} à ${reward.cost} ${unit}
` : ''}
+
`;
+}
+
+export function enrollPage(store: StoreWithDesign) {
+ const program = store.cardDesign!.programName;
+ const unitLower = store.cardDesign!.pointsMode === 'STAMP' ? 'tampons' : 'points';
+ const body = `
+
+
+ Vous avez déjà une carte
+ Une carte ${e(program)} est déjà associée à . Vos ${unitLower} sont bien conservés.
+ Renvoyer le lien par e-mail
+ C'est envoyé. Ouvrez l'e-mail sur ce téléphone pour ajouter votre carte. Pensez à regarder dans les courriers indésirables.
+ Utiliser une autre adresse
+ `;
+
+ const script = `
+(function(){
+var slug=${JSON.stringify(store.slug)};
+var $=function(id){return document.getElementById(id)};
+var lastEmail='';
+function show(id,on){$(id).hidden=!on}
+$('f').addEventListener('submit',async function(ev){
+ ev.preventDefault();
+ var firstName=$('firstName').value.trim(),email=$('email').value.trim(),consent=$('consent').checked;
+ var okName=firstName.length>0,okMail=/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email);
+ show('e-firstName',!okName);show('e-email',!okMail);show('h-email',okMail);show('e-consent',!consent);show('e-global',false);
+ if(!okName||!okMail||!consent)return;
+ $('submit').disabled=true;
+ try{
+ var r=await fetch('/api/public/stores/'+slug+'/enroll',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({firstName:firstName,email:email,consent:true})});
+ var data=await r.json().catch(function(){return {}});
+ if(!r.ok){throw new Error(r.status===409?'Le programme est momentanément indisponible.':r.status===429?'Trop de tentatives, réessayez dans une minute.':'Une erreur est survenue, réessayez.')}
+ if(data.status==='created'){location.href=data.cardUrl+'&nouveau=1';return}
+ lastEmail=email;$('masked').textContent=data.maskedEmail;show('v-form',false);show('v-exists',true);show('resent',false);show('resend',true);
+ }catch(err){$('e-global').textContent=err.message;show('e-global',true)}
+ finally{$('submit').disabled=false}
+});
+$('resend').addEventListener('click',async function(){
+ this.disabled=true;
+ await fetch('/api/public/stores/'+slug+'/resend',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({email:lastEmail})}).catch(function(){});
+ show('resend',false);show('resent',true);this.disabled=false;
+});
+$('back').addEventListener('click',function(){show('v-exists',false);show('v-form',true);$('email').focus()});
+})();`;
+ return layout(store, program, body, script);
+}
+
+export function unavailablePage(store: StoreWithDesign) {
+ const unitLower = store.cardDesign?.pointsMode === 'STAMP' ? 'tampons' : 'points';
+ return layout(
+ store,
+ store.name,
+ `${e(store.name)} · ${e(store.city)}
+Programme momentanément indisponible
+L'inscription au programme de fidélité ${e(de(store.name))} n'est pas possible pour le moment. Si vous avez déjà une carte, vos ${unitLower} sont conservés.
+N'hésitez pas à vous renseigner au comptoir. Merci de votre fidélité !
`,
+ );
+}
+
+export function cardPage(
+ card: CardWithContext,
+ opts: { platform: Platform; isNew: boolean; apple: boolean; google: boolean },
+) {
+ const store = card.store as StoreWithDesign;
+ const d = store.cardDesign!;
+ const t = theme(store);
+ const unit = d.pointsMode === 'STAMP' ? 'Tampons' : 'Points';
+ const q = `?k=${encodeURIComponent(card.accessKey)}`;
+ const appleBtn = opts.apple
+ ? `Ajouter à Apple Wallet `
+ : '';
+ const googleBtn = opts.google
+ ? `Ajouter à Google Wallet `
+ : '';
+ // Le bouton de la plateforme détectée en premier, l'autre en lien secondaire.
+ const buttons =
+ opts.platform === 'google'
+ ? googleBtn + (appleBtn && `Vous avez un iPhone ? Apple Wallet `)
+ : opts.platform === 'apple'
+ ? appleBtn + (googleBtn && `Vous avez un Android ? Google Wallet `)
+ : appleBtn + googleBtn;
+ const none = !opts.apple && !opts.google;
+
+ const body = `
+
+ ${opts.isNew ? `
` : ''}
+
${opts.isNew ? `Votre carte est prête, ${e(card.customer.firstName)} !` : `Votre carte ${e(d.programName)}`}
+
Ajoutez-la à votre téléphone et présentez-la au comptoir à chaque passage.
+
+
+
${t.logo ? `
` : ''}
${e(d.programName)}
+
${t.strip ? `
` : ''}
+
Membre
${e(card.customer.firstName)}
Récompense
${e(d.rewards[0]?.label ?? '—')}
+
+
+ ${none ? '
L\'ajout au téléphone sera disponible très bientôt. Gardez l\'e-mail reçu : il contient le lien de votre carte.
' : buttons}
+
+${opts.isNew ? 'Un e-mail de confirmation vous a été envoyé avec le lien de votre carte.
' : ''}
+
+ Supprimer ma carte
+
+
Votre carte, votre solde et vos données personnelles seront définitivement effacés. Pensez aussi à retirer la carte de votre Wallet.
+
Supprimer définitivement
+
+ `;
+
+ const script = `
+document.getElementById('delete').addEventListener('click',async function(){
+ if(!confirm('Supprimer définitivement votre carte et votre solde ?'))return;
+ this.disabled=true;
+ var r=await fetch('/api/public/cards/${card.serial}${q}',{method:'DELETE'});
+ document.querySelector('main').innerHTML=r.ok?'Carte supprimée Vos données ont été effacées. Vous pouvez retirer la carte de votre Wallet.
':'Suppression impossible Réessayez plus tard.
';
+});`;
+ return layout(store, d.programName, body, script);
+}
+
+export function privacyPage(store: StoreWithDesign) {
+ return layout(
+ store,
+ `Confidentialité — ${store.name}`,
+ `Confidentialité
+Responsable du traitement : ${e(store.name)}, ${e(store.addressLine)}, ${e(store.postalCode)} ${e(store.city)} (SIRET ${e(store.siret)}). Contact : ${e(store.contactEmail)} .
+Données collectées : votre prénom, votre adresse e-mail, votre solde et l'historique de vos passages (date, montant, points).
+Finalité : gérer votre carte de fidélité. Vos données ne sont ni vendues ni utilisées à des fins publicitaires.
+Base légale : votre consentement, que vous pouvez retirer à tout moment en supprimant votre carte depuis le lien reçu par e-mail.
+Sous-traitant : la plateforme MonEspacePro (EI Tony Averty) héberge les données pour le compte du commerce, en France / Union européenne.
+Durée de conservation : tant que votre carte est active, puis suppression.
+Vos droits : accès, rectification, effacement, portabilité, en écrivant au commerce. Vous pouvez aussi saisir la CNIL (cnil.fr).
+Retour `,
+ );
+}
+
+export function notFoundPage() {
+ return `Introuvable
+
+Lien introuvable Ce lien n'existe pas ou n'est plus valide. Renseignez-vous au comptoir.
`;
+}
diff --git a/backend/src/mail/mail.service.ts b/backend/src/mail/mail.service.ts
new file mode 100644
index 0000000..7876a45
--- /dev/null
+++ b/backend/src/mail/mail.service.ts
@@ -0,0 +1,39 @@
+import { Global, Injectable, Logger, Module } from '@nestjs/common';
+import { ConfigService } from '@nestjs/config';
+import { createTransport, Transporter } from 'nodemailer';
+
+/**
+ * Envoi d'e-mails transactionnels. Sans SMTP configuré (développement),
+ * le message est écrit dans les logs au lieu d'être envoyé.
+ */
+@Injectable()
+export class MailService {
+ private readonly logger = new Logger(MailService.name);
+ private readonly transport: Transporter | null;
+ private readonly from: string;
+
+ constructor(config: ConfigService) {
+ const mail = config.get('mail');
+ this.from = mail.from;
+ this.transport = mail.host
+ ? createTransport({
+ host: mail.host,
+ port: mail.port,
+ secure: mail.port === 465,
+ auth: mail.user ? { user: mail.user, pass: mail.pass } : undefined,
+ })
+ : null;
+ }
+
+ async send(to: string, subject: string, text: string, html: string) {
+ if (!this.transport) {
+ this.logger.warn(`SMTP non configuré — e-mail à ${to} : « ${subject} »\n${text}`);
+ return;
+ }
+ await this.transport.sendMail({ from: this.from, to, subject, text, html });
+ }
+}
+
+@Global()
+@Module({ providers: [MailService], exports: [MailService] })
+export class MailModule {}
diff --git a/backend/src/main.ts b/backend/src/main.ts
index 0fb5bd2..d1f0d7d 100644
--- a/backend/src/main.ts
+++ b/backend/src/main.ts
@@ -1,7 +1,7 @@
process.env.TZ = process.env.TZ || 'Europe/Paris';
import { NestFactory } from '@nestjs/core';
-import { ValidationPipe } from '@nestjs/common';
+import { RequestMethod, ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { NestExpressApplication } from '@nestjs/platform-express';
import helmet from 'helmet';
@@ -32,7 +32,14 @@ async function bootstrap() {
app.use(helmet({ contentSecurityPolicy: false, crossOriginResourcePolicy: { policy: 'cross-origin' } }));
// Logos et bandeaux des cartes (aperçu admin, page d'inscription, génération des pass).
app.useStaticAssets(UPLOADS_DIR, { prefix: '/uploads/' });
- app.setGlobalPrefix('api');
+ // Les pages client gardent des URL courtes (imprimées sur les QR, envoyées par e-mail).
+ app.setGlobalPrefix('api', {
+ exclude: [
+ { path: 'c/:slug', method: RequestMethod.GET },
+ { path: 'c/:slug/confidentialite', method: RequestMethod.GET },
+ { path: 'carte/:serial', method: RequestMethod.GET },
+ ],
+ });
app.useGlobalPipes(new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true }));
const origins = (config.get('cors.origins') ?? '')
diff --git a/backend/src/stores/stores.service.ts b/backend/src/stores/stores.service.ts
index 8608209..8849f62 100644
--- a/backend/src/stores/stores.service.ts
+++ b/backend/src/stores/stores.service.ts
@@ -1,4 +1,5 @@
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common';
+import { ConfigService } from '@nestjs/config';
import { Prisma, Store, StoreStatus } from '@prisma/client';
import { randomBytes } from 'crypto';
import { PrismaService } from '../prisma/prisma.service';
@@ -14,7 +15,10 @@ const TRANSITIONS: Record = {
@Injectable()
export class StoresService {
- constructor(private prisma: PrismaService) {}
+ constructor(
+ private prisma: PrismaService,
+ private config: ConfigService,
+ ) {}
async list(query: ListStoresQuery) {
const where: Prisma.StoreWhereInput = {
@@ -49,7 +53,12 @@ export class StoresService {
});
if (!store) throw new NotFoundException('Magasin introuvable');
const { _count, subscription, ...s } = store;
- return { ...this.present(s), counts: _count, subscription };
+ return {
+ ...this.present(s),
+ counts: _count,
+ subscription,
+ enrollUrl: `${this.config.get('publicUrl')}/c/${s.slug}`,
+ };
}
async create(dto: CreateStoreDto) {
@@ -76,6 +85,10 @@ export class StoresService {
if (status === 'ACTIVE' && !store.cardDesign) {
throw new BadRequestException("La carte de fidélité doit être conçue avant l'activation");
}
+ if (status === 'ACTIVE' && !store.cardDesign?.logoPath) {
+ // Google Wallet refuse une carte sans logo ; Apple s'en sert comme icône.
+ throw new BadRequestException("Ajoutez le logo du magasin avant l'activation");
+ }
const updated = await this.prisma.store.update({ where: { id }, data: { status } });
return this.present(updated);
}
diff --git a/backend/src/wallet/apple-pass.service.ts b/backend/src/wallet/apple-pass.service.ts
new file mode 100644
index 0000000..acff3c8
--- /dev/null
+++ b/backend/src/wallet/apple-pass.service.ts
@@ -0,0 +1,135 @@
+import { Injectable, Logger, ServiceUnavailableException } from '@nestjs/common';
+import { ConfigService } from '@nestjs/config';
+import { readFileSync } from 'fs';
+import { join } from 'path';
+import { Jimp } from 'jimp';
+import { PKPass } from 'passkit-generator';
+import { UPLOADS_DIR } from '../card-design/card-design.service';
+import { CardWithContext, rewardsText, unitLabel } from './wallet.types';
+
+type Certificates = { wwdr: Buffer; signerCert: Buffer; signerKey: Buffer; signerKeyPassphrase?: string };
+
+/** « #1F2937 » → « rgb(31, 41, 55) » (seul format accepté par pass.json). */
+function rgb(hex: string) {
+ const [r, g, b] = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16));
+ return `rgb(${r}, ${g}, ${b})`;
+}
+
+/**
+ * Génération des .pkpass Apple Wallet (style « storeCard »).
+ * Le QR contient le numéro de série de la carte : fixe, la protection
+ * anti-triche est faite côté serveur au moment du scan.
+ */
+@Injectable()
+export class ApplePassService {
+ private readonly logger = new Logger(ApplePassService.name);
+ private certificates: Certificates | null | undefined;
+
+ constructor(private config: ConfigService) {}
+
+ get enabled() {
+ return this.loadCertificates() !== null;
+ }
+
+ async generate(card: CardWithContext): Promise {
+ const certificates = this.loadCertificates();
+ if (!certificates) throw new ServiceUnavailableException('Apple Wallet n’est pas encore configuré');
+ const design = card.store.cardDesign;
+ if (!design) throw new ServiceUnavailableException('Carte non conçue');
+
+ const unit = unitLabel(card);
+ const passJson = {
+ formatVersion: 1,
+ passTypeIdentifier: this.config.get('apple.passTypeId'),
+ teamIdentifier: this.config.get('apple.teamId'),
+ serialNumber: card.serial,
+ organizationName: card.store.name,
+ description: design.programName,
+ backgroundColor: rgb(design.backgroundColor),
+ foregroundColor: rgb(design.foregroundColor),
+ labelColor: rgb(design.labelColor),
+ ...(design.logoPath ? {} : { logoText: card.store.name }),
+ sharingProhibited: true,
+ barcodes: [{ format: 'PKBarcodeFormatQR', message: card.serial, messageEncoding: 'iso-8859-1' }],
+ storeCard: {
+ headerFields: [{ key: 'balance-header', label: unit.toUpperCase(), value: card.balance }],
+ primaryFields: [{ key: 'balance', label: 'SOLDE', value: card.balance, changeMessage: `Nouveau solde : %@ ${unit.toLowerCase()}` }],
+ secondaryFields: [
+ { key: 'program', label: 'PROGRAMME', value: design.programName },
+ { key: 'member', label: 'MEMBRE', value: card.customer.firstName, textAlignment: 'PKTextAlignmentRight' },
+ ],
+ backFields: [
+ { key: 'rewards', label: 'Récompenses', value: rewardsText(card) },
+ {
+ key: 'store',
+ label: card.store.name,
+ value: `${card.store.addressLine}\n${card.store.postalCode} ${card.store.city}`,
+ },
+ {
+ key: 'manage',
+ label: 'Ma carte',
+ value: `${this.config.get('publicUrl')}/carte/${card.serial}?k=${card.accessKey}`,
+ },
+ { key: 'powered', label: '', value: 'Propulsé par MonEspacePro' },
+ ],
+ },
+ };
+
+ const pass = new PKPass(
+ { 'pass.json': Buffer.from(JSON.stringify(passJson)), ...(await this.images(card)) },
+ certificates,
+ );
+ return pass.getAsBuffer();
+ }
+
+ /** Icône (obligatoire), logo et bandeau aux trois densités d'écran. */
+ private async images(card: CardWithContext) {
+ const design = card.store.cardDesign!;
+ const files: Record = {};
+ const scales = [1, 2, 3] as const;
+ const name = (base: string, s: number) => (s === 1 ? `${base}.png` : `${base}@${s}x.png`);
+
+ if (design.logoPath) {
+ const logo = await Jimp.read(join(UPLOADS_DIR, design.logoPath));
+ for (const s of scales) {
+ files[name('icon', s)] = await logo.clone().contain({ w: 29 * s, h: 29 * s }).getBuffer('image/png');
+ files[name('logo', s)] = await logo.clone().scaleToFit({ w: 160 * s, h: 50 * s }).getBuffer('image/png');
+ }
+ } else {
+ // Icône unie à la couleur de la carte : Apple refuse un pass sans icône.
+ for (const s of scales) {
+ const icon = new Jimp({ width: 29 * s, height: 29 * s, color: design.backgroundColor + 'FF' });
+ files[name('icon', s)] = await icon.getBuffer('image/png');
+ }
+ }
+ if (design.stripPath) {
+ const strip = await Jimp.read(join(UPLOADS_DIR, design.stripPath));
+ for (const s of scales) {
+ files[name('strip', s)] = await strip.clone().cover({ w: 375 * s, h: 144 * s }).getBuffer('image/png');
+ }
+ }
+ return files;
+ }
+
+ /** Lus une fois ; null si la configuration Apple est incomplète. */
+ private loadCertificates(): Certificates | null {
+ if (this.certificates !== undefined) return this.certificates;
+ const a = this.config.get('apple');
+ if (!a.passTypeId || !a.teamId || !a.signerCert || !a.signerKey || !a.wwdrCert) {
+ this.certificates = null;
+ return null;
+ }
+ try {
+ this.certificates = {
+ signerCert: readFileSync(a.signerCert),
+ signerKey: readFileSync(a.signerKey),
+ wwdr: readFileSync(a.wwdrCert),
+ signerKeyPassphrase: a.signerKeyPassphrase,
+ };
+ } catch (e) {
+ this.logger.error(`Certificats Apple illisibles : ${(e as Error).message}`);
+ this.certificates = null;
+ }
+ return this.certificates;
+ }
+}
diff --git a/backend/src/wallet/google-wallet.service.ts b/backend/src/wallet/google-wallet.service.ts
new file mode 100644
index 0000000..af687c1
--- /dev/null
+++ b/backend/src/wallet/google-wallet.service.ts
@@ -0,0 +1,101 @@
+import { Injectable, Logger, ServiceUnavailableException } from '@nestjs/common';
+import { ConfigService } from '@nestjs/config';
+import { readFileSync } from 'fs';
+import { importPKCS8, SignJWT } from 'jose';
+import { CardWithContext, rewardsText, unitLabel } from './wallet.types';
+
+type ServiceAccount = { client_email: string; private_key: string };
+
+/**
+ * Google Wallet : lien « Ajouter à Google Wallet » sous forme de JWT signé
+ * par le compte de service, qui embarque la classe (le programme du
+ * magasin) et l'objet (la carte du client). Aucun appel à l'API Google
+ * n'est nécessaire à l'inscription ; les mises à jour du solde passeront
+ * par l'API REST (étape 5).
+ */
+@Injectable()
+export class GoogleWalletService {
+ private readonly logger = new Logger(GoogleWalletService.name);
+ private account: ServiceAccount | null | undefined;
+
+ constructor(private config: ConfigService) {}
+
+ get enabled() {
+ return this.loadAccount() !== null;
+ }
+
+ classId(storeId: string) {
+ return `${this.config.get('google.issuerId')}.store_${storeId}`;
+ }
+
+ objectId(serial: string) {
+ return `${this.config.get('google.issuerId')}.card_${serial}`;
+ }
+
+ async saveUrl(card: CardWithContext): Promise {
+ const account = this.loadAccount();
+ if (!account) throw new ServiceUnavailableException('Google Wallet n’est pas encore configuré');
+ const design = card.store.cardDesign;
+ if (!design?.logoPath) throw new ServiceUnavailableException('Logo du magasin manquant');
+
+ const publicUrl: string = this.config.get('publicUrl')!;
+ const image = (path: string, description: string) => ({
+ sourceUri: { uri: `${publicUrl}/uploads/${path}` },
+ contentDescription: { defaultValue: { language: 'fr-FR', value: description } },
+ });
+
+ const loyaltyClass = {
+ id: this.classId(card.storeId),
+ issuerName: card.store.name,
+ programName: design.programName,
+ programLogo: image(design.logoPath, `Logo ${card.store.name}`),
+ ...(design.stripPath && { heroImage: image(design.stripPath, card.store.name) }),
+ hexBackgroundColor: design.backgroundColor,
+ reviewStatus: 'UNDER_REVIEW',
+ countryCode: 'FR',
+ multipleDevicesAndHoldersAllowedStatus: 'ONE_USER_ALL_DEVICES',
+ };
+ const loyaltyObject = {
+ id: this.objectId(card.serial),
+ classId: loyaltyClass.id,
+ state: 'ACTIVE',
+ accountId: card.serial,
+ accountName: card.customer.firstName,
+ loyaltyPoints: { label: unitLabel(card), balance: { int: card.balance } },
+ barcode: { type: 'QR_CODE', value: card.serial },
+ textModulesData: [{ id: 'rewards', header: 'Récompenses', body: rewardsText(card) }],
+ linksModuleData: {
+ uris: [{ id: 'manage', uri: `${publicUrl}/carte/${card.serial}?k=${card.accessKey}`, description: 'Ma carte' }],
+ },
+ };
+
+ const key = await importPKCS8(account.private_key, 'RS256');
+ const jwt = await new SignJWT({
+ origins: [publicUrl],
+ typ: 'savetowallet',
+ payload: { loyaltyClasses: [loyaltyClass], loyaltyObjects: [loyaltyObject] },
+ })
+ .setProtectedHeader({ alg: 'RS256', typ: 'JWT' })
+ .setIssuer(account.client_email)
+ .setAudience('google')
+ .setIssuedAt()
+ .sign(key);
+ return `https://pay.google.com/gp/v/save/${jwt}`;
+ }
+
+ private loadAccount(): ServiceAccount | null {
+ if (this.account !== undefined) return this.account;
+ const file: string = this.config.get('google.serviceAccountFile')!;
+ if (!file || !this.config.get('google.issuerId')) {
+ this.account = null;
+ return null;
+ }
+ try {
+ this.account = JSON.parse(readFileSync(file, 'utf8')) as ServiceAccount;
+ } catch (e) {
+ this.logger.error(`Clé Google Wallet illisible : ${(e as Error).message}`);
+ this.account = null;
+ }
+ return this.account;
+ }
+}
diff --git a/backend/src/wallet/wallet.types.ts b/backend/src/wallet/wallet.types.ts
new file mode 100644
index 0000000..08a1eff
--- /dev/null
+++ b/backend/src/wallet/wallet.types.ts
@@ -0,0 +1,21 @@
+import { Prisma } from '@prisma/client';
+
+/** Tout ce qu'il faut pour dessiner une carte, chargé en une requête. */
+export const CARD_WITH_CONTEXT = {
+ customer: true,
+ store: { include: { cardDesign: { include: { rewards: { where: { active: true }, orderBy: { cost: 'asc' } } } } } },
+} satisfies Prisma.LoyaltyCardInclude;
+
+export type CardWithContext = Prisma.LoyaltyCardGetPayload<{ include: typeof CARD_WITH_CONTEXT }>;
+
+export function unitLabel(card: CardWithContext, plural = true) {
+ const stamp = card.store.cardDesign?.pointsMode === 'STAMP';
+ if (!plural) return stamp ? 'tampon' : 'point';
+ return stamp ? 'Tampons' : 'Points';
+}
+
+export function rewardsText(card: CardWithContext) {
+ const unit = card.store.cardDesign?.pointsMode === 'STAMP' ? 'tampons' : 'points';
+ const rewards = card.store.cardDesign?.rewards ?? [];
+ return rewards.length ? rewards.map((r) => `${r.label} — ${r.cost} ${unit}`).join('\n') : 'Renseignez-vous au comptoir.';
+}
diff --git a/docs/wallet.md b/docs/wallet.md
new file mode 100644
index 0000000..23d3ee0
--- /dev/null
+++ b/docs/wallet.md
@@ -0,0 +1,30 @@
+# Configuration Apple Wallet et Google Wallet
+
+## Apple Wallet
+
+1. developer.apple.com → Identifiers → **Pass Type IDs** → créer `pass..mep`.
+2. Sur ce Pass Type ID → **Create Certificate** (CSR générée depuis Trousseau d'accès, ou avec OpenSSL ci-dessous).
+3. Télécharger le certificat **Apple WWDR G4** : https://www.apple.com/certificateauthority/ (`AppleWWDRCAG4.cer`).
+4. Convertir en PEM (Git Bash, sur ton PC — pas besoin de shell sur le serveur) :
+
+```bash
+openssl pkcs12 -in pass.p12 -clcerts -nokeys -out signerCert.pem -legacy
+openssl pkcs12 -in pass.p12 -nocerts -out signerKey.pem -legacy
+openssl x509 -inform der -in AppleWWDRCAG4.cer -out wwdr.pem
+```
+
+5. Déposer les trois `.pem` sur le serveur **hors du dossier public** (ex. `backend/certs/`, ignoré par git) et renseigner
+ `APPLE_PASS_TYPE_ID`, `APPLE_TEAM_ID`, `APPLE_SIGNER_CERT`, `APPLE_SIGNER_KEY`, `APPLE_SIGNER_KEY_PASSPHRASE`, `APPLE_WWDR_CERT`.
+
+## Google Wallet
+
+1. pay.google.com/business/console → **Google Wallet API** → noter l'**Issuer ID**.
+2. Google Cloud Console → activer « Google Wallet API » → créer un **compte de service** → clé JSON.
+3. Dans la console Wallet → Utilisateurs → ajouter l'e-mail du compte de service (rôle Développeur).
+4. Déposer la clé JSON dans `backend/certs/` et renseigner `GOOGLE_WALLET_ISSUER_ID`, `GOOGLE_WALLET_SA_FILE`.
+5. Tant que le compte émetteur est en mode démo, seuls les comptes Google de test ajoutés dans la console peuvent enregistrer une carte.
+
+## Notes
+- `PUBLIC_URL` doit être en HTTPS en production : Google télécharge les logos depuis cette adresse.
+- Les boutons « Ajouter à Apple Wallet / Google Wallet » sont provisoires : remplacer par les badges officiels FR
+ (Apple : developer.apple.com/wallet/add-to-apple-wallet-guidelines, Google : developers.google.com/wallet/generic/resources/brand-guidelines).