@atbas/m-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (366) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +364 -0
  3. package/dist/builder/transaction-builder.d.ts +53 -0
  4. package/dist/builder/transaction-builder.d.ts.map +1 -0
  5. package/dist/builder/transaction-builder.js +159 -0
  6. package/dist/builder/transaction-builder.js.map +1 -0
  7. package/dist/catalogue/default-catalogue.d.ts +18 -0
  8. package/dist/catalogue/default-catalogue.d.ts.map +1 -0
  9. package/dist/catalogue/default-catalogue.js +21 -0
  10. package/dist/catalogue/default-catalogue.js.map +1 -0
  11. package/dist/catalogue/endpoints.d.ts +22 -0
  12. package/dist/catalogue/endpoints.d.ts.map +1 -0
  13. package/dist/catalogue/endpoints.js +24 -0
  14. package/dist/catalogue/endpoints.js.map +1 -0
  15. package/dist/catalogue/flows.d.ts +32 -0
  16. package/dist/catalogue/flows.d.ts.map +1 -0
  17. package/dist/catalogue/flows.js +64 -0
  18. package/dist/catalogue/flows.js.map +1 -0
  19. package/dist/catalogue/hash-options.d.ts +112 -0
  20. package/dist/catalogue/hash-options.d.ts.map +1 -0
  21. package/dist/catalogue/hash-options.js +151 -0
  22. package/dist/catalogue/hash-options.js.map +1 -0
  23. package/dist/catalogue/types.d.ts +279 -0
  24. package/dist/catalogue/types.d.ts.map +1 -0
  25. package/dist/catalogue/types.js +360 -0
  26. package/dist/catalogue/types.js.map +1 -0
  27. package/dist/codegen/generate.d.ts +14 -0
  28. package/dist/codegen/generate.d.ts.map +1 -0
  29. package/dist/codegen/generate.js +490 -0
  30. package/dist/codegen/generate.js.map +1 -0
  31. package/dist/codegen/languages/node.d.ts +3 -0
  32. package/dist/codegen/languages/node.d.ts.map +1 -0
  33. package/dist/codegen/languages/node.js +32 -0
  34. package/dist/codegen/languages/node.js.map +1 -0
  35. package/dist/codegen/languages/php.d.ts +3 -0
  36. package/dist/codegen/languages/php.d.ts.map +1 -0
  37. package/dist/codegen/languages/php.js +27 -0
  38. package/dist/codegen/languages/php.js.map +1 -0
  39. package/dist/codegen/languages/python.d.ts +3 -0
  40. package/dist/codegen/languages/python.d.ts.map +1 -0
  41. package/dist/codegen/languages/python.js +27 -0
  42. package/dist/codegen/languages/python.js.map +1 -0
  43. package/dist/codegen/renderer.d.ts +24 -0
  44. package/dist/codegen/renderer.d.ts.map +1 -0
  45. package/dist/codegen/renderer.js +59 -0
  46. package/dist/codegen/renderer.js.map +1 -0
  47. package/dist/codegen/types.d.ts +50 -0
  48. package/dist/codegen/types.d.ts.map +1 -0
  49. package/dist/codegen/types.js +5 -0
  50. package/dist/codegen/types.js.map +1 -0
  51. package/dist/config/credentials.d.ts +64 -0
  52. package/dist/config/credentials.d.ts.map +1 -0
  53. package/dist/config/credentials.js +216 -0
  54. package/dist/config/credentials.js.map +1 -0
  55. package/dist/config/environment.d.ts +23 -0
  56. package/dist/config/environment.d.ts.map +1 -0
  57. package/dist/config/environment.js +54 -0
  58. package/dist/config/environment.js.map +1 -0
  59. package/dist/core/dependencies.d.ts +43 -0
  60. package/dist/core/dependencies.d.ts.map +1 -0
  61. package/dist/core/dependencies.js +2 -0
  62. package/dist/core/dependencies.js.map +1 -0
  63. package/dist/core/registry.d.ts +33 -0
  64. package/dist/core/registry.d.ts.map +1 -0
  65. package/dist/core/registry.js +13 -0
  66. package/dist/core/registry.js.map +1 -0
  67. package/dist/core/server.d.ts +61 -0
  68. package/dist/core/server.d.ts.map +1 -0
  69. package/dist/core/server.js +90 -0
  70. package/dist/core/server.js.map +1 -0
  71. package/dist/dependencies.d.ts +28 -0
  72. package/dist/dependencies.d.ts.map +1 -0
  73. package/dist/dependencies.js +2 -0
  74. package/dist/dependencies.js.map +1 -0
  75. package/dist/diagnostics/diagnose.d.ts +43 -0
  76. package/dist/diagnostics/diagnose.d.ts.map +1 -0
  77. package/dist/diagnostics/diagnose.js +121 -0
  78. package/dist/diagnostics/diagnose.js.map +1 -0
  79. package/dist/domain/amount.d.ts +157 -0
  80. package/dist/domain/amount.d.ts.map +1 -0
  81. package/dist/domain/amount.js +275 -0
  82. package/dist/domain/amount.js.map +1 -0
  83. package/dist/domain/datetime.d.ts +95 -0
  84. package/dist/domain/datetime.d.ts.map +1 -0
  85. package/dist/domain/datetime.js +211 -0
  86. package/dist/domain/datetime.js.map +1 -0
  87. package/dist/domain/response-codes.d.ts +116 -0
  88. package/dist/domain/response-codes.d.ts.map +1 -0
  89. package/dist/domain/response-codes.js +380 -0
  90. package/dist/domain/response-codes.js.map +1 -0
  91. package/dist/domain/secure-hash.d.ts +78 -0
  92. package/dist/domain/secure-hash.d.ts.map +1 -0
  93. package/dist/domain/secure-hash.js +69 -0
  94. package/dist/domain/secure-hash.js.map +1 -0
  95. package/dist/domain/signature/jazzcash.d.ts +56 -0
  96. package/dist/domain/signature/jazzcash.d.ts.map +1 -0
  97. package/dist/domain/signature/jazzcash.js +214 -0
  98. package/dist/domain/signature/jazzcash.js.map +1 -0
  99. package/dist/domain/signature/registry.d.ts +69 -0
  100. package/dist/domain/signature/registry.d.ts.map +1 -0
  101. package/dist/domain/signature/registry.js +92 -0
  102. package/dist/domain/signature/registry.js.map +1 -0
  103. package/dist/domain/signature/scheme.d.ts +349 -0
  104. package/dist/domain/signature/scheme.d.ts.map +1 -0
  105. package/dist/domain/signature/scheme.js +398 -0
  106. package/dist/domain/signature/scheme.js.map +1 -0
  107. package/dist/domain/txn-ref.d.ts +76 -0
  108. package/dist/domain/txn-ref.d.ts.map +1 -0
  109. package/dist/domain/txn-ref.js +126 -0
  110. package/dist/domain/txn-ref.js.map +1 -0
  111. package/dist/domain/types.d.ts +45 -0
  112. package/dist/domain/types.d.ts.map +1 -0
  113. package/dist/domain/types.js +70 -0
  114. package/dist/domain/types.js.map +1 -0
  115. package/dist/errors.d.ts +84 -0
  116. package/dist/errors.d.ts.map +1 -0
  117. package/dist/errors.js +87 -0
  118. package/dist/errors.js.map +1 -0
  119. package/dist/gateway/checkout-form.d.ts +16 -0
  120. package/dist/gateway/checkout-form.d.ts.map +1 -0
  121. package/dist/gateway/checkout-form.js +103 -0
  122. package/dist/gateway/checkout-form.js.map +1 -0
  123. package/dist/gateway/checkout-output.d.ts +70 -0
  124. package/dist/gateway/checkout-output.d.ts.map +1 -0
  125. package/dist/gateway/checkout-output.js +199 -0
  126. package/dist/gateway/checkout-output.js.map +1 -0
  127. package/dist/gateway/guards.d.ts +37 -0
  128. package/dist/gateway/guards.d.ts.map +1 -0
  129. package/dist/gateway/guards.js +44 -0
  130. package/dist/gateway/guards.js.map +1 -0
  131. package/dist/gateway/http-client.d.ts +42 -0
  132. package/dist/gateway/http-client.d.ts.map +1 -0
  133. package/dist/gateway/http-client.js +153 -0
  134. package/dist/gateway/http-client.js.map +1 -0
  135. package/dist/gateway/rest-client.d.ts +42 -0
  136. package/dist/gateway/rest-client.d.ts.map +1 -0
  137. package/dist/gateway/rest-client.js +241 -0
  138. package/dist/gateway/rest-client.js.map +1 -0
  139. package/dist/gateway/transport.d.ts +31 -0
  140. package/dist/gateway/transport.d.ts.map +1 -0
  141. package/dist/gateway/transport.js +73 -0
  142. package/dist/gateway/transport.js.map +1 -0
  143. package/dist/index.d.ts +3 -0
  144. package/dist/index.d.ts.map +1 -0
  145. package/dist/index.js +75 -0
  146. package/dist/index.js.map +1 -0
  147. package/dist/install/cli.d.ts +38 -0
  148. package/dist/install/cli.d.ts.map +1 -0
  149. package/dist/install/cli.js +274 -0
  150. package/dist/install/cli.js.map +1 -0
  151. package/dist/install/harnesses.d.ts +74 -0
  152. package/dist/install/harnesses.d.ts.map +1 -0
  153. package/dist/install/harnesses.js +263 -0
  154. package/dist/install/harnesses.js.map +1 -0
  155. package/dist/knowledge/corpus.d.ts +15 -0
  156. package/dist/knowledge/corpus.d.ts.map +1 -0
  157. package/dist/knowledge/corpus.js +129 -0
  158. package/dist/knowledge/corpus.js.map +1 -0
  159. package/dist/knowledge/search.d.ts +29 -0
  160. package/dist/knowledge/search.d.ts.map +1 -0
  161. package/dist/knowledge/search.js +181 -0
  162. package/dist/knowledge/search.js.map +1 -0
  163. package/dist/knowledge/source.d.ts +60 -0
  164. package/dist/knowledge/source.d.ts.map +1 -0
  165. package/dist/knowledge/source.js +91 -0
  166. package/dist/knowledge/source.js.map +1 -0
  167. package/dist/knowledge/types.d.ts +40 -0
  168. package/dist/knowledge/types.d.ts.map +1 -0
  169. package/dist/knowledge/types.js +19 -0
  170. package/dist/knowledge/types.js.map +1 -0
  171. package/dist/paths.d.ts +26 -0
  172. package/dist/paths.d.ts.map +1 -0
  173. package/dist/paths.js +106 -0
  174. package/dist/paths.js.map +1 -0
  175. package/dist/prompts/integration-walkthrough.d.ts +11 -0
  176. package/dist/prompts/integration-walkthrough.d.ts.map +1 -0
  177. package/dist/prompts/integration-walkthrough.js +52 -0
  178. package/dist/prompts/integration-walkthrough.js.map +1 -0
  179. package/dist/prompts/register.d.ts +4 -0
  180. package/dist/prompts/register.d.ts.map +1 -0
  181. package/dist/prompts/register.js +4 -0
  182. package/dist/prompts/register.js.map +1 -0
  183. package/dist/registry.d.ts +14 -0
  184. package/dist/registry.d.ts.map +1 -0
  185. package/dist/registry.js +2 -0
  186. package/dist/registry.js.map +1 -0
  187. package/dist/resources/knowledge-resources.d.ts +5 -0
  188. package/dist/resources/knowledge-resources.d.ts.map +1 -0
  189. package/dist/resources/knowledge-resources.js +121 -0
  190. package/dist/resources/knowledge-resources.js.map +1 -0
  191. package/dist/resources/register.d.ts +4 -0
  192. package/dist/resources/register.d.ts.map +1 -0
  193. package/dist/resources/register.js +8 -0
  194. package/dist/resources/register.js.map +1 -0
  195. package/dist/server.d.ts +40 -0
  196. package/dist/server.d.ts.map +1 -0
  197. package/dist/server.js +56 -0
  198. package/dist/server.js.map +1 -0
  199. package/dist/telemetry/logger.d.ts +31 -0
  200. package/dist/telemetry/logger.d.ts.map +1 -0
  201. package/dist/telemetry/logger.js +67 -0
  202. package/dist/telemetry/logger.js.map +1 -0
  203. package/dist/telemetry/redaction.d.ts +88 -0
  204. package/dist/telemetry/redaction.d.ts.map +1 -0
  205. package/dist/telemetry/redaction.js +238 -0
  206. package/dist/telemetry/redaction.js.map +1 -0
  207. package/dist/tools/build-transaction-parameters.d.ts +10 -0
  208. package/dist/tools/build-transaction-parameters.d.ts.map +1 -0
  209. package/dist/tools/build-transaction-parameters.js +154 -0
  210. package/dist/tools/build-transaction-parameters.js.map +1 -0
  211. package/dist/tools/call-context.d.ts +47 -0
  212. package/dist/tools/call-context.d.ts.map +1 -0
  213. package/dist/tools/call-context.js +15 -0
  214. package/dist/tools/call-context.js.map +1 -0
  215. package/dist/tools/codegen-tools.d.ts +4 -0
  216. package/dist/tools/codegen-tools.d.ts.map +1 -0
  217. package/dist/tools/codegen-tools.js +131 -0
  218. package/dist/tools/codegen-tools.js.map +1 -0
  219. package/dist/tools/credential-tools.d.ts +32 -0
  220. package/dist/tools/credential-tools.d.ts.map +1 -0
  221. package/dist/tools/credential-tools.js +65 -0
  222. package/dist/tools/credential-tools.js.map +1 -0
  223. package/dist/tools/descriptor.d.ts +52 -0
  224. package/dist/tools/descriptor.d.ts.map +1 -0
  225. package/dist/tools/descriptor.js +2 -0
  226. package/dist/tools/descriptor.js.map +1 -0
  227. package/dist/tools/diagnostic-tools.d.ts +3 -0
  228. package/dist/tools/diagnostic-tools.d.ts.map +1 -0
  229. package/dist/tools/diagnostic-tools.js +128 -0
  230. package/dist/tools/diagnostic-tools.js.map +1 -0
  231. package/dist/tools/gateway-tools.d.ts +6 -0
  232. package/dist/tools/gateway-tools.d.ts.map +1 -0
  233. package/dist/tools/gateway-tools.js +381 -0
  234. package/dist/tools/gateway-tools.js.map +1 -0
  235. package/dist/tools/hash-tools.d.ts +5 -0
  236. package/dist/tools/hash-tools.d.ts.map +1 -0
  237. package/dist/tools/hash-tools.js +238 -0
  238. package/dist/tools/hash-tools.js.map +1 -0
  239. package/dist/tools/knowledge-tools.d.ts +7 -0
  240. package/dist/tools/knowledge-tools.d.ts.map +1 -0
  241. package/dist/tools/knowledge-tools.js +247 -0
  242. package/dist/tools/knowledge-tools.js.map +1 -0
  243. package/dist/tools/onboarding-checklist.d.ts +3 -0
  244. package/dist/tools/onboarding-checklist.d.ts.map +1 -0
  245. package/dist/tools/onboarding-checklist.js +141 -0
  246. package/dist/tools/onboarding-checklist.js.map +1 -0
  247. package/dist/tools/register.d.ts +60 -0
  248. package/dist/tools/register.d.ts.map +1 -0
  249. package/dist/tools/register.js +145 -0
  250. package/dist/tools/register.js.map +1 -0
  251. package/dist/tools/tool-kit.d.ts +88 -0
  252. package/dist/tools/tool-kit.d.ts.map +1 -0
  253. package/dist/tools/tool-kit.js +297 -0
  254. package/dist/tools/tool-kit.js.map +1 -0
  255. package/dist/validation/payload-validator.d.ts +29 -0
  256. package/dist/validation/payload-validator.d.ts.map +1 -0
  257. package/dist/validation/payload-validator.js +79 -0
  258. package/dist/validation/payload-validator.js.map +1 -0
  259. package/dist/validation/rules/amount.d.ts +3 -0
  260. package/dist/validation/rules/amount.d.ts.map +1 -0
  261. package/dist/validation/rules/amount.js +77 -0
  262. package/dist/validation/rules/amount.js.map +1 -0
  263. package/dist/validation/rules/bill-reference.d.ts +10 -0
  264. package/dist/validation/rules/bill-reference.d.ts.map +1 -0
  265. package/dist/validation/rules/bill-reference.js +34 -0
  266. package/dist/validation/rules/bill-reference.js.map +1 -0
  267. package/dist/validation/rules/cnic.d.ts +3 -0
  268. package/dist/validation/rules/cnic.d.ts.map +1 -0
  269. package/dist/validation/rules/cnic.js +42 -0
  270. package/dist/validation/rules/cnic.js.map +1 -0
  271. package/dist/validation/rules/constants.d.ts +9 -0
  272. package/dist/validation/rules/constants.d.ts.map +1 -0
  273. package/dist/validation/rules/constants.js +28 -0
  274. package/dist/validation/rules/constants.js.map +1 -0
  275. package/dist/validation/rules/constraints.d.ts +3 -0
  276. package/dist/validation/rules/constraints.d.ts.map +1 -0
  277. package/dist/validation/rules/constraints.js +113 -0
  278. package/dist/validation/rules/constraints.js.map +1 -0
  279. package/dist/validation/rules/datetime.d.ts +3 -0
  280. package/dist/validation/rules/datetime.d.ts.map +1 -0
  281. package/dist/validation/rules/datetime.js +49 -0
  282. package/dist/validation/rules/datetime.js.map +1 -0
  283. package/dist/validation/rules/empty-string.d.ts +13 -0
  284. package/dist/validation/rules/empty-string.d.ts.map +1 -0
  285. package/dist/validation/rules/empty-string.js +32 -0
  286. package/dist/validation/rules/empty-string.js.map +1 -0
  287. package/dist/validation/rules/expiry.d.ts +3 -0
  288. package/dist/validation/rules/expiry.d.ts.map +1 -0
  289. package/dist/validation/rules/expiry.js +52 -0
  290. package/dist/validation/rules/expiry.js.map +1 -0
  291. package/dist/validation/rules/msisdn.d.ts +3 -0
  292. package/dist/validation/rules/msisdn.d.ts.map +1 -0
  293. package/dist/validation/rules/msisdn.js +45 -0
  294. package/dist/validation/rules/msisdn.js.map +1 -0
  295. package/dist/validation/rules/presence.d.ts +3 -0
  296. package/dist/validation/rules/presence.d.ts.map +1 -0
  297. package/dist/validation/rules/presence.js +90 -0
  298. package/dist/validation/rules/presence.js.map +1 -0
  299. package/dist/validation/rules/return-url.d.ts +14 -0
  300. package/dist/validation/rules/return-url.d.ts.map +1 -0
  301. package/dist/validation/rules/return-url.js +58 -0
  302. package/dist/validation/rules/return-url.js.map +1 -0
  303. package/dist/validation/rules/tool-argument.d.ts +16 -0
  304. package/dist/validation/rules/tool-argument.d.ts.map +1 -0
  305. package/dist/validation/rules/tool-argument.js +38 -0
  306. package/dist/validation/rules/tool-argument.js.map +1 -0
  307. package/dist/validation/rules/txn-ref.d.ts +3 -0
  308. package/dist/validation/rules/txn-ref.d.ts.map +1 -0
  309. package/dist/validation/rules/txn-ref.js +47 -0
  310. package/dist/validation/rules/txn-ref.js.map +1 -0
  311. package/dist/validation/rules/unknown-fields.d.ts +10 -0
  312. package/dist/validation/rules/unknown-fields.d.ts.map +1 -0
  313. package/dist/validation/rules/unknown-fields.js +29 -0
  314. package/dist/validation/rules/unknown-fields.js.map +1 -0
  315. package/dist/validation/types.d.ts +36 -0
  316. package/dist/validation/types.d.ts.map +1 -0
  317. package/dist/validation/types.js +12 -0
  318. package/dist/validation/types.js.map +1 -0
  319. package/dist/version.d.ts +23 -0
  320. package/dist/version.d.ts.map +1 -0
  321. package/dist/version.js +23 -0
  322. package/dist/version.js.map +1 -0
  323. package/knowledge/diagnostics/symptoms.json +321 -0
  324. package/knowledge/docs/bnpl-guide.md +77 -0
  325. package/knowledge/docs/card-page-redirection.md +67 -0
  326. package/knowledge/docs/card-refund.md +91 -0
  327. package/knowledge/docs/hmac-sha256-calculation.md +72 -0
  328. package/knowledge/docs/index.json +189 -0
  329. package/knowledge/docs/ipn-implementation.md +89 -0
  330. package/knowledge/docs/mwallet-recurring.md +117 -0
  331. package/knowledge/docs/mwallet-refund.md +65 -0
  332. package/knowledge/docs/mwallet-rest-v1-1.md +126 -0
  333. package/knowledge/docs/mwallet-rest-v2-0-cnic.md +113 -0
  334. package/knowledge/docs/portal-guide.md +45 -0
  335. package/knowledge/docs/shopify-guide.md +74 -0
  336. package/knowledge/docs/status-inquiry-2025-26.md +32 -0
  337. package/knowledge/docs/status-inquiry.md +111 -0
  338. package/knowledge/docs/wordpress-guide.md +49 -0
  339. package/knowledge/flow.schema.json +390 -0
  340. package/knowledge/flows/bnpl-page-redirection-v1.1.json +211 -0
  341. package/knowledge/flows/card-page-redirection-v1.1.json +211 -0
  342. package/knowledge/flows/mwallet-rest-v1.1.json +187 -0
  343. package/knowledge/flows/mwallet-rest-v2.0-cnic.json +197 -0
  344. package/knowledge/flows/mwallet-token-pay-v4.0.json +130 -0
  345. package/knowledge/flows/refund-bnpl.json +105 -0
  346. package/knowledge/flows/refund-card-v1.1.json +112 -0
  347. package/knowledge/flows/refund-card-v2.0.json +121 -0
  348. package/knowledge/flows/refund-mwallet-v1.1.json +106 -0
  349. package/knowledge/flows/status-inquiry-v1.1.json +102 -0
  350. package/knowledge/flows/status-inquiry-v2.0.json +103 -0
  351. package/knowledge/flows/token-delete-v1.json +85 -0
  352. package/knowledge/flows/token-inquiry-v1.json +85 -0
  353. package/knowledge/flows/wallet-linking-portal.json +103 -0
  354. package/knowledge/templates/node/checkout-redirect.tmpl +166 -0
  355. package/knowledge/templates/node/ipn-handler.tmpl +108 -0
  356. package/knowledge/templates/node/rest-client.tmpl +197 -0
  357. package/knowledge/templates/node/wallet-linking.tmpl +147 -0
  358. package/knowledge/templates/php/checkout-redirect.tmpl +149 -0
  359. package/knowledge/templates/php/ipn-handler.tmpl +105 -0
  360. package/knowledge/templates/php/rest-client.tmpl +191 -0
  361. package/knowledge/templates/php/wallet-linking.tmpl +137 -0
  362. package/knowledge/templates/python/checkout-redirect.tmpl +148 -0
  363. package/knowledge/templates/python/ipn-handler.tmpl +110 -0
  364. package/knowledge/templates/python/rest-client.tmpl +179 -0
  365. package/knowledge/templates/python/wallet-linking.tmpl +133 -0
  366. package/package.json +84 -0
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Shared domain vocabulary.
3
+ *
4
+ * JazzCash transmits every parameter as a string. Numbers are accepted at the
5
+ * boundary for ergonomics and normalised immediately, because the gateway's
6
+ * documented rule — "all parameter values must be passed as strings and enclosed
7
+ * in double quotes" — admits no exceptions.
8
+ */
9
+ /** A raw parameter value as a caller may supply it. */
10
+ export type ParameterValue = string | number | null | undefined;
11
+ /** A payload as supplied by a caller, before normalisation. */
12
+ export type RawParameters = Readonly<Record<string, ParameterValue>>;
13
+ /** A payload after normalisation: every value is a string, empties are `''`. */
14
+ export type NormalisedParameters = Readonly<Record<string, string>>;
15
+ /**
16
+ * Normalise a single value to its wire representation.
17
+ *
18
+ * `null` and `undefined` collapse to `''`, which is what the guides require for
19
+ * unused parameters ("do not replace them with null and do not remove them").
20
+ */
21
+ export declare function normaliseValue(value: ParameterValue): string;
22
+ /** Normalise every value in a payload, preserving key order. */
23
+ export declare function normaliseParameters(parameters: RawParameters): NormalisedParameters;
24
+ /**
25
+ * Coerce an arbitrary decoded JSON object into hashable parameters.
26
+ *
27
+ * Every documented JazzCash response is a flat map of strings and nulls. A
28
+ * nested object or array is therefore not something the hash rules cover, and it
29
+ * is dropped rather than stringified: `[object Object]` in a hash string would be
30
+ * a silent corruption. Response hash verification already reports `unverified`
31
+ * rather than `failed` (assumption A2), so a dropped field cannot be mistaken for
32
+ * a broken integration.
33
+ */
34
+ export declare function toParameters(record: Readonly<Record<string, unknown>>): NormalisedParameters;
35
+ /**
36
+ * Compare two parameter names by ASCII code unit, ascending.
37
+ *
38
+ * `String.prototype.localeCompare` is deliberately avoided: it is locale
39
+ * sensitive and would order `pp_MerchantID` and `pp_merchantid` differently on
40
+ * different machines, producing a hash that works on one host and fails on
41
+ * another. JavaScript's default string comparison is code-unit order, which is
42
+ * ASCII order for every parameter name JazzCash defines.
43
+ */
44
+ export declare function compareParameterNames(left: string, right: string): number;
45
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/domain/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAEhE,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAErE,gFAAgF;AAChF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAK5D;AAED,gEAAgE;AAChE,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,aAAa,GAAG,oBAAoB,CAMnF;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,oBAAoB,CAa5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQzE"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Shared domain vocabulary.
3
+ *
4
+ * JazzCash transmits every parameter as a string. Numbers are accepted at the
5
+ * boundary for ergonomics and normalised immediately, because the gateway's
6
+ * documented rule — "all parameter values must be passed as strings and enclosed
7
+ * in double quotes" — admits no exceptions.
8
+ */
9
+ /**
10
+ * Normalise a single value to its wire representation.
11
+ *
12
+ * `null` and `undefined` collapse to `''`, which is what the guides require for
13
+ * unused parameters ("do not replace them with null and do not remove them").
14
+ */
15
+ export function normaliseValue(value) {
16
+ if (value === null || value === undefined) {
17
+ return '';
18
+ }
19
+ return typeof value === 'string' ? value : String(value);
20
+ }
21
+ /** Normalise every value in a payload, preserving key order. */
22
+ export function normaliseParameters(parameters) {
23
+ const result = {};
24
+ for (const key of Object.keys(parameters)) {
25
+ result[key] = normaliseValue(parameters[key]);
26
+ }
27
+ return result;
28
+ }
29
+ /**
30
+ * Coerce an arbitrary decoded JSON object into hashable parameters.
31
+ *
32
+ * Every documented JazzCash response is a flat map of strings and nulls. A
33
+ * nested object or array is therefore not something the hash rules cover, and it
34
+ * is dropped rather than stringified: `[object Object]` in a hash string would be
35
+ * a silent corruption. Response hash verification already reports `unverified`
36
+ * rather than `failed` (assumption A2), so a dropped field cannot be mistaken for
37
+ * a broken integration.
38
+ */
39
+ export function toParameters(record) {
40
+ const result = {};
41
+ for (const key of Object.keys(record)) {
42
+ const value = record[key];
43
+ if (value === null || value === undefined) {
44
+ result[key] = '';
45
+ }
46
+ else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
47
+ result[key] = String(value);
48
+ }
49
+ }
50
+ return result;
51
+ }
52
+ /**
53
+ * Compare two parameter names by ASCII code unit, ascending.
54
+ *
55
+ * `String.prototype.localeCompare` is deliberately avoided: it is locale
56
+ * sensitive and would order `pp_MerchantID` and `pp_merchantid` differently on
57
+ * different machines, producing a hash that works on one host and fails on
58
+ * another. JavaScript's default string comparison is code-unit order, which is
59
+ * ASCII order for every parameter name JazzCash defines.
60
+ */
61
+ export function compareParameterNames(left, right) {
62
+ if (left < right) {
63
+ return -1;
64
+ }
65
+ if (left > right) {
66
+ return 1;
67
+ }
68
+ return 0;
69
+ }
70
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/domain/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAqB;IAClD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,mBAAmB,CAAC,UAAyB;IAC3D,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1C,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,MAAyC;IACpE,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YAChG,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,KAAa;IAC/D,IAAI,IAAI,GAAG,KAAK,EAAE,CAAC;QACjB,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IACD,IAAI,IAAI,GAAG,KAAK,EAAE,CAAC;QACjB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Error taxonomy for the JazzCash MCP server.
3
+ *
4
+ * Every error carries a stable machine-readable `code` and, where the failure is
5
+ * traceable to official JazzCash documentation, the references that explain it.
6
+ * Tool handlers convert these into `isError` results rather than letting them
7
+ * escape across the protocol boundary.
8
+ */
9
+ /**
10
+ * Pointer into the curated knowledge corpus.
11
+ *
12
+ * The optional members are declared as `?: T | undefined` so the type stays
13
+ * assignable from zod-inferred flow specifications under
14
+ * `exactOptionalPropertyTypes`.
15
+ */
16
+ export interface DocRef {
17
+ /** Document identifier, e.g. `hmac-sha256-calculation`. */
18
+ readonly docId: string;
19
+ /** Optional section anchor within that document. */
20
+ readonly sectionId?: string | undefined;
21
+ /** Human-readable label for display alongside the citation. */
22
+ readonly label?: string | undefined;
23
+ }
24
+ export interface JazzCashErrorOptions {
25
+ readonly docRefs?: readonly DocRef[];
26
+ readonly cause?: unknown;
27
+ readonly details?: Readonly<Record<string, unknown>>;
28
+ }
29
+ /** Base class for every error this server raises deliberately. */
30
+ export declare abstract class JazzCashError extends Error {
31
+ /** Stable identifier, safe to branch on and to show to a merchant. */
32
+ abstract readonly code: string;
33
+ readonly docRefs: readonly DocRef[];
34
+ readonly details: Readonly<Record<string, unknown>>;
35
+ protected constructor(message: string, options?: JazzCashErrorOptions);
36
+ }
37
+ /** Server configuration or credential resolution failed. */
38
+ export declare class JazzCashConfigError extends JazzCashError {
39
+ readonly code = "JAZZCASH_CONFIG_ERROR";
40
+ constructor(message: string, options?: JazzCashErrorOptions);
41
+ }
42
+ /** A payload failed the documented parameter rules for its flow. */
43
+ export declare class JazzCashValidationError extends JazzCashError {
44
+ readonly code = "JAZZCASH_VALIDATION_ERROR";
45
+ constructor(message: string, options?: JazzCashErrorOptions);
46
+ }
47
+ /**
48
+ * Request signature construction or verification failed.
49
+ *
50
+ * Named for the operation rather than for a gateway: one engine signs and
51
+ * diagnoses every registered scheme, so naming this error after a single gateway
52
+ * renders every signature failure under that gateway's name — including one
53
+ * raised for a scheme it has nothing to do with. A merchant told to check a
54
+ * credential their gateway does not issue checks nothing.
55
+ */
56
+ export declare class SignatureError extends JazzCashError {
57
+ readonly code = "SIGNATURE_ERROR";
58
+ constructor(message: string, options?: JazzCashErrorOptions);
59
+ }
60
+ /** The gateway was unreachable, timed out, or returned something unparseable. */
61
+ export declare class JazzCashGatewayError extends JazzCashError {
62
+ readonly code = "JAZZCASH_GATEWAY_ERROR";
63
+ constructor(message: string, options?: JazzCashErrorOptions);
64
+ }
65
+ /**
66
+ * A safety guard refused the request.
67
+ *
68
+ * Raised when a caller attempts production money movement without the required
69
+ * dual opt-in, or when the declared environment disagrees with the credential
70
+ * profile in use. Sandbox and production share identical gateway URLs, so this
71
+ * guard cannot be inferred away.
72
+ */
73
+ export declare class JazzCashSafetyError extends JazzCashError {
74
+ readonly code = "JAZZCASH_SAFETY_ERROR";
75
+ constructor(message: string, options?: JazzCashErrorOptions);
76
+ }
77
+ /** A requested flow, document or knowledge entry does not exist. */
78
+ export declare class JazzCashNotFoundError extends JazzCashError {
79
+ readonly code = "JAZZCASH_NOT_FOUND";
80
+ constructor(message: string, options?: JazzCashErrorOptions);
81
+ }
82
+ /** Narrow an unknown thrown value to a readable message without leaking internals. */
83
+ export declare function describeError(error: unknown): string;
84
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,MAAM;IACrB,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACtD;AAED,kEAAkE;AAClE,8BAAsB,aAAc,SAAQ,KAAK;IAC/C,sEAAsE;IACtE,kBAAyB,IAAI,EAAE,MAAM,CAAC;IAEtC,SAAgB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAE3C,SAAgB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3D,SAAS,aAAa,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB;CAM1E;AAED,4DAA4D;AAC5D,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,SAAyB,IAAI,2BAA2B;gBAErC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB;CAGnE;AAED,oEAAoE;AACpE,qBAAa,uBAAwB,SAAQ,aAAa;IACxD,SAAyB,IAAI,+BAA+B;gBAEzC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB;CAGnE;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,aAAa;IAC/C,SAAyB,IAAI,qBAAqB;gBAE/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB;CAGnE;AAED,iFAAiF;AACjF,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,SAAyB,IAAI,4BAA4B;gBAEtC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB;CAGnE;AAED;;;;;;;GAOG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,SAAyB,IAAI,2BAA2B;gBAErC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB;CAGnE;AAED,oEAAoE;AACpE,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,SAAyB,IAAI,wBAAwB;gBAElC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB;CAGnE;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQpD"}
package/dist/errors.js ADDED
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Error taxonomy for the JazzCash MCP server.
3
+ *
4
+ * Every error carries a stable machine-readable `code` and, where the failure is
5
+ * traceable to official JazzCash documentation, the references that explain it.
6
+ * Tool handlers convert these into `isError` results rather than letting them
7
+ * escape across the protocol boundary.
8
+ */
9
+ /** Base class for every error this server raises deliberately. */
10
+ export class JazzCashError extends Error {
11
+ docRefs;
12
+ details;
13
+ constructor(message, options = {}) {
14
+ super(message, options.cause === undefined ? undefined : { cause: options.cause });
15
+ this.name = new.target.name;
16
+ this.docRefs = options.docRefs ?? [];
17
+ this.details = options.details ?? {};
18
+ }
19
+ }
20
+ /** Server configuration or credential resolution failed. */
21
+ export class JazzCashConfigError extends JazzCashError {
22
+ code = 'JAZZCASH_CONFIG_ERROR';
23
+ constructor(message, options) {
24
+ super(message, options);
25
+ }
26
+ }
27
+ /** A payload failed the documented parameter rules for its flow. */
28
+ export class JazzCashValidationError extends JazzCashError {
29
+ code = 'JAZZCASH_VALIDATION_ERROR';
30
+ constructor(message, options) {
31
+ super(message, options);
32
+ }
33
+ }
34
+ /**
35
+ * Request signature construction or verification failed.
36
+ *
37
+ * Named for the operation rather than for a gateway: one engine signs and
38
+ * diagnoses every registered scheme, so naming this error after a single gateway
39
+ * renders every signature failure under that gateway's name — including one
40
+ * raised for a scheme it has nothing to do with. A merchant told to check a
41
+ * credential their gateway does not issue checks nothing.
42
+ */
43
+ export class SignatureError extends JazzCashError {
44
+ code = 'SIGNATURE_ERROR';
45
+ constructor(message, options) {
46
+ super(message, options);
47
+ }
48
+ }
49
+ /** The gateway was unreachable, timed out, or returned something unparseable. */
50
+ export class JazzCashGatewayError extends JazzCashError {
51
+ code = 'JAZZCASH_GATEWAY_ERROR';
52
+ constructor(message, options) {
53
+ super(message, options);
54
+ }
55
+ }
56
+ /**
57
+ * A safety guard refused the request.
58
+ *
59
+ * Raised when a caller attempts production money movement without the required
60
+ * dual opt-in, or when the declared environment disagrees with the credential
61
+ * profile in use. Sandbox and production share identical gateway URLs, so this
62
+ * guard cannot be inferred away.
63
+ */
64
+ export class JazzCashSafetyError extends JazzCashError {
65
+ code = 'JAZZCASH_SAFETY_ERROR';
66
+ constructor(message, options) {
67
+ super(message, options);
68
+ }
69
+ }
70
+ /** A requested flow, document or knowledge entry does not exist. */
71
+ export class JazzCashNotFoundError extends JazzCashError {
72
+ code = 'JAZZCASH_NOT_FOUND';
73
+ constructor(message, options) {
74
+ super(message, options);
75
+ }
76
+ }
77
+ /** Narrow an unknown thrown value to a readable message without leaking internals. */
78
+ export function describeError(error) {
79
+ if (error instanceof Error) {
80
+ return error.message;
81
+ }
82
+ if (typeof error === 'string') {
83
+ return error;
84
+ }
85
+ return 'An unknown error occurred.';
86
+ }
87
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwBH,kEAAkE;AAClE,MAAM,OAAgB,aAAc,SAAQ,KAAK;IAI/B,OAAO,CAAoB;IAE3B,OAAO,CAAoC;IAE3D,YAAsB,OAAe,EAAE,UAAgC,EAAE;QACvE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IACvC,CAAC;CACF;AAED,4DAA4D;AAC5D,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAC3B,IAAI,GAAG,uBAAuB,CAAC;IAExD,YAAmB,OAAe,EAAE,OAA8B;QAChE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,oEAAoE;AACpE,MAAM,OAAO,uBAAwB,SAAQ,aAAa;IAC/B,IAAI,GAAG,2BAA2B,CAAC;IAE5D,YAAmB,OAAe,EAAE,OAA8B;QAChE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAe,SAAQ,aAAa;IACtB,IAAI,GAAG,iBAAiB,CAAC;IAElD,YAAmB,OAAe,EAAE,OAA8B;QAChE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,OAAO,oBAAqB,SAAQ,aAAa;IAC5B,IAAI,GAAG,wBAAwB,CAAC;IAEzD,YAAmB,OAAe,EAAE,OAA8B;QAChE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAC3B,IAAI,GAAG,uBAAuB,CAAC;IAExD,YAAmB,OAAe,EAAE,OAA8B;QAChE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,oEAAoE;AACpE,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IAC7B,IAAI,GAAG,oBAAoB,CAAC;IAErD,YAAmB,OAAe,EAAE,OAA8B;QAChE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,sFAAsF;AACtF,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,4BAA4B,CAAC;AACtC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { IntegrationFlow } from '../catalogue/types.js';
2
+ import type { JazzCashEnvironment } from '../config/environment.js';
3
+ import type { NormalisedParameters } from '../domain/types.js';
4
+ export interface CheckoutFormOptions {
5
+ readonly flow: IntegrationFlow;
6
+ readonly environment: JazzCashEnvironment;
7
+ readonly parameters: NormalisedParameters;
8
+ }
9
+ /**
10
+ * Render a self-contained page that posts the signed parameters to JazzCash.
11
+ *
12
+ * The form is NOT auto-submitting: the page is a deliberate manual test step, and
13
+ * an auto-submit would make it easy to fire a real transaction by opening a file.
14
+ */
15
+ export declare function renderCheckoutForm(options: CheckoutFormOptions): string;
16
+ //# sourceMappingURL=checkout-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-form.d.ts","sourceRoot":"","sources":["../../src/gateway/checkout-form.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAuB/D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAC;CAC3C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAqFvE"}
@@ -0,0 +1,103 @@
1
+ import { endpointIsAmbiguous, resolveEndpoint } from '../catalogue/endpoints.js';
2
+ /**
3
+ * Signed HTML form for the browser flows.
4
+ *
5
+ * Card checkout, BNPL checkout and wallet linking cannot be driven headlessly:
6
+ * the customer completes them in a browser, entering card details or an MPIN.
7
+ * The server therefore produces a ready-to-submit local page and hands the human
8
+ * explicit instructions, rather than pretending to automate the payment page.
9
+ */
10
+ const HTML_ESCAPES = {
11
+ '&': '&amp;',
12
+ '<': '&lt;',
13
+ '>': '&gt;',
14
+ '"': '&quot;',
15
+ "'": '&#39;',
16
+ };
17
+ function escapeHtml(value) {
18
+ return value.replace(/[&<>"']/g, (character) => HTML_ESCAPES[character] ?? character);
19
+ }
20
+ /**
21
+ * Render a self-contained page that posts the signed parameters to JazzCash.
22
+ *
23
+ * The form is NOT auto-submitting: the page is a deliberate manual test step, and
24
+ * an auto-submit would make it easy to fire a real transaction by opening a file.
25
+ */
26
+ export function renderCheckoutForm(options) {
27
+ const { flow, environment, parameters } = options;
28
+ const endpoint = resolveEndpoint(flow, environment);
29
+ const isLive = environment === 'production';
30
+ const rows = Object.entries(parameters)
31
+ .map(([name, value]) => ` <tr><th>${escapeHtml(name)}</th><td>${value === '' ? '<em>(empty)</em>' : escapeHtml(value)}</td></tr>`)
32
+ .join('\n');
33
+ const inputs = Object.entries(parameters)
34
+ .map(([name, value]) => ` <input type="hidden" name="${escapeHtml(name)}" value="${escapeHtml(value)}">`)
35
+ .join('\n');
36
+ return `<!DOCTYPE html>
37
+ <html lang="en">
38
+ <head>
39
+ <meta charset="UTF-8">
40
+ <title>JazzCash test — ${escapeHtml(flow.title)}</title>
41
+ <style>
42
+ body { font-family: system-ui, sans-serif; max-width: 60rem; margin: 2rem auto; padding: 0 1rem; }
43
+ table { border-collapse: collapse; width: 100%; font-family: ui-monospace, monospace; font-size: 0.85rem; }
44
+ th, td { border: 1px solid #ddd; padding: 0.4rem 0.6rem; text-align: left; vertical-align: top; }
45
+ th { width: 16rem; background: #fafafa; }
46
+ .banner { padding: 1rem; border-radius: 6px; margin-bottom: 1.5rem; }
47
+ .live { background: #fdecea; border: 2px solid #d32f2f; }
48
+ .sandbox { background: #e8f5e9; border: 1px solid #2e7d32; }
49
+ button { font-size: 1rem; padding: 0.6rem 1.4rem; margin-top: 1rem; }
50
+ </style>
51
+ </head>
52
+ <body>
53
+ <h1>${escapeHtml(flow.title)}</h1>
54
+
55
+ <div class="banner ${isLive ? 'live' : 'sandbox'}">
56
+ <strong>Environment: ${escapeHtml(environment.toUpperCase())}</strong>
57
+ <p>
58
+ ${isLive
59
+ ? 'These are PRODUCTION credentials. Submitting this form starts a real transaction against a real account.'
60
+ : 'These are sandbox credentials. Submitting this form starts a sandbox transaction.'}
61
+ </p>
62
+ <p>
63
+ ${
64
+ // Computed from the URLs actually rendered below rather than from the
65
+ // declared flag, so the page cannot assert something the form contradicts.
66
+ endpointIsAmbiguous(flow)
67
+ ? 'The endpoint below is identical for sandbox and production. The environment above reflects the credentials embedded in this form, not the URL.'
68
+ : `The endpoint below belongs to the ${escapeHtml(environment)} environment, as do the credentials embedded in this form. Submitting it reaches ${escapeHtml(environment)}.`}
69
+ </p>
70
+ </div>
71
+
72
+ <p>Posting to: <code>${escapeHtml(endpoint)}</code></p>
73
+
74
+ <h2>Parameters</h2>
75
+ <table>
76
+ ${rows}
77
+ </table>
78
+
79
+ <form method="post" action="${escapeHtml(endpoint)}">
80
+ ${inputs}
81
+ <button type="submit">Submit to JazzCash</button>
82
+ </form>
83
+
84
+ <h2>After you submit</h2>
85
+ <ol>
86
+ <li>Complete the payment on the JazzCash page.</li>
87
+ <li>Confirm the result is posted back to your registered Return URL.</li>
88
+ <li>Wait at least ten minutes, then call the Status Inquiry API with
89
+ <code>${escapeHtml(parameters['pp_TxnRefNo'] ?? parameters['pp_RequestID'] ?? '')}</code>
90
+ to confirm the outcome independently.</li>
91
+ <li>Capture the screenshots JazzCash requires: checkout page, landing page,
92
+ method selection, payment, callback response, and order status.</li>
93
+ </ol>
94
+
95
+ <p><small>
96
+ Generated by the JazzCash MCP server. This file contains a valid signed payload
97
+ for your merchant account — delete it after testing and never commit it.
98
+ </small></p>
99
+ </body>
100
+ </html>
101
+ `;
102
+ }
103
+ //# sourceMappingURL=checkout-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-form.js","sourceRoot":"","sources":["../../src/gateway/checkout-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAKjF;;;;;;;GAOG;AAEH,MAAM,YAAY,GAAqC;IACrD,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,OAAO;CACb,CAAC;AAEF,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,CAAC;AACxF,CAAC;AAQD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA4B;IAC7D,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,WAAW,KAAK,YAAY,CAAC;IAE5C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;SACpC,GAAG,CACF,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAChB,iBAAiB,UAAU,CAAC,IAAI,CAAC,YAAY,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CACjH;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;SACtC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,oCAAoC,UAAU,CAAC,IAAI,CAAC,YAAY,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;SAC7G,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;;;2BAIkB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;QAazC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;;uBAEP,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;2BACvB,UAAU,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;;QAGxD,MAAM;QACJ,CAAC,CAAC,0GAA0G;QAC5G,CAAC,CAAC,mFACN;;;QAGE;IACA,sEAAsE;IACtE,2EAA2E;IAC3E,mBAAmB,CAAC,IAAI,CAAC;QACvB,CAAC,CAAC,gJAAgJ;QAClJ,CAAC,CAAC,qCAAqC,UAAU,CAAC,WAAW,CAAC,oFAAoF,UAAU,CAAC,WAAW,CAAC,GAC7K;;;;yBAImB,UAAU,CAAC,QAAQ,CAAC;;;;EAI3C,IAAI;;;gCAG0B,UAAU,CAAC,QAAQ,CAAC;EAClD,MAAM;;;;;;;;;gBASQ,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;;;;;;;;;;;;CAYxF,CAAC;AACF,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Directory generated forms land in when the operator has named none.
3
+ *
4
+ * Deliberately NOT derived from the package root. This server is installed with
5
+ * `npx`, which unpacks it into a cache directory npm garbage-collects without
6
+ * warning: a default under the package would scatter pages embedding the
7
+ * merchant's password and a valid pp_SecureHash across `~/.npm/_npx/<hash>/`,
8
+ * where the operator neither expects them nor knows to delete them, and where a
9
+ * reinstall silently moves the directory out from under them.
10
+ *
11
+ * A per-user state directory is the right home instead. It is stable across
12
+ * reinstalls, it belongs to the operator rather than to a package manager, and
13
+ * `XDG_STATE_HOME` is the variable a user has already set if they keep such
14
+ * state somewhere other than `~/.local/state`.
15
+ *
16
+ * An empty, whitespace-only or relative `XDG_STATE_HOME` falls back rather than
17
+ * being used. A blank variable is an unset one, which is the same treatment
18
+ * {@link CHECKOUT_OUTPUT_DIRECTORY_VARIABLE} gets below. A relative one is
19
+ * ignored because the XDG specification says it must be, and because joining it
20
+ * would produce a relative path that {@link canonicalPath} anchors to
21
+ * `process.cwd()` — for a stdio server that is whatever the AI client chose,
22
+ * routinely the merchant's own project directory, which is exactly where a page
23
+ * carrying live credentials must never be written.
24
+ *
25
+ * Exported so the default can be asserted directly. Every suite that exercises
26
+ * the tool pins {@link CHECKOUT_OUTPUT_DIRECTORY_VARIABLE} to a temporary
27
+ * directory, so without this the default is the one path in this module no test
28
+ * would ever execute.
29
+ */
30
+ export declare function defaultCheckoutRoot(): string;
31
+ export interface CheckoutTarget {
32
+ /** Directory every generated form is confined to. */
33
+ readonly root: string;
34
+ /** Absolute file the form will be written to. */
35
+ readonly path: string;
36
+ }
37
+ /**
38
+ * Decide where a checkout form may be written, refusing anything outside the
39
+ * server's own output directory.
40
+ *
41
+ * An escaping path is refused rather than silently rewritten: quietly relocating
42
+ * live credentials would hide where they actually landed.
43
+ */
44
+ export declare function resolveCheckoutTarget(outputPath: string | undefined, defaultFileName: string): CheckoutTarget;
45
+ /**
46
+ * Write the page, re-checking containment once the directory exists.
47
+ *
48
+ * `resolveCheckoutTarget` could only resolve the symlinks present when it ran,
49
+ * and the write is what actually discloses the credentials, so the check is made
50
+ * again against the directory that now exists on disk.
51
+ *
52
+ * The directory is created 0700 because every file in it embeds the merchant's
53
+ * password and a valid pp_SecureHash. On a shared host the process umask alone
54
+ * would commonly leave it world-readable, and the mode is only applied to
55
+ * directories this call actually creates — an operator who pointed
56
+ * `JAZZCASH_CHECKOUT_OUTPUT_DIR` at an existing directory keeps their own
57
+ * permissions.
58
+ *
59
+ * The file is opened rather than handed to `writeFileSync` for two reasons that
60
+ * `writeFileSync` cannot serve at once. `O_NOFOLLOW` makes the open fail rather
61
+ * than follow a symbolic link at the target name, which is the one component no
62
+ * containment check could resolve, and it does so atomically — there is no
63
+ * window between the check and the write for a link to appear in. And `O_CREAT`
64
+ * carries the mode, so the page is 0600 from the moment it exists rather than
65
+ * whatever the umask allows. `chmodSync` follows because a mode passed to
66
+ * `open` is ignored for a file that already exists, and overwriting yesterday's
67
+ * world-readable page must tighten it rather than inherit it.
68
+ */
69
+ export declare function writeCheckoutForm(target: CheckoutTarget, html: string): void;
70
+ //# sourceMappingURL=checkout-output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-output.d.ts","sourceRoot":"","sources":["../../src/gateway/checkout-output.ts"],"names":[],"mappings":"AAwDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAI5C;AAED,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AA0ED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,cAAc,CAqB7G;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAsB5E"}