@coderoftime/fints 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +519 -1
- package/README.md +138 -40
- package/dist/client.d.ts +49 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +242 -0
- package/dist/client.js.map +1 -0
- package/dist/core/account.d.ts +46 -7
- package/dist/core/account.d.ts.map +1 -1
- package/dist/core/account.js +143 -24
- package/dist/core/account.js.map +1 -1
- package/dist/core/amount.d.ts +15 -4
- package/dist/core/amount.d.ts.map +1 -1
- package/dist/core/amount.js +46 -9
- package/dist/core/amount.js.map +1 -1
- package/dist/core/balance.d.ts +4 -0
- package/dist/core/balance.d.ts.map +1 -1
- package/dist/core/balance.js +11 -5
- package/dist/core/balance.js.map +1 -1
- package/dist/core/bank-info.d.ts +21 -4
- package/dist/core/bank-info.d.ts.map +1 -1
- package/dist/core/bank-info.js +26 -5
- package/dist/core/bank-info.js.map +1 -1
- package/dist/core/client.d.ts +81 -19
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/config.d.ts +40 -20
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +85 -30
- package/dist/core/config.js.map +1 -1
- package/dist/core/errors.d.ts +100 -26
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +136 -53
- package/dist/core/errors.js.map +1 -1
- package/dist/core/feedback.d.ts +11 -1
- package/dist/core/feedback.d.ts.map +1 -1
- package/dist/core/feedback.js +14 -2
- package/dist/core/feedback.js.map +1 -1
- package/dist/core/transaction.d.ts +11 -1
- package/dist/core/transaction.d.ts.map +1 -1
- package/dist/core/transaction.js +21 -4
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/transport.d.ts +48 -6
- package/dist/core/transport.d.ts.map +1 -1
- package/dist/core/transport.js +126 -29
- package/dist/core/transport.js.map +1 -1
- package/dist/formats/camt.d.ts +28 -5
- package/dist/formats/camt.d.ts.map +1 -1
- package/dist/formats/camt.js +132 -50
- package/dist/formats/camt.js.map +1 -1
- package/dist/formats/mt940.d.ts +29 -5
- package/dist/formats/mt940.d.ts.map +1 -1
- package/dist/formats/mt940.js +209 -113
- package/dist/formats/mt940.js.map +1 -1
- package/dist/formats/readers.d.ts +6 -2
- package/dist/formats/readers.d.ts.map +1 -1
- package/dist/formats/readers.js +28 -29
- package/dist/formats/readers.js.map +1 -1
- package/dist/formats/record-budget.d.ts +7 -0
- package/dist/formats/record-budget.d.ts.map +1 -0
- package/dist/formats/record-budget.js +17 -0
- package/dist/formats/record-budget.js.map +1 -0
- package/dist/formats/sepa-purpose.d.ts +9 -0
- package/dist/formats/sepa-purpose.d.ts.map +1 -1
- package/dist/formats/sepa-purpose.js +32 -2
- package/dist/formats/sepa-purpose.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/session/app-approval.d.ts +11 -5
- package/dist/session/app-approval.d.ts.map +1 -1
- package/dist/session/app-approval.js +23 -12
- package/dist/session/app-approval.js.map +1 -1
- package/dist/session/dialog-runner.d.ts +11 -11
- package/dist/session/dialog-runner.d.ts.map +1 -1
- package/dist/session/dialog-runner.js +34 -19
- package/dist/session/dialog-runner.js.map +1 -1
- package/dist/session/login-guard.d.ts +54 -49
- package/dist/session/login-guard.d.ts.map +1 -1
- package/dist/session/login-guard.js +170 -83
- package/dist/session/login-guard.js.map +1 -1
- package/dist/session/sepa-accounts.d.ts +20 -14
- package/dist/session/sepa-accounts.d.ts.map +1 -1
- package/dist/session/sepa-accounts.js +62 -46
- package/dist/session/sepa-accounts.js.map +1 -1
- package/dist/session/session-setup.d.ts +41 -24
- package/dist/session/session-setup.d.ts.map +1 -1
- package/dist/session/session-setup.js +106 -63
- package/dist/session/session-setup.js.map +1 -1
- package/dist/session/session-state.d.ts +10 -6
- package/dist/session/session-state.d.ts.map +1 -1
- package/dist/session/session-state.js +72 -18
- package/dist/session/session-state.js.map +1 -1
- package/dist/session/signed-dialog.d.ts +83 -0
- package/dist/session/signed-dialog.d.ts.map +1 -0
- package/dist/session/signed-dialog.js +185 -0
- package/dist/session/signed-dialog.js.map +1 -0
- package/dist/session/tan-selection.d.ts +26 -18
- package/dist/session/tan-selection.d.ts.map +1 -1
- package/dist/session/tan-selection.js +44 -33
- package/dist/session/tan-selection.js.map +1 -1
- package/dist/session/user-prompts.d.ts +14 -5
- package/dist/session/user-prompts.d.ts.map +1 -1
- package/dist/session/user-prompts.js +53 -18
- package/dist/session/user-prompts.js.map +1 -1
- package/dist/tan/challenge.d.ts +47 -24
- package/dist/tan/challenge.d.ts.map +1 -1
- package/dist/tan/challenge.js +56 -51
- package/dist/tan/challenge.js.map +1 -1
- package/dist/tan/flicker.d.ts +11 -1
- package/dist/tan/flicker.d.ts.map +1 -1
- package/dist/tan/flicker.js +70 -24
- package/dist/tan/flicker.js.map +1 -1
- package/dist/tan/tan-image.d.ts +6 -2
- package/dist/tan/tan-image.d.ts.map +1 -1
- package/dist/tan/tan-image.js +14 -6
- package/dist/tan/tan-image.js.map +1 -1
- package/dist/tan/tan-models.d.ts +14 -2
- package/dist/tan/tan-models.d.ts.map +1 -1
- package/dist/tan/tan-models.js +24 -7
- package/dist/tan/tan-models.js.map +1 -1
- package/dist/util/arguments.d.ts +13 -0
- package/dist/util/arguments.d.ts.map +1 -0
- package/dist/util/arguments.js +40 -0
- package/dist/util/arguments.js.map +1 -0
- package/dist/util/async.d.ts +4 -3
- package/dist/util/async.d.ts.map +1 -1
- package/dist/util/async.js +6 -7
- package/dist/util/async.js.map +1 -1
- package/dist/util/bytes.d.ts +3 -4
- package/dist/util/bytes.d.ts.map +1 -1
- package/dist/util/bytes.js +13 -21
- package/dist/util/bytes.js.map +1 -1
- package/dist/util/call-context.d.ts.map +1 -1
- package/dist/util/call-context.js +3 -2
- package/dist/util/call-context.js.map +1 -1
- package/dist/util/dates.d.ts +6 -20
- package/dist/util/dates.d.ts.map +1 -1
- package/dist/util/dates.js +58 -28
- package/dist/util/dates.js.map +1 -1
- package/dist/util/errors.d.ts +13 -3
- package/dist/util/errors.d.ts.map +1 -1
- package/dist/util/errors.js +19 -6
- package/dist/util/errors.js.map +1 -1
- package/dist/util/immutable-map.d.ts +5 -2
- package/dist/util/immutable-map.d.ts.map +1 -1
- package/dist/util/immutable-map.js +15 -12
- package/dist/util/immutable-map.js.map +1 -1
- package/dist/util/inspect.d.ts +11 -0
- package/dist/util/inspect.d.ts.map +1 -0
- package/dist/util/inspect.js +14 -0
- package/dist/util/inspect.js.map +1 -0
- package/dist/util/json.d.ts +4 -0
- package/dist/util/json.d.ts.map +1 -1
- package/dist/util/json.js +18 -0
- package/dist/util/json.js.map +1 -1
- package/dist/util/text.d.ts +38 -5
- package/dist/util/text.d.ts.map +1 -1
- package/dist/util/text.js +90 -16
- package/dist/util/text.js.map +1 -1
- package/dist/util/xml.d.ts +9 -6
- package/dist/util/xml.d.ts.map +1 -1
- package/dist/util/xml.js +129 -56
- package/dist/util/xml.js.map +1 -1
- package/dist/v3/account-extension.d.ts.map +1 -1
- package/dist/v3/account-extension.js +7 -10
- package/dist/v3/account-extension.js.map +1 -1
- package/dist/v3/bank-connection.d.ts +54 -0
- package/dist/v3/bank-connection.d.ts.map +1 -0
- package/dist/v3/bank-connection.js +118 -0
- package/dist/v3/bank-connection.js.map +1 -0
- package/dist/v3/dialog.d.ts +84 -46
- package/dist/v3/dialog.d.ts.map +1 -1
- package/dist/v3/dialog.js +174 -60
- package/dist/v3/dialog.js.map +1 -1
- package/dist/v3/message.d.ts +32 -11
- package/dist/v3/message.d.ts.map +1 -1
- package/dist/v3/message.js +144 -83
- package/dist/v3/message.js.map +1 -1
- package/dist/v3/parameter-store.d.ts +111 -0
- package/dist/v3/parameter-store.d.ts.map +1 -0
- package/dist/v3/parameter-store.js +197 -0
- package/dist/v3/parameter-store.js.map +1 -0
- package/dist/v3/parameters.d.ts +44 -17
- package/dist/v3/parameters.d.ts.map +1 -1
- package/dist/v3/parameters.js +136 -60
- package/dist/v3/parameters.js.map +1 -1
- package/dist/v3/protocol.d.ts +50 -50
- package/dist/v3/protocol.d.ts.map +1 -1
- package/dist/v3/protocol.js +91 -210
- package/dist/v3/protocol.js.map +1 -1
- package/dist/v3/queries.d.ts +51 -0
- package/dist/v3/queries.d.ts.map +1 -0
- package/dist/v3/queries.js +128 -0
- package/dist/v3/queries.js.map +1 -0
- package/dist/v3/segments.d.ts +43 -19
- package/dist/v3/segments.d.ts.map +1 -1
- package/dist/v3/segments.js +84 -33
- package/dist/v3/segments.js.map +1 -1
- package/dist/v3/syntax.d.ts +68 -13
- package/dist/v3/syntax.d.ts.map +1 -1
- package/dist/v3/syntax.js +183 -102
- package/dist/v3/syntax.js.map +1 -1
- package/package.json +10 -6
- package/src/client.ts +293 -0
- package/src/core/account.ts +153 -24
- package/src/core/amount.ts +45 -10
- package/src/core/balance.ts +12 -5
- package/src/core/bank-info.ts +29 -5
- package/src/core/client.ts +83 -19
- package/src/core/config.ts +95 -35
- package/src/core/errors.ts +148 -54
- package/src/core/feedback.ts +16 -2
- package/src/core/transaction.ts +22 -4
- package/src/core/transport.ts +153 -32
- package/src/formats/camt.ts +153 -45
- package/src/formats/mt940.ts +244 -122
- package/src/formats/readers.ts +28 -31
- package/src/formats/record-budget.ts +18 -0
- package/src/formats/sepa-purpose.ts +29 -2
- package/src/index.ts +4 -2
- package/src/session/app-approval.ts +51 -38
- package/src/session/dialog-runner.ts +61 -31
- package/src/session/login-guard.ts +189 -87
- package/src/session/sepa-accounts.ts +63 -45
- package/src/session/session-setup.ts +105 -68
- package/src/session/session-state.ts +74 -23
- package/src/session/signed-dialog.ts +222 -0
- package/src/session/tan-selection.ts +50 -39
- package/src/session/user-prompts.ts +62 -18
- package/src/tan/challenge.ts +87 -64
- package/src/tan/flicker.ts +72 -23
- package/src/tan/tan-image.ts +15 -6
- package/src/tan/tan-models.ts +26 -7
- package/src/util/arguments.ts +40 -0
- package/src/util/async.ts +10 -9
- package/src/util/bytes.ts +14 -20
- package/src/util/call-context.ts +3 -2
- package/src/util/dates.ts +64 -33
- package/src/util/errors.ts +22 -6
- package/src/util/immutable-map.ts +15 -12
- package/src/util/inspect.ts +14 -0
- package/src/util/json.ts +16 -0
- package/src/util/text.ts +87 -15
- package/src/util/xml.ts +130 -52
- package/src/v3/account-extension.ts +7 -12
- package/src/v3/bank-connection.ts +126 -0
- package/src/v3/dialog.ts +186 -92
- package/src/v3/message.ts +140 -79
- package/src/v3/parameter-store.ts +226 -0
- package/src/v3/parameters.ts +166 -66
- package/src/v3/protocol.ts +103 -253
- package/src/v3/queries.ts +198 -0
- package/src/v3/segments.ts +86 -31
- package/src/v3/syntax.ts +172 -93
- package/dist/session/bank-connection.d.ts +0 -28
- package/dist/session/bank-connection.d.ts.map +0 -1
- package/dist/session/bank-connection.js +0 -48
- package/dist/session/bank-connection.js.map +0 -1
- package/dist/session/parameter-data.d.ts +0 -83
- package/dist/session/parameter-data.d.ts.map +0 -1
- package/dist/session/parameter-data.js +0 -68
- package/dist/session/parameter-data.js.map +0 -1
- package/dist/session/pin-tan-client.d.ts +0 -54
- package/dist/session/pin-tan-client.d.ts.map +0 -1
- package/dist/session/pin-tan-client.js +0 -153
- package/dist/session/pin-tan-client.js.map +0 -1
- package/dist/session/pin-tan-dialog.d.ts +0 -71
- package/dist/session/pin-tan-dialog.d.ts.map +0 -1
- package/dist/session/pin-tan-dialog.js +0 -124
- package/dist/session/pin-tan-dialog.js.map +0 -1
- package/dist/session/protocol.d.ts +0 -209
- package/dist/session/protocol.d.ts.map +0 -1
- package/dist/session/protocol.js +0 -75
- package/dist/session/protocol.js.map +0 -1
- package/dist/session/response-handler.d.ts +0 -48
- package/dist/session/response-handler.d.ts.map +0 -1
- package/dist/session/response-handler.js +0 -121
- package/dist/session/response-handler.js.map +0 -1
- package/dist/v3/client.d.ts +0 -24
- package/dist/v3/client.d.ts.map +0 -1
- package/dist/v3/client.js +0 -16
- package/dist/v3/client.js.map +0 -1
- package/src/session/bank-connection.ts +0 -51
- package/src/session/parameter-data.ts +0 -137
- package/src/session/pin-tan-client.ts +0 -186
- package/src/session/pin-tan-dialog.ts +0 -160
- package/src/session/protocol.ts +0 -311
- package/src/session/response-handler.ts +0 -130
- package/src/v3/client.ts +0 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tan-selection.d.ts","sourceRoot":"","sources":["../../src/session/tan-selection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,
|
|
1
|
+
{"version":3,"file":"tan-selection.d.ts","sourceRoot":"","sources":["../../src/session/tan-selection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,qBAAa,YAAY;IAWrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAZ1B;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA8C;IAEnF,wFAAwF;IACxF,OAAO,CAAC,cAAc,CAAS;gBAGZ,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,WAAW;IAGvC,sEAAsE;IACtE,IAAI,MAAM,IAAI,SAAS,CAKtB;IAED,8EAA8E;IAC9E,MAAM,CAAC,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAKrE;;;OAGG;IACH,YAAY,IAAI,IAAI;IAKpB;;;;;OAKG;IACH,SAAS,IAAI,YAAY;IAYzB;;;;;OAKG;IACH,YAAY,IAAI,YAAY;IAK5B;;;;;;;;;;OAUG;IACH,qBAAqB,IAAI,YAAY;IAYrC,+DAA+D;IAC/D,OAAO,CAAC,WAAW;IAInB;;;;;OAKG;IACH,SAAS,IAAI,SAAS,EAAE;IAgBxB;;;;;OAKG;IACG,OAAO,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IASpD,4FAA4F;IACtF,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAQzC;;;OAGG;IACH,IAAI,cAAc,IAAI,OAAO,CAG5B;IAED;;;OAGG;IACG,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjE;;;;;;OAMG;IACH,IAAI,aAAa,IAAI,SAAS,EAAE,GAAG,SAAS,CAE3C;IAED,+GAA+G;YACjG,cAAc;CAQ7B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FinTsTanSetupError } from '../core/errors.js';
|
|
2
2
|
import { TanMethod } from '../tan/tan-models.js';
|
|
3
|
-
import {
|
|
3
|
+
import { FinTs3Dialog } from '../v3/dialog.js';
|
|
4
|
+
import { noReference } from '../v3/segments.js';
|
|
4
5
|
/**
|
|
5
6
|
* The TAN method and medium the session's messages are signed with, chosen by the user among what the bank offers and
|
|
6
7
|
* the user may use, and kept in the session state.
|
|
@@ -9,10 +10,11 @@ export class TanSelection {
|
|
|
9
10
|
protocol;
|
|
10
11
|
state;
|
|
11
12
|
prompts;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The lookups of this session that found no medium to choose, by TAN method, with the list each gave; `undefined`
|
|
15
|
+
* where the bank gave none. Such a lookup is not repeated for its method until `select` or `forgetMedium` drops it.
|
|
16
|
+
*/
|
|
17
|
+
lookupsWithoutMedium = new Map();
|
|
16
18
|
/** Whether the bank refused a login signed with the one-step method in this session. */
|
|
17
19
|
oneStepRefused = false;
|
|
18
20
|
constructor(protocol, state, prompts) {
|
|
@@ -25,27 +27,36 @@ export class TanSelection {
|
|
|
25
27
|
const code = this.state.tanMethod;
|
|
26
28
|
if (code === undefined || code === TanMethod.oneStep.securityFunction)
|
|
27
29
|
return TanMethod.oneStep;
|
|
28
|
-
|
|
30
|
+
const methods = this.protocol.parameters.bankParameters?.tanMethods ?? [];
|
|
31
|
+
return methods.find((m) => m.securityFunction === code) ?? TanMethod.oneStep;
|
|
29
32
|
}
|
|
30
33
|
/** Switches to `securityFunction` and `tanMedium` for the dialogs to come. */
|
|
31
34
|
select(securityFunction, tanMedium) {
|
|
32
35
|
this.state.useTanMethod(securityFunction, tanMedium);
|
|
33
|
-
this.
|
|
36
|
+
this.lookupsWithoutMedium.delete(securityFunction);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Forgets the medium in use and the lookups of this session, so that the next login looks the media up anew where the
|
|
40
|
+
* method needs one: the bank may have refused the medium, such as that of a phone the user has replaced.
|
|
41
|
+
*/
|
|
42
|
+
forgetMedium() {
|
|
43
|
+
this.state.useTanMedium(undefined);
|
|
44
|
+
this.lookupsWithoutMedium.clear();
|
|
34
45
|
}
|
|
35
46
|
/**
|
|
36
47
|
* A dialog signed with the TAN method in use and its medium.
|
|
37
48
|
*
|
|
38
|
-
* Throws `
|
|
49
|
+
* Throws `FinTsTanSetupError` if the method needs a medium the user has not chosen: the bank would refuse the
|
|
39
50
|
* login, and the client would not send the PIN again.
|
|
40
51
|
*/
|
|
41
52
|
newDialog() {
|
|
42
53
|
const method = this.method;
|
|
43
54
|
if (this.lacksMedium(method)) {
|
|
44
|
-
throw new
|
|
55
|
+
throw new FinTsTanSetupError(`The TAN method ${method.name} needs a TAN medium, and the client could not learn one: the bank lists no ` +
|
|
45
56
|
'active medium for it, or does not offer or permit the list of TAN media, or rejected it. Pass a medium to ' +
|
|
46
57
|
'selectTanMethod, or choose another method');
|
|
47
58
|
}
|
|
48
|
-
return this.protocol
|
|
59
|
+
return FinTs3Dialog.signed(this.protocol, method, this.state.tanMedium);
|
|
49
60
|
}
|
|
50
61
|
/**
|
|
51
62
|
* The dialog that looks up the TAN media, signed with the TAN method in use.
|
|
@@ -55,7 +66,7 @@ export class TanSelection {
|
|
|
55
66
|
*/
|
|
56
67
|
lookupDialog() {
|
|
57
68
|
const method = this.method;
|
|
58
|
-
return this.protocol
|
|
69
|
+
return FinTs3Dialog.signed(this.protocol, method, this.lacksMedium(method) ? noReference : this.state.tanMedium);
|
|
59
70
|
}
|
|
60
71
|
/**
|
|
61
72
|
* The synchronization dialog. It runs before the TAN media are looked up, so its method must do without a medium the
|
|
@@ -66,18 +77,18 @@ export class TanSelection {
|
|
|
66
77
|
* a one-step login;
|
|
67
78
|
* 3. another two-step method the user may use.
|
|
68
79
|
*
|
|
69
|
-
* Throws `
|
|
80
|
+
* Throws `FinTsTanSetupError` if none does, before the bank could refuse the login.
|
|
70
81
|
*/
|
|
71
82
|
synchronizationDialog() {
|
|
72
83
|
const method = this.method;
|
|
73
84
|
if (!this.lacksMedium(method))
|
|
74
|
-
return this.protocol
|
|
85
|
+
return FinTs3Dialog.signed(this.protocol, method, this.state.tanMedium);
|
|
75
86
|
if (!this.oneStepRefused)
|
|
76
|
-
return this.protocol
|
|
87
|
+
return FinTs3Dialog.signed(this.protocol, TanMethod.oneStep);
|
|
77
88
|
const other = this.available().find((m) => !m.isOneStep && !this.lacksMedium(m));
|
|
78
89
|
if (other !== undefined)
|
|
79
|
-
return this.protocol
|
|
80
|
-
throw new
|
|
90
|
+
return FinTs3Dialog.signed(this.protocol, other);
|
|
91
|
+
throw new FinTsTanSetupError(`The bank refuses the one-step method, and the TAN method ${method.name} needs a TAN medium, which the client ` +
|
|
81
92
|
'can look up only after the synchronization. Pass the medium to selectTanMethod, or choose another method');
|
|
82
93
|
}
|
|
83
94
|
/** Whether `method` needs a medium the user has not chosen. */
|
|
@@ -88,17 +99,17 @@ export class TanSelection {
|
|
|
88
99
|
* The two-step TAN methods the bank offers, the user may use and this client can run; the one-step method if there
|
|
89
100
|
* are none.
|
|
90
101
|
*
|
|
91
|
-
* Throws `
|
|
102
|
+
* Throws `FinTsTanSetupError` if the bank offers the user nothing but methods the client cannot run.
|
|
92
103
|
*/
|
|
93
104
|
available() {
|
|
94
|
-
const bpd = this.protocol.bankParameters;
|
|
105
|
+
const bpd = this.protocol.parameters.bankParameters;
|
|
95
106
|
if (bpd === undefined)
|
|
96
107
|
return [TanMethod.oneStep];
|
|
97
|
-
const allowed = this.state.allowedMethods
|
|
108
|
+
const allowed = this.state.allowedMethods;
|
|
98
109
|
const isAllowed = (securityFunction) => allowed === undefined || allowed.length === 0 || allowed.includes(securityFunction);
|
|
99
110
|
const runnable = bpd.tanMethods.filter((m) => isAllowed(m.securityFunction));
|
|
100
111
|
if (runnable.length === 0 && bpd.unsupportedTanMethods.some(isAllowed)) {
|
|
101
|
-
throw new
|
|
112
|
+
throw new FinTsTanSetupError('The bank offers only TAN methods this client cannot run: process variant 1, or methods that need an SMS ' +
|
|
102
113
|
'charge account or an HHD_UC answer');
|
|
103
114
|
}
|
|
104
115
|
return runnable.length === 0 ? [TanMethod.oneStep] : runnable;
|
|
@@ -130,11 +141,11 @@ export class TanSelection {
|
|
|
130
141
|
}
|
|
131
142
|
/**
|
|
132
143
|
* Whether the media of the method in use have to be looked up: it needs a medium the user has not chosen, and they
|
|
133
|
-
* were not looked up for it in this session.
|
|
144
|
+
* were not looked up in vain for it in this session.
|
|
134
145
|
*/
|
|
135
146
|
get mediumToLookUp() {
|
|
136
147
|
const method = this.method;
|
|
137
|
-
return this.lacksMedium(method) && !this.
|
|
148
|
+
return this.lacksMedium(method) && !this.lookupsWithoutMedium.has(method.securityFunction);
|
|
138
149
|
}
|
|
139
150
|
/**
|
|
140
151
|
* Lets the user choose the medium of the method in use among the active ones in `media`, the result of a lookup;
|
|
@@ -142,20 +153,20 @@ export class TanSelection {
|
|
|
142
153
|
*/
|
|
143
154
|
async chooseMedium(media) {
|
|
144
155
|
const method = this.method;
|
|
145
|
-
|
|
146
|
-
this.state.useTanMedium(
|
|
147
|
-
|
|
156
|
+
const medium = media === undefined ? undefined : await this.chooseMediumOf(method, media);
|
|
157
|
+
this.state.useTanMedium(medium);
|
|
158
|
+
if (medium === undefined)
|
|
159
|
+
this.lookupsWithoutMedium.set(method.securityFunction, media);
|
|
148
160
|
}
|
|
149
161
|
/**
|
|
150
|
-
* The list of the
|
|
162
|
+
* The list of the lookup that found no medium for the method in use; `undefined` where there was none, or the bank
|
|
163
|
+
* gave no list.
|
|
151
164
|
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
165
|
+
* It outlasts the call that failed for want of the medium, so that `getTanMedia` can show the user the list that tells
|
|
166
|
+
* why: the client neither looks the media up again for the method nor can list them in a dialog without a medium.
|
|
154
167
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
this.lookedUpMedia = undefined;
|
|
158
|
-
return media;
|
|
168
|
+
get lookedUpMedia() {
|
|
169
|
+
return this.lookupsWithoutMedium.get(this.method.securityFunction);
|
|
159
170
|
}
|
|
160
171
|
/** The name of the medium the user chooses among the active ones in `media`; `undefined` if none is active. */
|
|
161
172
|
async chooseMediumOf(method, media) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tan-selection.js","sourceRoot":"","sources":["../../src/session/tan-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tan-selection.js","sourceRoot":"","sources":["../../src/session/tan-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAkB,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CA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AC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5D,CAAC;CACF;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,MAAiB;IAC1C,OAAO,MAAM,CAAC,eAAe,IAAI,CAAC,MAAM,CAAC,gBAAgB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BankMessage } from '../core/bank-info.js';
|
|
2
2
|
import type { FinTsClientOptions, MessageLogger } from '../core/client.js';
|
|
3
3
|
import type { FinTsFeedback } from '../core/feedback.js';
|
|
4
|
-
import
|
|
4
|
+
import { TanAnswer, type TanChallenge } from '../tan/challenge.js';
|
|
5
5
|
import type { TanMedium, TanMethod } from '../tan/tan-models.js';
|
|
6
6
|
/**
|
|
7
7
|
* Everything a session tells the app, asks of it or waits for: the bank's messages, warnings and log, the TAN callback,
|
|
@@ -11,12 +11,17 @@ import type { TanMedium, TanMethod } from '../tan/tan-models.js';
|
|
|
11
11
|
* callbacks that only inform the app wait for `reportingCallbackErrors`, as `FinTsClientOptions` promises.
|
|
12
12
|
*/
|
|
13
13
|
export declare class UserPrompts {
|
|
14
|
-
private readonly options;
|
|
15
14
|
private closed;
|
|
16
15
|
/** The first error an informing callback threw during the running call. */
|
|
17
16
|
private callbackError;
|
|
18
|
-
/** Aborts the waits under way; each wait removes its abort when it is over. */
|
|
17
|
+
/** Aborts the waits under way; each wait removes its abort when it is over, or when nothing waits for it any more. */
|
|
19
18
|
private readonly aborts;
|
|
19
|
+
/** The callbacks as the client was built with them, as in the Dart package, whose options are final. */
|
|
20
|
+
private readonly options;
|
|
21
|
+
/**
|
|
22
|
+
* Throws `TypeError` for a `tanCallback` that is no function, and for another callback that is neither a function
|
|
23
|
+
* nor `undefined` or `null`, which mean none.
|
|
24
|
+
*/
|
|
20
25
|
constructor(options: FinTsClientOptions);
|
|
21
26
|
/** Ends every wait; the client calls it once. */
|
|
22
27
|
close(): void;
|
|
@@ -34,7 +39,10 @@ export declare class UserPrompts {
|
|
|
34
39
|
/** Passes the bank's `warning` to the app, unless the client is closed. */
|
|
35
40
|
showWarning(warning: FinTsFeedback): void;
|
|
36
41
|
private inform;
|
|
37
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Shows `challenge` through the TAN callback and returns its answer; rejects with `TypeError` for anything but a
|
|
44
|
+
* `TanAnswer`. Once `TanChallenge.resolved` settles, nothing waits for the answer any more.
|
|
45
|
+
*/
|
|
38
46
|
askTan(challenge: TanChallenge): Promise<TanAnswer>;
|
|
39
47
|
/** Waits for `delayMs` milliseconds, or until `interrupt` settles. */
|
|
40
48
|
pause(delayMs: number, interrupt?: Promise<unknown>): Promise<void>;
|
|
@@ -51,7 +59,8 @@ export declare class UserPrompts {
|
|
|
51
59
|
*/
|
|
52
60
|
chooseMedium(media: readonly TanMedium[]): Promise<TanMedium>;
|
|
53
61
|
/**
|
|
54
|
-
* Starts `wait` and ends it with `FinTsStateError` if `close` is called before it is over.
|
|
62
|
+
* Starts `wait` and ends it with `FinTsStateError` if `close` is called before it is over. Once `unwanted` settles,
|
|
63
|
+
* nothing waits for it any more: it is forgotten then, rather than kept until a callback that never answers does.
|
|
55
64
|
*
|
|
56
65
|
* Once the client is closed, the returned promise rejects rather than this function throwing: a caller that starts
|
|
57
66
|
* several waits at once would otherwise leave the failure of those started first unheard.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-prompts.d.ts","sourceRoot":"","sources":["../../src/session/user-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"user-prompts.d.ts","sourceRoot":"","sources":["../../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AAC,IAAI,CAAC;IAcnE;;;;OAIG;IACG,YAAY,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IAUxE;;;;OAIG;IACG,YAAY,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IAUnE;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;CA0BrB"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { clientClosedError } from '../core/errors.js';
|
|
2
|
+
import { TanAnswer } from '../tan/challenge.js';
|
|
3
|
+
import { optionalFunction, requireFunction } from '../util/arguments.js';
|
|
2
4
|
import { Deferred } from '../util/async.js';
|
|
3
5
|
import { invalidArgument } from '../util/errors.js';
|
|
4
|
-
function closedError() {
|
|
5
|
-
return new FinTsStateError('The FinTS client is closed');
|
|
6
|
-
}
|
|
7
6
|
/**
|
|
8
7
|
* Everything a session tells the app, asks of it or waits for: the bank's messages, warnings and log, the TAN callback,
|
|
9
8
|
* the selectors and the pauses between status requests.
|
|
@@ -12,14 +11,28 @@ function closedError() {
|
|
|
12
11
|
* callbacks that only inform the app wait for `reportingCallbackErrors`, as `FinTsClientOptions` promises.
|
|
13
12
|
*/
|
|
14
13
|
export class UserPrompts {
|
|
15
|
-
options;
|
|
16
14
|
closed = false;
|
|
17
15
|
/** The first error an informing callback threw during the running call. */
|
|
18
16
|
callbackError;
|
|
19
|
-
/** Aborts the waits under way; each wait removes its abort when it is over. */
|
|
17
|
+
/** Aborts the waits under way; each wait removes its abort when it is over, or when nothing waits for it any more. */
|
|
20
18
|
aborts = new Set();
|
|
19
|
+
/** The callbacks as the client was built with them, as in the Dart package, whose options are final. */
|
|
20
|
+
options;
|
|
21
|
+
/**
|
|
22
|
+
* Throws `TypeError` for a `tanCallback` that is no function, and for another callback that is neither a function
|
|
23
|
+
* nor `undefined` or `null`, which mean none.
|
|
24
|
+
*/
|
|
21
25
|
constructor(options) {
|
|
22
|
-
|
|
26
|
+
const tanCallback = requireFunction(options.tanCallback, 'tanCallback');
|
|
27
|
+
this.options = {
|
|
28
|
+
// Called on the app's options, which a callback written as a method of them may refer to as `this`.
|
|
29
|
+
tanCallback: (challenge) => tanCallback.call(options, challenge),
|
|
30
|
+
tanMethodSelector: optionalFunction(options.tanMethodSelector, 'tanMethodSelector'),
|
|
31
|
+
tanMediumSelector: optionalFunction(options.tanMediumSelector, 'tanMediumSelector'),
|
|
32
|
+
onBankMessage: optionalFunction(options.onBankMessage, 'onBankMessage'),
|
|
33
|
+
onWarning: optionalFunction(options.onWarning, 'onWarning'),
|
|
34
|
+
logger: optionalFunction(options.logger, 'logger'),
|
|
35
|
+
};
|
|
23
36
|
}
|
|
24
37
|
/** Ends every wait; the client calls it once. */
|
|
25
38
|
close() {
|
|
@@ -31,7 +44,7 @@ export class UserPrompts {
|
|
|
31
44
|
/** Throws `FinTsStateError` once `close` was called. */
|
|
32
45
|
checkOpen() {
|
|
33
46
|
if (this.closed)
|
|
34
|
-
throw
|
|
47
|
+
throw clientClosedError();
|
|
35
48
|
}
|
|
36
49
|
/**
|
|
37
50
|
* Runs `call` and then fails it with the first error an informing callback threw meanwhile; an error of `call` itself
|
|
@@ -83,14 +96,17 @@ export class UserPrompts {
|
|
|
83
96
|
this.callbackError ??= { error };
|
|
84
97
|
}
|
|
85
98
|
}
|
|
86
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Shows `challenge` through the TAN callback and returns its answer; rejects with `TypeError` for anything but a
|
|
101
|
+
* `TanAnswer`. Once `TanChallenge.resolved` settles, nothing waits for the answer any more.
|
|
102
|
+
*/
|
|
87
103
|
askTan(challenge) {
|
|
88
|
-
return this.unlessClosed(() => this.options.tanCallback(challenge));
|
|
104
|
+
return this.unlessClosed(async () => tanAnswerOf(await this.options.tanCallback(challenge)), challenge.resolved);
|
|
89
105
|
}
|
|
90
106
|
/** Waits for `delayMs` milliseconds, or until `interrupt` settles. */
|
|
91
107
|
pause(delayMs, interrupt) {
|
|
92
108
|
if (this.closed)
|
|
93
|
-
return Promise.reject(
|
|
109
|
+
return Promise.reject(clientClosedError());
|
|
94
110
|
let timer;
|
|
95
111
|
const elapsed = new Promise((resolve) => {
|
|
96
112
|
timer = setTimeout(resolve, Math.max(0, delayMs));
|
|
@@ -110,7 +126,7 @@ export class UserPrompts {
|
|
|
110
126
|
if (candidates.length === 1 || selector === undefined)
|
|
111
127
|
return candidates[0];
|
|
112
128
|
const chosen = await this.unlessClosed(() => selector(candidates));
|
|
113
|
-
if (chosen === undefined)
|
|
129
|
+
if (chosen === undefined || chosen === null)
|
|
114
130
|
return candidates[0];
|
|
115
131
|
const match = candidates.find((m) => m.securityFunction === chosen.securityFunction);
|
|
116
132
|
if (match === undefined)
|
|
@@ -127,7 +143,7 @@ export class UserPrompts {
|
|
|
127
143
|
if (media.length === 1 || selector === undefined)
|
|
128
144
|
return media[0];
|
|
129
145
|
const chosen = await this.unlessClosed(() => selector(media));
|
|
130
|
-
if (chosen === undefined)
|
|
146
|
+
if (chosen === undefined || chosen === null)
|
|
131
147
|
return media[0];
|
|
132
148
|
const match = media.find((m) => m.name === chosen.name);
|
|
133
149
|
if (match === undefined)
|
|
@@ -135,17 +151,21 @@ export class UserPrompts {
|
|
|
135
151
|
return match;
|
|
136
152
|
}
|
|
137
153
|
/**
|
|
138
|
-
* Starts `wait` and ends it with `FinTsStateError` if `close` is called before it is over.
|
|
154
|
+
* Starts `wait` and ends it with `FinTsStateError` if `close` is called before it is over. Once `unwanted` settles,
|
|
155
|
+
* nothing waits for it any more: it is forgotten then, rather than kept until a callback that never answers does.
|
|
139
156
|
*
|
|
140
157
|
* Once the client is closed, the returned promise rejects rather than this function throwing: a caller that starts
|
|
141
158
|
* several waits at once would otherwise leave the failure of those started first unheard.
|
|
142
159
|
*/
|
|
143
|
-
unlessClosed(wait) {
|
|
160
|
+
unlessClosed(wait, unwanted) {
|
|
144
161
|
if (this.closed)
|
|
145
|
-
return Promise.reject(
|
|
162
|
+
return Promise.reject(clientClosedError());
|
|
146
163
|
const result = new Deferred();
|
|
147
164
|
const abort = () => {
|
|
148
|
-
result.reject(
|
|
165
|
+
result.reject(clientClosedError());
|
|
166
|
+
};
|
|
167
|
+
const forget = () => {
|
|
168
|
+
this.aborts.delete(abort);
|
|
149
169
|
};
|
|
150
170
|
this.aborts.add(abort);
|
|
151
171
|
// Runs `wait` at once, as far as its first `await`, and turns an error it throws into a rejection.
|
|
@@ -156,9 +176,24 @@ export class UserPrompts {
|
|
|
156
176
|
}, (error) => {
|
|
157
177
|
result.reject(error);
|
|
158
178
|
})
|
|
159
|
-
.finally(
|
|
179
|
+
.finally(forget)
|
|
160
180
|
.catch(() => undefined);
|
|
181
|
+
void unwanted?.then(forget, forget);
|
|
161
182
|
return result.promise;
|
|
162
183
|
}
|
|
163
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* `answer`, a result of the TAN callback, as a `TanAnswer`; throws `TypeError` for anything else, such as the
|
|
187
|
+
* `undefined` of a callback that returns nothing. The answer is read once, so that what was checked is what counts.
|
|
188
|
+
*/
|
|
189
|
+
function tanAnswerOf(answer) {
|
|
190
|
+
const { kind, tan } = (typeof answer === 'object' && answer !== null ? answer : {});
|
|
191
|
+
if (kind === 'tan' && typeof tan === 'string')
|
|
192
|
+
return TanAnswer.tan(tan);
|
|
193
|
+
if (kind === 'approved')
|
|
194
|
+
return TanAnswer.approved;
|
|
195
|
+
if (kind === 'cancelled')
|
|
196
|
+
return TanAnswer.cancelled;
|
|
197
|
+
throw invalidArgument('Returned no TanAnswer', 'tanCallback');
|
|
198
|
+
}
|
|
164
199
|
//# sourceMappingURL=user-prompts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-prompts.js","sourceRoot":"","sources":["../../src/session/user-prompts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"user-prompts.js","sourceRoot":"","sources":["../../src/session/user-prompts.ts"],"names":[],"m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C,OAAO,CAAC;IACxB,CAAC;CACF;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,MAAe;IAClC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAGjF,CAAC;IACF,IAAI,IAAI,KAAK,KAAK,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzE,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC,QAAQ,CAAC;IACnD,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO,SAAS,CAAC,SAAS,CAAC;IACrD,MAAM,eAAe,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/tan/challenge.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { inspectCustom } from '../util/inspect.js';
|
|
1
2
|
import { FlickerCode } from './flicker.js';
|
|
2
3
|
import { TanImage } from './tan-image.js';
|
|
3
4
|
import type { TanMedium, TanMethod } from './tan-models.js';
|
|
@@ -21,9 +22,13 @@ export interface TanChallengeInit {
|
|
|
21
22
|
export declare class TanChallenge {
|
|
22
23
|
/** The TAN method the challenge is for. */
|
|
23
24
|
readonly method: TanMethod;
|
|
24
|
-
/** Bank reference of the pending action. */
|
|
25
|
+
/** Bank reference of the pending action, one character per byte the bank sent (ISO 8859-1). */
|
|
25
26
|
readonly reference: string;
|
|
26
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Challenge text as the bank sent it, including the formatting tags of a structured challenge
|
|
29
|
+
* (`TanMethod.structuredChallenge`); `plainMessage` is the text to show. Show either as text only, never as HTML
|
|
30
|
+
* (`innerHTML`, `v-html`): it is the bank's text, not markup to trust.
|
|
31
|
+
*/
|
|
27
32
|
readonly message: string | undefined;
|
|
28
33
|
/** Raw challenge data for TAN generators (HHD_UC). */
|
|
29
34
|
readonly hhdUc: Uint8Array | undefined;
|
|
@@ -40,12 +45,15 @@ export declare class TanChallenge {
|
|
|
40
45
|
/** Counts repeated prompts for the same decoupled approval. */
|
|
41
46
|
readonly attempt: number;
|
|
42
47
|
/**
|
|
43
|
-
* Settles when the client needs no more answer to this challenge:
|
|
44
|
-
* failed, timed out or was cancelled. Set where the client asks the bank
|
|
45
|
-
* challenge (`TanCallback`), `undefined` otherwise. It never rejects.
|
|
48
|
+
* Settles when the client needs no more answer to this challenge: a later prompt for the approval replaces it, or the
|
|
49
|
+
* bank confirmed the approval, or the approval failed, timed out or was cancelled. Set where the client asks the bank
|
|
50
|
+
* by itself while the callback shows the challenge (`TanCallback`), `undefined` otherwise. It never rejects.
|
|
46
51
|
*/
|
|
47
52
|
readonly resolved: Promise<void> | undefined;
|
|
48
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* A challenge as the bank sent it, with a copy of `validUntil`, which no other challenge shares. Use
|
|
55
|
+
* `TanChallenge.create` to have a flicker code or image detected in the data.
|
|
56
|
+
*/
|
|
49
57
|
constructor(init: TanChallengeInit);
|
|
50
58
|
/** Builds a challenge and detects a photoTAN image or chipTAN flicker code in `hhdUc` or `message`. */
|
|
51
59
|
static create(init: Omit<TanChallengeInit, 'flickerCode' | 'image' | 'resolved'>): TanChallenge;
|
|
@@ -60,9 +68,18 @@ export declare class TanChallenge {
|
|
|
60
68
|
* A method with structured challenges (`TanMethod.structuredChallenge`) may use the formatting tags the specification
|
|
61
69
|
* defines. Line breaks, paragraphs and list items become new lines. Bold, italics, underlining and list tags are
|
|
62
70
|
* removed, and the entity references of such markup are resolved. Any other challenge stays as the bank sent it,
|
|
63
|
-
* which is how the specification wants it shown.
|
|
71
|
+
* which is how the specification wants it shown. So does a structured challenge of more than 65,536 characters.
|
|
72
|
+
*
|
|
73
|
+
* Show it as text, such as with `textContent`, or `{{ }}` in Vue, and `white-space: pre-line` for its line breaks;
|
|
74
|
+
* never as HTML (`innerHTML`, `v-html`). It keeps the tags the specification does not define, and `<` becomes
|
|
75
|
+
* `<`, so that as HTML the bank's text could run scripts in the app.
|
|
64
76
|
*/
|
|
65
77
|
get plainMessage(): string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* What Node.js's `util.inspect` and `console.log` show: the method, the kind of challenge and the attempt; not the
|
|
80
|
+
* text, the reference, the challenge data, the image or the medium, which may name the user, the account or the order.
|
|
81
|
+
*/
|
|
82
|
+
[inspectCustom](): string;
|
|
66
83
|
}
|
|
67
84
|
/** `challenge` again, counted as the next prompt for the same approval, with the bank's new instructions `message`. */
|
|
68
85
|
export declare function nextAttempt(challenge: TanChallenge, message?: string): TanChallenge;
|
|
@@ -70,7 +87,10 @@ export declare function nextAttempt(challenge: TanChallenge, message?: string):
|
|
|
70
87
|
export declare function withResolved(challenge: TanChallenge, resolved: Promise<void>): TanChallenge;
|
|
71
88
|
/** The user's answer to a `TanChallenge`: `TanAnswer.tan(…)`, `TanAnswer.approved` or `TanAnswer.cancelled`. */
|
|
72
89
|
export type TanAnswer =
|
|
73
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* The TAN the user entered; an empty one cancels a TAN challenge. Blanks around it do not count, and full-width
|
|
92
|
+
* characters, as East Asian input methods type them, count as their ASCII counterparts.
|
|
93
|
+
*/
|
|
74
94
|
{
|
|
75
95
|
readonly kind: 'tan';
|
|
76
96
|
readonly tan: string;
|
|
@@ -85,30 +105,33 @@ export type TanAnswer =
|
|
|
85
105
|
};
|
|
86
106
|
/** The answers a `TanCallback` returns. */
|
|
87
107
|
export declare const TanAnswer: Readonly<{
|
|
88
|
-
/** The TAN the user entered; an empty one cancels. */
|
|
108
|
+
/** The TAN the user entered; an empty one cancels a TAN challenge (`TanAnswer`). */
|
|
89
109
|
tan: (tan: string) => TanAnswer;
|
|
90
110
|
/** The user reports the approval in the banking app (`TanChallenge.isDecoupled`); the client then asks the bank. */
|
|
91
|
-
approved:
|
|
92
|
-
readonly kind: "approved";
|
|
93
|
-
};
|
|
111
|
+
approved: TanAnswer;
|
|
94
112
|
/** The user cancels: the client ends the bank dialog, and the call fails with `FinTsTanCancelledError`. */
|
|
95
|
-
cancelled:
|
|
96
|
-
readonly kind: "cancelled";
|
|
97
|
-
};
|
|
113
|
+
cancelled: TanAnswer;
|
|
98
114
|
}>;
|
|
99
115
|
/**
|
|
100
116
|
* Shows the `TanChallenge` to the user and returns the `TanAnswer`: `TanAnswer.tan(…)` for a TAN, `TanAnswer.approved`
|
|
101
117
|
* once the user reports an approval in the banking app (`TanChallenge.isDecoupled`), `TanAnswer.cancelled` to cancel
|
|
102
|
-
* either.
|
|
118
|
+
* either.
|
|
119
|
+
*
|
|
120
|
+
* The call fails with a `TypeError`, without reaching the bank, for anything but a `TanAnswer`, for `approved` to a TAN
|
|
121
|
+
* challenge, for a TAN to an app approval the user can report, and for a TAN that the method rules out: longer than
|
|
122
|
+
* `TanMethod.maxTanLength`, with anything but the digits 0 to 9 where `TanMethod.numericTan`, or that FinTS 3.0 cannot
|
|
123
|
+
* send (ISO 8859-1 only). Where the user cannot report the approval (`TanChallenge.manualConfirmation` is `false`),
|
|
124
|
+
* offer no confirm button: any `TanAnswer` but `cancelled` is ignored.
|
|
103
125
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
126
|
+
* If the bank has not confirmed a reported approval yet, the callback is called again with the next
|
|
127
|
+
* `TanChallenge.attempt` and the bank's latest instructions. Where the client polls the bank by itself, it sets
|
|
128
|
+
* `TanChallenge.resolved`: close the prompt when it settles, the callback's result is no longer waited for then. New
|
|
129
|
+
* instructions of the bank then replace the open prompt with the next attempt, which the callback gets after the
|
|
130
|
+
* handlers of the earlier prompt's `resolved` have run.
|
|
108
131
|
*/
|
|
109
132
|
export type TanCallback = (challenge: TanChallenge) => TanAnswer | Promise<TanAnswer>;
|
|
110
|
-
/** Picks one of several allowed TAN methods; the first is used when this returns `undefined`. */
|
|
111
|
-
export type TanMethodSelector = (methods: readonly TanMethod[]) => TanMethod | undefined | Promise<TanMethod | undefined>;
|
|
112
|
-
/** Picks one of several active TAN media; the first is used when this returns `undefined`. */
|
|
113
|
-
export type TanMediumSelector = (media: readonly TanMedium[]) => TanMedium | undefined | Promise<TanMedium | undefined>;
|
|
133
|
+
/** Picks one of several allowed TAN methods; the first is used when this returns `undefined` or `null`. */
|
|
134
|
+
export type TanMethodSelector = (methods: readonly TanMethod[]) => TanMethod | null | undefined | Promise<TanMethod | null | undefined>;
|
|
135
|
+
/** Picks one of several active TAN media; the first is used when this returns `undefined` or `null`. */
|
|
136
|
+
export type TanMediumSelector = (media: readonly TanMedium[]) => TanMedium | null | undefined | Promise<TanMedium | null | undefined>;
|
|
114
137
|
//# sourceMappingURL=challenge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"challenge.d.ts","sourceRoot":"","sources":["../../src/tan/challenge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"challenge.d.ts","sourceRoot":"","sources":["../../src/tan/challenge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAwB,WAAW,EAA0B,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5D,0GAA0G;AAC1G,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAE7E;AAuCD,iCAAiC;AACjC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,KAAK,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAC/B,W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