@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
package/src/client.ts ADDED
@@ -0,0 +1,1005 @@
1
+ // Changed from lib-fints 1.5.4 for @davidvornholt/lib-fints, last on 2026-12-05. FORK.md lists the changes.
2
+ import { internationalAccount } from './accountDescriptor.js';
3
+ import { type AccountRef, describeAccount } from './bankAccount.js';
4
+ import { UpdUsage } from './codes.js';
5
+ import { FinTSConfig } from './config.js';
6
+ import { canSendTanSegment, Dialog } from './dialog.js';
7
+ import {
8
+ type AccountBalanceResponse,
9
+ BalanceInteraction,
10
+ } from './interactions/balanceInteraction.js';
11
+ import { CreditCardStatementInteraction } from './interactions/creditcardStatementInteraction.js';
12
+ import { CreditCardStatementInteractionHKKKU } from './interactions/creditcardStatementInteractionHKKKU.js';
13
+ import {
14
+ CreditTransferInteraction,
15
+ CreditTransferOrder,
16
+ type PreparedTransfer,
17
+ type TransferResponse,
18
+ VopAuthorizationInteraction,
19
+ type VopParameters,
20
+ VopPollInteraction,
21
+ } from './interactions/creditTransferInteraction.js';
22
+ import type {
23
+ ClientResponse,
24
+ CustomerOrderInteraction,
25
+ StatementResponse,
26
+ } from './interactions/customerInteraction.js';
27
+ import {
28
+ ElectronicStatementInteraction,
29
+ type ElectronicStatementOptions,
30
+ type ElectronicStatementResponse,
31
+ } from './interactions/electronicStatementInteraction.js';
32
+ import type { InitResponse } from './interactions/initDialogInteraction.js';
33
+ import {
34
+ PortfolioInteraction,
35
+ type PortfolioResponse,
36
+ } from './interactions/portfolioInteraction.js';
37
+ import { StatementInteractionCAMT } from './interactions/statementInteractionCAMT.js';
38
+ import { StatementInteractionMT940 } from './interactions/statementInteractionMT940.js';
39
+ import { TanMediaInteraction, type TanMediaResponse } from './interactions/tanMediaInteraction.js';
40
+ import { buildPain001, type CreditTransfer, selectPain001Format } from './pain001Builder.js';
41
+ import { DKKKU } from './segments/DKKKU.js';
42
+ import type { HISPASParameter } from './segments/HISPAS.js';
43
+ import type { HIVPPSParameter } from './segments/HIVPPS.js';
44
+ import { HKCAZ } from './segments/HKCAZ.js';
45
+ import { HKCCS } from './segments/HKCCS.js';
46
+ import { HKEKA } from './segments/HKEKA.js';
47
+ import { HKIDN } from './segments/HKIDN.js';
48
+ import { HKKAZ } from './segments/HKKAZ.js';
49
+ import { HKKKU } from './segments/HKKKU.js';
50
+ import { HKSAL } from './segments/HKSAL.js';
51
+ import { HKSPA } from './segments/HKSPA.js';
52
+ import { HKTAB } from './segments/HKTAB.js';
53
+ import { HKVPA } from './segments/HKVPA.js';
54
+ import { HKVPP } from './segments/HKVPP.js';
55
+ import { HKWPD } from './segments/HKWPD.js';
56
+ import type { TanMethod } from './tanMethod.js';
57
+
58
+ export interface SynchronizeResponse extends InitResponse {}
59
+
60
+ /** How long the bank may take for a Verification of Payee result, counting the waits between polls */
61
+ const VOP_TIMEOUT_SECONDS = 60;
62
+ /** The wait between polls when the bank names none (python-fints uses the same) */
63
+ const VOP_DEFAULT_WAIT_SECONDS = 2;
64
+ /** The format the DK VoP specification names, for a bank whose HIVPPS lists none */
65
+ const VOP_DEFAULT_REPORT_FORMAT = 'urn:iso:std:iso:20022:tech:xsd:pain.002.001.10';
66
+
67
+ type PendingTransfer = {
68
+ order: CreditTransferOrder;
69
+ dialog: Dialog;
70
+ /**
71
+ * The reference of the challenge the transfer waits for, if it waits for a TAN, as the
72
+ * bank sent it: the response handed to the caller may be changed, this is not
73
+ */
74
+ tanReference?: string;
75
+ /** The TAN method the challenge was issued for */
76
+ tanMethodId?: number;
77
+ /** Whether a step of the transfer has been sent and its answer is not handled yet */
78
+ inFlight: boolean;
79
+ };
80
+
81
+ const STEP_IN_FLIGHT =
82
+ 'the transfer is still waiting for the answer to its previous step; wait for that response';
83
+
84
+ /**
85
+ * A client to communicate with a bank over the FinTS protocol
86
+ */
87
+ export class FinTSClient {
88
+ private currentDialog: Dialog | undefined;
89
+ private currentTransfer: PendingTransfer | undefined;
90
+
91
+ /**
92
+ * Creates a new FinTS client
93
+ * @param config - the configuration for the client, use the static factory methods FinTSConfig.forFirstTimeUse or FinTSConfig.fromBankingInformation to create a configuration
94
+ */
95
+ constructor(public config: FinTSConfig) {
96
+ if (!config) {
97
+ throw new Error('configuration must be provided when creating a FinTSClient');
98
+ }
99
+
100
+ if (!(config instanceof FinTSConfig)) {
101
+ throw new Error('configuration must be an instance of class FinTSConfig');
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Selects a TAN method by its ID
107
+ * @param tanMethodId - the ID of the TAN method to select, get the ID from FinTSClient.config.availableTanMethods
108
+ * @returns the selected TAN method
109
+ */
110
+ selectTanMethod(tanMethodId: number): TanMethod {
111
+ return this.config.selectTanMethod(tanMethodId);
112
+ }
113
+
114
+ /**
115
+ * Selects a TAN media by its name
116
+ * @param tanMediaName - the name of the TAN media to select corresponding to a name in TanMethod.activeTanMedia
117
+ */
118
+ selectTanMedia(tanMediaName: string): void {
119
+ this.config.selectTanMedia(tanMediaName);
120
+ }
121
+
122
+ /**
123
+ * Fetches the names of the user's active TAN media (HKTAB), such as the device a pushTAN
124
+ * app runs on, so that one can be chosen with selectTanMedia().
125
+ *
126
+ * The dialog's initialisation refers to HKTAB in its HKTAN instead of to HKIDN, as FinTS
127
+ * PIN/TAN chapter B.4.3.1 prescribes for PIN/TAN management orders, and the bank ignores
128
+ * the TAN media name there. This works before the client knows a TAN media name, which a
129
+ * TAN method that requires one would otherwise need for the dialog initialisation.
130
+ * @returns the TAN media response, with the names in tanMediaList
131
+ */
132
+ async getTanMedia(): Promise<TanMediaResponse> {
133
+ return (await this.startCustomerOrderInteraction(
134
+ new TanMediaInteraction(),
135
+ HKTAB.Id,
136
+ )) as TanMediaResponse;
137
+ }
138
+
139
+ /**
140
+ * Synchronizes information with the bank, updating config.bankingInformation
141
+ * @returns the synchronization response
142
+ */
143
+ async synchronize(): Promise<SynchronizeResponse> {
144
+ this.currentDialog = new Dialog(this.config, true);
145
+ const responses = await this.currentDialog.start();
146
+ return responses.get(HKIDN.Id) as SynchronizeResponse;
147
+ }
148
+
149
+ /**
150
+ * Continues the synchronization transaction when a TAN is required
151
+ * @param tanReference The TAN reference provided in the first call's response
152
+ * @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
153
+ * @returns the synchronization response
154
+ */
155
+ async synchronizeWithTan(tanReference: string, tan?: string): Promise<SynchronizeResponse> {
156
+ return await this.continueCustomerInteractionWithTan([HKIDN.Id], tanReference, tan);
157
+ }
158
+
159
+ /**
160
+ * Checks if the bank supports fetching an account balance in general or for the given account number when provided
161
+ * @param account when the account number is provided, checks if the account supports fetching the balance
162
+ * @returns true if the bank (and account) supports fetching the account balance
163
+ */
164
+ canGetAccountBalance(account?: AccountRef): boolean {
165
+ return account
166
+ ? this.config.isAccountTransactionSupported(account, HKSAL.Id)
167
+ : this.config.isTransactionSupported(HKSAL.Id);
168
+ }
169
+
170
+ /**
171
+ * Fetches the account balance for the given account number
172
+ * @param account - the account number to fetch the balance for, must be an account available in the config.baningInformation.UPD.accounts
173
+ * @returns the account balance response
174
+ */
175
+ async getAccountBalance(account: AccountRef): Promise<AccountBalanceResponse> {
176
+ const response = await this.startCustomerOrderInteraction(new BalanceInteraction(account));
177
+ return response as AccountBalanceResponse;
178
+ }
179
+
180
+ /**
181
+ * Continues the account balance fetching when a TAN is required
182
+ * @param tanReference The TAN reference provided in the first call's response
183
+ * @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
184
+ * @returns the account balance response
185
+ */
186
+ async getAccountBalanceWithTan(
187
+ tanReference: string,
188
+ tan?: string,
189
+ ): Promise<AccountBalanceResponse> {
190
+ return (await this.continueCustomerInteractionWithTan(
191
+ [HKSAL.Id],
192
+ tanReference,
193
+ tan,
194
+ )) as AccountBalanceResponse;
195
+ }
196
+
197
+ /**
198
+ * Checks if the bank supports fetching account statements in general or for the given account number when provided
199
+ * @param account when the account number is provided, checks if the account supports fetching of statements
200
+ * @returns true if the bank (and account) supports fetching account statements
201
+ */
202
+ canGetAccountStatements(account?: AccountRef): boolean {
203
+ if (account) {
204
+ // Check if either CAMT or MT940 is supported for this account
205
+ return (
206
+ this.config.isAccountTransactionSupported(account, HKCAZ.Id) ||
207
+ this.config.isAccountTransactionSupported(account, HKKAZ.Id)
208
+ );
209
+ } else {
210
+ // Check if either CAMT or MT940 is supported by the bank
211
+ return (
212
+ this.config.isTransactionSupported(HKCAZ.Id) || this.config.isTransactionSupported(HKKAZ.Id)
213
+ );
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Fetches the account statements for the given account number
219
+ * @param account - the account number to fetch the statements for, must be an account available in the config.baningInformation.UPD.accounts
220
+ * @param from - an optional start date of the period to fetch the statements for
221
+ * @param to - an optional end date of the period to fetch the statements for
222
+ * @param preferCamt - whether to prefer CAMT format over MT940 when both are supported (default: true)
223
+ * @returns an account statements response containing an array of statements
224
+ */
225
+ async getAccountStatements(
226
+ account: AccountRef,
227
+ from?: Date,
228
+ to?: Date,
229
+ preferCamt: boolean = true,
230
+ ): Promise<StatementResponse> {
231
+ // Check what formats the bank supports
232
+ const camtSupported = this.config.isAccountTransactionSupported(account, 'HKCAZ');
233
+ const mt940Supported = this.config.isAccountTransactionSupported(account, 'HKKAZ');
234
+
235
+ if (!camtSupported && !mt940Supported) {
236
+ throw Error(`Account ${describeAccount(account)} does not support account statements`);
237
+ }
238
+
239
+ // Choose format based on support and preference
240
+ const useCAMT = (preferCamt && camtSupported) || (!mt940Supported && camtSupported);
241
+
242
+ if (useCAMT) {
243
+ return (await this.startCustomerOrderInteraction(
244
+ new StatementInteractionCAMT(account, from, to),
245
+ )) as StatementResponse;
246
+ } else {
247
+ return (await this.startCustomerOrderInteraction(
248
+ new StatementInteractionMT940(account, from, to),
249
+ )) as StatementResponse;
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Continues the account statements fetching when a TAN is required
255
+ * @param tanReference The TAN reference provided in the first call's response
256
+ * @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
257
+ * @returns an account statements response containing an array of statements
258
+ */
259
+ async getAccountStatementsWithTan(
260
+ tanReference: string,
261
+ tan?: string,
262
+ ): Promise<StatementResponse> {
263
+ return (await this.continueCustomerInteractionWithTan(
264
+ [HKCAZ.Id, HKKAZ.Id],
265
+ tanReference,
266
+ tan,
267
+ )) as StatementResponse;
268
+ }
269
+
270
+ /**
271
+ * Checks if the bank supports fetching portfolio information in general or for the given account number when provided
272
+ * @param account when the account number is provided, checks if the account supports fetching of portfolio information
273
+ * @returns true if the bank (and account) supports fetching portfolio information
274
+ */
275
+ canGetPortfolio(account?: AccountRef): boolean {
276
+ return account
277
+ ? this.config.isAccountTransactionSupported(account, HKWPD.Id)
278
+ : this.config.isTransactionSupported(HKWPD.Id);
279
+ }
280
+
281
+ /**
282
+ * Fetches the portfolio information for the given depot account number
283
+ * @param account - the depot account number to fetch the portfolio for, must be an account available in the config.bankingInformation.UPD.accounts
284
+ * @param currency - optional currency filter for the portfolio statement
285
+ * @param priceQuality - optional price quality filter ('1' for real-time, '2' for delayed)
286
+ * @param maxEntries - optional maximum number of entries to retrieve
287
+ * @returns a portfolio response containing holdings and total value
288
+ */
289
+ async getPortfolio(
290
+ account: AccountRef,
291
+ currency?: string,
292
+ priceQuality?: '1' | '2',
293
+ maxEntries?: number,
294
+ ): Promise<PortfolioResponse> {
295
+ return (await this.startCustomerOrderInteraction(
296
+ new PortfolioInteraction(account, currency, priceQuality, maxEntries),
297
+ )) as PortfolioResponse;
298
+ }
299
+
300
+ /**
301
+ * Continues the portfolio fetching when a TAN is required
302
+ * @param tanReference The TAN reference provided in the first call's response
303
+
304
+ * @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
305
+ * @returns a portfolio response containing holdings and total value
306
+ */
307
+ async getPortfolioWithTan(tanReference: string, tan?: string): Promise<PortfolioResponse> {
308
+ return (await this.continueCustomerInteractionWithTan(
309
+ [HKWPD.Id],
310
+ tanReference,
311
+ tan,
312
+ )) as PortfolioResponse;
313
+ }
314
+
315
+ /**
316
+ * Checks if the bank supports fetching credit card statements in general or for the given account number
317
+ * @param account when the account number is provided, checks if the account supports fetching of statements
318
+ * @returns true if the bank (and account) supports fetching credit card statements
319
+ */
320
+ canGetCreditCardStatements(account?: AccountRef): boolean {
321
+ // HKKKU is the standardized successor of DKKKU; some banks (e.g. Postbank) only offer HKKKU
322
+ return account
323
+ ? this.config.isAccountTransactionSupported(account, HKKKU.Id) ||
324
+ this.config.isAccountTransactionSupported(account, DKKKU.Id)
325
+ : this.config.isTransactionSupported(HKKKU.Id) ||
326
+ this.config.isTransactionSupported(DKKKU.Id);
327
+ }
328
+
329
+ /**
330
+ * Fetches the credit card statements for the given account number
331
+ * @param account - the account number to fetch the statements for, must be a credit card account available
332
+ * in the config.baningInformation.UPD.accounts
333
+ * @param from - an optional start date of the period to fetch the statements for
334
+ * @param to - an optional end date of the period to fetch the statements for
335
+ * @returns an account statements response containing an array of statements
336
+ */
337
+ async getCreditCardStatements(
338
+ account: AccountRef,
339
+ from?: Date,
340
+ to?: Date,
341
+ ): Promise<StatementResponse> {
342
+ // Prefer HKKKU where the bank offers it for this account; DKKKU has no end date
343
+ if (this.config.isAccountTransactionSupported(account, HKKKU.Id)) {
344
+ return (await this.startCustomerOrderInteraction(
345
+ new CreditCardStatementInteractionHKKKU(account, from, to),
346
+ )) as StatementResponse;
347
+ }
348
+ return (await this.startCustomerOrderInteraction(
349
+ new CreditCardStatementInteraction(account, from),
350
+ )) as StatementResponse;
351
+ }
352
+
353
+ /**
354
+ * Continues the credit card statements fetching when a TAN is required
355
+ * @param tanReference The TAN reference provided in the first call's response
356
+ * @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
357
+ * @returns a credit card statements response containing an array of statements
358
+ */
359
+ async getCreditCardStatementsWithTan(
360
+ tanReference: string,
361
+ tan?: string,
362
+ ): Promise<StatementResponse> {
363
+ return (await this.continueCustomerInteractionWithTan(
364
+ [HKKKU.Id, DKKKU.Id],
365
+ tanReference,
366
+ tan,
367
+ )) as StatementResponse;
368
+ }
369
+
370
+ /**
371
+ * Checks if the bank supports fetching electronic account statements in general or for the given account number
372
+ * @param account when the account number is provided, checks if the account supports fetching of electronic statements
373
+ * @returns true if the bank (and account) supports fetching electronic account statements
374
+ */
375
+ canGetElectronicStatements(account?: AccountRef): boolean {
376
+ return account
377
+ ? this.config.isAccountTransactionSupported(account, HKEKA.Id)
378
+ : this.config.isTransactionSupported(HKEKA.Id);
379
+ }
380
+
381
+ /**
382
+ * Fetches an electronic account statement (Elektronischer Kontoauszug) for the given account number
383
+ *
384
+ * This returns the statement document the bank files in the customer's electronic mailbox,
385
+ * usually a PDF, not a list of transactions. The bank hands out one statement per call and
386
+ * announces a waiting successor in `nextOffset`; pass that value back in `options.offset` to
387
+ * fetch the next one. Banks that set `receiptRequired` in their HIEKAS parameters keep
388
+ * offering a statement until it has been acknowledged with its receipt.
389
+ *
390
+ * @param account - the account number to fetch the statement for, must be an account available in the config.bankingInformation.upd.accounts
391
+ * @param options - optional format, statement number and year, entry limit and offset
392
+ * @returns a response containing the statement documents and the offset of a waiting successor
393
+ */
394
+ async getElectronicStatements(
395
+ account: AccountRef,
396
+ options?: ElectronicStatementOptions,
397
+ ): Promise<ElectronicStatementResponse> {
398
+ return (await this.startCustomerOrderInteraction(
399
+ new ElectronicStatementInteraction(account, options),
400
+ )) as ElectronicStatementResponse;
401
+ }
402
+
403
+ /**
404
+ * Continues the electronic account statement fetching when a TAN is required
405
+ * @param tanReference The TAN reference provided in the first call's response
406
+ * @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
407
+ * @returns a response containing the statement documents
408
+ */
409
+ async getElectronicStatementsWithTan(
410
+ tanReference: string,
411
+ tan?: string,
412
+ ): Promise<ElectronicStatementResponse> {
413
+ return (await this.continueCustomerInteractionWithTan(
414
+ [HKEKA.Id],
415
+ tanReference,
416
+ tan,
417
+ )) as ElectronicStatementResponse;
418
+ }
419
+
420
+ /**
421
+ * Checks if the bank supports SEPA credit transfers in general or from the given account when provided:
422
+ * HKCCS in a version this library speaks, a pain.001 format it builds, where the bank requires
423
+ * Verification of Payee for transfers, readable VoP parameters (HIVPPS), and, where the bank requires
424
+ * a TAN or VoP for them, a selected TAN method of version 6 or later
425
+ * @param account when the account number is provided, checks if the account allows transfers and has an IBAN;
426
+ * an account whose UPD entry does not list HKCCS counts only with UPD usage 1, which leaves it to the bank
427
+ * @returns true if the bank (and account) supports SEPA credit transfers
428
+ */
429
+ canTransfer(account?: AccountRef): boolean {
430
+ if (account) {
431
+ // An unknown account is a mistake of the caller, as for the other can... methods
432
+ this.config.getBankAccount(account);
433
+ }
434
+
435
+ try {
436
+ this.checkTransferSupport(account);
437
+ return true;
438
+ } catch {
439
+ return false;
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Starts a SEPA credit transfer (HKCCS), executed as soon as possible.
445
+ *
446
+ * It starts a payment, and its first call can already be final: a bank may execute the
447
+ * transfer without asking for a confirmation or a TAN. `confirmTransfer()` and
448
+ * `transferWithTan()` can authorise it while it is pending. The input is checked before
449
+ * anything is sent: an invalid IBAN, BIC, amount or text throws a `SepaValidationError`, and
450
+ * nothing is transliterated or shortened.
451
+ *
452
+ * Where the bank requires Verification of Payee, it checks the payee's name against the IBAN
453
+ * first, and the response carries the result in `vop`. Then:
454
+ * - `requiresVopConfirmation`: the bank waits for a decision. Show `vop` (with `vop.notice`,
455
+ * the notice lines of `vop.paymentStatusReport?.groupReasons` and, for a close match,
456
+ * `vop.suggestedName`) to the user, then call
457
+ * `confirmTransfer(transferId)` to authorise the transfer anyway, or
458
+ * `cancelTransfer(transferId)` to drop it. Nothing is confirmed
459
+ * automatically, whatever the result.
460
+ * - `requiresTan`: the payee matched (or the bank requires no check) and the bank asks for
461
+ * the TAN; continue with `transferWithTan()`, or drop the transfer with
462
+ * `cancelTransfer(transferId)`.
463
+ * - `success` and neither flag: the bank accepted the transfer.
464
+ * - `success: false`: the transfer stopped; `bankAnswers` and `failureReason` say why. Anything
465
+ * unexpected, such as an unknown result code or a missing VoP ID, ends it this way. With
466
+ * `outcomeUncertain` the bank may have executed the order without confirming it (it
467
+ * received the order and a later step failed or timed out, it answered 9000, or it
468
+ * reported an execution its other answers contradict): check the account before
469
+ * sending it again.
470
+ *
471
+ * While the bank is still checking the payee, the call asks again until the result is
472
+ * there; `bankAnswers` then holds the answers to every one of these messages.
473
+ *
474
+ * Only one transfer can be in progress per client. Every response carries the same
475
+ * `transferId` for it.
476
+ *
477
+ * @param account - the account to transfer from, must be an account available in the config.bankingInformation.upd.bankAccounts with an IBAN
478
+ * @param transfer - the payee, amount and purpose
479
+ * @returns the transfer response
480
+ * @throws SepaValidationError when the transfer data is invalid
481
+ * @throws Error when a transfer is already in progress, the account cannot transfer, or the
482
+ * connection fails; an error after the first message was sent leaves the outcome unknown,
483
+ * check the account before trying again
484
+ */
485
+ async transfer(account: AccountRef, transfer: CreditTransfer): Promise<TransferResponse> {
486
+ if (this.currentTransfer) {
487
+ throw new Error(
488
+ 'a transfer is already in progress; continue it or call cancelTransfer() first',
489
+ );
490
+ }
491
+
492
+ // The payment as it is now: the caller's objects may change during the login
493
+ const accountRef = typeof account === 'string' ? account : { ...account };
494
+ const payment: CreditTransfer =
495
+ transfer && typeof transfer === 'object'
496
+ ? {
497
+ // Read one by one, so that a getter counts like a field
498
+ name: transfer.name,
499
+ iban: transfer.iban,
500
+ bic: transfer.bic,
501
+ amount: transfer.amount,
502
+ purpose: transfer.purpose,
503
+ endToEndId: transfer.endToEndId,
504
+ debtorName: transfer.debtorName,
505
+ }
506
+ : transfer;
507
+ const order = new CreditTransferOrder(() => this.prepareTransfer(accountRef, payment));
508
+ const dialog = new Dialog(this.config, false);
509
+ dialog.addCustomerInteraction(new CreditTransferInteraction(order, 'submit'));
510
+ const pending: PendingTransfer = { order, dialog, inFlight: false };
511
+ this.currentTransfer = pending;
512
+
513
+ return this.driveTransfer(pending, () => dialog.start());
514
+ }
515
+
516
+ /**
517
+ * Authorises the transfer despite the Verification of Payee result, after the user has seen
518
+ * `vop` and decided to go ahead. Only callable when the last response had
519
+ * `requiresVopConfirmation`. The bank may then ask for a TAN (`requiresTan`).
520
+ *
521
+ * Authorising a transfer to a payee whose name does not match may mean the money goes to
522
+ * someone else, and the payer's bank is then not liable for that.
523
+ * @param transferId the `transferId` of the response the user decided on
524
+ * @returns the transfer response
525
+ * @throws Error when that transfer is not the one waiting for a confirmation, or, before
526
+ * anything is sent and with the transfer still pending, when no TAN method of version 6
527
+ * or later is selected
528
+ */
529
+ async confirmTransfer(transferId: string): Promise<TransferResponse> {
530
+ const transfer = this.currentTransfer;
531
+
532
+ if (transfer?.inFlight) {
533
+ throw new Error(STEP_IN_FLIGHT);
534
+ }
535
+
536
+ if (
537
+ !transfer ||
538
+ transfer.order.transferId !== transferId ||
539
+ transfer.order.status !== 'awaitingConfirmation'
540
+ ) {
541
+ throw new Error(
542
+ 'no transfer is waiting for a confirmation of its Verification of Payee result',
543
+ );
544
+ }
545
+
546
+ // HKVPA, the order and HKTAN go together (DK VoP E.8.1 rule 4): nothing goes out
547
+ // without a TAN method that can send HKTAN
548
+ if (!transfer.order.authorizationOnly && !canSendTanSegment(this.config)) {
549
+ throw new Error(
550
+ 'the confirmation needs a TAN method of version 6 or later; select one with selectTanMethod()',
551
+ );
552
+ }
553
+
554
+ transfer.order.confirmed = true;
555
+
556
+ return this.driveTransfer(transfer, () =>
557
+ transfer.dialog.continueWith(
558
+ transfer.order.authorizationOnly
559
+ ? new VopAuthorizationInteraction(transfer.order)
560
+ : new CreditTransferInteraction(transfer.order, 'confirm'),
561
+ ),
562
+ );
563
+ }
564
+
565
+ /**
566
+ * Continues the transfer when a TAN is required. With a decoupled TAN method, call it again
567
+ * while the response still has `requiresTan`, after the user has approved in their app.
568
+ * @param tanReference The TAN reference provided in the previous response
569
+ * @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
570
+ * @returns the transfer response
571
+ * @throws Error, before anything is sent and with the transfer still pending, when the
572
+ * TAN method the challenge was issued for is no longer selected
573
+ */
574
+ async transferWithTan(tanReference: string, tan?: string): Promise<TransferResponse> {
575
+ const transfer = this.currentTransfer;
576
+
577
+ if (transfer?.inFlight) {
578
+ throw new Error(STEP_IN_FLIGHT);
579
+ }
580
+
581
+ if (transfer?.tanReference === undefined) {
582
+ throw new Error('no transfer is waiting for a TAN');
583
+ }
584
+
585
+ if (transfer.tanReference !== tanReference) {
586
+ throw new Error(
587
+ 'the TAN reference does not belong to the challenge of the transfer in progress',
588
+ );
589
+ }
590
+
591
+ // The answer to the challenge, HKVPA included, goes out only with the HKTAN of the
592
+ // method the challenge is for
593
+ if (!canSendTanSegment(this.config) || this.config.tanMethodId !== transfer.tanMethodId) {
594
+ throw new Error(
595
+ 'the TAN method of the challenge is no longer selected; select it again with selectTanMethod()',
596
+ );
597
+ }
598
+
599
+ if (!this.config.selectedTanMethod?.isDecoupled && !tan) {
600
+ throw new Error('TAN must be provided for non-decoupled TAN methods');
601
+ }
602
+
603
+ return this.driveTransfer(transfer, () => transfer.dialog.continue(tanReference, tan));
604
+ }
605
+
606
+ /**
607
+ * Drops the transfer in progress without executing it and ends its dialog. Call it after a
608
+ * response with `requiresVopConfirmation` or `requiresTan` when the user decides against the
609
+ * transfer. Does nothing when that transfer is no longer in progress.
610
+ * @param transferId the `transferId` of the transfer to drop
611
+ * @throws Error while a step of the transfer still waits for the bank's answer: that
612
+ * answer may already have executed it
613
+ */
614
+ async cancelTransfer(transferId: string): Promise<void> {
615
+ const transfer = this.currentTransfer;
616
+
617
+ if (!transfer || transfer.order.transferId !== transferId) {
618
+ return;
619
+ }
620
+
621
+ if (transfer.inFlight) {
622
+ throw new Error(STEP_IN_FLIGHT);
623
+ }
624
+
625
+ this.currentTransfer = undefined;
626
+
627
+ if (!transfer.dialog.hasEnded) {
628
+ await transfer.dialog.end();
629
+ }
630
+ }
631
+
632
+ /**
633
+ * @param initTanReference the order a PIN/TAN management dialog's initialisation refers
634
+ * to in its HKTAN (see Dialog.initTanReference)
635
+ */
636
+ private async startCustomerOrderInteraction(
637
+ interaction: CustomerOrderInteraction,
638
+ initTanReference?: string,
639
+ ): Promise<ClientResponse> {
640
+ this.currentDialog = new Dialog(this.config, false);
641
+ this.currentDialog.initTanReference = initTanReference;
642
+ this.currentDialog.addCustomerInteraction(interaction);
643
+ const responses = await this.currentDialog.start();
644
+
645
+ const response = responses.get(interaction.segId);
646
+ if (response) {
647
+ return response;
648
+ } else {
649
+ const lastResponse = [...responses.values()].at(-1);
650
+ if (lastResponse) {
651
+ return lastResponse;
652
+ } else {
653
+ throw new Error(
654
+ `No response received for customer interaction with segment ID '${interaction.segId}'`,
655
+ );
656
+ }
657
+ }
658
+ }
659
+
660
+ private async continueCustomerInteractionWithTan(
661
+ segIds: string[],
662
+ tanReference: string,
663
+ tan?: string,
664
+ ): Promise<ClientResponse> {
665
+ if (!this.currentDialog) {
666
+ throw new Error('no customer dialog was started which can continue');
667
+ }
668
+
669
+ const responses = await this.currentDialog.continue(tanReference, tan);
670
+
671
+ for (const segId of segIds) {
672
+ const response = responses.get(segId);
673
+ if (response) {
674
+ return response;
675
+ }
676
+ }
677
+
678
+ const lastResponse = [...responses.values()].at(-1);
679
+ if (lastResponse) {
680
+ return lastResponse;
681
+ } else {
682
+ throw new Error(
683
+ `No response received for customer interaction with segment IDs '${segIds.join(', ')}'`,
684
+ );
685
+ }
686
+ }
687
+
688
+ /**
689
+ * What canTransfer() checks, from the banking information as it is now
690
+ * @throws Error naming what does not allow the transfer
691
+ */
692
+ private checkTransferSupport(account?: AccountRef) {
693
+ const hkccsVersion = this.config.getMaxSupportedTransactionVersion(HKCCS.Id);
694
+
695
+ if (!hkccsVersion) {
696
+ throw new Error(
697
+ 'the bank does not support SEPA credit transfers (HKCCS) in a version this library supports',
698
+ );
699
+ }
700
+
701
+ // With UPD usage 1 the bank decides on a transaction the account does not list
702
+ if (
703
+ account &&
704
+ this.config.bankingInformation.upd?.usage !== UpdUsage.MissingUnknown &&
705
+ !this.config.isAccountTransactionSupported(account, HKCCS.Id)
706
+ ) {
707
+ throw new Error(
708
+ `account ${describeAccount(account)} does not allow SEPA credit transfers (HKCCS) according to the bank's account information (UPD)`,
709
+ );
710
+ }
711
+
712
+ if (account && !this.config.getBankAccount(account).iban) {
713
+ throw new Error(`account ${describeAccount(account)} has no IBAN to transfer from`);
714
+ }
715
+
716
+ const descriptor = this.selectTransferFormat();
717
+
718
+ if (!descriptor) {
719
+ throw new Error(
720
+ 'the bank supports none of the pain.001 formats this library builds (pain.001.001.09, pain.001.001.03)',
721
+ );
722
+ }
723
+
724
+ const vopParameters = this.getVopParameters();
725
+ const tanRequired = this.config.bankingInformation.bpd?.allowedTransactions.find(
726
+ (t) => t.transId === HKCCS.Id,
727
+ )?.tanRequired;
728
+
729
+ // The check and the order go only together with HKTAN (DK VoP specification E.8.1)
730
+ if ((tanRequired || vopParameters) && !canSendTanSegment(this.config)) {
731
+ throw new Error(
732
+ 'the bank requires a TAN for transfers, but no TAN method of version 6 or later is selected; select one with selectTanMethod()',
733
+ );
734
+ }
735
+
736
+ return { hkccsVersion, descriptor, vopParameters };
737
+ }
738
+
739
+ /**
740
+ * Builds the order from the banking information as it is at the time of the call: once
741
+ * when the transfer is created, and again right before it is first sent, after the dialog
742
+ * initialisation may have brought new parameters
743
+ */
744
+ private prepareTransfer(account: AccountRef, transfer: CreditTransfer): PreparedTransfer {
745
+ const { hkccsVersion, descriptor, vopParameters } = this.checkTransferSupport(account);
746
+ const bankAccount = this.config.getBankAccount(account);
747
+ const pain = buildPain001(
748
+ {
749
+ name: transfer.debtorName ?? bankAccount.holder1,
750
+ iban: bankAccount.iban ?? '',
751
+ bic: bankAccount.bic,
752
+ },
753
+ transfer,
754
+ descriptor,
755
+ );
756
+
757
+ return {
758
+ account: internationalAccount(this.config, bankAccount),
759
+ pain,
760
+ hkccsVersion,
761
+ vopParameters,
762
+ };
763
+ }
764
+
765
+ private selectTransferFormat(): string | undefined {
766
+ return selectPain001Format(
767
+ this.config.getTransactionParameters<HISPASParameter>(HKSPA.Id)?.supportedSepaFormats,
768
+ );
769
+ }
770
+
771
+ /**
772
+ * What the bank's parameters say about Verification of Payee for transfers
773
+ * @returns undefined when the bank does not require it for HKCCS
774
+ * @throws Error when the bank announces it but its parameters cannot be used
775
+ */
776
+ private getVopParameters(): VopParameters | undefined {
777
+ if (!this.config.isTransactionSupported(HKVPP.Id)) {
778
+ return undefined;
779
+ }
780
+
781
+ const params = this.config.getTransactionParameters<HIVPPSParameter>(HKVPP.Id);
782
+
783
+ // Unreadable parameters must not be taken for "no check required"
784
+ if (!params || !Array.isArray(params.vopRequiredTransactions)) {
785
+ throw new Error(
786
+ 'the bank announces Verification of Payee (HKVPP), but its parameters (HIVPPS) could not be read',
787
+ );
788
+ }
789
+
790
+ if (!params.vopRequiredTransactions.includes(HKCCS.Id)) {
791
+ return undefined;
792
+ }
793
+
794
+ const hkvppVersion = this.config.getMaxSupportedTransactionVersion(HKVPP.Id);
795
+ const hkvpaVersion = this.config.getMaxSupportedTransactionVersion(HKVPA.Id);
796
+
797
+ if (!hkvppVersion || !hkvpaVersion) {
798
+ throw new Error(
799
+ 'the bank requires Verification of Payee for transfers, but not in a version of HKVPP and HKVPA this library supports',
800
+ );
801
+ }
802
+
803
+ const reportFormats = (params.supportedReportFormats ?? '')
804
+ .split(/[;,\s]+/)
805
+ .filter((format) => !!format)
806
+ .slice(0, 99);
807
+
808
+ return {
809
+ reportFormats: reportFormats.length ? reportFormats : [VOP_DEFAULT_REPORT_FORMAT],
810
+ noticeStructured: !!params.noticeStructured,
811
+ hkvppVersion,
812
+ hkvpaVersion,
813
+ };
814
+ }
815
+
816
+ /**
817
+ * Runs one step of the given transfer, then asks again for a Verification of Payee
818
+ * result for as long as the bank is still producing it. The transfer is marked in
819
+ * flight before anything is sent, so that no other step overlaps this one, and only
820
+ * this transfer is dropped when it ends.
821
+ */
822
+ private async driveTransfer(
823
+ transfer: PendingTransfer,
824
+ step: () => Promise<Map<string, ClientResponse>>,
825
+ ): Promise<TransferResponse> {
826
+ transfer.inFlight = true;
827
+
828
+ try {
829
+ return await this.runTransferStep(transfer, step);
830
+ } finally {
831
+ transfer.inFlight = false;
832
+ }
833
+ }
834
+
835
+ private async runTransferStep(
836
+ transfer: PendingTransfer,
837
+ step: () => Promise<Map<string, ClientResponse>>,
838
+ ): Promise<TransferResponse> {
839
+ const { order, dialog } = transfer;
840
+ const release = () => {
841
+ if (this.currentTransfer === transfer) {
842
+ this.currentTransfer = undefined;
843
+ }
844
+ };
845
+ let response: TransferResponse | undefined;
846
+ // Any message of the call may update it, the dialog initialisation above all
847
+ const bankingInformation = JSON.stringify(this.config.bankingInformation);
848
+ const withUpdate = (response: TransferResponse): TransferResponse =>
849
+ JSON.stringify(this.config.bankingInformation) === bankingInformation
850
+ ? response
851
+ : { ...response, bankingInformationUpdated: true };
852
+
853
+ transfer.tanReference = undefined;
854
+
855
+ try {
856
+ order.lastResponse = undefined;
857
+ await step();
858
+ response = this.toTransferResponse(order, dialog);
859
+ let waitedSeconds = 0;
860
+
861
+ while (order.status === 'polling' && response.success) {
862
+ const waitSeconds = Math.max(1, order.waitSeconds ?? VOP_DEFAULT_WAIT_SECONDS);
863
+
864
+ if (waitedSeconds + waitSeconds > VOP_TIMEOUT_SECONDS) {
865
+ order.status = 'failed';
866
+ const { reason, uncertain } = order.evidence.giveUp(
867
+ `The bank did not deliver the Verification of Payee result within ${VOP_TIMEOUT_SECONDS} seconds.`,
868
+ );
869
+ response = {
870
+ ...response,
871
+ success: false,
872
+ outcomeUncertain: uncertain,
873
+ failureReason: reason,
874
+ };
875
+ break;
876
+ }
877
+
878
+ waitedSeconds += waitSeconds;
879
+ await this.sleep(waitSeconds * 1000);
880
+ order.lastResponse = undefined;
881
+ await dialog.continueWith(new VopPollInteraction(order));
882
+ // The caller sees what the bank said on every poll of this call
883
+ const earlierAnswers: TransferResponse['bankAnswers'] = response.bankAnswers;
884
+ response = this.toTransferResponse(order, dialog);
885
+ response = { ...response, bankAnswers: [...earlierAnswers, ...response.bankAnswers] };
886
+ }
887
+ } catch (error) {
888
+ release();
889
+
890
+ // The bank accepted the order and only ending the dialog failed: still a success
891
+ if (order.status === 'accepted' && order.lastResponse) {
892
+ return withUpdate(order.lastResponse);
893
+ }
894
+
895
+ await this.endQuietly(dialog);
896
+ const { refused } = order.evidence;
897
+
898
+ // Without an answer the outcome is unknown, as any error says; once the answers so
899
+ // far allow that the bank executes the payment, or the payment was refused here,
900
+ // the caller gets them with the uncertainty
901
+ if (!refused && !order.evidence.mayHaveExecuted()) {
902
+ throw error;
903
+ }
904
+
905
+ order.status = 'failed';
906
+ const { reason } = order.evidence.giveUp(
907
+ refused ?? `The answer of the bank did not arrive (${(error as Error).message}).`,
908
+ true,
909
+ );
910
+ return withUpdate({
911
+ ...(response ?? this.unanswered(order, dialog)),
912
+ success: false,
913
+ requiresTan: false,
914
+ requiresVopConfirmation: false,
915
+ outcomeUncertain: true,
916
+ failureReason: reason,
917
+ });
918
+ }
919
+
920
+ response = withUpdate(response);
921
+
922
+ if (response.success && response.requiresTan) {
923
+ transfer.tanReference = response.tanReference;
924
+ transfer.tanMethodId = this.config.tanMethodId;
925
+ }
926
+
927
+ if (order.status === 'accepted') {
928
+ // The dialog has already sent HKEND
929
+ release();
930
+ } else if (!response.success || order.status === 'failed') {
931
+ release();
932
+ await this.endQuietly(dialog);
933
+ }
934
+
935
+ return response;
936
+ }
937
+
938
+ /**
939
+ * The response of the transfer interaction, or, when the dialog stopped before the transfer
940
+ * was sent (a TAN or an error in the dialog initialisation or a step it queued, such as
941
+ * HKSPA), the response of the interaction it stopped at
942
+ */
943
+ private toTransferResponse(order: CreditTransferOrder, dialog: Dialog): TransferResponse {
944
+ if (order.lastResponse) {
945
+ return order.lastResponse;
946
+ }
947
+
948
+ const segId = dialog.currentInteraction?.segId;
949
+ const response = segId ? dialog.responses.get(segId) : undefined;
950
+
951
+ if (!response) {
952
+ throw new Error('No response received for the transfer');
953
+ }
954
+
955
+ const transferResponse: TransferResponse = {
956
+ ...response,
957
+ requiresVopConfirmation: false,
958
+ vop: order.vopResult,
959
+ transferId: order.transferId,
960
+ endToEndId: order.pain.endToEndId,
961
+ outcomeUncertain: false,
962
+ };
963
+
964
+ if (response.requiresTan && response.success && response.tanReference) {
965
+ return transferResponse;
966
+ }
967
+
968
+ order.status = 'failed';
969
+ return {
970
+ ...transferResponse,
971
+ success: false,
972
+ requiresTan: false,
973
+ failureReason:
974
+ 'The dialog stopped before the transfer was sent, see bankAnswers. The transfer was not executed.',
975
+ };
976
+ }
977
+
978
+ /** The response of a transfer step the bank did not answer */
979
+ private unanswered(order: CreditTransferOrder, dialog: Dialog): TransferResponse {
980
+ return {
981
+ dialogId: dialog.dialogId,
982
+ success: false,
983
+ bankingInformationUpdated: false,
984
+ bankAnswers: [],
985
+ requiresTan: false,
986
+ requiresVopConfirmation: false,
987
+ vop: order.vopResult,
988
+ transferId: order.transferId,
989
+ endToEndId: order.pain.endToEndId,
990
+ outcomeUncertain: true,
991
+ };
992
+ }
993
+
994
+ private async endQuietly(dialog: Dialog): Promise<void> {
995
+ try {
996
+ await dialog.end();
997
+ } catch {
998
+ // The dialog times out at the bank all the same
999
+ }
1000
+ }
1001
+
1002
+ private sleep(milliseconds: number): Promise<void> {
1003
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
1004
+ }
1005
+ }