@davidvornholt/lib-fints 0.0.0-stage → 1.5.401
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/FORK.md +40 -0
- package/LICENSE +504 -0
- package/README.md +423 -2
- package/biome.json +35 -0
- package/dist/accountBalance.js +1 -0
- package/dist/accountDescriptor.js +65 -0
- package/dist/bankAccount.js +42 -0
- package/dist/bankAnswer.js +1 -0
- package/dist/bankTransaction.js +1 -0
- package/dist/bankingInformation.js +1 -0
- package/dist/bpd.js +1 -0
- package/dist/camtParser.js +443 -0
- package/dist/client.js +740 -0
- package/dist/codes.js +87 -0
- package/dist/config.js +241 -0
- package/dist/creditCardStatement.js +1 -0
- package/dist/dataElements/AlphaNumeric.js +24 -0
- package/dist/dataElements/Amount.js +6 -0
- package/dist/dataElements/Binary.js +37 -0
- package/dist/dataElements/Country.js +6 -0
- package/dist/dataElements/Currency.js +6 -0
- package/dist/dataElements/Dat.js +18 -0
- package/dist/dataElements/DataElement.js +38 -0
- package/dist/dataElements/Digits.js +23 -0
- package/dist/dataElements/Float.js +21 -0
- package/dist/dataElements/Identification.js +6 -0
- package/dist/dataElements/Numeric.js +26 -0
- package/dist/dataElements/Text.js +21 -0
- package/dist/dataElements/Time.js +18 -0
- package/dist/dataElements/YesNo.js +18 -0
- package/dist/dataGroups/Account.js +12 -0
- package/dist/dataGroups/Balance.js +15 -0
- package/dist/dataGroups/BankIdentification.js +8 -0
- package/dist/dataGroups/DataGroup.js +61 -0
- package/dist/dataGroups/InternationalAccount.js +15 -0
- package/dist/dataGroups/Money.js +8 -0
- package/dist/dataGroups/RefMessage.js +8 -0
- package/dist/dataGroups/SepaAccount.js +17 -0
- package/dist/dataGroups/TimeStamp.js +8 -0
- package/dist/decoder.js +100 -0
- package/dist/dialog.js +469 -0
- package/dist/electronicStatement.js +1 -0
- package/dist/encoder.js +59 -0
- package/dist/format.js +6 -0
- package/dist/httpClient.js +84 -0
- package/dist/index.js +22 -0
- package/dist/interactions/balanceInteraction.js +46 -0
- package/dist/interactions/creditTransferInteraction.js +499 -0
- package/dist/interactions/creditcardStatementInteraction.js +115 -0
- package/dist/interactions/creditcardStatementInteractionHKKKU.js +141 -0
- package/dist/interactions/customerInteraction.js +121 -0
- package/dist/interactions/electronicStatementInteraction.js +89 -0
- package/dist/interactions/endDialogInteraction.js +17 -0
- package/dist/interactions/initDialogInteraction.js +232 -0
- package/dist/interactions/portfolioInteraction.js +65 -0
- package/dist/interactions/sepaAccountInteraction.js +51 -0
- package/dist/interactions/statementInteractionCAMT.js +71 -0
- package/dist/interactions/statementInteractionMT940.js +50 -0
- package/dist/interactions/tanMediaInteraction.js +37 -0
- package/dist/interactions/transferOutcome.js +364 -0
- package/dist/interactions/vopCheck.js +346 -0
- package/dist/message.js +239 -0
- package/dist/mt535parser.js +151 -0
- package/dist/mt940parser.js +313 -0
- package/dist/pain001Builder.js +308 -0
- package/dist/pain002Parser.js +140 -0
- package/dist/parser.js +28 -0
- package/dist/partedSegment.js +11 -0
- package/dist/segment.js +81 -0
- package/dist/segmentDefinition.js +20 -0
- package/dist/segmentHeader.js +13 -0
- package/dist/segments/DIKKU.js +23 -0
- package/dist/segments/DKKKU.js +25 -0
- package/dist/segments/HIBPA.js +26 -0
- package/dist/segments/HICAZ.js +22 -0
- package/dist/segments/HICAZS.js +19 -0
- package/dist/segments/HICCSS.js +23 -0
- package/dist/segments/HIEKA.js +45 -0
- package/dist/segments/HIEKAS.js +18 -0
- package/dist/segments/HIKAZ.js +16 -0
- package/dist/segments/HIKAZS.js +17 -0
- package/dist/segments/HIKIM.js +14 -0
- package/dist/segments/HIKKU.js +23 -0
- package/dist/segments/HIKKUS.js +18 -0
- package/dist/segments/HIKOM.js +26 -0
- package/dist/segments/HIPINS.js +22 -0
- package/dist/segments/HIRMG.js +23 -0
- package/dist/segments/HIRMS.js +23 -0
- package/dist/segments/HISAL.js +34 -0
- package/dist/segments/HISPA.js +14 -0
- package/dist/segments/HISPAS.js +22 -0
- package/dist/segments/HISYN.js +19 -0
- package/dist/segments/HITAB.js +40 -0
- package/dist/segments/HITAN.js +25 -0
- package/dist/segments/HITANS.js +53 -0
- package/dist/segments/HIUPA.js +21 -0
- package/dist/segments/HIUPD.js +41 -0
- package/dist/segments/HIVPAS.js +21 -0
- package/dist/segments/HIVPP.js +35 -0
- package/dist/segments/HIVPPS.js +23 -0
- package/dist/segments/HIWPD.js +15 -0
- package/dist/segments/HKCAZ.js +28 -0
- package/dist/segments/HKCCS.js +30 -0
- package/dist/segments/HKEKA.js +43 -0
- package/dist/segments/HKEND.js +14 -0
- package/dist/segments/HKIDN.js +21 -0
- package/dist/segments/HKKAZ.js +27 -0
- package/dist/segments/HKKKU.js +26 -0
- package/dist/segments/HKSAL.js +24 -0
- package/dist/segments/HKSPA.js +21 -0
- package/dist/segments/HKSYN.js +14 -0
- package/dist/segments/HKTAB.js +15 -0
- package/dist/segments/HKTAN.js +38 -0
- package/dist/segments/HKVPA.js +19 -0
- package/dist/segments/HKVPP.js +33 -0
- package/dist/segments/HKVVB.js +21 -0
- package/dist/segments/HKWPD.js +23 -0
- package/dist/segments/HNHBK.js +23 -0
- package/dist/segments/HNHBS.js +14 -0
- package/dist/segments/HNSHA.js +20 -0
- package/dist/segments/HNSHK.js +54 -0
- package/dist/segments/HNVSD.js +14 -0
- package/dist/segments/HNVSK.js +52 -0
- package/dist/segments/businessTransactionParameter.js +20 -0
- package/dist/segments/registry.js +120 -0
- package/dist/statement.js +1 -0
- package/dist/tanMethod.js +1 -0
- package/dist/tests/HIBPA.test.js +26 -0
- package/dist/tests/HICAZS.test.js +18 -0
- package/dist/tests/HICCSS.test.js +16 -0
- package/dist/tests/HIPINS.test.js +14 -0
- package/dist/tests/HIRMG.test.js +24 -0
- package/dist/tests/HITAB.test.js +26 -0
- package/dist/tests/HITANS.test.js +19 -0
- package/dist/tests/HIUPA.test.js +11 -0
- package/dist/tests/HIUPD.test.js +11 -0
- package/dist/tests/HIVPAS.test.js +16 -0
- package/dist/tests/HIVPP.test.js +58 -0
- package/dist/tests/HIVPPS.test.js +29 -0
- package/dist/tests/HIWPD.test.js +25 -0
- package/dist/tests/HKCAZ.test.js +43 -0
- package/dist/tests/HKCCS.test.js +52 -0
- package/dist/tests/HKEKA.test.js +198 -0
- package/dist/tests/HKIDN.test.js +22 -0
- package/dist/tests/HKKKU.test.js +207 -0
- package/dist/tests/HKSAL.test.js +45 -0
- package/dist/tests/HKTAN.test.js +22 -0
- package/dist/tests/HKVPA.test.js +21 -0
- package/dist/tests/HKVPP.test.js +40 -0
- package/dist/tests/HKWPD.test.js +38 -0
- package/dist/tests/HNSHK.test.js +11 -0
- package/dist/tests/HNVSK.test.js +11 -0
- package/dist/tests/accountDescriptor.test.js +99 -0
- package/dist/tests/accountReference.test.js +126 -0
- package/dist/tests/bankReplyChecks.test.js +37 -0
- package/dist/tests/camtParser.test.js +988 -0
- package/dist/tests/client.test.js +690 -0
- package/dist/tests/credentialRedaction.test.js +59 -0
- package/dist/tests/creditTransfer.test.js +1475 -0
- package/dist/tests/creditTransferBank.js +205 -0
- package/dist/tests/creditTransferSafety.test.js +319 -0
- package/dist/tests/datatypes.test.js +8 -0
- package/dist/tests/dialog.test.js +435 -0
- package/dist/tests/httpClientErrorLog.test.js +27 -0
- package/dist/tests/interactionAccountDescriptor.test.js +153 -0
- package/dist/tests/message.test.js +98 -0
- package/dist/tests/mt535parser.test.js +245 -0
- package/dist/tests/mt940parser.test.js +82 -0
- package/dist/tests/pain001Builder.test.js +291 -0
- package/dist/tests/pain002Parser.test.js +152 -0
- package/dist/tests/parser.test.js +25 -0
- package/dist/tests/partedDialog.test.js +203 -0
- package/dist/tests/partedResponse.test.js +181 -0
- package/dist/tests/statementParseFailure.test.js +18 -0
- package/dist/tests/tanMedia.test.js +125 -0
- package/dist/types/accountBalance.d.ts +9 -0
- package/dist/types/accountBalance.d.ts.map +1 -0
- package/dist/types/accountDescriptor.d.ts +49 -0
- package/dist/types/accountDescriptor.d.ts.map +1 -0
- package/dist/types/bankAccount.d.ts +39 -0
- package/dist/types/bankAccount.d.ts.map +1 -0
- package/dist/types/bankAnswer.d.ts +6 -0
- package/dist/types/bankAnswer.d.ts.map +1 -0
- package/dist/types/bankTransaction.d.ts +22 -0
- package/dist/types/bankTransaction.d.ts.map +1 -0
- package/dist/types/bankingInformation.d.ts +20 -0
- package/dist/types/bankingInformation.d.ts.map +1 -0
- package/dist/types/bpd.d.ts +17 -0
- package/dist/types/bpd.d.ts.map +1 -0
- package/dist/types/camtParser.d.ts +31 -0
- package/dist/types/camtParser.d.ts.map +1 -0
- package/dist/types/client.d.ts +302 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/codes.d.ts +75 -0
- package/dist/types/codes.d.ts.map +1 -0
- package/dist/types/config.d.ts +127 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/creditCardStatement.d.ts +16 -0
- package/dist/types/creditCardStatement.d.ts.map +1 -0
- package/dist/types/dataElements/AlphaNumeric.d.ts +8 -0
- package/dist/types/dataElements/AlphaNumeric.d.ts.map +1 -0
- package/dist/types/dataElements/Amount.d.ts +5 -0
- package/dist/types/dataElements/Amount.d.ts.map +1 -0
- package/dist/types/dataElements/Binary.d.ts +15 -0
- package/dist/types/dataElements/Binary.d.ts.map +1 -0
- package/dist/types/dataElements/Country.d.ts +5 -0
- package/dist/types/dataElements/Country.d.ts.map +1 -0
- package/dist/types/dataElements/Currency.d.ts +5 -0
- package/dist/types/dataElements/Currency.d.ts.map +1 -0
- package/dist/types/dataElements/Dat.d.ts +8 -0
- package/dist/types/dataElements/Dat.d.ts.map +1 -0
- package/dist/types/dataElements/DataElement.d.ts +14 -0
- package/dist/types/dataElements/DataElement.d.ts.map +1 -0
- package/dist/types/dataElements/Digits.d.ts +8 -0
- package/dist/types/dataElements/Digits.d.ts.map +1 -0
- package/dist/types/dataElements/Float.d.ts +8 -0
- package/dist/types/dataElements/Float.d.ts.map +1 -0
- package/dist/types/dataElements/Identification.d.ts +5 -0
- package/dist/types/dataElements/Identification.d.ts.map +1 -0
- package/dist/types/dataElements/Numeric.d.ts +9 -0
- package/dist/types/dataElements/Numeric.d.ts.map +1 -0
- package/dist/types/dataElements/Text.d.ts +8 -0
- package/dist/types/dataElements/Text.d.ts.map +1 -0
- package/dist/types/dataElements/Time.d.ts +8 -0
- package/dist/types/dataElements/Time.d.ts.map +1 -0
- package/dist/types/dataElements/YesNo.d.ts +7 -0
- package/dist/types/dataElements/YesNo.d.ts.map +1 -0
- package/dist/types/dataGroups/Account.d.ts +14 -0
- package/dist/types/dataGroups/Account.d.ts.map +1 -0
- package/dist/types/dataGroups/Balance.d.ts +12 -0
- package/dist/types/dataGroups/Balance.d.ts.map +1 -0
- package/dist/types/dataGroups/BankIdentification.d.ts +5 -0
- package/dist/types/dataGroups/BankIdentification.d.ts.map +1 -0
- package/dist/types/dataGroups/DataGroup.d.ts +10 -0
- package/dist/types/dataGroups/DataGroup.d.ts.map +1 -0
- package/dist/types/dataGroups/InternationalAccount.d.ts +13 -0
- package/dist/types/dataGroups/InternationalAccount.d.ts.map +1 -0
- package/dist/types/dataGroups/Money.d.ts +9 -0
- package/dist/types/dataGroups/Money.d.ts.map +1 -0
- package/dist/types/dataGroups/RefMessage.d.ts +9 -0
- package/dist/types/dataGroups/RefMessage.d.ts.map +1 -0
- package/dist/types/dataGroups/SepaAccount.d.ts +11 -0
- package/dist/types/dataGroups/SepaAccount.d.ts.map +1 -0
- package/dist/types/dataGroups/TimeStamp.d.ts +9 -0
- package/dist/types/dataGroups/TimeStamp.d.ts.map +1 -0
- package/dist/types/decoder.d.ts +4 -0
- package/dist/types/decoder.d.ts.map +1 -0
- package/dist/types/dialog.d.ts +106 -0
- package/dist/types/dialog.d.ts.map +1 -0
- package/dist/types/electronicStatement.d.ts +40 -0
- package/dist/types/electronicStatement.d.ts.map +1 -0
- package/dist/types/encoder.d.ts +3 -0
- package/dist/types/encoder.d.ts.map +1 -0
- package/dist/types/format.d.ts +3 -0
- package/dist/types/format.d.ts.map +1 -0
- package/dist/types/httpClient.d.ts +14 -0
- package/dist/types/httpClient.d.ts.map +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interactions/balanceInteraction.d.ts +16 -0
- package/dist/types/interactions/balanceInteraction.d.ts.map +1 -0
- package/dist/types/interactions/creditTransferInteraction.d.ts +228 -0
- package/dist/types/interactions/creditTransferInteraction.d.ts.map +1 -0
- package/dist/types/interactions/creditcardStatementInteraction.d.ts +19 -0
- package/dist/types/interactions/creditcardStatementInteraction.d.ts.map +1 -0
- package/dist/types/interactions/creditcardStatementInteractionHKKKU.d.ts +23 -0
- package/dist/types/interactions/creditcardStatementInteractionHKKKU.d.ts.map +1 -0
- package/dist/types/interactions/customerInteraction.d.ts +84 -0
- package/dist/types/interactions/customerInteraction.d.ts.map +1 -0
- package/dist/types/interactions/electronicStatementInteraction.d.ts +34 -0
- package/dist/types/interactions/electronicStatementInteraction.d.ts.map +1 -0
- package/dist/types/interactions/endDialogInteraction.d.ts +13 -0
- package/dist/types/interactions/endDialogInteraction.d.ts.map +1 -0
- package/dist/types/interactions/initDialogInteraction.d.ts +23 -0
- package/dist/types/interactions/initDialogInteraction.d.ts.map +1 -0
- package/dist/types/interactions/portfolioInteraction.d.ts +40 -0
- package/dist/types/interactions/portfolioInteraction.d.ts.map +1 -0
- package/dist/types/interactions/sepaAccountInteraction.d.ts +18 -0
- package/dist/types/interactions/sepaAccountInteraction.d.ts.map +1 -0
- package/dist/types/interactions/statementInteractionCAMT.d.ts +14 -0
- package/dist/types/interactions/statementInteractionCAMT.d.ts.map +1 -0
- package/dist/types/interactions/statementInteractionMT940.d.ts +14 -0
- package/dist/types/interactions/statementInteractionMT940.d.ts.map +1 -0
- package/dist/types/interactions/tanMediaInteraction.d.ts +13 -0
- package/dist/types/interactions/tanMediaInteraction.d.ts.map +1 -0
- package/dist/types/interactions/transferOutcome.d.ts +129 -0
- package/dist/types/interactions/transferOutcome.d.ts.map +1 -0
- package/dist/types/interactions/vopCheck.d.ts +107 -0
- package/dist/types/interactions/vopCheck.d.ts.map +1 -0
- package/dist/types/message.d.ts +30 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/mt535parser.d.ts +23 -0
- package/dist/types/mt535parser.d.ts.map +1 -0
- package/dist/types/mt940parser.d.ts +46 -0
- package/dist/types/mt940parser.d.ts.map +1 -0
- package/dist/types/pain001Builder.d.ts +96 -0
- package/dist/types/pain001Builder.d.ts.map +1 -0
- package/dist/types/pain002Parser.d.ts +77 -0
- package/dist/types/pain002Parser.d.ts.map +1 -0
- package/dist/types/parser.d.ts +2 -0
- package/dist/types/parser.d.ts.map +1 -0
- package/dist/types/partedSegment.d.ts +15 -0
- package/dist/types/partedSegment.d.ts.map +1 -0
- package/dist/types/segment.d.ts +11 -0
- package/dist/types/segment.d.ts.map +1 -0
- package/dist/types/segmentDefinition.d.ts +13 -0
- package/dist/types/segmentDefinition.d.ts.map +1 -0
- package/dist/types/segmentHeader.d.ts +11 -0
- package/dist/types/segmentHeader.d.ts.map +1 -0
- package/dist/types/segments/DIKKU.d.ts +20 -0
- package/dist/types/segments/DIKKU.d.ts.map +1 -0
- package/dist/types/segments/DKKKU.d.ts +24 -0
- package/dist/types/segments/DKKKU.d.ts.map +1 -0
- package/dist/types/segments/HIBPA.d.ts +28 -0
- package/dist/types/segments/HIBPA.d.ts.map +1 -0
- package/dist/types/segments/HICAZ.d.ts +22 -0
- package/dist/types/segments/HICAZ.d.ts.map +1 -0
- package/dist/types/segments/HICAZS.d.ts +17 -0
- package/dist/types/segments/HICAZS.d.ts.map +1 -0
- package/dist/types/segments/HICCSS.d.ts +23 -0
- package/dist/types/segments/HICCSS.d.ts.map +1 -0
- package/dist/types/segments/HIEKA.d.ts +52 -0
- package/dist/types/segments/HIEKA.d.ts.map +1 -0
- package/dist/types/segments/HIEKAS.d.ts +21 -0
- package/dist/types/segments/HIEKAS.d.ts.map +1 -0
- package/dist/types/segments/HIKAZ.d.ts +17 -0
- package/dist/types/segments/HIKAZ.d.ts.map +1 -0
- package/dist/types/segments/HIKAZS.d.ts +16 -0
- package/dist/types/segments/HIKAZS.d.ts.map +1 -0
- package/dist/types/segments/HIKIM.d.ts +18 -0
- package/dist/types/segments/HIKIM.d.ts.map +1 -0
- package/dist/types/segments/HIKKU.d.ts +25 -0
- package/dist/types/segments/HIKKU.d.ts.map +1 -0
- package/dist/types/segments/HIKKUS.d.ts +21 -0
- package/dist/types/segments/HIKKUS.d.ts.map +1 -0
- package/dist/types/segments/HIKOM.d.ts +28 -0
- package/dist/types/segments/HIKOM.d.ts.map +1 -0
- package/dist/types/segments/HIPINS.d.ts +23 -0
- package/dist/types/segments/HIPINS.d.ts.map +1 -0
- package/dist/types/segments/HIRMG.d.ts +23 -0
- package/dist/types/segments/HIRMG.d.ts.map +1 -0
- package/dist/types/segments/HIRMS.d.ts +18 -0
- package/dist/types/segments/HIRMS.d.ts.map +1 -0
- package/dist/types/segments/HISAL.d.ts +33 -0
- package/dist/types/segments/HISAL.d.ts.map +1 -0
- package/dist/types/segments/HISPA.d.ts +17 -0
- package/dist/types/segments/HISPA.d.ts.map +1 -0
- package/dist/types/segments/HISPAS.d.ts +20 -0
- package/dist/types/segments/HISPAS.d.ts.map +1 -0
- package/dist/types/segments/HISYN.d.ts +20 -0
- package/dist/types/segments/HISYN.d.ts.map +1 -0
- package/dist/types/segments/HITAB.d.ts +40 -0
- package/dist/types/segments/HITAB.d.ts.map +1 -0
- package/dist/types/segments/HITAN.d.ts +26 -0
- package/dist/types/segments/HITAN.d.ts.map +1 -0
- package/dist/types/segments/HITANS.d.ts +46 -0
- package/dist/types/segments/HITANS.d.ts.map +1 -0
- package/dist/types/segments/HIUPA.d.ts +22 -0
- package/dist/types/segments/HIUPA.d.ts.map +1 -0
- package/dist/types/segments/HIUPD.d.ts +43 -0
- package/dist/types/segments/HIUPD.d.ts.map +1 -0
- package/dist/types/segments/HIVPAS.d.ts +21 -0
- package/dist/types/segments/HIVPAS.d.ts.map +1 -0
- package/dist/types/segments/HIVPP.d.ts +49 -0
- package/dist/types/segments/HIVPP.d.ts.map +1 -0
- package/dist/types/segments/HIVPPS.d.ts +27 -0
- package/dist/types/segments/HIVPPS.d.ts.map +1 -0
- package/dist/types/segments/HIWPD.d.ts +22 -0
- package/dist/types/segments/HIWPD.d.ts.map +1 -0
- package/dist/types/segments/HKCAZ.d.ts +27 -0
- package/dist/types/segments/HKCAZ.d.ts.map +1 -0
- package/dist/types/segments/HKCCS.d.ts +32 -0
- package/dist/types/segments/HKCCS.d.ts.map +1 -0
- package/dist/types/segments/HKEKA.d.ts +54 -0
- package/dist/types/segments/HKEKA.d.ts.map +1 -0
- package/dist/types/segments/HKEND.d.ts +17 -0
- package/dist/types/segments/HKEND.d.ts.map +1 -0
- package/dist/types/segments/HKIDN.d.ts +23 -0
- package/dist/types/segments/HKIDN.d.ts.map +1 -0
- package/dist/types/segments/HKKAZ.d.ts +26 -0
- package/dist/types/segments/HKKAZ.d.ts.map +1 -0
- package/dist/types/segments/HKKKU.d.ts +26 -0
- package/dist/types/segments/HKKKU.d.ts.map +1 -0
- package/dist/types/segments/HKSAL.d.ts +23 -0
- package/dist/types/segments/HKSAL.d.ts.map +1 -0
- package/dist/types/segments/HKSPA.d.ts +21 -0
- package/dist/types/segments/HKSPA.d.ts.map +1 -0
- package/dist/types/segments/HKSYN.d.ts +18 -0
- package/dist/types/segments/HKSYN.d.ts.map +1 -0
- package/dist/types/segments/HKTAB.d.ts +20 -0
- package/dist/types/segments/HKTAB.d.ts.map +1 -0
- package/dist/types/segments/HKTAN.d.ts +41 -0
- package/dist/types/segments/HKTAN.d.ts.map +1 -0
- package/dist/types/segments/HKVPA.d.ts +22 -0
- package/dist/types/segments/HKVPA.d.ts.map +1 -0
- package/dist/types/segments/HKVPP.d.ts +37 -0
- package/dist/types/segments/HKVPP.d.ts.map +1 -0
- package/dist/types/segments/HKVVB.d.ts +23 -0
- package/dist/types/segments/HKVVB.d.ts.map +1 -0
- package/dist/types/segments/HKWPD.d.ts +43 -0
- package/dist/types/segments/HKWPD.d.ts.map +1 -0
- package/dist/types/segments/HNHBK.d.ts +24 -0
- package/dist/types/segments/HNHBK.d.ts.map +1 -0
- package/dist/types/segments/HNHBS.d.ts +17 -0
- package/dist/types/segments/HNHBS.d.ts.map +1 -0
- package/dist/types/segments/HNSHA.d.ts +25 -0
- package/dist/types/segments/HNSHA.d.ts.map +1 -0
- package/dist/types/segments/HNSHK.d.ts +67 -0
- package/dist/types/segments/HNSHK.d.ts.map +1 -0
- package/dist/types/segments/HNVSD.d.ts +21 -0
- package/dist/types/segments/HNVSD.d.ts.map +1 -0
- package/dist/types/segments/HNVSK.d.ts +41 -0
- package/dist/types/segments/HNVSK.d.ts.map +1 -0
- package/dist/types/segments/businessTransactionParameter.d.ts +18 -0
- package/dist/types/segments/businessTransactionParameter.d.ts.map +1 -0
- package/dist/types/segments/registry.d.ts +4 -0
- package/dist/types/segments/registry.d.ts.map +1 -0
- package/dist/types/statement.d.ts +39 -0
- package/dist/types/statement.d.ts.map +1 -0
- package/dist/types/tanMethod.d.ts +31 -0
- package/dist/types/tanMethod.d.ts.map +1 -0
- package/dist/types/tests/HIBPA.test.d.ts +2 -0
- package/dist/types/tests/HIBPA.test.d.ts.map +1 -0
- package/dist/types/tests/HICAZS.test.d.ts +2 -0
- package/dist/types/tests/HICAZS.test.d.ts.map +1 -0
- package/dist/types/tests/HICCSS.test.d.ts +2 -0
- package/dist/types/tests/HICCSS.test.d.ts.map +1 -0
- package/dist/types/tests/HIPINS.test.d.ts +2 -0
- package/dist/types/tests/HIPINS.test.d.ts.map +1 -0
- package/dist/types/tests/HIRMG.test.d.ts +2 -0
- package/dist/types/tests/HIRMG.test.d.ts.map +1 -0
- package/dist/types/tests/HITAB.test.d.ts +2 -0
- package/dist/types/tests/HITAB.test.d.ts.map +1 -0
- package/dist/types/tests/HITANS.test.d.ts +2 -0
- package/dist/types/tests/HITANS.test.d.ts.map +1 -0
- package/dist/types/tests/HIUPA.test.d.ts +2 -0
- package/dist/types/tests/HIUPA.test.d.ts.map +1 -0
- package/dist/types/tests/HIUPD.test.d.ts +2 -0
- package/dist/types/tests/HIUPD.test.d.ts.map +1 -0
- package/dist/types/tests/HIVPAS.test.d.ts +2 -0
- package/dist/types/tests/HIVPAS.test.d.ts.map +1 -0
- package/dist/types/tests/HIVPP.test.d.ts +2 -0
- package/dist/types/tests/HIVPP.test.d.ts.map +1 -0
- package/dist/types/tests/HIVPPS.test.d.ts +2 -0
- package/dist/types/tests/HIVPPS.test.d.ts.map +1 -0
- package/dist/types/tests/HIWPD.test.d.ts +2 -0
- package/dist/types/tests/HIWPD.test.d.ts.map +1 -0
- package/dist/types/tests/HKCAZ.test.d.ts +2 -0
- package/dist/types/tests/HKCAZ.test.d.ts.map +1 -0
- package/dist/types/tests/HKCCS.test.d.ts +2 -0
- package/dist/types/tests/HKCCS.test.d.ts.map +1 -0
- package/dist/types/tests/HKEKA.test.d.ts +2 -0
- package/dist/types/tests/HKEKA.test.d.ts.map +1 -0
- package/dist/types/tests/HKIDN.test.d.ts +2 -0
- package/dist/types/tests/HKIDN.test.d.ts.map +1 -0
- package/dist/types/tests/HKKKU.test.d.ts +2 -0
- package/dist/types/tests/HKKKU.test.d.ts.map +1 -0
- package/dist/types/tests/HKSAL.test.d.ts +2 -0
- package/dist/types/tests/HKSAL.test.d.ts.map +1 -0
- package/dist/types/tests/HKTAN.test.d.ts +2 -0
- package/dist/types/tests/HKTAN.test.d.ts.map +1 -0
- package/dist/types/tests/HKVPA.test.d.ts +2 -0
- package/dist/types/tests/HKVPA.test.d.ts.map +1 -0
- package/dist/types/tests/HKVPP.test.d.ts +2 -0
- package/dist/types/tests/HKVPP.test.d.ts.map +1 -0
- package/dist/types/tests/HKWPD.test.d.ts +2 -0
- package/dist/types/tests/HKWPD.test.d.ts.map +1 -0
- package/dist/types/tests/HNSHK.test.d.ts +2 -0
- package/dist/types/tests/HNSHK.test.d.ts.map +1 -0
- package/dist/types/tests/HNVSK.test.d.ts +2 -0
- package/dist/types/tests/HNVSK.test.d.ts.map +1 -0
- package/dist/types/tests/accountDescriptor.test.d.ts +2 -0
- package/dist/types/tests/accountDescriptor.test.d.ts.map +1 -0
- package/dist/types/tests/accountReference.test.d.ts +2 -0
- package/dist/types/tests/accountReference.test.d.ts.map +1 -0
- package/dist/types/tests/bankReplyChecks.test.d.ts +2 -0
- package/dist/types/tests/bankReplyChecks.test.d.ts.map +1 -0
- package/dist/types/tests/camtParser.test.d.ts +2 -0
- package/dist/types/tests/camtParser.test.d.ts.map +1 -0
- package/dist/types/tests/client.test.d.ts +2 -0
- package/dist/types/tests/client.test.d.ts.map +1 -0
- package/dist/types/tests/credentialRedaction.test.d.ts +2 -0
- package/dist/types/tests/credentialRedaction.test.d.ts.map +1 -0
- package/dist/types/tests/creditTransfer.test.d.ts +2 -0
- package/dist/types/tests/creditTransfer.test.d.ts.map +1 -0
- package/dist/types/tests/creditTransferBank.d.ts +63 -0
- package/dist/types/tests/creditTransferBank.d.ts.map +1 -0
- package/dist/types/tests/creditTransferSafety.test.d.ts +2 -0
- package/dist/types/tests/creditTransferSafety.test.d.ts.map +1 -0
- package/dist/types/tests/datatypes.test.d.ts +2 -0
- package/dist/types/tests/datatypes.test.d.ts.map +1 -0
- package/dist/types/tests/dialog.test.d.ts +2 -0
- package/dist/types/tests/dialog.test.d.ts.map +1 -0
- package/dist/types/tests/httpClientErrorLog.test.d.ts +2 -0
- package/dist/types/tests/httpClientErrorLog.test.d.ts.map +1 -0
- package/dist/types/tests/interactionAccountDescriptor.test.d.ts +2 -0
- package/dist/types/tests/interactionAccountDescriptor.test.d.ts.map +1 -0
- package/dist/types/tests/message.test.d.ts +2 -0
- package/dist/types/tests/message.test.d.ts.map +1 -0
- package/dist/types/tests/mt535parser.test.d.ts +2 -0
- package/dist/types/tests/mt535parser.test.d.ts.map +1 -0
- package/dist/types/tests/mt940parser.test.d.ts +2 -0
- package/dist/types/tests/mt940parser.test.d.ts.map +1 -0
- package/dist/types/tests/pain001Builder.test.d.ts +2 -0
- package/dist/types/tests/pain001Builder.test.d.ts.map +1 -0
- package/dist/types/tests/pain002Parser.test.d.ts +2 -0
- package/dist/types/tests/pain002Parser.test.d.ts.map +1 -0
- package/dist/types/tests/parser.test.d.ts +2 -0
- package/dist/types/tests/parser.test.d.ts.map +1 -0
- package/dist/types/tests/partedDialog.test.d.ts +2 -0
- package/dist/types/tests/partedDialog.test.d.ts.map +1 -0
- package/dist/types/tests/partedResponse.test.d.ts +2 -0
- package/dist/types/tests/partedResponse.test.d.ts.map +1 -0
- package/dist/types/tests/statementParseFailure.test.d.ts +2 -0
- package/dist/types/tests/statementParseFailure.test.d.ts.map +1 -0
- package/dist/types/tests/tanMedia.test.d.ts +2 -0
- package/dist/types/tests/tanMedia.test.d.ts.map +1 -0
- package/dist/types/unknownSegment.d.ts +15 -0
- package/dist/types/unknownSegment.d.ts.map +1 -0
- package/dist/types/upd.d.ts +8 -0
- package/dist/types/upd.d.ts.map +1 -0
- package/dist/unknownSegment.js +11 -0
- package/dist/upd.js +1 -0
- package/package.json +59 -5
- package/pnpm-workspace.yaml +8 -0
- package/src/accountBalance.ts +8 -0
- package/src/accountDescriptor.ts +78 -0
- package/src/bankAccount.ts +59 -0
- package/src/bankAnswer.ts +5 -0
- package/src/bankTransaction.ts +25 -0
- package/src/bankingInformation.ts +21 -0
- package/src/bpd.ts +17 -0
- package/src/camtParser.ts +698 -0
- package/src/client.ts +1005 -0
- package/src/codes.ts +86 -0
- package/src/config.ts +338 -0
- package/src/creditCardStatement.ts +26 -0
- package/src/dataElements/AlphaNumeric.ts +35 -0
- package/src/dataElements/Amount.ts +7 -0
- package/src/dataElements/Binary.ts +50 -0
- package/src/dataElements/Country.ts +7 -0
- package/src/dataElements/Currency.ts +7 -0
- package/src/dataElements/Dat.ts +22 -0
- package/src/dataElements/DataElement.ts +41 -0
- package/src/dataElements/Digits.ts +34 -0
- package/src/dataElements/Float.ts +31 -0
- package/src/dataElements/Identification.ts +7 -0
- package/src/dataElements/Numeric.ts +38 -0
- package/src/dataElements/Text.ts +31 -0
- package/src/dataElements/Time.ts +24 -0
- package/src/dataElements/YesNo.ts +23 -0
- package/src/dataGroups/Account.ts +31 -0
- package/src/dataGroups/Balance.ts +30 -0
- package/src/dataGroups/BankIdentification.ts +16 -0
- package/src/dataGroups/DataGroup.ts +76 -0
- package/src/dataGroups/InternationalAccount.ts +32 -0
- package/src/dataGroups/Money.ts +21 -0
- package/src/dataGroups/RefMessage.ts +21 -0
- package/src/dataGroups/SepaAccount.ts +32 -0
- package/src/dataGroups/TimeStamp.ts +21 -0
- package/src/decoder.ts +125 -0
- package/src/dialog.ts +625 -0
- package/src/electronicStatement.ts +51 -0
- package/src/encoder.ts +87 -0
- package/src/format.ts +7 -0
- package/src/httpClient.ts +90 -0
- package/src/index.ts +53 -0
- package/src/interactions/balanceInteraction.ts +65 -0
- package/src/interactions/creditTransferInteraction.ts +667 -0
- package/src/interactions/creditcardStatementInteraction.ts +134 -0
- package/src/interactions/creditcardStatementInteractionHKKKU.ts +163 -0
- package/src/interactions/customerInteraction.ts +191 -0
- package/src/interactions/electronicStatementInteraction.ts +132 -0
- package/src/interactions/endDialogInteraction.ts +28 -0
- package/src/interactions/initDialogInteraction.ts +300 -0
- package/src/interactions/portfolioInteraction.ts +97 -0
- package/src/interactions/sepaAccountInteraction.ts +68 -0
- package/src/interactions/statementInteractionCAMT.ts +87 -0
- package/src/interactions/statementInteractionMT940.ts +60 -0
- package/src/interactions/tanMediaInteraction.ts +54 -0
- package/src/interactions/transferOutcome.ts +513 -0
- package/src/interactions/vopCheck.ts +502 -0
- package/src/message.ts +305 -0
- package/src/mt535parser.ts +199 -0
- package/src/mt940parser.ts +395 -0
- package/src/pain001Builder.ts +446 -0
- package/src/pain002Parser.ts +233 -0
- package/src/parser.ts +31 -0
- package/src/partedSegment.ts +19 -0
- package/src/segment.ts +114 -0
- package/src/segmentDefinition.ts +36 -0
- package/src/segmentHeader.ts +26 -0
- package/src/segments/DIKKU.ts +30 -0
- package/src/segments/DKKKU.ts +35 -0
- package/src/segments/HIBPA.ts +42 -0
- package/src/segments/HICAZ.ts +34 -0
- package/src/segments/HICAZS.ts +33 -0
- package/src/segments/HICCSS.ts +31 -0
- package/src/segments/HIEKA.ts +68 -0
- package/src/segments/HIEKAS.ts +36 -0
- package/src/segments/HIKAZ.ts +23 -0
- package/src/segments/HIKAZS.ts +34 -0
- package/src/segments/HIKIM.ts +21 -0
- package/src/segments/HIKKU.ts +35 -0
- package/src/segments/HIKKUS.ts +36 -0
- package/src/segments/HIKOM.ts +49 -0
- package/src/segments/HIPINS.ts +48 -0
- package/src/segments/HIRMG.ts +41 -0
- package/src/segments/HIRMS.ts +35 -0
- package/src/segments/HISAL.ts +51 -0
- package/src/segments/HISPA.ts +20 -0
- package/src/segments/HISPAS.ts +42 -0
- package/src/segments/HISYN.ts +28 -0
- package/src/segments/HITAB.ts +76 -0
- package/src/segments/HITAN.ts +39 -0
- package/src/segments/HITANS.ts +102 -0
- package/src/segments/HIUPA.ts +32 -0
- package/src/segments/HIUPD.ts +82 -0
- package/src/segments/HIVPAS.ts +29 -0
- package/src/segments/HIVPP.ts +75 -0
- package/src/segments/HIVPPS.ts +47 -0
- package/src/segments/HIWPD.ts +25 -0
- package/src/segments/HKCAZ.ts +42 -0
- package/src/segments/HKCCS.ts +43 -0
- package/src/segments/HKEKA.ts +69 -0
- package/src/segments/HKEND.ts +20 -0
- package/src/segments/HKIDN.ts +31 -0
- package/src/segments/HKKAZ.ts +40 -0
- package/src/segments/HKKKU.ts +41 -0
- package/src/segments/HKSAL.ts +35 -0
- package/src/segments/HKSPA.ts +28 -0
- package/src/segments/HKSYN.ts +21 -0
- package/src/segments/HKTAB.ts +23 -0
- package/src/segments/HKTAN.ts +72 -0
- package/src/segments/HKVPA.ts +26 -0
- package/src/segments/HKVPP.ts +46 -0
- package/src/segments/HKVVB.ts +32 -0
- package/src/segments/HKWPD.ts +52 -0
- package/src/segments/HNHBK.ts +33 -0
- package/src/segments/HNHBS.ts +20 -0
- package/src/segments/HNSHA.ts +38 -0
- package/src/segments/HNSHK.ts +145 -0
- package/src/segments/HNVSD.ts +22 -0
- package/src/segments/HNVSK.ts +110 -0
- package/src/segments/businessTransactionParameter.ts +33 -0
- package/src/segments/registry.ts +125 -0
- package/src/statement.ts +40 -0
- package/src/tanMethod.ts +32 -0
- package/src/tests/HIBPA.test.ts +33 -0
- package/src/tests/HICAZS.test.ts +24 -0
- package/src/tests/HICCSS.test.ts +20 -0
- package/src/tests/HIPINS.test.ts +19 -0
- package/src/tests/HIRMG.test.ts +33 -0
- package/src/tests/HITAB.test.ts +33 -0
- package/src/tests/HITANS.test.ts +27 -0
- package/src/tests/HIUPA.test.ts +13 -0
- package/src/tests/HIUPD.test.ts +13 -0
- package/src/tests/HIVPAS.test.ts +20 -0
- package/src/tests/HIVPP.test.ts +75 -0
- package/src/tests/HIVPPS.test.ts +37 -0
- package/src/tests/HIWPD.test.ts +32 -0
- package/src/tests/HKCAZ.test.ts +56 -0
- package/src/tests/HKCCS.test.ts +64 -0
- package/src/tests/HKEKA.test.ts +252 -0
- package/src/tests/HKIDN.test.ts +26 -0
- package/src/tests/HKKKU.test.ts +248 -0
- package/src/tests/HKSAL.test.ts +52 -0
- package/src/tests/HKTAN.test.ts +26 -0
- package/src/tests/HKVPA.test.ts +25 -0
- package/src/tests/HKVPP.test.ts +54 -0
- package/src/tests/HKWPD.test.ts +47 -0
- package/src/tests/HNSHK.test.ts +14 -0
- package/src/tests/HNVSK.test.ts +14 -0
- package/src/tests/accountDescriptor.test.ts +113 -0
- package/src/tests/accountReference.test.ts +150 -0
- package/src/tests/bankReplyChecks.test.ts +75 -0
- package/src/tests/camtParser.test.ts +1068 -0
- package/src/tests/client.test.ts +826 -0
- package/src/tests/credentialRedaction.test.ts +75 -0
- package/src/tests/creditTransfer.test.ts +2433 -0
- package/src/tests/creditTransferBank.ts +245 -0
- package/src/tests/creditTransferSafety.test.ts +573 -0
- package/src/tests/datatypes.test.ts +9 -0
- package/src/tests/dialog.test.ts +579 -0
- package/src/tests/httpClientErrorLog.test.ts +41 -0
- package/src/tests/interactionAccountDescriptor.test.ts +203 -0
- package/src/tests/message.test.ts +130 -0
- package/src/tests/mt535parser.test.ts +280 -0
- package/src/tests/mt940parser.test.ts +91 -0
- package/src/tests/pain001Builder.test.ts +474 -0
- package/src/tests/pain002Parser.test.ts +191 -0
- package/src/tests/parser.test.ts +34 -0
- package/src/tests/partedDialog.test.ts +309 -0
- package/src/tests/partedResponse.test.ts +234 -0
- package/src/tests/statementParseFailure.test.ts +23 -0
- package/src/tests/tanMedia.test.ts +163 -0
- package/src/unknownSegment.ts +19 -0
- package/src/upd.ts +8 -0
- package/tsconfig.json +103 -0
package/dist/client.js
ADDED
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
// Changed from lib-fints 1.5.4 for @davidvornholt/lib-fints, last on 2026-12-05. FORK.md lists the changes.
|
|
2
|
+
import { internationalAccount } from './accountDescriptor.js';
|
|
3
|
+
import { describeAccount } from './bankAccount.js';
|
|
4
|
+
import { UpdUsage } from './codes.js';
|
|
5
|
+
import { FinTSConfig } from './config.js';
|
|
6
|
+
import { canSendTanSegment, Dialog } from './dialog.js';
|
|
7
|
+
import { BalanceInteraction, } from './interactions/balanceInteraction.js';
|
|
8
|
+
import { CreditCardStatementInteraction } from './interactions/creditcardStatementInteraction.js';
|
|
9
|
+
import { CreditCardStatementInteractionHKKKU } from './interactions/creditcardStatementInteractionHKKKU.js';
|
|
10
|
+
import { CreditTransferInteraction, CreditTransferOrder, VopAuthorizationInteraction, VopPollInteraction, } from './interactions/creditTransferInteraction.js';
|
|
11
|
+
import { ElectronicStatementInteraction, } from './interactions/electronicStatementInteraction.js';
|
|
12
|
+
import { PortfolioInteraction, } from './interactions/portfolioInteraction.js';
|
|
13
|
+
import { StatementInteractionCAMT } from './interactions/statementInteractionCAMT.js';
|
|
14
|
+
import { StatementInteractionMT940 } from './interactions/statementInteractionMT940.js';
|
|
15
|
+
import { TanMediaInteraction } from './interactions/tanMediaInteraction.js';
|
|
16
|
+
import { buildPain001, selectPain001Format } from './pain001Builder.js';
|
|
17
|
+
import { DKKKU } from './segments/DKKKU.js';
|
|
18
|
+
import { HKCAZ } from './segments/HKCAZ.js';
|
|
19
|
+
import { HKCCS } from './segments/HKCCS.js';
|
|
20
|
+
import { HKEKA } from './segments/HKEKA.js';
|
|
21
|
+
import { HKIDN } from './segments/HKIDN.js';
|
|
22
|
+
import { HKKAZ } from './segments/HKKAZ.js';
|
|
23
|
+
import { HKKKU } from './segments/HKKKU.js';
|
|
24
|
+
import { HKSAL } from './segments/HKSAL.js';
|
|
25
|
+
import { HKSPA } from './segments/HKSPA.js';
|
|
26
|
+
import { HKTAB } from './segments/HKTAB.js';
|
|
27
|
+
import { HKVPA } from './segments/HKVPA.js';
|
|
28
|
+
import { HKVPP } from './segments/HKVPP.js';
|
|
29
|
+
import { HKWPD } from './segments/HKWPD.js';
|
|
30
|
+
/** How long the bank may take for a Verification of Payee result, counting the waits between polls */
|
|
31
|
+
const VOP_TIMEOUT_SECONDS = 60;
|
|
32
|
+
/** The wait between polls when the bank names none (python-fints uses the same) */
|
|
33
|
+
const VOP_DEFAULT_WAIT_SECONDS = 2;
|
|
34
|
+
/** The format the DK VoP specification names, for a bank whose HIVPPS lists none */
|
|
35
|
+
const VOP_DEFAULT_REPORT_FORMAT = 'urn:iso:std:iso:20022:tech:xsd:pain.002.001.10';
|
|
36
|
+
const STEP_IN_FLIGHT = 'the transfer is still waiting for the answer to its previous step; wait for that response';
|
|
37
|
+
/**
|
|
38
|
+
* A client to communicate with a bank over the FinTS protocol
|
|
39
|
+
*/
|
|
40
|
+
export class FinTSClient {
|
|
41
|
+
config;
|
|
42
|
+
currentDialog;
|
|
43
|
+
currentTransfer;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new FinTS client
|
|
46
|
+
* @param config - the configuration for the client, use the static factory methods FinTSConfig.forFirstTimeUse or FinTSConfig.fromBankingInformation to create a configuration
|
|
47
|
+
*/
|
|
48
|
+
constructor(config) {
|
|
49
|
+
this.config = config;
|
|
50
|
+
if (!config) {
|
|
51
|
+
throw new Error('configuration must be provided when creating a FinTSClient');
|
|
52
|
+
}
|
|
53
|
+
if (!(config instanceof FinTSConfig)) {
|
|
54
|
+
throw new Error('configuration must be an instance of class FinTSConfig');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Selects a TAN method by its ID
|
|
59
|
+
* @param tanMethodId - the ID of the TAN method to select, get the ID from FinTSClient.config.availableTanMethods
|
|
60
|
+
* @returns the selected TAN method
|
|
61
|
+
*/
|
|
62
|
+
selectTanMethod(tanMethodId) {
|
|
63
|
+
return this.config.selectTanMethod(tanMethodId);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Selects a TAN media by its name
|
|
67
|
+
* @param tanMediaName - the name of the TAN media to select corresponding to a name in TanMethod.activeTanMedia
|
|
68
|
+
*/
|
|
69
|
+
selectTanMedia(tanMediaName) {
|
|
70
|
+
this.config.selectTanMedia(tanMediaName);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Fetches the names of the user's active TAN media (HKTAB), such as the device a pushTAN
|
|
74
|
+
* app runs on, so that one can be chosen with selectTanMedia().
|
|
75
|
+
*
|
|
76
|
+
* The dialog's initialisation refers to HKTAB in its HKTAN instead of to HKIDN, as FinTS
|
|
77
|
+
* PIN/TAN chapter B.4.3.1 prescribes for PIN/TAN management orders, and the bank ignores
|
|
78
|
+
* the TAN media name there. This works before the client knows a TAN media name, which a
|
|
79
|
+
* TAN method that requires one would otherwise need for the dialog initialisation.
|
|
80
|
+
* @returns the TAN media response, with the names in tanMediaList
|
|
81
|
+
*/
|
|
82
|
+
async getTanMedia() {
|
|
83
|
+
return (await this.startCustomerOrderInteraction(new TanMediaInteraction(), HKTAB.Id));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Synchronizes information with the bank, updating config.bankingInformation
|
|
87
|
+
* @returns the synchronization response
|
|
88
|
+
*/
|
|
89
|
+
async synchronize() {
|
|
90
|
+
this.currentDialog = new Dialog(this.config, true);
|
|
91
|
+
const responses = await this.currentDialog.start();
|
|
92
|
+
return responses.get(HKIDN.Id);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Continues the synchronization transaction when a TAN is required
|
|
96
|
+
* @param tanReference The TAN reference provided in the first call's response
|
|
97
|
+
* @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
|
|
98
|
+
* @returns the synchronization response
|
|
99
|
+
*/
|
|
100
|
+
async synchronizeWithTan(tanReference, tan) {
|
|
101
|
+
return await this.continueCustomerInteractionWithTan([HKIDN.Id], tanReference, tan);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Checks if the bank supports fetching an account balance in general or for the given account number when provided
|
|
105
|
+
* @param account when the account number is provided, checks if the account supports fetching the balance
|
|
106
|
+
* @returns true if the bank (and account) supports fetching the account balance
|
|
107
|
+
*/
|
|
108
|
+
canGetAccountBalance(account) {
|
|
109
|
+
return account
|
|
110
|
+
? this.config.isAccountTransactionSupported(account, HKSAL.Id)
|
|
111
|
+
: this.config.isTransactionSupported(HKSAL.Id);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Fetches the account balance for the given account number
|
|
115
|
+
* @param account - the account number to fetch the balance for, must be an account available in the config.baningInformation.UPD.accounts
|
|
116
|
+
* @returns the account balance response
|
|
117
|
+
*/
|
|
118
|
+
async getAccountBalance(account) {
|
|
119
|
+
const response = await this.startCustomerOrderInteraction(new BalanceInteraction(account));
|
|
120
|
+
return response;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Continues the account balance fetching when a TAN is required
|
|
124
|
+
* @param tanReference The TAN reference provided in the first call's response
|
|
125
|
+
* @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
|
|
126
|
+
* @returns the account balance response
|
|
127
|
+
*/
|
|
128
|
+
async getAccountBalanceWithTan(tanReference, tan) {
|
|
129
|
+
return (await this.continueCustomerInteractionWithTan([HKSAL.Id], tanReference, tan));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Checks if the bank supports fetching account statements in general or for the given account number when provided
|
|
133
|
+
* @param account when the account number is provided, checks if the account supports fetching of statements
|
|
134
|
+
* @returns true if the bank (and account) supports fetching account statements
|
|
135
|
+
*/
|
|
136
|
+
canGetAccountStatements(account) {
|
|
137
|
+
if (account) {
|
|
138
|
+
// Check if either CAMT or MT940 is supported for this account
|
|
139
|
+
return (this.config.isAccountTransactionSupported(account, HKCAZ.Id) ||
|
|
140
|
+
this.config.isAccountTransactionSupported(account, HKKAZ.Id));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// Check if either CAMT or MT940 is supported by the bank
|
|
144
|
+
return (this.config.isTransactionSupported(HKCAZ.Id) || this.config.isTransactionSupported(HKKAZ.Id));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Fetches the account statements for the given account number
|
|
149
|
+
* @param account - the account number to fetch the statements for, must be an account available in the config.baningInformation.UPD.accounts
|
|
150
|
+
* @param from - an optional start date of the period to fetch the statements for
|
|
151
|
+
* @param to - an optional end date of the period to fetch the statements for
|
|
152
|
+
* @param preferCamt - whether to prefer CAMT format over MT940 when both are supported (default: true)
|
|
153
|
+
* @returns an account statements response containing an array of statements
|
|
154
|
+
*/
|
|
155
|
+
async getAccountStatements(account, from, to, preferCamt = true) {
|
|
156
|
+
// Check what formats the bank supports
|
|
157
|
+
const camtSupported = this.config.isAccountTransactionSupported(account, 'HKCAZ');
|
|
158
|
+
const mt940Supported = this.config.isAccountTransactionSupported(account, 'HKKAZ');
|
|
159
|
+
if (!camtSupported && !mt940Supported) {
|
|
160
|
+
throw Error(`Account ${describeAccount(account)} does not support account statements`);
|
|
161
|
+
}
|
|
162
|
+
// Choose format based on support and preference
|
|
163
|
+
const useCAMT = (preferCamt && camtSupported) || (!mt940Supported && camtSupported);
|
|
164
|
+
if (useCAMT) {
|
|
165
|
+
return (await this.startCustomerOrderInteraction(new StatementInteractionCAMT(account, from, to)));
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return (await this.startCustomerOrderInteraction(new StatementInteractionMT940(account, from, to)));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Continues the account statements fetching when a TAN is required
|
|
173
|
+
* @param tanReference The TAN reference provided in the first call's response
|
|
174
|
+
* @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
|
|
175
|
+
* @returns an account statements response containing an array of statements
|
|
176
|
+
*/
|
|
177
|
+
async getAccountStatementsWithTan(tanReference, tan) {
|
|
178
|
+
return (await this.continueCustomerInteractionWithTan([HKCAZ.Id, HKKAZ.Id], tanReference, tan));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Checks if the bank supports fetching portfolio information in general or for the given account number when provided
|
|
182
|
+
* @param account when the account number is provided, checks if the account supports fetching of portfolio information
|
|
183
|
+
* @returns true if the bank (and account) supports fetching portfolio information
|
|
184
|
+
*/
|
|
185
|
+
canGetPortfolio(account) {
|
|
186
|
+
return account
|
|
187
|
+
? this.config.isAccountTransactionSupported(account, HKWPD.Id)
|
|
188
|
+
: this.config.isTransactionSupported(HKWPD.Id);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Fetches the portfolio information for the given depot account number
|
|
192
|
+
* @param account - the depot account number to fetch the portfolio for, must be an account available in the config.bankingInformation.UPD.accounts
|
|
193
|
+
* @param currency - optional currency filter for the portfolio statement
|
|
194
|
+
* @param priceQuality - optional price quality filter ('1' for real-time, '2' for delayed)
|
|
195
|
+
* @param maxEntries - optional maximum number of entries to retrieve
|
|
196
|
+
* @returns a portfolio response containing holdings and total value
|
|
197
|
+
*/
|
|
198
|
+
async getPortfolio(account, currency, priceQuality, maxEntries) {
|
|
199
|
+
return (await this.startCustomerOrderInteraction(new PortfolioInteraction(account, currency, priceQuality, maxEntries)));
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Continues the portfolio fetching when a TAN is required
|
|
203
|
+
* @param tanReference The TAN reference provided in the first call's response
|
|
204
|
+
|
|
205
|
+
* @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
|
|
206
|
+
* @returns a portfolio response containing holdings and total value
|
|
207
|
+
*/
|
|
208
|
+
async getPortfolioWithTan(tanReference, tan) {
|
|
209
|
+
return (await this.continueCustomerInteractionWithTan([HKWPD.Id], tanReference, tan));
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Checks if the bank supports fetching credit card statements in general or for the given account number
|
|
213
|
+
* @param account when the account number is provided, checks if the account supports fetching of statements
|
|
214
|
+
* @returns true if the bank (and account) supports fetching credit card statements
|
|
215
|
+
*/
|
|
216
|
+
canGetCreditCardStatements(account) {
|
|
217
|
+
// HKKKU is the standardized successor of DKKKU; some banks (e.g. Postbank) only offer HKKKU
|
|
218
|
+
return account
|
|
219
|
+
? this.config.isAccountTransactionSupported(account, HKKKU.Id) ||
|
|
220
|
+
this.config.isAccountTransactionSupported(account, DKKKU.Id)
|
|
221
|
+
: this.config.isTransactionSupported(HKKKU.Id) ||
|
|
222
|
+
this.config.isTransactionSupported(DKKKU.Id);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Fetches the credit card statements for the given account number
|
|
226
|
+
* @param account - the account number to fetch the statements for, must be a credit card account available
|
|
227
|
+
* in the config.baningInformation.UPD.accounts
|
|
228
|
+
* @param from - an optional start date of the period to fetch the statements for
|
|
229
|
+
* @param to - an optional end date of the period to fetch the statements for
|
|
230
|
+
* @returns an account statements response containing an array of statements
|
|
231
|
+
*/
|
|
232
|
+
async getCreditCardStatements(account, from, to) {
|
|
233
|
+
// Prefer HKKKU where the bank offers it for this account; DKKKU has no end date
|
|
234
|
+
if (this.config.isAccountTransactionSupported(account, HKKKU.Id)) {
|
|
235
|
+
return (await this.startCustomerOrderInteraction(new CreditCardStatementInteractionHKKKU(account, from, to)));
|
|
236
|
+
}
|
|
237
|
+
return (await this.startCustomerOrderInteraction(new CreditCardStatementInteraction(account, from)));
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Continues the credit card statements fetching when a TAN is required
|
|
241
|
+
* @param tanReference The TAN reference provided in the first call's response
|
|
242
|
+
* @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
|
|
243
|
+
* @returns a credit card statements response containing an array of statements
|
|
244
|
+
*/
|
|
245
|
+
async getCreditCardStatementsWithTan(tanReference, tan) {
|
|
246
|
+
return (await this.continueCustomerInteractionWithTan([HKKKU.Id, DKKKU.Id], tanReference, tan));
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Checks if the bank supports fetching electronic account statements in general or for the given account number
|
|
250
|
+
* @param account when the account number is provided, checks if the account supports fetching of electronic statements
|
|
251
|
+
* @returns true if the bank (and account) supports fetching electronic account statements
|
|
252
|
+
*/
|
|
253
|
+
canGetElectronicStatements(account) {
|
|
254
|
+
return account
|
|
255
|
+
? this.config.isAccountTransactionSupported(account, HKEKA.Id)
|
|
256
|
+
: this.config.isTransactionSupported(HKEKA.Id);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Fetches an electronic account statement (Elektronischer Kontoauszug) for the given account number
|
|
260
|
+
*
|
|
261
|
+
* This returns the statement document the bank files in the customer's electronic mailbox,
|
|
262
|
+
* usually a PDF, not a list of transactions. The bank hands out one statement per call and
|
|
263
|
+
* announces a waiting successor in `nextOffset`; pass that value back in `options.offset` to
|
|
264
|
+
* fetch the next one. Banks that set `receiptRequired` in their HIEKAS parameters keep
|
|
265
|
+
* offering a statement until it has been acknowledged with its receipt.
|
|
266
|
+
*
|
|
267
|
+
* @param account - the account number to fetch the statement for, must be an account available in the config.bankingInformation.upd.accounts
|
|
268
|
+
* @param options - optional format, statement number and year, entry limit and offset
|
|
269
|
+
* @returns a response containing the statement documents and the offset of a waiting successor
|
|
270
|
+
*/
|
|
271
|
+
async getElectronicStatements(account, options) {
|
|
272
|
+
return (await this.startCustomerOrderInteraction(new ElectronicStatementInteraction(account, options)));
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Continues the electronic account statement fetching when a TAN is required
|
|
276
|
+
* @param tanReference The TAN reference provided in the first call's response
|
|
277
|
+
* @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
|
|
278
|
+
* @returns a response containing the statement documents
|
|
279
|
+
*/
|
|
280
|
+
async getElectronicStatementsWithTan(tanReference, tan) {
|
|
281
|
+
return (await this.continueCustomerInteractionWithTan([HKEKA.Id], tanReference, tan));
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Checks if the bank supports SEPA credit transfers in general or from the given account when provided:
|
|
285
|
+
* HKCCS in a version this library speaks, a pain.001 format it builds, where the bank requires
|
|
286
|
+
* Verification of Payee for transfers, readable VoP parameters (HIVPPS), and, where the bank requires
|
|
287
|
+
* a TAN or VoP for them, a selected TAN method of version 6 or later
|
|
288
|
+
* @param account when the account number is provided, checks if the account allows transfers and has an IBAN;
|
|
289
|
+
* an account whose UPD entry does not list HKCCS counts only with UPD usage 1, which leaves it to the bank
|
|
290
|
+
* @returns true if the bank (and account) supports SEPA credit transfers
|
|
291
|
+
*/
|
|
292
|
+
canTransfer(account) {
|
|
293
|
+
if (account) {
|
|
294
|
+
// An unknown account is a mistake of the caller, as for the other can... methods
|
|
295
|
+
this.config.getBankAccount(account);
|
|
296
|
+
}
|
|
297
|
+
try {
|
|
298
|
+
this.checkTransferSupport(account);
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Starts a SEPA credit transfer (HKCCS), executed as soon as possible.
|
|
307
|
+
*
|
|
308
|
+
* It starts a payment, and its first call can already be final: a bank may execute the
|
|
309
|
+
* transfer without asking for a confirmation or a TAN. `confirmTransfer()` and
|
|
310
|
+
* `transferWithTan()` can authorise it while it is pending. The input is checked before
|
|
311
|
+
* anything is sent: an invalid IBAN, BIC, amount or text throws a `SepaValidationError`, and
|
|
312
|
+
* nothing is transliterated or shortened.
|
|
313
|
+
*
|
|
314
|
+
* Where the bank requires Verification of Payee, it checks the payee's name against the IBAN
|
|
315
|
+
* first, and the response carries the result in `vop`. Then:
|
|
316
|
+
* - `requiresVopConfirmation`: the bank waits for a decision. Show `vop` (with `vop.notice`,
|
|
317
|
+
* the notice lines of `vop.paymentStatusReport?.groupReasons` and, for a close match,
|
|
318
|
+
* `vop.suggestedName`) to the user, then call
|
|
319
|
+
* `confirmTransfer(transferId)` to authorise the transfer anyway, or
|
|
320
|
+
* `cancelTransfer(transferId)` to drop it. Nothing is confirmed
|
|
321
|
+
* automatically, whatever the result.
|
|
322
|
+
* - `requiresTan`: the payee matched (or the bank requires no check) and the bank asks for
|
|
323
|
+
* the TAN; continue with `transferWithTan()`, or drop the transfer with
|
|
324
|
+
* `cancelTransfer(transferId)`.
|
|
325
|
+
* - `success` and neither flag: the bank accepted the transfer.
|
|
326
|
+
* - `success: false`: the transfer stopped; `bankAnswers` and `failureReason` say why. Anything
|
|
327
|
+
* unexpected, such as an unknown result code or a missing VoP ID, ends it this way. With
|
|
328
|
+
* `outcomeUncertain` the bank may have executed the order without confirming it (it
|
|
329
|
+
* received the order and a later step failed or timed out, it answered 9000, or it
|
|
330
|
+
* reported an execution its other answers contradict): check the account before
|
|
331
|
+
* sending it again.
|
|
332
|
+
*
|
|
333
|
+
* While the bank is still checking the payee, the call asks again until the result is
|
|
334
|
+
* there; `bankAnswers` then holds the answers to every one of these messages.
|
|
335
|
+
*
|
|
336
|
+
* Only one transfer can be in progress per client. Every response carries the same
|
|
337
|
+
* `transferId` for it.
|
|
338
|
+
*
|
|
339
|
+
* @param account - the account to transfer from, must be an account available in the config.bankingInformation.upd.bankAccounts with an IBAN
|
|
340
|
+
* @param transfer - the payee, amount and purpose
|
|
341
|
+
* @returns the transfer response
|
|
342
|
+
* @throws SepaValidationError when the transfer data is invalid
|
|
343
|
+
* @throws Error when a transfer is already in progress, the account cannot transfer, or the
|
|
344
|
+
* connection fails; an error after the first message was sent leaves the outcome unknown,
|
|
345
|
+
* check the account before trying again
|
|
346
|
+
*/
|
|
347
|
+
async transfer(account, transfer) {
|
|
348
|
+
if (this.currentTransfer) {
|
|
349
|
+
throw new Error('a transfer is already in progress; continue it or call cancelTransfer() first');
|
|
350
|
+
}
|
|
351
|
+
// The payment as it is now: the caller's objects may change during the login
|
|
352
|
+
const accountRef = typeof account === 'string' ? account : { ...account };
|
|
353
|
+
const payment = transfer && typeof transfer === 'object'
|
|
354
|
+
? {
|
|
355
|
+
// Read one by one, so that a getter counts like a field
|
|
356
|
+
name: transfer.name,
|
|
357
|
+
iban: transfer.iban,
|
|
358
|
+
bic: transfer.bic,
|
|
359
|
+
amount: transfer.amount,
|
|
360
|
+
purpose: transfer.purpose,
|
|
361
|
+
endToEndId: transfer.endToEndId,
|
|
362
|
+
debtorName: transfer.debtorName,
|
|
363
|
+
}
|
|
364
|
+
: transfer;
|
|
365
|
+
const order = new CreditTransferOrder(() => this.prepareTransfer(accountRef, payment));
|
|
366
|
+
const dialog = new Dialog(this.config, false);
|
|
367
|
+
dialog.addCustomerInteraction(new CreditTransferInteraction(order, 'submit'));
|
|
368
|
+
const pending = { order, dialog, inFlight: false };
|
|
369
|
+
this.currentTransfer = pending;
|
|
370
|
+
return this.driveTransfer(pending, () => dialog.start());
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Authorises the transfer despite the Verification of Payee result, after the user has seen
|
|
374
|
+
* `vop` and decided to go ahead. Only callable when the last response had
|
|
375
|
+
* `requiresVopConfirmation`. The bank may then ask for a TAN (`requiresTan`).
|
|
376
|
+
*
|
|
377
|
+
* Authorising a transfer to a payee whose name does not match may mean the money goes to
|
|
378
|
+
* someone else, and the payer's bank is then not liable for that.
|
|
379
|
+
* @param transferId the `transferId` of the response the user decided on
|
|
380
|
+
* @returns the transfer response
|
|
381
|
+
* @throws Error when that transfer is not the one waiting for a confirmation, or, before
|
|
382
|
+
* anything is sent and with the transfer still pending, when no TAN method of version 6
|
|
383
|
+
* or later is selected
|
|
384
|
+
*/
|
|
385
|
+
async confirmTransfer(transferId) {
|
|
386
|
+
const transfer = this.currentTransfer;
|
|
387
|
+
if (transfer?.inFlight) {
|
|
388
|
+
throw new Error(STEP_IN_FLIGHT);
|
|
389
|
+
}
|
|
390
|
+
if (!transfer ||
|
|
391
|
+
transfer.order.transferId !== transferId ||
|
|
392
|
+
transfer.order.status !== 'awaitingConfirmation') {
|
|
393
|
+
throw new Error('no transfer is waiting for a confirmation of its Verification of Payee result');
|
|
394
|
+
}
|
|
395
|
+
// HKVPA, the order and HKTAN go together (DK VoP E.8.1 rule 4): nothing goes out
|
|
396
|
+
// without a TAN method that can send HKTAN
|
|
397
|
+
if (!transfer.order.authorizationOnly && !canSendTanSegment(this.config)) {
|
|
398
|
+
throw new Error('the confirmation needs a TAN method of version 6 or later; select one with selectTanMethod()');
|
|
399
|
+
}
|
|
400
|
+
transfer.order.confirmed = true;
|
|
401
|
+
return this.driveTransfer(transfer, () => transfer.dialog.continueWith(transfer.order.authorizationOnly
|
|
402
|
+
? new VopAuthorizationInteraction(transfer.order)
|
|
403
|
+
: new CreditTransferInteraction(transfer.order, 'confirm')));
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Continues the transfer when a TAN is required. With a decoupled TAN method, call it again
|
|
407
|
+
* while the response still has `requiresTan`, after the user has approved in their app.
|
|
408
|
+
* @param tanReference The TAN reference provided in the previous response
|
|
409
|
+
* @param tan The TAN entered by the user, can be omitted if a decoupled TAN method is used
|
|
410
|
+
* @returns the transfer response
|
|
411
|
+
* @throws Error, before anything is sent and with the transfer still pending, when the
|
|
412
|
+
* TAN method the challenge was issued for is no longer selected
|
|
413
|
+
*/
|
|
414
|
+
async transferWithTan(tanReference, tan) {
|
|
415
|
+
const transfer = this.currentTransfer;
|
|
416
|
+
if (transfer?.inFlight) {
|
|
417
|
+
throw new Error(STEP_IN_FLIGHT);
|
|
418
|
+
}
|
|
419
|
+
if (transfer?.tanReference === undefined) {
|
|
420
|
+
throw new Error('no transfer is waiting for a TAN');
|
|
421
|
+
}
|
|
422
|
+
if (transfer.tanReference !== tanReference) {
|
|
423
|
+
throw new Error('the TAN reference does not belong to the challenge of the transfer in progress');
|
|
424
|
+
}
|
|
425
|
+
// The answer to the challenge, HKVPA included, goes out only with the HKTAN of the
|
|
426
|
+
// method the challenge is for
|
|
427
|
+
if (!canSendTanSegment(this.config) || this.config.tanMethodId !== transfer.tanMethodId) {
|
|
428
|
+
throw new Error('the TAN method of the challenge is no longer selected; select it again with selectTanMethod()');
|
|
429
|
+
}
|
|
430
|
+
if (!this.config.selectedTanMethod?.isDecoupled && !tan) {
|
|
431
|
+
throw new Error('TAN must be provided for non-decoupled TAN methods');
|
|
432
|
+
}
|
|
433
|
+
return this.driveTransfer(transfer, () => transfer.dialog.continue(tanReference, tan));
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Drops the transfer in progress without executing it and ends its dialog. Call it after a
|
|
437
|
+
* response with `requiresVopConfirmation` or `requiresTan` when the user decides against the
|
|
438
|
+
* transfer. Does nothing when that transfer is no longer in progress.
|
|
439
|
+
* @param transferId the `transferId` of the transfer to drop
|
|
440
|
+
* @throws Error while a step of the transfer still waits for the bank's answer: that
|
|
441
|
+
* answer may already have executed it
|
|
442
|
+
*/
|
|
443
|
+
async cancelTransfer(transferId) {
|
|
444
|
+
const transfer = this.currentTransfer;
|
|
445
|
+
if (!transfer || transfer.order.transferId !== transferId) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
if (transfer.inFlight) {
|
|
449
|
+
throw new Error(STEP_IN_FLIGHT);
|
|
450
|
+
}
|
|
451
|
+
this.currentTransfer = undefined;
|
|
452
|
+
if (!transfer.dialog.hasEnded) {
|
|
453
|
+
await transfer.dialog.end();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* @param initTanReference the order a PIN/TAN management dialog's initialisation refers
|
|
458
|
+
* to in its HKTAN (see Dialog.initTanReference)
|
|
459
|
+
*/
|
|
460
|
+
async startCustomerOrderInteraction(interaction, initTanReference) {
|
|
461
|
+
this.currentDialog = new Dialog(this.config, false);
|
|
462
|
+
this.currentDialog.initTanReference = initTanReference;
|
|
463
|
+
this.currentDialog.addCustomerInteraction(interaction);
|
|
464
|
+
const responses = await this.currentDialog.start();
|
|
465
|
+
const response = responses.get(interaction.segId);
|
|
466
|
+
if (response) {
|
|
467
|
+
return response;
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
const lastResponse = [...responses.values()].at(-1);
|
|
471
|
+
if (lastResponse) {
|
|
472
|
+
return lastResponse;
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
throw new Error(`No response received for customer interaction with segment ID '${interaction.segId}'`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
async continueCustomerInteractionWithTan(segIds, tanReference, tan) {
|
|
480
|
+
if (!this.currentDialog) {
|
|
481
|
+
throw new Error('no customer dialog was started which can continue');
|
|
482
|
+
}
|
|
483
|
+
const responses = await this.currentDialog.continue(tanReference, tan);
|
|
484
|
+
for (const segId of segIds) {
|
|
485
|
+
const response = responses.get(segId);
|
|
486
|
+
if (response) {
|
|
487
|
+
return response;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
const lastResponse = [...responses.values()].at(-1);
|
|
491
|
+
if (lastResponse) {
|
|
492
|
+
return lastResponse;
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
throw new Error(`No response received for customer interaction with segment IDs '${segIds.join(', ')}'`);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* What canTransfer() checks, from the banking information as it is now
|
|
500
|
+
* @throws Error naming what does not allow the transfer
|
|
501
|
+
*/
|
|
502
|
+
checkTransferSupport(account) {
|
|
503
|
+
const hkccsVersion = this.config.getMaxSupportedTransactionVersion(HKCCS.Id);
|
|
504
|
+
if (!hkccsVersion) {
|
|
505
|
+
throw new Error('the bank does not support SEPA credit transfers (HKCCS) in a version this library supports');
|
|
506
|
+
}
|
|
507
|
+
// With UPD usage 1 the bank decides on a transaction the account does not list
|
|
508
|
+
if (account &&
|
|
509
|
+
this.config.bankingInformation.upd?.usage !== UpdUsage.MissingUnknown &&
|
|
510
|
+
!this.config.isAccountTransactionSupported(account, HKCCS.Id)) {
|
|
511
|
+
throw new Error(`account ${describeAccount(account)} does not allow SEPA credit transfers (HKCCS) according to the bank's account information (UPD)`);
|
|
512
|
+
}
|
|
513
|
+
if (account && !this.config.getBankAccount(account).iban) {
|
|
514
|
+
throw new Error(`account ${describeAccount(account)} has no IBAN to transfer from`);
|
|
515
|
+
}
|
|
516
|
+
const descriptor = this.selectTransferFormat();
|
|
517
|
+
if (!descriptor) {
|
|
518
|
+
throw new Error('the bank supports none of the pain.001 formats this library builds (pain.001.001.09, pain.001.001.03)');
|
|
519
|
+
}
|
|
520
|
+
const vopParameters = this.getVopParameters();
|
|
521
|
+
const tanRequired = this.config.bankingInformation.bpd?.allowedTransactions.find((t) => t.transId === HKCCS.Id)?.tanRequired;
|
|
522
|
+
// The check and the order go only together with HKTAN (DK VoP specification E.8.1)
|
|
523
|
+
if ((tanRequired || vopParameters) && !canSendTanSegment(this.config)) {
|
|
524
|
+
throw new Error('the bank requires a TAN for transfers, but no TAN method of version 6 or later is selected; select one with selectTanMethod()');
|
|
525
|
+
}
|
|
526
|
+
return { hkccsVersion, descriptor, vopParameters };
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Builds the order from the banking information as it is at the time of the call: once
|
|
530
|
+
* when the transfer is created, and again right before it is first sent, after the dialog
|
|
531
|
+
* initialisation may have brought new parameters
|
|
532
|
+
*/
|
|
533
|
+
prepareTransfer(account, transfer) {
|
|
534
|
+
const { hkccsVersion, descriptor, vopParameters } = this.checkTransferSupport(account);
|
|
535
|
+
const bankAccount = this.config.getBankAccount(account);
|
|
536
|
+
const pain = buildPain001({
|
|
537
|
+
name: transfer.debtorName ?? bankAccount.holder1,
|
|
538
|
+
iban: bankAccount.iban ?? '',
|
|
539
|
+
bic: bankAccount.bic,
|
|
540
|
+
}, transfer, descriptor);
|
|
541
|
+
return {
|
|
542
|
+
account: internationalAccount(this.config, bankAccount),
|
|
543
|
+
pain,
|
|
544
|
+
hkccsVersion,
|
|
545
|
+
vopParameters,
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
selectTransferFormat() {
|
|
549
|
+
return selectPain001Format(this.config.getTransactionParameters(HKSPA.Id)?.supportedSepaFormats);
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* What the bank's parameters say about Verification of Payee for transfers
|
|
553
|
+
* @returns undefined when the bank does not require it for HKCCS
|
|
554
|
+
* @throws Error when the bank announces it but its parameters cannot be used
|
|
555
|
+
*/
|
|
556
|
+
getVopParameters() {
|
|
557
|
+
if (!this.config.isTransactionSupported(HKVPP.Id)) {
|
|
558
|
+
return undefined;
|
|
559
|
+
}
|
|
560
|
+
const params = this.config.getTransactionParameters(HKVPP.Id);
|
|
561
|
+
// Unreadable parameters must not be taken for "no check required"
|
|
562
|
+
if (!params || !Array.isArray(params.vopRequiredTransactions)) {
|
|
563
|
+
throw new Error('the bank announces Verification of Payee (HKVPP), but its parameters (HIVPPS) could not be read');
|
|
564
|
+
}
|
|
565
|
+
if (!params.vopRequiredTransactions.includes(HKCCS.Id)) {
|
|
566
|
+
return undefined;
|
|
567
|
+
}
|
|
568
|
+
const hkvppVersion = this.config.getMaxSupportedTransactionVersion(HKVPP.Id);
|
|
569
|
+
const hkvpaVersion = this.config.getMaxSupportedTransactionVersion(HKVPA.Id);
|
|
570
|
+
if (!hkvppVersion || !hkvpaVersion) {
|
|
571
|
+
throw new Error('the bank requires Verification of Payee for transfers, but not in a version of HKVPP and HKVPA this library supports');
|
|
572
|
+
}
|
|
573
|
+
const reportFormats = (params.supportedReportFormats ?? '')
|
|
574
|
+
.split(/[;,\s]+/)
|
|
575
|
+
.filter((format) => !!format)
|
|
576
|
+
.slice(0, 99);
|
|
577
|
+
return {
|
|
578
|
+
reportFormats: reportFormats.length ? reportFormats : [VOP_DEFAULT_REPORT_FORMAT],
|
|
579
|
+
noticeStructured: !!params.noticeStructured,
|
|
580
|
+
hkvppVersion,
|
|
581
|
+
hkvpaVersion,
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Runs one step of the given transfer, then asks again for a Verification of Payee
|
|
586
|
+
* result for as long as the bank is still producing it. The transfer is marked in
|
|
587
|
+
* flight before anything is sent, so that no other step overlaps this one, and only
|
|
588
|
+
* this transfer is dropped when it ends.
|
|
589
|
+
*/
|
|
590
|
+
async driveTransfer(transfer, step) {
|
|
591
|
+
transfer.inFlight = true;
|
|
592
|
+
try {
|
|
593
|
+
return await this.runTransferStep(transfer, step);
|
|
594
|
+
}
|
|
595
|
+
finally {
|
|
596
|
+
transfer.inFlight = false;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
async runTransferStep(transfer, step) {
|
|
600
|
+
const { order, dialog } = transfer;
|
|
601
|
+
const release = () => {
|
|
602
|
+
if (this.currentTransfer === transfer) {
|
|
603
|
+
this.currentTransfer = undefined;
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
let response;
|
|
607
|
+
// Any message of the call may update it, the dialog initialisation above all
|
|
608
|
+
const bankingInformation = JSON.stringify(this.config.bankingInformation);
|
|
609
|
+
const withUpdate = (response) => JSON.stringify(this.config.bankingInformation) === bankingInformation
|
|
610
|
+
? response
|
|
611
|
+
: { ...response, bankingInformationUpdated: true };
|
|
612
|
+
transfer.tanReference = undefined;
|
|
613
|
+
try {
|
|
614
|
+
order.lastResponse = undefined;
|
|
615
|
+
await step();
|
|
616
|
+
response = this.toTransferResponse(order, dialog);
|
|
617
|
+
let waitedSeconds = 0;
|
|
618
|
+
while (order.status === 'polling' && response.success) {
|
|
619
|
+
const waitSeconds = Math.max(1, order.waitSeconds ?? VOP_DEFAULT_WAIT_SECONDS);
|
|
620
|
+
if (waitedSeconds + waitSeconds > VOP_TIMEOUT_SECONDS) {
|
|
621
|
+
order.status = 'failed';
|
|
622
|
+
const { reason, uncertain } = order.evidence.giveUp(`The bank did not deliver the Verification of Payee result within ${VOP_TIMEOUT_SECONDS} seconds.`);
|
|
623
|
+
response = {
|
|
624
|
+
...response,
|
|
625
|
+
success: false,
|
|
626
|
+
outcomeUncertain: uncertain,
|
|
627
|
+
failureReason: reason,
|
|
628
|
+
};
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
waitedSeconds += waitSeconds;
|
|
632
|
+
await this.sleep(waitSeconds * 1000);
|
|
633
|
+
order.lastResponse = undefined;
|
|
634
|
+
await dialog.continueWith(new VopPollInteraction(order));
|
|
635
|
+
// The caller sees what the bank said on every poll of this call
|
|
636
|
+
const earlierAnswers = response.bankAnswers;
|
|
637
|
+
response = this.toTransferResponse(order, dialog);
|
|
638
|
+
response = { ...response, bankAnswers: [...earlierAnswers, ...response.bankAnswers] };
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
catch (error) {
|
|
642
|
+
release();
|
|
643
|
+
// The bank accepted the order and only ending the dialog failed: still a success
|
|
644
|
+
if (order.status === 'accepted' && order.lastResponse) {
|
|
645
|
+
return withUpdate(order.lastResponse);
|
|
646
|
+
}
|
|
647
|
+
await this.endQuietly(dialog);
|
|
648
|
+
const { refused } = order.evidence;
|
|
649
|
+
// Without an answer the outcome is unknown, as any error says; once the answers so
|
|
650
|
+
// far allow that the bank executes the payment, or the payment was refused here,
|
|
651
|
+
// the caller gets them with the uncertainty
|
|
652
|
+
if (!refused && !order.evidence.mayHaveExecuted()) {
|
|
653
|
+
throw error;
|
|
654
|
+
}
|
|
655
|
+
order.status = 'failed';
|
|
656
|
+
const { reason } = order.evidence.giveUp(refused ?? `The answer of the bank did not arrive (${error.message}).`, true);
|
|
657
|
+
return withUpdate({
|
|
658
|
+
...(response ?? this.unanswered(order, dialog)),
|
|
659
|
+
success: false,
|
|
660
|
+
requiresTan: false,
|
|
661
|
+
requiresVopConfirmation: false,
|
|
662
|
+
outcomeUncertain: true,
|
|
663
|
+
failureReason: reason,
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
response = withUpdate(response);
|
|
667
|
+
if (response.success && response.requiresTan) {
|
|
668
|
+
transfer.tanReference = response.tanReference;
|
|
669
|
+
transfer.tanMethodId = this.config.tanMethodId;
|
|
670
|
+
}
|
|
671
|
+
if (order.status === 'accepted') {
|
|
672
|
+
// The dialog has already sent HKEND
|
|
673
|
+
release();
|
|
674
|
+
}
|
|
675
|
+
else if (!response.success || order.status === 'failed') {
|
|
676
|
+
release();
|
|
677
|
+
await this.endQuietly(dialog);
|
|
678
|
+
}
|
|
679
|
+
return response;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* The response of the transfer interaction, or, when the dialog stopped before the transfer
|
|
683
|
+
* was sent (a TAN or an error in the dialog initialisation or a step it queued, such as
|
|
684
|
+
* HKSPA), the response of the interaction it stopped at
|
|
685
|
+
*/
|
|
686
|
+
toTransferResponse(order, dialog) {
|
|
687
|
+
if (order.lastResponse) {
|
|
688
|
+
return order.lastResponse;
|
|
689
|
+
}
|
|
690
|
+
const segId = dialog.currentInteraction?.segId;
|
|
691
|
+
const response = segId ? dialog.responses.get(segId) : undefined;
|
|
692
|
+
if (!response) {
|
|
693
|
+
throw new Error('No response received for the transfer');
|
|
694
|
+
}
|
|
695
|
+
const transferResponse = {
|
|
696
|
+
...response,
|
|
697
|
+
requiresVopConfirmation: false,
|
|
698
|
+
vop: order.vopResult,
|
|
699
|
+
transferId: order.transferId,
|
|
700
|
+
endToEndId: order.pain.endToEndId,
|
|
701
|
+
outcomeUncertain: false,
|
|
702
|
+
};
|
|
703
|
+
if (response.requiresTan && response.success && response.tanReference) {
|
|
704
|
+
return transferResponse;
|
|
705
|
+
}
|
|
706
|
+
order.status = 'failed';
|
|
707
|
+
return {
|
|
708
|
+
...transferResponse,
|
|
709
|
+
success: false,
|
|
710
|
+
requiresTan: false,
|
|
711
|
+
failureReason: 'The dialog stopped before the transfer was sent, see bankAnswers. The transfer was not executed.',
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
/** The response of a transfer step the bank did not answer */
|
|
715
|
+
unanswered(order, dialog) {
|
|
716
|
+
return {
|
|
717
|
+
dialogId: dialog.dialogId,
|
|
718
|
+
success: false,
|
|
719
|
+
bankingInformationUpdated: false,
|
|
720
|
+
bankAnswers: [],
|
|
721
|
+
requiresTan: false,
|
|
722
|
+
requiresVopConfirmation: false,
|
|
723
|
+
vop: order.vopResult,
|
|
724
|
+
transferId: order.transferId,
|
|
725
|
+
endToEndId: order.pain.endToEndId,
|
|
726
|
+
outcomeUncertain: true,
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
async endQuietly(dialog) {
|
|
730
|
+
try {
|
|
731
|
+
await dialog.end();
|
|
732
|
+
}
|
|
733
|
+
catch {
|
|
734
|
+
// The dialog times out at the bank all the same
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
sleep(milliseconds) {
|
|
738
|
+
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
739
|
+
}
|
|
740
|
+
}
|