Link ING and other European banks through Enable Banking
- Docker passes ENABLE_BANKING_APP_ID and ENABLE_BANKING_PRIVATE_KEY through - transactions are keyed on entry_reference: Enable Banking says transaction_id may change between fetches, which imported rows twice - a key pasted on one line keeps its own PEM label (PKCS#1 keys broke before) - nginx keeps X-Forwarded-Proto/Host from a reverse proxy, so return links are https - README: how to set up the app, the keys, and https if Enable Banking needs it Checked against Enable Banking's API docs and tested end to end against a stand-in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cc22098868
commit
ea53718e5d
6 files changed
+101
-7
No files matched your search
@@ -27,9 +27,11 @@ async function call<T>(f: Fetch, label: string, url: string, init?: RequestInit)
|
||||
|
||||
// ---- Enable Banking (UK and Europe) ----
|
||||
// A pasted key loses its line breaks in a one-line box: rebuild the PEM from whatever came in.
|
||||
// Keeps the key's own label (PRIVATE KEY or RSA PRIVATE KEY): the body differs between the two, so one can't stand in for the other.
|
||||
export function pemFrom(raw: string) {
|
||||
const label = raw.match(/-----BEGIN ([A-Z ]+)-----/)?.[1] ?? "PRIVATE KEY";
|
||||
const body = raw.replace(/\\n/g, "\n").replace(/-----[^-]+-----/g, "").replace(/\s+/g, "");
|
||||
return `-----BEGIN PRIVATE KEY-----\n${body.match(/.{1,64}/g)?.join("\n") ?? ""}\n-----END PRIVATE KEY-----\n`;
|
||||
return `-----BEGIN ${label}-----\n${body.match(/.{1,64}/g)?.join("\n") ?? ""}\n-----END ${label}-----\n`;
|
||||
}
|
||||
const b64 = (v: unknown) => Buffer.from(JSON.stringify(v)).toString("base64url");
|
||||
export function ebJwt(env: Env, now = Date.now()) {
|
||||
@@ -84,7 +86,9 @@ export function ebTxn(t: EbTxn, uid: string): FeedTxn | null {
|
||||
const out = t.credit_debit_indicator === "DBIT";
|
||||
const text = (Array.isArray(t.remittance_information) ? t.remittance_information.join(" ") : t.remittance_information) || t.note || "";
|
||||
const other = (out ? t.creditor?.name : t.debtor?.name) ?? null;
|
||||
const id = t.transaction_id || t.entry_reference || `${date}|${n}|${text}`; // no id from the bank: same day, amount and text is the same row
|
||||
// entry_reference is fixed per account; Enable Banking says transaction_id "may change" between fetches, which would
|
||||
// import the same row twice. No id from the bank: same day, amount and text is the same row.
|
||||
const id = t.entry_reference || t.transaction_id || `${date}|${n}|${text}`;
|
||||
return { plaid_transaction_id: `enablebanking:${uid}:${id}`, account_ref: `enablebanking:${uid}`, date: date.slice(0, 10), amount: out ? Math.abs(n) : -Math.abs(n), name: text || other || "Transaction", merchant_name: other, logo_url: null, pending: false, plaid_category: t.bank_transaction_code?.code ?? null };
|
||||
}
|
||||
async function ebFeed(env: Env, token: string, since: string, f?: Fetch) {
|
||||
|
||||
Reference in new issue
Block a user