@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,83 +0,0 @@
1
- import type { Account } from '../core/account.js';
2
- import type { Balance } from '../core/balance.js';
3
- import type { BankInfo } from '../core/bank-info.js';
4
- import type { TanMethod } from '../tan/tan-models.js';
5
- /** `parameters`, or `FinTsProtocolError` if the bank has not sent its parameter data yet. */
6
- export declare function requireBankParameters<T extends BankParameters>(parameters: T | undefined): T;
7
- /** The highest of the `offered` versions of a business transaction that the client `implemented`. */
8
- export declare function highestCommonVersion(offered: Iterable<number> | undefined, implemented: ReadonlySet<number>): number | undefined;
9
- /** Bank parameter data (BPD): what the bank offers. */
10
- export interface BankParameters {
11
- /** The version of the parameter data, which the client reports back so that the bank sends newer ones only. */
12
- readonly version: number;
13
- /** General information about the bank. */
14
- readonly bankInfo: BankInfo;
15
- /** Two-step TAN methods the bank offers and the client can run. */
16
- readonly tanMethods: readonly TanMethod[];
17
- /** Security functions of the two-step methods the bank offers in a form the client cannot run. */
18
- readonly unsupportedTanMethods: readonly string[];
19
- /** The shortest and longest PIN the bank takes, as far as it says. */
20
- readonly pinLength: {
21
- readonly min: number | undefined;
22
- readonly max: number | undefined;
23
- };
24
- /** Whether the bank allows `transaction` with PIN/TAN at all (HIPINS); `true` where it does not say. */
25
- allowsWithPinTan(transaction: string): boolean;
26
- /** The highest version of `transaction` that the bank offers and the client `implemented`. */
27
- bestVersion(transaction: string, implemented: ReadonlySet<number>): number | undefined;
28
- }
29
- /** User parameter data (UPD): what the user may do. */
30
- export interface UserParameters {
31
- /** The version of the parameter data, which the client reports back so that the bank sends newer ones only. */
32
- readonly version: number;
33
- /** The accounts the user may access. */
34
- readonly accounts: readonly Account[];
35
- /** Security functions of the TAN methods the user may use; empty when the UPD do not say. */
36
- readonly allowedTanMethods: readonly string[];
37
- /**
38
- * Whether the lists of permitted transactions are complete: the bank permits nothing they leave out ("UPD-Verwendung"
39
- * 0).
40
- */
41
- readonly listsAllTransactions: boolean;
42
- /** The transactions any entry lists as permitted, with or without an account. */
43
- readonly listedTransactions: ReadonlySet<string>;
44
- /**
45
- * The balance of `account` the user parameter data carry, where it holds all a balance query would deliver, so that
46
- * the client asks for none (Formals E.3.1, F.3.2); `undefined` otherwise.
47
- */
48
- completeBalance(account: Account): Balance | undefined;
49
- }
50
- /**
51
- * The version of `transaction` to send, for `account` where it concerns one: the highest the bank offers and the client
52
- * `implemented`. `undefined` where there is none, or the parameter data do not permit the transaction
53
- * (`permitsTransaction`).
54
- */
55
- export declare function offeredVersion(bpd: BankParameters | undefined, upd: UserParameters | undefined, transaction: string, implemented: ReadonlySet<number>, options?: {
56
- account?: Account;
57
- requiresEntry?: boolean;
58
- }): number | undefined;
59
- /**
60
- * Whether the parameter data let the user send `transaction`, for `account` where it concerns one: the bank allows it
61
- * with PIN/TAN, and the user parameter data permit it (Formals E.1, F.3.4; PIN/TAN B.1, B.8.1).
62
- *
63
- * - A known account permits what it lists, and anything else only where the lists are incomplete ("UPD-Verwendung" 1).
64
- * An unknown account permits anything.
65
- * - A transaction without account, such as the TAN media list, is permitted where some entry lists it or the lists are
66
- * incomplete.
67
- * - One that `requiresEntry`, the SEPA account list, must be listed even where the lists are incomplete (Formals F.3.4),
68
- * unless they list nothing at all, which tells nothing.
69
- */
70
- export declare function permitsTransaction(bpd: BankParameters | undefined, upd: UserParameters | undefined, transaction: string, options?: {
71
- account?: Account;
72
- requiresEntry?: boolean;
73
- }): boolean;
74
- /** Whether the bank lists `transaction`, such as `HKCAZ`, as permitted for `account`. */
75
- export declare function lists(account: Account, transaction: string): boolean;
76
- /**
77
- * Whether the bank may permit `transaction` on `account`: it lists it, or its list is not complete
78
- * (`Account.allowedTransactionsComplete`), so that only the bank can tell.
79
- */
80
- export declare function allows(account: Account, transaction: string): boolean;
81
- /** The account of the user parameter data `upd` that matches `account`; `account` itself if they do not know it. */
82
- export declare function knownAccount(upd: UserParameters | undefined, account: Account): Account;
83
- //# sourceMappingURL=parameter-data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parameter-data.d.ts","sourceRoot":"","sources":["../../src/session/parameter-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,6FAA6F;AAC7F,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,cAAc,EAAE,UAAU,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,CAG5F;AAED,qGAAqG;AACrG,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,EACrC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,GAC/B,MAAM,GAAG,SAAS,CAMpB;AAED,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,+GAA+G;IAC/G,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE5B,mEAAmE;IACnE,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAE1C,kGAAkG;IAClG,QAAQ,CAAC,qBAAqB,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EAAE,cAAc,GAAG,SAAS,EAC/B,GAAG,EAAE,cAAc,GAAG,SAAS,EAC/B,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,GAC3D,OAAO,CAOT;AAOD,yFAAyF;AACzF,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAEpE;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAErE;AAED,oHAAoH;AACpH,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAEvF"}
@@ -1,68 +0,0 @@
1
- import { FinTsProtocolError } from '../core/errors.js';
2
- /** `parameters`, or `FinTsProtocolError` if the bank has not sent its parameter data yet. */
3
- export function requireBankParameters(parameters) {
4
- if (parameters === undefined)
5
- throw new FinTsProtocolError('No bank parameter data available');
6
- return parameters;
7
- }
8
- /** The highest of the `offered` versions of a business transaction that the client `implemented`. */
9
- export function highestCommonVersion(offered, implemented) {
10
- let best;
11
- for (const version of offered ?? []) {
12
- if (implemented.has(version) && (best === undefined || version > best))
13
- best = version;
14
- }
15
- return best;
16
- }
17
- /**
18
- * The version of `transaction` to send, for `account` where it concerns one: the highest the bank offers and the client
19
- * `implemented`. `undefined` where there is none, or the parameter data do not permit the transaction
20
- * (`permitsTransaction`).
21
- */
22
- export function offeredVersion(bpd, upd, transaction, implemented, options = {}) {
23
- return permitsTransaction(bpd, upd, transaction, options) ? bpd?.bestVersion(transaction, implemented) : undefined;
24
- }
25
- /**
26
- * Whether the parameter data let the user send `transaction`, for `account` where it concerns one: the bank allows it
27
- * with PIN/TAN, and the user parameter data permit it (Formals E.1, F.3.4; PIN/TAN B.1, B.8.1).
28
- *
29
- * - A known account permits what it lists, and anything else only where the lists are incomplete ("UPD-Verwendung" 1).
30
- * An unknown account permits anything.
31
- * - A transaction without account, such as the TAN media list, is permitted where some entry lists it or the lists are
32
- * incomplete.
33
- * - One that `requiresEntry`, the SEPA account list, must be listed even where the lists are incomplete (Formals F.3.4),
34
- * unless they list nothing at all, which tells nothing.
35
- */
36
- export function permitsTransaction(bpd, upd, transaction, options = {}) {
37
- if (bpd !== undefined && !bpd.allowsWithPinTan(transaction))
38
- return false;
39
- if (upd === undefined)
40
- return true;
41
- if (options.account !== undefined)
42
- return allows(knownAccount(upd, options.account), transaction);
43
- const listed = upd.listedTransactions;
44
- for (const t of listed)
45
- if (names(t, transaction))
46
- return true;
47
- return !upd.listsAllTransactions && (!(options.requiresEntry ?? false) || listed.size === 0);
48
- }
49
- /** Whether the `listed` name of a transaction names `transaction`, also in a versioned form such as `AcctBal_2`. */
50
- function names(listed, transaction) {
51
- return listed === transaction || listed.startsWith(`${transaction}_`);
52
- }
53
- /** Whether the bank lists `transaction`, such as `HKCAZ`, as permitted for `account`. */
54
- export function lists(account, transaction) {
55
- return account.allowedTransactions.some((t) => names(t, transaction));
56
- }
57
- /**
58
- * Whether the bank may permit `transaction` on `account`: it lists it, or its list is not complete
59
- * (`Account.allowedTransactionsComplete`), so that only the bank can tell.
60
- */
61
- export function allows(account, transaction) {
62
- return lists(account, transaction) || !account.allowedTransactionsComplete;
63
- }
64
- /** The account of the user parameter data `upd` that matches `account`; `account` itself if they do not know it. */
65
- export function knownAccount(upd, account) {
66
- return upd?.accounts.find((a) => account.matches(a)) ?? account;
67
- }
68
- //# sourceMappingURL=parameter-data.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parameter-data.js","sourceRoot":"","sources":["../../src/session/parameter-data.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,6FAA6F;AAC7F,MAAM,UAAU,qBAAqB,CAA2B,UAAyB;IACvF,IAAI,UAAU,KA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QAAE,IAAI,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC;YAAE,OAAO,IAAI,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,IAAI,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;AAC/F,CAAC;AAED,oHAAoH;AACpH,SAAS,KAAK,CAAC,MAAc,EAAE,WAAmB;IAChD,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC;AACxE,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,KAAK,CAAC,OAAgB,EAAE,WAAmB;IACzD,OAAO,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;AACxE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,OAAgB,EAAE,WAAmB;IAC1D,OAAO,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC;AAC7E,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,YAAY,CAAC,GAA+B,EAAE,OAAgB;IAC5E,OAAO,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC;AAClE,CAAC"}
@@ -1,54 +0,0 @@
1
- import type { Account } from '../core/account.js';
2
- import type { Balance } from '../core/balance.js';
3
- import type { BankInfo } from '../core/bank-info.js';
4
- import type { FinTsClient, FinTsClientOptions, MessageLogger, TransactionQuery } from '../core/client.js';
5
- import type { Transaction } from '../core/transaction.js';
6
- import type { TanMedium, TanMethod } from '../tan/tan-models.js';
7
- import type { BankResponse, PinTanProtocol } from './protocol.js';
8
- /**
9
- * PIN/TAN session logic; the `PinTanProtocol` builds and reads the messages.
10
- *
11
- * A call such as `getBalance` runs through these parts:
12
- * 1. `DialogRunner.open` reuses the session's dialog or logs in, through `SessionSetup.remedied`, which logs in once
13
- * more for each refusal it can take care of.
14
- * 2. `SessionSetup.prepare` first settles what is open: the bank parameter data, the synchronization, and through
15
- * `TanSelection` the TAN method and medium.
16
- * 3. `ResponseHandler.startDialog` sends the login and completes the strong authentication the bank asks for, a TAN or
17
- * an app approval (`AppApprovalWait`).
18
- * 4. `DialogRunner.query` sends the order in that dialog, completes its approval the same way, and fetches all pages.
19
- *
20
- * `SepaAccounts` completes IBAN and BIC, and `UserPrompts` is everything the app is told or asked. The protocol's
21
- * `LoginGuard` decides which bank errors refuse the login, and keeps the PIN from going out after one.
22
- */
23
- export declare abstract class PinTanClient<R extends BankResponse, O> implements FinTsClient {
24
- private readonly prompts;
25
- private readonly protocol;
26
- private readonly sessionState;
27
- private readonly tans;
28
- private readonly setup;
29
- private readonly dialogs;
30
- private readonly sepa;
31
- private readonly queue;
32
- private closed;
33
- /** The call running now, which a call from inside its callbacks would wait for. */
34
- private runningCall;
35
- /**
36
- * A client of the protocol `createProtocol` builds around the logger it is given (`UserPrompts.logger`), with the
37
- * session restored from `FinTsClientOptions.state` where it was saved for this user and bank.
38
- */
39
- protected constructor(options: FinTsClientOptions, createProtocol: (logger: MessageLogger | undefined) => PinTanProtocol<R, O>);
40
- get state(): string;
41
- get selectedTanMethod(): string | undefined;
42
- get selectedTanMedium(): string | undefined;
43
- selectTanMethod(securityFunction: string, tanMedium?: string): Promise<void>;
44
- getBankInfo(): Promise<BankInfo>;
45
- getTanMethods(): Promise<TanMethod[]>;
46
- getTanMedia(): Promise<TanMedium[]>;
47
- getAccounts(): Promise<Account[]>;
48
- getBalance(account: Account): Promise<Balance>;
49
- getTransactions(account: Account, query?: TransactionQuery): Promise<Transaction[]>;
50
- close(): Promise<void>;
51
- private closeNow;
52
- private serialized;
53
- }
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,GAAG,SAAS,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;IAa7E,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAE1C;IAED,IAAI,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAE1C;IAED,eAAe,CAAC,gBAAgB,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO5E,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;IAIhC,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAIrC,WAAW,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAcnC,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIjC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAa9C,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,GAAE,gBAAqB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAmBvF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,UAAU;CAmBnB"}
@@ -1,153 +0,0 @@
1
- import { FinTsStateError, FinTsUnsupportedError } from '../core/errors.js';
2
- import { SerialExecutor } from '../util/async.js';
3
- import { CallContext } from '../util/call-context.js';
4
- import { calendarDay, notAfterToday } from '../util/dates.js';
5
- import { invalidArgument } from '../util/errors.js';
6
- import { DialogRunner } from './dialog-runner.js';
7
- import { ResponseHandler } from './response-handler.js';
8
- import { SepaAccounts } from './sepa-accounts.js';
9
- import { SessionSetup } from './session-setup.js';
10
- import { restoreSession, saveSession } from './session-state.js';
11
- import { TanSelection } from './tan-selection.js';
12
- import { UserPrompts } from './user-prompts.js';
13
- /** The call running now, by the client it belongs to, so that a call from inside its callbacks is recognized. */
14
- const runningCalls = new CallContext();
15
- /**
16
- * PIN/TAN session logic; the `PinTanProtocol` builds and reads the messages.
17
- *
18
- * A call such as `getBalance` runs through these parts:
19
- * 1. `DialogRunner.open` reuses the session's dialog or logs in, through `SessionSetup.remedied`, which logs in once
20
- * more for each refusal it can take care of.
21
- * 2. `SessionSetup.prepare` first settles what is open: the bank parameter data, the synchronization, and through
22
- * `TanSelection` the TAN method and medium.
23
- * 3. `ResponseHandler.startDialog` sends the login and completes the strong authentication the bank asks for, a TAN or
24
- * an app approval (`AppApprovalWait`).
25
- * 4. `DialogRunner.query` sends the order in that dialog, completes its approval the same way, and fetches all pages.
26
- *
27
- * `SepaAccounts` completes IBAN and BIC, and `UserPrompts` is everything the app is told or asked. The protocol's
28
- * `LoginGuard` decides which bank errors refuse the login, and keeps the PIN from going out after one.
29
- */
30
- export class PinTanClient {
31
- prompts;
32
- protocol;
33
- sessionState;
34
- tans;
35
- setup;
36
- dialogs;
37
- sepa;
38
- queue = new SerialExecutor();
39
- closed;
40
- /** The call running now, which a call from inside its callbacks would wait for. */
41
- runningCall;
42
- /**
43
- * A client of the protocol `createProtocol` builds around the logger it is given (`UserPrompts.logger`), with the
44
- * session restored from `FinTsClientOptions.state` where it was saved for this user and bank.
45
- */
46
- constructor(options, createProtocol) {
47
- this.prompts = new UserPrompts(options);
48
- this.protocol = createProtocol(this.prompts.logger);
49
- this.sessionState = restoreSession(options.state, this.protocol);
50
- const guard = this.protocol.loginGuard;
51
- const responses = new ResponseHandler(this.protocol, this.sessionState, this.prompts, guard);
52
- this.tans = new TanSelection(this.protocol, this.sessionState, this.prompts);
53
- this.setup = new SessionSetup(this.protocol, responses, this.tans, guard);
54
- this.dialogs = new DialogRunner(this.setup, responses, this.prompts);
55
- this.sepa = new SepaAccounts(this.protocol, this.sessionState, this.dialogs, guard);
56
- }
57
- get state() {
58
- return saveSession(this.protocol, this.sessionState);
59
- }
60
- get selectedTanMethod() {
61
- return this.sessionState.tanMethod;
62
- }
63
- get selectedTanMedium() {
64
- return this.sessionState.tanMedium;
65
- }
66
- selectTanMethod(securityFunction, tanMedium) {
67
- return this.serialized(async () => {
68
- await this.dialogs.end();
69
- this.tans.select(securityFunction, tanMedium);
70
- });
71
- }
72
- getBankInfo() {
73
- return this.serialized(() => this.setup.remedied(() => this.setup.bankInfo()));
74
- }
75
- getTanMethods() {
76
- return this.serialized(() => this.setup.remedied(() => this.setup.methods()));
77
- }
78
- getTanMedia() {
79
- return this.serialized(async () => {
80
- await this.setup.remedied(() => this.setup.prepare());
81
- return (this.tans.takeLookedUpMedia() ??
82
- (await this.dialogs.query(() => {
83
- const query = this.protocol.tanMedia();
84
- if (query === undefined)
85
- throw new FinTsUnsupportedError('The bank does not list TAN media');
86
- return query;
87
- })));
88
- });
89
- }
90
- getAccounts() {
91
- return this.serialized(() => this.sepa.completedAccounts());
92
- }
93
- getBalance(account) {
94
- return this.serialized(async () => {
95
- const completed = await this.sepa.complete(account);
96
- // The dialog start delivers the user parameter data, which may carry the complete balance: then the client must
97
- // not ask for it separately (Formals E.3.1.1, F.3.2).
98
- await this.dialogs.open();
99
- return (this.protocol.userParameters?.completeBalance(completed) ??
100
- (await this.dialogs.query(() => this.protocol.balance(completed))));
101
- });
102
- }
103
- getTransactions(account, query = {}) {
104
- // Only the days count: the bank takes dates without time of day. Checked before the call waits for others.
105
- const firstDay = query.from === undefined ? undefined : calendarDay(query.from);
106
- const lastDay = query.to === undefined ? undefined : calendarDay(query.to);
107
- if (firstDay !== undefined && lastDay !== undefined && firstDay.getTime() > lastDay.getTime()) {
108
- return Promise.reject(invalidArgument('`from` lies on a day after `to`', 'from'));
109
- }
110
- return this.serialized(async () => {
111
- const completed = await this.sepa.complete(account);
112
- const transactions = await this.dialogs.query(() => this.protocol.transactions(completed, query.format ?? 'auto', notAfterToday(firstDay), notAfterToday(lastDay)));
113
- // A stable sort, so that transactions of the same day keep the bank's order.
114
- return transactions.sort((a, b) => (a.bookingDate ?? a.valueDate).getTime() - (b.bookingDate ?? b.valueDate).getTime());
115
- });
116
- }
117
- close() {
118
- this.closed ??= this.closeNow();
119
- return this.closed;
120
- }
121
- closeNow() {
122
- this.prompts.close();
123
- return this.queue.run(() => this.prompts.reportingCallbackErrors(async () => {
124
- try {
125
- await this.dialogs.end();
126
- }
127
- finally {
128
- this.protocol.close();
129
- }
130
- }));
131
- }
132
- serialized(action) {
133
- const caller = runningCalls.current;
134
- if (caller !== undefined && caller.client === this && caller === this.runningCall) {
135
- // The call would wait behind the running one, which waits for the callback: neither would ever end.
136
- return Promise.reject(new FinTsStateError('The FinTS client was called from inside one of its callbacks'));
137
- }
138
- return this.queue.run(async () => {
139
- const call = { client: this };
140
- this.runningCall = call;
141
- try {
142
- return await runningCalls.run(call, () => {
143
- this.prompts.checkOpen();
144
- return this.prompts.reportingCallbackErrors(action);
145
- });
146
- }
147
- finally {
148
- this.runningCall = undefined;
149
- }
150
- });
151
- }
152
- }
153
- //# sourceMappingURL=pin-tan-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pin-tan-client.js","sourceRoot":"","sources":["../../src/session/pin-tan-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG3E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,o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import type { Approval, BankResponse, ProtocolDialog, StartWithOrder } from './protocol.js';
4
- /** What `PinTanDialog.approvalOf` takes besides the response. */
5
- export interface ApprovalParts<R> {
6
- readonly reference: string;
7
- readonly message: string | undefined;
8
- readonly hhdUc: Uint8Array | undefined;
9
- readonly validUntil: Date | undefined;
10
- readonly tanMediumName: string | undefined;
11
- readonly submitTan: (tan: string) => Promise<R>;
12
- readonly checkStatus: () => Promise<R>;
13
- readonly instructionsIn: (response: R) => string | undefined;
14
- }
15
- /** The dialog logic of PIN/TAN: the TAN method and medium, the message count, the dialog's end, and the approvals. */
16
- export declare abstract class PinTanDialog<R extends BankResponse, O> implements ProtocolDialog<R, O> {
17
- readonly method: TanMethod;
18
- /** The TAN medium the messages name, where the method takes one. */
19
- readonly tanMedium: string | undefined;
20
- private messageNumber;
21
- private ended;
22
- /** When the bank last answered without rejecting the whole message, which shows it still knows the dialog. */
23
- private lastAnswer;
24
- constructor(method: TanMethod,
25
- /** The TAN medium the messages name, where the method takes one. */
26
- tanMedium: string | undefined);
27
- abstract readonly isActive: boolean;
28
- abstract start(synchronize?: boolean): Promise<R>;
29
- abstract startWith(order: O): StartWithOrder<R>;
30
- abstract send(order: O): Promise<R>;
31
- /** The bank parameter data received so far, which tell how long the bank keeps an idle dialog. */
32
- protected abstract get bankParameters(): BankParameters | undefined;
33
- /**
34
- * Whether the dialog has ended, on either side.
35
- *
36
- * The bank ends a dialog idle for longer than its maximum timeout (HIBPA, Formals C.9), or five minutes where it
37
- * states none. Such a dialog is neither used nor ended again: the bank would refuse any message in it.
38
- */
39
- get hasEnded(): boolean;
40
- private get idleTooLong();
41
- /** Whether the messages are signed with a two-step TAN method, so that the bank may ask for approvals. */
42
- get isTwoStep(): boolean;
43
- /** The TAN medium name the messages send: the dialog's, unless the method takes none. */
44
- get mediumName(): string | undefined;
45
- end(): Promise<void>;
46
- /** Sends the message that ends the dialog. */
47
- protected abstract sendEnd(): Promise<void>;
48
- discard(): void;
49
- /**
50
- * Sends the next message through `post`, which takes its number, and reads the answer with `read`. The message counts
51
- * once the bank has answered, whatever it answered.
52
- *
53
- * The dialog ends on the client's side, without a dialog end, where it is over for the bank: after a return code that
54
- * ends it, such as 9800, and after a rejected opening message (Formals C.1.2), or a broken connection (C.6).
55
- *
56
- * Only an answer that does not reject the whole message starts the idle time anew (`hasEnded`): a rejection may come
57
- * from a bank that has ended the dialog without saying so.
58
- */
59
- protected transmit<A>(post: (number: number) => Promise<A>, read: (answer: A) => R): Promise<R>;
60
- /** Reads what `response` tells about the dialog itself, such as the ID the bank assigns it. */
61
- protected abstract readDialogData(response: R): void;
62
- approvalAskedIn(response: R): Approval<R> | undefined;
63
- /**
64
- * The approval whose challenge `response` carries; `undefined` where it carries none, or only the dummy one of a
65
- * message the bank exempts from strong authentication.
66
- */
67
- protected abstract approvalIn(response: R): Approval<R> | undefined;
68
- /** The approval `response` asks for, with the challenge for the order the bank calls `reference`. */
69
- protected approvalOf(response: R, parts: ApprovalParts<R>): Approval<R>;
70
- }
71
- //# sourceMappingURL=pin-tan-dialog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pin-tan-dialog.d.ts","sourceRoot":"","sources":["../../src/session/pin-tan-dialog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAQ5F,iEAAiE;AACjE,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,IAAI,GAAG,SAAS,CAAC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OAAO,CAEvB;IAED,yFAAyF;IACzF,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAEnC;IAEK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAW1B,8CAA8C;IAC9C,SAAS,CAAC,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3C,OAAO,IAAI,IAAI;IAIf;;;;;;;;;OASG;cACa,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAiBrG,+FAA+F;IAC/F,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI;IAEpD,eAAe,CAAC,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS;IAWrD;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS;IAEnE,qGAAqG;IACrG,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;CAkBxE"}
@@ -1,124 +0,0 @@
1
- import { FinTsError, FinTsProtocolError, FinTsTransportError, parseBankData } from '../core/errors.js';
2
- import { endsDialog, FeedbackCodes, hasCode, hasErrors } from '../core/feedback.js';
3
- import { challengeText, TanChallenge } from '../tan/challenge.js';
4
- /**
5
- * How long a dialog may stay idle where the bank states no timeout: on the safe side, since a dialog given up too early
6
- * only costs a new login, while one kept too long fails the next call.
7
- */
8
- const defaultIdleLimitMs = 5 * 60_000;
9
- /** The dialog logic of PIN/TAN: the TAN method and medium, the message count, the dialog's end, and the approvals. */
10
- export class PinTanDialog {
11
- method;
12
- tanMedium;
13
- messageNumber = 1;
14
- ended = false;
15
- /** When the bank last answered without rejecting the whole message, which shows it still knows the dialog. */
16
- lastAnswer;
17
- constructor(method,
18
- /** The TAN medium the messages name, where the method takes one. */
19
- tanMedium) {
20
- this.method = method;
21
- this.tanMedium = tanMedium;
22
- }
23
- /**
24
- * Whether the dialog has ended, on either side.
25
- *
26
- * The bank ends a dialog idle for longer than its maximum timeout (HIBPA, Formals C.9), or five minutes where it
27
- * states none. Such a dialog is neither used nor ended again: the bank would refuse any message in it.
28
- */
29
- get hasEnded() {
30
- return this.ended || this.idleTooLong;
31
- }
32
- get idleTooLong() {
33
- const last = this.lastAnswer;
34
- const timeout = this.bankParameters?.bankInfo.maxTimeout;
35
- // A timeout of 0 or below: the bank keeps idle dialogs without limit.
36
- const limit = timeout === undefined ? defaultIdleLimitMs : timeout <= 0 ? undefined : timeout * 1000;
37
- return last !== undefined && limit !== undefined && Date.now() - last > limit;
38
- }
39
- /** Whether the messages are signed with a two-step TAN method, so that the bank may ask for approvals. */
40
- get isTwoStep() {
41
- return !this.method.isOneStep;
42
- }
43
- /** The TAN medium name the messages send: the dialog's, unless the method takes none. */
44
- get mediumName() {
45
- return this.method.mediumRequirement === 'notAllowed' ? undefined : this.tanMedium;
46
- }
47
- async end() {
48
- if (!this.isActive)
49
- return;
50
- this.ended = true;
51
- try {
52
- await this.sendEnd();
53
- }
54
- catch (error) {
55
- // The bank may have ended the dialog on its side already.
56
- if (!(error instanceof FinTsError))
57
- throw error;
58
- }
59
- }
60
- discard() {
61
- this.ended = true;
62
- }
63
- /**
64
- * Sends the next message through `post`, which takes its number, and reads the answer with `read`. The message counts
65
- * once the bank has answered, whatever it answered.
66
- *
67
- * The dialog ends on the client's side, without a dialog end, where it is over for the bank: after a return code that
68
- * ends it, such as 9800, and after a rejected opening message (Formals C.1.2), or a broken connection (C.6).
69
- *
70
- * Only an answer that does not reject the whole message starts the idle time anew (`hasEnded`): a rejection may come
71
- * from a bank that has ended the dialog without saying so.
72
- */
73
- async transmit(post, read) {
74
- const number = this.messageNumber;
75
- let answer;
76
- try {
77
- answer = await post(number);
78
- }
79
- catch (error) {
80
- if (error instanceof FinTsTransportError)
81
- this.discard();
82
- throw error;
83
- }
84
- this.messageNumber++;
85
- const response = parseBankData(() => read(answer));
86
- this.readDialogData(response);
87
- if (!response.messageRejected)
88
- this.lastAnswer = Date.now();
89
- if (endsDialog(response.feedback) || (number === 1 && response.messageRejected))
90
- this.discard();
91
- return response;
92
- }
93
- approvalAskedIn(response) {
94
- const feedback = response.feedback;
95
- const asks = !hasErrors(feedback) &&
96
- (hasCode(feedback, FeedbackCodes.tanRequired) || hasCode(feedback, FeedbackCodes.decoupledPending));
97
- if (!asks)
98
- return undefined;
99
- const approval = this.approvalIn(response);
100
- if (approval === undefined)
101
- throw new FinTsProtocolError('The bank asks for an approval, but sends no challenge');
102
- return approval;
103
- }
104
- /** The approval `response` asks for, with the challenge for the order the bank calls `reference`. */
105
- approvalOf(response, parts) {
106
- const feedback = response.feedback;
107
- return {
108
- challenge: TanChallenge.create({
109
- method: this.method,
110
- reference: parts.reference,
111
- message: parts.message,
112
- hhdUc: parts.hhdUc,
113
- isDecoupled: hasCode(feedback, FeedbackCodes.decoupledPending) || this.method.decoupled,
114
- validUntil: parts.validUntil,
115
- tanMediumName: parts.tanMediumName ?? this.tanMedium,
116
- }),
117
- submitTan: parts.submitTan,
118
- checkStatus: parts.checkStatus,
119
- waitForPush: hasCode(feedback, FeedbackCodes.decoupledWaitForPush),
120
- instructionsIn: (status) => challengeText(parts.instructionsIn(status)),
121
- };
122
- }
123
- }
124
- //# sourceMappingURL=pin-tan-dialog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pin-tan-dialog.js","sourceRoot":"","sources":["../../src/session/pin-tan-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvG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