fints-lib 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README_advanced_usage.md +70 -0
- package/dist/client.d.ts +89 -0
- package/dist/client.js +473 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.d.ts +15 -0
- package/dist/constants.js +19 -0
- package/dist/constants.js.map +1 -0
- package/dist/dialog.d.ts +111 -0
- package/dist/dialog.js +187 -0
- package/dist/dialog.js.map +1 -0
- package/dist/error-codes.d.ts +39 -0
- package/dist/error-codes.js +228 -0
- package/dist/error-codes.js.map +1 -0
- package/dist/errors/fints-error.d.ts +55 -0
- package/dist/errors/fints-error.js +131 -0
- package/dist/errors/fints-error.js.map +1 -0
- package/dist/errors/response-error.d.ts +6 -0
- package/dist/errors/response-error.js +20 -0
- package/dist/errors/response-error.js.map +1 -0
- package/dist/errors/tan-required-error.d.ts +40 -0
- package/dist/errors/tan-required-error.js +54 -0
- package/dist/errors/tan-required-error.js.map +1 -0
- package/dist/format.d.ts +81 -0
- package/dist/format.js +112 -0
- package/dist/format.js.map +1 -0
- package/dist/http-connection.d.ts +36 -0
- package/dist/http-connection.js +109 -0
- package/dist/http-connection.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.js +13 -0
- package/dist/logger.js.map +1 -0
- package/dist/mt535.d.ts +19 -0
- package/dist/mt535.js +153 -0
- package/dist/mt535.js.map +1 -0
- package/dist/mt940-86-structured.d.ts +47 -0
- package/dist/mt940-86-structured.js +213 -0
- package/dist/mt940-86-structured.js.map +1 -0
- package/dist/pain-formats.d.ts +50 -0
- package/dist/pain-formats.js +7 -0
- package/dist/pain-formats.js.map +1 -0
- package/dist/pain.d.ts +21 -0
- package/dist/pain.js +315 -0
- package/dist/pain.js.map +1 -0
- package/dist/parse.d.ts +46 -0
- package/dist/parse.js +97 -0
- package/dist/parse.js.map +1 -0
- package/dist/pin-tan-client.d.ts +47 -0
- package/dist/pin-tan-client.js +35 -0
- package/dist/pin-tan-client.js.map +1 -0
- package/dist/request.d.ts +90 -0
- package/dist/request.js +102 -0
- package/dist/request.js.map +1 -0
- package/dist/response.d.ts +104 -0
- package/dist/response.js +197 -0
- package/dist/response.js.map +1 -0
- package/dist/return-value.d.ts +37 -0
- package/dist/return-value.js +31 -0
- package/dist/return-value.js.map +1 -0
- package/dist/segments/hibpa.d.ts +22 -0
- package/dist/segments/hibpa.js +36 -0
- package/dist/segments/hibpa.js.map +1 -0
- package/dist/segments/hiccs.d.ts +14 -0
- package/dist/segments/hiccs.js +28 -0
- package/dist/segments/hiccs.js.map +1 -0
- package/dist/segments/hiccss.d.ts +13 -0
- package/dist/segments/hiccss.js +24 -0
- package/dist/segments/hiccss.js.map +1 -0
- package/dist/segments/hicdb.d.ts +17 -0
- package/dist/segments/hicdb.js +62 -0
- package/dist/segments/hicdb.js.map +1 -0
- package/dist/segments/hicdbs.d.ts +16 -0
- package/dist/segments/hicdbs.js +28 -0
- package/dist/segments/hicdbs.js.map +1 -0
- package/dist/segments/hidse.d.ts +14 -0
- package/dist/segments/hidse.js +28 -0
- package/dist/segments/hidse.js.map +1 -0
- package/dist/segments/hidses.d.ts +13 -0
- package/dist/segments/hidses.js +24 -0
- package/dist/segments/hidses.js.map +1 -0
- package/dist/segments/hikaz.d.ts +16 -0
- package/dist/segments/hikaz.js +31 -0
- package/dist/segments/hikaz.js.map +1 -0
- package/dist/segments/hikazs.d.ts +16 -0
- package/dist/segments/hikazs.js +28 -0
- package/dist/segments/hikazs.js.map +1 -0
- package/dist/segments/hirmg.d.ts +17 -0
- package/dist/segments/hirmg.js +39 -0
- package/dist/segments/hirmg.js.map +1 -0
- package/dist/segments/hirms.d.ts +16 -0
- package/dist/segments/hirms.js +37 -0
- package/dist/segments/hirms.js.map +1 -0
- package/dist/segments/hisal.d.ts +22 -0
- package/dist/segments/hisal.js +33 -0
- package/dist/segments/hisal.js.map +1 -0
- package/dist/segments/hisals.d.ts +16 -0
- package/dist/segments/hisals.js +28 -0
- package/dist/segments/hisals.js.map +1 -0
- package/dist/segments/hispa.d.ts +16 -0
- package/dist/segments/hispa.js +31 -0
- package/dist/segments/hispa.js.map +1 -0
- package/dist/segments/hispas.d.ts +14 -0
- package/dist/segments/hispas.js +28 -0
- package/dist/segments/hispas.js.map +1 -0
- package/dist/segments/hisyn.d.ts +15 -0
- package/dist/segments/hisyn.js +26 -0
- package/dist/segments/hisyn.js.map +1 -0
- package/dist/segments/hitan.d.ts +18 -0
- package/dist/segments/hitan.js +66 -0
- package/dist/segments/hitan.js.map +1 -0
- package/dist/segments/hitans.d.ts +18 -0
- package/dist/segments/hitans.js +46 -0
- package/dist/segments/hitans.js.map +1 -0
- package/dist/segments/hiupd.d.ts +16 -0
- package/dist/segments/hiupd.js +34 -0
- package/dist/segments/hiupd.js.map +1 -0
- package/dist/segments/hiwpd.d.ts +15 -0
- package/dist/segments/hiwpd.js +26 -0
- package/dist/segments/hiwpd.js.map +1 -0
- package/dist/segments/hiwpds.d.ts +16 -0
- package/dist/segments/hiwpds.js +32 -0
- package/dist/segments/hiwpds.js.map +1 -0
- package/dist/segments/hkccs.d.ts +18 -0
- package/dist/segments/hkccs.js +32 -0
- package/dist/segments/hkccs.js.map +1 -0
- package/dist/segments/hkcdb.d.ts +19 -0
- package/dist/segments/hkcdb.js +30 -0
- package/dist/segments/hkcdb.js.map +1 -0
- package/dist/segments/hkdse.d.ts +18 -0
- package/dist/segments/hkdse.js +27 -0
- package/dist/segments/hkdse.js.map +1 -0
- package/dist/segments/hkend.d.ts +12 -0
- package/dist/segments/hkend.js +24 -0
- package/dist/segments/hkend.js.map +1 -0
- package/dist/segments/hkidn.d.ts +19 -0
- package/dist/segments/hkidn.js +33 -0
- package/dist/segments/hkidn.js.map +1 -0
- package/dist/segments/hkkaz.d.ts +20 -0
- package/dist/segments/hkkaz.js +42 -0
- package/dist/segments/hkkaz.js.map +1 -0
- package/dist/segments/hksal.d.ts +18 -0
- package/dist/segments/hksal.js +35 -0
- package/dist/segments/hksal.js.map +1 -0
- package/dist/segments/hkspa.d.ts +18 -0
- package/dist/segments/hkspa.js +31 -0
- package/dist/segments/hkspa.js.map +1 -0
- package/dist/segments/hksyn.d.ts +16 -0
- package/dist/segments/hksyn.js +31 -0
- package/dist/segments/hksyn.js.map +1 -0
- package/dist/segments/hktab.d.ts +17 -0
- package/dist/segments/hktab.js +31 -0
- package/dist/segments/hktab.js.map +1 -0
- package/dist/segments/hktan.d.ts +19 -0
- package/dist/segments/hktan.js +66 -0
- package/dist/segments/hktan.js.map +1 -0
- package/dist/segments/hkvvb.d.ts +17 -0
- package/dist/segments/hkvvb.js +39 -0
- package/dist/segments/hkvvb.js.map +1 -0
- package/dist/segments/hkwpd.d.ts +21 -0
- package/dist/segments/hkwpd.js +39 -0
- package/dist/segments/hkwpd.js.map +1 -0
- package/dist/segments/hnhbk.d.ts +22 -0
- package/dist/segments/hnhbk.js +54 -0
- package/dist/segments/hnhbk.js.map +1 -0
- package/dist/segments/hnhbs.d.ts +16 -0
- package/dist/segments/hnhbs.js +29 -0
- package/dist/segments/hnhbs.js.map +1 -0
- package/dist/segments/hnsha.d.ts +18 -0
- package/dist/segments/hnsha.js +30 -0
- package/dist/segments/hnsha.js.map +1 -0
- package/dist/segments/hnshk.d.ts +21 -0
- package/dist/segments/hnshk.js +44 -0
- package/dist/segments/hnshk.js.map +1 -0
- package/dist/segments/hnvsd.d.ts +25 -0
- package/dist/segments/hnvsd.js +31 -0
- package/dist/segments/hnvsd.js.map +1 -0
- package/dist/segments/hnvsk.d.ts +15 -0
- package/dist/segments/hnvsk.js +51 -0
- package/dist/segments/hnvsk.js.map +1 -0
- package/dist/segments/index.d.ts +40 -0
- package/dist/segments/index.js +57 -0
- package/dist/segments/index.js.map +1 -0
- package/dist/segments/segment.d.ts +60 -0
- package/dist/segments/segment.js +74 -0
- package/dist/segments/segment.js.map +1 -0
- package/dist/tan-method.d.ts +36 -0
- package/dist/tan-method.js +224 -0
- package/dist/tan-method.js.map +1 -0
- package/dist/types.d.ts +386 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +55 -0
- package/dist/utils.js +178 -0
- package/dist/utils.js.map +1 -0
- package/package.json +1 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client"), exports);
|
|
18
|
+
__exportStar(require("./constants"), exports);
|
|
19
|
+
__exportStar(require("./dialog"), exports);
|
|
20
|
+
__exportStar(require("./error-codes"), exports);
|
|
21
|
+
__exportStar(require("./format"), exports);
|
|
22
|
+
__exportStar(require("./http-connection"), exports);
|
|
23
|
+
__exportStar(require("./logger"), exports);
|
|
24
|
+
__exportStar(require("./mt940-86-structured"), exports);
|
|
25
|
+
__exportStar(require("./mt535"), exports);
|
|
26
|
+
__exportStar(require("./pain"), exports);
|
|
27
|
+
__exportStar(require("./pain-formats"), exports);
|
|
28
|
+
__exportStar(require("./parse"), exports);
|
|
29
|
+
__exportStar(require("./pin-tan-client"), exports);
|
|
30
|
+
__exportStar(require("./request"), exports);
|
|
31
|
+
__exportStar(require("./response"), exports);
|
|
32
|
+
__exportStar(require("./return-value"), exports);
|
|
33
|
+
__exportStar(require("./segments"), exports);
|
|
34
|
+
__exportStar(require("./tan-method"), exports);
|
|
35
|
+
__exportStar(require("./types"), exports);
|
|
36
|
+
__exportStar(require("./utils"), exports);
|
|
37
|
+
__exportStar(require("./errors/response-error"), exports);
|
|
38
|
+
__exportStar(require("./errors/tan-required-error"), exports);
|
|
39
|
+
__exportStar(require("./errors/fints-error"), exports);
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,gDAA8B;AAC9B,2CAAyB;AACzB,oDAAkC;AAClC,2CAAyB;AACzB,wDAAsC;AACtC,0CAAwB;AACxB,yCAAuB;AACvB,iDAA+B;AAC/B,0CAAwB;AACxB,mDAAiC;AACjC,4CAA0B;AAC1B,6CAA2B;AAC3B,iDAA+B;AAC/B,6CAA2B;AAC3B,+CAA6B;AAC7B,0CAAwB;AACxB,0CAAwB;AACxB,0DAAwC;AACxC,8DAA4C;AAC5C,uDAAqC"}
|
package/dist/logger.d.ts
ADDED
package/dist/logger.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.error = exports.warn = exports.verbose = exports.logger = void 0;
|
|
4
|
+
const winston_1 = require("winston");
|
|
5
|
+
exports.logger = (0, winston_1.createLogger)();
|
|
6
|
+
exports.logger.silent = true;
|
|
7
|
+
const verbose = (...args) => exports.logger.verbose(...args);
|
|
8
|
+
exports.verbose = verbose;
|
|
9
|
+
const warn = (...args) => exports.logger.warn(...args);
|
|
10
|
+
exports.warn = warn;
|
|
11
|
+
const error = (...args) => exports.logger.error(...args);
|
|
12
|
+
exports.error = error;
|
|
13
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAE1B,QAAA,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;AAErC,cAAM,CAAC,MAAM,GAAG,IAAI,CAAC;AAEd,MAAM,OAAO,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CAAE,cAAM,CAAC,OAAe,CAAC,GAAG,IAAI,CAAC,CAAC;AAA/D,QAAA,OAAO,WAAwD;AACrE,MAAM,IAAI,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CAAE,cAAM,CAAC,IAAY,CAAC,GAAG,IAAI,CAAC,CAAC;AAAzD,QAAA,IAAI,QAAqD;AAC/D,MAAM,KAAK,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CAAE,cAAM,CAAC,KAAa,CAAC,GAAG,IAAI,CAAC,CAAC;AAA3D,QAAA,KAAK,SAAsD"}
|
package/dist/mt535.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Holding } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Parser for holdings information encoded in MT535 statements.
|
|
4
|
+
*/
|
|
5
|
+
export declare class MT535Parser {
|
|
6
|
+
private readonly identification;
|
|
7
|
+
private readonly marketPrice;
|
|
8
|
+
private readonly priceDate;
|
|
9
|
+
private readonly pieces;
|
|
10
|
+
private readonly totalValue;
|
|
11
|
+
private readonly acquisitionPrice;
|
|
12
|
+
parse(lines: string[]): Holding[];
|
|
13
|
+
private parseFinancialInstrument;
|
|
14
|
+
private parseClause;
|
|
15
|
+
private parseDecimal;
|
|
16
|
+
private parseDate;
|
|
17
|
+
private collapseMultilines;
|
|
18
|
+
private grabFinancialInstrumentSegments;
|
|
19
|
+
}
|
package/dist/mt535.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MT535Parser = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Parser for holdings information encoded in MT535 statements.
|
|
6
|
+
*/
|
|
7
|
+
class MT535Parser {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.identification = /^:35B:ISIN\s(.*)\|(.*)\|(.*)$/;
|
|
10
|
+
this.marketPrice = /^:90B::MRKT\/\/ACTU\/([A-Z]{3})(\d*),{1}(\d*)$/;
|
|
11
|
+
this.priceDate = /^:98A::PRIC\/\/(\d*)$/;
|
|
12
|
+
this.pieces = /^:93B::AGGR\/\/UNIT\/(\d*),(\d*)$/;
|
|
13
|
+
this.totalValue = /^:19A::HOLD\/\/([A-Z]{3})(\d*),{1}(\d*)$/;
|
|
14
|
+
this.acquisitionPrice = /^:70E::HOLD\/\/\d*STK\|2(\d*?),{1}(\d*?)\+([A-Z]{3})$/;
|
|
15
|
+
}
|
|
16
|
+
parse(lines) {
|
|
17
|
+
if (!lines || lines.length === 0) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
const clauses = this.collapseMultilines(lines);
|
|
21
|
+
const financialInstrumentSegments = this.grabFinancialInstrumentSegments(clauses);
|
|
22
|
+
return financialInstrumentSegments.reduce((result, segment) => {
|
|
23
|
+
const holding = this.parseFinancialInstrument(segment);
|
|
24
|
+
if (holding) {
|
|
25
|
+
result.push(holding);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}, []);
|
|
29
|
+
}
|
|
30
|
+
parseFinancialInstrument(segment) {
|
|
31
|
+
const context = {};
|
|
32
|
+
segment.forEach((clause) => this.parseClause(clause, context));
|
|
33
|
+
if (Object.keys(context).length === 0) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
isin: context.isin,
|
|
38
|
+
name: context.name,
|
|
39
|
+
marketPrice: context.marketPrice,
|
|
40
|
+
currency: context.currency,
|
|
41
|
+
valuationDate: context.valuationDate,
|
|
42
|
+
pieces: context.pieces,
|
|
43
|
+
totalValue: context.totalValue,
|
|
44
|
+
acquisitionPrice: context.acquisitionPrice,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
parseClause(clause, context) {
|
|
48
|
+
let match = this.identification.exec(clause);
|
|
49
|
+
if (match) {
|
|
50
|
+
context.isin = match[1];
|
|
51
|
+
context.name = match[3];
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
match = this.marketPrice.exec(clause);
|
|
55
|
+
if (match) {
|
|
56
|
+
context.currency = match[1];
|
|
57
|
+
context.marketPrice = this.parseDecimal(match[2], match[3]);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
match = this.priceDate.exec(clause);
|
|
61
|
+
if (match) {
|
|
62
|
+
context.valuationDate = this.parseDate(match[1]);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
match = this.pieces.exec(clause);
|
|
66
|
+
if (match) {
|
|
67
|
+
context.pieces = this.parseDecimal(match[1], match[2]);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
match = this.totalValue.exec(clause);
|
|
71
|
+
if (match) {
|
|
72
|
+
context.totalValue = this.parseDecimal(match[2], match[3]);
|
|
73
|
+
if (!context.currency) {
|
|
74
|
+
context.currency = match[1];
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
match = this.acquisitionPrice.exec(clause);
|
|
79
|
+
if (match) {
|
|
80
|
+
context.acquisitionPrice = this.parseDecimal(match[1], match[2]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
parseDecimal(integerPart, fractionPart) {
|
|
84
|
+
const integer = integerPart || "0";
|
|
85
|
+
const fraction = fractionPart || "0";
|
|
86
|
+
return parseFloat(`${integer}.${fraction}`);
|
|
87
|
+
}
|
|
88
|
+
parseDate(raw) {
|
|
89
|
+
if (!raw || raw.length !== 8) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const year = Number(raw.substr(0, 4));
|
|
93
|
+
const month = Number(raw.substr(4, 2));
|
|
94
|
+
const day = Number(raw.substr(6, 2));
|
|
95
|
+
if (Number.isNaN(year) || Number.isNaN(month) || Number.isNaN(day)) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
return new Date(Date.UTC(year, month - 1, day));
|
|
99
|
+
}
|
|
100
|
+
collapseMultilines(lines) {
|
|
101
|
+
const clauses = [];
|
|
102
|
+
let previous = "";
|
|
103
|
+
for (const line of lines) {
|
|
104
|
+
if (line.startsWith(":")) {
|
|
105
|
+
if (previous !== "") {
|
|
106
|
+
clauses.push(previous);
|
|
107
|
+
}
|
|
108
|
+
previous = line;
|
|
109
|
+
}
|
|
110
|
+
else if (line.startsWith("-")) {
|
|
111
|
+
if (previous !== "") {
|
|
112
|
+
clauses.push(previous);
|
|
113
|
+
}
|
|
114
|
+
clauses.push(line);
|
|
115
|
+
previous = "";
|
|
116
|
+
}
|
|
117
|
+
else if (previous) {
|
|
118
|
+
previous += `|${line}`;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
previous = line;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (previous) {
|
|
125
|
+
clauses.push(previous);
|
|
126
|
+
}
|
|
127
|
+
return clauses;
|
|
128
|
+
}
|
|
129
|
+
grabFinancialInstrumentSegments(clauses) {
|
|
130
|
+
const segments = [];
|
|
131
|
+
let stack = [];
|
|
132
|
+
let withinInstrument = false;
|
|
133
|
+
clauses.forEach((clause) => {
|
|
134
|
+
if (clause.startsWith(":16R:FIN")) {
|
|
135
|
+
withinInstrument = true;
|
|
136
|
+
stack = [];
|
|
137
|
+
}
|
|
138
|
+
else if (clause.startsWith(":16S:FIN")) {
|
|
139
|
+
if (withinInstrument) {
|
|
140
|
+
segments.push(stack.slice());
|
|
141
|
+
}
|
|
142
|
+
withinInstrument = false;
|
|
143
|
+
stack = [];
|
|
144
|
+
}
|
|
145
|
+
else if (withinInstrument) {
|
|
146
|
+
stack.push(clause);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return segments;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.MT535Parser = MT535Parser;
|
|
153
|
+
//# sourceMappingURL=mt535.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mt535.js","sourceRoot":"","sources":["../src/mt535.ts"],"names":[],"mappings":";;;AAaA;;GAEG;AACH,MAAa,WAAW;IAAxB;QACqB,mBAAc,GAAG,+BAA+B,CAAC;QACjD,gBAAW,GAAG,gDAAgD,CAAC;QAC/D,cAAS,GAAG,uBAAuB,CAAC;QACpC,WAAM,GAAG,mCAAmC,CAAC;QAC7C,eAAU,GAAG,0CAA0C,CAAC;QACxD,qBAAgB,GAAG,uDAAuD,CAAC;IAgJhG,CAAC;IA9IU,KAAK,CAAC,KAAe;QACxB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,2BAA2B,GAAG,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC;QAClF,OAAO,2BAA2B,CAAC,MAAM,CAAY,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;YACrE,MAAM,OAAO,GAAG,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;YACvD,IAAI,OAAO,EAAE,CAAC;gBACV,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzB,CAAC;YACD,OAAO,MAAM,CAAC;QAClB,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC;IAEO,wBAAwB,CAAC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@
|
|
|
1
|
+
import { Section, PaymentReference, StructuredDescription } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Used to sniff whether the 86 section of the MT940 statement list supports the fints structured
|
|
4
|
+
* representation.
|
|
5
|
+
*
|
|
6
|
+
* @param input The string for the 86 section.
|
|
7
|
+
*
|
|
8
|
+
* @return Whether the string is likely structured.
|
|
9
|
+
*/
|
|
10
|
+
export declare function is86Structured(input: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Parses a commonly used date format ("DATUM 15.11.2018, 12:00 UHR") into a date
|
|
13
|
+
*
|
|
14
|
+
* @param content The date string to parse.
|
|
15
|
+
*
|
|
16
|
+
* @return The parsed date.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parsePaymentReferenceDate(content: string): Date;
|
|
19
|
+
/**
|
|
20
|
+
* Parses a commonly format for representing a TAN related to a transaction ("1. TAN 123456").
|
|
21
|
+
*
|
|
22
|
+
* @param content The string to parse.
|
|
23
|
+
*
|
|
24
|
+
* @return The parsed TAN number and TAN iteself.
|
|
25
|
+
*/
|
|
26
|
+
export declare function parsePaymentReferenceTan(content: string): {
|
|
27
|
+
num: number;
|
|
28
|
+
value: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* If the payment reference follows the SEPA tagging system, parse the information.
|
|
32
|
+
* See: https://tinyurl.com/ycdfx5hd
|
|
33
|
+
*
|
|
34
|
+
* @param references A list of all sections used for payment reference (20 - 29 and 60 - 63).
|
|
35
|
+
*
|
|
36
|
+
* @return A parsed payment reference with all extracted data.
|
|
37
|
+
*/
|
|
38
|
+
export declare function assemblePaymentReference(references: Section[]): PaymentReference;
|
|
39
|
+
/**
|
|
40
|
+
* Parse as much information as possible from the structured 86 section of a MT940 statement list.
|
|
41
|
+
* Use `is86Structured` to sniff whether the payment reference is parsable.
|
|
42
|
+
*
|
|
43
|
+
* @param input The input string for the 86 section to parse.
|
|
44
|
+
*
|
|
45
|
+
* @return The parsed structured description.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parse86Structured(input: string): StructuredDescription;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.is86Structured = is86Structured;
|
|
4
|
+
exports.parsePaymentReferenceDate = parsePaymentReferenceDate;
|
|
5
|
+
exports.parsePaymentReferenceTan = parsePaymentReferenceTan;
|
|
6
|
+
exports.assemblePaymentReference = assemblePaymentReference;
|
|
7
|
+
exports.parse86Structured = parse86Structured;
|
|
8
|
+
const detectionRegex = /(?:^|\?)(..)(.*?)(?:$|\?)/g;
|
|
9
|
+
/**
|
|
10
|
+
* Used to sniff whether the 86 section of the MT940 statement list supports the fints structured
|
|
11
|
+
* representation.
|
|
12
|
+
*
|
|
13
|
+
* @param input The string for the 86 section.
|
|
14
|
+
*
|
|
15
|
+
* @return Whether the string is likely structured.
|
|
16
|
+
*/
|
|
17
|
+
function is86Structured(input) {
|
|
18
|
+
const matches = [];
|
|
19
|
+
let lastMatch;
|
|
20
|
+
do {
|
|
21
|
+
lastMatch = detectionRegex.exec(input);
|
|
22
|
+
matches.push(lastMatch);
|
|
23
|
+
} while (lastMatch);
|
|
24
|
+
const results = matches
|
|
25
|
+
.filter((match) => match !== null)
|
|
26
|
+
.map((match) => ({ code: Number(match[1]), value: match[2] }));
|
|
27
|
+
if (results.length === 0) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (results.some((result) => isNaN(result.code))) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Parses a commonly used date format ("DATUM 15.11.2018, 12:00 UHR") into a date
|
|
37
|
+
*
|
|
38
|
+
* @param content The date string to parse.
|
|
39
|
+
*
|
|
40
|
+
* @return The parsed date.
|
|
41
|
+
*/
|
|
42
|
+
function parsePaymentReferenceDate(content) {
|
|
43
|
+
const groups = /DATUM\s+(\d+)\.(\d+)\.(\d+),\s+(\d+)\.(\d+)\s+UHR/.exec(content);
|
|
44
|
+
if (!groups) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return new Date(Number(groups[3]), Number(groups[2]) - 1, Number(groups[1]), Number(groups[4]), Number(groups[5]));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parses a commonly format for representing a TAN related to a transaction ("1. TAN 123456").
|
|
51
|
+
*
|
|
52
|
+
* @param content The string to parse.
|
|
53
|
+
*
|
|
54
|
+
* @return The parsed TAN number and TAN iteself.
|
|
55
|
+
*/
|
|
56
|
+
function parsePaymentReferenceTan(content) {
|
|
57
|
+
const groups = /(\d+)\.\s*TAN\s+(.*)/.exec(content);
|
|
58
|
+
if (!groups) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
num: Number(groups[1]),
|
|
63
|
+
value: groups[2],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* If the payment reference follows the SEPA tagging system, parse the information.
|
|
68
|
+
* See: https://tinyurl.com/ycdfx5hd
|
|
69
|
+
*
|
|
70
|
+
* @param references A list of all sections used for payment reference (20 - 29 and 60 - 63).
|
|
71
|
+
*
|
|
72
|
+
* @return A parsed payment reference with all extracted data.
|
|
73
|
+
*/
|
|
74
|
+
function assemblePaymentReference(references) {
|
|
75
|
+
let lastIdentifiedAttribute;
|
|
76
|
+
const result = { raw: "" };
|
|
77
|
+
const add = (name, content) => {
|
|
78
|
+
lastIdentifiedAttribute = name;
|
|
79
|
+
result[name] = content;
|
|
80
|
+
};
|
|
81
|
+
references
|
|
82
|
+
.sort((a, b) => a.code - b.code)
|
|
83
|
+
.forEach(({ content }) => {
|
|
84
|
+
if (content.startsWith("IBAN+")) {
|
|
85
|
+
add("iban", content.substr(5));
|
|
86
|
+
}
|
|
87
|
+
else if (content.startsWith("BIC+")) {
|
|
88
|
+
add("bic", content.substr(5));
|
|
89
|
+
}
|
|
90
|
+
else if (content.startsWith("EREF+")) {
|
|
91
|
+
add("endToEndRef", content.substr(5));
|
|
92
|
+
}
|
|
93
|
+
else if (content.startsWith("KREF+")) {
|
|
94
|
+
add("customerRef", content.substr(5));
|
|
95
|
+
}
|
|
96
|
+
else if (content.startsWith("MREF+")) {
|
|
97
|
+
add("mandateRef", content.substr(5));
|
|
98
|
+
}
|
|
99
|
+
else if (content.startsWith("CRED+")) {
|
|
100
|
+
add("creditorId", content.substr(5));
|
|
101
|
+
}
|
|
102
|
+
else if (content.startsWith("DEBT+")) {
|
|
103
|
+
add("originatorId", content.substr(5));
|
|
104
|
+
}
|
|
105
|
+
else if (content.startsWith("COAM+")) {
|
|
106
|
+
add("interestCompensation", content.substr(5));
|
|
107
|
+
}
|
|
108
|
+
else if (content.startsWith("OAMT+")) {
|
|
109
|
+
add("originalTurnover", content.substr(5));
|
|
110
|
+
}
|
|
111
|
+
else if (content.startsWith("SVWZ+")) {
|
|
112
|
+
add("text", content.substr(5));
|
|
113
|
+
}
|
|
114
|
+
else if (content.startsWith("ABWA+")) {
|
|
115
|
+
add("divergingPrincipal", content.substr(5));
|
|
116
|
+
}
|
|
117
|
+
else if (content.startsWith("PURP+")) {
|
|
118
|
+
add("purpose", content.substr(5));
|
|
119
|
+
}
|
|
120
|
+
else if (content.startsWith("BREF+")) {
|
|
121
|
+
add("back", content.substr(5));
|
|
122
|
+
}
|
|
123
|
+
else if (content.startsWith("RREF+")) {
|
|
124
|
+
add("back", content.substr(5));
|
|
125
|
+
}
|
|
126
|
+
else if (content.startsWith("DATUM ")) {
|
|
127
|
+
result.date = parsePaymentReferenceDate(content);
|
|
128
|
+
}
|
|
129
|
+
else if (/\d+\.\s*TAN/.test(content)) {
|
|
130
|
+
result.tan = parsePaymentReferenceTan(content);
|
|
131
|
+
}
|
|
132
|
+
else if (lastIdentifiedAttribute) {
|
|
133
|
+
result[lastIdentifiedAttribute] += content;
|
|
134
|
+
}
|
|
135
|
+
result.raw += content;
|
|
136
|
+
return result;
|
|
137
|
+
});
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Parse as much information as possible from the structured 86 section of a MT940 statement list.
|
|
142
|
+
* Use `is86Structured` to sniff whether the payment reference is parsable.
|
|
143
|
+
*
|
|
144
|
+
* @param input The input string for the 86 section to parse.
|
|
145
|
+
*
|
|
146
|
+
* @return The parsed structured description.
|
|
147
|
+
*/
|
|
148
|
+
function parse86Structured(input) {
|
|
149
|
+
let iban;
|
|
150
|
+
let text;
|
|
151
|
+
let bic;
|
|
152
|
+
let primaNota;
|
|
153
|
+
let currentContent = "";
|
|
154
|
+
let inHeader = true;
|
|
155
|
+
let sectionCode;
|
|
156
|
+
const references = [];
|
|
157
|
+
const names = [];
|
|
158
|
+
// The header has been parsed fully. Store the section code and begin parsing the content.
|
|
159
|
+
const flushHeader = () => {
|
|
160
|
+
sectionCode = Number(currentContent);
|
|
161
|
+
currentContent = "";
|
|
162
|
+
inHeader = false;
|
|
163
|
+
};
|
|
164
|
+
// A questionmark has been encountered, hence the content of the current section is complete.
|
|
165
|
+
// Store the parsed data and continue to read the next header.
|
|
166
|
+
const flushSection = () => {
|
|
167
|
+
if (sectionCode === 0) {
|
|
168
|
+
text = currentContent;
|
|
169
|
+
}
|
|
170
|
+
else if (sectionCode === 10) {
|
|
171
|
+
primaNota = currentContent;
|
|
172
|
+
}
|
|
173
|
+
else if ((sectionCode >= 20 && sectionCode < 30) || (sectionCode >= 60 && sectionCode <= 63)) {
|
|
174
|
+
references.push({ code: sectionCode, content: currentContent });
|
|
175
|
+
}
|
|
176
|
+
else if (sectionCode === 30) {
|
|
177
|
+
bic = currentContent;
|
|
178
|
+
}
|
|
179
|
+
else if (sectionCode === 31) {
|
|
180
|
+
iban = currentContent;
|
|
181
|
+
}
|
|
182
|
+
else if (sectionCode >= 32 && sectionCode <= 33) {
|
|
183
|
+
names.push({ code: sectionCode, content: currentContent });
|
|
184
|
+
}
|
|
185
|
+
currentContent = "";
|
|
186
|
+
sectionCode = undefined;
|
|
187
|
+
inHeader = true;
|
|
188
|
+
};
|
|
189
|
+
// Read the string character by character and split it into sections.
|
|
190
|
+
for (let i = 0; i < input.length; ++i) {
|
|
191
|
+
const character = input[i];
|
|
192
|
+
if (character === "?") {
|
|
193
|
+
flushSection();
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
currentContent += character;
|
|
197
|
+
if (inHeader && currentContent.length === 2) {
|
|
198
|
+
flushHeader();
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// After parsing, flush the last section.
|
|
203
|
+
flushSection();
|
|
204
|
+
// The payment reference could have been using tags.
|
|
205
|
+
// Attempt to parse the tags.
|
|
206
|
+
const reference = assemblePaymentReference(references);
|
|
207
|
+
const name = names
|
|
208
|
+
.sort((a, b) => a.code - b.code)
|
|
209
|
+
.map((recipient) => recipient.content)
|
|
210
|
+
.join("");
|
|
211
|
+
return { reference, name, iban, text, bic, primaNota };
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=mt940-86-structured.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mt940-86-structured.js","sourceRoot":"","sources":["../src/mt940-86-structured.ts"],"names":[],"mappings":";;AAYA,wCAiBC;AASD,8DAMC;AASD,4DASC;AAUD,4DAiDC;AAUD,8CA2DC;AA5LD,MAAM,cAAc,GAAG,4BAA4B,CAAC;AAEpD;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,KAAa;IACxC,MAAM,OAAO,GAAsB,EAAE,CAAC;IACtC,IAAI,SAA0B,CAAC;IAC/B,GAAG,CAAC;QACA,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC,QAAQ,SAAS,EAAE;IACpB,MAAM,OAAO,GAAG,OAAO;SAClB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,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AAC;YAC1C,WAAW,EAAE,CAAC;YACd,SAAS;QACb,CAAC;IACL,CAAC;IACD,yCAAyC;IACzC,YAAY,EAAE,CAAC;IACf,oDAAoD;IACpD,6BAA6B;IAC7B,MAAM,SAAS,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,KAAK;SACb,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;SAC/B,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;SACrC,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholder definitions for SEPA pain.001.001.03 structures.
|
|
3
|
+
* The real XSD-derived types are not included in this repository.
|
|
4
|
+
*/
|
|
5
|
+
export interface Pain001Document {
|
|
6
|
+
Document: {
|
|
7
|
+
CstmrCdtTrfInitn: CustomerCreditTransferInitiationV03;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface CustomerCreditTransferInitiationV03 {
|
|
11
|
+
GrpHdr: {
|
|
12
|
+
CreDtTm: string;
|
|
13
|
+
CtrlSum: number;
|
|
14
|
+
};
|
|
15
|
+
PmtInf: PaymentInstructionInformationSCT | PaymentInstructionInformationSCT[];
|
|
16
|
+
}
|
|
17
|
+
export interface PaymentInstructionInformationSCT {
|
|
18
|
+
Dbtr: {
|
|
19
|
+
Nm: string;
|
|
20
|
+
};
|
|
21
|
+
DbtrAcct: {
|
|
22
|
+
Id: {
|
|
23
|
+
IBAN: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
DbtrAgt: {
|
|
27
|
+
FinInstnId: {
|
|
28
|
+
BIC: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
CdtTrfTxInf: CreditTransferTransactionInformationSCT | CreditTransferTransactionInformationSCT[];
|
|
32
|
+
}
|
|
33
|
+
export interface CreditTransferTransactionInformationSCT {
|
|
34
|
+
Cdtr: {
|
|
35
|
+
Nm: string;
|
|
36
|
+
};
|
|
37
|
+
CdtrAcct: {
|
|
38
|
+
Id: {
|
|
39
|
+
IBAN: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
CdtrAgt: {
|
|
43
|
+
FinInstnId: {
|
|
44
|
+
BIC: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
RmtInf: {
|
|
48
|
+
Ustrd: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pain-formats.js","sourceRoot":"","sources":["../src/pain-formats.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
package/dist/pain.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DirectDebitRequest, DirectDebitSubmission, SEPAAccount, CreditTransferRequest, CreditTransferSubmission } from "./types";
|
|
2
|
+
export interface Pain008Message {
|
|
3
|
+
xml: string;
|
|
4
|
+
messageId: string;
|
|
5
|
+
paymentInformationId: string;
|
|
6
|
+
endToEndId: string;
|
|
7
|
+
namespace: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Pain001Message {
|
|
10
|
+
xml: string;
|
|
11
|
+
messageId: string;
|
|
12
|
+
paymentInformationId: string;
|
|
13
|
+
endToEndId: string;
|
|
14
|
+
namespace: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function selectPain001Descriptor(painFormats: string[]): string;
|
|
17
|
+
export declare function selectPain008Descriptor(painFormats: string[]): string;
|
|
18
|
+
export declare function buildPain008(request: DirectDebitRequest, account: SEPAAccount, descriptor: string): Pain008Message;
|
|
19
|
+
export declare function buildPain001(request: CreditTransferRequest, account: SEPAAccount, descriptor: string): Pain001Message;
|
|
20
|
+
export declare function buildDirectDebitSubmission(request: DirectDebitRequest, account: SEPAAccount, descriptor: string): DirectDebitSubmission;
|
|
21
|
+
export declare function buildCreditTransferSubmission(request: CreditTransferRequest, account: SEPAAccount, descriptor: string): CreditTransferSubmission;
|