@coderoftime/fints 0.1.0 → 0.3.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 (289) hide show
  1. package/CHANGELOG.md +519 -1
  2. package/README.md +138 -40
  3. package/dist/client.d.ts +49 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +242 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/core/account.d.ts +46 -7
  8. package/dist/core/account.d.ts.map +1 -1
  9. package/dist/core/account.js +143 -24
  10. package/dist/core/account.js.map +1 -1
  11. package/dist/core/amount.d.ts +15 -4
  12. package/dist/core/amount.d.ts.map +1 -1
  13. package/dist/core/amount.js +46 -9
  14. package/dist/core/amount.js.map +1 -1
  15. package/dist/core/balance.d.ts +4 -0
  16. package/dist/core/balance.d.ts.map +1 -1
  17. package/dist/core/balance.js +11 -5
  18. package/dist/core/balance.js.map +1 -1
  19. package/dist/core/bank-info.d.ts +21 -4
  20. package/dist/core/bank-info.d.ts.map +1 -1
  21. package/dist/core/bank-info.js +26 -5
  22. package/dist/core/bank-info.js.map +1 -1
  23. package/dist/core/client.d.ts +81 -19
  24. package/dist/core/client.d.ts.map +1 -1
  25. package/dist/core/config.d.ts +40 -20
  26. package/dist/core/config.d.ts.map +1 -1
  27. package/dist/core/config.js +85 -30
  28. package/dist/core/config.js.map +1 -1
  29. package/dist/core/errors.d.ts +100 -26
  30. package/dist/core/errors.d.ts.map +1 -1
  31. package/dist/core/errors.js +136 -53
  32. package/dist/core/errors.js.map +1 -1
  33. package/dist/core/feedback.d.ts +11 -1
  34. package/dist/core/feedback.d.ts.map +1 -1
  35. package/dist/core/feedback.js +14 -2
  36. package/dist/core/feedback.js.map +1 -1
  37. package/dist/core/transaction.d.ts +11 -1
  38. package/dist/core/transaction.d.ts.map +1 -1
  39. package/dist/core/transaction.js +21 -4
  40. package/dist/core/transaction.js.map +1 -1
  41. package/dist/core/transport.d.ts +48 -6
  42. package/dist/core/transport.d.ts.map +1 -1
  43. package/dist/core/transport.js +126 -29
  44. package/dist/core/transport.js.map +1 -1
  45. package/dist/formats/camt.d.ts +28 -5
  46. package/dist/formats/camt.d.ts.map +1 -1
  47. package/dist/formats/camt.js +132 -50
  48. package/dist/formats/camt.js.map +1 -1
  49. package/dist/formats/mt940.d.ts +29 -5
  50. package/dist/formats/mt940.d.ts.map +1 -1
  51. package/dist/formats/mt940.js +209 -113
  52. package/dist/formats/mt940.js.map +1 -1
  53. package/dist/formats/readers.d.ts +6 -2
  54. package/dist/formats/readers.d.ts.map +1 -1
  55. package/dist/formats/readers.js +28 -29
  56. package/dist/formats/readers.js.map +1 -1
  57. package/dist/formats/record-budget.d.ts +7 -0
  58. package/dist/formats/record-budget.d.ts.map +1 -0
  59. package/dist/formats/record-budget.js +17 -0
  60. package/dist/formats/record-budget.js.map +1 -0
  61. package/dist/formats/sepa-purpose.d.ts +9 -0
  62. package/dist/formats/sepa-purpose.d.ts.map +1 -1
  63. package/dist/formats/sepa-purpose.js +32 -2
  64. package/dist/formats/sepa-purpose.js.map +1 -1
  65. package/dist/index.d.ts +3 -3
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +2 -2
  68. package/dist/index.js.map +1 -1
  69. package/dist/session/app-approval.d.ts +11 -5
  70. package/dist/session/app-approval.d.ts.map +1 -1
  71. package/dist/session/app-approval.js +23 -12
  72. package/dist/session/app-approval.js.map +1 -1
  73. package/dist/session/dialog-runner.d.ts +11 -11
  74. package/dist/session/dialog-runner.d.ts.map +1 -1
  75. package/dist/session/dialog-runner.js +34 -19
  76. package/dist/session/dialog-runner.js.map +1 -1
  77. package/dist/session/login-guard.d.ts +54 -49
  78. package/dist/session/login-guard.d.ts.map +1 -1
  79. package/dist/session/login-guard.js +170 -83
  80. package/dist/session/login-guard.js.map +1 -1
  81. package/dist/session/sepa-accounts.d.ts +20 -14
  82. package/dist/session/sepa-accounts.d.ts.map +1 -1
  83. package/dist/session/sepa-accounts.js +62 -46
  84. package/dist/session/sepa-accounts.js.map +1 -1
  85. package/dist/session/session-setup.d.ts +41 -24
  86. package/dist/session/session-setup.d.ts.map +1 -1
  87. package/dist/session/session-setup.js +106 -63
  88. package/dist/session/session-setup.js.map +1 -1
  89. package/dist/session/session-state.d.ts +10 -6
  90. package/dist/session/session-state.d.ts.map +1 -1
  91. package/dist/session/session-state.js +72 -18
  92. package/dist/session/session-state.js.map +1 -1
  93. package/dist/session/signed-dialog.d.ts +83 -0
  94. package/dist/session/signed-dialog.d.ts.map +1 -0
  95. package/dist/session/signed-dialog.js +185 -0
  96. package/dist/session/signed-dialog.js.map +1 -0
  97. package/dist/session/tan-selection.d.ts +26 -18
  98. package/dist/session/tan-selection.d.ts.map +1 -1
  99. package/dist/session/tan-selection.js +44 -33
  100. package/dist/session/tan-selection.js.map +1 -1
  101. package/dist/session/user-prompts.d.ts +14 -5
  102. package/dist/session/user-prompts.d.ts.map +1 -1
  103. package/dist/session/user-prompts.js +53 -18
  104. package/dist/session/user-prompts.js.map +1 -1
  105. package/dist/tan/challenge.d.ts +47 -24
  106. package/dist/tan/challenge.d.ts.map +1 -1
  107. package/dist/tan/challenge.js +56 -51
  108. package/dist/tan/challenge.js.map +1 -1
  109. package/dist/tan/flicker.d.ts +11 -1
  110. package/dist/tan/flicker.d.ts.map +1 -1
  111. package/dist/tan/flicker.js +70 -24
  112. package/dist/tan/flicker.js.map +1 -1
  113. package/dist/tan/tan-image.d.ts +6 -2
  114. package/dist/tan/tan-image.d.ts.map +1 -1
  115. package/dist/tan/tan-image.js +14 -6
  116. package/dist/tan/tan-image.js.map +1 -1
  117. package/dist/tan/tan-models.d.ts +14 -2
  118. package/dist/tan/tan-models.d.ts.map +1 -1
  119. package/dist/tan/tan-models.js +24 -7
  120. package/dist/tan/tan-models.js.map +1 -1
  121. package/dist/util/arguments.d.ts +13 -0
  122. package/dist/util/arguments.d.ts.map +1 -0
  123. package/dist/util/arguments.js +40 -0
  124. package/dist/util/arguments.js.map +1 -0
  125. package/dist/util/async.d.ts +4 -3
  126. package/dist/util/async.d.ts.map +1 -1
  127. package/dist/util/async.js +6 -7
  128. package/dist/util/async.js.map +1 -1
  129. package/dist/util/bytes.d.ts +3 -4
  130. package/dist/util/bytes.d.ts.map +1 -1
  131. package/dist/util/bytes.js +13 -21
  132. package/dist/util/bytes.js.map +1 -1
  133. package/dist/util/call-context.d.ts.map +1 -1
  134. package/dist/util/call-context.js +3 -2
  135. package/dist/util/call-context.js.map +1 -1
  136. package/dist/util/dates.d.ts +6 -20
  137. package/dist/util/dates.d.ts.map +1 -1
  138. package/dist/util/dates.js +58 -28
  139. package/dist/util/dates.js.map +1 -1
  140. package/dist/util/errors.d.ts +13 -3
  141. package/dist/util/errors.d.ts.map +1 -1
  142. package/dist/util/errors.js +19 -6
  143. package/dist/util/errors.js.map +1 -1
  144. package/dist/util/immutable-map.d.ts +5 -2
  145. package/dist/util/immutable-map.d.ts.map +1 -1
  146. package/dist/util/immutable-map.js +15 -12
  147. package/dist/util/immutable-map.js.map +1 -1
  148. package/dist/util/inspect.d.ts +11 -0
  149. package/dist/util/inspect.d.ts.map +1 -0
  150. package/dist/util/inspect.js +14 -0
  151. package/dist/util/inspect.js.map +1 -0
  152. package/dist/util/json.d.ts +4 -0
  153. package/dist/util/json.d.ts.map +1 -1
  154. package/dist/util/json.js +18 -0
  155. package/dist/util/json.js.map +1 -1
  156. package/dist/util/text.d.ts +38 -5
  157. package/dist/util/text.d.ts.map +1 -1
  158. package/dist/util/text.js +90 -16
  159. package/dist/util/text.js.map +1 -1
  160. package/dist/util/xml.d.ts +9 -6
  161. package/dist/util/xml.d.ts.map +1 -1
  162. package/dist/util/xml.js +129 -56
  163. package/dist/util/xml.js.map +1 -1
  164. package/dist/v3/account-extension.d.ts.map +1 -1
  165. package/dist/v3/account-extension.js +7 -10
  166. package/dist/v3/account-extension.js.map +1 -1
  167. package/dist/v3/bank-connection.d.ts +54 -0
  168. package/dist/v3/bank-connection.d.ts.map +1 -0
  169. package/dist/v3/bank-connection.js +118 -0
  170. package/dist/v3/bank-connection.js.map +1 -0
  171. package/dist/v3/dialog.d.ts +84 -46
  172. package/dist/v3/dialog.d.ts.map +1 -1
  173. package/dist/v3/dialog.js +174 -60
  174. package/dist/v3/dialog.js.map +1 -1
  175. package/dist/v3/message.d.ts +32 -11
  176. package/dist/v3/message.d.ts.map +1 -1
  177. package/dist/v3/message.js +144 -83
  178. package/dist/v3/message.js.map +1 -1
  179. package/dist/v3/parameter-store.d.ts +111 -0
  180. package/dist/v3/parameter-store.d.ts.map +1 -0
  181. package/dist/v3/parameter-store.js +197 -0
  182. package/dist/v3/parameter-store.js.map +1 -0
  183. package/dist/v3/parameters.d.ts +44 -17
  184. package/dist/v3/parameters.d.ts.map +1 -1
  185. package/dist/v3/parameters.js +136 -60
  186. package/dist/v3/parameters.js.map +1 -1
  187. package/dist/v3/protocol.d.ts +50 -50
  188. package/dist/v3/protocol.d.ts.map +1 -1
  189. package/dist/v3/protocol.js +91 -210
  190. package/dist/v3/protocol.js.map +1 -1
  191. package/dist/v3/queries.d.ts +51 -0
  192. package/dist/v3/queries.d.ts.map +1 -0
  193. package/dist/v3/queries.js +128 -0
  194. package/dist/v3/queries.js.map +1 -0
  195. package/dist/v3/segments.d.ts +43 -19
  196. package/dist/v3/segments.d.ts.map +1 -1
  197. package/dist/v3/segments.js +84 -33
  198. package/dist/v3/segments.js.map +1 -1
  199. package/dist/v3/syntax.d.ts +68 -13
  200. package/dist/v3/syntax.d.ts.map +1 -1
  201. package/dist/v3/syntax.js +183 -102
  202. package/dist/v3/syntax.js.map +1 -1
  203. package/package.json +10 -6
  204. package/src/client.ts +293 -0
  205. package/src/core/account.ts +153 -24
  206. package/src/core/amount.ts +45 -10
  207. package/src/core/balance.ts +12 -5
  208. package/src/core/bank-info.ts +29 -5
  209. package/src/core/client.ts +83 -19
  210. package/src/core/config.ts +95 -35
  211. package/src/core/errors.ts +148 -54
  212. package/src/core/feedback.ts +16 -2
  213. package/src/core/transaction.ts +22 -4
  214. package/src/core/transport.ts +153 -32
  215. package/src/formats/camt.ts +153 -45
  216. package/src/formats/mt940.ts +244 -122
  217. package/src/formats/readers.ts +28 -31
  218. package/src/formats/record-budget.ts +18 -0
  219. package/src/formats/sepa-purpose.ts +29 -2
  220. package/src/index.ts +4 -2
  221. package/src/session/app-approval.ts +51 -38
  222. package/src/session/dialog-runner.ts +61 -31
  223. package/src/session/login-guard.ts +189 -87
  224. package/src/session/sepa-accounts.ts +63 -45
  225. package/src/session/session-setup.ts +105 -68
  226. package/src/session/session-state.ts +74 -23
  227. package/src/session/signed-dialog.ts +222 -0
  228. package/src/session/tan-selection.ts +50 -39
  229. package/src/session/user-prompts.ts +62 -18
  230. package/src/tan/challenge.ts +87 -64
  231. package/src/tan/flicker.ts +72 -23
  232. package/src/tan/tan-image.ts +15 -6
  233. package/src/tan/tan-models.ts +26 -7
  234. package/src/util/arguments.ts +40 -0
  235. package/src/util/async.ts +10 -9
  236. package/src/util/bytes.ts +14 -20
  237. package/src/util/call-context.ts +3 -2
  238. package/src/util/dates.ts +64 -33
  239. package/src/util/errors.ts +22 -6
  240. package/src/util/immutable-map.ts +15 -12
  241. package/src/util/inspect.ts +14 -0
  242. package/src/util/json.ts +16 -0
  243. package/src/util/text.ts +87 -15
  244. package/src/util/xml.ts +130 -52
  245. package/src/v3/account-extension.ts +7 -12
  246. package/src/v3/bank-connection.ts +126 -0
  247. package/src/v3/dialog.ts +186 -92
  248. package/src/v3/message.ts +140 -79
  249. package/src/v3/parameter-store.ts +226 -0
  250. package/src/v3/parameters.ts +166 -66
  251. package/src/v3/protocol.ts +103 -253
  252. package/src/v3/queries.ts +198 -0
  253. package/src/v3/segments.ts +86 -31
  254. package/src/v3/syntax.ts +172 -93
  255. package/dist/session/bank-connection.d.ts +0 -28
  256. package/dist/session/bank-connection.d.ts.map +0 -1
  257. package/dist/session/bank-connection.js +0 -48
  258. package/dist/session/bank-connection.js.map +0 -1
  259. package/dist/session/parameter-data.d.ts +0 -83
  260. package/dist/session/parameter-data.d.ts.map +0 -1
  261. package/dist/session/parameter-data.js +0 -68
  262. package/dist/session/parameter-data.js.map +0 -1
  263. package/dist/session/pin-tan-client.d.ts +0 -54
  264. package/dist/session/pin-tan-client.d.ts.map +0 -1
  265. package/dist/session/pin-tan-client.js +0 -153
  266. package/dist/session/pin-tan-client.js.map +0 -1
  267. package/dist/session/pin-tan-dialog.d.ts +0 -71
  268. package/dist/session/pin-tan-dialog.d.ts.map +0 -1
  269. package/dist/session/pin-tan-dialog.js +0 -124
  270. package/dist/session/pin-tan-dialog.js.map +0 -1
  271. package/dist/session/protocol.d.ts +0 -209
  272. package/dist/session/protocol.d.ts.map +0 -1
  273. package/dist/session/protocol.js +0 -75
  274. package/dist/session/protocol.js.map +0 -1
  275. package/dist/session/response-handler.d.ts +0 -48
  276. package/dist/session/response-handler.d.ts.map +0 -1
  277. package/dist/session/response-handler.js +0 -121
  278. package/dist/session/response-handler.js.map +0 -1
  279. package/dist/v3/client.d.ts +0 -24
  280. package/dist/v3/client.d.ts.map +0 -1
  281. package/dist/v3/client.js +0 -16
  282. package/dist/v3/client.js.map +0 -1
  283. package/src/session/bank-connection.ts +0 -51
  284. package/src/session/parameter-data.ts +0 -137
  285. package/src/session/pin-tan-client.ts +0 -186
  286. package/src/session/pin-tan-dialog.ts +0 -160
  287. package/src/session/protocol.ts +0 -311
  288. package/src/session/response-handler.ts +0 -130
  289. package/src/v3/client.ts +0 -29
@@ -1 +1 @@
1
- {"version":3,"file":"session-setup.js","sourceRoot":"","sources":["../../src/session/session-setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAK5D;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAKJ;IACA;IACA;IACA;IAPnB,kFAAkF;IAC1E,oBAA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,KAAK,EAAE,MAAM,EAAE,EAAE;YACnD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;YAC/D,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IAED,+FAA+F;IACvF,KAAK,CAAC,IAAI,CAAI,MAAoB,EAAE,GAAyC;QACnF,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,CAAC;YACH,OAAO,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;CACF"}
@@ -1,15 +1,19 @@
1
1
  import { Account } from '../core/account.js';
2
2
  import { type JsonObject } from '../util/json.js';
3
- import type { BankResponse, PinTanProtocol } from './protocol.js';
4
- /** The session and the protocol's parameter data as one JSON string, which `restoreSession` reads. */
5
- export declare function saveSession<R extends BankResponse, O>(protocol: PinTanProtocol<R, O>, session: SessionState): string;
3
+ import type { ParameterStore } from '../v3/parameter-store.js';
4
+ import type { LoginGuard } from './login-guard.js';
5
+ /** The session, the parameter data and the guard's refusal as JSON, which `restoreSession` reads. */
6
+ export declare function saveSession(parameters: ParameterStore, guard: LoginGuard, session: SessionState): string;
6
7
  /**
7
- * The session saved in `json`, and the protocol's parameter data restored from it.
8
+ * The session saved in `json`, and the parameter data and the guard's refused login restored from it.
8
9
  *
9
10
  * A missing or damaged state, or one saved for another user, bank, server or protocol version, gives a new session,
10
- * which only costs a new synchronization.
11
+ * which only costs a new synchronization. The refused login and the count of logins whose answer was lost belong to the
12
+ * user at the bank, so they come first: they hold for another server or protocol version as well, and where the rest is
13
+ * damaged; a state saved by fints-ts 0.1 or the Dart package 0.2.0 has neither. A damaged section of their own fails
14
+ * closed: it restores a refusal without return codes, since it may have held one.
11
15
  */
12
- export declare function restoreSession<R extends BankResponse, O>(json: string | undefined, protocol: PinTanProtocol<R, O>): SessionState;
16
+ export declare function restoreSession(json: string | undefined, parameters: ParameterStore, guard: LoginGuard): SessionState;
13
17
  /**
14
18
  * The session data saved between app starts: the allowed TAN methods, the TAN method and medium in use, and the SEPA
15
19
  * account list.
@@ -1 +1 @@
1
- {"version":3,"file":"session-state.d.ts","sourceRoot":"","sources":["../../src/session/session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,OAAO,EAOL,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAQlE,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAQpH;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,EACtD,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,QAAQ,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAC7B,YAAY,CAoBd;AAOD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,mBAAmB,CAAgC;IAC3D,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,iBAAiB,CAAiC;IAC1D,OAAO,CAAC,cAAc,CAAqB;IAE3C,yGAAyG;IACzG,IAAI,cAAc,IAAI,SAAS,MAAM,EAAE,GAAG,SAAS,CAElD;IAED,kDAAkD;IAClD,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC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;AAYD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,mBAAmB,CAAgC;IAC3D,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,iBAAiB,CAAiC;IAC1D,OAAO,CAAC,cAAc,CAAqB;IAE3C,yGAAyG;IACzG,IAAI,cAAc,IAAI,SAAS,MAAM,EAAE,GAAG,SAAS,CAElD;IAED,kDAAkD;IAClD,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,qCAAqC;IACrC,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,uEAAuE;IACvE,sBAAsB,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAIlE;;;OAGG;IACH,YAAY,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAKzE,yDAAyD;IACzD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAI9C,iGAAiG;IACjG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,OAAO,EAAE,GAAG,SAAS;IAI5E,mGAAmG;IACnG,iBAAiB,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAKrF,4EAA4E;IAC5E,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY;IAa/C,gCAAgC;IAChC,MAAM,IAAI,UAAU;CASrB"}
@@ -1,42 +1,55 @@
1
1
  import { Account } from '../core/account.js';
2
2
  import { hostOf } from '../core/config.js';
3
+ import { FinTsFeedback } from '../core/feedback.js';
3
4
  import { FormatError } from '../util/errors.js';
4
- import { isJsonObject, isString, readObject, readOptionalInt, readOptionalList, readOptionalString, } from '../util/json.js';
5
+ import { isJsonObject, isString, readObject, readOptionalInt, readOptionalObject, readOptionalList, readOptionalString, } from '../util/json.js';
5
6
  /** Layout of the saved session; a state of another layout is ignored. */
6
7
  const stateFormat = 1;
7
8
  /** The protocol version the state is for, named as the Dart package names it, so that both read each other's states. */
8
9
  const protocolVersion = 'v300';
9
- /** The session and the protocol's parameter data as one JSON string, which `restoreSession` reads. */
10
- export function saveSession(protocol, session) {
10
+ /** The session, the parameter data and the guard's refusal as JSON, which `restoreSession` reads. */
11
+ export function saveSession(parameters, guard, session) {
11
12
  return JSON.stringify({
12
13
  format: stateFormat,
13
14
  version: protocolVersion,
14
- owner: ownerOf(protocol.config),
15
+ owner: ownerOf(parameters.config),
15
16
  session: session.toJson(),
16
- protocol: protocol.saveState(),
17
+ // Under the key the Dart package reads as well.
18
+ protocol: parameters.saveState(),
19
+ loginGuard: guardStateToJson(guard.saveState()),
17
20
  });
18
21
  }
19
22
  /**
20
- * The session saved in `json`, and the protocol's parameter data restored from it.
23
+ * The session saved in `json`, and the parameter data and the guard's refused login restored from it.
21
24
  *
22
25
  * A missing or damaged state, or one saved for another user, bank, server or protocol version, gives a new session,
23
- * which only costs a new synchronization.
26
+ * which only costs a new synchronization. The refused login and the count of logins whose answer was lost belong to the
27
+ * user at the bank, so they come first: they hold for another server or protocol version as well, and where the rest is
28
+ * damaged; a state saved by fints-ts 0.1 or the Dart package 0.2.0 has neither. A damaged section of their own fails
29
+ * closed: it restores a refusal without return codes, since it may have held one.
24
30
  */
25
- export function restoreSession(json, protocol) {
31
+ export function restoreSession(json, parameters, guard) {
26
32
  if (json === undefined)
27
33
  return new SessionState();
28
34
  try {
29
35
  const saved = JSON.parse(json);
30
- if (!isJsonObject(saved) || saved.format !== stateFormat || saved.version !== protocolVersion) {
36
+ if (!isJsonObject(saved) || saved.format !== stateFormat)
31
37
  return new SessionState();
32
- }
33
- const owner = readOptionalList(saved, 'owner', isString);
34
- const expected = ownerOf(protocol.config);
35
- if (owner?.length !== expected.length || owner.some((value, i) => value !== expected[i])) {
38
+ // Entries of another type differ like any other value, so that a damaged server entry keeps the refused login.
39
+ const owner = saved.owner ?? [];
40
+ if (!Array.isArray(owner))
41
+ return new SessionState();
42
+ const [server, ...user] = owner;
43
+ const expected = userOf(parameters.config);
44
+ if (user.length !== expected.length || user.some((value, i) => value !== expected[i]))
45
+ return new SessionState();
46
+ const guardState = savedGuardState(saved);
47
+ if (guardState !== undefined)
48
+ guard.restoreState(guardState);
49
+ if (server !== hostOf(parameters.config.url) || saved.version !== protocolVersion)
36
50
  return new SessionState();
37
- }
38
51
  const session = SessionState.fromJson(readObject(saved, 'session'));
39
- protocol.restoreState(readObject(saved, 'protocol'));
52
+ parameters.restoreState(readObject(saved, 'protocol'), session.tanMedium);
40
53
  return session;
41
54
  }
42
55
  catch (error) {
@@ -46,9 +59,13 @@ export function restoreSession(json, protocol) {
46
59
  throw error;
47
60
  }
48
61
  }
49
- /** Whose data a state holds, so that the state of another user or bank is never used. */
62
+ /** Whose data a state holds, so that the state of another user or bank is never used: the server, then `userOf`. */
50
63
  function ownerOf(config) {
51
- return [hostOf(config.url), config.bankCode, config.userId, config.customerId];
64
+ return [hostOf(config.url), ...userOf(config)];
65
+ }
66
+ /** The user at the bank, whom a refused login belongs to. */
67
+ function userOf(config) {
68
+ return [config.bankCode, config.userId, config.customerId];
52
69
  }
53
70
  /**
54
71
  * The session data saved between app starts: the allowed TAN methods, the TAN method and medium in use, and the SEPA
@@ -106,7 +123,9 @@ export class SessionState {
106
123
  state.useTanMethod(readOptionalString(json, 'tanMethod'), readOptionalString(json, 'tanMedium'));
107
124
  if (allowedMethods !== undefined)
108
125
  state.rememberAllowedMethods(allowedMethods);
109
- if (sepaAccounts !== undefined)
126
+ // fints-ts 0.1 and the Dart package 0.2.0 saved an empty list as well, which completes nothing; without it, the
127
+ // list is asked for again.
128
+ if (sepaAccounts !== undefined && sepaAccounts.length > 0)
110
129
  state.cacheSepaAccounts(sepaAccounts, sepaUpdVersion);
111
130
  return state;
112
131
  }
@@ -144,4 +163,39 @@ function accountFromJson(json) {
144
163
  bankCode,
145
164
  });
146
165
  }
166
+ function guardStateToJson(state) {
167
+ return { refusal: state.refusal?.map(feedbackToJson) ?? null, unreadLogins: state.unreadLogins };
168
+ }
169
+ /** The guard's section of `saved`, `undefined` where there is none; a damaged one is a refusal without return codes. */
170
+ function savedGuardState(saved) {
171
+ try {
172
+ const json = readOptionalObject(saved, 'loginGuard');
173
+ return json === undefined ? undefined : guardStateFromJson(json);
174
+ }
175
+ catch (error) {
176
+ if (error instanceof FormatError)
177
+ return { refusal: [], unreadLogins: 0 };
178
+ throw error;
179
+ }
180
+ }
181
+ function guardStateFromJson(json) {
182
+ return {
183
+ refusal: readOptionalList(json, 'refusal', isJsonObject)?.map(feedbackFromJson),
184
+ unreadLogins: readOptionalInt(json, 'unreadLogins') ?? 0,
185
+ };
186
+ }
187
+ function feedbackToJson(f) {
188
+ return { code: f.code, reference: f.reference ?? null, text: f.text, parameters: [...f.parameters] };
189
+ }
190
+ function feedbackFromJson(json) {
191
+ const code = readOptionalString(json, 'code');
192
+ if (code === undefined)
193
+ throw new FormatError('Saved state: return code without code');
194
+ return new FinTsFeedback({
195
+ code,
196
+ reference: readOptionalString(json, 'reference'),
197
+ text: readOptionalString(json, 'text') ?? '',
198
+ parameters: readOptionalList(json, 'parameters', isString) ?? [],
199
+ });
200
+ }
147
201
  //# sourceMappingURL=session-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-state.js","sourceRoot":"","sources":["../../src/session/session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAoB,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,iBAAiB,CAAC;AAGzB,yEAAyE;AACzE,MAAM,WAAW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@ -0,0 +1,83 @@
1
+ import type { FinTs3Dialog } from '../v3/dialog.js';
2
+ import { IncomingMessage3 } from '../v3/message.js';
3
+ import type { ParameterStore } from '../v3/parameter-store.js';
4
+ import type { SegmentSpec } from '../v3/syntax.js';
5
+ import type { LoginGuard } from './login-guard.js';
6
+ import type { SessionState } from './session-state.js';
7
+ import type { UserPrompts } from './user-prompts.js';
8
+ /** The parts of the session that every `SignedDialog` reports to. */
9
+ export interface SessionParts {
10
+ readonly parameters: ParameterStore;
11
+ readonly state: SessionState;
12
+ readonly prompts: UserPrompts;
13
+ readonly guard: LoginGuard;
14
+ }
15
+ /**
16
+ * A dialog signed with the PIN, which settles each answer before it hands it out: it keeps the parameter data of the
17
+ * dialog's opening, passes the notices on, has the `LoginGuard` judge the answer and throws its errors, and completes
18
+ * the approval the bank asks for. The session sends every message signed with the PIN through it, so that the guard
19
+ * judges every answer, that to the dialog's end included.
20
+ */
21
+ export declare class SignedDialog {
22
+ private readonly dialog;
23
+ private readonly session;
24
+ constructor(dialog: FinTs3Dialog, session: SessionParts);
25
+ /** Whether the bank knows this dialog and it has not ended. */
26
+ get isActive(): boolean;
27
+ /** Logs in, which opens the dialog; with `synchronize` the bank also assigns a customer system ID. */
28
+ login(synchronize?: boolean): Promise<IncomingMessage3>;
29
+ /**
30
+ * Logs in, asking strong authentication for `order`, then sends `order` in a message of its own, as for listing the
31
+ * TAN media while no medium is chosen yet (`FinTs3Dialog.startWith`); returns both answers.
32
+ */
33
+ loginWith(order: SegmentSpec): Promise<IncomingMessage3[]>;
34
+ /**
35
+ * Sends `order` and completes the approval the bank asks for. `admitApproval` runs before the user is asked, and
36
+ * refuses the approval by throwing.
37
+ */
38
+ send(order: SegmentSpec, admitApproval?: () => void): Promise<IncomingMessage3>;
39
+ /**
40
+ * Ends the dialog at the bank; does nothing if it is not active. Of the answer only a rejected PIN counts, which the
41
+ * guard judges: the dialog is over either way.
42
+ */
43
+ end(): Promise<void>;
44
+ /**
45
+ * Receives `response`, the answer to a request of `kind`: keeps its parameter data where it answers the `opening` of
46
+ * the dialog, the login or its approval, even alongside errors, since the remedy for a refused login may need them;
47
+ * passes its notices on; and has the guard judge it, then throws its errors, as the refusal of the login where they
48
+ * amount to one.
49
+ */
50
+ private receive;
51
+ /**
52
+ * Sends the login `send` and settles its answer. New login data next to an error in the answer to its approval are
53
+ * retired all the same (`retireLoginData`), although the guard counts that error as no refusal; next to an error in
54
+ * the answer to the login they are its refusal already (`loginRefusalFor`).
55
+ */
56
+ private settleLogin;
57
+ /**
58
+ * Where `response` answers a login, a request of `kind` other than `order`, or its approval with new login data,
59
+ * retires them (`retireLoginData`). It runs before any approval, which would cost the user a TAN for a session that
60
+ * ends anyway.
61
+ */
62
+ private retireOldLoginData;
63
+ /**
64
+ * Ends the dialog, whose answer to a request of `kind` brought new login data with `feedback`, stops the client from
65
+ * logging in with the old ones, and fails the call with `FinTsLoginDataChangedError` (Rückmeldungscodes C.6).
66
+ */
67
+ private retireLoginData;
68
+ /**
69
+ * Receives `response`, the answer to a request of `kind`, then completes the approval it asks for, once
70
+ * `admitApproval` has let it; returns it joined with the response that completes the approval.
71
+ *
72
+ * Throws `FinTsProtocolError` if that response asks for an approval once more: the bank has not executed the message
73
+ * then either, and read as done it would report an empty result.
74
+ */
75
+ private settle;
76
+ /** Passes on the notices in `response`: the TAN methods the user may use (3920), the bank's messages and warnings. */
77
+ private readNotices;
78
+ /** Asks the user for the TAN `approval` takes and sends it; `opening` tells whether it approves the login. */
79
+ private enterTan;
80
+ /** Waits for the user to approve in the banking app; `opening` tells whether the approval is that of the login. */
81
+ private awaitAppApproval;
82
+ }
83
+ //# sourceMappingURL=signed-dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signed-dialog.d.ts","sourceRoot":"","sources":["../../src/session/signed-dialog.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAY,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MA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IAqBpB,sHAAsH;IACtH,OAAO,CAAC,WAAW;IAOnB,8GAA8G;YAChG,QAAQ;IAatB,mHAAmH;IACnH,OAAO,CAAC,gBAAgB;CAUzB"}
@@ -0,0 +1,185 @@
1
+ import { requireLatin1 } from '../core/config.js';
2
+ import { bankErrorFor, FinTsBankError, FinTsLoginDataChangedError, FinTsLoginRefusedError, FinTsProtocolError, FinTsTanCancelledError, } from '../core/errors.js';
3
+ import { allowedTanMethodsIn, FeedbackCodes, hasCode, hasErrors, userWarnings, } from '../core/feedback.js';
4
+ import { invalidArgument } from '../util/errors.js';
5
+ import { trimBlanks, withAsciiForms } from '../util/text.js';
6
+ import { IncomingMessage3 } from '../v3/message.js';
7
+ import { appApprovalWait } from './app-approval.js';
8
+ /**
9
+ * A dialog signed with the PIN, which settles each answer before it hands it out: it keeps the parameter data of the
10
+ * dialog's opening, passes the notices on, has the `LoginGuard` judge the answer and throws its errors, and completes
11
+ * the approval the bank asks for. The session sends every message signed with the PIN through it, so that the guard
12
+ * judges every answer, that to the dialog's end included.
13
+ */
14
+ export class SignedDialog {
15
+ dialog;
16
+ session;
17
+ constructor(dialog, session) {
18
+ this.dialog = dialog;
19
+ this.session = session;
20
+ }
21
+ /** Whether the bank knows this dialog and it has not ended. */
22
+ get isActive() {
23
+ return this.dialog.isActive;
24
+ }
25
+ /** Logs in, which opens the dialog; with `synchronize` the bank also assigns a customer system ID. */
26
+ login(synchronize = false) {
27
+ return this.settleLogin(() => this.dialog.start(synchronize));
28
+ }
29
+ /**
30
+ * Logs in, asking strong authentication for `order`, then sends `order` in a message of its own, as for listing the
31
+ * TAN media while no medium is chosen yet (`FinTs3Dialog.startWith`); returns both answers.
32
+ */
33
+ async loginWith(order) {
34
+ const start = this.dialog.startWith(order);
35
+ const login = await this.settleLogin(start.login);
36
+ return [login, await this.settle(await start.order(), 'order')];
37
+ }
38
+ /**
39
+ * Sends `order` and completes the approval the bank asks for. `admitApproval` runs before the user is asked, and
40
+ * refuses the approval by throwing.
41
+ */
42
+ async send(order, admitApproval) {
43
+ return this.settle(await this.dialog.send(order), 'order', admitApproval);
44
+ }
45
+ /**
46
+ * Ends the dialog at the bank; does nothing if it is not active. Of the answer only a rejected PIN counts, which the
47
+ * guard judges: the dialog is over either way.
48
+ */
49
+ async end() {
50
+ const response = await this.dialog.end();
51
+ if (response !== undefined && hasErrors(response.feedback)) {
52
+ this.session.guard.judge(bankErrorFor(response.feedback), 'order', this.dialog.method);
53
+ }
54
+ }
55
+ /**
56
+ * Receives `response`, the answer to a request of `kind`: keeps its parameter data where it answers the `opening` of
57
+ * the dialog, the login or its approval, even alongside errors, since the remedy for a refused login may need them;
58
+ * passes its notices on; and has the guard judge it, then throws its errors, as the refusal of the login where they
59
+ * amount to one.
60
+ */
61
+ receive(response, kind, opening) {
62
+ if (opening)
63
+ this.session.parameters.keep(response);
64
+ this.readNotices(response);
65
+ const error = hasErrors(response.feedback) ? bankErrorFor(response.feedback, kind === 'approval') : undefined;
66
+ const refusal = this.session.guard.judge(error, kind, this.dialog.method);
67
+ // Every further message of a refused login's dialog would carry the refused PIN.
68
+ if (refusal !== undefined)
69
+ this.dialog.discard();
70
+ if (error !== undefined)
71
+ throw refusal ?? error;
72
+ }
73
+ /**
74
+ * Sends the login `send` and settles its answer. New login data next to an error in the answer to its approval are
75
+ * retired all the same (`retireLoginData`), although the guard counts that error as no refusal; next to an error in
76
+ * the answer to the login they are its refusal already (`loginRefusalFor`).
77
+ */
78
+ async settleLogin(send) {
79
+ try {
80
+ return await this.settle(await send(), 'login');
81
+ }
82
+ catch (error) {
83
+ if (!(error instanceof FinTsBankError) ||
84
+ error instanceof FinTsLoginRefusedError ||
85
+ !hasCode(error.feedback, FeedbackCodes.newLoginData)) {
86
+ throw error;
87
+ }
88
+ return this.retireLoginData(error.feedback, 'approval');
89
+ }
90
+ }
91
+ /**
92
+ * Where `response` answers a login, a request of `kind` other than `order`, or its approval with new login data,
93
+ * retires them (`retireLoginData`). It runs before any approval, which would cost the user a TAN for a session that
94
+ * ends anyway.
95
+ */
96
+ async retireOldLoginData(response, kind) {
97
+ if (kind === 'order' || !hasCode(response.feedback, FeedbackCodes.newLoginData))
98
+ return;
99
+ await this.retireLoginData(response.feedback, kind);
100
+ }
101
+ /**
102
+ * Ends the dialog, whose answer to a request of `kind` brought new login data with `feedback`, stops the client from
103
+ * logging in with the old ones, and fails the call with `FinTsLoginDataChangedError` (Rückmeldungscodes C.6).
104
+ */
105
+ async retireLoginData(feedback, kind) {
106
+ await this.end();
107
+ const error = new FinTsLoginDataChangedError(feedback);
108
+ throw this.session.guard.judge(error, kind, this.dialog.method) ?? error;
109
+ }
110
+ /**
111
+ * Receives `response`, the answer to a request of `kind`, then completes the approval it asks for, once
112
+ * `admitApproval` has let it; returns it joined with the response that completes the approval.
113
+ *
114
+ * Throws `FinTsProtocolError` if that response asks for an approval once more: the bank has not executed the message
115
+ * then either, and read as done it would report an empty result.
116
+ */
117
+ async settle(response, kind, admitApproval) {
118
+ const opening = kind !== 'order';
119
+ this.receive(response, kind, opening);
120
+ await this.retireOldLoginData(response, kind);
121
+ const approval = this.dialog.approvalAskedIn(response);
122
+ if (approval === undefined)
123
+ return response;
124
+ admitApproval?.();
125
+ const approved = approval.challenge.isDecoupled
126
+ ? await this.awaitAppApproval(approval, opening)
127
+ : await this.enterTan(approval, opening);
128
+ await this.retireOldLoginData(approved, kind);
129
+ if (this.dialog.approvalAskedIn(approved) !== undefined) {
130
+ throw new FinTsProtocolError('The bank asks for another approval in answer to the approval');
131
+ }
132
+ return IncomingMessage3.combine(response, approved);
133
+ }
134
+ /** Passes on the notices in `response`: the TAN methods the user may use (3920), the bank's messages and warnings. */
135
+ readNotices(response) {
136
+ const allowed = allowedTanMethodsIn(response.feedback);
137
+ if (allowed.length > 0)
138
+ this.session.state.rememberAllowedMethods(allowed);
139
+ for (const message of response.bankMessages)
140
+ this.session.prompts.showBankMessage(message);
141
+ for (const warning of userWarnings(response.feedback))
142
+ this.session.prompts.showWarning(warning);
143
+ }
144
+ /** Asks the user for the TAN `approval` takes and sends it; `opening` tells whether it approves the login. */
145
+ async enterTan(approval, opening) {
146
+ const answer = await this.session.prompts.askTan(approval.challenge);
147
+ if (answer.kind === 'approved') {
148
+ throw invalidArgument('Answered a TAN challenge with an approval in the banking app', 'tanCallback');
149
+ }
150
+ // Not NFKC, which also changes characters FinTS 3.0 sends as they are, such as `²`, in a TAN the bank compares.
151
+ const tan = answer.kind === 'tan' ? trimBlanks(withAsciiForms(answer.tan)) : '';
152
+ if (tan === '')
153
+ throw new FinTsTanCancelledError();
154
+ const response = await approval.submitTan(requireTanOf(approval.challenge.method, tan));
155
+ this.receive(response, 'approval', opening);
156
+ return response;
157
+ }
158
+ /** Waits for the user to approve in the banking app; `opening` tells whether the approval is that of the login. */
159
+ awaitAppApproval(approval, opening) {
160
+ const prompts = this.session.prompts;
161
+ return appApprovalWait(approval, {
162
+ ask: (challenge) => prompts.askTan(challenge),
163
+ pause: (delayMs, interrupt) => prompts.pause(delayMs, interrupt),
164
+ receive: (response) => {
165
+ this.receive(response, 'approval', opening);
166
+ },
167
+ }).run();
168
+ }
169
+ }
170
+ /**
171
+ * Throws `TypeError` for a TAN that `method` rules out, which the bank would count as a failed attempt: one longer than
172
+ * `TanMethod.maxTanLength`, or with other characters than digits for a `TanMethod.numericTan` method; and for one that
173
+ * FinTS 3.0 cannot send. The message leaves out the TAN.
174
+ */
175
+ function requireTanOf(method, tan) {
176
+ const max = method.maxTanLength;
177
+ if (max !== undefined && max > 0 && tan.length > max) {
178
+ throw invalidArgument(`The TAN method ${method.name} takes TANs of at most ${max} characters`, 'tan');
179
+ }
180
+ if (method.numericTan && !/^[0-9]+$/.test(tan)) {
181
+ throw invalidArgument(`The TAN method ${method.name} takes digits only`, 'tan');
182
+ }
183
+ return requireLatin1(tan, 'tan');
184
+ }
185
+ //# sourceMappingURL=signed-dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signed-dialog.js","sourceRoot":"","sources":["../../src/session/sign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AAO,EAAE,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC;YAChE,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACpB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC;SACF,CAAC,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,MAAiB,EAAE,GAAW;IAClD,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC;IAChC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QACrD,MAAM,eAAe,CAAC,kBAAkB,MAAM,CAAC,IAAI,0BAA0B,GAAG,aAAa,EAAE,KAAK,CAAC,CAAC;IACxG,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,eAAe,CAAC,kBAAkB,MAAM,CAAC,IAAI,oBAAoB,EAAE,KAAK,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC"}
@@ -1,40 +1,47 @@
1
1
  import { TanMethod, type TanMedium } from '../tan/tan-models.js';
2
- import { type BankResponse, type PinTanProtocol, type ProtocolDialog } from './protocol.js';
2
+ import { FinTs3Dialog } from '../v3/dialog.js';
3
+ import type { FinTs3Protocol } from '../v3/protocol.js';
3
4
  import type { SessionState } from './session-state.js';
4
5
  import type { UserPrompts } from './user-prompts.js';
5
6
  /**
6
7
  * The TAN method and medium the session's messages are signed with, chosen by the user among what the bank offers and
7
8
  * the user may use, and kept in the session state.
8
9
  */
9
- export declare class TanSelection<R extends BankResponse, O> {
10
+ export declare class TanSelection {
10
11
  private readonly protocol;
11
12
  private readonly state;
12
13
  private readonly prompts;
13
- /** TAN methods whose media were looked up in this session. A lookup is not repeated, even where it gave no medium. */
14
- private readonly mediaLookedUp;
15
- /** The list the last lookup gave, until `takeLookedUpMedia` hands it out. */
16
- private lookedUpMedia;
14
+ /**
15
+ * The lookups of this session that found no medium to choose, by TAN method, with the list each gave; `undefined`
16
+ * where the bank gave none. Such a lookup is not repeated for its method until `select` or `forgetMedium` drops it.
17
+ */
18
+ private readonly lookupsWithoutMedium;
17
19
  /** Whether the bank refused a login signed with the one-step method in this session. */
18
20
  private oneStepRefused;
19
- constructor(protocol: PinTanProtocol<R, O>, state: SessionState, prompts: UserPrompts);
21
+ constructor(protocol: FinTs3Protocol, state: SessionState, prompts: UserPrompts);
20
22
  /** The TAN method in use; the one-step method until one is chosen. */
21
23
  get method(): TanMethod;
22
24
  /** Switches to `securityFunction` and `tanMedium` for the dialogs to come. */
23
25
  select(securityFunction: string, tanMedium: string | undefined): void;
26
+ /**
27
+ * Forgets the medium in use and the lookups of this session, so that the next login looks the media up anew where the
28
+ * method needs one: the bank may have refused the medium, such as that of a phone the user has replaced.
29
+ */
30
+ forgetMedium(): void;
24
31
  /**
25
32
  * A dialog signed with the TAN method in use and its medium.
26
33
  *
27
- * Throws `FinTsUnsupportedError` if the method needs a medium the user has not chosen: the bank would refuse the
34
+ * Throws `FinTsTanSetupError` if the method needs a medium the user has not chosen: the bank would refuse the
28
35
  * login, and the client would not send the PIN again.
29
36
  */
30
- newDialog(): ProtocolDialog<R, O>;
37
+ newDialog(): FinTs3Dialog;
31
38
  /**
32
39
  * The dialog that looks up the TAN media, signed with the TAN method in use.
33
40
  *
34
41
  * It runs before the medium is known, so it names a placeholder where the method needs one; the bank ignores the
35
42
  * medium in this dialog (PIN/TAN B.4.3.1.3).
36
43
  */
37
- lookupDialog(): ProtocolDialog<R, O>;
44
+ lookupDialog(): FinTs3Dialog;
38
45
  /**
39
46
  * The synchronization dialog. It runs before the TAN media are looked up, so its method must do without a medium the
40
47
  * user has not chosen: the placeholder for one is meant for the lookup only (PIN/TAN B.4.3.1.3). The first method
@@ -44,16 +51,16 @@ export declare class TanSelection<R extends BankResponse, O> {
44
51
  * a one-step login;
45
52
  * 3. another two-step method the user may use.
46
53
  *
47
- * Throws `FinTsUnsupportedError` if none does, before the bank could refuse the login.
54
+ * Throws `FinTsTanSetupError` if none does, before the bank could refuse the login.
48
55
  */
49
- synchronizationDialog(): ProtocolDialog<R, O>;
56
+ synchronizationDialog(): FinTs3Dialog;
50
57
  /** Whether `method` needs a medium the user has not chosen. */
51
58
  private lacksMedium;
52
59
  /**
53
60
  * The two-step TAN methods the bank offers, the user may use and this client can run; the one-step method if there
54
61
  * are none.
55
62
  *
56
- * Throws `FinTsUnsupportedError` if the bank offers the user nothing but methods the client cannot run.
63
+ * Throws `FinTsTanSetupError` if the bank offers the user nothing but methods the client cannot run.
57
64
  */
58
65
  available(): TanMethod[];
59
66
  /**
@@ -67,7 +74,7 @@ export declare class TanSelection<R extends BankResponse, O> {
67
74
  ensureMethodChosen(): Promise<void>;
68
75
  /**
69
76
  * Whether the media of the method in use have to be looked up: it needs a medium the user has not chosen, and they
70
- * were not looked up for it in this session.
77
+ * were not looked up in vain for it in this session.
71
78
  */
72
79
  get mediumToLookUp(): boolean;
73
80
  /**
@@ -76,12 +83,13 @@ export declare class TanSelection<R extends BankResponse, O> {
76
83
  */
77
84
  chooseMedium(media: TanMedium[] | undefined): Promise<void>;
78
85
  /**
79
- * The list of the last lookup, once; `undefined` if there was none since the last time.
86
+ * The list of the lookup that found no medium for the method in use; `undefined` where there was none, or the bank
87
+ * gave no list.
80
88
  *
81
- * `getTanMedia` takes it, so that the list is not asked for twice in a row. It also outlasts a call that failed for
82
- * want of an active medium, so that the app can show the user the list that tells why; later calls ask anew.
89
+ * It outlasts the call that failed for want of the medium, so that `getTanMedia` can show the user the list that tells
90
+ * why: the client neither looks the media up again for the method nor can list them in a dialog without a medium.
83
91
  */
84
- takeLookedUpMedia(): TanMedium[] | undefined;
92
+ get lookedUpMedia(): TanMedium[] | undefined;
85
93
  /** The name of the medium the user chooses among the active ones in `media`; `undefined` if none is active. */
86
94
  private chooseMediumOf;
87
95
  }