@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.
- package/CHANGELOG.md +11 -0
- package/LICENSE +28 -0
- package/README.md +156 -2
- package/dist/core/account.d.ts +140 -0
- package/dist/core/account.d.ts.map +1 -0
- package/dist/core/account.js +174 -0
- package/dist/core/account.js.map +1 -0
- package/dist/core/amount.d.ts +62 -0
- package/dist/core/amount.d.ts.map +1 -0
- package/dist/core/amount.js +189 -0
- package/dist/core/amount.js.map +1 -0
- package/dist/core/balance.d.ts +54 -0
- package/dist/core/balance.d.ts.map +1 -0
- package/dist/core/balance.js +53 -0
- package/dist/core/balance.js.map +1 -0
- package/dist/core/bank-info.d.ts +49 -0
- package/dist/core/bank-info.d.ts.map +1 -0
- package/dist/core/bank-info.js +52 -0
- package/dist/core/bank-info.js.map +1 -0
- package/dist/core/client.d.ts +126 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +2 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/config.d.ts +68 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +113 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/errors.d.ts +91 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +182 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/feedback.d.ts +69 -0
- package/dist/core/feedback.d.ts.map +1 -0
- package/dist/core/feedback.js +124 -0
- package/dist/core/feedback.js.map +1 -0
- package/dist/core/transaction.d.ts +98 -0
- package/dist/core/transaction.d.ts.map +1 -0
- package/dist/core/transaction.js +91 -0
- package/dist/core/transaction.js.map +1 -0
- package/dist/core/transport.d.ts +37 -0
- package/dist/core/transport.d.ts.map +1 -0
- package/dist/core/transport.js +92 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/formats/camt.d.ts +12 -0
- package/dist/formats/camt.d.ts.map +1 -0
- package/dist/formats/camt.js +159 -0
- package/dist/formats/camt.js.map +1 -0
- package/dist/formats/mt940.d.ts +42 -0
- package/dist/formats/mt940.d.ts.map +1 -0
- package/dist/formats/mt940.js +297 -0
- package/dist/formats/mt940.js.map +1 -0
- package/dist/formats/readers.d.ts +11 -0
- package/dist/formats/readers.d.ts.map +1 -0
- package/dist/formats/readers.js +47 -0
- package/dist/formats/readers.js.map +1 -0
- package/dist/formats/sepa-purpose.d.ts +22 -0
- package/dist/formats/sepa-purpose.d.ts.map +1 -0
- package/dist/formats/sepa-purpose.js +68 -0
- package/dist/formats/sepa-purpose.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/session/app-approval.d.ts +60 -0
- package/dist/session/app-approval.d.ts.map +1 -0
- package/dist/session/app-approval.js +215 -0
- package/dist/session/app-approval.js.map +1 -0
- package/dist/session/bank-connection.d.ts +28 -0
- package/dist/session/bank-connection.d.ts.map +1 -0
- package/dist/session/bank-connection.js +48 -0
- package/dist/session/bank-connection.js.map +1 -0
- package/dist/session/dialog-runner.d.ts +34 -0
- package/dist/session/dialog-runner.d.ts.map +1 -0
- package/dist/session/dialog-runner.js +112 -0
- package/dist/session/dialog-runner.js.map +1 -0
- package/dist/session/login-guard.d.ts +73 -0
- package/dist/session/login-guard.d.ts.map +1 -0
- package/dist/session/login-guard.js +109 -0
- package/dist/session/login-guard.js.map +1 -0
- package/dist/session/parameter-data.d.ts +83 -0
- package/dist/session/parameter-data.d.ts.map +1 -0
- package/dist/session/parameter-data.js +68 -0
- package/dist/session/parameter-data.js.map +1 -0
- package/dist/session/pin-tan-client.d.ts +54 -0
- package/dist/session/pin-tan-client.d.ts.map +1 -0
- package/dist/session/pin-tan-client.js +153 -0
- package/dist/session/pin-tan-client.js.map +1 -0
- package/dist/session/pin-tan-dialog.d.ts +71 -0
- package/dist/session/pin-tan-dialog.d.ts.map +1 -0
- package/dist/session/pin-tan-dialog.js +124 -0
- package/dist/session/pin-tan-dialog.js.map +1 -0
- package/dist/session/protocol.d.ts +209 -0
- package/dist/session/protocol.d.ts.map +1 -0
- package/dist/session/protocol.js +75 -0
- package/dist/session/protocol.js.map +1 -0
- package/dist/session/response-handler.d.ts +48 -0
- package/dist/session/response-handler.d.ts.map +1 -0
- package/dist/session/response-handler.js +121 -0
- package/dist/session/response-handler.js.map +1 -0
- package/dist/session/sepa-accounts.d.ts +34 -0
- package/dist/session/sepa-accounts.d.ts.map +1 -0
- package/dist/session/sepa-accounts.js +96 -0
- package/dist/session/sepa-accounts.js.map +1 -0
- package/dist/session/session-setup.d.ts +72 -0
- package/dist/session/session-setup.d.ts.map +1 -0
- package/dist/session/session-setup.js +160 -0
- package/dist/session/session-setup.js.map +1 -0
- package/dist/session/session-state.d.ts +47 -0
- package/dist/session/session-state.d.ts.map +1 -0
- package/dist/session/session-state.js +147 -0
- package/dist/session/session-state.js.map +1 -0
- package/dist/session/tan-selection.d.ts +88 -0
- package/dist/session/tan-selection.d.ts.map +1 -0
- package/dist/session/tan-selection.js +178 -0
- package/dist/session/tan-selection.js.map +1 -0
- package/dist/session/user-prompts.d.ts +61 -0
- package/dist/session/user-prompts.d.ts.map +1 -0
- package/dist/session/user-prompts.js +164 -0
- package/dist/session/user-prompts.js.map +1 -0
- package/dist/tan/challenge.d.ts +114 -0
- package/dist/tan/challenge.d.ts.map +1 -0
- package/dist/tan/challenge.js +185 -0
- package/dist/tan/challenge.js.map +1 -0
- package/dist/tan/flicker.d.ts +36 -0
- package/dist/tan/flicker.d.ts.map +1 -0
- package/dist/tan/flicker.js +262 -0
- package/dist/tan/flicker.js.map +1 -0
- package/dist/tan/tan-image.d.ts +21 -0
- package/dist/tan/tan-image.d.ts.map +1 -0
- package/dist/tan/tan-image.js +41 -0
- package/dist/tan/tan-image.js.map +1 -0
- package/dist/tan/tan-models.d.ts +145 -0
- package/dist/tan/tan-models.d.ts.map +1 -0
- package/dist/tan/tan-models.js +148 -0
- package/dist/tan/tan-models.js.map +1 -0
- package/dist/util/async.d.ts +24 -0
- package/dist/util/async.d.ts.map +1 -0
- package/dist/util/async.js +49 -0
- package/dist/util/async.js.map +1 -0
- package/dist/util/bytes.d.ts +23 -0
- package/dist/util/bytes.d.ts.map +1 -0
- package/dist/util/bytes.js +136 -0
- package/dist/util/bytes.js.map +1 -0
- package/dist/util/call-context.d.ts +12 -0
- package/dist/util/call-context.d.ts.map +1 -0
- package/dist/util/call-context.js +29 -0
- package/dist/util/call-context.js.map +1 -0
- package/dist/util/dates.d.ts +62 -0
- package/dist/util/dates.d.ts.map +1 -0
- package/dist/util/dates.js +169 -0
- package/dist/util/dates.js.map +1 -0
- package/dist/util/errors.d.ts +9 -0
- package/dist/util/errors.d.ts.map +1 -0
- package/dist/util/errors.js +15 -0
- package/dist/util/errors.js.map +1 -0
- package/dist/util/immutable-map.d.ts +16 -0
- package/dist/util/immutable-map.d.ts.map +1 -0
- package/dist/util/immutable-map.js +38 -0
- package/dist/util/immutable-map.js.map +1 -0
- package/dist/util/json.d.ts +13 -0
- package/dist/util/json.d.ts.map +1 -0
- package/dist/util/json.js +44 -0
- package/dist/util/json.js.map +1 -0
- package/dist/util/text.d.ts +20 -0
- package/dist/util/text.d.ts.map +1 -0
- package/dist/util/text.js +78 -0
- package/dist/util/text.js.map +1 -0
- package/dist/util/xml.d.ts +35 -0
- package/dist/util/xml.d.ts.map +1 -0
- package/dist/util/xml.js +183 -0
- package/dist/util/xml.js.map +1 -0
- package/dist/v3/account-extension.d.ts +25 -0
- package/dist/v3/account-extension.d.ts.map +1 -0
- package/dist/v3/account-extension.js +176 -0
- package/dist/v3/account-extension.js.map +1 -0
- package/dist/v3/client.d.ts +24 -0
- package/dist/v3/client.d.ts.map +1 -0
- package/dist/v3/client.js +16 -0
- package/dist/v3/client.js.map +1 -0
- package/dist/v3/dialog.d.ts +78 -0
- package/dist/v3/dialog.d.ts.map +1 -0
- package/dist/v3/dialog.js +138 -0
- package/dist/v3/dialog.js.map +1 -0
- package/dist/v3/message.d.ts +72 -0
- package/dist/v3/message.d.ts.map +1 -0
- package/dist/v3/message.js +259 -0
- package/dist/v3/message.js.map +1 -0
- package/dist/v3/parameters.d.ts +79 -0
- package/dist/v3/parameters.d.ts.map +1 -0
- package/dist/v3/parameters.js +396 -0
- package/dist/v3/parameters.js.map +1 -0
- package/dist/v3/protocol.d.ts +68 -0
- package/dist/v3/protocol.d.ts.map +1 -0
- package/dist/v3/protocol.js +263 -0
- package/dist/v3/protocol.js.map +1 -0
- package/dist/v3/segments.d.ts +89 -0
- package/dist/v3/segments.d.ts.map +1 -0
- package/dist/v3/segments.js +283 -0
- package/dist/v3/segments.js.map +1 -0
- package/dist/v3/syntax.d.ts +76 -0
- package/dist/v3/syntax.d.ts.map +1 -0
- package/dist/v3/syntax.js +301 -0
- package/dist/v3/syntax.js.map +1 -0
- package/package.json +63 -4
- package/src/core/account.ts +250 -0
- package/src/core/amount.ts +209 -0
- package/src/core/balance.ts +84 -0
- package/src/core/bank-info.ts +66 -0
- package/src/core/client.ts +149 -0
- package/src/core/config.ts +141 -0
- package/src/core/errors.ts +203 -0
- package/src/core/feedback.ts +137 -0
- package/src/core/transaction.ts +156 -0
- package/src/core/transport.ts +114 -0
- package/src/formats/camt.ts +169 -0
- package/src/formats/mt940.ts +333 -0
- package/src/formats/readers.ts +56 -0
- package/src/formats/sepa-purpose.ts +75 -0
- package/src/index.ts +68 -0
- package/src/session/app-approval.ts +265 -0
- package/src/session/bank-connection.ts +51 -0
- package/src/session/dialog-runner.ts +119 -0
- package/src/session/login-guard.ts +135 -0
- package/src/session/parameter-data.ts +137 -0
- package/src/session/pin-tan-client.ts +186 -0
- package/src/session/pin-tan-dialog.ts +160 -0
- package/src/session/protocol.ts +311 -0
- package/src/session/response-handler.ts +130 -0
- package/src/session/sepa-accounts.ts +97 -0
- package/src/session/session-setup.ts +165 -0
- package/src/session/session-state.ts +170 -0
- package/src/session/tan-selection.ts +192 -0
- package/src/session/user-prompts.ts +174 -0
- package/src/tan/challenge.ts +252 -0
- package/src/tan/flicker.ts +270 -0
- package/src/tan/tan-image.ts +36 -0
- package/src/tan/tan-models.ts +247 -0
- package/src/util/async.ts +53 -0
- package/src/util/bytes.ts +135 -0
- package/src/util/call-context.ts +40 -0
- package/src/util/dates.ts +193 -0
- package/src/util/errors.ts +16 -0
- package/src/util/immutable-map.ts +47 -0
- package/src/util/json.ts +51 -0
- package/src/util/text.ts +82 -0
- package/src/util/xml.ts +172 -0
- package/src/v3/account-extension.ts +190 -0
- package/src/v3/client.ts +29 -0
- package/src/v3/dialog.ts +199 -0
- package/src/v3/message.ts +321 -0
- package/src/v3/parameters.ts +451 -0
- package/src/v3/protocol.ts +331 -0
- package/src/v3/segments.ts +331 -0
- package/src/v3/syntax.ts +307 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { invalidArgument } from '../util/errors.js';
|
|
2
|
+
/** Numeric country code of Germany (ISO 3166), where FinTS banks are. */
|
|
3
|
+
export const defaultCountryCode = '280';
|
|
4
|
+
/** Connection and login data for one bank user. */
|
|
5
|
+
export class FinTsConfig {
|
|
6
|
+
/** Numeric country code of Germany (ISO 3166), where FinTS banks are. */
|
|
7
|
+
static defaultCountryCode = defaultCountryCode;
|
|
8
|
+
url;
|
|
9
|
+
bankCode;
|
|
10
|
+
userId;
|
|
11
|
+
explicitCustomerId;
|
|
12
|
+
productId;
|
|
13
|
+
productVersion;
|
|
14
|
+
countryCode;
|
|
15
|
+
allowInsecureUrl;
|
|
16
|
+
/**
|
|
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.
|
|
19
|
+
*/
|
|
20
|
+
constructor(init) {
|
|
21
|
+
// `URL` would read `https:bank` and `https:///bank` as the host `bank`; such a URL is a mistake, not a host.
|
|
22
|
+
if (typeof init.url === 'string' && !/^[a-z][a-z0-9+.-]*:\/\/[^/]/i.test(init.url)) {
|
|
23
|
+
throw invalidArgument('The URL has no host', 'url');
|
|
24
|
+
}
|
|
25
|
+
let url;
|
|
26
|
+
try {
|
|
27
|
+
url = new URL(init.url);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw invalidArgument('Not a valid URL', 'url');
|
|
31
|
+
}
|
|
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;
|
|
40
|
+
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');
|
|
48
|
+
}
|
|
49
|
+
/** Customer ID; defaults to `userId`. */
|
|
50
|
+
get customerId() {
|
|
51
|
+
return this.explicitCustomerId ?? this.userId;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function requireNotBlank(value, name) {
|
|
55
|
+
if (value.trim() === '')
|
|
56
|
+
throw invalidArgument('Must not be empty', name);
|
|
57
|
+
}
|
|
58
|
+
/** The host of `url` without the brackets of an IPv6 address, as `URL` writes it. */
|
|
59
|
+
export function hostOf(url) {
|
|
60
|
+
const host = url.hostname;
|
|
61
|
+
return host.startsWith('[') && host.endsWith(']') ? host.substring(1, host.length - 1) : host;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Throws `TypeError` unless `url` names a host and uses https: the PIN travels with every message.
|
|
65
|
+
*
|
|
66
|
+
* With `allowInsecure`, http is accepted for loopback hosts only.
|
|
67
|
+
*/
|
|
68
|
+
export function requireSecureUrl(url, allowInsecure = false) {
|
|
69
|
+
if (hostOf(url) === '')
|
|
70
|
+
throw invalidArgument('The URL has no host', 'url');
|
|
71
|
+
const loopbackHttp = allowInsecure && url.protocol === 'http:' && isLoopback(hostOf(url));
|
|
72
|
+
if (url.protocol !== 'https:' && !loopbackHttp)
|
|
73
|
+
throw invalidArgument('PIN/TAN requires an https URL', 'url');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
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.
|
|
78
|
+
*
|
|
79
|
+
* The message leaves out the value.
|
|
80
|
+
*/
|
|
81
|
+
export function requirePin(pin) {
|
|
82
|
+
if (pin.trim() === '')
|
|
83
|
+
throw invalidArgument('The PIN is empty', 'pin');
|
|
84
|
+
if (pin.trim() !== pin)
|
|
85
|
+
throw invalidArgument('The PIN begins or ends with a blank', 'pin');
|
|
86
|
+
return pin;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Throws `TypeError` if `pin` is shorter than `min` or longer than `max` characters, the bank's limits: the bank would
|
|
90
|
+
* count such a PIN as a failed attempt. A limit that is `undefined` or below 1 does not apply.
|
|
91
|
+
*
|
|
92
|
+
* The message leaves out the PIN and its length.
|
|
93
|
+
*/
|
|
94
|
+
export function requirePinLength(pin, min, max) {
|
|
95
|
+
const tooShort = min !== undefined && min > 0 && pin.length < min;
|
|
96
|
+
const tooLong = max !== undefined && max > 0 && pin.length > max;
|
|
97
|
+
if (tooShort || tooLong) {
|
|
98
|
+
const range = [
|
|
99
|
+
...(min !== undefined && min > 0 ? [`at least ${min}`] : []),
|
|
100
|
+
...(max !== undefined && max > 0 ? [`at most ${max}`] : []),
|
|
101
|
+
].join(' and ');
|
|
102
|
+
throw invalidArgument(`The bank takes PINs of ${range} characters`, 'pin');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const loopbackAddress = /^127(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/;
|
|
106
|
+
/**
|
|
107
|
+
* Only addresses and names that cannot leave the machine: a resolver may send a subdomain such as `bank.localhost`, or
|
|
108
|
+
* a string that is not an address, such as `127.999.1.1`, to DNS.
|
|
109
|
+
*/
|
|
110
|
+
function isLoopback(host) {
|
|
111
|
+
return host === 'localhost' || host === '::1' || loopbackAddress.test(host);
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +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,CAAS;IACpB,gBAAgB,CAAU;IAEnC;;;OAGG;IACH,YAAY,IAAqB;QAC/B,6GAA6G;QAC7G,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACnF,MAAM,eAAe,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,GAAQ,CAAC;QACb,IAAI,CAAC;YACH,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC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AAE,GAAuB,EAAE,GAAuB;IAC5F,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"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type FinTsFeedback } from './feedback.js';
|
|
2
|
+
/** Base class of all errors the client raises about the bank and its data. */
|
|
3
|
+
export declare abstract class FinTsError extends Error {
|
|
4
|
+
protected constructor(name: string, message: string, cause?: unknown);
|
|
5
|
+
}
|
|
6
|
+
/** The connection to the bank failed or returned an HTTP error. */
|
|
7
|
+
export declare class FinTsTransportError extends FinTsError {
|
|
8
|
+
/** The HTTP status code of the response, `undefined` if there was none, for example after a timeout. */
|
|
9
|
+
readonly statusCode: number | undefined;
|
|
10
|
+
constructor(message: string, options?: {
|
|
11
|
+
statusCode?: number;
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** The bank's response could not be understood. */
|
|
16
|
+
export declare class FinTsProtocolError extends FinTsError {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
19
|
+
/** The bank does not offer the requested business transaction. */
|
|
20
|
+
export declare class FinTsUnsupportedError extends FinTsError {
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The bank rejected the request; `feedback` holds all return codes.
|
|
25
|
+
*
|
|
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.
|
|
28
|
+
*/
|
|
29
|
+
export declare class FinTsBankError extends FinTsError {
|
|
30
|
+
/** 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);
|
|
34
|
+
/** The return codes of `feedback`. */
|
|
35
|
+
get codes(): string[];
|
|
36
|
+
}
|
|
37
|
+
/** Wrong or blocked PIN, a refused login as `FinTsBankError` describes it. */
|
|
38
|
+
export declare class FinTsPinError extends FinTsBankError {
|
|
39
|
+
constructor(feedback: readonly FinTsFeedback[]);
|
|
40
|
+
}
|
|
41
|
+
/** Invalid, expired or rejected TAN, as the bank reports it in answer to a TAN or to an approval status request. */
|
|
42
|
+
export declare class FinTsTanError extends FinTsBankError {
|
|
43
|
+
constructor(feedback: readonly FinTsFeedback[]);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The bank has changed the user's login data and expects the new ones from now on (return code 3072).
|
|
47
|
+
*
|
|
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.
|
|
50
|
+
*/
|
|
51
|
+
export declare class FinTsLoginDataChangedError extends FinTsBankError {
|
|
52
|
+
constructor(feedback: readonly FinTsFeedback[]);
|
|
53
|
+
/** The new user ID (Benutzerkennung); `undefined` where the bank names none. */
|
|
54
|
+
get userId(): string | undefined;
|
|
55
|
+
/** The new customer ID (Kunden-ID); `undefined` where the bank names none. */
|
|
56
|
+
get customerId(): string | undefined;
|
|
57
|
+
/** The new login name (Anmeldename); `undefined` where the bank names none. */
|
|
58
|
+
get loginName(): string | undefined;
|
|
59
|
+
private parameter;
|
|
60
|
+
}
|
|
61
|
+
/** The bank ended the dialog, for example after a timeout. */
|
|
62
|
+
export declare class FinTsDialogAbortedError extends FinTsBankError {
|
|
63
|
+
constructor(feedback: readonly FinTsFeedback[]);
|
|
64
|
+
}
|
|
65
|
+
/** The user cancelled the TAN entry or the approval in the banking app. */
|
|
66
|
+
export declare class FinTsTanCancelledError extends FinTsError {
|
|
67
|
+
constructor();
|
|
68
|
+
}
|
|
69
|
+
/** The user did not approve in the banking app within the bank's polling limit. */
|
|
70
|
+
export declare class FinTsDecoupledTimeoutError extends FinTsError {
|
|
71
|
+
constructor();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The client was closed, or called from inside one of its own callbacks, which would wait for itself.
|
|
75
|
+
*
|
|
76
|
+
* It does not extend `FinTsError`: it tells about the app's use of the client, not about the bank.
|
|
77
|
+
*/
|
|
78
|
+
export declare class FinTsStateError extends Error {
|
|
79
|
+
constructor(message: string);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The most specific error for the errors in `feedback`, the answer to a message that `completesApproval` or not.
|
|
83
|
+
*
|
|
84
|
+
* Only the answer to a TAN or an approval status request can reject a TAN; anywhere else a TAN return code is a plain
|
|
85
|
+
* `FinTsBankError`. In answer to a login, 9941 or 9951 may reject the PIN, and the client must not take a refused login
|
|
86
|
+
* for a wrong TAN, after which it would send the PIN again.
|
|
87
|
+
*/
|
|
88
|
+
export declare function bankErrorFor(feedback: readonly FinTsFeedback[], completesApproval?: boolean): FinTsBankError;
|
|
89
|
+
/** Runs `parse` on data from the bank and reports malformed data as `FinTsProtocolError`. */
|
|
90
|
+
export declare function parseBankData<T>(parse: () => T): T;
|
|
91
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9E,8EAA8E;AAC9E,8BAAsB,UAAW,SAAQ,KAAK;IAC5C,SAAS,aAAa,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAKrE;AAED,mEAAmE;AACnE,qBAAa,mBAAoB,SAAQ,UAAU;IACjD,wGAAwG;IACxG,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE5B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAIhF;AAED,mDAAmD;AACnD,qBAAa,kBAAmB,SAAQ,UAAU;gBACpC,OAAO,EAAE,MAAM;CAG5B;AAED,kEAAkE;AAClE,qBAAa,qBAAsB,SAAQ,UAAU;gBACvC,OAAO,EAAE,MAAM;CAG5B;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAE5C,oGAAoG;gBACxF,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,SAAmB;IAYzF,sCAAsC;IACtC,IAAI,KAAK,IAAI,MAAM,EAAE,CAEpB;CACF;AAED,8EAA8E;AAC9E,qBAAa,aAAc,SAAQ,cAAc;gBACnC,QAAQ,EAAE,SAAS,aAAa,EAAE;CAG/C;AAED,oHAAoH;AACpH,qBAAa,aAAc,SAAQ,cAAc;gBACnC,QAAQ,EAAE,SAAS,aAAa,EAAE;CAG/C;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,cAAc;gBAChD,QAAQ,EAAE,SAAS,aAAa,EAAE;IAI9C,gFAAgF;IAChF,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,8EAA8E;IAC9E,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAEnC;IAED,+EAA+E;IAC/E,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,OAAO,CAAC,SAAS;CAKlB;AAED,8DAA8D;AAC9D,qBAAa,uBAAwB,SAAQ,cAAc;gBAC7C,QAAQ,EAAE,SAAS,aAAa,EAAE;CAG/C;AAED,2EAA2E;AAC3E,qBAAa,sBAAuB,SAAQ,UAAU;;CAIrD;AAED,mFAAmF;AACnF,qBAAa,0BAA2B,SAAQ,UAAU;;CAIzD;AAED;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAkCD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,iBAAiB,UAAQ,GAAG,cAAc,CAO1G;AAED,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAOlD"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { FormatError } from '../util/errors.js';
|
|
2
|
+
import { endsDialog, FeedbackCodes } from './feedback.js';
|
|
3
|
+
/** Base class of all errors the client raises about the bank and its data. */
|
|
4
|
+
export class FinTsError extends Error {
|
|
5
|
+
constructor(name, message, cause) {
|
|
6
|
+
super(message, cause === undefined ? undefined : { cause });
|
|
7
|
+
// Set explicitly: a minifier renames classes, and `constructor.name` would show a meaningless name.
|
|
8
|
+
this.name = name;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** The connection to the bank failed or returned an HTTP error. */
|
|
12
|
+
export class FinTsTransportError extends FinTsError {
|
|
13
|
+
/** The HTTP status code of the response, `undefined` if there was none, for example after a timeout. */
|
|
14
|
+
statusCode;
|
|
15
|
+
constructor(message, options) {
|
|
16
|
+
super('FinTsTransportError', message, options?.cause);
|
|
17
|
+
this.statusCode = options?.statusCode;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** The bank's response could not be understood. */
|
|
21
|
+
export class FinTsProtocolError extends FinTsError {
|
|
22
|
+
constructor(message) {
|
|
23
|
+
super('FinTsProtocolError', message);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** The bank does not offer the requested business transaction. */
|
|
27
|
+
export class FinTsUnsupportedError extends FinTsError {
|
|
28
|
+
constructor(message) {
|
|
29
|
+
super('FinTsUnsupportedError', message);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The bank rejected the request; `feedback` holds all return codes.
|
|
34
|
+
*
|
|
35
|
+
* After a refused login every later call that would send the PIN fails with the same error, without contacting the
|
|
36
|
+
* bank; create a new client to try again. The README tells which errors refuse a login.
|
|
37
|
+
*/
|
|
38
|
+
export class FinTsBankError extends FinTsError {
|
|
39
|
+
/** All return codes of the response, warnings and successes included. */
|
|
40
|
+
feedback;
|
|
41
|
+
/** A rejection with the return codes in `feedback`; `message` defaults to the errors among them. */
|
|
42
|
+
constructor(feedback, message, name = 'FinTsBankError') {
|
|
43
|
+
super(name, message ??
|
|
44
|
+
feedback
|
|
45
|
+
.filter((f) => f.isError)
|
|
46
|
+
.map((f) => f.toString())
|
|
47
|
+
.join('; '));
|
|
48
|
+
this.feedback = Object.freeze([...feedback]);
|
|
49
|
+
}
|
|
50
|
+
/** The return codes of `feedback`. */
|
|
51
|
+
get codes() {
|
|
52
|
+
return this.feedback.map((f) => f.code);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Wrong or blocked PIN, a refused login as `FinTsBankError` describes it. */
|
|
56
|
+
export class FinTsPinError extends FinTsBankError {
|
|
57
|
+
constructor(feedback) {
|
|
58
|
+
super(feedback, undefined, 'FinTsPinError');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Invalid, expired or rejected TAN, as the bank reports it in answer to a TAN or to an approval status request. */
|
|
62
|
+
export class FinTsTanError extends FinTsBankError {
|
|
63
|
+
constructor(feedback) {
|
|
64
|
+
super(feedback, undefined, 'FinTsTanError');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The bank has changed the user's login data and expects the new ones from now on (return code 3072).
|
|
69
|
+
*
|
|
70
|
+
* The client has ended the dialog, and every later call fails with this error. Create a new client with the new data; a
|
|
71
|
+
* `loginName` replaces user ID and customer ID: pass it as `userId`, without a customer ID.
|
|
72
|
+
*/
|
|
73
|
+
export class FinTsLoginDataChangedError extends FinTsBankError {
|
|
74
|
+
constructor(feedback) {
|
|
75
|
+
super(feedback, 'The bank has changed the login data', 'FinTsLoginDataChangedError');
|
|
76
|
+
}
|
|
77
|
+
/** The new user ID (Benutzerkennung); `undefined` where the bank names none. */
|
|
78
|
+
get userId() {
|
|
79
|
+
return this.parameter(0);
|
|
80
|
+
}
|
|
81
|
+
/** The new customer ID (Kunden-ID); `undefined` where the bank names none. */
|
|
82
|
+
get customerId() {
|
|
83
|
+
return this.parameter(1);
|
|
84
|
+
}
|
|
85
|
+
/** The new login name (Anmeldename); `undefined` where the bank names none. */
|
|
86
|
+
get loginName() {
|
|
87
|
+
return this.parameter(2);
|
|
88
|
+
}
|
|
89
|
+
parameter(index) {
|
|
90
|
+
const change = this.feedback.find((f) => f.code === FeedbackCodes.newLoginData);
|
|
91
|
+
const value = change?.parameters[index]?.trim();
|
|
92
|
+
return value === undefined || value === '' ? undefined : value;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** The bank ended the dialog, for example after a timeout. */
|
|
96
|
+
export class FinTsDialogAbortedError extends FinTsBankError {
|
|
97
|
+
constructor(feedback) {
|
|
98
|
+
super(feedback, undefined, 'FinTsDialogAbortedError');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** The user cancelled the TAN entry or the approval in the banking app. */
|
|
102
|
+
export class FinTsTanCancelledError extends FinTsError {
|
|
103
|
+
constructor() {
|
|
104
|
+
super('FinTsTanCancelledError', 'TAN entry cancelled');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** The user did not approve in the banking app within the bank's polling limit. */
|
|
108
|
+
export class FinTsDecoupledTimeoutError extends FinTsError {
|
|
109
|
+
constructor() {
|
|
110
|
+
super('FinTsDecoupledTimeoutError', 'Approval on the separate device was not completed in time');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The client was closed, or called from inside one of its own callbacks, which would wait for itself.
|
|
115
|
+
*
|
|
116
|
+
* It does not extend `FinTsError`: it tells about the app's use of the client, not about the bank.
|
|
117
|
+
*/
|
|
118
|
+
export class FinTsStateError extends Error {
|
|
119
|
+
constructor(message) {
|
|
120
|
+
super(message);
|
|
121
|
+
this.name = 'FinTsStateError';
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Return codes for a wrong or blocked PIN, from the FinTS return code list (Rückmeldungscodes): 9340 signature (PIN)
|
|
126
|
+
* wrong, 9910 PIN invalid or blocked, 9930 PIN blocked, 9931 blocked after failed attempts, 9942 PIN invalid.
|
|
127
|
+
*/
|
|
128
|
+
const pinErrors = new Set(['9340', '9910', '9930', '9931', '9942']);
|
|
129
|
+
/**
|
|
130
|
+
* Return codes for a rejected TAN: 9941 TAN invalid, 9943 and 9991 TAN already used (the return code list and the
|
|
131
|
+
* PIN/TAN specification give different numbers), 9951 two-step timeout.
|
|
132
|
+
*
|
|
133
|
+
* The return code list gives 9941 and 9951 a second meaning, "Signatur ungültig" (invalid signature), which in PIN/TAN
|
|
134
|
+
* is the PIN; see `bankErrorFor`.
|
|
135
|
+
*/
|
|
136
|
+
const tanErrors = new Set(['9941', '9943', '9951', '9991']);
|
|
137
|
+
/**
|
|
138
|
+
* Whether `f` reports a wrong or blocked PIN. Two of the codes stand for other faults as well, which the text tells:
|
|
139
|
+
* 9340 "Sicherheitsprofil unbekannt", 9910 "TAN-Reihe gesperrt" and "Chipkarte gesperrt".
|
|
140
|
+
*/
|
|
141
|
+
function isPinError(f) {
|
|
142
|
+
if (!f.isError || !pinErrors.has(f.code))
|
|
143
|
+
return false;
|
|
144
|
+
const text = f.text.toLowerCase();
|
|
145
|
+
switch (f.code) {
|
|
146
|
+
case '9340':
|
|
147
|
+
return !text.includes('profil');
|
|
148
|
+
case '9910':
|
|
149
|
+
return !text.includes('tan-reihe') && !text.includes('chipkarte');
|
|
150
|
+
default:
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The most specific error for the errors in `feedback`, the answer to a message that `completesApproval` or not.
|
|
156
|
+
*
|
|
157
|
+
* Only the answer to a TAN or an approval status request can reject a TAN; anywhere else a TAN return code is a plain
|
|
158
|
+
* `FinTsBankError`. In answer to a login, 9941 or 9951 may reject the PIN, and the client must not take a refused login
|
|
159
|
+
* for a wrong TAN, after which it would send the PIN again.
|
|
160
|
+
*/
|
|
161
|
+
export function bankErrorFor(feedback, completesApproval = false) {
|
|
162
|
+
if (feedback.some(isPinError))
|
|
163
|
+
return new FinTsPinError(feedback);
|
|
164
|
+
if (completesApproval && feedback.some((f) => f.isError && tanErrors.has(f.code))) {
|
|
165
|
+
return new FinTsTanError(feedback);
|
|
166
|
+
}
|
|
167
|
+
if (endsDialog(feedback))
|
|
168
|
+
return new FinTsDialogAbortedError(feedback);
|
|
169
|
+
return new FinTsBankError(feedback);
|
|
170
|
+
}
|
|
171
|
+
/** Runs `parse` on data from the bank and reports malformed data as `FinTsProtocolError`. */
|
|
172
|
+
export function parseBankData(parse) {
|
|
173
|
+
try {
|
|
174
|
+
return parse();
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
if (error instanceof FormatError)
|
|
178
|
+
throw new FinTsProtocolError(`Malformed bank data: ${error.message}`);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAsB,MAAM,eAAe,CAAC;AAE9E,8EAA8E;AAC9E,MAAM,OAAgB,UAAW,SAAQ,KAAK;IAC5C,YAAsB,IAAY,EAAE,OAAe,EAAE,KAAe;QAClE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,oGAAoG;QACpG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,mEAAmE;AACnE,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IACjD,wGAAwG;IAC/F,UAAU,CAAqB;IAExC,YAAY,OAAe,EAAE,OAAkD;QAC7E,KAAK,CAAC,qBAAqB,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACtD,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;IACxC,CAAC;CACF;AAED,mDAAmD;AACnD,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAA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I,aAAa,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IACvE,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,aAAa,CAAI,KAAc;IAC7C,IAAI,CAAC;QACH,OAAO,KAAK,EAAE,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW;YAAE,MAAM,IAAI,kBAAkB,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACxG,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** A return code with text from the bank, for example `0020: Auftrag ausgeführt`. */
|
|
2
|
+
export declare class FinTsFeedback {
|
|
3
|
+
/** The four-digit return code; `0…` reports success, `3…` a warning and `9…` an error. */
|
|
4
|
+
readonly code: string;
|
|
5
|
+
/** The element of the request the code refers to, if the bank names one. */
|
|
6
|
+
readonly reference: string | undefined;
|
|
7
|
+
/** The bank's explanation of the code. */
|
|
8
|
+
readonly text: string;
|
|
9
|
+
/** Values the bank adds to the code, such as the position to continue at. */
|
|
10
|
+
readonly parameters: readonly string[];
|
|
11
|
+
constructor(init: {
|
|
12
|
+
code: string;
|
|
13
|
+
reference?: string | undefined;
|
|
14
|
+
text: string;
|
|
15
|
+
parameters?: readonly string[];
|
|
16
|
+
});
|
|
17
|
+
/** Whether the code reports success. */
|
|
18
|
+
get isSuccess(): boolean;
|
|
19
|
+
/** Whether the code is a warning. */
|
|
20
|
+
get isWarning(): boolean;
|
|
21
|
+
/** Whether the code is an error. */
|
|
22
|
+
get isError(): boolean;
|
|
23
|
+
toString(): string;
|
|
24
|
+
}
|
|
25
|
+
/** Return codes the client reacts to, as named in the FinTS return code list (Rückmeldungscodes). */
|
|
26
|
+
export declare const FeedbackCodes: Readonly<{
|
|
27
|
+
/** Order received, strong authentication required (Auftrag empfangen – Sicherheitsfreigabe erforderlich). */
|
|
28
|
+
tanRequired: "0030";
|
|
29
|
+
/** More information available; the first parameter is where to continue (Es liegen weitere Informationen vor). */
|
|
30
|
+
moreData: "3040";
|
|
31
|
+
/**
|
|
32
|
+
* The bank has new login data for the user; the parameters are the user ID, the customer ID and the login name
|
|
33
|
+
* (Neue Anmeldedaten).
|
|
34
|
+
*/
|
|
35
|
+
newLoginData: "3072";
|
|
36
|
+
/** The one- and two-step methods the user may use, as parameters. */
|
|
37
|
+
allowedTanMethods: "3920";
|
|
38
|
+
/** Approval happens on another channel, such as a banking app (Sicherheitsfreigabe erfolgt über anderen Kanal). */
|
|
39
|
+
decoupledPending: "3955";
|
|
40
|
+
/** Strong authentication still pending (Starke Kundenauthentifizierung noch ausstehend). */
|
|
41
|
+
decoupledStillPending: "3956";
|
|
42
|
+
/** Wait for the push message (Auf Push-Nachricht warten). */
|
|
43
|
+
decoupledWaitForPush: "3957";
|
|
44
|
+
/** The bank ended the dialog (Dialog abgebrochen). */
|
|
45
|
+
dialogAborted: "9800";
|
|
46
|
+
/**
|
|
47
|
+
* The bank ended the dialog because it requires strong authentication (Dialog abgebrochen – starke Authentifizierung
|
|
48
|
+
* erforderlich).
|
|
49
|
+
*/
|
|
50
|
+
scaRequired: "9075";
|
|
51
|
+
/** The customer system ID is not accepted any more; a synchronization delivers a new one (Neue Kundensystem-ID holen). */
|
|
52
|
+
newSystemIdRequired: "9391";
|
|
53
|
+
}>;
|
|
54
|
+
/** Whether a return code `code` is among the `feedback`. */
|
|
55
|
+
export declare function hasCode(feedback: readonly FinTsFeedback[], code: string): boolean;
|
|
56
|
+
/** Whether any return code is an error. */
|
|
57
|
+
export declare function hasErrors(feedback: readonly FinTsFeedback[]): boolean;
|
|
58
|
+
/** The positions to continue at that the bank names with return code 3040; empty on the last page. */
|
|
59
|
+
export declare function continuations(feedback: readonly FinTsFeedback[]): Set<string>;
|
|
60
|
+
/**
|
|
61
|
+
* The security functions of the TAN methods the user may use, as the bank lists them with return code 3920, in all such
|
|
62
|
+
* return codes; empty if it lists none.
|
|
63
|
+
*/
|
|
64
|
+
export declare function allowedTanMethodsIn(feedback: readonly FinTsFeedback[]): string[];
|
|
65
|
+
/** Whether the bank ended the dialog with one of its return codes for that. */
|
|
66
|
+
export declare function endsDialog(feedback: readonly FinTsFeedback[]): boolean;
|
|
67
|
+
/** The warnings for the user: all but those about the protocol. */
|
|
68
|
+
export declare function userWarnings(feedback: readonly FinTsFeedback[]): FinTsFeedback[];
|
|
69
|
+
//# sourceMappingURL=feedback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../../src/core/feedback.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,qBAAa,aAAa;IACxB,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;gBAE3B,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE;IAOhH,wCAAwC;IACxC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,qCAAqC;IACrC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,oCAAoC;IACpC,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,QAAQ,IAAI,MAAM;CAGnB;AAED,qGAAqG;AACrG,eAAO,MAAM,aAAa;IACxB,6GAA6G;;IAE7G,kHAAkH;;IAElH;;;OAGG;;IAEH,qEAAqE;;IAErE,mHAAmH;;IAEnH,4FAA4F;;IAE5F,6DAA6D;;IAE7D,sDAAsD;;IAEtD;;;OAGG;;IAEH,0HAA0H;;EAE1H,CAAC;AA0BH,4DAA4D;AAC5D,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjF;AAED,2CAA2C;AAC3C,wBAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAErE;AAED,sGAAsG;AACtG,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAO7E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,EAAE,CAOhF;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAEtE;AAED,mEAAmE;AACnE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,EAAE,CAEhF"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/** A return code with text from the bank, for example `0020: Auftrag ausgeführt`. */
|
|
2
|
+
export class FinTsFeedback {
|
|
3
|
+
/** The four-digit return code; `0…` reports success, `3…` a warning and `9…` an error. */
|
|
4
|
+
code;
|
|
5
|
+
/** The element of the request the code refers to, if the bank names one. */
|
|
6
|
+
reference;
|
|
7
|
+
/** The bank's explanation of the code. */
|
|
8
|
+
text;
|
|
9
|
+
/** Values the bank adds to the code, such as the position to continue at. */
|
|
10
|
+
parameters;
|
|
11
|
+
constructor(init) {
|
|
12
|
+
this.code = init.code;
|
|
13
|
+
this.reference = init.reference;
|
|
14
|
+
this.text = init.text;
|
|
15
|
+
this.parameters = Object.freeze([...(init.parameters ?? [])]);
|
|
16
|
+
}
|
|
17
|
+
/** Whether the code reports success. */
|
|
18
|
+
get isSuccess() {
|
|
19
|
+
return this.code.startsWith('0');
|
|
20
|
+
}
|
|
21
|
+
/** Whether the code is a warning. */
|
|
22
|
+
get isWarning() {
|
|
23
|
+
return this.code.startsWith('3');
|
|
24
|
+
}
|
|
25
|
+
/** Whether the code is an error. */
|
|
26
|
+
get isError() {
|
|
27
|
+
return this.code.startsWith('9');
|
|
28
|
+
}
|
|
29
|
+
toString() {
|
|
30
|
+
return `${this.code}: ${this.text}${this.parameters.length === 0 ? '' : ` [${this.parameters.join(', ')}]`}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Return codes the client reacts to, as named in the FinTS return code list (Rückmeldungscodes). */
|
|
34
|
+
export const FeedbackCodes = Object.freeze({
|
|
35
|
+
/** Order received, strong authentication required (Auftrag empfangen – Sicherheitsfreigabe erforderlich). */
|
|
36
|
+
tanRequired: '0030',
|
|
37
|
+
/** More information available; the first parameter is where to continue (Es liegen weitere Informationen vor). */
|
|
38
|
+
moreData: '3040',
|
|
39
|
+
/**
|
|
40
|
+
* The bank has new login data for the user; the parameters are the user ID, the customer ID and the login name
|
|
41
|
+
* (Neue Anmeldedaten).
|
|
42
|
+
*/
|
|
43
|
+
newLoginData: '3072',
|
|
44
|
+
/** The one- and two-step methods the user may use, as parameters. */
|
|
45
|
+
allowedTanMethods: '3920',
|
|
46
|
+
/** Approval happens on another channel, such as a banking app (Sicherheitsfreigabe erfolgt über anderen Kanal). */
|
|
47
|
+
decoupledPending: '3955',
|
|
48
|
+
/** Strong authentication still pending (Starke Kundenauthentifizierung noch ausstehend). */
|
|
49
|
+
decoupledStillPending: '3956',
|
|
50
|
+
/** Wait for the push message (Auf Push-Nachricht warten). */
|
|
51
|
+
decoupledWaitForPush: '3957',
|
|
52
|
+
/** The bank ended the dialog (Dialog abgebrochen). */
|
|
53
|
+
dialogAborted: '9800',
|
|
54
|
+
/**
|
|
55
|
+
* The bank ended the dialog because it requires strong authentication (Dialog abgebrochen – starke Authentifizierung
|
|
56
|
+
* erforderlich).
|
|
57
|
+
*/
|
|
58
|
+
scaRequired: '9075',
|
|
59
|
+
/** The customer system ID is not accepted any more; a synchronization delivers a new one (Neue Kundensystem-ID holen). */
|
|
60
|
+
newSystemIdRequired: '9391',
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* The return codes with which the bank ends the dialog ("Dialog abgebrochen" in the return code list): 9800 and 9075,
|
|
64
|
+
* and 9077 (hardened browser required), 9078 (product not registered) and 9361 (security procedure no longer allowed).
|
|
65
|
+
*/
|
|
66
|
+
const dialogEnding = new Set([FeedbackCodes.dialogAborted, FeedbackCodes.scaRequired, '9077', '9078', '9361']);
|
|
67
|
+
/**
|
|
68
|
+
* The warnings about the protocol, which the client acts on itself and the user has no use for: paging, the allowed TAN
|
|
69
|
+
* methods, the steps of an approval and 3076 (no strong authentication needed), new login data, which fail the call,
|
|
70
|
+
* and 3060 (some warnings), which only announces the others.
|
|
71
|
+
*/
|
|
72
|
+
const protocolWarnings = new Set([
|
|
73
|
+
FeedbackCodes.moreData,
|
|
74
|
+
'3060',
|
|
75
|
+
FeedbackCodes.newLoginData,
|
|
76
|
+
'3076',
|
|
77
|
+
FeedbackCodes.allowedTanMethods,
|
|
78
|
+
FeedbackCodes.decoupledPending,
|
|
79
|
+
FeedbackCodes.decoupledStillPending,
|
|
80
|
+
FeedbackCodes.decoupledWaitForPush,
|
|
81
|
+
]);
|
|
82
|
+
// Reading return codes the way the session logic needs; not part of the public API.
|
|
83
|
+
/** Whether a return code `code` is among the `feedback`. */
|
|
84
|
+
export function hasCode(feedback, code) {
|
|
85
|
+
return feedback.some((f) => f.code === code);
|
|
86
|
+
}
|
|
87
|
+
/** Whether any return code is an error. */
|
|
88
|
+
export function hasErrors(feedback) {
|
|
89
|
+
return feedback.some((f) => f.isError);
|
|
90
|
+
}
|
|
91
|
+
/** The positions to continue at that the bank names with return code 3040; empty on the last page. */
|
|
92
|
+
export function continuations(feedback) {
|
|
93
|
+
const positions = new Set();
|
|
94
|
+
for (const f of feedback) {
|
|
95
|
+
const position = f.parameters[0];
|
|
96
|
+
if (f.code === FeedbackCodes.moreData && position !== undefined && position !== '')
|
|
97
|
+
positions.add(position);
|
|
98
|
+
}
|
|
99
|
+
return positions;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The security functions of the TAN methods the user may use, as the bank lists them with return code 3920, in all such
|
|
103
|
+
* return codes; empty if it lists none.
|
|
104
|
+
*/
|
|
105
|
+
export function allowedTanMethodsIn(feedback) {
|
|
106
|
+
const codes = new Set();
|
|
107
|
+
for (const f of feedback) {
|
|
108
|
+
if (f.code !== FeedbackCodes.allowedTanMethods)
|
|
109
|
+
continue;
|
|
110
|
+
for (const code of f.parameters)
|
|
111
|
+
if (code !== '')
|
|
112
|
+
codes.add(code);
|
|
113
|
+
}
|
|
114
|
+
return [...codes];
|
|
115
|
+
}
|
|
116
|
+
/** Whether the bank ended the dialog with one of its return codes for that. */
|
|
117
|
+
export function endsDialog(feedback) {
|
|
118
|
+
return feedback.some((f) => dialogEnding.has(f.code));
|
|
119
|
+
}
|
|
120
|
+
/** The warnings for the user: all but those about the protocol. */
|
|
121
|
+
export function userWarnings(feedback) {
|
|
122
|
+
return feedback.filter((f) => f.isWarning && !protocolWarnings.has(f.code));
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.js","sourceRoot":"","sources":["../../src/core/feedback.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,MAAM,OAAO,aAAa;IACxB,0FAA0F;IACjF,IAAI,CAAS;IAEtB,4EAA4E;IACnE,SAAS,CAAqB;IAEvC,0CAA0C;IACjC,IAAI,CAAS;IAEtB,6EAA6E;IACpE,UAAU,CAAoB;IAEvC,YAAY,IAAoG;QAC9G,IAAI,CAAC,IA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