@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,11 +1,25 @@
1
+ import { optionalBoolean, optionalString, requireString } from '../util/arguments.js';
1
2
  import { invalidArgument } from '../util/errors.js';
2
- /** Numeric country code of Germany (ISO 3166), where FinTS banks are. */
3
+ import { inspectCustom } from '../util/inspect.js';
4
+ import { isLatin1, trimBlanks } from '../util/text.js';
5
+ /**
6
+ * The country code FinTS gives Germany, where FinTS banks are: the ISO 3166 code of the Federal Republic before 1990,
7
+ * not today's `276`.
8
+ */
3
9
  export const defaultCountryCode = '280';
4
- /** Connection and login data for one bank user. */
10
+ /**
11
+ * Longest bank code (Kreditinstitutscode), user or customer ID (data type `id`), product ID (Produktbezeichnung) and
12
+ * product version FinTS 3.0 takes.
13
+ */
14
+ const maxBankCodeLength = 30;
15
+ const maxIdLength = 30;
16
+ const maxProductIdLength = 25;
17
+ const maxProductVersionLength = 5;
18
+ /** Connection and login data for one bank user; frozen, so that the client sends what the constructor has checked. */
5
19
  export class FinTsConfig {
6
- /** Numeric country code of Germany (ISO 3166), where FinTS banks are. */
20
+ /** The country code FinTS gives Germany, where FinTS banks are: `280`, not today's ISO 3166 code `276`. */
7
21
  static defaultCountryCode = defaultCountryCode;
8
- url;
22
+ href;
9
23
  bankCode;
10
24
  userId;
11
25
  explicitCustomerId;
@@ -14,8 +28,17 @@ export class FinTsConfig {
14
28
  countryCode;
15
29
  allowInsecureUrl;
16
30
  /**
17
- * Throws `TypeError` if `url` is not a valid URL, has no host or is not https, unless `allowInsecureUrl` is set and
18
- * `url` is a loopback address, and if a login detail or the product is empty: the bank would refuse the login.
31
+ * Throws `TypeError` if `url` is not a valid URL, has no host, holds a user name or password, or is not https, unless
32
+ * `allowInsecureUrl` is set and `url` is a loopback address. Throws as well where the bank would refuse the login: for
33
+ * a login or product detail that is empty, has characters FinTS 3.0 cannot send (it uses ISO 8859-1, so `€` and most
34
+ * non-Latin letters are not possible) or is longer than its field (30 characters for the bank code, the user ID and
35
+ * the customer ID, 25 for the product ID, 5 for its version), for a country code of other than three digits, and for
36
+ * a German bank code of other than eight. Throws as well for a detail of another type than `FinTsConfigInit` names,
37
+ * such as a number as `bankCode` or the string `'false'` as `allowInsecureUrl`; `null` counts as a detail not given.
38
+ * The message leaves out the value.
39
+ *
40
+ * Drops leading and trailing blanks of the login details and the product, as FinTS sends them without (Formals
41
+ * B.4.1): `'alice '` is the user `alice`, also for a saved state.
19
42
  */
20
43
  constructor(init) {
21
44
  // `URL` would read `https:bank` and `https:///bank` as the host `bank`; such a URL is a mistake, not a host.
@@ -29,31 +52,59 @@ export class FinTsConfig {
29
52
  catch {
30
53
  throw invalidArgument('Not a valid URL', 'url');
31
54
  }
32
- this.url = url;
33
- this.bankCode = init.bankCode;
34
- this.userId = init.userId;
35
- this.explicitCustomerId = init.customerId;
36
- this.productId = init.productId;
37
- this.productVersion = init.productVersion ?? '1.0';
38
- this.countryCode = init.countryCode ?? defaultCountryCode;
39
- this.allowInsecureUrl = init.allowInsecureUrl ?? false;
55
+ this.href = url.href;
56
+ this.allowInsecureUrl = optionalBoolean(init.allowInsecureUrl, 'allowInsecureUrl') ?? false;
40
57
  requireSecureUrl(url, this.allowInsecureUrl);
41
- requireNotBlank(this.bankCode, 'bankCode');
42
- requireNotBlank(this.userId, 'userId');
43
- if (this.explicitCustomerId !== undefined)
44
- requireNotBlank(this.explicitCustomerId, 'customerId');
45
- requireNotBlank(this.productId, 'productId');
46
- requireNotBlank(this.productVersion, 'productVersion');
47
- requireNotBlank(this.countryCode, 'countryCode');
58
+ this.countryCode = requireValue(init.countryCode ?? defaultCountryCode, 'countryCode');
59
+ if (!/^\d{3}$/.test(this.countryCode)) {
60
+ throw invalidArgument('Must be three digits, 280 for Germany', 'countryCode');
61
+ }
62
+ this.bankCode = requireValue(init.bankCode, 'bankCode', maxBankCodeLength);
63
+ if (this.countryCode === defaultCountryCode && !/^\d{8}$/.test(this.bankCode)) {
64
+ throw invalidArgument('A German bank code (BLZ) has eight digits', 'bankCode');
65
+ }
66
+ this.userId = requireValue(init.userId, 'userId', maxIdLength);
67
+ const customerId = optionalString(init.customerId, 'customerId');
68
+ this.explicitCustomerId =
69
+ customerId === undefined ? undefined : requireValue(customerId, 'customerId', maxIdLength);
70
+ this.productId = requireValue(init.productId, 'productId', maxProductIdLength);
71
+ this.productVersion = requireValue(init.productVersion ?? '1.0', 'productVersion', maxProductVersionLength);
72
+ Object.freeze(this);
73
+ }
74
+ /**
75
+ * The bank's FinTS PIN/TAN endpoint, as checked by the constructor. A new `URL` on each access, so that changing one
76
+ * cannot change where the client posts the PIN.
77
+ */
78
+ get url() {
79
+ return new URL(this.href);
48
80
  }
49
81
  /** Customer ID; defaults to `userId`. */
50
82
  get customerId() {
51
83
  return this.explicitCustomerId ?? this.userId;
52
84
  }
85
+ /** What Node.js's `util.inspect` and `console.log` show: the bank code, neither the login data nor the product ID. */
86
+ [inspectCustom]() {
87
+ return `FinTsConfig(${this.bankCode})`;
88
+ }
53
89
  }
54
- function requireNotBlank(value, name) {
55
- if (value.trim() === '')
90
+ /**
91
+ * `value` without leading and trailing blanks; throws `TypeError` if it is no string, nothing is left, or what is left
92
+ * is not sendable (`requireLatin1`) or longer than `maxLength`: cut short, a value would be one the bank does not know.
93
+ */
94
+ function requireValue(value, name, maxLength = Number.POSITIVE_INFINITY) {
95
+ const trimmed = trimBlanks(requireString(value, name));
96
+ if (trimmed === '')
56
97
  throw invalidArgument('Must not be empty', name);
98
+ requireLatin1(trimmed, name);
99
+ if (trimmed.length > maxLength)
100
+ throw invalidArgument(`At most ${maxLength} characters in FinTS 3.0`, name);
101
+ return trimmed;
102
+ }
103
+ /** `text`, unless it has characters FinTS 3.0 cannot send (ISO 8859-1 only); the message leaves out the value. */
104
+ export function requireLatin1(text, name) {
105
+ if (!isLatin1(text))
106
+ throw invalidArgument('Contains characters FinTS 3.0 cannot send (ISO 8859-1 only)', name);
107
+ return text;
57
108
  }
58
109
  /** The host of `url` without the brackets of an IPv6 address, as `URL` writes it. */
59
110
  export function hostOf(url) {
@@ -63,27 +114,31 @@ export function hostOf(url) {
63
114
  /**
64
115
  * Throws `TypeError` unless `url` names a host and uses https: the PIN travels with every message.
65
116
  *
66
- * With `allowInsecure`, http is accepted for loopback hosts only.
117
+ * With `allowInsecure`, http is accepted for loopback hosts only. Throws as well for a user name or password in `url`:
118
+ * `fetch` refuses such a URL, with the whole URL in its error message. The message leaves them out.
67
119
  */
68
- export function requireSecureUrl(url, allowInsecure = false) {
120
+ function requireSecureUrl(url, allowInsecure = false) {
69
121
  if (hostOf(url) === '')
70
122
  throw invalidArgument('The URL has no host', 'url');
123
+ if (url.username !== '' || url.password !== '')
124
+ throw invalidArgument('The URL must not contain credentials', 'url');
71
125
  const loopbackHttp = allowInsecure && url.protocol === 'http:' && isLoopback(hostOf(url));
72
126
  if (url.protocol !== 'https:' && !loopbackHttp)
73
127
  throw invalidArgument('PIN/TAN requires an https URL', 'url');
74
128
  }
75
129
  /**
76
- * Throws `TypeError` for an empty PIN, which the bank would count as a failed attempt, and for one with leading or
77
- * trailing blanks: FinTS values carry none (Formals B.4.1), so such a PIN could only go out changed.
130
+ * `pin`, unless FinTS 3.0 cannot send it: throws `TypeError` for an empty PIN, which the bank would count as a failed
131
+ * attempt, for one with leading or trailing blanks, which would go out without them since FinTS values carry none
132
+ * (Formals B.4.1), and for one with characters outside ISO 8859-1.
78
133
  *
79
134
  * The message leaves out the value.
80
135
  */
81
136
  export function requirePin(pin) {
82
- if (pin.trim() === '')
137
+ if (trimBlanks(pin) === '')
83
138
  throw invalidArgument('The PIN is empty', 'pin');
84
- if (pin.trim() !== pin)
139
+ if (trimBlanks(pin) !== pin)
85
140
  throw invalidArgument('The PIN begins or ends with a blank', 'pin');
86
- return pin;
141
+ return requireLatin1(pin, 'pin');
87
142
  }
88
143
  /**
89
144
  * Throws `TypeError` if `pin` is shorter than `min` or longer than `max` characters, the bank's limits: the bank would
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,yEAAyE;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AA0BxC,mDAAmD;AACnD,MAAM,OAAO,WAAW;IACtB,yEAAyE;IACzE,MAAM,CAAU,kBAAkB,GAAG,kBAAkB,CAAC;IAE/C,GAAG,CAAM;IACT,QAAQ,CAAS;IACjB,MAAM,CAAS;IACP,kBAAkB,CAAqB;IAC/C,SAAS,CAAS;IAClB,cAAc,CAAS;IACvB,WAAW,CA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,MAAM,QAAQ,GAAG,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;IAClE,MAAM,OAAO,GAAG,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;IACjE,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG;YACZ,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChB,MAAM,eAAe,CAAC,0BAA0B,KAAK,aAAa,EAAE,KAAK,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED,MAAM,eAAe,GAAG,+CAA+C,CAAC;AAExE;;;GAGG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,KAAK,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9E,CAAC"}
@@ -1,54 +1,101 @@
1
1
  import { type FinTsFeedback } from './feedback.js';
2
- /** Base class of all errors the client raises about the bank and its data. */
2
+ /**
3
+ * Base class of all errors the client raises about the bank and its data.
4
+ *
5
+ * Each error class states its `name`: a minifier renames classes, and `constructor.name` would show a meaningless one.
6
+ */
3
7
  export declare abstract class FinTsError extends Error {
4
- protected constructor(name: string, message: string, cause?: unknown);
8
+ abstract name: string;
5
9
  }
6
- /** The connection to the bank failed or returned an HTTP error. */
10
+ /**
11
+ * The connection to the bank failed or returned an HTTP error.
12
+ *
13
+ * It carries no `cause`: the transport's own error may hold the message it was sending, PIN and TAN included.
14
+ */
7
15
  export declare class FinTsTransportError extends FinTsError {
8
- /** The HTTP status code of the response, `undefined` if there was none, for example after a timeout. */
16
+ name: string;
17
+ /**
18
+ * The HTTP status code of the bank's answer, `undefined` where none came, for example after a timeout; the client
19
+ * acts on it (`FinTsTransport.post`).
20
+ */
9
21
  readonly statusCode: number | undefined;
10
22
  constructor(message: string, options?: {
11
23
  statusCode?: number;
12
- cause?: unknown;
13
24
  });
14
25
  }
15
26
  /** The bank's response could not be understood. */
16
27
  export declare class FinTsProtocolError extends FinTsError {
17
- constructor(message: string);
28
+ name: string;
18
29
  }
19
30
  /** The bank does not offer the requested business transaction. */
20
31
  export declare class FinTsUnsupportedError extends FinTsError {
21
- constructor(message: string);
32
+ name: string;
33
+ }
34
+ /**
35
+ * The client has no TAN method or medium to log in with: the method in use needs a TAN medium the client could not
36
+ * learn, or the bank offers the user only TAN methods the client cannot run. Pass a medium to
37
+ * `FinTsClient.selectTanMethod`, or choose another method.
38
+ *
39
+ * The client does not send a login the bank would refuse for it, but the steps before, such as the synchronization or
40
+ * the lookup of the TAN media, may have gone out.
41
+ */
42
+ export declare class FinTsTanSetupError extends FinTsError {
43
+ name: string;
22
44
  }
23
45
  /**
24
- * The bank rejected the request; `feedback` holds all return codes.
46
+ * The bank rejected the request; `feedback` holds all return codes. A refused login is a `FinTsLoginRefusedError`.
25
47
  *
26
- * After a refused login every later call that would send the PIN fails with the same error, without contacting the
27
- * bank; create a new client to try again. The README tells which errors refuse a login.
48
+ * The message is not safe to log: by default it holds the code, text and parameters of each error the bank names, such
49
+ * as an IBAN or a login name, and so does `stack`. Log `codes` instead. `feedback` is a getter, not a field, so that
50
+ * `JSON.stringify` and Node.js's report of an uncaught error, which show an error's fields as they are, leave out at
51
+ * least the warnings and successes, such as the new login data of return code 3072.
28
52
  */
29
53
  export declare class FinTsBankError extends FinTsError {
54
+ #private;
55
+ name: string;
56
+ /**
57
+ * A rejection with the return codes in `feedback`; `message` defaults to the errors among them, with the bank's texts
58
+ * and parameters, such as `9010: Konto gesperrt [DE89370400440532013000]`, so it is not safe to log.
59
+ */
60
+ constructor(feedback: readonly FinTsFeedback[], message?: string);
30
61
  /** All return codes of the response, warnings and successes included. */
31
- readonly feedback: readonly FinTsFeedback[];
32
- /** A rejection with the return codes in `feedback`; `message` defaults to the errors among them. */
33
- constructor(feedback: readonly FinTsFeedback[], message?: string, name?: string);
62
+ get feedback(): readonly FinTsFeedback[];
34
63
  /** The return codes of `feedback`. */
35
64
  get codes(): string[];
36
65
  }
37
- /** Wrong or blocked PIN, a refused login as `FinTsBankError` describes it. */
38
- export declare class FinTsPinError extends FinTsBankError {
39
- constructor(feedback: readonly FinTsFeedback[]);
66
+ /**
67
+ * The bank refused the login, so the client sends the PIN no more: every later call that would send it fails with this
68
+ * error without contacting the bank, also in a client restored from the saved state, until
69
+ * `FinTsClient.clearLoginRefusal` takes a PIN the user has entered anew; for good where the bank has changed the login
70
+ * data (`FinTsLoginDataChangedError`).
71
+ *
72
+ * Banks lock the access after a few failed logins, and a return code does not always tell whether the PIN was the
73
+ * reason, so any error in the answer to a login refuses it, also one that ends the dialog, and so does a wrong PIN
74
+ * wherever the bank reports it. Only where the bank names a reason the client can take care of, another TAN method or a
75
+ * new customer system ID, does the same call log in once more, for each reason once. The client refuses the login
76
+ * itself where it could not read the answers to two logins in a row, which the bank may have counted as failed
77
+ * attempts; `feedback` is empty then.
78
+ */
79
+ export declare class FinTsLoginRefusedError extends FinTsBankError {
80
+ name: string;
81
+ }
82
+ /** Wrong or blocked PIN. */
83
+ export declare class FinTsPinError extends FinTsLoginRefusedError {
84
+ name: string;
40
85
  }
41
86
  /** Invalid, expired or rejected TAN, as the bank reports it in answer to a TAN or to an approval status request. */
42
87
  export declare class FinTsTanError extends FinTsBankError {
43
- constructor(feedback: readonly FinTsFeedback[]);
88
+ name: string;
44
89
  }
45
90
  /**
46
- * The bank has changed the user's login data and expects the new ones from now on (return code 3072).
91
+ * The bank has changed the user's login data and expects the new ones from now on (return code 3072), also where it
92
+ * names an error next to them, but for a rejected PIN, which is a `FinTsPinError`.
47
93
  *
48
- * The client has ended the dialog, and every later call fails with this error. Create a new client with the new data; a
49
- * `loginName` replaces user ID and customer ID: pass it as `userId`, without a customer ID.
94
+ * The client has ended the dialog, where the bank opened one, and logs in with the old data no more. Create a new
95
+ * client with the new data; a `loginName` replaces user ID and customer ID: pass it as `userId`, without a customer ID.
50
96
  */
51
- export declare class FinTsLoginDataChangedError extends FinTsBankError {
97
+ export declare class FinTsLoginDataChangedError extends FinTsLoginRefusedError {
98
+ name: string;
52
99
  constructor(feedback: readonly FinTsFeedback[]);
53
100
  /** The new user ID (Benutzerkennung); `undefined` where the bank names none. */
54
101
  get userId(): string | undefined;
@@ -58,16 +105,24 @@ export declare class FinTsLoginDataChangedError extends FinTsBankError {
58
105
  get loginName(): string | undefined;
59
106
  private parameter;
60
107
  }
61
- /** The bank ended the dialog, for example after a timeout. */
108
+ /**
109
+ * The bank ended the dialog, for example after a timeout; the next call logs in anew. Where the bank ends the dialog
110
+ * in answer to a login, the call fails with `FinTsLoginRefusedError` instead.
111
+ */
62
112
  export declare class FinTsDialogAbortedError extends FinTsBankError {
63
- constructor(feedback: readonly FinTsFeedback[]);
113
+ name: string;
64
114
  }
65
115
  /** The user cancelled the TAN entry or the approval in the banking app. */
66
116
  export declare class FinTsTanCancelledError extends FinTsError {
117
+ name: string;
67
118
  constructor();
68
119
  }
69
- /** The user did not approve in the banking app within the bank's polling limit. */
120
+ /**
121
+ * The user did not approve in the banking app in time: within the status requests the bank allows, 60 where it states
122
+ * none, and 10 minutes of polling at most.
123
+ */
70
124
  export declare class FinTsDecoupledTimeoutError extends FinTsError {
125
+ name: string;
71
126
  constructor();
72
127
  }
73
128
  /**
@@ -76,8 +131,10 @@ export declare class FinTsDecoupledTimeoutError extends FinTsError {
76
131
  * It does not extend `FinTsError`: it tells about the app's use of the client, not about the bank.
77
132
  */
78
133
  export declare class FinTsStateError extends Error {
79
- constructor(message: string);
134
+ name: string;
80
135
  }
136
+ /** The error of whatever a closed client is asked to do. */
137
+ export declare function clientClosedError(): FinTsStateError;
81
138
  /**
82
139
  * The most specific error for the errors in `feedback`, the answer to a message that `completesApproval` or not.
83
140
  *
@@ -86,6 +143,23 @@ export declare class FinTsStateError extends Error {
86
143
  * for a wrong TAN, after which it would send the PIN again.
87
144
  */
88
145
  export declare function bankErrorFor(feedback: readonly FinTsFeedback[], completesApproval?: boolean): FinTsBankError;
89
- /** Runs `parse` on data from the bank and reports malformed data as `FinTsProtocolError`. */
146
+ /**
147
+ * The refusal of a login whose answer carried `feedback`: `FinTsPinError` for a rejected PIN, else
148
+ * `FinTsLoginDataChangedError` for new login data, also next to other errors, and `FinTsLoginRefusedError` for anything
149
+ * else. The same for a refusal restored from the saved state, which keeps only `feedback`.
150
+ *
151
+ * New login data end the old ones for good, so the session takes care of no other reason the answer names.
152
+ */
153
+ export declare function loginRefusalFor(feedback: readonly FinTsFeedback[]): FinTsLoginRefusedError;
154
+ /**
155
+ * Runs `parse` on data from the bank and reports malformed data as `FinTsProtocolError`, whose message leaves the data
156
+ * out (`FormatError`).
157
+ */
90
158
  export declare function parseBankData<T>(parse: () => T): T;
159
+ /**
160
+ * Runs `lookup`, which only completes data, such as the SEPA account list; `undefined` where the bank rejects it, so
161
+ * that the caller carries on without it. An aborted dialog counts as a rejection: banks end the dialog along with many.
162
+ * A refused login and a rejected TAN fail the call: the user must hear of them.
163
+ */
164
+ export declare function tryLookUp<T>(lookup: () => Promise<T>): Promise<T | undefined>;
91
165
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9E,8EAA8E;AAC9E,8BAAsB,UAAW,SAAQ,KAAK;IAC5C,SAAS,aA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