@davidvornholt/lib-fints 0.0.0-stage → 1.5.401

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 (699) hide show
  1. package/FORK.md +40 -0
  2. package/LICENSE +504 -0
  3. package/README.md +423 -2
  4. package/biome.json +35 -0
  5. package/dist/accountBalance.js +1 -0
  6. package/dist/accountDescriptor.js +65 -0
  7. package/dist/bankAccount.js +42 -0
  8. package/dist/bankAnswer.js +1 -0
  9. package/dist/bankTransaction.js +1 -0
  10. package/dist/bankingInformation.js +1 -0
  11. package/dist/bpd.js +1 -0
  12. package/dist/camtParser.js +443 -0
  13. package/dist/client.js +740 -0
  14. package/dist/codes.js +87 -0
  15. package/dist/config.js +241 -0
  16. package/dist/creditCardStatement.js +1 -0
  17. package/dist/dataElements/AlphaNumeric.js +24 -0
  18. package/dist/dataElements/Amount.js +6 -0
  19. package/dist/dataElements/Binary.js +37 -0
  20. package/dist/dataElements/Country.js +6 -0
  21. package/dist/dataElements/Currency.js +6 -0
  22. package/dist/dataElements/Dat.js +18 -0
  23. package/dist/dataElements/DataElement.js +38 -0
  24. package/dist/dataElements/Digits.js +23 -0
  25. package/dist/dataElements/Float.js +21 -0
  26. package/dist/dataElements/Identification.js +6 -0
  27. package/dist/dataElements/Numeric.js +26 -0
  28. package/dist/dataElements/Text.js +21 -0
  29. package/dist/dataElements/Time.js +18 -0
  30. package/dist/dataElements/YesNo.js +18 -0
  31. package/dist/dataGroups/Account.js +12 -0
  32. package/dist/dataGroups/Balance.js +15 -0
  33. package/dist/dataGroups/BankIdentification.js +8 -0
  34. package/dist/dataGroups/DataGroup.js +61 -0
  35. package/dist/dataGroups/InternationalAccount.js +15 -0
  36. package/dist/dataGroups/Money.js +8 -0
  37. package/dist/dataGroups/RefMessage.js +8 -0
  38. package/dist/dataGroups/SepaAccount.js +17 -0
  39. package/dist/dataGroups/TimeStamp.js +8 -0
  40. package/dist/decoder.js +100 -0
  41. package/dist/dialog.js +469 -0
  42. package/dist/electronicStatement.js +1 -0
  43. package/dist/encoder.js +59 -0
  44. package/dist/format.js +6 -0
  45. package/dist/httpClient.js +84 -0
  46. package/dist/index.js +22 -0
  47. package/dist/interactions/balanceInteraction.js +46 -0
  48. package/dist/interactions/creditTransferInteraction.js +499 -0
  49. package/dist/interactions/creditcardStatementInteraction.js +115 -0
  50. package/dist/interactions/creditcardStatementInteractionHKKKU.js +141 -0
  51. package/dist/interactions/customerInteraction.js +121 -0
  52. package/dist/interactions/electronicStatementInteraction.js +89 -0
  53. package/dist/interactions/endDialogInteraction.js +17 -0
  54. package/dist/interactions/initDialogInteraction.js +232 -0
  55. package/dist/interactions/portfolioInteraction.js +65 -0
  56. package/dist/interactions/sepaAccountInteraction.js +51 -0
  57. package/dist/interactions/statementInteractionCAMT.js +71 -0
  58. package/dist/interactions/statementInteractionMT940.js +50 -0
  59. package/dist/interactions/tanMediaInteraction.js +37 -0
  60. package/dist/interactions/transferOutcome.js +364 -0
  61. package/dist/interactions/vopCheck.js +346 -0
  62. package/dist/message.js +239 -0
  63. package/dist/mt535parser.js +151 -0
  64. package/dist/mt940parser.js +313 -0
  65. package/dist/pain001Builder.js +308 -0
  66. package/dist/pain002Parser.js +140 -0
  67. package/dist/parser.js +28 -0
  68. package/dist/partedSegment.js +11 -0
  69. package/dist/segment.js +81 -0
  70. package/dist/segmentDefinition.js +20 -0
  71. package/dist/segmentHeader.js +13 -0
  72. package/dist/segments/DIKKU.js +23 -0
  73. package/dist/segments/DKKKU.js +25 -0
  74. package/dist/segments/HIBPA.js +26 -0
  75. package/dist/segments/HICAZ.js +22 -0
  76. package/dist/segments/HICAZS.js +19 -0
  77. package/dist/segments/HICCSS.js +23 -0
  78. package/dist/segments/HIEKA.js +45 -0
  79. package/dist/segments/HIEKAS.js +18 -0
  80. package/dist/segments/HIKAZ.js +16 -0
  81. package/dist/segments/HIKAZS.js +17 -0
  82. package/dist/segments/HIKIM.js +14 -0
  83. package/dist/segments/HIKKU.js +23 -0
  84. package/dist/segments/HIKKUS.js +18 -0
  85. package/dist/segments/HIKOM.js +26 -0
  86. package/dist/segments/HIPINS.js +22 -0
  87. package/dist/segments/HIRMG.js +23 -0
  88. package/dist/segments/HIRMS.js +23 -0
  89. package/dist/segments/HISAL.js +34 -0
  90. package/dist/segments/HISPA.js +14 -0
  91. package/dist/segments/HISPAS.js +22 -0
  92. package/dist/segments/HISYN.js +19 -0
  93. package/dist/segments/HITAB.js +40 -0
  94. package/dist/segments/HITAN.js +25 -0
  95. package/dist/segments/HITANS.js +53 -0
  96. package/dist/segments/HIUPA.js +21 -0
  97. package/dist/segments/HIUPD.js +41 -0
  98. package/dist/segments/HIVPAS.js +21 -0
  99. package/dist/segments/HIVPP.js +35 -0
  100. package/dist/segments/HIVPPS.js +23 -0
  101. package/dist/segments/HIWPD.js +15 -0
  102. package/dist/segments/HKCAZ.js +28 -0
  103. package/dist/segments/HKCCS.js +30 -0
  104. package/dist/segments/HKEKA.js +43 -0
  105. package/dist/segments/HKEND.js +14 -0
  106. package/dist/segments/HKIDN.js +21 -0
  107. package/dist/segments/HKKAZ.js +27 -0
  108. package/dist/segments/HKKKU.js +26 -0
  109. package/dist/segments/HKSAL.js +24 -0
  110. package/dist/segments/HKSPA.js +21 -0
  111. package/dist/segments/HKSYN.js +14 -0
  112. package/dist/segments/HKTAB.js +15 -0
  113. package/dist/segments/HKTAN.js +38 -0
  114. package/dist/segments/HKVPA.js +19 -0
  115. package/dist/segments/HKVPP.js +33 -0
  116. package/dist/segments/HKVVB.js +21 -0
  117. package/dist/segments/HKWPD.js +23 -0
  118. package/dist/segments/HNHBK.js +23 -0
  119. package/dist/segments/HNHBS.js +14 -0
  120. package/dist/segments/HNSHA.js +20 -0
  121. package/dist/segments/HNSHK.js +54 -0
  122. package/dist/segments/HNVSD.js +14 -0
  123. package/dist/segments/HNVSK.js +52 -0
  124. package/dist/segments/businessTransactionParameter.js +20 -0
  125. package/dist/segments/registry.js +120 -0
  126. package/dist/statement.js +1 -0
  127. package/dist/tanMethod.js +1 -0
  128. package/dist/tests/HIBPA.test.js +26 -0
  129. package/dist/tests/HICAZS.test.js +18 -0
  130. package/dist/tests/HICCSS.test.js +16 -0
  131. package/dist/tests/HIPINS.test.js +14 -0
  132. package/dist/tests/HIRMG.test.js +24 -0
  133. package/dist/tests/HITAB.test.js +26 -0
  134. package/dist/tests/HITANS.test.js +19 -0
  135. package/dist/tests/HIUPA.test.js +11 -0
  136. package/dist/tests/HIUPD.test.js +11 -0
  137. package/dist/tests/HIVPAS.test.js +16 -0
  138. package/dist/tests/HIVPP.test.js +58 -0
  139. package/dist/tests/HIVPPS.test.js +29 -0
  140. package/dist/tests/HIWPD.test.js +25 -0
  141. package/dist/tests/HKCAZ.test.js +43 -0
  142. package/dist/tests/HKCCS.test.js +52 -0
  143. package/dist/tests/HKEKA.test.js +198 -0
  144. package/dist/tests/HKIDN.test.js +22 -0
  145. package/dist/tests/HKKKU.test.js +207 -0
  146. package/dist/tests/HKSAL.test.js +45 -0
  147. package/dist/tests/HKTAN.test.js +22 -0
  148. package/dist/tests/HKVPA.test.js +21 -0
  149. package/dist/tests/HKVPP.test.js +40 -0
  150. package/dist/tests/HKWPD.test.js +38 -0
  151. package/dist/tests/HNSHK.test.js +11 -0
  152. package/dist/tests/HNVSK.test.js +11 -0
  153. package/dist/tests/accountDescriptor.test.js +99 -0
  154. package/dist/tests/accountReference.test.js +126 -0
  155. package/dist/tests/bankReplyChecks.test.js +37 -0
  156. package/dist/tests/camtParser.test.js +988 -0
  157. package/dist/tests/client.test.js +690 -0
  158. package/dist/tests/credentialRedaction.test.js +59 -0
  159. package/dist/tests/creditTransfer.test.js +1475 -0
  160. package/dist/tests/creditTransferBank.js +205 -0
  161. package/dist/tests/creditTransferSafety.test.js +319 -0
  162. package/dist/tests/datatypes.test.js +8 -0
  163. package/dist/tests/dialog.test.js +435 -0
  164. package/dist/tests/httpClientErrorLog.test.js +27 -0
  165. package/dist/tests/interactionAccountDescriptor.test.js +153 -0
  166. package/dist/tests/message.test.js +98 -0
  167. package/dist/tests/mt535parser.test.js +245 -0
  168. package/dist/tests/mt940parser.test.js +82 -0
  169. package/dist/tests/pain001Builder.test.js +291 -0
  170. package/dist/tests/pain002Parser.test.js +152 -0
  171. package/dist/tests/parser.test.js +25 -0
  172. package/dist/tests/partedDialog.test.js +203 -0
  173. package/dist/tests/partedResponse.test.js +181 -0
  174. package/dist/tests/statementParseFailure.test.js +18 -0
  175. package/dist/tests/tanMedia.test.js +125 -0
  176. package/dist/types/accountBalance.d.ts +9 -0
  177. package/dist/types/accountBalance.d.ts.map +1 -0
  178. package/dist/types/accountDescriptor.d.ts +49 -0
  179. package/dist/types/accountDescriptor.d.ts.map +1 -0
  180. package/dist/types/bankAccount.d.ts +39 -0
  181. package/dist/types/bankAccount.d.ts.map +1 -0
  182. package/dist/types/bankAnswer.d.ts +6 -0
  183. package/dist/types/bankAnswer.d.ts.map +1 -0
  184. package/dist/types/bankTransaction.d.ts +22 -0
  185. package/dist/types/bankTransaction.d.ts.map +1 -0
  186. package/dist/types/bankingInformation.d.ts +20 -0
  187. package/dist/types/bankingInformation.d.ts.map +1 -0
  188. package/dist/types/bpd.d.ts +17 -0
  189. package/dist/types/bpd.d.ts.map +1 -0
  190. package/dist/types/camtParser.d.ts +31 -0
  191. package/dist/types/camtParser.d.ts.map +1 -0
  192. package/dist/types/client.d.ts +302 -0
  193. package/dist/types/client.d.ts.map +1 -0
  194. package/dist/types/codes.d.ts +75 -0
  195. package/dist/types/codes.d.ts.map +1 -0
  196. package/dist/types/config.d.ts +127 -0
  197. package/dist/types/config.d.ts.map +1 -0
  198. package/dist/types/creditCardStatement.d.ts +16 -0
  199. package/dist/types/creditCardStatement.d.ts.map +1 -0
  200. package/dist/types/dataElements/AlphaNumeric.d.ts +8 -0
  201. package/dist/types/dataElements/AlphaNumeric.d.ts.map +1 -0
  202. package/dist/types/dataElements/Amount.d.ts +5 -0
  203. package/dist/types/dataElements/Amount.d.ts.map +1 -0
  204. package/dist/types/dataElements/Binary.d.ts +15 -0
  205. package/dist/types/dataElements/Binary.d.ts.map +1 -0
  206. package/dist/types/dataElements/Country.d.ts +5 -0
  207. package/dist/types/dataElements/Country.d.ts.map +1 -0
  208. package/dist/types/dataElements/Currency.d.ts +5 -0
  209. package/dist/types/dataElements/Currency.d.ts.map +1 -0
  210. package/dist/types/dataElements/Dat.d.ts +8 -0
  211. package/dist/types/dataElements/Dat.d.ts.map +1 -0
  212. package/dist/types/dataElements/DataElement.d.ts +14 -0
  213. package/dist/types/dataElements/DataElement.d.ts.map +1 -0
  214. package/dist/types/dataElements/Digits.d.ts +8 -0
  215. package/dist/types/dataElements/Digits.d.ts.map +1 -0
  216. package/dist/types/dataElements/Float.d.ts +8 -0
  217. package/dist/types/dataElements/Float.d.ts.map +1 -0
  218. package/dist/types/dataElements/Identification.d.ts +5 -0
  219. package/dist/types/dataElements/Identification.d.ts.map +1 -0
  220. package/dist/types/dataElements/Numeric.d.ts +9 -0
  221. package/dist/types/dataElements/Numeric.d.ts.map +1 -0
  222. package/dist/types/dataElements/Text.d.ts +8 -0
  223. package/dist/types/dataElements/Text.d.ts.map +1 -0
  224. package/dist/types/dataElements/Time.d.ts +8 -0
  225. package/dist/types/dataElements/Time.d.ts.map +1 -0
  226. package/dist/types/dataElements/YesNo.d.ts +7 -0
  227. package/dist/types/dataElements/YesNo.d.ts.map +1 -0
  228. package/dist/types/dataGroups/Account.d.ts +14 -0
  229. package/dist/types/dataGroups/Account.d.ts.map +1 -0
  230. package/dist/types/dataGroups/Balance.d.ts +12 -0
  231. package/dist/types/dataGroups/Balance.d.ts.map +1 -0
  232. package/dist/types/dataGroups/BankIdentification.d.ts +5 -0
  233. package/dist/types/dataGroups/BankIdentification.d.ts.map +1 -0
  234. package/dist/types/dataGroups/DataGroup.d.ts +10 -0
  235. package/dist/types/dataGroups/DataGroup.d.ts.map +1 -0
  236. package/dist/types/dataGroups/InternationalAccount.d.ts +13 -0
  237. package/dist/types/dataGroups/InternationalAccount.d.ts.map +1 -0
  238. package/dist/types/dataGroups/Money.d.ts +9 -0
  239. package/dist/types/dataGroups/Money.d.ts.map +1 -0
  240. package/dist/types/dataGroups/RefMessage.d.ts +9 -0
  241. package/dist/types/dataGroups/RefMessage.d.ts.map +1 -0
  242. package/dist/types/dataGroups/SepaAccount.d.ts +11 -0
  243. package/dist/types/dataGroups/SepaAccount.d.ts.map +1 -0
  244. package/dist/types/dataGroups/TimeStamp.d.ts +9 -0
  245. package/dist/types/dataGroups/TimeStamp.d.ts.map +1 -0
  246. package/dist/types/decoder.d.ts +4 -0
  247. package/dist/types/decoder.d.ts.map +1 -0
  248. package/dist/types/dialog.d.ts +106 -0
  249. package/dist/types/dialog.d.ts.map +1 -0
  250. package/dist/types/electronicStatement.d.ts +40 -0
  251. package/dist/types/electronicStatement.d.ts.map +1 -0
  252. package/dist/types/encoder.d.ts +3 -0
  253. package/dist/types/encoder.d.ts.map +1 -0
  254. package/dist/types/format.d.ts +3 -0
  255. package/dist/types/format.d.ts.map +1 -0
  256. package/dist/types/httpClient.d.ts +14 -0
  257. package/dist/types/httpClient.d.ts.map +1 -0
  258. package/dist/types/index.d.ts +27 -0
  259. package/dist/types/index.d.ts.map +1 -0
  260. package/dist/types/interactions/balanceInteraction.d.ts +16 -0
  261. package/dist/types/interactions/balanceInteraction.d.ts.map +1 -0
  262. package/dist/types/interactions/creditTransferInteraction.d.ts +228 -0
  263. package/dist/types/interactions/creditTransferInteraction.d.ts.map +1 -0
  264. package/dist/types/interactions/creditcardStatementInteraction.d.ts +19 -0
  265. package/dist/types/interactions/creditcardStatementInteraction.d.ts.map +1 -0
  266. package/dist/types/interactions/creditcardStatementInteractionHKKKU.d.ts +23 -0
  267. package/dist/types/interactions/creditcardStatementInteractionHKKKU.d.ts.map +1 -0
  268. package/dist/types/interactions/customerInteraction.d.ts +84 -0
  269. package/dist/types/interactions/customerInteraction.d.ts.map +1 -0
  270. package/dist/types/interactions/electronicStatementInteraction.d.ts +34 -0
  271. package/dist/types/interactions/electronicStatementInteraction.d.ts.map +1 -0
  272. package/dist/types/interactions/endDialogInteraction.d.ts +13 -0
  273. package/dist/types/interactions/endDialogInteraction.d.ts.map +1 -0
  274. package/dist/types/interactions/initDialogInteraction.d.ts +23 -0
  275. package/dist/types/interactions/initDialogInteraction.d.ts.map +1 -0
  276. package/dist/types/interactions/portfolioInteraction.d.ts +40 -0
  277. package/dist/types/interactions/portfolioInteraction.d.ts.map +1 -0
  278. package/dist/types/interactions/sepaAccountInteraction.d.ts +18 -0
  279. package/dist/types/interactions/sepaAccountInteraction.d.ts.map +1 -0
  280. package/dist/types/interactions/statementInteractionCAMT.d.ts +14 -0
  281. package/dist/types/interactions/statementInteractionCAMT.d.ts.map +1 -0
  282. package/dist/types/interactions/statementInteractionMT940.d.ts +14 -0
  283. package/dist/types/interactions/statementInteractionMT940.d.ts.map +1 -0
  284. package/dist/types/interactions/tanMediaInteraction.d.ts +13 -0
  285. package/dist/types/interactions/tanMediaInteraction.d.ts.map +1 -0
  286. package/dist/types/interactions/transferOutcome.d.ts +129 -0
  287. package/dist/types/interactions/transferOutcome.d.ts.map +1 -0
  288. package/dist/types/interactions/vopCheck.d.ts +107 -0
  289. package/dist/types/interactions/vopCheck.d.ts.map +1 -0
  290. package/dist/types/message.d.ts +30 -0
  291. package/dist/types/message.d.ts.map +1 -0
  292. package/dist/types/mt535parser.d.ts +23 -0
  293. package/dist/types/mt535parser.d.ts.map +1 -0
  294. package/dist/types/mt940parser.d.ts +46 -0
  295. package/dist/types/mt940parser.d.ts.map +1 -0
  296. package/dist/types/pain001Builder.d.ts +96 -0
  297. package/dist/types/pain001Builder.d.ts.map +1 -0
  298. package/dist/types/pain002Parser.d.ts +77 -0
  299. package/dist/types/pain002Parser.d.ts.map +1 -0
  300. package/dist/types/parser.d.ts +2 -0
  301. package/dist/types/parser.d.ts.map +1 -0
  302. package/dist/types/partedSegment.d.ts +15 -0
  303. package/dist/types/partedSegment.d.ts.map +1 -0
  304. package/dist/types/segment.d.ts +11 -0
  305. package/dist/types/segment.d.ts.map +1 -0
  306. package/dist/types/segmentDefinition.d.ts +13 -0
  307. package/dist/types/segmentDefinition.d.ts.map +1 -0
  308. package/dist/types/segmentHeader.d.ts +11 -0
  309. package/dist/types/segmentHeader.d.ts.map +1 -0
  310. package/dist/types/segments/DIKKU.d.ts +20 -0
  311. package/dist/types/segments/DIKKU.d.ts.map +1 -0
  312. package/dist/types/segments/DKKKU.d.ts +24 -0
  313. package/dist/types/segments/DKKKU.d.ts.map +1 -0
  314. package/dist/types/segments/HIBPA.d.ts +28 -0
  315. package/dist/types/segments/HIBPA.d.ts.map +1 -0
  316. package/dist/types/segments/HICAZ.d.ts +22 -0
  317. package/dist/types/segments/HICAZ.d.ts.map +1 -0
  318. package/dist/types/segments/HICAZS.d.ts +17 -0
  319. package/dist/types/segments/HICAZS.d.ts.map +1 -0
  320. package/dist/types/segments/HICCSS.d.ts +23 -0
  321. package/dist/types/segments/HICCSS.d.ts.map +1 -0
  322. package/dist/types/segments/HIEKA.d.ts +52 -0
  323. package/dist/types/segments/HIEKA.d.ts.map +1 -0
  324. package/dist/types/segments/HIEKAS.d.ts +21 -0
  325. package/dist/types/segments/HIEKAS.d.ts.map +1 -0
  326. package/dist/types/segments/HIKAZ.d.ts +17 -0
  327. package/dist/types/segments/HIKAZ.d.ts.map +1 -0
  328. package/dist/types/segments/HIKAZS.d.ts +16 -0
  329. package/dist/types/segments/HIKAZS.d.ts.map +1 -0
  330. package/dist/types/segments/HIKIM.d.ts +18 -0
  331. package/dist/types/segments/HIKIM.d.ts.map +1 -0
  332. package/dist/types/segments/HIKKU.d.ts +25 -0
  333. package/dist/types/segments/HIKKU.d.ts.map +1 -0
  334. package/dist/types/segments/HIKKUS.d.ts +21 -0
  335. package/dist/types/segments/HIKKUS.d.ts.map +1 -0
  336. package/dist/types/segments/HIKOM.d.ts +28 -0
  337. package/dist/types/segments/HIKOM.d.ts.map +1 -0
  338. package/dist/types/segments/HIPINS.d.ts +23 -0
  339. package/dist/types/segments/HIPINS.d.ts.map +1 -0
  340. package/dist/types/segments/HIRMG.d.ts +23 -0
  341. package/dist/types/segments/HIRMG.d.ts.map +1 -0
  342. package/dist/types/segments/HIRMS.d.ts +18 -0
  343. package/dist/types/segments/HIRMS.d.ts.map +1 -0
  344. package/dist/types/segments/HISAL.d.ts +33 -0
  345. package/dist/types/segments/HISAL.d.ts.map +1 -0
  346. package/dist/types/segments/HISPA.d.ts +17 -0
  347. package/dist/types/segments/HISPA.d.ts.map +1 -0
  348. package/dist/types/segments/HISPAS.d.ts +20 -0
  349. package/dist/types/segments/HISPAS.d.ts.map +1 -0
  350. package/dist/types/segments/HISYN.d.ts +20 -0
  351. package/dist/types/segments/HISYN.d.ts.map +1 -0
  352. package/dist/types/segments/HITAB.d.ts +40 -0
  353. package/dist/types/segments/HITAB.d.ts.map +1 -0
  354. package/dist/types/segments/HITAN.d.ts +26 -0
  355. package/dist/types/segments/HITAN.d.ts.map +1 -0
  356. package/dist/types/segments/HITANS.d.ts +46 -0
  357. package/dist/types/segments/HITANS.d.ts.map +1 -0
  358. package/dist/types/segments/HIUPA.d.ts +22 -0
  359. package/dist/types/segments/HIUPA.d.ts.map +1 -0
  360. package/dist/types/segments/HIUPD.d.ts +43 -0
  361. package/dist/types/segments/HIUPD.d.ts.map +1 -0
  362. package/dist/types/segments/HIVPAS.d.ts +21 -0
  363. package/dist/types/segments/HIVPAS.d.ts.map +1 -0
  364. package/dist/types/segments/HIVPP.d.ts +49 -0
  365. package/dist/types/segments/HIVPP.d.ts.map +1 -0
  366. package/dist/types/segments/HIVPPS.d.ts +27 -0
  367. package/dist/types/segments/HIVPPS.d.ts.map +1 -0
  368. package/dist/types/segments/HIWPD.d.ts +22 -0
  369. package/dist/types/segments/HIWPD.d.ts.map +1 -0
  370. package/dist/types/segments/HKCAZ.d.ts +27 -0
  371. package/dist/types/segments/HKCAZ.d.ts.map +1 -0
  372. package/dist/types/segments/HKCCS.d.ts +32 -0
  373. package/dist/types/segments/HKCCS.d.ts.map +1 -0
  374. package/dist/types/segments/HKEKA.d.ts +54 -0
  375. package/dist/types/segments/HKEKA.d.ts.map +1 -0
  376. package/dist/types/segments/HKEND.d.ts +17 -0
  377. package/dist/types/segments/HKEND.d.ts.map +1 -0
  378. package/dist/types/segments/HKIDN.d.ts +23 -0
  379. package/dist/types/segments/HKIDN.d.ts.map +1 -0
  380. package/dist/types/segments/HKKAZ.d.ts +26 -0
  381. package/dist/types/segments/HKKAZ.d.ts.map +1 -0
  382. package/dist/types/segments/HKKKU.d.ts +26 -0
  383. package/dist/types/segments/HKKKU.d.ts.map +1 -0
  384. package/dist/types/segments/HKSAL.d.ts +23 -0
  385. package/dist/types/segments/HKSAL.d.ts.map +1 -0
  386. package/dist/types/segments/HKSPA.d.ts +21 -0
  387. package/dist/types/segments/HKSPA.d.ts.map +1 -0
  388. package/dist/types/segments/HKSYN.d.ts +18 -0
  389. package/dist/types/segments/HKSYN.d.ts.map +1 -0
  390. package/dist/types/segments/HKTAB.d.ts +20 -0
  391. package/dist/types/segments/HKTAB.d.ts.map +1 -0
  392. package/dist/types/segments/HKTAN.d.ts +41 -0
  393. package/dist/types/segments/HKTAN.d.ts.map +1 -0
  394. package/dist/types/segments/HKVPA.d.ts +22 -0
  395. package/dist/types/segments/HKVPA.d.ts.map +1 -0
  396. package/dist/types/segments/HKVPP.d.ts +37 -0
  397. package/dist/types/segments/HKVPP.d.ts.map +1 -0
  398. package/dist/types/segments/HKVVB.d.ts +23 -0
  399. package/dist/types/segments/HKVVB.d.ts.map +1 -0
  400. package/dist/types/segments/HKWPD.d.ts +43 -0
  401. package/dist/types/segments/HKWPD.d.ts.map +1 -0
  402. package/dist/types/segments/HNHBK.d.ts +24 -0
  403. package/dist/types/segments/HNHBK.d.ts.map +1 -0
  404. package/dist/types/segments/HNHBS.d.ts +17 -0
  405. package/dist/types/segments/HNHBS.d.ts.map +1 -0
  406. package/dist/types/segments/HNSHA.d.ts +25 -0
  407. package/dist/types/segments/HNSHA.d.ts.map +1 -0
  408. package/dist/types/segments/HNSHK.d.ts +67 -0
  409. package/dist/types/segments/HNSHK.d.ts.map +1 -0
  410. package/dist/types/segments/HNVSD.d.ts +21 -0
  411. package/dist/types/segments/HNVSD.d.ts.map +1 -0
  412. package/dist/types/segments/HNVSK.d.ts +41 -0
  413. package/dist/types/segments/HNVSK.d.ts.map +1 -0
  414. package/dist/types/segments/businessTransactionParameter.d.ts +18 -0
  415. package/dist/types/segments/businessTransactionParameter.d.ts.map +1 -0
  416. package/dist/types/segments/registry.d.ts +4 -0
  417. package/dist/types/segments/registry.d.ts.map +1 -0
  418. package/dist/types/statement.d.ts +39 -0
  419. package/dist/types/statement.d.ts.map +1 -0
  420. package/dist/types/tanMethod.d.ts +31 -0
  421. package/dist/types/tanMethod.d.ts.map +1 -0
  422. package/dist/types/tests/HIBPA.test.d.ts +2 -0
  423. package/dist/types/tests/HIBPA.test.d.ts.map +1 -0
  424. package/dist/types/tests/HICAZS.test.d.ts +2 -0
  425. package/dist/types/tests/HICAZS.test.d.ts.map +1 -0
  426. package/dist/types/tests/HICCSS.test.d.ts +2 -0
  427. package/dist/types/tests/HICCSS.test.d.ts.map +1 -0
  428. package/dist/types/tests/HIPINS.test.d.ts +2 -0
  429. package/dist/types/tests/HIPINS.test.d.ts.map +1 -0
  430. package/dist/types/tests/HIRMG.test.d.ts +2 -0
  431. package/dist/types/tests/HIRMG.test.d.ts.map +1 -0
  432. package/dist/types/tests/HITAB.test.d.ts +2 -0
  433. package/dist/types/tests/HITAB.test.d.ts.map +1 -0
  434. package/dist/types/tests/HITANS.test.d.ts +2 -0
  435. package/dist/types/tests/HITANS.test.d.ts.map +1 -0
  436. package/dist/types/tests/HIUPA.test.d.ts +2 -0
  437. package/dist/types/tests/HIUPA.test.d.ts.map +1 -0
  438. package/dist/types/tests/HIUPD.test.d.ts +2 -0
  439. package/dist/types/tests/HIUPD.test.d.ts.map +1 -0
  440. package/dist/types/tests/HIVPAS.test.d.ts +2 -0
  441. package/dist/types/tests/HIVPAS.test.d.ts.map +1 -0
  442. package/dist/types/tests/HIVPP.test.d.ts +2 -0
  443. package/dist/types/tests/HIVPP.test.d.ts.map +1 -0
  444. package/dist/types/tests/HIVPPS.test.d.ts +2 -0
  445. package/dist/types/tests/HIVPPS.test.d.ts.map +1 -0
  446. package/dist/types/tests/HIWPD.test.d.ts +2 -0
  447. package/dist/types/tests/HIWPD.test.d.ts.map +1 -0
  448. package/dist/types/tests/HKCAZ.test.d.ts +2 -0
  449. package/dist/types/tests/HKCAZ.test.d.ts.map +1 -0
  450. package/dist/types/tests/HKCCS.test.d.ts +2 -0
  451. package/dist/types/tests/HKCCS.test.d.ts.map +1 -0
  452. package/dist/types/tests/HKEKA.test.d.ts +2 -0
  453. package/dist/types/tests/HKEKA.test.d.ts.map +1 -0
  454. package/dist/types/tests/HKIDN.test.d.ts +2 -0
  455. package/dist/types/tests/HKIDN.test.d.ts.map +1 -0
  456. package/dist/types/tests/HKKKU.test.d.ts +2 -0
  457. package/dist/types/tests/HKKKU.test.d.ts.map +1 -0
  458. package/dist/types/tests/HKSAL.test.d.ts +2 -0
  459. package/dist/types/tests/HKSAL.test.d.ts.map +1 -0
  460. package/dist/types/tests/HKTAN.test.d.ts +2 -0
  461. package/dist/types/tests/HKTAN.test.d.ts.map +1 -0
  462. package/dist/types/tests/HKVPA.test.d.ts +2 -0
  463. package/dist/types/tests/HKVPA.test.d.ts.map +1 -0
  464. package/dist/types/tests/HKVPP.test.d.ts +2 -0
  465. package/dist/types/tests/HKVPP.test.d.ts.map +1 -0
  466. package/dist/types/tests/HKWPD.test.d.ts +2 -0
  467. package/dist/types/tests/HKWPD.test.d.ts.map +1 -0
  468. package/dist/types/tests/HNSHK.test.d.ts +2 -0
  469. package/dist/types/tests/HNSHK.test.d.ts.map +1 -0
  470. package/dist/types/tests/HNVSK.test.d.ts +2 -0
  471. package/dist/types/tests/HNVSK.test.d.ts.map +1 -0
  472. package/dist/types/tests/accountDescriptor.test.d.ts +2 -0
  473. package/dist/types/tests/accountDescriptor.test.d.ts.map +1 -0
  474. package/dist/types/tests/accountReference.test.d.ts +2 -0
  475. package/dist/types/tests/accountReference.test.d.ts.map +1 -0
  476. package/dist/types/tests/bankReplyChecks.test.d.ts +2 -0
  477. package/dist/types/tests/bankReplyChecks.test.d.ts.map +1 -0
  478. package/dist/types/tests/camtParser.test.d.ts +2 -0
  479. package/dist/types/tests/camtParser.test.d.ts.map +1 -0
  480. package/dist/types/tests/client.test.d.ts +2 -0
  481. package/dist/types/tests/client.test.d.ts.map +1 -0
  482. package/dist/types/tests/credentialRedaction.test.d.ts +2 -0
  483. package/dist/types/tests/credentialRedaction.test.d.ts.map +1 -0
  484. package/dist/types/tests/creditTransfer.test.d.ts +2 -0
  485. package/dist/types/tests/creditTransfer.test.d.ts.map +1 -0
  486. package/dist/types/tests/creditTransferBank.d.ts +63 -0
  487. package/dist/types/tests/creditTransferBank.d.ts.map +1 -0
  488. package/dist/types/tests/creditTransferSafety.test.d.ts +2 -0
  489. package/dist/types/tests/creditTransferSafety.test.d.ts.map +1 -0
  490. package/dist/types/tests/datatypes.test.d.ts +2 -0
  491. package/dist/types/tests/datatypes.test.d.ts.map +1 -0
  492. package/dist/types/tests/dialog.test.d.ts +2 -0
  493. package/dist/types/tests/dialog.test.d.ts.map +1 -0
  494. package/dist/types/tests/httpClientErrorLog.test.d.ts +2 -0
  495. package/dist/types/tests/httpClientErrorLog.test.d.ts.map +1 -0
  496. package/dist/types/tests/interactionAccountDescriptor.test.d.ts +2 -0
  497. package/dist/types/tests/interactionAccountDescriptor.test.d.ts.map +1 -0
  498. package/dist/types/tests/message.test.d.ts +2 -0
  499. package/dist/types/tests/message.test.d.ts.map +1 -0
  500. package/dist/types/tests/mt535parser.test.d.ts +2 -0
  501. package/dist/types/tests/mt535parser.test.d.ts.map +1 -0
  502. package/dist/types/tests/mt940parser.test.d.ts +2 -0
  503. package/dist/types/tests/mt940parser.test.d.ts.map +1 -0
  504. package/dist/types/tests/pain001Builder.test.d.ts +2 -0
  505. package/dist/types/tests/pain001Builder.test.d.ts.map +1 -0
  506. package/dist/types/tests/pain002Parser.test.d.ts +2 -0
  507. package/dist/types/tests/pain002Parser.test.d.ts.map +1 -0
  508. package/dist/types/tests/parser.test.d.ts +2 -0
  509. package/dist/types/tests/parser.test.d.ts.map +1 -0
  510. package/dist/types/tests/partedDialog.test.d.ts +2 -0
  511. package/dist/types/tests/partedDialog.test.d.ts.map +1 -0
  512. package/dist/types/tests/partedResponse.test.d.ts +2 -0
  513. package/dist/types/tests/partedResponse.test.d.ts.map +1 -0
  514. package/dist/types/tests/statementParseFailure.test.d.ts +2 -0
  515. package/dist/types/tests/statementParseFailure.test.d.ts.map +1 -0
  516. package/dist/types/tests/tanMedia.test.d.ts +2 -0
  517. package/dist/types/tests/tanMedia.test.d.ts.map +1 -0
  518. package/dist/types/unknownSegment.d.ts +15 -0
  519. package/dist/types/unknownSegment.d.ts.map +1 -0
  520. package/dist/types/upd.d.ts +8 -0
  521. package/dist/types/upd.d.ts.map +1 -0
  522. package/dist/unknownSegment.js +11 -0
  523. package/dist/upd.js +1 -0
  524. package/package.json +59 -5
  525. package/pnpm-workspace.yaml +8 -0
  526. package/src/accountBalance.ts +8 -0
  527. package/src/accountDescriptor.ts +78 -0
  528. package/src/bankAccount.ts +59 -0
  529. package/src/bankAnswer.ts +5 -0
  530. package/src/bankTransaction.ts +25 -0
  531. package/src/bankingInformation.ts +21 -0
  532. package/src/bpd.ts +17 -0
  533. package/src/camtParser.ts +698 -0
  534. package/src/client.ts +1005 -0
  535. package/src/codes.ts +86 -0
  536. package/src/config.ts +338 -0
  537. package/src/creditCardStatement.ts +26 -0
  538. package/src/dataElements/AlphaNumeric.ts +35 -0
  539. package/src/dataElements/Amount.ts +7 -0
  540. package/src/dataElements/Binary.ts +50 -0
  541. package/src/dataElements/Country.ts +7 -0
  542. package/src/dataElements/Currency.ts +7 -0
  543. package/src/dataElements/Dat.ts +22 -0
  544. package/src/dataElements/DataElement.ts +41 -0
  545. package/src/dataElements/Digits.ts +34 -0
  546. package/src/dataElements/Float.ts +31 -0
  547. package/src/dataElements/Identification.ts +7 -0
  548. package/src/dataElements/Numeric.ts +38 -0
  549. package/src/dataElements/Text.ts +31 -0
  550. package/src/dataElements/Time.ts +24 -0
  551. package/src/dataElements/YesNo.ts +23 -0
  552. package/src/dataGroups/Account.ts +31 -0
  553. package/src/dataGroups/Balance.ts +30 -0
  554. package/src/dataGroups/BankIdentification.ts +16 -0
  555. package/src/dataGroups/DataGroup.ts +76 -0
  556. package/src/dataGroups/InternationalAccount.ts +32 -0
  557. package/src/dataGroups/Money.ts +21 -0
  558. package/src/dataGroups/RefMessage.ts +21 -0
  559. package/src/dataGroups/SepaAccount.ts +32 -0
  560. package/src/dataGroups/TimeStamp.ts +21 -0
  561. package/src/decoder.ts +125 -0
  562. package/src/dialog.ts +625 -0
  563. package/src/electronicStatement.ts +51 -0
  564. package/src/encoder.ts +87 -0
  565. package/src/format.ts +7 -0
  566. package/src/httpClient.ts +90 -0
  567. package/src/index.ts +53 -0
  568. package/src/interactions/balanceInteraction.ts +65 -0
  569. package/src/interactions/creditTransferInteraction.ts +667 -0
  570. package/src/interactions/creditcardStatementInteraction.ts +134 -0
  571. package/src/interactions/creditcardStatementInteractionHKKKU.ts +163 -0
  572. package/src/interactions/customerInteraction.ts +191 -0
  573. package/src/interactions/electronicStatementInteraction.ts +132 -0
  574. package/src/interactions/endDialogInteraction.ts +28 -0
  575. package/src/interactions/initDialogInteraction.ts +300 -0
  576. package/src/interactions/portfolioInteraction.ts +97 -0
  577. package/src/interactions/sepaAccountInteraction.ts +68 -0
  578. package/src/interactions/statementInteractionCAMT.ts +87 -0
  579. package/src/interactions/statementInteractionMT940.ts +60 -0
  580. package/src/interactions/tanMediaInteraction.ts +54 -0
  581. package/src/interactions/transferOutcome.ts +513 -0
  582. package/src/interactions/vopCheck.ts +502 -0
  583. package/src/message.ts +305 -0
  584. package/src/mt535parser.ts +199 -0
  585. package/src/mt940parser.ts +395 -0
  586. package/src/pain001Builder.ts +446 -0
  587. package/src/pain002Parser.ts +233 -0
  588. package/src/parser.ts +31 -0
  589. package/src/partedSegment.ts +19 -0
  590. package/src/segment.ts +114 -0
  591. package/src/segmentDefinition.ts +36 -0
  592. package/src/segmentHeader.ts +26 -0
  593. package/src/segments/DIKKU.ts +30 -0
  594. package/src/segments/DKKKU.ts +35 -0
  595. package/src/segments/HIBPA.ts +42 -0
  596. package/src/segments/HICAZ.ts +34 -0
  597. package/src/segments/HICAZS.ts +33 -0
  598. package/src/segments/HICCSS.ts +31 -0
  599. package/src/segments/HIEKA.ts +68 -0
  600. package/src/segments/HIEKAS.ts +36 -0
  601. package/src/segments/HIKAZ.ts +23 -0
  602. package/src/segments/HIKAZS.ts +34 -0
  603. package/src/segments/HIKIM.ts +21 -0
  604. package/src/segments/HIKKU.ts +35 -0
  605. package/src/segments/HIKKUS.ts +36 -0
  606. package/src/segments/HIKOM.ts +49 -0
  607. package/src/segments/HIPINS.ts +48 -0
  608. package/src/segments/HIRMG.ts +41 -0
  609. package/src/segments/HIRMS.ts +35 -0
  610. package/src/segments/HISAL.ts +51 -0
  611. package/src/segments/HISPA.ts +20 -0
  612. package/src/segments/HISPAS.ts +42 -0
  613. package/src/segments/HISYN.ts +28 -0
  614. package/src/segments/HITAB.ts +76 -0
  615. package/src/segments/HITAN.ts +39 -0
  616. package/src/segments/HITANS.ts +102 -0
  617. package/src/segments/HIUPA.ts +32 -0
  618. package/src/segments/HIUPD.ts +82 -0
  619. package/src/segments/HIVPAS.ts +29 -0
  620. package/src/segments/HIVPP.ts +75 -0
  621. package/src/segments/HIVPPS.ts +47 -0
  622. package/src/segments/HIWPD.ts +25 -0
  623. package/src/segments/HKCAZ.ts +42 -0
  624. package/src/segments/HKCCS.ts +43 -0
  625. package/src/segments/HKEKA.ts +69 -0
  626. package/src/segments/HKEND.ts +20 -0
  627. package/src/segments/HKIDN.ts +31 -0
  628. package/src/segments/HKKAZ.ts +40 -0
  629. package/src/segments/HKKKU.ts +41 -0
  630. package/src/segments/HKSAL.ts +35 -0
  631. package/src/segments/HKSPA.ts +28 -0
  632. package/src/segments/HKSYN.ts +21 -0
  633. package/src/segments/HKTAB.ts +23 -0
  634. package/src/segments/HKTAN.ts +72 -0
  635. package/src/segments/HKVPA.ts +26 -0
  636. package/src/segments/HKVPP.ts +46 -0
  637. package/src/segments/HKVVB.ts +32 -0
  638. package/src/segments/HKWPD.ts +52 -0
  639. package/src/segments/HNHBK.ts +33 -0
  640. package/src/segments/HNHBS.ts +20 -0
  641. package/src/segments/HNSHA.ts +38 -0
  642. package/src/segments/HNSHK.ts +145 -0
  643. package/src/segments/HNVSD.ts +22 -0
  644. package/src/segments/HNVSK.ts +110 -0
  645. package/src/segments/businessTransactionParameter.ts +33 -0
  646. package/src/segments/registry.ts +125 -0
  647. package/src/statement.ts +40 -0
  648. package/src/tanMethod.ts +32 -0
  649. package/src/tests/HIBPA.test.ts +33 -0
  650. package/src/tests/HICAZS.test.ts +24 -0
  651. package/src/tests/HICCSS.test.ts +20 -0
  652. package/src/tests/HIPINS.test.ts +19 -0
  653. package/src/tests/HIRMG.test.ts +33 -0
  654. package/src/tests/HITAB.test.ts +33 -0
  655. package/src/tests/HITANS.test.ts +27 -0
  656. package/src/tests/HIUPA.test.ts +13 -0
  657. package/src/tests/HIUPD.test.ts +13 -0
  658. package/src/tests/HIVPAS.test.ts +20 -0
  659. package/src/tests/HIVPP.test.ts +75 -0
  660. package/src/tests/HIVPPS.test.ts +37 -0
  661. package/src/tests/HIWPD.test.ts +32 -0
  662. package/src/tests/HKCAZ.test.ts +56 -0
  663. package/src/tests/HKCCS.test.ts +64 -0
  664. package/src/tests/HKEKA.test.ts +252 -0
  665. package/src/tests/HKIDN.test.ts +26 -0
  666. package/src/tests/HKKKU.test.ts +248 -0
  667. package/src/tests/HKSAL.test.ts +52 -0
  668. package/src/tests/HKTAN.test.ts +26 -0
  669. package/src/tests/HKVPA.test.ts +25 -0
  670. package/src/tests/HKVPP.test.ts +54 -0
  671. package/src/tests/HKWPD.test.ts +47 -0
  672. package/src/tests/HNSHK.test.ts +14 -0
  673. package/src/tests/HNVSK.test.ts +14 -0
  674. package/src/tests/accountDescriptor.test.ts +113 -0
  675. package/src/tests/accountReference.test.ts +150 -0
  676. package/src/tests/bankReplyChecks.test.ts +75 -0
  677. package/src/tests/camtParser.test.ts +1068 -0
  678. package/src/tests/client.test.ts +826 -0
  679. package/src/tests/credentialRedaction.test.ts +75 -0
  680. package/src/tests/creditTransfer.test.ts +2433 -0
  681. package/src/tests/creditTransferBank.ts +245 -0
  682. package/src/tests/creditTransferSafety.test.ts +573 -0
  683. package/src/tests/datatypes.test.ts +9 -0
  684. package/src/tests/dialog.test.ts +579 -0
  685. package/src/tests/httpClientErrorLog.test.ts +41 -0
  686. package/src/tests/interactionAccountDescriptor.test.ts +203 -0
  687. package/src/tests/message.test.ts +130 -0
  688. package/src/tests/mt535parser.test.ts +280 -0
  689. package/src/tests/mt940parser.test.ts +91 -0
  690. package/src/tests/pain001Builder.test.ts +474 -0
  691. package/src/tests/pain002Parser.test.ts +191 -0
  692. package/src/tests/parser.test.ts +34 -0
  693. package/src/tests/partedDialog.test.ts +309 -0
  694. package/src/tests/partedResponse.test.ts +234 -0
  695. package/src/tests/statementParseFailure.test.ts +23 -0
  696. package/src/tests/tanMedia.test.ts +163 -0
  697. package/src/unknownSegment.ts +19 -0
  698. package/src/upd.ts +8 -0
  699. package/tsconfig.json +103 -0
@@ -0,0 +1,51 @@
1
+ import { HISPA } from '../segments/HISPA.js';
2
+ import { HKSPA } from '../segments/HKSPA.js';
3
+ import { CustomerOrderInteraction } from './customerInteraction.js';
4
+ export class SepaAccountInteraction extends CustomerOrderInteraction {
5
+ accounts;
6
+ maxEntries;
7
+ constructor(accounts, // optional: only these accounts
8
+ maxEntries) {
9
+ super(HKSPA.Id, HISPA.Id);
10
+ this.accounts = accounts;
11
+ this.maxEntries = maxEntries;
12
+ }
13
+ createSegments(init) {
14
+ if (!init.isTransactionSupported(this.segId)) {
15
+ throw Error(`Business transaction '${this.segId}' is not supported by this bank`);
16
+ }
17
+ const version = init.getMaxSupportedTransactionVersion(HKSPA.Id);
18
+ if (!version) {
19
+ throw Error(`There is no supported version for business transaction '${HKSPA.Id}'`);
20
+ }
21
+ const accounts = this.accounts?.map((account) => init.getBankAccount(account));
22
+ const hkspa = {
23
+ header: { segId: HKSPA.Id, segNr: 0, version: version },
24
+ accounts: accounts,
25
+ maxEntries: this.maxEntries,
26
+ };
27
+ return [hkspa];
28
+ }
29
+ handleResponse(response, clientResponse) {
30
+ // A response the bank spread over several messages arrives as several HISPA
31
+ // segments, each carrying its own share of the accounts.
32
+ const hispaSegments = response.findAllSegments(HISPA.Id);
33
+ if (hispaSegments.length > 0) {
34
+ clientResponse.sepaAccounts = hispaSegments.flatMap((segment) => segment.sepaAccounts ?? []);
35
+ this.dialog?.config.bankingInformation.upd?.bankAccounts.forEach((bankAccount) => {
36
+ bankAccount.isSepaAccount = false;
37
+ });
38
+ clientResponse.sepaAccounts.forEach((sepaAccount) => {
39
+ // Matched, not resolved: this is the bank listing its own accounts, and at an
40
+ // institution where two of them share a number, demanding an unambiguous
41
+ // answer here would fail every dialog before it reached its order.
42
+ const bankAccount = this.dialog?.config.matchBankAccount(sepaAccount);
43
+ if (bankAccount && !bankAccount.isSepaAccount) {
44
+ bankAccount.isSepaAccount = sepaAccount.isSepaAccount;
45
+ bankAccount.iban = sepaAccount.iban;
46
+ bankAccount.bic = sepaAccount.bic;
47
+ }
48
+ });
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,71 @@
1
+ import { internationalAccount } from '../accountDescriptor.js';
2
+ import { CamtParser } from '../camtParser.js';
3
+ import { HICAZ } from '../segments/HICAZ.js';
4
+ import { HKCAZ } from '../segments/HKCAZ.js';
5
+ import { CustomerOrderInteraction } from './customerInteraction.js';
6
+ export class StatementInteractionCAMT extends CustomerOrderInteraction {
7
+ account;
8
+ from;
9
+ to;
10
+ constructor(account, from, to) {
11
+ super(HKCAZ.Id, HICAZ.Id);
12
+ this.account = account;
13
+ this.from = from;
14
+ this.to = to;
15
+ }
16
+ createSegments(init) {
17
+ const bankAccount = init.getBankAccount(this.account);
18
+ const version = init.getMaxSupportedTransactionVersion(HKCAZ.Id);
19
+ if (!version) {
20
+ throw Error(`There is no supported version for business transaction '${HKCAZ.Id}'`);
21
+ }
22
+ let acceptedCamtFormats = ['urn:iso:std:iso:20022:tech:xsd:camt.052.001.08'];
23
+ const params = init.getTransactionParameters(HKCAZ.Id);
24
+ if (params && params.supportedCamtFormats.length > 0) {
25
+ acceptedCamtFormats = params.supportedCamtFormats.filter((format) => format.startsWith('urn:iso:std:iso:20022:tech:xsd:camt.052.001.'));
26
+ }
27
+ const hkcaz = {
28
+ header: { segId: HKCAZ.Id, segNr: 0, version: version },
29
+ account: internationalAccount(init, bankAccount),
30
+ acceptedCamtFormats: acceptedCamtFormats,
31
+ allAccounts: false,
32
+ from: this.from,
33
+ to: this.to,
34
+ };
35
+ return [hkcaz];
36
+ }
37
+ handleResponse(response, clientResponse) {
38
+ // A response the bank spread over several messages arrives as several HICAZ
39
+ // segments, each carrying its own share of the CAMT documents. Taking only the
40
+ // first one would silently drop everything after it.
41
+ const camtMessages = response
42
+ .findAllSegments(HICAZ.Id)
43
+ .flatMap((segment) => segment.bookedTransactions ?? []);
44
+ if (camtMessages.length > 0) {
45
+ // A parse failure is thrown: an empty result would look like an account
46
+ // without transactions.
47
+ // Parse all CAMT messages (one per booking day) and combine statements
48
+ const allStatements = [];
49
+ for (const camtMessage of camtMessages) {
50
+ // The regex looks for the XML declaration `<?xml ... ?>`
51
+ // and checks if it contains the attribute encoding="UTF-8".
52
+ // The 'i' flag makes the match case-insensitive (e.g., for "utf-8").
53
+ const isUtf8Encoded = /<\?xml[^>]*encoding="UTF-8"[^>]*\?>/i.test(camtMessage);
54
+ let xmlString = camtMessage;
55
+ if (isUtf8Encoded) {
56
+ // camtMessage is initially encoded as 'latin1' (ISO-8859-1), but actually contains UTF-8 data.
57
+ // Therefore, we need to first convert it back to a buffer using 'latin1', and then decode it as 'utf8'.
58
+ const intermediateBuffer = Buffer.from(camtMessage, 'latin1');
59
+ xmlString = intermediateBuffer.toString('utf8');
60
+ }
61
+ const parser = new CamtParser(xmlString);
62
+ const statements = parser.parse();
63
+ allStatements.push(...statements);
64
+ }
65
+ clientResponse.statements = allStatements;
66
+ }
67
+ else {
68
+ clientResponse.statements = [];
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,50 @@
1
+ import { internationalAccount, nationalAccount } from '../accountDescriptor.js';
2
+ import { Mt940Parser } from '../mt940parser.js';
3
+ import { HIKAZ } from '../segments/HIKAZ.js';
4
+ import { HKKAZ } from '../segments/HKKAZ.js';
5
+ import { CustomerOrderInteraction } from './customerInteraction.js';
6
+ export class StatementInteractionMT940 extends CustomerOrderInteraction {
7
+ account;
8
+ from;
9
+ to;
10
+ constructor(account, from, to) {
11
+ super(HKKAZ.Id, HIKAZ.Id);
12
+ this.account = account;
13
+ this.from = from;
14
+ this.to = to;
15
+ }
16
+ createSegments(init) {
17
+ const bankAccount = init.getBankAccount(this.account);
18
+ const version = init.getMaxSupportedTransactionVersion(HKKAZ.Id);
19
+ if (!version) {
20
+ throw Error(`There is no supported version for business transaction '${HKKAZ.Id}'`);
21
+ }
22
+ const account = version <= 6 ? nationalAccount(bankAccount) : internationalAccount(init, bankAccount);
23
+ const hkkaz = {
24
+ header: { segId: HKKAZ.Id, segNr: 0, version: version },
25
+ account: account,
26
+ allAccounts: false,
27
+ from: this.from,
28
+ to: this.to,
29
+ };
30
+ return [hkkaz];
31
+ }
32
+ handleResponse(response, clientResponse) {
33
+ // A response the bank spread over several messages arrives as several HIKAZ
34
+ // segments. Unlike CAMT these carry one continuous MT940 stream, so their
35
+ // payloads are joined rather than listed.
36
+ const bookedTransactions = response
37
+ .findAllSegments(HIKAZ.Id)
38
+ .map((segment) => segment.bookedTransactions)
39
+ .filter((booked) => !!booked)
40
+ .join('');
41
+ if (bookedTransactions) {
42
+ // A parse failure is thrown: an empty result would look like an account
43
+ // without transactions.
44
+ clientResponse.statements = new Mt940Parser(bookedTransactions).parse();
45
+ }
46
+ else {
47
+ clientResponse.statements = [];
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,37 @@
1
+ // Changed from lib-fints 1.5.4 for @davidvornholt/lib-fints, last on 2026-12-05. FORK.md lists the changes.
2
+ import { TanMediaClass, TanMediaType, TanStatus } from '../codes.js';
3
+ import { HITAB } from '../segments/HITAB.js';
4
+ import { HKTAB } from '../segments/HKTAB.js';
5
+ import { CustomerOrderInteraction } from './customerInteraction.js';
6
+ export class TanMediaInteraction extends CustomerOrderInteraction {
7
+ constructor() {
8
+ super(HKTAB.Id, HITAB.Id);
9
+ }
10
+ createSegments(init) {
11
+ const version = init.getMaxSupportedTransactionVersion(HKTAB.Id);
12
+ if (!version) {
13
+ throw Error(`There is no supported version for business transaction '${HKTAB.Id}`);
14
+ }
15
+ const hktab = {
16
+ header: { segId: HKTAB.Id, segNr: 0, version: version },
17
+ // All media, because a Sparkasse refuses a request for only the active ones (as
18
+ // HBCI4Java notes), so the active ones are picked from the answer
19
+ mediaType: TanMediaType.All,
20
+ mediaClass: TanMediaClass.All,
21
+ };
22
+ return [hktab];
23
+ }
24
+ handleResponse(response, clientResponse) {
25
+ const hitab = response.findSegment(HITAB.Id);
26
+ if (hitab) {
27
+ clientResponse.tanMediaList = (hitab.mediaList ?? [])
28
+ .filter((media) => media.status === TanStatus.Active || media.status === TanStatus.ActiveFollowUpCard)
29
+ .map((media) => media.name)
30
+ .filter((name) => name);
31
+ const tanMethod = this.dialog?.config.selectedTanMethod;
32
+ if (tanMethod) {
33
+ tanMethod.activeTanMedia = clientResponse.tanMediaList;
34
+ }
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,364 @@
1
+ // Added to lib-fints 1.5.4 for @davidvornholt/lib-fints, last on 2026-11-18. FORK.md lists the changes.
2
+ import { TanProcess } from '../codes.js';
3
+ import { HIRMG } from '../segments/HIRMG.js';
4
+ import { HIRMS } from '../segments/HIRMS.js';
5
+ import { HKCCS } from '../segments/HKCCS.js';
6
+ import { HKTAN } from '../segments/HKTAN.js';
7
+ import { HKVPA } from '../segments/HKVPA.js';
8
+ import { HKVPP } from '../segments/HKVPP.js';
9
+ import { HNHBK } from '../segments/HNHBK.js';
10
+ const NOT_EXECUTED = 'The transfer was not executed.';
11
+ const CHECK_ACCOUNT = 'Check the account before sending the transfer again.';
12
+ /** 0010: received ("entgegengenommen", not legally binding); 0020: executed (DK return codes B.1) */
13
+ const RECEIVED = 10;
14
+ const EXECUTED = 20;
15
+ /** 0030: received, the bank waits for its approval */
16
+ const AWAITING_APPROVAL = 30;
17
+ /** The bank processes the order under the reference it gives */
18
+ const PROCESSING = 3070;
19
+ /** 3076: no strong authentication needed; 3091: no HKVPA needed (DK VoP E.8.1 rule 2) */
20
+ const SCA_WAIVED = 3076;
21
+ const VOP_WAIVED = 3091;
22
+ /** The approval was voided (3945) or cannot be given in the app (3958) */
23
+ const APPROVAL_VOIDED = 3945;
24
+ const APPROVAL_UNSUPPORTED = 3958;
25
+ /** A decoupled approval is under way (3955) or still outstanding (3956) */
26
+ const APPROVAL_PENDING = [3955, 3956];
27
+ /** The bank is not done with the order: 3040 more to come, 3093 the check is still running */
28
+ const PENDING = [3040, 3093];
29
+ /** 9000: the status of the order is indifferent */
30
+ const STATUS_INDIFFERENT = 9000;
31
+ /** The order was submitted twice (DK return codes B.4) */
32
+ const DUPLICATE = 9390;
33
+ /** "Auftrag existiert nicht bzw. wurde bereits ausgeführt" to HKVPA (DK VoP C.10.7.1.2) */
34
+ const ORDER_UNKNOWN_OR_EXECUTED = 9210;
35
+ const ROLES = {
36
+ [HKCCS.Id]: 'payment',
37
+ [HKVPP.Id]: 'check',
38
+ [HKVPA.Id]: 'authorization',
39
+ };
40
+ /**
41
+ * Every message of one transfer and every bank answer to it, and the one place that
42
+ * decides what became of the transfer and whether its payment may go out again.
43
+ *
44
+ * The ledger keeps each outgoing message by number with what each of its segments is,
45
+ * and reads every answer against the message it references (HNHBK), else the latest.
46
+ * Only answers to the payment count for it: to HKCCS in a message that carries it,
47
+ * otherwise to HKVPA and the HKTAN for HKCCS, which stand for it (FinTS PIN/TAN B.4.2.1).
48
+ * A poll and its HKTAN are read-only.
49
+ *
50
+ * The decision is fixed:
51
+ * 1. Execution of the payment (0020 to it, or 3091 with 3076 in the answer to the order)
52
+ * means executed; if the same answer contradicts it, uncertain.
53
+ * 2. An error ends the transfer: uncertain while anything allows that the bank executes
54
+ * the payment (a receipt, 3070, a hold, an open approval, an authorisation sent, the
55
+ * waiver pair, a duplicate, an HKVPA rejection that admits execution) or with 9000,
56
+ * otherwise not executed. Only a rejection of the payment itself undoes a receipt.
57
+ * 3. A receipt alone is not an execution: without a continuation, uncertain.
58
+ * 4. A confirmation that would send the payment again while the bank may still execute
59
+ * the one it has means uncertain.
60
+ *
61
+ * The guard: the payment (HKCCS) goes out once, and again only as the DK continuation
62
+ * (HKVPA with HKCCS) the caller confirmed, once, while nothing the bank has can execute.
63
+ */
64
+ export class TransferEvidence {
65
+ sent = [];
66
+ current;
67
+ submissions = 0;
68
+ continuations = 0;
69
+ /** Whether the decision offered a confirmation that has not been sent yet */
70
+ offered = false;
71
+ /** Why the guard refused to send the payment again, once it has */
72
+ refused;
73
+ executed = false;
74
+ /** The receipt of the payment, 0010 or 0030 */
75
+ received;
76
+ /** The reference of 3070, possibly empty */
77
+ processing;
78
+ /** Whether the bank holds the order for an authorisation by HKVPA alone */
79
+ held = false;
80
+ /** Whether the bank waits for an approval the user may give outside the dialog */
81
+ approvalOpen = false;
82
+ /** Whether a TAN or an authorisation for the payment has been sent and not refused */
83
+ authorized = false;
84
+ waivers = new Set();
85
+ /** 3091 and 3076 across the answers of a check, though not in one answer */
86
+ waived = false;
87
+ duplicate = false;
88
+ /** The bank rejected HKVPA in a way that admits the order may have executed */
89
+ maybeExecutedBefore = false;
90
+ /**
91
+ * Takes in a message right before it goes out. A payment the guard does not allow is
92
+ * refused here, so that no path, a resend of a parted answer included, sends it.
93
+ * @throws Error when the message would send the payment again
94
+ */
95
+ send(message) {
96
+ const segments = message.segments;
97
+ const has = (segId) => segments.some((segment) => segment.header.segId === segId);
98
+ const hktan = segments.find((segment) => segment.header.segId === HKTAN.Id);
99
+ const kind = has(HKCCS.Id)
100
+ ? has(HKVPA.Id)
101
+ ? 'continuation'
102
+ : 'submission'
103
+ : hktan?.tanProcess === TanProcess.Process2
104
+ ? 'approval'
105
+ : hktan?.tanProcess === TanProcess.Status
106
+ ? 'statusQuery'
107
+ : has(HKVPP.Id)
108
+ ? 'poll'
109
+ : has(HKVPA.Id)
110
+ ? 'authorization'
111
+ : 'other';
112
+ if (kind === 'submission' || kind === 'continuation') {
113
+ this.admit(kind);
114
+ }
115
+ this.sent.push({
116
+ msgNr: message.findSegment(HNHBK.Id)?.msgNr ?? 0,
117
+ kind,
118
+ // Numbered by position, as CustomerMessage.encode() numbers them
119
+ segments: new Map(segments.map((segment, index) => [
120
+ index + 1,
121
+ { segId: segment.header.segId, role: roleOf(segment) },
122
+ ])),
123
+ });
124
+ if (kind === 'approval' || (kind !== 'continuation' && has(HKVPA.Id))) {
125
+ this.authorized = true;
126
+ }
127
+ }
128
+ admit(kind) {
129
+ const continuation = kind === 'continuation' &&
130
+ this.continuations === 0 &&
131
+ this.offered &&
132
+ !this.held &&
133
+ this.blocking() === undefined;
134
+ if (this.submissions > 0 && !continuation) {
135
+ this.refused =
136
+ 'The transfer would have sent its payment to the bank again, which may still execute the first one.';
137
+ throw new Error(this.refused);
138
+ }
139
+ if (kind === 'continuation') {
140
+ this.continuations++;
141
+ this.waivers.clear();
142
+ }
143
+ this.submissions++;
144
+ this.offered = false;
145
+ }
146
+ /**
147
+ * Takes in the bank's answer to a message of the transfer, before anything branches on it
148
+ * @param tanRequested whether the bank asked for a TAN
149
+ * @param unreadable why the answer could not be read, such as a TAN request without HITAN
150
+ * @param externalApproval whether the TAN method is approved outside the dialog (decoupled)
151
+ */
152
+ record(message, { tanRequested, unreadable, externalApproval, }) {
153
+ const reference = message.findSegment(HNHBK.Id)?.refMsg?.msgNr;
154
+ const sent = this.sent.find((entry) => entry.msgNr === reference) ?? this.sent.at(-1);
155
+ const kind = sent?.kind ?? 'other';
156
+ const answers = [
157
+ ...message
158
+ .findAllSegments(HIRMG.Id)
159
+ .flatMap((hirmg) => hirmg.answers.map((a) => ({ ...a, role: 'message' }))),
160
+ ...message.findAllSegments(HIRMS.Id).flatMap((hirms) => {
161
+ const segment = sent?.segments.get(hirms.header.refSegNr ?? 0);
162
+ return hirms.answers.map((a) => ({
163
+ ...a,
164
+ role: segment?.role ?? 'message',
165
+ segId: segment?.segId,
166
+ }));
167
+ }),
168
+ ];
169
+ const codes = answers.map((answer) => answer.code);
170
+ const carriesPayment = kind === 'submission' || kind === 'continuation';
171
+ const payment = answers.filter((answer) => carriesPayment
172
+ ? answer.role === 'payment'
173
+ : answer.role === 'authorization' || answer.role === 'tan');
174
+ const paymentHas = (code) => payment.some((answer) => answer.code === code);
175
+ const errorTo = (role) => answers.filter((answer) => answer.role === role && answer.code >= STATUS_INDIFFERENT);
176
+ if (paymentHas(EXECUTED) ||
177
+ (carriesPayment && codes.includes(VOP_WAIVED) && codes.includes(SCA_WAIVED))) {
178
+ this.executed = true;
179
+ }
180
+ if (carriesPayment || kind === 'poll') {
181
+ for (const code of [VOP_WAIVED, SCA_WAIVED].filter((code) => codes.includes(code))) {
182
+ this.waivers.add(code);
183
+ }
184
+ this.waived ||= !this.executed && this.waivers.size === 2;
185
+ }
186
+ if (paymentHas(DUPLICATE) && (kind === 'continuation' || this.received !== undefined)) {
187
+ this.duplicate = true;
188
+ }
189
+ const receipt = payment.find((answer) => answer.code === RECEIVED ||
190
+ (answer.code === AWAITING_APPROVAL && answer.role === 'payment'));
191
+ const processing = payment.find((answer) => answer.code === PROCESSING);
192
+ const rejected = carriesPayment && payment.some((answer) => answer.code >= STATUS_INDIFFERENT);
193
+ if (rejected && !receipt && !processing && !paymentHas(DUPLICATE)) {
194
+ // The bank refused the order it was sent: nothing of it can execute
195
+ this.received = undefined;
196
+ this.processing = undefined;
197
+ this.held = false;
198
+ this.approvalOpen = false;
199
+ this.authorized = false;
200
+ }
201
+ this.received = receipt?.code ?? this.received;
202
+ this.processing = processing ? (processing.params?.[0] ?? '') : this.processing;
203
+ for (const answer of errorTo('authorization')) {
204
+ if (answer.code === ORDER_UNKNOWN_OR_EXECUTED || /ausgef|executed/i.test(answer.text)) {
205
+ this.maybeExecutedBefore = true;
206
+ }
207
+ this.authorized = false;
208
+ }
209
+ if (tanRequested &&
210
+ (externalApproval || APPROVAL_PENDING.some((code) => codes.includes(code)))) {
211
+ this.approvalOpen = true;
212
+ }
213
+ // A failed status query says nothing about the approval; a refused TAN closes it
214
+ if (codes.includes(APPROVAL_VOIDED) ||
215
+ codes.includes(APPROVAL_UNSUPPORTED) ||
216
+ (kind === 'approval' && errorTo('tan').length)) {
217
+ this.approvalOpen = false;
218
+ this.authorized = false;
219
+ }
220
+ if (codes.includes(APPROVAL_VOIDED)) {
221
+ this.held = false;
222
+ }
223
+ this.current = {
224
+ codes,
225
+ touchdownPoint: answers.find((answer) => answer.code === PENDING[0] && answer.segId === HKVPP.Id)
226
+ ?.params?.[0] || undefined,
227
+ unreadable,
228
+ rejected,
229
+ contradicts: !!unreadable ||
230
+ tanRequested ||
231
+ codes.some((code) => code >= STATUS_INDIFFERENT ||
232
+ code === APPROVAL_VOIDED ||
233
+ code === APPROVAL_UNSUPPORTED ||
234
+ APPROVAL_PENDING.includes(code) ||
235
+ PENDING.includes(code)),
236
+ };
237
+ }
238
+ /**
239
+ * The touchdown point of the latest answer for the rest of the payee check: that of
240
+ * code 3040 to HKVPP, not to any other segment
241
+ */
242
+ get touchdownPoint() {
243
+ return this.current?.touchdownPoint;
244
+ }
245
+ /** The bank holds the order for an authorisation by HKVPA alone (3076 after a match) */
246
+ hold() {
247
+ this.held = true;
248
+ }
249
+ /**
250
+ * Whether the answers so far allow that the bank executes the payment, so that a step
251
+ * that got no answer leaves the outcome uncertain
252
+ */
253
+ mayHaveExecuted() {
254
+ return this.executed || this.allowance(false) !== undefined;
255
+ }
256
+ /**
257
+ * Why the transfer stops after a step that got no answer, such as polling that took too
258
+ * long or a lost connection, and whether the bank may execute it all the same
259
+ */
260
+ giveUp(reason, uncertain = false) {
261
+ const outcome = this.decide({ stop: reason, uncertain }, false);
262
+ return outcome.status === 'failed' ? outcome : { reason, uncertain: true };
263
+ }
264
+ /**
265
+ * Decides what became of the transfer after the latest answer recorded, or, with
266
+ * `answered` false, after a step that got no answer
267
+ */
268
+ decide(proposal, answered = true) {
269
+ const current = answered ? this.current : undefined;
270
+ const codes = current?.codes ?? [];
271
+ if (this.executed) {
272
+ return current?.contradicts
273
+ ? failed(`The bank reported the transfer as executed, but its other answers contradict that; see bankAnswers. ${CHECK_ACCOUNT}`, true)
274
+ : { status: 'accepted' };
275
+ }
276
+ const reason = current?.unreadable ??
277
+ (current?.rejected
278
+ ? 'The bank rejected the order, see bankAnswers.'
279
+ : codes.some((code) => code >= STATUS_INDIFFERENT)
280
+ ? 'The bank answered with an error, see bankAnswers.'
281
+ : typeof proposal === 'object'
282
+ ? proposal.stop
283
+ : undefined);
284
+ const allowance = this.allowance(true);
285
+ if (reason !== undefined) {
286
+ if (codes.includes(STATUS_INDIFFERENT)) {
287
+ return failed(`The bank did not say whether it executed the transfer (9000) and may have executed it. ${CHECK_ACCOUNT}`, true);
288
+ }
289
+ if (allowance) {
290
+ return failed(`${reason} The bank ${allowance} and may execute it. ${CHECK_ACCOUNT}`, true);
291
+ }
292
+ if (typeof proposal === 'object' && proposal.uncertain && reason === proposal.stop) {
293
+ return failed(`${reason} ${CHECK_ACCOUNT}`, true);
294
+ }
295
+ return failed(`${reason} ${NOT_EXECUTED}`, false);
296
+ }
297
+ if (proposal === 'none') {
298
+ return failed(allowance
299
+ ? `The bank ${allowance}, but did not confirm that it executed it. ${CHECK_ACCOUNT}`
300
+ : `The bank did not confirm the outcome of the transfer and may have executed it. ${CHECK_ACCOUNT}`, true);
301
+ }
302
+ if (proposal === 'confirmation') {
303
+ const blocking = this.blocking();
304
+ if (blocking) {
305
+ // A confirmation would send the order again while the bank may execute it
306
+ return failed(`The bank ${blocking} and did not confirm its outcome; it may execute it. ${CHECK_ACCOUNT}`, true);
307
+ }
308
+ this.offered = true;
309
+ }
310
+ return { status: proposal };
311
+ }
312
+ /**
313
+ * What the bank has of the payment that can still execute, a reason against sending it
314
+ * again, if anything
315
+ */
316
+ blocking() {
317
+ if (this.executed) {
318
+ return 'reported the transfer as executed';
319
+ }
320
+ if (this.continuations > 0) {
321
+ return 'has been sent the transfer again after the payee check already';
322
+ }
323
+ return this.allowance(true, true);
324
+ }
325
+ /**
326
+ * What allows that the bank executes the payment, for the failure reason, if anything
327
+ * does
328
+ * @param sentAuthorization whether an authorisation sent counts, not only the answers
329
+ * @param exceptHeld leave out what the DK continuation is for: a receipt, and an order
330
+ * the bank holds for HKVPA alone, which the confirmation authorises without the order
331
+ */
332
+ allowance(sentAuthorization, exceptHeld = false) {
333
+ const reasons = [
334
+ [
335
+ this.processing !== undefined,
336
+ `processes the transfer under the reference ${this.processing || '(none given)'} (3070)`,
337
+ ],
338
+ [this.duplicate, 'reported a duplicate submission of the transfer (9390)'],
339
+ [
340
+ this.maybeExecutedBefore,
341
+ 'answered the authorisation saying the order may have been executed already',
342
+ ],
343
+ [this.approvalOpen, 'waits for an approval of the transfer that may still be given'],
344
+ [this.waived, 'waived the payee check and the strong authentication (3091, 3076)'],
345
+ [sentAuthorization && this.authorized, 'was sent the authorisation of the transfer'],
346
+ [!exceptHeld && this.held, 'holds the transfer for its authorisation'],
347
+ [
348
+ !exceptHeld && this.received !== undefined,
349
+ `received the transfer (${String(this.received).padStart(4, '0')})`,
350
+ ],
351
+ ];
352
+ return reasons.find(([applies]) => applies)?.[1];
353
+ }
354
+ }
355
+ function roleOf(segment) {
356
+ if (segment.header.segId === HKTAN.Id) {
357
+ // The HKTAN for a poll authorises the poll, not the payment
358
+ return segment.segId === HKVPP.Id ? 'check' : 'tan';
359
+ }
360
+ return ROLES[segment.header.segId] ?? 'message';
361
+ }
362
+ function failed(reason, uncertain) {
363
+ return { status: 'failed', reason, uncertain };
364
+ }