@coderoftime/fints 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/CHANGELOG.md +142 -1
  2. package/README.md +127 -37
  3. package/dist/client.d.ts +48 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +199 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/core/account.d.ts +35 -7
  8. package/dist/core/account.d.ts.map +1 -1
  9. package/dist/core/account.js +84 -13
  10. package/dist/core/account.js.map +1 -1
  11. package/dist/core/amount.d.ts +2 -1
  12. package/dist/core/amount.d.ts.map +1 -1
  13. package/dist/core/amount.js +4 -1
  14. package/dist/core/amount.js.map +1 -1
  15. package/dist/core/balance.d.ts +1 -0
  16. package/dist/core/balance.d.ts.map +1 -1
  17. package/dist/core/balance.js +6 -5
  18. package/dist/core/balance.js.map +1 -1
  19. package/dist/core/bank-info.d.ts +1 -1
  20. package/dist/core/bank-info.js +1 -1
  21. package/dist/core/client.d.ts +50 -15
  22. package/dist/core/client.d.ts.map +1 -1
  23. package/dist/core/config.d.ts +28 -16
  24. package/dist/core/config.d.ts.map +1 -1
  25. package/dist/core/config.js +66 -26
  26. package/dist/core/config.js.map +1 -1
  27. package/dist/core/errors.d.ts +85 -23
  28. package/dist/core/errors.d.ts.map +1 -1
  29. package/dist/core/errors.js +112 -47
  30. package/dist/core/errors.js.map +1 -1
  31. package/dist/core/feedback.d.ts +4 -1
  32. package/dist/core/feedback.d.ts.map +1 -1
  33. package/dist/core/feedback.js +4 -1
  34. package/dist/core/feedback.js.map +1 -1
  35. package/dist/core/transaction.d.ts +6 -1
  36. package/dist/core/transaction.d.ts.map +1 -1
  37. package/dist/core/transaction.js +9 -4
  38. package/dist/core/transaction.js.map +1 -1
  39. package/dist/core/transport.d.ts +33 -6
  40. package/dist/core/transport.d.ts.map +1 -1
  41. package/dist/core/transport.js +77 -20
  42. package/dist/core/transport.js.map +1 -1
  43. package/dist/formats/camt.d.ts +24 -4
  44. package/dist/formats/camt.d.ts.map +1 -1
  45. package/dist/formats/camt.js +124 -41
  46. package/dist/formats/camt.js.map +1 -1
  47. package/dist/formats/mt940.d.ts +15 -3
  48. package/dist/formats/mt940.d.ts.map +1 -1
  49. package/dist/formats/mt940.js +161 -82
  50. package/dist/formats/mt940.js.map +1 -1
  51. package/dist/formats/readers.d.ts +6 -2
  52. package/dist/formats/readers.d.ts.map +1 -1
  53. package/dist/formats/readers.js +24 -29
  54. package/dist/formats/readers.js.map +1 -1
  55. package/dist/formats/record-budget.d.ts +7 -0
  56. package/dist/formats/record-budget.d.ts.map +1 -0
  57. package/dist/formats/record-budget.js +17 -0
  58. package/dist/formats/record-budget.js.map +1 -0
  59. package/dist/formats/sepa-purpose.d.ts +6 -0
  60. package/dist/formats/sepa-purpose.d.ts.map +1 -1
  61. package/dist/formats/sepa-purpose.js +23 -2
  62. package/dist/formats/sepa-purpose.js.map +1 -1
  63. package/dist/index.d.ts +3 -3
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +2 -2
  66. package/dist/index.js.map +1 -1
  67. package/dist/session/app-approval.d.ts +11 -5
  68. package/dist/session/app-approval.d.ts.map +1 -1
  69. package/dist/session/app-approval.js +23 -12
  70. package/dist/session/app-approval.js.map +1 -1
  71. package/dist/session/dialog-runner.d.ts +7 -10
  72. package/dist/session/dialog-runner.d.ts.map +1 -1
  73. package/dist/session/dialog-runner.js +15 -16
  74. package/dist/session/dialog-runner.js.map +1 -1
  75. package/dist/session/login-guard.d.ts +54 -49
  76. package/dist/session/login-guard.d.ts.map +1 -1
  77. package/dist/session/login-guard.js +156 -84
  78. package/dist/session/login-guard.js.map +1 -1
  79. package/dist/session/sepa-accounts.d.ts +20 -14
  80. package/dist/session/sepa-accounts.d.ts.map +1 -1
  81. package/dist/session/sepa-accounts.js +62 -46
  82. package/dist/session/sepa-accounts.js.map +1 -1
  83. package/dist/session/session-setup.d.ts +33 -25
  84. package/dist/session/session-setup.d.ts.map +1 -1
  85. package/dist/session/session-setup.js +87 -65
  86. package/dist/session/session-setup.js.map +1 -1
  87. package/dist/session/session-state.d.ts +9 -6
  88. package/dist/session/session-state.d.ts.map +1 -1
  89. package/dist/session/session-state.js +52 -17
  90. package/dist/session/session-state.js.map +1 -1
  91. package/dist/session/signed-dialog.d.ts +77 -0
  92. package/dist/session/signed-dialog.d.ts.map +1 -0
  93. package/dist/session/signed-dialog.js +170 -0
  94. package/dist/session/signed-dialog.js.map +1 -0
  95. package/dist/session/tan-selection.d.ts +26 -18
  96. package/dist/session/tan-selection.d.ts.map +1 -1
  97. package/dist/session/tan-selection.js +44 -33
  98. package/dist/session/tan-selection.js.map +1 -1
  99. package/dist/session/user-prompts.d.ts +8 -4
  100. package/dist/session/user-prompts.d.ts.map +1 -1
  101. package/dist/session/user-prompts.js +34 -14
  102. package/dist/session/user-prompts.js.map +1 -1
  103. package/dist/tan/challenge.d.ts +34 -13
  104. package/dist/tan/challenge.d.ts.map +1 -1
  105. package/dist/tan/challenge.js +25 -26
  106. package/dist/tan/challenge.js.map +1 -1
  107. package/dist/tan/flicker.d.ts +7 -1
  108. package/dist/tan/flicker.d.ts.map +1 -1
  109. package/dist/tan/flicker.js +40 -6
  110. package/dist/tan/flicker.js.map +1 -1
  111. package/dist/tan/tan-image.d.ts +3 -2
  112. package/dist/tan/tan-image.d.ts.map +1 -1
  113. package/dist/tan/tan-image.js +7 -5
  114. package/dist/tan/tan-image.js.map +1 -1
  115. package/dist/tan/tan-models.d.ts +5 -1
  116. package/dist/tan/tan-models.d.ts.map +1 -1
  117. package/dist/tan/tan-models.js +10 -5
  118. package/dist/tan/tan-models.js.map +1 -1
  119. package/dist/util/async.d.ts +0 -2
  120. package/dist/util/async.d.ts.map +1 -1
  121. package/dist/util/async.js +0 -4
  122. package/dist/util/async.js.map +1 -1
  123. package/dist/util/bytes.d.ts +2 -3
  124. package/dist/util/bytes.d.ts.map +1 -1
  125. package/dist/util/bytes.js +12 -20
  126. package/dist/util/bytes.js.map +1 -1
  127. package/dist/util/call-context.d.ts.map +1 -1
  128. package/dist/util/call-context.js +3 -2
  129. package/dist/util/call-context.js.map +1 -1
  130. package/dist/util/dates.d.ts +9 -16
  131. package/dist/util/dates.d.ts.map +1 -1
  132. package/dist/util/dates.js +39 -19
  133. package/dist/util/dates.js.map +1 -1
  134. package/dist/util/errors.d.ts +9 -1
  135. package/dist/util/errors.d.ts.map +1 -1
  136. package/dist/util/errors.js +12 -3
  137. package/dist/util/errors.js.map +1 -1
  138. package/dist/util/json.d.ts +4 -0
  139. package/dist/util/json.d.ts.map +1 -1
  140. package/dist/util/json.js +18 -0
  141. package/dist/util/json.js.map +1 -1
  142. package/dist/util/text.d.ts +21 -4
  143. package/dist/util/text.d.ts.map +1 -1
  144. package/dist/util/text.js +42 -13
  145. package/dist/util/text.js.map +1 -1
  146. package/dist/util/xml.d.ts +4 -3
  147. package/dist/util/xml.d.ts.map +1 -1
  148. package/dist/util/xml.js +37 -26
  149. package/dist/util/xml.js.map +1 -1
  150. package/dist/v3/account-extension.d.ts.map +1 -1
  151. package/dist/v3/account-extension.js +7 -10
  152. package/dist/v3/account-extension.js.map +1 -1
  153. package/dist/v3/bank-connection.d.ts +34 -0
  154. package/dist/v3/bank-connection.d.ts.map +1 -0
  155. package/dist/v3/bank-connection.js +58 -0
  156. package/dist/v3/bank-connection.js.map +1 -0
  157. package/dist/v3/dialog.d.ts +80 -46
  158. package/dist/v3/dialog.d.ts.map +1 -1
  159. package/dist/v3/dialog.js +162 -59
  160. package/dist/v3/dialog.js.map +1 -1
  161. package/dist/v3/message.d.ts +17 -4
  162. package/dist/v3/message.d.ts.map +1 -1
  163. package/dist/v3/message.js +62 -18
  164. package/dist/v3/message.js.map +1 -1
  165. package/dist/v3/parameter-store.d.ts +75 -0
  166. package/dist/v3/parameter-store.d.ts.map +1 -0
  167. package/dist/v3/parameter-store.js +143 -0
  168. package/dist/v3/parameter-store.js.map +1 -0
  169. package/dist/v3/parameters.d.ts +38 -12
  170. package/dist/v3/parameters.d.ts.map +1 -1
  171. package/dist/v3/parameters.js +91 -37
  172. package/dist/v3/parameters.js.map +1 -1
  173. package/dist/v3/protocol.d.ts +43 -50
  174. package/dist/v3/protocol.d.ts.map +1 -1
  175. package/dist/v3/protocol.js +58 -208
  176. package/dist/v3/protocol.js.map +1 -1
  177. package/dist/v3/queries.d.ts +51 -0
  178. package/dist/v3/queries.d.ts.map +1 -0
  179. package/dist/v3/queries.js +120 -0
  180. package/dist/v3/queries.js.map +1 -0
  181. package/dist/v3/segments.d.ts +29 -12
  182. package/dist/v3/segments.d.ts.map +1 -1
  183. package/dist/v3/segments.js +65 -23
  184. package/dist/v3/segments.js.map +1 -1
  185. package/dist/v3/syntax.d.ts +65 -14
  186. package/dist/v3/syntax.d.ts.map +1 -1
  187. package/dist/v3/syntax.js +167 -101
  188. package/dist/v3/syntax.js.map +1 -1
  189. package/package.json +10 -6
  190. package/src/client.ts +252 -0
  191. package/src/core/account.ts +86 -13
  192. package/src/core/amount.ts +3 -1
  193. package/src/core/balance.ts +6 -5
  194. package/src/core/bank-info.ts +1 -1
  195. package/src/core/client.ts +52 -15
  196. package/src/core/config.ts +69 -28
  197. package/src/core/errors.ts +122 -48
  198. package/src/core/feedback.ts +4 -1
  199. package/src/core/transaction.ts +9 -4
  200. package/src/core/transport.ts +98 -23
  201. package/src/formats/camt.ts +136 -39
  202. package/src/formats/mt940.ts +167 -81
  203. package/src/formats/readers.ts +24 -31
  204. package/src/formats/record-budget.ts +18 -0
  205. package/src/formats/sepa-purpose.ts +21 -2
  206. package/src/index.ts +4 -2
  207. package/src/session/app-approval.ts +51 -38
  208. package/src/session/dialog-runner.ts +31 -28
  209. package/src/session/login-guard.ts +174 -88
  210. package/src/session/sepa-accounts.ts +63 -45
  211. package/src/session/session-setup.ts +90 -71
  212. package/src/session/session-state.ts +56 -22
  213. package/src/session/signed-dialog.ts +192 -0
  214. package/src/session/tan-selection.ts +50 -39
  215. package/src/session/user-prompts.ts +35 -16
  216. package/src/tan/challenge.ts +40 -31
  217. package/src/tan/flicker.ts +44 -6
  218. package/src/tan/tan-image.ts +7 -5
  219. package/src/tan/tan-models.ts +10 -5
  220. package/src/util/async.ts +0 -5
  221. package/src/util/bytes.ts +13 -19
  222. package/src/util/call-context.ts +3 -2
  223. package/src/util/dates.ts +41 -24
  224. package/src/util/errors.ts +14 -3
  225. package/src/util/json.ts +16 -0
  226. package/src/util/text.ts +42 -12
  227. package/src/util/xml.ts +37 -26
  228. package/src/v3/account-extension.ts +7 -12
  229. package/src/v3/bank-connection.ts +67 -0
  230. package/src/v3/dialog.ts +175 -91
  231. package/src/v3/message.ts +69 -17
  232. package/src/v3/parameter-store.ts +160 -0
  233. package/src/v3/parameters.ts +110 -37
  234. package/src/v3/protocol.ts +70 -253
  235. package/src/v3/queries.ts +190 -0
  236. package/src/v3/segments.ts +65 -22
  237. package/src/v3/syntax.ts +153 -91
  238. package/dist/session/bank-connection.d.ts +0 -28
  239. package/dist/session/bank-connection.d.ts.map +0 -1
  240. package/dist/session/bank-connection.js +0 -48
  241. package/dist/session/bank-connection.js.map +0 -1
  242. package/dist/session/parameter-data.d.ts +0 -83
  243. package/dist/session/parameter-data.d.ts.map +0 -1
  244. package/dist/session/parameter-data.js +0 -68
  245. package/dist/session/parameter-data.js.map +0 -1
  246. package/dist/session/pin-tan-client.d.ts +0 -54
  247. package/dist/session/pin-tan-client.d.ts.map +0 -1
  248. package/dist/session/pin-tan-client.js +0 -153
  249. package/dist/session/pin-tan-client.js.map +0 -1
  250. package/dist/session/pin-tan-dialog.d.ts +0 -71
  251. package/dist/session/pin-tan-dialog.d.ts.map +0 -1
  252. package/dist/session/pin-tan-dialog.js +0 -124
  253. package/dist/session/pin-tan-dialog.js.map +0 -1
  254. package/dist/session/protocol.d.ts +0 -209
  255. package/dist/session/protocol.d.ts.map +0 -1
  256. package/dist/session/protocol.js +0 -75
  257. package/dist/session/protocol.js.map +0 -1
  258. package/dist/session/response-handler.d.ts +0 -48
  259. package/dist/session/response-handler.d.ts.map +0 -1
  260. package/dist/session/response-handler.js +0 -121
  261. package/dist/session/response-handler.js.map +0 -1
  262. package/dist/v3/client.d.ts +0 -24
  263. package/dist/v3/client.d.ts.map +0 -1
  264. package/dist/v3/client.js +0 -16
  265. package/dist/v3/client.js.map +0 -1
  266. package/src/session/bank-connection.ts +0 -51
  267. package/src/session/parameter-data.ts +0 -137
  268. package/src/session/pin-tan-client.ts +0 -186
  269. package/src/session/pin-tan-dialog.ts +0 -160
  270. package/src/session/protocol.ts +0 -311
  271. package/src/session/response-handler.ts +0 -130
  272. package/src/v3/client.ts +0 -29
@@ -1 +1 @@
1
- {"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/core/balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAoBjD,+CAA+C;AAC/C,MAAM,OAAO,OAAO;IAClB,0CAA0C;IACjC,OAAO,CAAU;IAE1B,+CAA+C;IACtC,MAAM,CAAS;IAExB;;;OAGG;IACM,UAAU,CAAO;IAE1B,8GAA8G;IACrG,cAAc,CAAmB;IAE1C,gFAAgF;IACvE,OAAO,CAAqB;IAErC,gCAAgC;IACvB,UAAU,CAAqB;IAExC,+CAA+C;IACtC,SAAS,CAAqB;IAEvC,mDAAmD;IAC1C,IAAI,CAAqB;IAElC,qDAAqD;IAC5C,SAAS,CAAqB;IAEvC,oGAAoG;IAC3F,WAAW,CAAmB;IAEvC,+GAA+G;IACtG,WAAW,CAAmB;IAEvC,gEAAgE;IACvD,WAAW,CAAqB;IAEzC,YAAY,IAAiB;QAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,C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IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,QAAQ;QACN,OAAO,WAAW,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;IAClF,CAAC;CACF"}
@@ -19,7 +19,7 @@ export declare class BankInfo {
19
19
  readonly minTimeout: number | undefined;
20
20
  /**
21
21
  * Time in seconds after which the bank will likely end a dialog without messages, `0` for no limit (HIBPA, Formals
22
- * C.9). The client starts a new dialog for a call after that time.
22
+ * C.9). The client starts a new dialog for a call after that time, or after 5 minutes where the bank states none.
23
23
  */
24
24
  readonly maxTimeout: number | undefined;
25
25
  constructor(init: {
@@ -19,7 +19,7 @@ export class BankInfo {
19
19
  minTimeout;
20
20
  /**
21
21
  * Time in seconds after which the bank will likely end a dialog without messages, `0` for no limit (HIBPA, Formals
22
- * C.9). The client starts a new dialog for a call after that time.
22
+ * C.9). The client starts a new dialog for a call after that time, or after 5 minutes where the bank states none.
23
23
  */
24
24
  maxTimeout;
25
25
  constructor(init) {
@@ -3,6 +3,7 @@ import type { TanMedium, TanMethod } from '../tan/tan-models.js';
3
3
  import type { Account } from './account.js';
4
4
  import type { Balance } from './balance.js';
5
5
  import type { BankInfo, BankMessage } from './bank-info.js';
6
+ import type { FinTsLoginRefusedError } from './errors.js';
6
7
  import type { FinTsFeedback } from './feedback.js';
7
8
  import type { Transaction, TransactionFormat } from './transaction.js';
8
9
  import type { FinTsTransport } from './transport.js';
@@ -38,9 +39,15 @@ export interface FinTsClientOptions {
38
39
  /** Receives every FinTS message with PIN and TAN masked, for diagnosis; the messages contain account data. */
39
40
  logger?: MessageLogger;
40
41
  /**
41
- * The `FinTsClient.state` of a previous session, which skips the bank setup steps.
42
+ * The `FinTsClient.state` of a previous session, which skips the bank setup steps. A refused login in it keeps the
43
+ * client from sending the PIN (`FinTsClient.loginRefusal`).
42
44
  *
43
- * A state saved for another user or bank is ignored.
45
+ * A state belongs to one client at a time: restore the clients of one bank user one after another, each from the
46
+ * state the one before saved, never two at once from the same state. The state saved last wins, and could lift a
47
+ * refused login the other client saved.
48
+ *
49
+ * A state saved for another user or bank is ignored, and of one saved for another server of the bank, such as before
50
+ * the bank moved its FinTS URL, only the refused login holds.
44
51
  */
45
52
  state?: string | undefined;
46
53
  /**
@@ -62,21 +69,31 @@ export interface TransactionQuery {
62
69
  /**
63
70
  * Read access to a bank account over FinTS.
64
71
  *
65
- * All calls share one bank dialog, so strong authentication happens once per session. Calls run one after another; call
66
- * `close` when done.
72
+ * A call logs in where it needs to, which sends the PIN and may ask the callbacks for a TAN method, a TAN medium and an
73
+ * approval. Calls share one bank dialog while it is open, so that the approval of its login serves them all. The next
74
+ * call logs in anew, which may ask for another approval, once the dialog has idled longer than `BankInfo.maxTimeout`,
75
+ * after `selectTanMethod` and `clearLoginRefusal`, once the bank has ended the dialog, and after a message failed with
76
+ * another error than the bank's (`FinTsBankError`), such as a cancelled approval or a broken connection. Calls run one
77
+ * after another; call `close` when done.
67
78
  *
68
79
  * A callback in `FinTsClientOptions` must not wait for another call of its client, which would wait for the running
69
- * call. On Node.js, Deno and Bun such a call fails with `FinTsStateError`; elsewhere it would wait forever. `close` works
70
- * from anywhere.
80
+ * call. On Node.js, Deno 2.1 and Bun 1.2.6 or later such a call fails with `FinTsStateError`; elsewhere it waits
81
+ * forever. `close` works from anywhere.
71
82
  */
72
83
  export interface FinTsClient {
73
84
  /**
74
85
  * Serialized session data: bank and user parameters, customer system ID, the TAN methods the user may use, the chosen
75
- * TAN method and medium, and the SEPA account list.
86
+ * TAN method and medium, the SEPA account list, and a refused login (`loginRefusal`).
76
87
  *
77
- * Contains no PIN or TAN, but account details, so store it encrypted.
88
+ * Contains no PIN or TAN, but account details, so store it encrypted. It holds what this client knows, and replaces
89
+ * the state it was restored from: one client at a time per state (`FinTsClientOptions.state`).
78
90
  */
79
91
  readonly state: string;
92
+ /**
93
+ * The refused login that keeps the client from sending the PIN again (`FinTsLoginRefusedError`); `undefined` while
94
+ * there is none. It is kept in `state` until `clearLoginRefusal`.
95
+ */
96
+ readonly loginRefusal: FinTsLoginRefusedError | undefined;
80
97
  /** Security function code of the TAN method in use, for example `942`; `undefined` before the first login. */
81
98
  readonly selectedTanMethod: string | undefined;
82
99
  /** Name of the TAN medium sent to the bank, if the method needs one. */
@@ -88,9 +105,23 @@ export interface FinTsClient {
88
105
  * `securityFunction`, the client picks another method at that login.
89
106
  */
90
107
  selectTanMethod(securityFunction: string, tanMedium?: string): Promise<void>;
108
+ /**
109
+ * Lifts `loginRefusal` and signs with `pin` from now on. Ends the current dialog, so that the next call logs in with
110
+ * it, and forgets the TAN medium, which the bank may have refused, such as that of a phone the user has replaced: where
111
+ * the TAN method needs one, the next call looks the media up anew and asks the `tanMediumSelector`.
112
+ *
113
+ * Pass a PIN the user has entered after the refusal, never a stored one unasked: banks lock the access after a few
114
+ * failed logins. Rejects with `TypeError` for a PIN the client cannot send, as its constructor throws, and with the
115
+ * refusal where it is a `FinTsLoginDataChangedError`: only a new client with the new login data can log in.
116
+ */
117
+ clearLoginRefusal(pin: string): Promise<void>;
91
118
  /** General information about the bank, from the bank parameter data. */
92
119
  getBankInfo(): Promise<BankInfo>;
93
- /** TAN procedures the bank allows for this user. */
120
+ /**
121
+ * TAN procedures the bank allows for this user, which the synchronization reports. Where the session has no customer
122
+ * system ID yet, as without a saved state, this call logs in for it: it may ask `tanMethodSelector` where the bank
123
+ * refuses the one-step method, and `tanCallback` for an approval.
124
+ */
94
125
  getTanMethods(): Promise<TanMethod[]>;
95
126
  /** TAN devices registered for this user. */
96
127
  getTanMedia(): Promise<TanMedium[]>;
@@ -102,7 +133,8 @@ export interface FinTsClient {
102
133
  * Where the user parameter data carry the complete balance (account extension), possibly from the saved `state`, it
103
134
  * comes from there without a query; `Balance.bookedAsOf` tells the day it states.
104
135
  *
105
- * Throws `FinTsUnsupportedError`, without asking the bank, where the parameter data rule the query out.
136
+ * Rejects with `FinTsUnsupportedError` where the parameter data rule the query out, without sending it; the login,
137
+ * which delivers them, may have gone out.
106
138
  */
107
139
  getBalance(account: Account): Promise<Balance>;
108
140
  /**
@@ -110,16 +142,19 @@ export interface FinTsClient {
110
142
  * the same day in the bank's order.
111
143
  *
112
144
  * Only the local calendar day counts, and a day in the future counts as today. Banks typically ask for a TAN when
113
- * `from` is more than 90 days ago; see also `Account.dataStatus`. Throws `TypeError` if `from` lies on a day after
114
- * `to`, and `FinTsUnsupportedError`, without asking the bank, where the parameter data rule the query out.
145
+ * `from` is more than 90 days ago; see also `Account.dataStatus`. Rejects with `TypeError`, before it waits for other
146
+ * calls, if `from` or `to` is no valid `Date` or `from` lies on a day after `to`, and with `FinTsUnsupportedError`,
147
+ * without sending the query, where the parameter data rule it out; the login may have gone out.
115
148
  */
116
149
  getTransactions(account: Account, query?: TransactionQuery): Promise<Transaction[]>;
117
150
  /**
118
- * Ends the bank dialog and releases the connection.
151
+ * Ends the bank dialog, releases the connection and forgets the PIN.
119
152
  *
120
153
  * A running call stops at its next step, also while it waits for a TAN, an app approval or a selection, and fails with
121
- * `FinTsStateError`, as do all later calls. A request already on its way is awaited, at most for the transport's
122
- * timeout.
154
+ * `FinTsStateError`, as do all later calls. A request already on its way is aborted where the transport supports it,
155
+ * as `HttpTransport` does: the call fails with `FinTsTransportError` then, as after a broken connection, and an aborted
156
+ * login counts as one whose answer was lost. Another transport is awaited, at most for its timeout; after the
157
+ * request, the call sends nothing but the end of its dialogs.
123
158
  */
124
159
  close(): Promise<void>;
125
160
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,+EAA+E;AAC/E,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,UAAU,CAAC;AAEvD,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAEnF,+DAA+D;AAC/D,MAAM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BAAsB,GAAG,SAAS,CAAC;IAE1D,8GAA8G;IAC9G,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/C,wEAAwE;IACxE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/C;;;;;OAKG;IACH,eAAe,CAAC,gBAAgB,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7E;;;;;;;;OAQG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C,wEAAwE;IACxE,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjC;;;;OAIG;IACH,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAEtC,4CAA4C;IAC5C,WAAW,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAEpC,sFAAsF;IACtF,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAElC;;;;;;;;OAQG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/C;;;;;;;;OAQG;IACH,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAEpF;;;;;;;;OAQG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
@@ -1,10 +1,13 @@
1
- /** Numeric country code of Germany (ISO 3166), where FinTS banks are. */
1
+ /**
2
+ * The country code FinTS gives Germany, where FinTS banks are: the ISO 3166 code of the Federal Republic before 1990,
3
+ * not today's `276`.
4
+ */
2
5
  export declare const defaultCountryCode = "280";
3
6
  /** What `FinTsConfig` takes. */
4
7
  export interface FinTsConfigInit {
5
- /** The bank's FinTS PIN/TAN endpoint; must be https. */
8
+ /** The bank's FinTS PIN/TAN endpoint; must be https, without user name or password. */
6
9
  url: string | URL;
7
- /** German bank code (BLZ). */
10
+ /** Bank code: for a German bank its BLZ, eight digits. */
8
11
  bankCode: string;
9
12
  /** Login name (Benutzerkennung / Legitimations-ID). */
10
13
  userId: string;
@@ -14,7 +17,7 @@ export interface FinTsConfigInit {
14
17
  productId: string;
15
18
  /** Version of the app as registered with the product; at most five characters. `1.0` by default. */
16
19
  productVersion?: string;
17
- /** Numeric country code of the bank, `280` (Germany) by default. */
20
+ /** Country code of the bank, three digits: `280`, the default, for Germany. */
18
21
  countryCode?: string;
19
22
  /**
20
23
  * Allows plain http for the loopback addresses `localhost`, `127.x.x.x` and `::1`, for tests against a local server.
@@ -25,9 +28,9 @@ export interface FinTsConfigInit {
25
28
  }
26
29
  /** Connection and login data for one bank user. */
27
30
  export declare class FinTsConfig {
28
- /** Numeric country code of Germany (ISO 3166), where FinTS banks are. */
31
+ /** The country code FinTS gives Germany, where FinTS banks are: `280`, not today's ISO 3166 code `276`. */
29
32
  static readonly defaultCountryCode = "280";
30
- readonly url: URL;
33
+ private readonly href;
31
34
  readonly bankCode: string;
32
35
  readonly userId: string;
33
36
  private readonly explicitCustomerId;
@@ -36,24 +39,33 @@ export declare class FinTsConfig {
36
39
  readonly countryCode: string;
37
40
  readonly allowInsecureUrl: boolean;
38
41
  /**
39
- * Throws `TypeError` if `url` is not a valid URL, has no host or is not https, unless `allowInsecureUrl` is set and
40
- * `url` is a loopback address, and if a login detail or the product is empty: the bank would refuse the login.
42
+ * Throws `TypeError` if `url` is not a valid URL, has no host, holds a user name or password, or is not https, unless
43
+ * `allowInsecureUrl` is set and `url` is a loopback address. Throws as well where the bank would refuse the login: for
44
+ * a login or product detail that is empty, has characters FinTS 3.0 cannot send (it uses ISO 8859-1, so `€` and most
45
+ * non-Latin letters are not possible) or is longer than its field (30 characters for the bank code, 25 for the
46
+ * product ID, 5 for its version), for a country code of other than three digits, and for a German bank code of other
47
+ * than eight. The message leaves out the value.
48
+ *
49
+ * Drops leading and trailing blanks of the login details and the product, as FinTS sends them without (Formals
50
+ * B.4.1): `'alice '` is the user `alice`, also for a saved state.
41
51
  */
42
52
  constructor(init: FinTsConfigInit);
53
+ /**
54
+ * The bank's FinTS PIN/TAN endpoint, as checked by the constructor. A new `URL` on each access, so that changing one
55
+ * cannot change where the client posts the PIN.
56
+ */
57
+ get url(): URL;
43
58
  /** Customer ID; defaults to `userId`. */
44
59
  get customerId(): string;
45
60
  }
61
+ /** `text`, unless it has characters FinTS 3.0 cannot send (ISO 8859-1 only); the message leaves out the value. */
62
+ export declare function requireLatin1(text: string, name: string): string;
46
63
  /** The host of `url` without the brackets of an IPv6 address, as `URL` writes it. */
47
64
  export declare function hostOf(url: URL): string;
48
65
  /**
49
- * Throws `TypeError` unless `url` names a host and uses https: the PIN travels with every message.
50
- *
51
- * With `allowInsecure`, http is accepted for loopback hosts only.
52
- */
53
- export declare function requireSecureUrl(url: URL, allowInsecure?: boolean): void;
54
- /**
55
- * Throws `TypeError` for an empty PIN, which the bank would count as a failed attempt, and for one with leading or
56
- * trailing blanks: FinTS values carry none (Formals B.4.1), so such a PIN could only go out changed.
66
+ * `pin`, unless FinTS 3.0 cannot send it: throws `TypeError` for an empty PIN, which the bank would count as a failed
67
+ * attempt, for one with leading or trailing blanks, which would go out without them since FinTS values carry none
68
+ * (Formals B.4.1), and for one with characters outside ISO 8859-1.
57
69
  *
58
70
  * The message leaves out the value.
59
71
  */
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC,gCAAgC;AAChC,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAClB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,MAAM,EAAE,MAAM,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I,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,qFAAqF;AACrF,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAGvC;AAeD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAUpG"}
@@ -1,11 +1,19 @@
1
1
  import { invalidArgument } from '../util/errors.js';
2
- /** Numeric country code of Germany (ISO 3166), where FinTS banks are. */
2
+ import { isLatin1 } from '../util/text.js';
3
+ /**
4
+ * The country code FinTS gives Germany, where FinTS banks are: the ISO 3166 code of the Federal Republic before 1990,
5
+ * not today's `276`.
6
+ */
3
7
  export const defaultCountryCode = '280';
8
+ /** Longest bank code (Kreditinstitutscode), product ID (Produktbezeichnung) and product version FinTS 3.0 takes. */
9
+ const maxBankCodeLength = 30;
10
+ const maxProductIdLength = 25;
11
+ const maxProductVersionLength = 5;
4
12
  /** Connection and login data for one bank user. */
5
13
  export class FinTsConfig {
6
- /** Numeric country code of Germany (ISO 3166), where FinTS banks are. */
14
+ /** The country code FinTS gives Germany, where FinTS banks are: `280`, not today's ISO 3166 code `276`. */
7
15
  static defaultCountryCode = defaultCountryCode;
8
- url;
16
+ href;
9
17
  bankCode;
10
18
  userId;
11
19
  explicitCustomerId;
@@ -14,8 +22,15 @@ export class FinTsConfig {
14
22
  countryCode;
15
23
  allowInsecureUrl;
16
24
  /**
17
- * Throws `TypeError` if `url` is not a valid URL, has no host or is not https, unless `allowInsecureUrl` is set and
18
- * `url` is a loopback address, and if a login detail or the product is empty: the bank would refuse the login.
25
+ * Throws `TypeError` if `url` is not a valid URL, has no host, holds a user name or password, or is not https, unless
26
+ * `allowInsecureUrl` is set and `url` is a loopback address. Throws as well where the bank would refuse the login: for
27
+ * a login or product detail that is empty, has characters FinTS 3.0 cannot send (it uses ISO 8859-1, so `€` and most
28
+ * non-Latin letters are not possible) or is longer than its field (30 characters for the bank code, 25 for the
29
+ * product ID, 5 for its version), for a country code of other than three digits, and for a German bank code of other
30
+ * than eight. The message leaves out the value.
31
+ *
32
+ * Drops leading and trailing blanks of the login details and the product, as FinTS sends them without (Formals
33
+ * B.4.1): `'alice '` is the user `alice`, also for a saved state.
19
34
  */
20
35
  constructor(init) {
21
36
  // `URL` would read `https:bank` and `https:///bank` as the host `bank`; such a URL is a mistake, not a host.
@@ -29,31 +44,52 @@ export class FinTsConfig {
29
44
  catch {
30
45
  throw invalidArgument('Not a valid URL', 'url');
31
46
  }
32
- this.url = url;
33
- this.bankCode = init.bankCode;
34
- this.userId = init.userId;
35
- this.explicitCustomerId = init.customerId;
36
- this.productId = init.productId;
37
- this.productVersion = init.productVersion ?? '1.0';
38
- this.countryCode = init.countryCode ?? defaultCountryCode;
47
+ this.href = url.href;
39
48
  this.allowInsecureUrl = init.allowInsecureUrl ?? false;
40
49
  requireSecureUrl(url, this.allowInsecureUrl);
41
- requireNotBlank(this.bankCode, 'bankCode');
42
- requireNotBlank(this.userId, 'userId');
43
- if (this.explicitCustomerId !== undefined)
44
- requireNotBlank(this.explicitCustomerId, 'customerId');
45
- requireNotBlank(this.productId, 'productId');
46
- requireNotBlank(this.productVersion, 'productVersion');
47
- requireNotBlank(this.countryCode, 'countryCode');
50
+ this.countryCode = requireValue(init.countryCode ?? defaultCountryCode, 'countryCode');
51
+ if (!/^\d{3}$/.test(this.countryCode)) {
52
+ throw invalidArgument('Must be three digits, 280 for Germany', 'countryCode');
53
+ }
54
+ this.bankCode = requireValue(init.bankCode, 'bankCode', maxBankCodeLength);
55
+ if (this.countryCode === defaultCountryCode && !/^\d{8}$/.test(this.bankCode)) {
56
+ throw invalidArgument('A German bank code (BLZ) has eight digits', 'bankCode');
57
+ }
58
+ this.userId = requireValue(init.userId, 'userId');
59
+ this.explicitCustomerId = init.customerId === undefined ? undefined : requireValue(init.customerId, 'customerId');
60
+ this.productId = requireValue(init.productId, 'productId', maxProductIdLength);
61
+ this.productVersion = requireValue(init.productVersion ?? '1.0', 'productVersion', maxProductVersionLength);
62
+ }
63
+ /**
64
+ * The bank's FinTS PIN/TAN endpoint, as checked by the constructor. A new `URL` on each access, so that changing one
65
+ * cannot change where the client posts the PIN.
66
+ */
67
+ get url() {
68
+ return new URL(this.href);
48
69
  }
49
70
  /** Customer ID; defaults to `userId`. */
50
71
  get customerId() {
51
72
  return this.explicitCustomerId ?? this.userId;
52
73
  }
53
74
  }
54
- function requireNotBlank(value, name) {
55
- if (value.trim() === '')
75
+ /**
76
+ * `value` without leading and trailing blanks; throws `TypeError` if nothing is left, or what is left is not sendable
77
+ * (`requireLatin1`) or longer than `maxLength`: cut short, a value would be one the bank does not know.
78
+ */
79
+ function requireValue(value, name, maxLength = Number.POSITIVE_INFINITY) {
80
+ const trimmed = value.trim();
81
+ if (trimmed === '')
56
82
  throw invalidArgument('Must not be empty', name);
83
+ requireLatin1(trimmed, name);
84
+ if (trimmed.length > maxLength)
85
+ throw invalidArgument(`At most ${maxLength} characters in FinTS 3.0`, name);
86
+ return trimmed;
87
+ }
88
+ /** `text`, unless it has characters FinTS 3.0 cannot send (ISO 8859-1 only); the message leaves out the value. */
89
+ export function requireLatin1(text, name) {
90
+ if (!isLatin1(text))
91
+ throw invalidArgument('Contains characters FinTS 3.0 cannot send (ISO 8859-1 only)', name);
92
+ return text;
57
93
  }
58
94
  /** The host of `url` without the brackets of an IPv6 address, as `URL` writes it. */
59
95
  export function hostOf(url) {
@@ -63,18 +99,22 @@ export function hostOf(url) {
63
99
  /**
64
100
  * Throws `TypeError` unless `url` names a host and uses https: the PIN travels with every message.
65
101
  *
66
- * With `allowInsecure`, http is accepted for loopback hosts only.
102
+ * With `allowInsecure`, http is accepted for loopback hosts only. Throws as well for a user name or password in `url`:
103
+ * `fetch` refuses such a URL, with the whole URL in its error message. The message leaves them out.
67
104
  */
68
- export function requireSecureUrl(url, allowInsecure = false) {
105
+ function requireSecureUrl(url, allowInsecure = false) {
69
106
  if (hostOf(url) === '')
70
107
  throw invalidArgument('The URL has no host', 'url');
108
+ if (url.username !== '' || url.password !== '')
109
+ throw invalidArgument('The URL must not contain credentials', 'url');
71
110
  const loopbackHttp = allowInsecure && url.protocol === 'http:' && isLoopback(hostOf(url));
72
111
  if (url.protocol !== 'https:' && !loopbackHttp)
73
112
  throw invalidArgument('PIN/TAN requires an https URL', 'url');
74
113
  }
75
114
  /**
76
- * Throws `TypeError` for an empty PIN, which the bank would count as a failed attempt, and for one with leading or
77
- * trailing blanks: FinTS values carry none (Formals B.4.1), so such a PIN could only go out changed.
115
+ * `pin`, unless FinTS 3.0 cannot send it: throws `TypeError` for an empty PIN, which the bank would count as a failed
116
+ * attempt, for one with leading or trailing blanks, which would go out without them since FinTS values carry none
117
+ * (Formals B.4.1), and for one with characters outside ISO 8859-1.
78
118
  *
79
119
  * The message leaves out the value.
80
120
  */
@@ -83,7 +123,7 @@ export function requirePin(pin) {
83
123
  throw invalidArgument('The PIN is empty', 'pin');
84
124
  if (pin.trim() !== pin)
85
125
  throw invalidArgument('The PIN begins or ends with a blank', 'pin');
86
- return pin;
126
+ return requireLatin1(pin, 'pin');
87
127
  }
88
128
  /**
89
129
  * Throws `TypeError` if `pin` is shorter than `min` or longer than `max` characters, the bank's limits: the bank would
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,yEAAyE;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AA0BxC,mDAAmD;AACnD,MAAM,OAAO,WAAW;IACtB,yEAAyE;IACzE,MAAM,CAAU,kBAAkB,GAAG,kBAAkB,CAAC;IAE/C,GAAG,CAAM;IACT,QAA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,YAAY,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChB,MAAM,eAAe,CAAC,0BAA0B,KAAK,aAAa,EAAE,KAAK,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED,MAAM,eAAe,GAAG,+CAA+C,CAAC;AAExE;;;GAGG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,KAAK,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9E,CAAC"}
@@ -1,54 +1,89 @@
1
1
  import { type FinTsFeedback } from './feedback.js';
2
- /** Base class of all errors the client raises about the bank and its data. */
2
+ /**
3
+ * Base class of all errors the client raises about the bank and its data.
4
+ *
5
+ * Each error class states its `name`: a minifier renames classes, and `constructor.name` would show a meaningless one.
6
+ */
3
7
  export declare abstract class FinTsError extends Error {
4
- protected constructor(name: string, message: string, cause?: unknown);
8
+ abstract name: string;
5
9
  }
6
- /** The connection to the bank failed or returned an HTTP error. */
10
+ /**
11
+ * The connection to the bank failed or returned an HTTP error.
12
+ *
13
+ * It carries no `cause`: the transport's own error may hold the message it was sending, PIN and TAN included.
14
+ */
7
15
  export declare class FinTsTransportError extends FinTsError {
8
- /** The HTTP status code of the response, `undefined` if there was none, for example after a timeout. */
16
+ name: string;
17
+ /**
18
+ * The HTTP status code of the bank's answer, `undefined` where none came, for example after a timeout; the client
19
+ * acts on it (`FinTsTransport.post`).
20
+ */
9
21
  readonly statusCode: number | undefined;
10
22
  constructor(message: string, options?: {
11
23
  statusCode?: number;
12
- cause?: unknown;
13
24
  });
14
25
  }
15
26
  /** The bank's response could not be understood. */
16
27
  export declare class FinTsProtocolError extends FinTsError {
17
- constructor(message: string);
28
+ name: string;
18
29
  }
19
30
  /** The bank does not offer the requested business transaction. */
20
31
  export declare class FinTsUnsupportedError extends FinTsError {
21
- constructor(message: string);
32
+ name: string;
22
33
  }
23
34
  /**
24
- * The bank rejected the request; `feedback` holds all return codes.
35
+ * The client has no TAN method or medium to log in with: the method in use needs a TAN medium the client could not
36
+ * learn, or the bank offers the user only TAN methods the client cannot run. Pass a medium to
37
+ * `FinTsClient.selectTanMethod`, or choose another method.
25
38
  *
26
- * After a refused login every later call that would send the PIN fails with the same error, without contacting the
27
- * bank; create a new client to try again. The README tells which errors refuse a login.
39
+ * The client does not send a login the bank would refuse for it, but the steps before, such as the synchronization or
40
+ * the lookup of the TAN media, may have gone out.
28
41
  */
42
+ export declare class FinTsTanSetupError extends FinTsError {
43
+ name: string;
44
+ }
45
+ /** The bank rejected the request; `feedback` holds all return codes. A refused login is a `FinTsLoginRefusedError`. */
29
46
  export declare class FinTsBankError extends FinTsError {
47
+ name: string;
30
48
  /** All return codes of the response, warnings and successes included. */
31
49
  readonly feedback: readonly FinTsFeedback[];
32
50
  /** A rejection with the return codes in `feedback`; `message` defaults to the errors among them. */
33
- constructor(feedback: readonly FinTsFeedback[], message?: string, name?: string);
51
+ constructor(feedback: readonly FinTsFeedback[], message?: string);
34
52
  /** The return codes of `feedback`. */
35
53
  get codes(): string[];
36
54
  }
37
- /** Wrong or blocked PIN, a refused login as `FinTsBankError` describes it. */
38
- export declare class FinTsPinError extends FinTsBankError {
39
- constructor(feedback: readonly FinTsFeedback[]);
55
+ /**
56
+ * The bank refused the login, so the client sends the PIN no more: every later call that would send it fails with this
57
+ * error without contacting the bank, also in a client restored from the saved state, until
58
+ * `FinTsClient.clearLoginRefusal` takes a PIN the user has entered anew; for good where the bank has changed the login
59
+ * data (`FinTsLoginDataChangedError`).
60
+ *
61
+ * Banks lock the access after a few failed logins, and a return code does not always tell whether the PIN was the
62
+ * reason, so any error in the answer to a login refuses it, also one that ends the dialog, and so does a wrong PIN
63
+ * wherever the bank reports it. Only where the bank names a reason the client can take care of, another TAN method or a
64
+ * new customer system ID, does the same call log in once more, for each reason once. The client refuses the login
65
+ * itself where it could not read the answers to two logins in a row, which the bank may have counted as failed
66
+ * attempts; `feedback` is empty then.
67
+ */
68
+ export declare class FinTsLoginRefusedError extends FinTsBankError {
69
+ name: string;
70
+ }
71
+ /** Wrong or blocked PIN. */
72
+ export declare class FinTsPinError extends FinTsLoginRefusedError {
73
+ name: string;
40
74
  }
41
75
  /** Invalid, expired or rejected TAN, as the bank reports it in answer to a TAN or to an approval status request. */
42
76
  export declare class FinTsTanError extends FinTsBankError {
43
- constructor(feedback: readonly FinTsFeedback[]);
77
+ name: string;
44
78
  }
45
79
  /**
46
80
  * The bank has changed the user's login data and expects the new ones from now on (return code 3072).
47
81
  *
48
- * The client has ended the dialog, and every later call fails with this error. Create a new client with the new data; a
49
- * `loginName` replaces user ID and customer ID: pass it as `userId`, without a customer ID.
82
+ * The client has ended the dialog, where the bank opened one, and logs in with the old data no more. Create a new
83
+ * client with the new data; a `loginName` replaces user ID and customer ID: pass it as `userId`, without a customer ID.
50
84
  */
51
- export declare class FinTsLoginDataChangedError extends FinTsBankError {
85
+ export declare class FinTsLoginDataChangedError extends FinTsLoginRefusedError {
86
+ name: string;
52
87
  constructor(feedback: readonly FinTsFeedback[]);
53
88
  /** The new user ID (Benutzerkennung); `undefined` where the bank names none. */
54
89
  get userId(): string | undefined;
@@ -58,16 +93,24 @@ export declare class FinTsLoginDataChangedError extends FinTsBankError {
58
93
  get loginName(): string | undefined;
59
94
  private parameter;
60
95
  }
61
- /** The bank ended the dialog, for example after a timeout. */
96
+ /**
97
+ * The bank ended the dialog, for example after a timeout; the next call logs in anew. Where the bank ends the dialog
98
+ * in answer to a login, the call fails with `FinTsLoginRefusedError` instead.
99
+ */
62
100
  export declare class FinTsDialogAbortedError extends FinTsBankError {
63
- constructor(feedback: readonly FinTsFeedback[]);
101
+ name: string;
64
102
  }
65
103
  /** The user cancelled the TAN entry or the approval in the banking app. */
66
104
  export declare class FinTsTanCancelledError extends FinTsError {
105
+ name: string;
67
106
  constructor();
68
107
  }
69
- /** The user did not approve in the banking app within the bank's polling limit. */
108
+ /**
109
+ * The user did not approve in the banking app in time: within the status requests the bank allows, 60 where it states
110
+ * none, and 10 minutes of polling at most.
111
+ */
70
112
  export declare class FinTsDecoupledTimeoutError extends FinTsError {
113
+ name: string;
71
114
  constructor();
72
115
  }
73
116
  /**
@@ -76,8 +119,10 @@ export declare class FinTsDecoupledTimeoutError extends FinTsError {
76
119
  * It does not extend `FinTsError`: it tells about the app's use of the client, not about the bank.
77
120
  */
78
121
  export declare class FinTsStateError extends Error {
79
- constructor(message: string);
122
+ name: string;
80
123
  }
124
+ /** The error of whatever a closed client is asked to do. */
125
+ export declare function clientClosedError(): FinTsStateError;
81
126
  /**
82
127
  * The most specific error for the errors in `feedback`, the answer to a message that `completesApproval` or not.
83
128
  *
@@ -86,6 +131,23 @@ export declare class FinTsStateError extends Error {
86
131
  * for a wrong TAN, after which it would send the PIN again.
87
132
  */
88
133
  export declare function bankErrorFor(feedback: readonly FinTsFeedback[], completesApproval?: boolean): FinTsBankError;
89
- /** Runs `parse` on data from the bank and reports malformed data as `FinTsProtocolError`. */
134
+ /**
135
+ * The refusal of a login whose answer carried `feedback`: `FinTsPinError` for a rejected PIN, else
136
+ * `FinTsLoginDataChangedError` for new login data, also next to other errors, and `FinTsLoginRefusedError` for anything
137
+ * else. The same for a refusal restored from the saved state, which keeps only `feedback`.
138
+ *
139
+ * New login data end the old ones for good, so the session takes care of no other reason the answer names.
140
+ */
141
+ export declare function loginRefusalFor(feedback: readonly FinTsFeedback[]): FinTsLoginRefusedError;
142
+ /**
143
+ * Runs `parse` on data from the bank and reports malformed data as `FinTsProtocolError`, whose message leaves the data
144
+ * out (`FormatError`).
145
+ */
90
146
  export declare function parseBankData<T>(parse: () => T): T;
147
+ /**
148
+ * Runs `lookup`, which only completes data, such as the SEPA account list; `undefined` where the bank rejects it, so
149
+ * that the caller carries on without it. An aborted dialog counts as a rejection: banks end the dialog along with many.
150
+ * A refused login and a rejected TAN fail the call: the user must hear of them.
151
+ */
152
+ export declare function tryLookUp<T>(lookup: () => Promise<T>): Promise<T | undefined>;
91
153
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9E,8EAA8E;AAC9E,8BAAsB,UAAW,SAAQ,KAAK;IAC5C,SAAS,aAAa,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAKrE;AAED,mEAAmE;AACnE,qBAAa,mBAAoB,SAAQ,UAAU;IACjD,wGAAwG;IACxG,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE5B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAIhF;AAED,mDAAmD;AACnD,qBAAa,kBAAmB,SAAQ,UAAU;gBACpC,OAAO,EAAE,MAAM;CAG5B;AAED,kEAAkE;AAClE,qBAAa,qBAAsB,SAAQ,UAAU;gBACvC,OAAO,EAAE,MAAM;CAG5B;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAE5C,oGAAoG;gBACxF,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,SAAmB;IAYzF,sCAAsC;IACtC,IAAI,KAAK,IAAI,MAAM,EAAE,CAEpB;CACF;AAED,8EAA8E;AAC9E,qBAAa,aAAc,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