Skip to content

feat: Add BankCapabilities to expose bank feature flags#36

Open
Copilot wants to merge 5 commits intomasterfrom
copilot/add-bank-capabilities-schema
Open

feat: Add BankCapabilities to expose bank feature flags#36
Copilot wants to merge 5 commits intomasterfrom
copilot/add-bank-capabilities-schema

Conversation

Copy link

Copilot AI commented Mar 7, 2026

Banks vary in which FinTS business transactions they support. There was no way to discover this without probing each endpoint individually.

Changes

New BankCapabilities interface (types.ts)

Nine flags derived from parameter segments in the sync response:

Flag FinTS source
supportsAccounts always true (universally supported)
supportsBalance HISALS present
supportsTransactions HIKAZS present
supportsHoldings HIWPDS present
supportsStandingOrders HICDBS present
supportsCreditTransfer HICCSS present
supportsDirectDebit HIDSES present
requiresTanForTransactions HIKAZS minSignatures > 0
requiresTanForBalance HISALS minSignatures > 0

Dialog (dialog.ts)

  • Adds supportsCreditTransfer, supportsDirectDebit, hikazsMinSignatures, hisalsMinSignatures fields, populated during sync()
  • Adds capabilities getter that assembles BankCapabilities from current dialog state

Client (client.ts)

  • Adds capabilities(): Promise<BankCapabilities> — runs a sync dialog and returns dialog.capabilities
const client = new PinTanClient({ blz, name, pin, url });
const caps = await client.capabilities();

if (!caps.supportsTransactions) {
  console.log("This bank does not support statement fetching");
}
if (caps.requiresTanForBalance) {
  console.log("A TAN is needed to query balances");
}

BankCapabilities is exported from the package's public index.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 7, 2026 00:53
Co-authored-by: larsdecker <1968186+larsdecker@users.noreply.github.com>
- Add BankCapabilities interface to types.ts with 9 capability flags
  derived from FinTS parameter segments (HIKAZS, HISALS, HIWPDS,
  HICCSS, HIDSES, HICDBS)
- Add supportsCreditTransfer, supportsDirectDebit, hikazsMinSignatures
  and hisalsMinSignatures fields to Dialog, populated during sync()
- Add Dialog.capabilities getter assembling BankCapabilities from state
- Add Client.capabilities() async method (sync + return capabilities)
- Add tests in test-client.ts and test-dialog.ts

Co-authored-by: larsdecker <1968186+larsdecker@users.noreply.github.com>
Copilot AI changed the title [WIP] Add feature flags for bank capabilities feat: Add BankCapabilities to expose bank feature flags Mar 7, 2026
@larsdecker larsdecker marked this pull request as ready for review March 7, 2026 01:16
Copilot AI review requested due to automatic review settings March 7, 2026 01:16
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8cb423fe8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +185 to +188
const hikazs = response.findSegment(HIKAZS);
this.hikazsMinSignatures = hikazs?.minSignatures ?? 0;
const hisals = response.findSegment(HISALS);
this.hisalsMinSignatures = hisals?.minSignatures ?? 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Derive TAN requirements from negotiated segment version

sync() determines supported HIKAZS/HISALS versions via segmentMaxVersion(...), but requiresTanForTransactions/requiresTanForBalance are populated from response.findSegment(...), which returns the first segment instance, not necessarily the version that will actually be used by requests. When a bank advertises multiple versions of these parameter segments and minSignatures differs between versions, dialog.capabilities can report incorrect TAN requirements; read minSignatures from the selected max version (or aggregate safely across all advertised versions).

Useful? React with 👍 / 👎.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a first-class way to discover which FinTS business transactions a bank advertises during the initial sync dialog, so callers can avoid probing endpoints individually.

Changes:

  • Introduce a new BankCapabilities interface to represent bank feature flags derived from sync parameter segments.
  • Extend Dialog.sync() to record additional capability-related fields and add a dialog.capabilities getter.
  • Add Client.capabilities() plus unit tests covering both Dialog and Client capability derivation.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/fints/src/types.ts Adds BankCapabilities interface and documentation.
packages/fints/src/dialog.ts Captures additional sync-derived fields and exposes them via a capabilities getter.
packages/fints/src/client.ts Adds capabilities(): Promise<BankCapabilities> convenience API.
packages/fints/src/tests/test-dialog.ts Tests Dialog.capabilities mapping from dialog state.
packages/fints/src/tests/test-client.ts Tests Client.capabilities() behavior using mocked sync/end responses.
IMPLEMENTATION_SUMMARY.md Removed from repository in this PR.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 172 to 174
@@ -153,12 +174,18 @@ export class Dialog extends DialogConfig {
this.hicdbVersion = response.segmentMaxVersion(HICDBS);
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sync() sets hisalsVersion/hikazsVersion/hicdbVersion directly to segmentMaxVersion(...), which can be 0 when the parameter segment is absent. These version fields are later used to construct request segments (e.g. HKSAL/HKKAZ) that throw on unsupported versions, so this can cause a local "Unsupported ... version 0" error instead of a clear "feature not supported" result. Consider keeping the request version at a valid default (e.g. latest supported) and tracking support separately, or add explicit capability checks before constructing versioned request segments.

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3c89d4c. The approach:

  • Added dedicated supportsBalance, supportsTransactions, and supportsStandingOrders boolean fields (defaulting to false) alongside the existing supportsCreditTransfer/supportsDirectDebit pattern.
  • sync() now sets each boolean flag from segmentMaxVersion > 0 and only updates the request-version field when the bank actually advertises support — so hisalsVersion, hikazsVersion, and hicdbVersion keep their safe defaults (6, 6, 1) when the segment is absent, preventing any "Unsupported version 0" error in HKSAL/HKKAZ.
  • The capabilities getter now reads from the boolean fields rather than > 0 version checks, which also fixes incorrect pre-sync() values (the old defaults of 6/6/1 would have produced true before sync ran).
  • Also merged the two separate ./types import statements into one.

HICCSS,
Segment,
} from "./segments";
import { BankCapabilities } from "./types";
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are now two separate imports from ./types (Connection above and BankCapabilities here). Consider merging them into a single import to avoid duplication and keep import blocks consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +364 to +368
public get capabilities(): BankCapabilities {
return {
supportsAccounts: true,
supportsBalance: this.hisalsVersion > 0,
supportsTransactions: this.hikazsVersion > 0,
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capabilities can return incorrect supports* values if accessed before sync() runs, because several *Version fields have non-zero defaults (e.g. hisalsVersion = 6, hikazsVersion = 6, hicdbVersion = 1). Consider adding a guard (e.g. track hasSynced and throw) or deriving support from fields that are only set during sync so consumers can’t accidentally get a misleading capabilities object.

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +74
public async capabilities(): Promise<BankCapabilities> {
const dialog = this.createDialog();
await dialog.sync();
return dialog.capabilities;
}
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description focuses on adding BankCapabilities, but the diff also removes IMPLEMENTATION_SUMMARY.md entirely. If that removal is intentional cleanup, please mention it in the PR description or move it to a separate PR to keep this change focused.

Copilot uses AI. Check for mistakes.
@larsdecker
Copy link
Owner

@copilot apply changes based on the comments in this thread

- Add supportsBalance, supportsTransactions, supportsStandingOrders
  boolean fields (default false) to Dialog, populated during sync()
- Keep hisalsVersion, hikazsVersion, hicdbVersion at their safe
  defaults when the bank does not advertise the feature, preventing
  'Unsupported version 0' errors in HKSAL/HKKAZ constructors
- Update capabilities getter to use the new boolean fields instead of
  version > 0 checks, fixing misleading results before sync() runs
- Merge the two separate import blocks from ./types into one
- Add pre-sync capabilities test to test-dialog.ts

Co-authored-by: larsdecker <1968186+larsdecker@users.noreply.github.com>
This file pre-existed and was unintentionally removed in the feature commit.
Restoring it to keep this PR focused on the BankCapabilities feature only.

Co-authored-by: larsdecker <1968186+larsdecker@users.noreply.github.com>
Copy link
Author

Copilot AI commented Mar 17, 2026

@copilot apply changes based on the comments in this thread

All four review comments are now addressed:

  1. dialog.ts:172-174 (3c89d4c) — sync() now keeps hisalsVersion/hikazsVersion/hicdbVersion at their safe defaults when the segment is absent and tracks support via dedicated supportsBalance/supportsTransactions/supportsStandingOrders booleans instead.
  2. dialog.ts:18 (3c89d4c) — Duplicate ./types imports merged into one.
  3. dialog.ts:364-368 (3c89d4c) — capabilities getter now reads from the boolean fields (all default false), so it returns correct values both before and after sync().
  4. client.ts:70-74 (318cfba) — IMPLEMENTATION_SUMMARY.md was a pre-existing file accidentally deleted in the feature commit; it has been restored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants