Treasury & Bank Transfer Management System — سامانه مدیریت خزانه‌داری و حواله‌های بانکی

feat: add SQL Server integration and Mayan-inspired payment safeguards

Davood Mehraban committed Oct 6, 2026 at 00:28 UTC 823fa2a22a69ce80e148cd945c5d979f9cb9d54f
15 files changed +1084 -23
package-lock.json
+803 -13
@@ -8,12 +8,14 @@
8 "name": "treasuryflow",
9 "version": "0.1.0",
10 "dependencies": {
11 + "mssql": "^12.7.4",
12 "next": "16.3.8",
13 "pg": "^8.23.1",
14 "react": "19.2.0",
15 "react-dom": "19.2.0"
16 },
17 "devDependencies": {
18 + "@types/mssql": "^12.3.0",
19 "@types/node": "^24.0.0",
20 "@types/pg": "^8.23.1",
21 "@types/react": "^19.0.0",
@@ -26,6 +28,267 @@
28 "vitest": "^3.2.4"
29 }
30 },
31 + "node_modules/@azure-rest/core-client": {
32 + "version": "2.9.0",
33 + "resolved": "https://registry.npmjs.org/@azure-rest/core-client/-/core-client-2.9.0.tgz",
34 + "integrity": "sha512-6933vNLqh06RR7rumnrq3UZIeBtRLeBHDPMrieDPIljiCaMMwt0nRw++nd3TOxiohtasNtm29rC+b/9ZVKCOqg==",
35 + "license": "MIT",
36 + "dependencies": {
37 + "@azure/abort-controller": "^2.1.2",
38 + "@azure/core-auth": "^1.10.0",
39 + "@azure/core-rest-pipeline": "^1.24.0",
40 + "@azure/core-tracing": "^1.3.0",
41 + "@typespec/ts-http-runtime": "^0.3.8",
42 + "tslib": "^2.6.2"
43 + },
44 + "engines": {
45 + "node": ">=22.0.0"
46 + }
47 + },
48 + "node_modules/@azure/abort-controller": {
49 + "version": "2.2.0",
50 + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.2.0.tgz",
51 + "integrity": "sha512-fNAjWnA/nZ2jz31kxR/AqRaUT8ewHBw/WuBIosK0moMy1C9e5ValbDfFdIxJzVOOYaYkV/b2F1S4H/aHiqfVQg==",
52 + "license": "MIT",
53 + "dependencies": {
54 + "tslib": "^2.6.2"
55 + },
56 + "engines": {
57 + "node": ">=22.0.0"
58 + }
59 + },
60 + "node_modules/@azure/core-auth": {
61 + "version": "1.11.0",
62 + "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.11.0.tgz",
63 + "integrity": "sha512-IUZydyTUkDnYdstOW9pFOOUQlBjAepK5teihDE3x6yxsPJs/hsAaaYpeGxdxrgtOiJbBKSjKW7MDk7AEhb4LRg==",
64 + "license": "MIT",
65 + "dependencies": {
66 + "@azure/abort-controller": "^2.1.2",
67 + "@azure/core-util": "^1.13.0",
68 + "tslib": "^2.6.2"
69 + },
70 + "engines": {
71 + "node": ">=22.0.0"
72 + }
73 + },
74 + "node_modules/@azure/core-client": {
75 + "version": "1.11.1",
76 + "resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.11.1.tgz",
77 + "integrity": "sha512-2QygG2F76ZpMP2eMztiJvAiFMu71M9rDeU7vO/QKg5Css7MgM4frUOslFjhVjRhbGaCNPtz/S8M6y46/fFKVuQ==",
78 + "license": "MIT",
79 + "dependencies": {
80 + "@azure/abort-controller": "^2.1.2",
81 + "@azure/core-auth": "^1.10.0",
82 + "@azure/core-rest-pipeline": "^1.22.0",
83 + "@azure/core-tracing": "^1.3.0",
84 + "@azure/core-util": "^1.13.0",
85 + "@azure/logger": "^1.3.0",
86 + "tslib": "^2.6.2"
87 + },
88 + "engines": {
89 + "node": ">=22.0.0"
90 + }
91 + },
92 + "node_modules/@azure/core-lro": {
93 + "version": "2.7.2",
94 + "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.7.2.tgz",
95 + "integrity": "sha512-0YIpccoX8m/k00O7mDDMdJpbr6mf1yWo2dfmxt5A8XVZVVMz2SSKaEbMCeJRvgQ0IaSlqhjT47p4hVIRRy90xw==",
96 + "license": "MIT",
97 + "dependencies": {
98 + "@azure/abort-controller": "^2.0.0",
99 + "@azure/core-util": "^1.2.0",
100 + "@azure/logger": "^1.0.0",
101 + "tslib": "^2.6.2"
102 + },
103 + "engines": {
104 + "node": ">=18.0.0"
105 + }
106 + },
107 + "node_modules/@azure/core-paging": {
108 + "version": "1.7.0",
109 + "resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.7.0.tgz",
110 + "integrity": "sha512-7GEAoIsaoBr6KELNRb8nypowCqvk8dnCHFCYg4XD4lOQGY2GqjQg5IhkRjyBFRO18CGSMq05PaNqSOE9GQro3g==",
111 + "license": "MIT",
112 + "dependencies": {
113 + "tslib": "^2.6.2"
114 + },
115 + "engines": {
116 + "node": ">=22.0.0"
117 + }
118 + },
119 + "node_modules/@azure/core-process": {
120 + "version": "1.0.0",
121 + "resolved": "https://registry.npmjs.org/@azure/core-process/-/core-process-1.0.0.tgz",
122 + "integrity": "sha512-/shnJ+ooO8WPxDhPEeI/2oRQuubn16gZ6CvlbpWbEswZfzwI9tI/sMAHmF3x1LuQ9yZYXfLW3TjzGMLEC5blKg==",
123 + "license": "MIT",
124 + "engines": {
125 + "node": ">=22.0.0"
126 + }
127 + },
128 + "node_modules/@azure/core-rest-pipeline": {
129 + "version": "1.25.0",
130 + "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.25.0.tgz",
131 + "integrity": "sha512-bMs8ekJLjX8wPV+9IPBges1SLPyuDtE9g5gLDWOpxzKcoOFQnpLGkbcT1tdw3FaAmDS1gnPmMmJ6y/T5B96kIA==",
132 + "license": "MIT",
133 + "dependencies": {
134 + "@azure/abort-controller": "^2.1.2",
135 + "@azure/core-auth": "^1.10.0",
136 + "@azure/core-tracing": "^1.3.0",
137 + "@azure/core-util": "^1.13.0",
138 + "@azure/logger": "^1.3.0",
139 + "@typespec/ts-http-runtime": "^0.3.4",
140 + "tslib": "^2.6.2"
141 + },
142 + "engines": {
143 + "node": ">=22.0.0"
144 + }
145 + },
146 + "node_modules/@azure/core-tracing": {
147 + "version": "1.4.0",
148 + "resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.4.0.tgz",
149 + "integrity": "sha512-eGwxD0AtncrxeBM4tG8R55Pc3rdX1hNW2WibJAgYpCVA6E93mvvVH+LcssoVjOBrSKWS55yEIHsk0X8ctHmfOQ==",
150 + "license": "MIT",
151 + "dependencies": {
152 + "tslib": "^2.6.2"
153 + },
154 + "engines": {
155 + "node": ">=22.0.0"
156 + }
157 + },
158 + "node_modules/@azure/core-util": {
159 + "version": "1.14.0",
160 + "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.14.0.tgz",
161 + "integrity": "sha512-9n2pWK61veAuN0V20t9lOuoV4CFMdyAZ1ygZzvBGk/pBBJRib/PjL9PLXa/aI2CcPpyHfqVsxxqLCYl6uZlfDw==",
162 + "license": "MIT",
163 + "dependencies": {
164 + "@azure/abort-controller": "^2.1.2",
165 + "@typespec/ts-http-runtime": "^0.3.0",
166 + "tslib": "^2.6.2"
167 + },
168 + "engines": {
169 + "node": ">=22.0.0"
170 + }
171 + },
172 + "node_modules/@azure/identity": {
173 + "version": "4.13.3",
174 + "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.13.3.tgz",
175 + "integrity": "sha512-zGQPtqvXPgSA8yfV2CkIQ1qirqk0p9AIVpC5uEkdXQYcKl07QHvyaGYRnZOk0AsQUmxNb4wfkcwY5di8Z5xa9A==",
176 + "license": "MIT",
177 + "dependencies": {
178 + "@azure/abort-controller": "^2.0.0",
179 + "@azure/core-auth": "^1.9.0",
180 + "@azure/core-client": "^1.9.2",
181 + "@azure/core-process": "^1.0.0",
182 + "@azure/core-rest-pipeline": "^1.17.0",
183 + "@azure/core-tracing": "^1.0.0",
184 + "@azure/core-util": "^1.11.0",
185 + "@azure/logger": "^1.0.0",
186 + "@azure/msal-browser": "^5.5.0",
187 + "@azure/msal-node": "^6.0.0",
188 + "open": "^10.1.0",
189 + "tslib": "^2.2.0"
190 + },
191 + "engines": {
192 + "node": ">=22.0.0"
193 + }
194 + },
195 + "node_modules/@azure/keyvault-common": {
196 + "version": "2.1.0",
197 + "resolved": "https://registry.npmjs.org/@azure/keyvault-common/-/keyvault-common-2.1.0.tgz",
198 + "integrity": "sha512-aCDidWuKY06LWQ4x7/8TIXK6iRqTaRWRL3t7T+LC+j1b07HtoIsOxP/tU90G4jCSBn5TAyUTCtA4MS/y5Hudaw==",
199 + "license": "MIT",
200 + "dependencies": {
201 + "@azure-rest/core-client": "^2.3.3",
202 + "@azure/abort-controller": "^2.0.0",
203 + "@azure/core-auth": "^1.3.0",
204 + "@azure/core-rest-pipeline": "^1.8.0",
205 + "@azure/core-tracing": "^1.0.0",
206 + "@azure/core-util": "^1.10.0",
207 + "@azure/logger": "^1.1.4",
208 + "tslib": "^2.2.0"
209 + },
210 + "engines": {
211 + "node": ">=20.0.0"
212 + }
213 + },
214 + "node_modules/@azure/keyvault-keys": {
215 + "version": "4.10.2",
216 + "resolved": "https://registry.npmjs.org/@azure/keyvault-keys/-/keyvault-keys-4.10.2.tgz",
217 + "integrity": "sha512-VmUSLbXRAbSzDD8grXHGPaknYs0SKr3yuf6U+d4XMpX4XuVYskNqbTTwXce0zR1LyxfTZm9rWEBcvs3vdYwCmQ==",
218 + "license": "MIT",
219 + "dependencies": {
220 + "@azure-rest/core-client": "^2.3.3",
221 + "@azure/abort-controller": "^2.1.2",
222 + "@azure/core-auth": "^1.9.0",
223 + "@azure/core-lro": "^2.7.2",
224 + "@azure/core-paging": "^1.6.2",
225 + "@azure/core-rest-pipeline": "^1.19.0",
226 + "@azure/core-tracing": "^1.2.0",
227 + "@azure/core-util": "^1.11.0",
228 + "@azure/keyvault-common": "^2.1.0",
229 + "@azure/logger": "^1.1.4",
230 + "tslib": "^2.8.1"
231 + },
232 + "engines": {
233 + "node": ">=20.0.0"
234 + }
235 + },
236 + "node_modules/@azure/logger": {
237 + "version": "1.4.0",
238 + "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.4.0.tgz",
239 + "integrity": "sha512-rbAE25KUfjU/s3XHUdJgceoCP5dEOpMx85J04kF+QMdta73XkuG9JGHHinch+XIoKpBdqljin+KqURpJriSzLA==",
240 + "license": "MIT",
241 + "dependencies": {
242 + "@typespec/ts-http-runtime": "^0.3.0",
243 + "tslib": "^2.6.2"
244 + },
245 + "engines": {
246 + "node": ">=22.0.0"
247 + }
248 + },
249 + "node_modules/@azure/msal-browser": {
250 + "version": "5.24.0",
251 + "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-5.24.0.tgz",
252 + "integrity": "sha512-jS1stt81tslcVZi7fqVD+g6vr8w/IWqFl/vAB2dx/6EOroQDuCR4+z0o3C+d6a/GpLATvdoO+kwnDcYzsBXKQA==",
253 + "license": "MIT",
254 + "dependencies": {
255 + "@azure/msal-common": "16.14.2"
256 + },
257 + "engines": {
258 + "node": ">=0.8.0"
259 + }
260 + },
261 + "node_modules/@azure/msal-common": {
262 + "version": "16.14.2",
263 + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-16.14.2.tgz",
264 + "integrity": "sha512-HOBR0Gfo39TMrkxNG8k6cfjRkrRjXZc3JQs3ebMWQc9S4cihuknMYra3sgmzbZB752oQBqBN9+WF7c826p2vIQ==",
265 + "license": "MIT",
266 + "engines": {
267 + "node": ">=0.8.0"
268 + }
269 + },
270 + "node_modules/@azure/msal-node": {
271 + "version": "6.0.1",
272 + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-6.0.1.tgz",
273 + "integrity": "sha512-ixSO1Y/kCVRthRs+hSx/5qkwaunX1/RAePhlMN0wIpIQ4WEZ6AREGGnGd1AP0qspHVsAwzWQKGubpjh50JyJIQ==",
274 + "license": "MIT",
275 + "dependencies": {
276 + "@azure/msal-common": "16.14.1",
277 + "jsonwebtoken": "^9.0.0"
278 + },
279 + "engines": {
280 + "node": ">=20"
281 + }
282 + },
283 + "node_modules/@azure/msal-node/node_modules/@azure/msal-common": {
284 + "version": "16.14.1",
285 + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-16.14.1.tgz",
286 + "integrity": "sha512-Or6xhPNyi4zHW25158yxBoyxuCqNSPa5YBVqfF1J5Ks4MJWBo/USXdp05DQIPu1Zli00YZu6t0+h6KvHJealxQ==",
287 + "license": "MIT",
288 + "engines": {
289 + "node": ">=0.8.0"
290 + }
291 + },
292 "node_modules/@babel/code-frame": {
293 "version": "7.29.7",
294 "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",
@@ -1849,6 +2112,12 @@
2112 "@jridgewell/sourcemap-codec": "^1.4.14"
2113 }
2114 },
2115 + "node_modules/@js-joda/core": {
2116 + "version": "6.2.0",
2117 + "resolved": "https://registry.npmjs.org/@js-joda/core/-/core-6.2.0.tgz",
2118 + "integrity": "sha512-39os1Z9zTxmvRCui90qirNsLYo9s/IJOQZD7dxBju1iOJyRviWmSk+/9HDFJf8jEogjFmY0aplZIdJsErdkTgw==",
2119 + "license": "BSD-3-Clause"
2120 + },
2121 "node_modules/@malept/cross-spawn-promise": {
2122 "version": "2.0.0",
2123 "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-2.0.0.tgz",
@@ -2682,6 +2951,12 @@
2951 "node": ">=10"
2952 }
2953 },
2954 + "node_modules/@tediousjs/connection-string": {
2955 + "version": "1.1.0",
2956 + "resolved": "https://registry.npmjs.org/@tediousjs/connection-string/-/connection-string-1.1.0.tgz",
2957 + "integrity": "sha512-z9ZBWEG+8pIB5V1zYzlRPXx0oRJ5H7coPnMQK8EZOw03UTPI9Umn6viL36f5w+CuqkKsnCM50RVStpjZmR0Bng==",
2958 + "license": "MIT"
2959 + },
2960 "node_modules/@tybys/wasm-util": {
2961 "version": "0.10.4",
2962 "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.4.tgz",
@@ -2789,11 +3064,22 @@
3064 "dev": true,
3065 "license": "MIT"
3066 },
3067 + "node_modules/@types/mssql": {
3068 + "version": "12.3.0",
3069 + "resolved": "https://registry.npmjs.org/@types/mssql/-/mssql-12.3.0.tgz",
3070 + "integrity": "sha512-+jy+AJtfuTDI5+nhh0hDNcir1p8P+pf+qsHXpUpYvg7EikxUUePBe+a+Kr6j/Xs89o4EbHlVzrh0HOxbqWM31Q==",
3071 + "dev": true,
3072 + "license": "MIT",
3073 + "dependencies": {
3074 + "@types/node": "*",
3075 + "tarn": "^3.0.1",
3076 + "tedious": "*"
3077 + }
3078 + },
3079 "node_modules/@types/node": {
3080 "version": "24.19.1",
3081 "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.1.tgz",
3082 "integrity": "sha512-aS3/DG0oM05K0RIXXP+hKjinGG5IgSSVGzswZxW3O0sS3pH4/fycXundUC9XsszgKCk4gHXylTEK6hyFxVxnoQ==",
2796 - "dev": true,
3083 "license": "MIT",
3084 "dependencies": {
3085 "undici-types": ">=7.24.0 <7.24.7"
@@ -2831,6 +3117,15 @@
3117 "@types/react": "^19.3.0"
3118 }
3119 },
3120 + "node_modules/@types/readable-stream": {
3121 + "version": "4.0.25",
3122 + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.25.tgz",
3123 + "integrity": "sha512-7GsxL8Wd5X3jh73/qgW7WCnbBvGSdD8U3E4Jiuus3/8I+PN20DtlkJtwFhr/sImXfDDQ2Z03i/9wNiIF3TVSsw==",
3124 + "license": "MIT",
3125 + "dependencies": {
3126 + "@types/node": "*"
3127 + }
3128 + },
3129 "node_modules/@types/responselike": {
3130 "version": "1.0.3",
3131 "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz",
@@ -3136,6 +3431,20 @@
3431 "url": "https://opencollective.com/eslint"
3432 }
3433 },
3434 + "node_modules/@typespec/ts-http-runtime": {
3435 + "version": "0.3.9",
3436 + "resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.9.tgz",
3437 + "integrity": "sha512-edSdeAqkdxBVzA1yL1LrLCml1YjyCVvPMtMqJpbF+6K609tHe8V6sQUzFQSGcYNhcuhOceZtjvN32+mpIth30A==",
3438 + "license": "MIT",
3439 + "dependencies": {
3440 + "http-proxy-agent": "^7.0.0",
3441 + "https-proxy-agent": "^7.0.0",
3442 + "tslib": "^2.6.2"
3443 + },
3444 + "engines": {
3445 + "node": ">=22.0.0"
3446 + }
3447 + },
3448 "node_modules/@unrs/resolver-binding-android-arm-eabi": {
3449 "version": "1.12.2",
3450 "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-android-arm-eabi/-/resolver-binding-android-arm-eabi-1.12.2.tgz",
@@ -3625,6 +3934,18 @@
3934 "node": "^20.17.0 || >=22.9.0"
3935 }
3936 },
3937 + "node_modules/abort-controller": {
3938 + "version": "3.0.0",
3939 + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
3940 + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
3941 + "license": "MIT",
3942 + "dependencies": {
3943 + "event-target-shim": "^5.0.0"
3944 + },
3945 + "engines": {
3946 + "node": ">=6.5"
3947 + }
3948 + },
3949 "node_modules/acorn": {
3950 "version": "8.18.0",
3951 "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
@@ -3652,7 +3973,6 @@
3973 "version": "7.1.4",
3974 "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
3975 "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==",
3655 - "dev": true,
3976 "license": "MIT",
3977 "engines": {
3978 "node": ">= 14"
@@ -4260,7 +4580,6 @@
4580 "version": "1.5.1",
4581 "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
4582 "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
4263 - "dev": true,
4583 "funding": [
4584 {
4585 "type": "github",
@@ -4289,6 +4608,63 @@
4608 "node": ">=6.0.0"
4609 }
4610 },
4611 + "node_modules/bl": {
4612 + "version": "6.1.6",
4613 + "resolved": "https://registry.npmjs.org/bl/-/bl-6.1.6.tgz",
4614 + "integrity": "sha512-jLsPgN/YSvPUg9UX0Kd73CXpm2Psg9FxMeCSXnk3WBO3CMT10JMwijubhGfHCnFu6TPn1ei3b975dxv7K2pWVg==",
4615 + "license": "MIT",
4616 + "dependencies": {
4617 + "@types/readable-stream": "^4.0.0",
4618 + "buffer": "^6.0.3",
4619 + "inherits": "^2.0.4",
4620 + "readable-stream": "^4.2.0"
4621 + }
4622 + },
4623 + "node_modules/bl/node_modules/readable-stream": {
4624 + "version": "4.7.0",
4625 + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz",
4626 + "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==",
4627 + "license": "MIT",
4628 + "dependencies": {
4629 + "abort-controller": "^3.0.0",
4630 + "buffer": "^6.0.3",
4631 + "events": "^3.3.0",
4632 + "process": "^0.11.10",
4633 + "string_decoder": "^1.3.0"
4634 + },
4635 + "engines": {
4636 + "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
4637 + }
4638 + },
4639 + "node_modules/bl/node_modules/safe-buffer": {
4640 + "version": "5.2.1",
4641 + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
4642 + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
4643 + "funding": [
4644 + {
4645 + "type": "github",
4646 + "url": "https://github.com/sponsors/feross"
4647 + },
4648 + {
4649 + "type": "patreon",
4650 + "url": "https://www.patreon.com/feross"
4651 + },
4652 + {
4653 + "type": "consulting",
4654 + "url": "https://feross.org/support"
4655 + }
4656 + ],
4657 + "license": "MIT"
4658 + },
4659 + "node_modules/bl/node_modules/string_decoder": {
4660 + "version": "1.3.0",
4661 + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
4662 + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
4663 + "license": "MIT",
4664 + "dependencies": {
4665 + "safe-buffer": "~5.2.0"
4666 + }
4667 + },
4668 "node_modules/bluebird": {
4669 "version": "3.7.2",
4670 "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
@@ -4363,6 +4739,36 @@
4739 "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
4740 }
4741 },
4742 + "node_modules/buffer": {
4743 + "version": "6.0.3",
4744 + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
4745 + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
4746 + "funding": [
4747 + {
4748 + "type": "github",
4749 + "url": "https://github.com/sponsors/feross"
4750 + },
4751 + {
4752 + "type": "patreon",
4753 + "url": "https://www.patreon.com/feross"
4754 + },
4755 + {
4756 + "type": "consulting",
4757 + "url": "https://feross.org/support"
4758 + }
4759 + ],
4760 + "license": "MIT",
4761 + "dependencies": {
4762 + "base64-js": "^1.3.1",
4763 + "ieee754": "^1.2.1"
4764 + }
4765 + },
4766 + "node_modules/buffer-equal-constant-time": {
4767 + "version": "1.0.1",
4768 + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
4769 + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==",
4770 + "license": "BSD-3-Clause"
4771 + },
4772 "node_modules/buffer-from": {
4773 "version": "1.1.2",
4774 "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
@@ -4410,6 +4816,21 @@
4816 "node": ">=12.0.0"
4817 }
4818 },
4819 + "node_modules/bundle-name": {
4820 + "version": "4.1.1",
4821 + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.1.tgz",
4822 + "integrity": "sha512-DdH81/zPLVS11EUgWq3tEu/xn+EzljlMYooDNdzWEnFha3R3NBMpMV1UqYIpjYHV/SgpFKMIX1Oh7o06SjM/oA==",
4823 + "license": "MIT",
4824 + "dependencies": {
4825 + "run-applescript": "^7.0.0"
4826 + },
4827 + "engines": {
4828 + "node": ">=18"
4829 + },
4830 + "funding": {
4831 + "url": "https://github.com/sponsors/sindresorhus"
4832 + }
4833 + },
4834 "node_modules/bytestreamjs": {
4835 "version": "2.0.1",
4836 "resolved": "https://registry.npmjs.org/bytestreamjs/-/bytestreamjs-2.0.1.tgz",
@@ -4820,7 +5241,6 @@
5241 "version": "4.4.3",
5242 "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
5243 "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
4823 - "dev": true,
5244 "license": "MIT",
5245 "dependencies": {
5246 "ms": "^2.1.3"
@@ -4880,6 +5300,34 @@
5300 "dev": true,
5301 "license": "MIT"
5302 },
5303 + "node_modules/default-browser": {
5304 + "version": "5.5.1",
5305 + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.5.1.tgz",
5306 + "integrity": "sha512-m1pAzaJgZ/gssEqlOhJkPJp8Xly7QyW6xcrkUa2KKcDeDSEMP7X8xipU3snUcfisTQx0w1AGae+9UtJSfVnXGw==",
5307 + "license": "MIT",
5308 + "dependencies": {
5309 + "bundle-name": "^4.1.0",
5310 + "default-browser-id": "^5.0.0"
5311 + },
5312 + "engines": {
5313 + "node": ">=18"
5314 + },
5315 + "funding": {
5316 + "url": "https://github.com/sponsors/sindresorhus"
5317 + }
5318 + },
5319 + "node_modules/default-browser-id": {
5320 + "version": "5.0.1",
5321 + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.1.tgz",
5322 + "integrity": "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==",
5323 + "license": "MIT",
5324 + "engines": {
5325 + "node": ">=18"
5326 + },
5327 + "funding": {
5328 + "url": "https://github.com/sponsors/sindresorhus"
5329 + }
5330 + },
5331 "node_modules/defer-to-connect": {
5332 "version": "2.0.1",
5333 "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz",
@@ -4908,6 +5356,18 @@
5356 "url": "https://github.com/sponsors/ljharb"
5357 }
5358 },
5359 + "node_modules/define-lazy-prop": {
5360 + "version": "3.0.0",
5361 + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz",
5362 + "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==",
5363 + "license": "MIT",
5364 + "engines": {
5365 + "node": ">=12"
5366 + },
5367 + "funding": {
5368 + "url": "https://github.com/sponsors/sindresorhus"
5369 + }
5370 + },
5371 "node_modules/define-properties": {
5372 "version": "1.2.1",
5373 "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz",
@@ -5045,6 +5505,15 @@
5505 "readable-stream": "^2.0.2"
5506 }
5507 },
5508 + "node_modules/ecdsa-sig-formatter": {
5509 + "version": "1.0.11",
5510 + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
5511 + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
5512 + "license": "Apache-2.0",
5513 + "dependencies": {
5514 + "safe-buffer": "^5.0.1"
5515 + }
5516 + },
5517 "node_modules/ejs": {
5518 "version": "3.1.10",
5519 "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
@@ -5937,6 +6406,24 @@
6406 "node": ">=0.10.0"
6407 }
6408 },
6409 + "node_modules/event-target-shim": {
6410 + "version": "5.0.1",
6411 + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
6412 + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
6413 + "license": "MIT",
6414 + "engines": {
6415 + "node": ">=6"
6416 + }
6417 + },
6418 + "node_modules/events": {
6419 + "version": "3.3.0",
6420 + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
6421 + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==",
6422 + "license": "MIT",
6423 + "engines": {
6424 + "node": ">=0.8.x"
6425 + }
6426 + },
6427 "node_modules/expect-type": {
6428 "version": "1.4.0",
6429 "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz",
@@ -6676,7 +7163,6 @@
7163 "version": "7.0.2",
7164 "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz",
7165 "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==",
6679 - "dev": true,
7166 "license": "MIT",
7167 "dependencies": {
7168 "agent-base": "^7.1.0",
@@ -6704,7 +7190,6 @@
7190 "version": "7.0.6",
7191 "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
7192 "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
6707 - "dev": true,
7193 "license": "MIT",
7194 "dependencies": {
7195 "agent-base": "^7.1.2",
@@ -6714,6 +7199,42 @@
7199 "node": ">= 14"
7200 }
7201 },
7202 + "node_modules/iconv-lite": {
7203 + "version": "0.7.3",
7204 + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
7205 + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==",
7206 + "license": "MIT",
7207 + "dependencies": {
7208 + "safer-buffer": ">= 2.1.2 < 3.0.0"
7209 + },
7210 + "engines": {
7211 + "node": ">=0.10.0"
7212 + },
7213 + "funding": {
7214 + "type": "opencollective",
7215 + "url": "https://opencollective.com/express"
7216 + }
7217 + },
7218 + "node_modules/ieee754": {
7219 + "version": "1.2.1",
7220 + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
7221 + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
7222 + "funding": [
7223 + {
7224 + "type": "github",
7225 + "url": "https://github.com/sponsors/feross"
7226 + },
7227 + {
7228 + "type": "patreon",
7229 + "url": "https://www.patreon.com/feross"
7230 + },
7231 + {
7232 + "type": "consulting",
7233 + "url": "https://feross.org/support"
7234 + }
7235 + ],
7236 + "license": "BSD-3-Clause"
7237 + },
7238 "node_modules/ignore": {
7239 "version": "5.3.2",
7240 "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
@@ -6767,7 +7288,6 @@
7288 "version": "2.0.4",
7289 "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
7290 "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
6770 - "dev": true,
7291 "license": "ISC"
7292 },
7293 "node_modules/internal-slot": {
@@ -6943,6 +7463,21 @@
7463 "url": "https://github.com/sponsors/ljharb"
7464 }
7465 },
7466 + "node_modules/is-docker": {
7467 + "version": "3.0.0",
7468 + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
7469 + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==",
7470 + "license": "MIT",
7471 + "bin": {
7472 + "is-docker": "cli.js"
7473 + },
7474 + "engines": {
7475 + "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
7476 + },
7477 + "funding": {
7478 + "url": "https://github.com/sponsors/sindresorhus"
7479 + }
7480 + },
7481 "node_modules/is-document.all": {
7482 "version": "1.0.0",
7483 "resolved": "https://registry.npmjs.org/is-document.all/-/is-document.all-1.0.0.tgz",
@@ -7028,6 +7563,24 @@
7563 "node": ">=0.10.0"
7564 }
7565 },
7566 + "node_modules/is-inside-container": {
7567 + "version": "1.0.0",
7568 + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz",
7569 + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==",
7570 + "license": "MIT",
7571 + "dependencies": {
7572 + "is-docker": "^3.0.0"
7573 + },
7574 + "bin": {
7575 + "is-inside-container": "cli.js"
7576 + },
7577 + "engines": {
7578 + "node": ">=14.16"
7579 + },
7580 + "funding": {
7581 + "url": "https://github.com/sponsors/sindresorhus"
7582 + }
7583 + },
7584 "node_modules/is-map": {
7585 "version": "2.0.3",
7586 "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz",
@@ -7226,6 +7779,21 @@
7779 "url": "https://github.com/sponsors/ljharb"
7780 }
7781 },
7782 + "node_modules/is-wsl": {
7783 + "version": "3.1.1",
7784 + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz",
7785 + "integrity": "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==",
7786 + "license": "MIT",
7787 + "dependencies": {
7788 + "is-inside-container": "^1.0.0"
7789 + },
7790 + "engines": {
7791 + "node": ">=16"
7792 + },
7793 + "funding": {
7794 + "url": "https://github.com/sponsors/sindresorhus"
7795 + }
7796 + },
7797 "node_modules/isarray": {
7798 "version": "2.0.5",
7799 "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
@@ -7299,6 +7867,12 @@
7867 "jiti": "lib/jiti-cli.mjs"
7868 }
7869 },
7870 + "node_modules/js-md4": {
7871 + "version": "0.3.2",
7872 + "resolved": "https://registry.npmjs.org/js-md4/-/js-md4-0.3.2.tgz",
7873 + "integrity": "sha512-/GDnfQYsltsjRswQhN9fhv3EMw2sCpUdrdxyWDOUK7eyD++r3gRhzgiQgc/x4MAv2i1iuQ4lxO5mvqM3vj4bwA==",
7874 + "license": "MIT"
7875 + },
7876 "node_modules/js-tokens": {
7877 "version": "9.0.1",
7878 "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz",
@@ -7397,6 +7971,40 @@
7971 "graceful-fs": "^4.1.6"
7972 }
7973 },
7974 + "node_modules/jsonwebtoken": {
7975 + "version": "9.0.3",
7976 + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz",
7977 + "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==",
7978 + "license": "MIT",
7979 + "dependencies": {
7980 + "jws": "^4.0.1",
7981 + "lodash.includes": "^4.3.0",
7982 + "lodash.isboolean": "^3.0.3",
7983 + "lodash.isinteger": "^4.0.4",
7984 + "lodash.isnumber": "^3.0.3",
7985 + "lodash.isplainobject": "^4.0.6",
7986 + "lodash.isstring": "^4.0.1",
7987 + "lodash.once": "^4.0.0",
7988 + "ms": "^2.1.1",
7989 + "semver": "^7.5.4"
7990 + },
7991 + "engines": {
7992 + "node": ">=12",
7993 + "npm": ">=6"
7994 + }
7995 + },
7996 + "node_modules/jsonwebtoken/node_modules/semver": {
7997 + "version": "7.8.5",
7998 + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
7999 + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
8000 + "license": "ISC",
8001 + "bin": {
8002 + "semver": "bin/semver.js"
8003 + },
8004 + "engines": {
8005 + "node": ">=10"
8006 + }
8007 + },
8008 "node_modules/jsx-ast-utils": {
8009 "version": "3.3.5",
8010 "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz",
@@ -7413,6 +8021,27 @@
8021 "node": ">=4.0"
8022 }
8023 },
8024 + "node_modules/jwa": {
8025 + "version": "2.0.1",
8026 + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz",
8027 + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==",
8028 + "license": "MIT",
8029 + "dependencies": {
8030 + "buffer-equal-constant-time": "^1.0.1",
8031 + "ecdsa-sig-formatter": "1.0.11",
8032 + "safe-buffer": "^5.0.1"
8033 + }
8034 + },
8035 + "node_modules/jws": {
8036 + "version": "4.0.1",
8037 + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz",
8038 + "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==",
8039 + "license": "MIT",
8040 + "dependencies": {
8041 + "jwa": "^2.0.1",
8042 + "safe-buffer": "^5.0.1"
8043 + }
8044 + },
8045 "node_modules/keyv": {
8046 "version": "4.5.4",
8047 "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
@@ -7487,6 +8116,42 @@
8116 "dev": true,
8117 "license": "MIT"
8118 },
8119 + "node_modules/lodash.includes": {
8120 + "version": "4.3.0",
8121 + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
8122 + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==",
8123 + "license": "MIT"
8124 + },
8125 + "node_modules/lodash.isboolean": {
8126 + "version": "3.0.3",
8127 + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
8128 + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==",
8129 + "license": "MIT"
8130 + },
8131 + "node_modules/lodash.isinteger": {
8132 + "version": "4.0.4",
8133 + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
8134 + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==",
8135 + "license": "MIT"
8136 + },
8137 + "node_modules/lodash.isnumber": {
8138 + "version": "3.0.3",
8139 + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
8140 + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==",
8141 + "license": "MIT"
8142 + },
8143 + "node_modules/lodash.isplainobject": {
8144 + "version": "4.0.6",
8145 + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
8146 + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==",
8147 + "license": "MIT"
8148 + },
8149 + "node_modules/lodash.isstring": {
8150 + "version": "4.0.1",
8151 + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
8152 + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==",
8153 + "license": "MIT"
8154 + },
8155 "node_modules/lodash.merge": {
8156 "version": "4.6.2",
8157 "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
@@ -7494,6 +8159,12 @@
8159 "dev": true,
8160 "license": "MIT"
8161 },
8162 + "node_modules/lodash.once": {
8163 + "version": "4.1.1",
8164 + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
8165 + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==",
8166 + "license": "MIT"
8167 + },
8168 "node_modules/loose-envify": {
8169 "version": "1.4.0",
8170 "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
@@ -7722,9 +8393,36 @@
8393 "version": "2.1.3",
8394 "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
8395 "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
7725 - "dev": true,
8396 "license": "MIT"
8397 },
8398 + "node_modules/mssql": {
8399 + "version": "12.7.4",
8400 + "resolved": "https://registry.npmjs.org/mssql/-/mssql-12.7.4.tgz",
8401 + "integrity": "sha512-rhN4TefcWOle1JsTep32bHGhHpcQPL9B08Q3P5HcTBRmZ+Irt/zI4y7TI2CXc2t3lP702fYoCASLPJiWh77KBA==",
8402 + "license": "MIT",
8403 + "dependencies": {
8404 + "@tediousjs/connection-string": "^1.0.0",
8405 + "commander": "^11.0.0",
8406 + "debug": "^4.3.3",
8407 + "tarn": "^3.0.2",
8408 + "tedious": "^19.2.2 || ^20.0.0"
8409 + },
8410 + "bin": {
8411 + "mssql": "bin/mssql"
8412 + },
8413 + "engines": {
8414 + "node": ">=18.19.0"
8415 + }
8416 + },
8417 + "node_modules/mssql/node_modules/commander": {
8418 + "version": "11.1.0",
8419 + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
8420 + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
8421 + "license": "MIT",
8422 + "engines": {
8423 + "node": ">=16"
8424 + }
8425 + },
8426 "node_modules/nanoid": {
8427 "version": "3.3.20",
8428 "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz",
@@ -7759,6 +8457,12 @@
8457 "url": "https://opencollective.com/napi-postinstall"
8458 }
8459 },
8460 + "node_modules/native-duplexpair": {
8461 + "version": "1.0.0",
8462 + "resolved": "https://registry.npmjs.org/native-duplexpair/-/native-duplexpair-1.0.0.tgz",
8463 + "integrity": "sha512-E7QQoM+3jvNtlmyfqRZ0/U75VFgCls+fSkbml2MpgWkWyz3ox8Y58gNhfuziuQYGNNQAbFZJQck55LHCnCK6CA==",
8464 + "license": "MIT"
8465 + },
8466 "node_modules/natural-compare": {
8467 "version": "1.4.0",
8468 "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
@@ -8178,6 +8882,24 @@
8882 "wrappy": "1"
8883 }
8884 },
8885 + "node_modules/open": {
8886 + "version": "10.2.0",
8887 + "resolved": "https://registry.npmjs.org/open/-/open-10.2.0.tgz",
8888 + "integrity": "sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==",
8889 + "license": "MIT",
8890 + "dependencies": {
8891 + "default-browser": "^5.2.1",
8892 + "define-lazy-prop": "^3.0.0",
8893 + "is-inside-container": "^1.0.0",
8894 + "wsl-utils": "^0.1.0"
8895 + },
8896 + "engines": {
8897 + "node": ">=18"
8898 + },
8899 + "funding": {
8900 + "url": "https://github.com/sponsors/sindresorhus"
8901 + }
8902 + },
8903 "node_modules/optionator": {
8904 "version": "0.9.4",
8905 "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
@@ -8624,6 +9346,15 @@
9346 "node": "^20.17.0 || >=22.9.0"
9347 }
9348 },
9349 + "node_modules/process": {
9350 + "version": "0.11.10",
9351 + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
9352 + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
9353 + "license": "MIT",
9354 + "engines": {
9355 + "node": ">= 0.6.0"
9356 + }
9357 + },
9358 "node_modules/process-nextick-args": {
9359 "version": "2.0.1",
9360 "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@@ -9065,6 +9796,18 @@
9796 "fsevents": "~2.3.2"
9797 }
9798 },
9799 + "node_modules/run-applescript": {
9800 + "version": "7.1.0",
9801 + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz",
9802 + "integrity": "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==",
9803 + "license": "MIT",
9804 + "engines": {
9805 + "node": ">=18"
9806 + },
9807 + "funding": {
9808 + "url": "https://github.com/sponsors/sindresorhus"
9809 + }
9810 + },
9811 "node_modules/run-parallel": {
9812 "version": "1.2.0",
9813 "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
@@ -9113,7 +9856,6 @@
9856 "version": "5.1.2",
9857 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
9858 "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
9116 - "dev": true,
9859 "license": "MIT"
9860 },
9861 "node_modules/safe-push-apply": {
@@ -9151,6 +9893,12 @@
9893 "url": "https://github.com/sponsors/ljharb"
9894 }
9895 },
9896 + "node_modules/safer-buffer": {
9897 + "version": "2.1.2",
9898 + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
9899 + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
9900 + "license": "MIT"
9901 + },
9902 "node_modules/sanitize-filename": {
9903 "version": "1.6.4",
9904 "resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.4.tgz",
@@ -9506,9 +10254,7 @@
10254 "version": "1.1.3",
10255 "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
10256 "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==",
9509 - "dev": true,
9510 - "license": "BSD-3-Clause",
9511 - "optional": true
10257 + "license": "BSD-3-Clause"
10258 },
10259 "node_modules/stable-hash": {
10260 "version": "0.0.5",
@@ -9839,6 +10585,36 @@
10585 "node": ">=18"
10586 }
10587 },
10588 + "node_modules/tarn": {
10589 + "version": "3.1.2",
10590 + "resolved": "https://registry.npmjs.org/tarn/-/tarn-3.1.2.tgz",
10591 + "integrity": "sha512-3RTvqKZcK/17jnJ8rMKFXbyNogywTs1z0gVPPwFsJGX46rkmUHOdIaSQ/aVO1rS7nH+soiXiWk7rvUXxndm8Dg==",
10592 + "license": "MIT",
10593 + "engines": {
10594 + "node": ">=8.0.0"
10595 + }
10596 + },
10597 + "node_modules/tedious": {
10598 + "version": "20.3.3",
10599 + "resolved": "https://registry.npmjs.org/tedious/-/tedious-20.3.3.tgz",
10600 + "integrity": "sha512-PgK/FhX/I4A6IfuQrZ03pok0hXa2LSVsvfXR+EmLeagiFhXzm97UtKQI4+lDDdQx9sKg1U2ag0dN8k7CQRgPhw==",
10601 + "license": "MIT",
10602 + "dependencies": {
10603 + "@azure/core-auth": "^1.10.1",
10604 + "@azure/identity": "^4.13.1",
10605 + "@azure/keyvault-keys": "^4.10.2",
10606 + "@js-joda/core": "^6.0.1",
10607 + "@types/node": ">=22",
10608 + "bl": "^6.1.4",
10609 + "iconv-lite": "^0.7.0",
10610 + "js-md4": "^0.3.2",
10611 + "native-duplexpair": "^1.0.0",
10612 + "sprintf-js": "^1.1.3"
10613 + },
10614 + "engines": {
10615 + "node": ">=22"
10616 + }
10617 + },
10618 "node_modules/temp": {
10619 "version": "0.9.4",
10620 "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz",
@@ -10210,7 +10986,6 @@
10986 "version": "7.24.6",
10987 "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
10988 "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
10213 - "dev": true,
10989 "license": "MIT"
10990 },
10991 "node_modules/universalify": {
@@ -10687,6 +11462,21 @@
11462 "dev": true,
11463 "license": "ISC"
11464 },
11465 + "node_modules/wsl-utils": {
11466 + "version": "0.1.0",
11467 + "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-0.1.0.tgz",
11468 + "integrity": "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw==",
11469 + "license": "MIT",
11470 + "dependencies": {
11471 + "is-wsl": "^3.1.0"
11472 + },
11473 + "engines": {
11474 + "node": ">=18"
11475 + },
11476 + "funding": {
11477 + "url": "https://github.com/sponsors/sindresorhus"
11478 + }
11479 + },
11480 "node_modules/xmlbuilder": {
11481 "version": "15.1.1",
11482 "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz",
package.json
+2
@@ -15,12 +15,14 @@
15 "desktop:dir": "npm run build && node scripts/prepare-standalone.mjs && electron-builder --dir"
16 },
17 "dependencies": {
18 + "mssql": "^12.7.4",
19 "next": "16.3.8",
20 "pg": "^8.23.1",
21 "react": "19.2.0",
22 "react-dom": "19.2.0"
23 },
24 "devDependencies": {
25 + "@types/mssql": "^12.3.0",
26 "@types/node": "^24.0.0",
27 "@types/pg": "^8.23.1",
28 "@types/react": "^19.0.0",
src/domain/payments/payment-guard.test.ts new
+9
@@ -0,0 +1,9 @@
1 +import {describe,expect,it} from 'vitest';
2 +import {evaluatePaymentGuard} from './payment-guard';
3 +const base={sourceAccountId:'a1',beneficiaryId:'b1',iban:'IR062960000000100324200001',amountIrr:1000,clientReference:'R-1',paymentDate:'2026-10-06'};
4 +describe('Mayan-inspired payment guard',()=>{
5 + it('blocks duplicate client reference',()=>expect(evaluatePaymentGuard(base,[base])).toMatchObject({ok:false,code:'DUPLICATE_REFERENCE'}));
6 + it('blocks duplicate fingerprint even with another reference',()=>expect(evaluatePaymentGuard({...base,clientReference:'R-2'},[{...base,clientReference:'OLD'}])).toMatchObject({ok:false,code:'DUPLICATE_PAYMENT'}));
7 + it('rejects invalid Iranian IBAN',()=>expect(evaluatePaymentGuard({...base,iban:'IR000'},[])).toMatchObject({ok:false,code:'INVALID_IBAN'}));
8 + it('accepts a distinct valid payment',()=>expect(evaluatePaymentGuard(base,[])).toEqual({ok:true}));
9 +});
src/domain/payments/payment-guard.ts new
+11
@@ -0,0 +1,11 @@
1 +export type PaymentGuardInput={sourceAccountId:string;beneficiaryId:string;iban:string;amountIrr:number;clientReference:string;paymentDate:string};
2 +export type PaymentGuardResult={ok:true}|{ok:false;code:'INVALID_IBAN'|'DUPLICATE_REFERENCE'|'DUPLICATE_PAYMENT'};
3 +const normalized=(v:string)=>v.replace(/\s+/g,'').toUpperCase();
4 +export function isValidIranianIban(v:string){const iban=normalized(v);if(!/^IR\d{24}$/.test(iban))return false;const rearranged=iban.slice(4)+iban.slice(0,4);let rem=0;for(const ch of rearranged){const part=/\d/.test(ch)?ch:String(ch.charCodeAt(0)-55);for(const digit of part)rem=(rem*10+Number(digit))%97}return rem===1}
5 +export function evaluatePaymentGuard(next:PaymentGuardInput,existing:PaymentGuardInput[]):PaymentGuardResult{
6 + if(!isValidIranianIban(next.iban)) return {ok:false,code:'INVALID_IBAN'};
7 + if(existing.some(p=>p.clientReference.trim()===next.clientReference.trim())) return {ok:false,code:'DUPLICATE_REFERENCE'};
8 + const fingerprint=(p:PaymentGuardInput)=>[p.sourceAccountId,p.beneficiaryId,normalized(p.iban),p.amountIrr,p.paymentDate].join('|');
9 + if(existing.some(p=>fingerprint(p)===fingerprint(next))) return {ok:false,code:'DUPLICATE_PAYMENT'};
10 + return {ok:true};
11 +}
src/platform/application/server-service.ts
+3 -6
@@ -1,10 +1,7 @@
1 -import {LocalStore,defaultLocalStorePath} from '../local/local-store';
1 +import {SqliteStore,defaultSqliteStorePath} from '../local/sqlite-store';
2 import {TreasuryService} from './treasury-service';
3 import type {ActorContext} from './types';
4 -
4 export function getDesktopTreasuryService(actor:ActorContext={tenantId:'local',userId:'local-maker',role:'MAKER'}){
6 - if(process.env.NODE_ENV==='production'&&process.env.TREASURYFLOW_DESKTOP_LOCAL!=='1'){
7 - throw new Error('desktop local service disabled in production');
8 - }
9 - return new TreasuryService(new LocalStore(process.env.TREASURYFLOW_DATA_FILE||defaultLocalStorePath()),actor);
5 + if(process.env.NODE_ENV==='production'&&process.env.TREASURYFLOW_DESKTOP_LOCAL!=='1') throw new Error('desktop local service disabled in production');
6 + return new TreasuryService(new SqliteStore(process.env.TREASURYFLOW_DATA_FILE||defaultSqliteStorePath()),actor);
7 }
src/platform/application/store.ts new
+2
@@ -0,0 +1,2 @@
1 +import type {LocalStoreData} from './types';
2 +export interface TreasuryStore{snapshot():LocalStoreData;update(mutator:(data:LocalStoreData)=>LocalStoreData):LocalStoreData}
src/platform/application/treasury-service-dispatch.test.ts new
+44
@@ -0,0 +1,44 @@
1 +import {afterEach,describe,expect,it,vi} from 'vitest';
2 +import {mkdtempSync,rmSync} from 'node:fs';
3 +import {tmpdir} from 'node:os';
4 +import {join} from 'node:path';
5 +import {LocalStore} from '../local/local-store';
6 +import {TreasuryService} from './treasury-service';
7 +import type {BankAdapter} from '../../domain/bank-adapter';
8 +
9 +const dirs:string[]=[];
10 +function newStore(){
11 + const dir=mkdtempSync(join(tmpdir(),'tf-dispatch-'));
12 + dirs.push(dir);
13 + return new LocalStore(join(dir,'store.json'));
14 +}
15 +afterEach(()=>dirs.splice(0).forEach(d=>rmSync(d,{recursive:true,force:true})));
16 +
17 +function prepareQueued(store:LocalStore,id:string,amountIrr:number,reference:string,date:string){
18 + const maker=new TreasuryService(store,{tenantId:'local',userId:'maker',role:'MAKER'});
19 + maker.createAccount({id:'a1',name:'حساب',iban:'IR062960000000100324200001',bankName:'بانک'});
20 + maker.createBeneficiary({id:'b1',name:'ذی‌نفع',iban:'IR062960000000100324200001',whitelisted:true});
21 + maker.createPayment({id,sourceAccountId:'a1',beneficiaryId:'b1',amountIrr,paymentDate:date,clientReference:reference,description:''});
22 + maker.submitPayment(id);
23 + const checker=new TreasuryService(store,{tenantId:'local',userId:'checker',role:'CHECKER'});
24 + checker.approvePayment(id);
25 + checker.queuePayment(id);
26 + return checker;
27 +}
28 +
29 +describe('TreasuryService bank dispatch',()=>{
30 + it('records bank reference and moves queued payment to submitted',async()=>{
31 + const checker=prepareQueued(newStore(),'p1',1000,'R1','2026-10-06');
32 + const adapter:BankAdapter={submit:vi.fn().mockResolvedValue({outcome:'ACCEPTED',bankReference:'TRK-1'}),poll:vi.fn()};
33 + const p=await checker.dispatchPayment('p1',adapter);
34 + expect(p.state).toBe('SUBMITTED');
35 + expect(p.bankReference).toBe('TRK-1');
36 + });
37 + it('marks unknown bank outcome for manual review path',async()=>{
38 + const checker=prepareQueued(newStore(),'p2',1001,'R2','2026-10-07');
39 + const adapter:BankAdapter={submit:vi.fn().mockResolvedValue({outcome:'UNKNOWN',bankReference:'TRK-2'}),poll:vi.fn()};
40 + const p=await checker.dispatchPayment('p2',adapter);
41 + expect(p.state).toBe('UNKNOWN');
42 + expect(p.bankReference).toBe('TRK-2');
43 + });
44 +});
src/platform/application/treasury-service-guard.test.ts new
+3
@@ -0,0 +1,3 @@
1 +import {afterEach,describe,expect,it} from 'vitest';import {mkdtempSync,rmSync} from 'node:fs';import {tmpdir} from 'node:os';import {join} from 'node:path';import {LocalStore} from '../local/local-store';import {TreasuryService} from './treasury-service';
2 +const ds:string[]=[];const service=()=>{const d=mkdtempSync(join(tmpdir(),'tf-guard-'));ds.push(d);const s=new TreasuryService(new LocalStore(join(d,'db.json')),{tenantId:'local',userId:'maker',role:'MAKER'});s.createAccount({id:'a1',name:'حساب',iban:'IR062960000000100324200001',bankName:'بانک'});s.createBeneficiary({id:'b1',name:'ذی‌نفع',iban:'IR062960000000100324200001',whitelisted:true});return s};afterEach(()=>ds.splice(0).forEach(d=>rmSync(d,{recursive:true,force:true})));
3 +describe('TreasuryService duplicate guard',()=>{it('blocks duplicate fingerprint even if reference differs',()=>{const s=service();s.createPayment({id:'p1',sourceAccountId:'a1',beneficiaryId:'b1',amountIrr:1000,paymentDate:'2026-10-06',clientReference:'R1',description:''});expect(()=>s.createPayment({id:'p2',sourceAccountId:'a1',beneficiaryId:'b1',amountIrr:1000,paymentDate:'2026-10-06',clientReference:'R2',description:''})).toThrow(/duplicate payment/i)})});
src/platform/application/treasury-service.ts
+30 -4
@@ -1,14 +1,17 @@
1 -import {createBankAccount,createBeneficiary} from '../../domain/core/master-data';
1 +import {createBankAccount,createBeneficiary} from '../../domain/core/master-data';
2 import {evaluatePaymentPolicy} from '../../domain/core/policy';
3 import {canApprove} from '../../domain/approvals/approval-policy';
4 import {transitionPayment} from '../../domain/payments/payment-state';
5 import {dashboard} from '../../domain/operations/dashboard';
6 +import type {BankAdapter} from '../../domain/bank-adapter';
7 +import {BankDispatchRegistry} from '../../domain/bank-adapter';
8 import {validateIranianIban} from '../../domain/iran/iban';
7 -import type {LocalStore} from '../local/local-store';
9 +import {evaluatePaymentGuard} from '../../domain/payments/payment-guard';
10 +import type {TreasuryStore} from './store';
11 import type {ActorContext,LocalAccount,LocalAudit,LocalBeneficiary,LocalPayment} from './types';
12
13 export class TreasuryService{
11 - constructor(private readonly store:LocalStore,private readonly actor:ActorContext){}
14 + constructor(private readonly store:TreasuryStore,private readonly actor:ActorContext){}
15
16 private own<T extends {tenantId:string}>(rows:T[]){
17 return rows.filter(x=>x.tenantId===this.actor.tenantId);
@@ -81,7 +84,10 @@ export class TreasuryService{
84 if(!Number.isSafeInteger(input.amountIrr)||input.amountIrr<=0) throw new Error('invalid amount');
85 if(!input.paymentDate||!input.clientReference.trim()) throw new Error('payment fields required');
86 if(!this.listAccounts().some(x=>x.id===input.sourceAccountId)) throw new Error('source account not found');
84 - if(!this.listBeneficiaries().some(x=>x.id===input.beneficiaryId)) throw new Error('beneficiary not found');
87 + const beneficiary=this.listBeneficiaries().find(x=>x.id===input.beneficiaryId);
88 + if(!beneficiary) throw new Error('beneficiary not found');
89 + const guard=evaluatePaymentGuard({sourceAccountId:input.sourceAccountId,beneficiaryId:input.beneficiaryId,iban:beneficiary.iban,amountIrr:input.amountIrr,clientReference:input.clientReference,paymentDate:input.paymentDate},this.listPayments().map(p=>({sourceAccountId:p.sourceAccountId,beneficiaryId:p.beneficiaryId,iban:this.listBeneficiaries().find(b=>b.id===p.beneficiaryId)?.iban??'',amountIrr:p.amountIrr,clientReference:p.clientReference,paymentDate:p.paymentDate})));
90 + if(!guard.ok) throw new Error(guard.code==='DUPLICATE_PAYMENT'?'duplicate payment':guard.code==='DUPLICATE_REFERENCE'?'duplicate payment reference':'invalid Iranian IBAN');
91 const payment:LocalPayment={
92 ...input,
93 clientReference:input.clientReference.trim(),
@@ -148,5 +154,25 @@ export class TreasuryService{
154 return this.changeState(id,transitionPayment(payment.state,'QUEUE'),'PAYMENT_QUEUED');
155 }
156
157 + async dispatchPayment(id:string,adapter:BankAdapter){
158 + const payment=this.getPayment(id);
159 + if(payment.state!=='QUEUED'||payment.approvedVersion!==payment.version) throw new Error('payment not eligible for dispatch');
160 + const registry=new BankDispatchRegistry();
161 + const dispatch=registry.begin({tenantId:payment.tenantId,paymentId:payment.id,version:payment.version});
162 + const result=await adapter.submit({tenantId:payment.tenantId,paymentId:payment.id,version:payment.version,idempotencyKey:dispatch.idempotencyKey});
163 + registry.record(dispatch.idempotencyKey,result.outcome);
164 + return this.store.update(d=>{
165 + const row=d.payments.find(x=>x.tenantId===this.actor.tenantId&&x.id===id);
166 + if(!row) throw new Error('payment not found');
167 + row.state=transitionPayment(row.state,'DISPATCH');
168 + row.bankReference=result.bankReference;
169 + if(result.outcome==='REJECTED') row.state=transitionPayment(row.state,'FAIL');
170 + else if(result.outcome==='UNKNOWN') row.state=transitionPayment(row.state,'UNKNOWN_RESULT');
171 + d.audit.push({tenantId:this.actor.tenantId,seq:d.audit.length+1,actor:this.actor.userId,action:'PAYMENT_BANK_'+result.outcome,entity:id,at:Date.now()});
172 + return d;
173 + }).payments.find(x=>x.tenantId===this.actor.tenantId&&x.id===id)!;
174 + }
175 +
176 getDashboard(){return dashboard(this.actor.tenantId,this.listPayments())}
177 }
178 +
src/platform/integration/sql-server-adapter.test.ts new
+7
@@ -0,0 +1,7 @@
1 +import {describe,expect,it} from 'vitest';
2 +import {validateExternalSqlServerConfig,buildSqlServerReadModelPolicy} from './sql-server-adapter';
3 +describe('external accounting SQL Server adapter policy',()=>{
4 + it('requires explicit server and database',()=>expect(validateExternalSqlServerConfig({server:'',database:'',auth:'windows'})).toEqual(expect.arrayContaining(['server','database'])));
5 + it('is read only by default',()=>expect(buildSqlServerReadModelPolicy()).toMatchObject({readOnly:true,allowArbitraryWrite:false,allowStoredProcedureWrite:false}));
6 + it('requires explicit approved write contract before accounting writes',()=>expect(buildSqlServerReadModelPolicy({approvedWriteContract:'peyvast-v1'})).toMatchObject({readOnly:false,allowArbitraryWrite:false,allowStoredProcedureWrite:true}));
7 +});
src/platform/integration/sql-server-adapter.ts new
+3
@@ -0,0 +1,3 @@
1 +export type ExternalSqlServerConfig={server:string;database:string;auth:'windows'|'sql';user?:string;password?:string;encrypt?:boolean;trustServerCertificate?:boolean};
2 +export function validateExternalSqlServerConfig(config:ExternalSqlServerConfig){const errors:string[]=[];if(!config.server.trim())errors.push('server');if(!config.database.trim())errors.push('database');if(config.auth==='sql'&&(!config.user?.trim()||!config.password))errors.push('credentials');return errors}
3 +export function buildSqlServerReadModelPolicy(options?:{approvedWriteContract?:string}){const approved=Boolean(options?.approvedWriteContract);return {readOnly:!approved,allowArbitraryWrite:false,allowStoredProcedureWrite:approved,approvedWriteContract:options?.approvedWriteContract??null} as const}
src/platform/integration/sql-server-client.test.ts new
+8
@@ -0,0 +1,8 @@
1 +import {describe,expect,it,vi} from 'vitest';
2 +import {SqlServerAccountingAdapter} from './sql-server-client';
3 +const config={server:'localhost',database:'Accounting',auth:'windows' as const};
4 +describe('SqlServerAccountingAdapter',()=>{
5 + it('tests connectivity with a harmless read',async()=>{const query=vi.fn().mockResolvedValue({recordset:[{ok:1}]});const close=vi.fn();const connect=vi.fn().mockResolvedValue({request:()=>({query}),close});const a=new SqlServerAccountingAdapter(config,{connect} as any);expect(await a.testConnection()).toEqual({ok:true});expect(query).toHaveBeenCalledWith('SELECT 1 AS ok');expect(close).toHaveBeenCalled()});
6 + it('rejects writes when no approved contract exists',async()=>{const a=new SqlServerAccountingAdapter(config,{connect:vi.fn()} as any);await expect(a.executeApprovedWrite('anything',{})).rejects.toThrow(/approved write contract/i)});
7 + it('lists schema metadata without changing accounting data',async()=>{const rows=[{schema_name:'dbo',table_name:'Persons',column_name:'Code',data_type:'int'}];const query=vi.fn().mockResolvedValue({recordset:rows});const close=vi.fn();const connect=vi.fn().mockResolvedValue({request:()=>({query}),close});const a=new SqlServerAccountingAdapter(config,{connect} as any);expect(await a.inspectSchema()).toEqual(rows);expect(String(query.mock.calls[0][0])).toContain('INFORMATION_SCHEMA.COLUMNS')});
8 +});
src/platform/integration/sql-server-client.ts new
+12
@@ -0,0 +1,12 @@
1 +import sql from 'mssql';
2 +import type {ExternalSqlServerConfig} from './sql-server-adapter';
3 +
4 +type Driver={connect:(config:any)=>Promise<any>};
5 +export class SqlServerAccountingAdapter{
6 + constructor(private config:ExternalSqlServerConfig,private driver:Driver=sql as unknown as Driver,private approvedWriteContract?:string){}
7 + private driverConfig(){const c:any={server:this.config.server,database:this.config.database,options:{encrypt:this.config.encrypt??false,trustServerCertificate:this.config.trustServerCertificate??true}};if(this.config.auth==='sql'){c.user=this.config.user;c.password=this.config.password}else{c.options.trustedConnection=true}return c}
8 + private async withPool<T>(fn:(pool:any)=>Promise<T>){const pool=await this.driver.connect(this.driverConfig());try{return await fn(pool)}finally{await pool.close()}}
9 + async testConnection(){return this.withPool(async pool=>{const r=await pool.request().query('SELECT 1 AS ok');return {ok:Number(r.recordset?.[0]?.ok)===1}})}
10 + async inspectSchema(){return this.withPool(async pool=>(await pool.request().query(`SELECT TABLE_SCHEMA AS schema_name,TABLE_NAME AS table_name,COLUMN_NAME AS column_name,DATA_TYPE AS data_type FROM INFORMATION_SCHEMA.COLUMNS ORDER BY TABLE_SCHEMA,TABLE_NAME,ORDINAL_POSITION`)).recordset)}
11 + async executeApprovedWrite(_operation:string,_params:Record<string,unknown>){if(!this.approvedWriteContract)throw new Error('approved write contract required');throw new Error('write contract implementation not installed')}
12 +}
src/platform/local/sqlite-store.test.ts new
+17
@@ -0,0 +1,17 @@
1 +import {afterEach,describe,expect,it} from 'vitest';
2 +import {mkdtempSync,rmSync} from 'node:fs';
3 +import {tmpdir} from 'node:os';
4 +import {join} from 'node:path';
5 +import {DatabaseSync} from 'node:sqlite';
6 +import {SqliteStore} from './sqlite-store';
7 +const dirs:string[]=[];
8 +const make=()=>{const d=mkdtempSync(join(tmpdir(),'tf-sqlite-'));dirs.push(d);return join(d,'treasuryflow.db')};
9 +afterEach(()=>dirs.splice(0).forEach(d=>rmSync(d,{recursive:true,force:true})));
10 +describe('SqliteStore',()=>{
11 + it('creates normalized SQL tables and persists data',()=>{
12 + const f=make();const s=new SqliteStore(f);s.update(d=>({...d,accounts:[{id:'a1',tenantId:'t1',name:'اصلی',iban:'IR062960000000100324200001',bankName:'بانک',status:'ACTIVE'}]}));s.close();
13 + const db=new DatabaseSync(f);const tables=db.prepare("select name from sqlite_master where type='table' order by name").all().map((r:any)=>r.name);expect(tables).toEqual(expect.arrayContaining(['meta','accounts','beneficiaries','payments','audit']));expect(db.prepare('select count(*) as c from accounts').get()).toMatchObject({c:1});db.close();
14 + const s2=new SqliteStore(f);expect(s2.snapshot().accounts[0].id).toBe('a1');s2.close();
15 + });
16 + it('uses SQLite foreign SQL storage rather than JSON serialization',()=>{const f=make();const s=new SqliteStore(f);s.close();const db=new DatabaseSync(f);expect(db.prepare('pragma journal_mode').get()).toBeTruthy();db.close()});
17 +});
src/platform/local/sqlite-store.ts new
+130
@@ -0,0 +1,130 @@
1 +import {mkdirSync} from 'node:fs';
2 +import {dirname} from 'node:path';
3 +import {DatabaseSync} from 'node:sqlite';
4 +import type {LocalStoreData,LocalAccount,LocalBeneficiary,LocalPayment,LocalAudit} from '../application/types';
5 +
6 +const empty=():LocalStoreData=>({
7 + version:1,
8 + meta:{organizationName:'TreasuryFlow'},
9 + accounts:[],
10 + beneficiaries:[],
11 + payments:[],
12 + audit:[]
13 +});
14 +
15 +export class SqliteStore{
16 + private readonly db:DatabaseSync;
17 +
18 + constructor(private readonly file:string){
19 + mkdirSync(dirname(file),{recursive:true});
20 + this.db=new DatabaseSync(file);
21 + this.db.exec('PRAGMA foreign_keys=ON; PRAGMA journal_mode=WAL; PRAGMA synchronous=FULL;');
22 + this.migrate();
23 + }
24 +
25 + private migrate(){
26 + this.db.exec(`
27 + CREATE TABLE IF NOT EXISTS meta (
28 + key TEXT PRIMARY KEY,
29 + value TEXT NOT NULL
30 + );
31 + CREATE TABLE IF NOT EXISTS accounts (
32 + id TEXT NOT NULL,
33 + tenant_id TEXT NOT NULL,
34 + name TEXT NOT NULL,
35 + iban TEXT NOT NULL,
36 + bank_name TEXT NOT NULL,
37 + status TEXT NOT NULL CHECK(status IN ('ACTIVE','INACTIVE')),
38 + PRIMARY KEY (tenant_id,id)
39 + );
40 + CREATE TABLE IF NOT EXISTS beneficiaries (
41 + id TEXT NOT NULL,
42 + tenant_id TEXT NOT NULL,
43 + name TEXT NOT NULL,
44 + iban TEXT NOT NULL,
45 + whitelisted INTEGER NOT NULL CHECK(whitelisted IN (0,1)),
46 + PRIMARY KEY (tenant_id,id)
47 + );
48 + CREATE TABLE IF NOT EXISTS payments (
49 + id TEXT NOT NULL,
50 + tenant_id TEXT NOT NULL,
51 + maker_id TEXT NOT NULL,
52 + source_account_id TEXT NOT NULL,
53 + beneficiary_id TEXT NOT NULL,
54 + amount_irr INTEGER NOT NULL CHECK(amount_irr > 0),
55 + payment_date TEXT NOT NULL,
56 + client_reference TEXT NOT NULL,
57 + description TEXT NOT NULL,
58 + version INTEGER NOT NULL CHECK(version > 0),
59 + state TEXT NOT NULL,
60 + approved_version INTEGER,
61 + bank_reference TEXT,
62 + PRIMARY KEY (tenant_id,id),
63 + UNIQUE (tenant_id,client_reference)
64 + );
65 + CREATE TABLE IF NOT EXISTS audit (
66 + tenant_id TEXT NOT NULL,
67 + seq INTEGER NOT NULL,
68 + actor TEXT NOT NULL,
69 + action TEXT NOT NULL,
70 + entity TEXT NOT NULL,
71 + at INTEGER NOT NULL,
72 + PRIMARY KEY (tenant_id,seq)
73 + );
74 + CREATE INDEX IF NOT EXISTS idx_payments_tenant_state ON payments(tenant_id,state);
75 + CREATE INDEX IF NOT EXISTS idx_payments_tenant_date ON payments(tenant_id,payment_date);
76 + CREATE INDEX IF NOT EXISTS idx_audit_tenant_at ON audit(tenant_id,at);
77 + `);
78 + const version=this.db.prepare("SELECT value FROM meta WHERE key='schema_version'").get() as {value?:string}|undefined;
79 + if(version&&version.value!=='1') throw new Error('unsupported sqlite schema version');
80 + this.db.prepare("INSERT OR IGNORE INTO meta(key,value) VALUES('schema_version','1')").run();
81 + this.db.prepare("INSERT OR IGNORE INTO meta(key,value) VALUES('organization_name','TreasuryFlow')").run();
82 + }
83 +
84 + snapshot():LocalStoreData{
85 + const organization=(this.db.prepare("SELECT value FROM meta WHERE key='organization_name'").get() as {value?:string}|undefined)?.value??'TreasuryFlow';
86 + const accounts=(this.db.prepare('SELECT id,tenant_id,name,iban,bank_name,status FROM accounts ORDER BY rowid').all() as any[]).map((r):LocalAccount=>({
87 + id:String(r.id),tenantId:String(r.tenant_id),name:String(r.name),iban:String(r.iban),bankName:String(r.bank_name),status:r.status as LocalAccount['status']
88 + }));
89 + const beneficiaries=(this.db.prepare('SELECT id,tenant_id,name,iban,whitelisted FROM beneficiaries ORDER BY rowid').all() as any[]).map((r):LocalBeneficiary=>({
90 + id:String(r.id),tenantId:String(r.tenant_id),name:String(r.name),iban:String(r.iban),whitelisted:Number(r.whitelisted)===1
91 + }));
92 + const payments=(this.db.prepare('SELECT * FROM payments ORDER BY rowid').all() as any[]).map((r):LocalPayment=>({
93 + id:String(r.id),tenantId:String(r.tenant_id),makerId:String(r.maker_id),sourceAccountId:String(r.source_account_id),beneficiaryId:String(r.beneficiary_id),amountIrr:Number(r.amount_irr),paymentDate:String(r.payment_date),clientReference:String(r.client_reference),description:String(r.description),version:Number(r.version),state:r.state as LocalPayment['state'],approvedVersion:r.approved_version==null?undefined:Number(r.approved_version),bankReference:r.bank_reference==null?undefined:String(r.bank_reference)
94 + }));
95 + const audit=(this.db.prepare('SELECT tenant_id,seq,actor,action,entity,at FROM audit ORDER BY tenant_id,seq').all() as any[]).map((r):LocalAudit=>({
96 + tenantId:String(r.tenant_id),seq:Number(r.seq),actor:String(r.actor),action:String(r.action),entity:String(r.entity),at:Number(r.at)
97 + }));
98 + return {version:1,meta:{organizationName:organization},accounts,beneficiaries,payments,audit};
99 + }
100 +
101 + update(mutator:(data:LocalStoreData)=>LocalStoreData){
102 + const next=mutator(structuredClone(this.snapshot()));
103 + if(next.version!==1) throw new Error('unsupported sqlite schema version');
104 + this.db.exec('BEGIN IMMEDIATE');
105 + try{
106 + this.db.prepare("UPDATE meta SET value=? WHERE key='organization_name'").run(next.meta.organizationName);
107 + this.db.exec('DELETE FROM audit; DELETE FROM payments; DELETE FROM beneficiaries; DELETE FROM accounts;');
108 + const accountStmt=this.db.prepare('INSERT INTO accounts(id,tenant_id,name,iban,bank_name,status) VALUES(?,?,?,?,?,?)');
109 + for(const a of next.accounts) accountStmt.run(a.id,a.tenantId,a.name,a.iban,a.bankName,a.status);
110 + const beneficiaryStmt=this.db.prepare('INSERT INTO beneficiaries(id,tenant_id,name,iban,whitelisted) VALUES(?,?,?,?,?)');
111 + for(const b of next.beneficiaries) beneficiaryStmt.run(b.id,b.tenantId,b.name,b.iban,b.whitelisted?1:0);
112 + const paymentStmt=this.db.prepare('INSERT INTO payments(id,tenant_id,maker_id,source_account_id,beneficiary_id,amount_irr,payment_date,client_reference,description,version,state,approved_version,bank_reference) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)');
113 + for(const p of next.payments) paymentStmt.run(p.id,p.tenantId,p.makerId,p.sourceAccountId,p.beneficiaryId,p.amountIrr,p.paymentDate,p.clientReference,p.description,p.version,p.state,p.approvedVersion??null,p.bankReference??null);
114 + const auditStmt=this.db.prepare('INSERT INTO audit(tenant_id,seq,actor,action,entity,at) VALUES(?,?,?,?,?,?)');
115 + for(const a of next.audit) auditStmt.run(a.tenantId,a.seq,a.actor,a.action,a.entity,a.at);
116 + this.db.exec('COMMIT');
117 + }catch(error){
118 + this.db.exec('ROLLBACK');
119 + throw error;
120 + }
121 + return structuredClone(next);
122 + }
123 +
124 + close(){this.db.close()}
125 +}
126 +
127 +export function defaultSqliteStorePath(){
128 + const base=process.env.LOCALAPPDATA||process.env.APPDATA||process.cwd();
129 + return `${base}\\TreasuryFlow\\data\\treasuryflow.db`;
130 +}