@coderoftime/fints 0.0.0-stage → 0.1.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 (254) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +28 -0
  3. package/README.md +156 -2
  4. package/dist/core/account.d.ts +140 -0
  5. package/dist/core/account.d.ts.map +1 -0
  6. package/dist/core/account.js +174 -0
  7. package/dist/core/account.js.map +1 -0
  8. package/dist/core/amount.d.ts +62 -0
  9. package/dist/core/amount.d.ts.map +1 -0
  10. package/dist/core/amount.js +189 -0
  11. package/dist/core/amount.js.map +1 -0
  12. package/dist/core/balance.d.ts +54 -0
  13. package/dist/core/balance.d.ts.map +1 -0
  14. package/dist/core/balance.js +53 -0
  15. package/dist/core/balance.js.map +1 -0
  16. package/dist/core/bank-info.d.ts +49 -0
  17. package/dist/core/bank-info.d.ts.map +1 -0
  18. package/dist/core/bank-info.js +52 -0
  19. package/dist/core/bank-info.js.map +1 -0
  20. package/dist/core/client.d.ts +126 -0
  21. package/dist/core/client.d.ts.map +1 -0
  22. package/dist/core/client.js +2 -0
  23. package/dist/core/client.js.map +1 -0
  24. package/dist/core/config.d.ts +68 -0
  25. package/dist/core/config.d.ts.map +1 -0
  26. package/dist/core/config.js +113 -0
  27. package/dist/core/config.js.map +1 -0
  28. package/dist/core/errors.d.ts +91 -0
  29. package/dist/core/errors.d.ts.map +1 -0
  30. package/dist/core/errors.js +182 -0
  31. package/dist/core/errors.js.map +1 -0
  32. package/dist/core/feedback.d.ts +69 -0
  33. package/dist/core/feedback.d.ts.map +1 -0
  34. package/dist/core/feedback.js +124 -0
  35. package/dist/core/feedback.js.map +1 -0
  36. package/dist/core/transaction.d.ts +98 -0
  37. package/dist/core/transaction.d.ts.map +1 -0
  38. package/dist/core/transaction.js +91 -0
  39. package/dist/core/transaction.js.map +1 -0
  40. package/dist/core/transport.d.ts +37 -0
  41. package/dist/core/transport.d.ts.map +1 -0
  42. package/dist/core/transport.js +92 -0
  43. package/dist/core/transport.js.map +1 -0
  44. package/dist/formats/camt.d.ts +12 -0
  45. package/dist/formats/camt.d.ts.map +1 -0
  46. package/dist/formats/camt.js +159 -0
  47. package/dist/formats/camt.js.map +1 -0
  48. package/dist/formats/mt940.d.ts +42 -0
  49. package/dist/formats/mt940.d.ts.map +1 -0
  50. package/dist/formats/mt940.js +297 -0
  51. package/dist/formats/mt940.js.map +1 -0
  52. package/dist/formats/readers.d.ts +11 -0
  53. package/dist/formats/readers.d.ts.map +1 -0
  54. package/dist/formats/readers.js +47 -0
  55. package/dist/formats/readers.js.map +1 -0
  56. package/dist/formats/sepa-purpose.d.ts +22 -0
  57. package/dist/formats/sepa-purpose.d.ts.map +1 -0
  58. package/dist/formats/sepa-purpose.js +68 -0
  59. package/dist/formats/sepa-purpose.js.map +1 -0
  60. package/dist/index.d.ts +28 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/index.js +27 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/session/app-approval.d.ts +60 -0
  65. package/dist/session/app-approval.d.ts.map +1 -0
  66. package/dist/session/app-approval.js +215 -0
  67. package/dist/session/app-approval.js.map +1 -0
  68. package/dist/session/bank-connection.d.ts +28 -0
  69. package/dist/session/bank-connection.d.ts.map +1 -0
  70. package/dist/session/bank-connection.js +48 -0
  71. package/dist/session/bank-connection.js.map +1 -0
  72. package/dist/session/dialog-runner.d.ts +34 -0
  73. package/dist/session/dialog-runner.d.ts.map +1 -0
  74. package/dist/session/dialog-runner.js +112 -0
  75. package/dist/session/dialog-runner.js.map +1 -0
  76. package/dist/session/login-guard.d.ts +73 -0
  77. package/dist/session/login-guard.d.ts.map +1 -0
  78. package/dist/session/login-guard.js +109 -0
  79. package/dist/session/login-guard.js.map +1 -0
  80. package/dist/session/parameter-data.d.ts +83 -0
  81. package/dist/session/parameter-data.d.ts.map +1 -0
  82. package/dist/session/parameter-data.js +68 -0
  83. package/dist/session/parameter-data.js.map +1 -0
  84. package/dist/session/pin-tan-client.d.ts +54 -0
  85. package/dist/session/pin-tan-client.d.ts.map +1 -0
  86. package/dist/session/pin-tan-client.js +153 -0
  87. package/dist/session/pin-tan-client.js.map +1 -0
  88. package/dist/session/pin-tan-dialog.d.ts +71 -0
  89. package/dist/session/pin-tan-dialog.d.ts.map +1 -0
  90. package/dist/session/pin-tan-dialog.js +124 -0
  91. package/dist/session/pin-tan-dialog.js.map +1 -0
  92. package/dist/session/protocol.d.ts +209 -0
  93. package/dist/session/protocol.d.ts.map +1 -0
  94. package/dist/session/protocol.js +75 -0
  95. package/dist/session/protocol.js.map +1 -0
  96. package/dist/session/response-handler.d.ts +48 -0
  97. package/dist/session/response-handler.d.ts.map +1 -0
  98. package/dist/session/response-handler.js +121 -0
  99. package/dist/session/response-handler.js.map +1 -0
  100. package/dist/session/sepa-accounts.d.ts +34 -0
  101. package/dist/session/sepa-accounts.d.ts.map +1 -0
  102. package/dist/session/sepa-accounts.js +96 -0
  103. package/dist/session/sepa-accounts.js.map +1 -0
  104. package/dist/session/session-setup.d.ts +72 -0
  105. package/dist/session/session-setup.d.ts.map +1 -0
  106. package/dist/session/session-setup.js +160 -0
  107. package/dist/session/session-setup.js.map +1 -0
  108. package/dist/session/session-state.d.ts +47 -0
  109. package/dist/session/session-state.d.ts.map +1 -0
  110. package/dist/session/session-state.js +147 -0
  111. package/dist/session/session-state.js.map +1 -0
  112. package/dist/session/tan-selection.d.ts +88 -0
  113. package/dist/session/tan-selection.d.ts.map +1 -0
  114. package/dist/session/tan-selection.js +178 -0
  115. package/dist/session/tan-selection.js.map +1 -0
  116. package/dist/session/user-prompts.d.ts +61 -0
  117. package/dist/session/user-prompts.d.ts.map +1 -0
  118. package/dist/session/user-prompts.js +164 -0
  119. package/dist/session/user-prompts.js.map +1 -0
  120. package/dist/tan/challenge.d.ts +114 -0
  121. package/dist/tan/challenge.d.ts.map +1 -0
  122. package/dist/tan/challenge.js +185 -0
  123. package/dist/tan/challenge.js.map +1 -0
  124. package/dist/tan/flicker.d.ts +36 -0
  125. package/dist/tan/flicker.d.ts.map +1 -0
  126. package/dist/tan/flicker.js +262 -0
  127. package/dist/tan/flicker.js.map +1 -0
  128. package/dist/tan/tan-image.d.ts +21 -0
  129. package/dist/tan/tan-image.d.ts.map +1 -0
  130. package/dist/tan/tan-image.js +41 -0
  131. package/dist/tan/tan-image.js.map +1 -0
  132. package/dist/tan/tan-models.d.ts +145 -0
  133. package/dist/tan/tan-models.d.ts.map +1 -0
  134. package/dist/tan/tan-models.js +148 -0
  135. package/dist/tan/tan-models.js.map +1 -0
  136. package/dist/util/async.d.ts +24 -0
  137. package/dist/util/async.d.ts.map +1 -0
  138. package/dist/util/async.js +49 -0
  139. package/dist/util/async.js.map +1 -0
  140. package/dist/util/bytes.d.ts +23 -0
  141. package/dist/util/bytes.d.ts.map +1 -0
  142. package/dist/util/bytes.js +136 -0
  143. package/dist/util/bytes.js.map +1 -0
  144. package/dist/util/call-context.d.ts +12 -0
  145. package/dist/util/call-context.d.ts.map +1 -0
  146. package/dist/util/call-context.js +29 -0
  147. package/dist/util/call-context.js.map +1 -0
  148. package/dist/util/dates.d.ts +62 -0
  149. package/dist/util/dates.d.ts.map +1 -0
  150. package/dist/util/dates.js +169 -0
  151. package/dist/util/dates.js.map +1 -0
  152. package/dist/util/errors.d.ts +9 -0
  153. package/dist/util/errors.d.ts.map +1 -0
  154. package/dist/util/errors.js +15 -0
  155. package/dist/util/errors.js.map +1 -0
  156. package/dist/util/immutable-map.d.ts +16 -0
  157. package/dist/util/immutable-map.d.ts.map +1 -0
  158. package/dist/util/immutable-map.js +38 -0
  159. package/dist/util/immutable-map.js.map +1 -0
  160. package/dist/util/json.d.ts +13 -0
  161. package/dist/util/json.d.ts.map +1 -0
  162. package/dist/util/json.js +44 -0
  163. package/dist/util/json.js.map +1 -0
  164. package/dist/util/text.d.ts +20 -0
  165. package/dist/util/text.d.ts.map +1 -0
  166. package/dist/util/text.js +78 -0
  167. package/dist/util/text.js.map +1 -0
  168. package/dist/util/xml.d.ts +35 -0
  169. package/dist/util/xml.d.ts.map +1 -0
  170. package/dist/util/xml.js +183 -0
  171. package/dist/util/xml.js.map +1 -0
  172. package/dist/v3/account-extension.d.ts +25 -0
  173. package/dist/v3/account-extension.d.ts.map +1 -0
  174. package/dist/v3/account-extension.js +176 -0
  175. package/dist/v3/account-extension.js.map +1 -0
  176. package/dist/v3/client.d.ts +24 -0
  177. package/dist/v3/client.d.ts.map +1 -0
  178. package/dist/v3/client.js +16 -0
  179. package/dist/v3/client.js.map +1 -0
  180. package/dist/v3/dialog.d.ts +78 -0
  181. package/dist/v3/dialog.d.ts.map +1 -0
  182. package/dist/v3/dialog.js +138 -0
  183. package/dist/v3/dialog.js.map +1 -0
  184. package/dist/v3/message.d.ts +72 -0
  185. package/dist/v3/message.d.ts.map +1 -0
  186. package/dist/v3/message.js +259 -0
  187. package/dist/v3/message.js.map +1 -0
  188. package/dist/v3/parameters.d.ts +79 -0
  189. package/dist/v3/parameters.d.ts.map +1 -0
  190. package/dist/v3/parameters.js +396 -0
  191. package/dist/v3/parameters.js.map +1 -0
  192. package/dist/v3/protocol.d.ts +68 -0
  193. package/dist/v3/protocol.d.ts.map +1 -0
  194. package/dist/v3/protocol.js +263 -0
  195. package/dist/v3/protocol.js.map +1 -0
  196. package/dist/v3/segments.d.ts +89 -0
  197. package/dist/v3/segments.d.ts.map +1 -0
  198. package/dist/v3/segments.js +283 -0
  199. package/dist/v3/segments.js.map +1 -0
  200. package/dist/v3/syntax.d.ts +76 -0
  201. package/dist/v3/syntax.d.ts.map +1 -0
  202. package/dist/v3/syntax.js +301 -0
  203. package/dist/v3/syntax.js.map +1 -0
  204. package/package.json +63 -4
  205. package/src/core/account.ts +250 -0
  206. package/src/core/amount.ts +209 -0
  207. package/src/core/balance.ts +84 -0
  208. package/src/core/bank-info.ts +66 -0
  209. package/src/core/client.ts +149 -0
  210. package/src/core/config.ts +141 -0
  211. package/src/core/errors.ts +203 -0
  212. package/src/core/feedback.ts +137 -0
  213. package/src/core/transaction.ts +156 -0
  214. package/src/core/transport.ts +114 -0
  215. package/src/formats/camt.ts +169 -0
  216. package/src/formats/mt940.ts +333 -0
  217. package/src/formats/readers.ts +56 -0
  218. package/src/formats/sepa-purpose.ts +75 -0
  219. package/src/index.ts +68 -0
  220. package/src/session/app-approval.ts +265 -0
  221. package/src/session/bank-connection.ts +51 -0
  222. package/src/session/dialog-runner.ts +119 -0
  223. package/src/session/login-guard.ts +135 -0
  224. package/src/session/parameter-data.ts +137 -0
  225. package/src/session/pin-tan-client.ts +186 -0
  226. package/src/session/pin-tan-dialog.ts +160 -0
  227. package/src/session/protocol.ts +311 -0
  228. package/src/session/response-handler.ts +130 -0
  229. package/src/session/sepa-accounts.ts +97 -0
  230. package/src/session/session-setup.ts +165 -0
  231. package/src/session/session-state.ts +170 -0
  232. package/src/session/tan-selection.ts +192 -0
  233. package/src/session/user-prompts.ts +174 -0
  234. package/src/tan/challenge.ts +252 -0
  235. package/src/tan/flicker.ts +270 -0
  236. package/src/tan/tan-image.ts +36 -0
  237. package/src/tan/tan-models.ts +247 -0
  238. package/src/util/async.ts +53 -0
  239. package/src/util/bytes.ts +135 -0
  240. package/src/util/call-context.ts +40 -0
  241. package/src/util/dates.ts +193 -0
  242. package/src/util/errors.ts +16 -0
  243. package/src/util/immutable-map.ts +47 -0
  244. package/src/util/json.ts +51 -0
  245. package/src/util/text.ts +82 -0
  246. package/src/util/xml.ts +172 -0
  247. package/src/v3/account-extension.ts +190 -0
  248. package/src/v3/client.ts +29 -0
  249. package/src/v3/dialog.ts +199 -0
  250. package/src/v3/message.ts +321 -0
  251. package/src/v3/parameters.ts +451 -0
  252. package/src/v3/protocol.ts +331 -0
  253. package/src/v3/segments.ts +331 -0
  254. package/src/v3/syntax.ts +307 -0
@@ -0,0 +1,62 @@
1
+ /** `YYYYMMDD`, the FinTS 3.0 date format. */
2
+ export declare function formatFintsDate(d: Date): string;
3
+ /** `HHMMSS`, the FinTS 3.0 time format. */
4
+ export declare function formatFintsTime(d: Date): string;
5
+ /** `YYYY-MM-DD`, the ISO 8601 date format of camt. */
6
+ export declare function formatIsoDate(d: Date): string;
7
+ /** Parses a FinTS 3.0 date `YYYYMMDD` as a calendar date; `undefined` if it is missing or invalid. */
8
+ export declare function parseFintsDate(date: string | undefined): Date | undefined;
9
+ /**
10
+ * Parses a FinTS 3.0 date `YYYYMMDD` and time `HHMMSS` as the moment they name; `undefined` if either is missing or
11
+ * invalid.
12
+ */
13
+ export declare function parseFintsDateTime(date: string | undefined, time: string | undefined): Date | undefined;
14
+ /**
15
+ * Parses an ISO 8601 date `YYYY-MM-DD` as a calendar date, ignoring extra characters such as a time part; `undefined`
16
+ * if it is missing or invalid.
17
+ */
18
+ export declare function parseIsoDate(date: string | undefined): Date | undefined;
19
+ /** Parses an ISO 8601 date `YYYY-MM-DD` and time `HH:MM:SS` as the moment they name. */
20
+ export declare function parseIsoDateTime(date: string | undefined, time: string | undefined): Date | undefined;
21
+ /**
22
+ * Parses a FinTS 3.0 date `YYYYMMDD` and time `HHMMSS` given in UTC+01:00 all year round, as the account extension of
23
+ * the user parameter data states its times (Formals E.3.1); `undefined` if either is missing or invalid. A time with
24
+ * fewer than six digits lost its leading zeros as a JSON number.
25
+ */
26
+ export declare function parseUtcPlusOneDateTime(date: string | undefined, time: string | undefined): Date | undefined;
27
+ /**
28
+ * The moment a German clock shows the given time.
29
+ *
30
+ * German time is CET (UTC+1), and CEST (UTC+2) from 01:00 UTC on the last Sunday of March to 01:00 UTC on the last
31
+ * Sunday of October (the EU rule). The hour the clocks show twice in October counts as CEST; a time in the hour that is
32
+ * skipped in March counts as CET.
33
+ */
34
+ export declare function germanTime(year: number, month: number, day: number, hour: number, minute: number, second: number): Date;
35
+ /** The calendar day a German clock shows at `moment`, as a local `Date` at midnight like every calendar date. */
36
+ export declare function germanDay(moment: Date): Date;
37
+ /** Local midnight of the day; `month` counts from 1, and years below 100 are not moved to 19xx. */
38
+ export declare function localDate(year: number, month: number, day: number): Date;
39
+ /** The date, or `undefined` if `month` or `day` is out of range; `Date` would roll it over into another date. */
40
+ export declare function validDate(year: number, month: number, day: number): Date | undefined;
41
+ /**
42
+ * The date, with a day beyond the end of the month moved to its last day: banks write 30 February or 31 April for
43
+ * month-end bookings. `undefined` for a month or day that no month has.
44
+ */
45
+ export declare function clampedDate(year: number, month: number, day: number): Date | undefined;
46
+ /**
47
+ * Parses a SWIFT date `YYMMDD`, as MT940 writes it, with month ends as `clampedDate` reads them; years from 80 on count
48
+ * as 19xx. `undefined` if the date is invalid.
49
+ */
50
+ export declare function parseSwiftDate(yymmdd: string): Date | undefined;
51
+ /** Number of days the `month` (1 to 12) of `year` has. */
52
+ export declare function daysInMonth(year: number, month: number): number;
53
+ /** The calendar day `moment` falls on in local time, as a local `Date` at midnight. */
54
+ export declare function calendarDay(moment: Date): Date;
55
+ /**
56
+ * The calendar `day`, moved back to the bank's today if it lies after it: banks reject future dates in queries.
57
+ *
58
+ * The bank's today is the German day at `now`, the current time by default; east of Germany the local day starts
59
+ * earlier.
60
+ */
61
+ export declare function notAfterToday(day: Date | undefined, now?: Date): Date | undefined;
62
+ //# sourceMappingURL=dates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../../src/util/dates.ts"],"names":[],"mappings":"AAcA,6CAA6C;AAC7C,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAE/C;AAED,2CAA2C;AAC3C,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAE/C;AAED,sDAAsD;AACtD,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAE7C;AAOD,sGAAsG;AACtG,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAEzE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS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AgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,GAAG,SAAS,EAAE,GAAG,GAAE,IAAiB,GAAG,IAAI,GAAG,SAAS,CAI7F"}
@@ -0,0 +1,169 @@
1
+ // A value is either a calendar date, a local `Date` at midnight of which only the day counts, or the exact moment of a
2
+ // date with a time of day, which the bank states in German time (see `germanTime`). The parsers keep the two apart: a
3
+ // date without a valid time of day is not a moment.
4
+ const hourMs = 3_600_000;
5
+ function twoDigits(n) {
6
+ return n.toString().padStart(2, '0');
7
+ }
8
+ function year(d) {
9
+ return d.getFullYear().toString().padStart(4, '0');
10
+ }
11
+ /** `YYYYMMDD`, the FinTS 3.0 date format. */
12
+ export function formatFintsDate(d) {
13
+ return `${year(d)}${twoDigits(d.getMonth() + 1)}${twoDigits(d.getDate())}`;
14
+ }
15
+ /** `HHMMSS`, the FinTS 3.0 time format. */
16
+ export function formatFintsTime(d) {
17
+ return `${twoDigits(d.getHours())}${twoDigits(d.getMinutes())}${twoDigits(d.getSeconds())}`;
18
+ }
19
+ /** `YYYY-MM-DD`, the ISO 8601 date format of camt. */
20
+ export function formatIsoDate(d) {
21
+ return `${year(d)}-${twoDigits(d.getMonth() + 1)}-${twoDigits(d.getDate())}`;
22
+ }
23
+ const fintsDate = /^(\d{4})(\d{2})(\d{2})$/;
24
+ const fintsTime = /^(\d{2})(\d{2})(\d{2})/;
25
+ const isoDate = /^(\d{4})-(\d{2})-(\d{2})/;
26
+ const isoTime = /^(\d{2}):(\d{2}):(\d{2})/;
27
+ /** Parses a FinTS 3.0 date `YYYYMMDD` as a calendar date; `undefined` if it is missing or invalid. */
28
+ export function parseFintsDate(date) {
29
+ return parseDate(fintsDate, date);
30
+ }
31
+ /**
32
+ * Parses a FinTS 3.0 date `YYYYMMDD` and time `HHMMSS` as the moment they name; `undefined` if either is missing or
33
+ * invalid.
34
+ */
35
+ export function parseFintsDateTime(date, time) {
36
+ return moment(parseDate(fintsDate, date), fintsTime, time);
37
+ }
38
+ /**
39
+ * Parses an ISO 8601 date `YYYY-MM-DD` as a calendar date, ignoring extra characters such as a time part; `undefined`
40
+ * if it is missing or invalid.
41
+ */
42
+ export function parseIsoDate(date) {
43
+ return parseDate(isoDate, date);
44
+ }
45
+ /** Parses an ISO 8601 date `YYYY-MM-DD` and time `HH:MM:SS` as the moment they name. */
46
+ export function parseIsoDateTime(date, time) {
47
+ return moment(parseDate(isoDate, date), isoTime, time);
48
+ }
49
+ function parseDate(pattern, date) {
50
+ const d = date === undefined ? null : pattern.exec(date);
51
+ return d ? validDate(Number(d[1]), Number(d[2]), Number(d[3])) : undefined;
52
+ }
53
+ /** The moment of the German time matched by `timePattern` in `time` on `day`. */
54
+ function moment(day, timePattern, time) {
55
+ const t = time === undefined ? null : timePattern.exec(time);
56
+ if (day === undefined || !t)
57
+ return undefined;
58
+ const [hour, minute, second] = [Number(t[1]), Number(t[2]), Number(t[3])];
59
+ if (hour > 23 || minute > 59 || second > 59)
60
+ return undefined;
61
+ return germanTime(day.getFullYear(), day.getMonth() + 1, day.getDate(), hour, minute, second);
62
+ }
63
+ /**
64
+ * Parses a FinTS 3.0 date `YYYYMMDD` and time `HHMMSS` given in UTC+01:00 all year round, as the account extension of
65
+ * the user parameter data states its times (Formals E.3.1); `undefined` if either is missing or invalid. A time with
66
+ * fewer than six digits lost its leading zeros as a JSON number.
67
+ */
68
+ export function parseUtcPlusOneDateTime(date, time) {
69
+ const day = parseDate(fintsDate, date);
70
+ const t = time === undefined ? null : fintsTime.exec(time.padStart(6, '0'));
71
+ if (day === undefined || !t)
72
+ return undefined;
73
+ const [hour, minute, second] = [Number(t[1]), Number(t[2]), Number(t[3])];
74
+ if (hour > 23 || minute > 59 || second > 59)
75
+ return undefined;
76
+ return new Date(utc(day.getFullYear(), day.getMonth() + 1, day.getDate(), hour, minute, second) - hourMs);
77
+ }
78
+ /**
79
+ * The moment a German clock shows the given time.
80
+ *
81
+ * German time is CET (UTC+1), and CEST (UTC+2) from 01:00 UTC on the last Sunday of March to 01:00 UTC on the last
82
+ * Sunday of October (the EU rule). The hour the clocks show twice in October counts as CEST; a time in the hour that is
83
+ * skipped in March counts as CET.
84
+ */
85
+ export function germanTime(year, month, day, hour, minute, second) {
86
+ const clock = utc(year, month, day, hour, minute, second);
87
+ const summer = clock - 2 * hourMs;
88
+ return new Date(isSummerTime(summer) ? summer : clock - hourMs);
89
+ }
90
+ /** The calendar day a German clock shows at `moment`, as a local `Date` at midnight like every calendar date. */
91
+ export function germanDay(moment) {
92
+ const utcMs = moment.getTime();
93
+ const clock = new Date(utcMs + (isSummerTime(utcMs) ? 2 : 1) * hourMs);
94
+ return localDate(clock.getUTCFullYear(), clock.getUTCMonth() + 1, clock.getUTCDate());
95
+ }
96
+ function isSummerTime(utcMs) {
97
+ const y = new Date(utcMs).getUTCFullYear();
98
+ return utcMs >= clockChange(y, 3) && utcMs < clockChange(y, 10);
99
+ }
100
+ /** 01:00 UTC on the last Sunday of `month`, when the EU changes the clocks. */
101
+ function clockChange(year, month) {
102
+ const lastDay = daysInMonth(year, month);
103
+ const weekday = new Date(utc(year, month, lastDay, 0, 0, 0)).getUTCDay();
104
+ return utc(year, month, lastDay - weekday, 1, 0, 0);
105
+ }
106
+ /** Milliseconds since the epoch of the UTC time; `month` counts from 1, and years below 100 are not moved to 19xx. */
107
+ function utc(year, month, day, hour, minute, second) {
108
+ const d = new Date(0);
109
+ d.setUTCFullYear(year, month - 1, day);
110
+ d.setUTCHours(hour, minute, second, 0);
111
+ return d.getTime();
112
+ }
113
+ /** Local midnight of the day; `month` counts from 1, and years below 100 are not moved to 19xx. */
114
+ export function localDate(year, month, day) {
115
+ const d = new Date(0);
116
+ d.setFullYear(year, month - 1, day);
117
+ d.setHours(0, 0, 0, 0);
118
+ return d;
119
+ }
120
+ /** The date, or `undefined` if `month` or `day` is out of range; `Date` would roll it over into another date. */
121
+ export function validDate(year, month, day) {
122
+ if (month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month))
123
+ return undefined;
124
+ return localDate(year, month, day);
125
+ }
126
+ /**
127
+ * The date, with a day beyond the end of the month moved to its last day: banks write 30 February or 31 April for
128
+ * month-end bookings. `undefined` for a month or day that no month has.
129
+ */
130
+ export function clampedDate(year, month, day) {
131
+ if (month < 1 || month > 12 || day < 1 || day > 31)
132
+ return undefined;
133
+ return validDate(year, month, day) ?? localDate(year, month, daysInMonth(year, month));
134
+ }
135
+ const swiftDate = /^(\d{2})(\d{2})(\d{2})$/;
136
+ /**
137
+ * Parses a SWIFT date `YYMMDD`, as MT940 writes it, with month ends as `clampedDate` reads them; years from 80 on count
138
+ * as 19xx. `undefined` if the date is invalid.
139
+ */
140
+ export function parseSwiftDate(yymmdd) {
141
+ const m = swiftDate.exec(yymmdd);
142
+ if (!m)
143
+ return undefined;
144
+ const yy = Number(m[1]);
145
+ return clampedDate(yy >= 80 ? 1900 + yy : 2000 + yy, Number(m[2]), Number(m[3]));
146
+ }
147
+ /** Number of days the `month` (1 to 12) of `year` has. */
148
+ export function daysInMonth(year, month) {
149
+ if (month === 2)
150
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0 ? 29 : 28;
151
+ return [4, 6, 9, 11].includes(month) ? 30 : 31;
152
+ }
153
+ /** The calendar day `moment` falls on in local time, as a local `Date` at midnight. */
154
+ export function calendarDay(moment) {
155
+ return localDate(moment.getFullYear(), moment.getMonth() + 1, moment.getDate());
156
+ }
157
+ /**
158
+ * The calendar `day`, moved back to the bank's today if it lies after it: banks reject future dates in queries.
159
+ *
160
+ * The bank's today is the German day at `now`, the current time by default; east of Germany the local day starts
161
+ * earlier.
162
+ */
163
+ export function notAfterToday(day, now = new Date()) {
164
+ if (day === undefined)
165
+ return undefined;
166
+ const today = germanDay(now);
167
+ return day.getTime() > today.getTime() ? today : day;
168
+ }
169
+ //# sourceMappingURL=dates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dates.js","sourceRoot":"","sources":["../../src/util/dates.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,sHAAsH;AACtH,oDAAoD;AAEpD,MAAM,MAAM,GAAG,SAAS,CAAC;AAEzB,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,IAAI,CAAC,CAAO;IACnB,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,eAAe,CAAC,CAAO;IACrC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;AAC7E,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,eAAe,CAAC,CAAO;IACrC,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;AAC9F,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,aAAa,CAAC,CAAO;IACnC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;AAC/E,CAAC;AAED,MAAM,SAAS,GAAG,yBAAyB,CAAC;AAC5C,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CAAC;AACnF,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,KAAa;IACrD,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,IAAI,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3F,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACjD,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,WAAW,CAAC,MAAY;IACtC,OAAO,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAClF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,GAAqB,EAAE,MAAY,IAAI,IAAI,EAAE;IACzE,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;AACvD,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** Data that do not have the expected format, such as a malformed MT940 line or amount. */
2
+ export declare class FormatError extends Error {
3
+ /** The part of the data that is malformed, where the parser can tell it. */
4
+ readonly source: string | undefined;
5
+ constructor(message: string, source?: string);
6
+ }
7
+ /** An argument the function cannot work with, such as an empty PIN. The message never contains a PIN. */
8
+ export declare function invalidArgument(message: string, name?: string): TypeError;
9
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/util/errors.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,qBAAa,WAAY,SAAQ,KAAK;IACpC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAK7C;AAED,yGAAyG;AACzG,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAEzE"}
@@ -0,0 +1,15 @@
1
+ /** Data that do not have the expected format, such as a malformed MT940 line or amount. */
2
+ export class FormatError extends Error {
3
+ /** The part of the data that is malformed, where the parser can tell it. */
4
+ source;
5
+ constructor(message, source) {
6
+ super(source === undefined ? message : `${message}: ${source}`);
7
+ this.name = 'FormatError';
8
+ this.source = source;
9
+ }
10
+ }
11
+ /** An argument the function cannot work with, such as an empty PIN. The message never contains a PIN. */
12
+ export function invalidArgument(message, name) {
13
+ return new TypeError(name === undefined ? message : `Invalid argument (${name}): ${message}`);
14
+ }
15
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/util/errors.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,4EAA4E;IACnE,MAAM,CAAqB;IAEpC,YAAY,OAAe,EAAE,MAAe;QAC1C,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,MAAM,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,yGAAyG;AACzG,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,IAAa;IAC5D,OAAO,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB,IAAI,MAAM,OAAO,EAAE,CAAC,CAAC;AAChG,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** A map that cannot be changed, also not at runtime: it has no `set`, `delete` or `clear`. */
2
+ export declare class ImmutableMap<K, V> implements ReadonlyMap<K, V> {
3
+ private readonly map;
4
+ constructor(entries?: Iterable<readonly [K, V]>);
5
+ get size(): number;
6
+ get(key: K): V | undefined;
7
+ has(key: K): boolean;
8
+ forEach(callback: (value: V, key: K, map: ReadonlyMap<K, V>) => void): void;
9
+ entries(): MapIterator<[K, V]>;
10
+ keys(): MapIterator<K>;
11
+ values(): MapIterator<V>;
12
+ [Symbol.iterator](): MapIterator<[K, V]>;
13
+ /** A plain object of the entries, for JSON and for display. */
14
+ toJSON(): Record<string, V>;
15
+ }
16
+ //# sourceMappingURL=immutable-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immutable-map.d.ts","sourceRoot":"","sources":["../../src/util/immutable-map.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,qBAAa,YAAY,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;gBAEpB,OAAO,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAI/C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAI1B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAM3E,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAI9B,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC;IAItB,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;IAIxB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAIxC,+DAA+D;IAC/D,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;CAG5B"}
@@ -0,0 +1,38 @@
1
+ /** A map that cannot be changed, also not at runtime: it has no `set`, `delete` or `clear`. */
2
+ export class ImmutableMap {
3
+ map;
4
+ constructor(entries) {
5
+ this.map = new Map(entries);
6
+ }
7
+ get size() {
8
+ return this.map.size;
9
+ }
10
+ get(key) {
11
+ return this.map.get(key);
12
+ }
13
+ has(key) {
14
+ return this.map.has(key);
15
+ }
16
+ forEach(callback) {
17
+ this.map.forEach((value, key) => {
18
+ callback(value, key, this);
19
+ });
20
+ }
21
+ entries() {
22
+ return this.map.entries();
23
+ }
24
+ keys() {
25
+ return this.map.keys();
26
+ }
27
+ values() {
28
+ return this.map.values();
29
+ }
30
+ [Symbol.iterator]() {
31
+ return this.map.entries();
32
+ }
33
+ /** A plain object of the entries, for JSON and for display. */
34
+ toJSON() {
35
+ return Object.fromEntries([...this.map].map(([key, value]) => [String(key), value]));
36
+ }
37
+ }
38
+ //# sourceMappingURL=immutable-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immutable-map.js","sourceRoot":"","sources":["../../src/util/immutable-map.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,MAAM,OAAO,YAAY;IACN,GAAG,CAAY;IAEhC,YAAY,OAAmC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,GAAG,CAAC,GAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,GAAG,CAAC,GAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,CAAC,QAA4D;QAClE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC9B,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IAED,+DAA+D;IAC/D,MAAM;QACJ,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACvF,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /** A JSON object read from a saved state. */
2
+ export type JsonObject = Record<string, unknown>;
3
+ export declare function isJsonObject(value: unknown): value is JsonObject;
4
+ /** The optional string at `key`; throws `FormatError` for a value of another type. */
5
+ export declare function readOptionalString(json: JsonObject, key: string): string | undefined;
6
+ /** The optional integer at `key`; throws `FormatError` for a value of another type. */
7
+ export declare function readOptionalInt(json: JsonObject, key: string): number | undefined;
8
+ /** The object at `key`; throws `FormatError` if it is missing or not an object. */
9
+ export declare function readObject(json: JsonObject, key: string): JsonObject;
10
+ /** The optional list at `key`, each element checked by `isElement`; throws `FormatError` for anything else. */
11
+ export declare function readOptionalList<T>(json: JsonObject, key: string, isElement: (value: unknown) => value is T): T[] | undefined;
12
+ export declare function isString(value: unknown): value is string;
13
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/util/json.ts"],"names":[],"mappings":"AAEA,6CAA6C;AAC7C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKpF;AAED,uFAAuF;AACvF,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOjF;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAIpE;AAED,+GAA+G;AAC/G,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,GACxC,CAAC,EAAE,GAAG,SAAS,CAOjB;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD"}
@@ -0,0 +1,44 @@
1
+ import { FormatError } from './errors.js';
2
+ export function isJsonObject(value) {
3
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
4
+ }
5
+ /** The optional string at `key`; throws `FormatError` for a value of another type. */
6
+ export function readOptionalString(json, key) {
7
+ const value = json[key];
8
+ if (value === undefined || value === null)
9
+ return undefined;
10
+ if (typeof value !== 'string')
11
+ throw new FormatError(`Saved state: "${key}" is not a string`);
12
+ return value;
13
+ }
14
+ /** The optional integer at `key`; throws `FormatError` for a value of another type. */
15
+ export function readOptionalInt(json, key) {
16
+ const value = json[key];
17
+ if (value === undefined || value === null)
18
+ return undefined;
19
+ if (typeof value !== 'number' || !Number.isInteger(value)) {
20
+ throw new FormatError(`Saved state: "${key}" is not an integer`);
21
+ }
22
+ return value;
23
+ }
24
+ /** The object at `key`; throws `FormatError` if it is missing or not an object. */
25
+ export function readObject(json, key) {
26
+ const value = json[key];
27
+ if (!isJsonObject(value))
28
+ throw new FormatError(`Saved state: "${key}" is not an object`);
29
+ return value;
30
+ }
31
+ /** The optional list at `key`, each element checked by `isElement`; throws `FormatError` for anything else. */
32
+ export function readOptionalList(json, key, isElement) {
33
+ const value = json[key];
34
+ if (value === undefined || value === null)
35
+ return undefined;
36
+ if (!Array.isArray(value) || !value.every(isElement)) {
37
+ throw new FormatError(`Saved state: "${key}" is not a list of the expected values`);
38
+ }
39
+ return value;
40
+ }
41
+ export function isString(value) {
42
+ return typeof value === 'string';
43
+ }
44
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/util/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1C,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,kBAAkB,CAAC,IAAgB,EAAE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,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,WAAW,CAAC,iBAAiB,GAAG,wCAAwC,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /** Decodes text from the bank, which may be UTF-8 (with or without BOM) or ISO 8859-1. */
2
+ export declare function decodeBankText(bytes: Uint8Array): string;
3
+ /** Decodes an XML document, honouring an ISO 8859-1 or Windows-1252 encoding declaration. */
4
+ export declare function decodeXmlText(bytes: Uint8Array): string;
5
+ /** Decodes Windows-1252, which matches ISO 8859-1 except for `€`, typographic quotes and a few letters. */
6
+ export declare function decodeWindows1252(bytes: Uint8Array): string;
7
+ /**
8
+ * The last four characters of `id`, such as an IBAN or a card number, after an ellipsis: enough to tell two apart, too
9
+ * little to identify one in a log.
10
+ */
11
+ export declare function maskedId(id: string): string;
12
+ /** `text` without spaces and line breaks. */
13
+ export declare function withoutWhitespace(text: string): string;
14
+ /** Decodes base64 that may be broken into lines; throws `FormatError` if it is invalid. */
15
+ export declare function decodeBase64Lines(text: string): Uint8Array;
16
+ /** `text` with every match of `pattern`, a literal string, escaped for use in a regular expression. */
17
+ export declare function escapeRegExp(text: string): string;
18
+ /** The integer `text` states, decimal digits with an optional sign and blanks around; `undefined` for anything else. */
19
+ export declare function tryParseInt(text: string | undefined): number | undefined;
20
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/util/text.ts"],"names":[],"mappings":"AAMA,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAUxD;AAED,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAcvD;AAYD,2GAA2G;AAC3G,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAI3D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,6CAA6C;AAC7C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAE1D;AAED,uGAAuG;AACvG,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wHAAwH;AACxH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAIxE"}
@@ -0,0 +1,78 @@
1
+ import { base64Decode, latin1Decode, utf8Decode } from './bytes.js';
2
+ import { FormatError } from './errors.js';
3
+ const xmlEncodingDeclaration = /encoding\s*=\s*["']([A-Za-z0-9._-]+)["']/;
4
+ const whitespace = /\s/g;
5
+ /** Decodes text from the bank, which may be UTF-8 (with or without BOM) or ISO 8859-1. */
6
+ export function decodeBankText(bytes) {
7
+ const hasBom = bytes.length >= 3 && bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf;
8
+ const content = hasBom ? bytes.subarray(3) : bytes;
9
+ if (content.every((b) => b < 0x80))
10
+ return latin1Decode(content);
11
+ try {
12
+ return utf8Decode(content);
13
+ }
14
+ catch (error) {
15
+ if (!(error instanceof FormatError))
16
+ throw error;
17
+ return hasBom ? utf8Decode(content, true) : latin1Decode(content);
18
+ }
19
+ }
20
+ /** Decodes an XML document, honouring an ISO 8859-1 or Windows-1252 encoding declaration. */
21
+ export function decodeXmlText(bytes) {
22
+ const head = latin1Decode(bytes.length > 200 ? bytes.subarray(0, 200) : bytes);
23
+ switch (xmlEncodingDeclaration.exec(head)?.[1]?.toLowerCase()) {
24
+ case 'windows-1252':
25
+ case 'cp1252':
26
+ return decodeWindows1252(bytes);
27
+ case 'iso-8859-1':
28
+ case 'iso8859-1':
29
+ case 'latin1':
30
+ case 'latin-1':
31
+ return latin1Decode(bytes);
32
+ default:
33
+ return decodeBankText(bytes);
34
+ }
35
+ }
36
+ /**
37
+ * The code points of the Windows-1252 bytes 0x80 to 0x9F, where ISO 8859-1 has control characters; the five unassigned
38
+ * bytes keep their code.
39
+ */
40
+ const windows1252High = [
41
+ 0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d,
42
+ 0x017d, 0x008f, 0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x02dc, 0x2122, 0x0161, 0x203a,
43
+ 0x0153, 0x009d, 0x017e, 0x0178,
44
+ ];
45
+ /** Decodes Windows-1252, which matches ISO 8859-1 except for `€`, typographic quotes and a few letters. */
46
+ export function decodeWindows1252(bytes) {
47
+ let text = '';
48
+ for (const b of bytes)
49
+ text += String.fromCharCode(b >= 0x80 && b < 0xa0 ? windows1252High[b - 0x80] : b);
50
+ return text;
51
+ }
52
+ /**
53
+ * The last four characters of `id`, such as an IBAN or a card number, after an ellipsis: enough to tell two apart, too
54
+ * little to identify one in a log.
55
+ */
56
+ export function maskedId(id) {
57
+ return id.length <= 4 ? '…' : `…${id.substring(id.length - 4)}`;
58
+ }
59
+ /** `text` without spaces and line breaks. */
60
+ export function withoutWhitespace(text) {
61
+ return text.replace(whitespace, '');
62
+ }
63
+ /** Decodes base64 that may be broken into lines; throws `FormatError` if it is invalid. */
64
+ export function decodeBase64Lines(text) {
65
+ return base64Decode(withoutWhitespace(text));
66
+ }
67
+ /** `text` with every match of `pattern`, a literal string, escaped for use in a regular expression. */
68
+ export function escapeRegExp(text) {
69
+ return text.replace(/[.*+?^${}()|[\]\\/-]/g, '\\$&');
70
+ }
71
+ /** The integer `text` states, decimal digits with an optional sign and blanks around; `undefined` for anything else. */
72
+ export function tryParseInt(text) {
73
+ if (text === undefined)
74
+ return undefined;
75
+ const match = /^\s*([+-]?\d+)\s*$/.exec(text);
76
+ return match ? Number(match[1]) : undefined;
77
+ }
78
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/util/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,sBAAsB,GAAG,0CAA0C,CAAC;AAC1E,MAAM,UAAU,GAAG,KAAK,CAAC;AAEzB,0FAA0F;AAC1F,MAAM,UAAU,cAAc,CAAC,KAAiB;IAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAChG,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnD,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;QAAE,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;IACjE,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,WAAW,CAAC;YAAE,MAAM,KAAK,CAAC;QACjD,OAAO,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC;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AAC,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,GAAG,IAAI,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3G,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,OAAO,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;AAClE,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAED,wHAAwH;AACxH,MAAM,UAAU,WAAW,CAAC,IAAwB;IAClD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,KAAK,GAAG,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * An element of a parsed XML document, looked up by local name: camt documents come with and without namespace
3
+ * prefixes.
4
+ */
5
+ export declare class XmlElement {
6
+ /** The name without namespace prefix. */
7
+ readonly localName: string;
8
+ /** The attributes by name without namespace prefix; namespace declarations are left out. */
9
+ readonly attributes: ReadonlyMap<string, string>;
10
+ readonly children: (XmlElement | string)[];
11
+ constructor(
12
+ /** The name without namespace prefix. */
13
+ localName: string,
14
+ /** The attributes by name without namespace prefix; namespace declarations are left out. */
15
+ attributes: ReadonlyMap<string, string>);
16
+ get childElements(): XmlElement[];
17
+ /** The text of this element and all below it. */
18
+ get innerText(): string;
19
+ getAttribute(localName: string): string | undefined;
20
+ /** The first child element called `localName`. */
21
+ child(localName: string): XmlElement | undefined;
22
+ /** The element reached by following child names along `path`; this element for an empty path. */
23
+ at(path: readonly string[]): XmlElement | undefined;
24
+ /** The trimmed text of the element at `path`, or `undefined` if it is missing or empty. */
25
+ textAt(path: readonly string[]): string | undefined;
26
+ /** All elements below this one called `localName`, in document order. */
27
+ descendantsNamed(localName: string): XmlElement[];
28
+ }
29
+ /**
30
+ * Parses an XML document and returns its root element; throws `FormatError` if it is not well-formed.
31
+ *
32
+ * A document type declaration is refused: bank data have none, and its entities could expand without limit.
33
+ */
34
+ export declare function parseXml(xml: string): XmlElement;
35
+ //# sourceMappingURL=xml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../../src/util/xml.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,UAAU;IAInB,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,4FAA4F;IAC5F,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;IANlD,QAAQ,CAAC,QAAQ,EAAE,CAAC,UAAU,GAAG,MAAM,CAAC,EAAE,CAAM;;IAG9C,yCAAyC;IAChC,SAAS,EAAE,MAAM;IAC1B,4FAA4F;IACnF,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;IAGlD,IAAI,aAAa,IAAI,UAAU,EAAE,CAEhC;IAED,iDAAiD;IACjD,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAInD,kDAAkD;IAClD,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIhD,iGAAiG;IACjG,EAAE,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,GAAG,SAAS;IAInD,2FAA2F;IAC3F,MAAM,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS;IAKnD,yEAAyE;IACzE,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE;CAWlD;AAoCD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAyEhD"}