bysquare 2.4.0 → 2.5.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/dist/types.js ADDED
@@ -0,0 +1,235 @@
1
+ /**
2
+ * Kalendárny mesiac.
3
+ */
4
+ export var MonthClassifier;
5
+ (function (MonthClassifier) {
6
+ MonthClassifier[MonthClassifier["January"] = 1] = "January";
7
+ MonthClassifier[MonthClassifier["February"] = 2] = "February";
8
+ MonthClassifier[MonthClassifier["March"] = 4] = "March";
9
+ MonthClassifier[MonthClassifier["April"] = 8] = "April";
10
+ MonthClassifier[MonthClassifier["May"] = 16] = "May";
11
+ MonthClassifier[MonthClassifier["June"] = 32] = "June";
12
+ MonthClassifier[MonthClassifier["July"] = 64] = "July";
13
+ MonthClassifier[MonthClassifier["August"] = 128] = "August";
14
+ MonthClassifier[MonthClassifier["September"] = 256] = "September";
15
+ MonthClassifier[MonthClassifier["October"] = 512] = "October";
16
+ MonthClassifier[MonthClassifier["November"] = 1024] = "November";
17
+ MonthClassifier[MonthClassifier["December"] = 2048] = "December";
18
+ })(MonthClassifier || (MonthClassifier = {}));
19
+ /**
20
+ * Deň platby vyplývajúci z opakovania (Periodicity). Deň v mesiaci je číslo
21
+ * medzi 1 a 31. Deň v týždni je číslo medzi 1 a 7 (1 = pondelok, 2=utorok, …, 7
22
+ * = nedeľa).
23
+ */
24
+ export var Periodicity;
25
+ (function (Periodicity) {
26
+ Periodicity["Daily"] = "d";
27
+ Periodicity["Weekly"] = "w";
28
+ Periodicity["Biweekly"] = "b";
29
+ Periodicity["Monthly"] = "m";
30
+ Periodicity["Bimonthly"] = "B";
31
+ Periodicity["Quarterly"] = "q";
32
+ Periodicity["Semiannually"] = "s";
33
+ Periodicity["Annually"] = "a";
34
+ })(Periodicity || (Periodicity = {}));
35
+ /**
36
+ * Možnosti platby sa dajú kombinovať. Oddeľujú sa medzerou a treba uviesť vždy
37
+ * aspoň jednu z možností:
38
+ *
39
+ * - paymentorder: platobný príkaz
40
+ * - standingorder: trvalý príkaz, údaje sa vyplnia do StandingOrderExt
41
+ * - directdebit: inkaso, údaje sa vyplnia do DirectDebitExt
42
+ */
43
+ export var PaymentOptions;
44
+ (function (PaymentOptions) {
45
+ PaymentOptions[PaymentOptions["PaymentOrder"] = 1] = "PaymentOrder";
46
+ PaymentOptions[PaymentOptions["StandingOrder"] = 2] = "StandingOrder";
47
+ PaymentOptions[PaymentOptions["DirectDebit"] = 4] = "DirectDebit";
48
+ })(PaymentOptions || (PaymentOptions = {}));
49
+ /**
50
+ * Inksaná schéma. Uvádza ja jedna z možností:
51
+ *
52
+ * SEPA - Inkaso zodpovedá schéme
53
+ * SEPA. other - iné
54
+ */
55
+ export var DirectDebitScheme;
56
+ (function (DirectDebitScheme) {
57
+ DirectDebitScheme[DirectDebitScheme["Other"] = 0] = "Other";
58
+ DirectDebitScheme[DirectDebitScheme["Sepa"] = 1] = "Sepa";
59
+ })(DirectDebitScheme || (DirectDebitScheme = {}));
60
+ /**
61
+ * Maximálna dĺžka 1
62
+ *
63
+ * Typ inkasa. Uvádza ja jedna z možností:
64
+ *
65
+ * one-off - jednorázové inkaso
66
+ * recurrent - opakované inkaso
67
+ */
68
+ export var DirectDebitType;
69
+ (function (DirectDebitType) {
70
+ DirectDebitType[DirectDebitType["OneOff"] = 0] = "OneOff";
71
+ DirectDebitType[DirectDebitType["Recurrent"] = 1] = "Recurrent";
72
+ })(DirectDebitType || (DirectDebitType = {}));
73
+ /**
74
+ * ISO-4217
75
+ */
76
+ export var CurrencyCode;
77
+ (function (CurrencyCode) {
78
+ CurrencyCode["AED"] = "AED";
79
+ CurrencyCode["AFN"] = "AFN";
80
+ CurrencyCode["ALL"] = "ALL";
81
+ CurrencyCode["AMD"] = "AMD";
82
+ CurrencyCode["ANG"] = "ANG";
83
+ CurrencyCode["AOA"] = "AOA";
84
+ CurrencyCode["ARS"] = "ARS";
85
+ CurrencyCode["AUD"] = "AUD";
86
+ CurrencyCode["AWG"] = "AWG";
87
+ CurrencyCode["AZN"] = "AZN";
88
+ CurrencyCode["BAM"] = "BAM";
89
+ CurrencyCode["BBD"] = "BBD";
90
+ CurrencyCode["BDT"] = "BDT";
91
+ CurrencyCode["BGN"] = "BGN";
92
+ CurrencyCode["BHD"] = "BHD";
93
+ CurrencyCode["BIF"] = "BIF";
94
+ CurrencyCode["BMD"] = "BMD";
95
+ CurrencyCode["BND"] = "BND";
96
+ CurrencyCode["BOB"] = "BOB";
97
+ CurrencyCode["BRL"] = "BRL";
98
+ CurrencyCode["BSD"] = "BSD";
99
+ CurrencyCode["BTN"] = "BTN";
100
+ CurrencyCode["BWP"] = "BWP";
101
+ CurrencyCode["BYN"] = "BYN";
102
+ CurrencyCode["BZD"] = "BZD";
103
+ CurrencyCode["CAD"] = "CAD";
104
+ CurrencyCode["CDF"] = "CDF";
105
+ CurrencyCode["CHF"] = "CHF";
106
+ CurrencyCode["CLP"] = "CLP";
107
+ CurrencyCode["CNY"] = "CNY";
108
+ CurrencyCode["COP"] = "COP";
109
+ CurrencyCode["CRC"] = "CRC";
110
+ CurrencyCode["CUC"] = "CUC";
111
+ CurrencyCode["CUP"] = "CUP";
112
+ CurrencyCode["CVE"] = "CVE";
113
+ CurrencyCode["CZK"] = "CZK";
114
+ CurrencyCode["DJF"] = "DJF";
115
+ CurrencyCode["DKK"] = "DKK";
116
+ CurrencyCode["DOP"] = "DOP";
117
+ CurrencyCode["DZD"] = "DZD";
118
+ CurrencyCode["EGP"] = "EGP";
119
+ CurrencyCode["ERN"] = "ERN";
120
+ CurrencyCode["ETB"] = "ETB";
121
+ CurrencyCode["EUR"] = "EUR";
122
+ CurrencyCode["FJD"] = "FJD";
123
+ CurrencyCode["FKP"] = "FKP";
124
+ CurrencyCode["GBP"] = "GBP";
125
+ CurrencyCode["GEL"] = "GEL";
126
+ CurrencyCode["GHS"] = "GHS";
127
+ CurrencyCode["GIP"] = "GIP";
128
+ CurrencyCode["GMD"] = "GMD";
129
+ CurrencyCode["GNF"] = "GNF";
130
+ CurrencyCode["GTQ"] = "GTQ";
131
+ CurrencyCode["GYD"] = "GYD";
132
+ CurrencyCode["HKD"] = "HKD";
133
+ CurrencyCode["HNL"] = "HNL";
134
+ CurrencyCode["HRK"] = "HRK";
135
+ CurrencyCode["HTG"] = "HTG";
136
+ CurrencyCode["HUF"] = "HUF";
137
+ CurrencyCode["IDR"] = "IDR";
138
+ CurrencyCode["ILS"] = "ILS";
139
+ CurrencyCode["INR"] = "INR";
140
+ CurrencyCode["IQD"] = "IQD";
141
+ CurrencyCode["IRR"] = "IRR";
142
+ CurrencyCode["ISK"] = "ISK";
143
+ CurrencyCode["JMD"] = "JMD";
144
+ CurrencyCode["JOD"] = "JOD";
145
+ CurrencyCode["JPY"] = "JPY";
146
+ CurrencyCode["KES"] = "KES";
147
+ CurrencyCode["KGS"] = "KGS";
148
+ CurrencyCode["KHR"] = "KHR";
149
+ CurrencyCode["KMF"] = "KMF";
150
+ CurrencyCode["KPW"] = "KPW";
151
+ CurrencyCode["KRW"] = "KRW";
152
+ CurrencyCode["KWD"] = "KWD";
153
+ CurrencyCode["KYD"] = "KYD";
154
+ CurrencyCode["KZT"] = "KZT";
155
+ CurrencyCode["LAK"] = "LAK";
156
+ CurrencyCode["LBP"] = "LBP";
157
+ CurrencyCode["LKR"] = "LKR";
158
+ CurrencyCode["LRD"] = "LRD";
159
+ CurrencyCode["LSL"] = "LSL";
160
+ CurrencyCode["LYD"] = "LYD";
161
+ CurrencyCode["MAD"] = "MAD";
162
+ CurrencyCode["MDL"] = "MDL";
163
+ CurrencyCode["MGA"] = "MGA";
164
+ CurrencyCode["MKD"] = "MKD";
165
+ CurrencyCode["MMK"] = "MMK";
166
+ CurrencyCode["MNT"] = "MNT";
167
+ CurrencyCode["MOP"] = "MOP";
168
+ CurrencyCode["MRU"] = "MRU";
169
+ CurrencyCode["MUR"] = "MUR";
170
+ CurrencyCode["MVR"] = "MVR";
171
+ CurrencyCode["MWK"] = "MWK";
172
+ CurrencyCode["MXN"] = "MXN";
173
+ CurrencyCode["MYR"] = "MYR";
174
+ CurrencyCode["MZN"] = "MZN";
175
+ CurrencyCode["NAD"] = "NAD";
176
+ CurrencyCode["NGN"] = "NGN";
177
+ CurrencyCode["NIO"] = "NIO";
178
+ CurrencyCode["NOK"] = "NOK";
179
+ CurrencyCode["NPR"] = "NPR";
180
+ CurrencyCode["NZD"] = "NZD";
181
+ CurrencyCode["OMR"] = "OMR";
182
+ CurrencyCode["PAB"] = "PAB";
183
+ CurrencyCode["PEN"] = "PEN";
184
+ CurrencyCode["PGK"] = "PGK";
185
+ CurrencyCode["PHP"] = "PHP";
186
+ CurrencyCode["PKR"] = "PKR";
187
+ CurrencyCode["PLN"] = "PLN";
188
+ CurrencyCode["PYG"] = "PYG";
189
+ CurrencyCode["QAR"] = "QAR";
190
+ CurrencyCode["RON"] = "RON";
191
+ CurrencyCode["RSD"] = "RSD";
192
+ CurrencyCode["RUB"] = "RUB";
193
+ CurrencyCode["RWF"] = "RWF";
194
+ CurrencyCode["SAR"] = "SAR";
195
+ CurrencyCode["SBD"] = "SBD";
196
+ CurrencyCode["SCR"] = "SCR";
197
+ CurrencyCode["SDG"] = "SDG";
198
+ CurrencyCode["SEK"] = "SEK";
199
+ CurrencyCode["SGD"] = "SGD";
200
+ CurrencyCode["SHP"] = "SHP";
201
+ CurrencyCode["SLL"] = "SLL";
202
+ CurrencyCode["SOS"] = "SOS";
203
+ CurrencyCode["SRD"] = "SRD";
204
+ CurrencyCode["SSP"] = "SSP";
205
+ CurrencyCode["STN"] = "STN";
206
+ CurrencyCode["SVC"] = "SVC";
207
+ CurrencyCode["SYP"] = "SYP";
208
+ CurrencyCode["SZL"] = "SZL";
209
+ CurrencyCode["THB"] = "THB";
210
+ CurrencyCode["TJS"] = "TJS";
211
+ CurrencyCode["TMT"] = "TMT";
212
+ CurrencyCode["TND"] = "TND";
213
+ CurrencyCode["TOP"] = "TOP";
214
+ CurrencyCode["TRY"] = "TRY";
215
+ CurrencyCode["TTD"] = "TTD";
216
+ CurrencyCode["TWD"] = "TWD";
217
+ CurrencyCode["TZS"] = "TZS";
218
+ CurrencyCode["UAH"] = "UAH";
219
+ CurrencyCode["UGX"] = "UGX";
220
+ CurrencyCode["USD"] = "USD";
221
+ CurrencyCode["UYU"] = "UYU";
222
+ CurrencyCode["UZS"] = "UZS";
223
+ CurrencyCode["VES"] = "VES";
224
+ CurrencyCode["VND"] = "VND";
225
+ CurrencyCode["VUV"] = "VUV";
226
+ CurrencyCode["WST"] = "WST";
227
+ CurrencyCode["XAF"] = "XAF";
228
+ CurrencyCode["XCD"] = "XCD";
229
+ CurrencyCode["XOF"] = "XOF";
230
+ CurrencyCode["XPF"] = "XPF";
231
+ CurrencyCode["YER"] = "YER";
232
+ CurrencyCode["ZAR"] = "ZAR";
233
+ CurrencyCode["ZMW"] = "ZMW";
234
+ CurrencyCode["ZWL"] = "ZWL";
235
+ })(CurrencyCode || (CurrencyCode = {}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bysquare",
3
3
  "description": "It's a national standard for payment QR codes adopted by Slovak Banking Association (SBA)",
4
- "version": "2.4.0",
4
+ "version": "2.5.0",
5
5
  "license": "Apache-2.0",
6
6
  "funding": "https://github.com/sponsors/xseman",
7
7
  "homepage": "https://github.com/xseman/bysquare#readme",
@@ -17,20 +17,20 @@
17
17
  "url": "git+https://github.com/xseman/bysquare.git"
18
18
  },
19
19
  "scripts": {
20
- "prebuild": "rm -rf ./lib || :",
21
- "build": ".scripts/build.sh",
22
- "postbuild": ".scripts/postbuild.sh",
20
+ "prebuild": "tsc --build --clean",
21
+ "build": "tsc --build",
22
+ "format": "dprint fmt ./src/**/*",
23
+ "typecheck": "tsc --noEmit",
23
24
  "test": "xv --loader=tsx ./src",
24
25
  "test:watch": "xv --loader=tsx --watch ./src",
25
- "typecheck": "tsc --noEmit",
26
26
  "cli:local": "npm run build && npm link bysquare",
27
- "preversion": "git checkout develop",
28
- "postversion": "npm run build && git flow release start v${npm_package_version}"
27
+ "version": "git checkout develop && npm test",
28
+ "postversion": "echo 'Now run npm run build && npm publish'"
29
29
  },
30
30
  "dependencies": {
31
31
  "crc-32": "~1.2.0",
32
32
  "lodash.deburr": "~4.1.0",
33
- "lzma1": "~0.0.1",
33
+ "lzma1": "0.0.2",
34
34
  "rfc4648": "~1.5.0"
35
35
  },
36
36
  "devDependencies": {
@@ -42,20 +42,21 @@
42
42
  "xv": "~2.1.0"
43
43
  },
44
44
  "type": "module",
45
- "bin": "lib/mjs/cli.js",
46
- "types": "lib/mjs/index.d.ts",
45
+ "bin": "./dist/cli.js",
46
+ "types": "./dist/index.d.ts",
47
+ "main": "./dist/index.js",
48
+ "module": "./dist/index.js",
47
49
  "exports": {
48
50
  ".": {
49
- "require": "./lib/cjs/index.js",
50
- "import": "./lib/mjs/index.js"
51
+ "import": "./dist/index.js"
51
52
  }
52
53
  },
53
54
  "files": [
54
- "lib",
55
- "!lib/*.test.*"
55
+ "dist",
56
+ "!dist/*.test.*"
56
57
  ],
57
58
  "engines": {
58
- "node": ">=16.14",
59
+ "node": ">=14.13.1 || >=16.0.0",
59
60
  "npm": ">=7.0"
60
61
  }
61
62
  }
package/lib/cjs/cli.js DELETED
@@ -1,88 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const node_fs_1 = require("node:fs");
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const node_readline_1 = require("node:readline");
10
- const generate_js_1 = require("./generate.js");
11
- if /** bysquare "file" */ (process.stdin.isTTY) {
12
- handleInput(process.argv[2]);
13
- } /** bysquare <<< "data" */
14
- else {
15
- ;
16
- (async () => {
17
- const stdin = await handleStdin();
18
- console.log(fromJsonString(stdin));
19
- process.exit(0);
20
- })();
21
- }
22
- function handleInput(input) {
23
- if (input === undefined || input === "-h" || input === "--help") {
24
- console.log(help());
25
- process.exit(0);
26
- }
27
- if ((0, node_fs_1.existsSync)(process.argv[2])) {
28
- const file = (0, node_fs_1.readFileSync)(process.argv[2], "utf8");
29
- console.log(fromJsonString(file));
30
- }
31
- else {
32
- console.error(`File ${process.argv[2]} doesn't exists`);
33
- process.exit(1);
34
- }
35
- }
36
- function fromJsonString(stdin) {
37
- const data = JSON.parse(stdin);
38
- return (0, generate_js_1.generate)(data);
39
- }
40
- async function handleStdin() {
41
- const readline = (0, node_readline_1.createInterface)({
42
- input: process.stdin,
43
- output: process.stdout,
44
- terminal: false
45
- });
46
- const lines = [];
47
- return new Promise((resolve, reject) => {
48
- readline
49
- .on("line", (line) => {
50
- lines.push(line);
51
- })
52
- .on("close", () => {
53
- resolve(lines.join(""));
54
- })
55
- .on("SIGINT", /* CTRL+C */ reject);
56
- });
57
- }
58
- function help() {
59
- const exe = node_path_1.default.basename(process.argv[1]);
60
- return [
61
- "Simple Node.js library to generate 'PAY by square' QR string.",
62
- "",
63
- "Usage:",
64
- ` ${exe} file`,
65
- "",
66
- "File:",
67
- " Valid json file",
68
- "",
69
- "Flags:",
70
- " -h, --help display this help and exit",
71
- "",
72
- "If <file> is omitted, reads from stdin.",
73
- "",
74
- "Examples:",
75
- " bysquare <<< \"{",
76
- " \"invoiceId\": \"random-id\",",
77
- " \"payments\": [",
78
- " {",
79
- " \"type\": 1,",
80
- " \"amount\": 100.0,",
81
- " \"bankAccounts\": [{ \"iban\": \"SK9611000000002918599669\" }],",
82
- " \"currencyCode\": \"EUR\",",
83
- " \"variableSymbol\": \"123\"",
84
- " }",
85
- " ]",
86
- " }\""
87
- ].join("\n");
88
- }
@@ -1,175 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generate = exports.serialize = exports.addChecksum = exports.headerDataLength = exports.headerBysquare = void 0;
7
- const crc_32_1 = __importDefault(require("crc-32"));
8
- const lodash_deburr_1 = __importDefault(require("lodash.deburr"));
9
- const lzma1_1 = require("lzma1");
10
- const rfc4648_1 = require("rfc4648");
11
- const types_js_1 = require("./types.js");
12
- /**
13
- * Returns a 2 byte buffer that represents the header of the bysquare
14
- * specification
15
- *
16
- * ```
17
- * | Attribute | Number of bits | Possible values | Note
18
- * --------------------------------------------------------------------------------------------
19
- * | BySquareType | 4 | 0-15 | by square type
20
- * | Version | 4 | 0-15 | version of the by square type
21
- * | DocumentType | 4 | 0-15 | document type within given by square type
22
- * | Reserved | 4 | 0-15 | bits reserved for future needs
23
- * ```
24
- *
25
- * @see 3.5.
26
- */
27
- function headerBysquare(
28
- /** dprint-ignore */
29
- header = [
30
- 0x00, 0x00,
31
- 0x00, 0x00
32
- ]) {
33
- const isValid = header.every((nibble) => 0 <= nibble && nibble <= 15);
34
- if (!isValid) {
35
- throw new Error("Invalid header byte value, valid range <0,15>");
36
- }
37
- const [bySquareType, version, documentType, reserved] = header;
38
- // Combine 4-nibbles to 2-bytes
39
- const mergedNibbles = Uint8Array.from([
40
- (bySquareType << 4) | (version << 0),
41
- (documentType << 4) | (reserved << 0)
42
- ]);
43
- return mergedNibbles;
44
- }
45
- exports.headerBysquare = headerBysquare;
46
- /**
47
- * Creates a one-byte array that represents the length of compressed data in
48
- * combination with CRC32 in bytes.
49
- */
50
- function headerDataLength(length) {
51
- if (length >= 131072 /** 2^17 */) {
52
- throw new Error("The maximum compressed data size has been reached");
53
- }
54
- const header = new ArrayBuffer(2);
55
- new DataView(header).setUint16(0, length);
56
- return new Uint8Array(header);
57
- }
58
- exports.headerDataLength = headerDataLength;
59
- /**
60
- * Transfer object to a tabbed string and append a CRC32 checksum
61
- *
62
- * @see 3.10.
63
- */
64
- function addChecksum(serialized) {
65
- const checksum = new ArrayBuffer(4);
66
- new DataView(checksum).setUint32(0, crc_32_1.default.str(serialized), true);
67
- const byteArray = new TextEncoder().encode(serialized);
68
- return Uint8Array.from([
69
- ...new Uint8Array(checksum),
70
- ...Uint8Array.from(byteArray)
71
- ]);
72
- }
73
- exports.addChecksum = addChecksum;
74
- /**
75
- * Transform data to ordered tab-separated intermediate representation ready for
76
- * encoding
77
- *
78
- * @see Table 15.
79
- */
80
- function serialize(data) {
81
- const serialized = new Array();
82
- serialized.push(data.invoiceId?.toString());
83
- serialized.push(data.payments.length.toString());
84
- for (const p of data.payments) {
85
- serialized.push(p.type.toString());
86
- serialized.push(p.amount?.toString());
87
- serialized.push(p.currencyCode);
88
- serialized.push(p.paymentDueDate);
89
- serialized.push(p.variableSymbol);
90
- serialized.push(p.constantSymbol);
91
- serialized.push(p.specificSymbol);
92
- serialized.push(p.originatorRefInfo);
93
- serialized.push(p.paymentNote);
94
- serialized.push(p.bankAccounts.length.toString());
95
- for (const ba of p.bankAccounts) {
96
- serialized.push(ba.iban);
97
- serialized.push(ba.bic);
98
- }
99
- if (p.type === types_js_1.PaymentOptions.StandingOrder) {
100
- serialized.push("1");
101
- serialized.push(p.day?.toString());
102
- serialized.push(p.month?.toString());
103
- serialized.push(p.periodicity);
104
- serialized.push(p.lastDate);
105
- }
106
- else {
107
- serialized.push("0");
108
- }
109
- if (p.type === types_js_1.PaymentOptions.DirectDebit) {
110
- serialized.push("1");
111
- serialized.push(p.directDebitScheme?.toString());
112
- serialized.push(p.directDebitType?.toString());
113
- serialized.push(p.variableSymbol?.toString());
114
- serialized.push(p.specificSymbol?.toString());
115
- serialized.push(p.originatorRefInfo?.toString());
116
- serialized.push(p.mandateId?.toString());
117
- serialized.push(p.creditorId?.toString());
118
- serialized.push(p.contractId?.toString());
119
- serialized.push(p.maxAmount?.toString());
120
- serialized.push(p.validTillDate?.toString());
121
- }
122
- else {
123
- serialized.push("0");
124
- }
125
- }
126
- for (const p of data.payments) {
127
- serialized.push(p.beneficiary?.name);
128
- serialized.push(p.beneficiary?.street);
129
- serialized.push(p.beneficiary?.city);
130
- }
131
- return serialized.join("\t");
132
- }
133
- exports.serialize = serialize;
134
- function removeDiacritics(model) {
135
- for (const payment of model.payments) {
136
- if (payment.paymentNote) {
137
- payment.paymentNote = (0, lodash_deburr_1.default)(payment.paymentNote);
138
- }
139
- if (payment.beneficiary?.name) {
140
- payment.beneficiary.name = (0, lodash_deburr_1.default)(payment.beneficiary.name);
141
- }
142
- if (payment.beneficiary?.city) {
143
- payment.beneficiary.city = (0, lodash_deburr_1.default)(payment.beneficiary.city);
144
- }
145
- if (payment.beneficiary?.street) {
146
- payment.beneficiary.street = (0, lodash_deburr_1.default)(payment.beneficiary.street);
147
- }
148
- }
149
- }
150
- /**
151
- * Generate QR string ready for encoding into text QR code
152
- */
153
- function generate(model, options = { deburr: true }) {
154
- if (options.deburr) {
155
- removeDiacritics(model);
156
- }
157
- const payload = serialize(model);
158
- const withChecksum = addChecksum(payload);
159
- const compressed = Uint8Array.from((0, lzma1_1.compress)(withChecksum));
160
- const _lzmaHeader = Uint8Array.from(compressed.subarray(0, 13));
161
- const lzmaBody = Uint8Array.from(compressed.subarray(13));
162
- const output = Uint8Array.from([
163
- // FIXME:
164
- // for now other implementation of bysquare doesn't recognize header if
165
- // version is specified like TatraBanka
166
- // ...headerBysquare([0x00, Version["1.1.0"], 0x00, 0x00]),
167
- ...headerBysquare([0x00, 0x00, 0x00, 0x00]),
168
- ...headerDataLength(withChecksum.byteLength),
169
- ...lzmaBody
170
- ]);
171
- return rfc4648_1.base32hex.stringify(output, {
172
- pad: false
173
- });
174
- }
175
- exports.generate = generate;
package/lib/cjs/index.js DELETED
@@ -1,23 +0,0 @@
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
- exports.parse = exports.detect = exports.generate = void 0;
18
- var generate_js_1 = require("./generate.js");
19
- Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return generate_js_1.generate; } });
20
- var parse_js_1 = require("./parse.js");
21
- Object.defineProperty(exports, "detect", { enumerable: true, get: function () { return parse_js_1.detect; } });
22
- Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_js_1.parse; } });
23
- __exportStar(require("./types.js"), exports);
@@ -1,61 +0,0 @@
1
- {
2
- "name": "bysquare",
3
- "description": "It's a national standard for payment QR codes adopted by Slovak Banking Association (SBA)",
4
- "version": "2.4.0",
5
- "license": "Apache-2.0",
6
- "funding": "https://github.com/sponsors/xseman",
7
- "homepage": "https://github.com/xseman/bysquare#readme",
8
- "author": "Filip Seman <filip.seman@pm.me>",
9
- "keywords": [
10
- "pay by square",
11
- "qr string",
12
- "paybysquare",
13
- "bysquare"
14
- ],
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/xseman/bysquare.git"
18
- },
19
- "scripts": {
20
- "prebuild": "rm -rf ./lib || :",
21
- "build": ".scripts/build.sh",
22
- "postbuild": ".scripts/postbuild.sh",
23
- "test": "xv --loader=tsx ./src",
24
- "test:watch": "xv --loader=tsx --watch ./src",
25
- "typecheck": "tsc --noEmit",
26
- "cli:local": "npm run build && npm link bysquare",
27
- "preversion": "git checkout develop",
28
- "postversion": "npm run build && git flow release start v${npm_package_version}"
29
- },
30
- "dependencies": {
31
- "crc-32": "~1.2.0",
32
- "lodash.deburr": "~4.1.0",
33
- "lzma1": "~0.0.1",
34
- "rfc4648": "~1.5.0"
35
- },
36
- "devDependencies": {
37
- "@types/lodash.deburr": "~4.1.0",
38
- "@types/node": ">=16.14",
39
- "dprint": "~0.36.0",
40
- "tsx": "~3.12.0",
41
- "typescript": "~5.0.0",
42
- "xv": "~2.1.0"
43
- },
44
- "type": "commonjs",
45
- "bin": "lib/mjs/cli.js",
46
- "types": "lib/mjs/index.d.ts",
47
- "exports": {
48
- ".": {
49
- "require": "./lib/cjs/index.js",
50
- "import": "./lib/mjs/index.js"
51
- }
52
- },
53
- "files": [
54
- "lib",
55
- "!lib/*.test.*"
56
- ],
57
- "engines": {
58
- "node": ">=16.14",
59
- "npm": ">=7.0"
60
- }
61
- }