1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//! # fints-client: a FinTS 3.0 PIN/TAN client
//!
//! FinTS (formerly HBCI) is the online-banking protocol of German banks.
//! This crate reads balances, transactions and securities holdings, and
//! sends SEPA and instant transfers with the payee name check
//! (Verification of Payee).
//!
//! Banks answer only clients registered with the Deutsche Kreditwirtschaft:
//! register your app at <https://www.fints.org/de/hersteller/produktregistrierung>
//! and pass its product ID to [`jobs::BankClient::new`]. The crate ships
//! with no product ID.
//!
//! ## Quick start
//!
//! Every operation is `async`. The default `http` transport is reqwest and
//! needs a tokio runtime.
//!
//! ```rust,no_run
//! use fints_client::jobs::{self, BankClient, Credentials, Step, TanKind};
//! use fints_client::{bank_by_blz, jiff::Timestamp, Pin, ProductId, SessionState, UserId};
//!
//! # fn read_tan() -> String { String::new() }
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let config = bank_by_blz("12030000").expect("BLZ in the bank directory"); // DKB
//! let client = BankClient::new(config, ProductId::new("YOUR-PRODUCT-ID"));
//! let user = UserId::new("user");
//! let creds = Credentials::new(user.clone(), Pin::new("pin"));
//! let state = SessionState::new(&client.config().blz, &user); // or SessionState::from_json(stored)
//!
//! // Open the dialog. A bank that wants a TAN answers `NeedTan`.
//! let (mut dialog, mut step) = jobs::open(&client, &creds, &state).await?;
//! let opened = loop {
//! match step {
//! Step::Done(done) => break done.value,
//! Step::NeedTan(challenge, resume) => {
//! println!("{}", challenge.challenge);
//! step = match challenge.kind {
//! // App approval: wait as long as the bank asks, then ask once.
//! TanKind::Decoupled { .. } => {
//! if let Some(at) = challenge.not_before {
//! let wait = at.duration_since(Timestamp::now());
//! tokio::time::sleep(wait.try_into().unwrap_or_default()).await;
//! }
//! dialog.poll(resume).await?
//! }
//! // chipTAN, smsTAN, photoTAN: the user types the TAN.
//! TanKind::Typed { .. } => dialog.submit_tan(resume, &read_tan()).await?,
//! };
//! }
//! _ => unreachable!("only a transfer pauses on its payee check"),
//! }
//! };
//!
//! let account = opened.accounts[0].account()?;
//! if let Step::Done(balance) = jobs::balance(&mut dialog, &account).await? {
//! println!("{:?}", balance.value);
//! }
//! let state = dialog.end().await?;
//! std::fs::write("state.json", state.to_json()?)?; // encrypt this in a real app
//! # Ok(())
//! # }
//! ```
//!
//! ## Steps instead of callbacks
//!
//! Every job in [`jobs`] returns a [`jobs::Step`]: `Done` with the value,
//! or a pause with a resume handle. `NeedTan` carries a
//! [`jobs::TanChallenge`]; its [`jobs::TanKind`] says how to answer:
//!
//! - **Typed** (chipTAN, smsTAN, photoTAN): the user types the TAN, you call
//! [`jobs::Dialog::submit_tan`]. A flicker code or photoTAN image comes in
//! `media` for you to render.
//! - **Decoupled** (app approval): sleep until `not_before`, then call
//! [`jobs::Dialog::poll`]; repeat while the bank says it is still waiting.
//! When `auto_polling_allowed` is `Some(false)`, poll only when the user
//! asks (a button), not on a timer.
//!
//! A [`jobs::transfer`] may also pause on its payee check
//! (`NeedVopConfirmation`). The library never sleeps and never calls back.
//! A paused dialog can be frozen into a serialisable value and thawed in a
//! new process ([`jobs::Dialog::freeze`]). [`jobs::synchronise`] learns the
//! allowed TAN methods without a login, so the user can choose one before
//! `open`.
//!
//! ## Banks
//!
//! [`bank_by_blz`] looks a bank up in the bank directory by its BLZ
//! (Bankleitzahl: the German bank code, characters 5 to 12 of the IBAN) and
//! returns a [`BankConfig`] with its server and profile. A bank's own
//! behaviour lives in its [`BankProfile`], not in code paths.
//!
//! ## Cargo features
//!
//! - `http` (default): `HttpTransport` (reqwest with rustls), the default
//! transport of a [`jobs::Dialog`]. Without it you supply the transport.
//! - `trace`: `Recorder` and `Trace`, masked recordings of dialogs.
//! - `testbank`: registers the synthetic test bank (BLZ 12345678 on
//! localhost) as a known bank.
//! - `tooling`: the protocol internals (`codec`, `protocol`, `types`) for
//! the test bank and wire-level tests. Applications use `jobs`.
//!
//! ## Dates
//!
//! Dates and timestamps in the API are [`jiff`] types. The crate re-exports
//! `jiff` so a caller can name the version this crate uses.
// Lets code generated by `fints-client-derive` name `::fints_client` inside
// this crate as well.
extern crate self as fints_client;
// ── Infrastructure ──
pub
pub
pub
pub
pub
// ── Architecture ──
pub
// ═══════════════════════════════════════════════════════════════════════════════
// Re-exports
// ═══════════════════════════════════════════════════════════════════════════════
pub use jiff;
// Protocol types that public signatures name
pub use ;
// Domain types
pub use ;
pub use ;
pub use ;
pub use ;
pub use SessionState;
pub use ;