bysquare 2.8.1 → 2.8.2

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/decode.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { decompress } from "lzma1";
2
2
  import { base32hex } from "rfc4648";
3
+ import { CurrencyCode, PaymentOptions, Version, } from "./index.js";
3
4
  function cleanUndefined(obj) {
4
5
  Object.keys(obj).forEach((key) => {
5
6
  if (typeof obj[key] === "undefined") {
@@ -33,7 +34,7 @@ export function deserialize(qr) {
33
34
  let payment = {
34
35
  bankAccounts: [],
35
36
  type: Number(paymentOptions),
36
- currencyCode: currency ?? "EUR" /* CurrencyCode.EUR */,
37
+ currencyCode: currency ?? CurrencyCode.EUR,
37
38
  amount: ammount?.length
38
39
  ? Number(ammount)
39
40
  : undefined,
@@ -76,9 +77,9 @@ export function deserialize(qr) {
76
77
  data.shift(); // DirectDebitExt
77
78
  // narrowing payment type
78
79
  switch (payment.type) {
79
- case 1 /* PaymentOptions.PaymentOrder */:
80
+ case PaymentOptions.PaymentOrder:
80
81
  break;
81
- case 2 /* PaymentOptions.StandingOrder */:
82
+ case PaymentOptions.StandingOrder:
82
83
  payment = {
83
84
  ...payment,
84
85
  day: Number(data.shift()),
@@ -87,7 +88,7 @@ export function deserialize(qr) {
87
88
  lastDate: data.shift(),
88
89
  };
89
90
  break;
90
- case 4 /* PaymentOptions.DirectDebit */:
91
+ case PaymentOptions.DirectDebit:
91
92
  payment = {
92
93
  ...payment,
93
94
  directDebitScheme: Number(data.shift()),
@@ -172,7 +173,7 @@ export function decode(qr) {
172
173
  throw new DecodeError(error, "Unable to decode QR string base32hex encoding");
173
174
  }
174
175
  const bysquareHeader = bytes.slice(0, 2);
175
- if ((bysquareHeaderDecoder(bysquareHeader).version > 1 /* Version["1.1.0"] */)) {
176
+ if ((bysquareHeaderDecoder(bysquareHeader).version > Version["1.1.0"])) {
176
177
  throw new Error("Unsupported Bysquare version");
177
178
  }
178
179
  /**
@@ -238,7 +239,7 @@ export function detect(qr) {
238
239
  const isValid = [bysquareType, version, documentType, reserved]
239
240
  .every((nibble, index) => {
240
241
  if (index === 1) {
241
- return nibble <= 1 /* Version["1.1.0"] */;
242
+ return nibble <= Version["1.1.0"];
242
243
  }
243
244
  return 0x00 <= nibble && nibble <= 0x0F;
244
245
  });
package/dist/encode.js CHANGED
@@ -2,6 +2,7 @@ import crc32 from "crc-32";
2
2
  import deburr from "lodash.deburr";
3
3
  import { compress } from "lzma1";
4
4
  import { base32hex } from "rfc4648";
5
+ import { PaymentOptions } from "./types.js";
5
6
  /**
6
7
  * Returns a 2 byte buffer that represents the header of the bysquare
7
8
  * specification
@@ -86,7 +87,7 @@ export function serialize(data) {
86
87
  serialized.push(ba.iban);
87
88
  serialized.push(ba.bic);
88
89
  }
89
- if (p.type === 2 /* PaymentOptions.StandingOrder */) {
90
+ if (p.type === PaymentOptions.StandingOrder) {
90
91
  serialized.push("1");
91
92
  serialized.push(p.day?.toString());
92
93
  serialized.push(p.month?.toString());
@@ -96,7 +97,7 @@ export function serialize(data) {
96
97
  else {
97
98
  serialized.push("0");
98
99
  }
99
- if (p.type === 4 /* PaymentOptions.DirectDebit */) {
100
+ if (p.type === PaymentOptions.DirectDebit) {
100
101
  serialized.push("1");
101
102
  serialized.push(p.directDebitScheme?.toString());
102
103
  serialized.push(p.directDebitType?.toString());
package/dist/types.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * It's a bit silly to limit the version number to 4-bit, if they keep
5
5
  * increasing the version number, the latest possible mapped value is 16
6
6
  */
7
- export declare const enum Version {
7
+ export declare enum Version {
8
8
  /**
9
9
  * 2013-02-22
10
10
  * Created this document from original by square specifications
@@ -19,7 +19,7 @@ export declare const enum Version {
19
19
  /**
20
20
  * Kalendárny mesiac.
21
21
  */
22
- export declare const enum MonthClassifier {
22
+ export declare enum MonthClassifier {
23
23
  January = 1,
24
24
  February = 2,
25
25
  March = 4,
@@ -38,7 +38,7 @@ export declare const enum MonthClassifier {
38
38
  * medzi 1 a 31. Deň v týždni je číslo medzi 1 a 7 (1 = pondelok, 2=utorok, …, 7
39
39
  * = nedeľa).
40
40
  */
41
- export declare const enum Periodicity {
41
+ export declare enum Periodicity {
42
42
  Daily = "d",
43
43
  Weekly = "w",
44
44
  Biweekly = "b",
@@ -64,7 +64,7 @@ export type Day = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 1
64
64
  * - standingorder: trvalý príkaz, údaje sa vyplnia do StandingOrderExt
65
65
  * - directdebit: inkaso, údaje sa vyplnia do DirectDebitExt
66
66
  */
67
- export declare const enum PaymentOptions {
67
+ export declare enum PaymentOptions {
68
68
  PaymentOrder = 1,
69
69
  StandingOrder = 2,
70
70
  DirectDebit = 4
@@ -97,7 +97,7 @@ export type BankAccount = {
97
97
  * SEPA - Inkaso zodpovedá schéme
98
98
  * SEPA. other - iné
99
99
  */
100
- export declare const enum DirectDebitScheme {
100
+ export declare enum DirectDebitScheme {
101
101
  Other = 0,
102
102
  Sepa = 1
103
103
  }
@@ -109,7 +109,7 @@ export declare const enum DirectDebitScheme {
109
109
  * one-off - jednorázové inkaso
110
110
  * recurrent - opakované inkaso
111
111
  */
112
- export declare const enum DirectDebitType {
112
+ export declare enum DirectDebitType {
113
113
  OneOff = 0,
114
114
  Recurrent = 1
115
115
  }
@@ -286,7 +286,7 @@ export type DataModel = {
286
286
  /**
287
287
  * ISO-4217
288
288
  */
289
- export declare const enum CurrencyCode {
289
+ export declare enum CurrencyCode {
290
290
  AED = "AED",
291
291
  AFN = "AFN",
292
292
  ALL = "ALL",
package/dist/types.js CHANGED
@@ -1 +1,254 @@
1
- export {};
1
+ /**
2
+ * Mapping semantic version to encoded version number, header 4-bits
3
+ *
4
+ * It's a bit silly to limit the version number to 4-bit, if they keep
5
+ * increasing the version number, the latest possible mapped value is 16
6
+ */
7
+ export var Version;
8
+ (function (Version) {
9
+ /**
10
+ * 2013-02-22
11
+ * Created this document from original by square specifications
12
+ */
13
+ Version[Version["1.0.0"] = 0] = "1.0.0";
14
+ /**
15
+ * 2015-06-24
16
+ * Added fields for beneficiary name and address
17
+ */
18
+ Version[Version["1.1.0"] = 1] = "1.1.0";
19
+ })(Version || (Version = {}));
20
+ /**
21
+ * Kalendárny mesiac.
22
+ */
23
+ export var MonthClassifier;
24
+ (function (MonthClassifier) {
25
+ MonthClassifier[MonthClassifier["January"] = 1] = "January";
26
+ MonthClassifier[MonthClassifier["February"] = 2] = "February";
27
+ MonthClassifier[MonthClassifier["March"] = 4] = "March";
28
+ MonthClassifier[MonthClassifier["April"] = 8] = "April";
29
+ MonthClassifier[MonthClassifier["May"] = 16] = "May";
30
+ MonthClassifier[MonthClassifier["June"] = 32] = "June";
31
+ MonthClassifier[MonthClassifier["July"] = 64] = "July";
32
+ MonthClassifier[MonthClassifier["August"] = 128] = "August";
33
+ MonthClassifier[MonthClassifier["September"] = 256] = "September";
34
+ MonthClassifier[MonthClassifier["October"] = 512] = "October";
35
+ MonthClassifier[MonthClassifier["November"] = 1024] = "November";
36
+ MonthClassifier[MonthClassifier["December"] = 2048] = "December";
37
+ })(MonthClassifier || (MonthClassifier = {}));
38
+ /**
39
+ * Deň platby vyplývajúci z opakovania (Periodicity). Deň v mesiaci je číslo
40
+ * medzi 1 a 31. Deň v týždni je číslo medzi 1 a 7 (1 = pondelok, 2=utorok, …, 7
41
+ * = nedeľa).
42
+ */
43
+ export var Periodicity;
44
+ (function (Periodicity) {
45
+ Periodicity["Daily"] = "d";
46
+ Periodicity["Weekly"] = "w";
47
+ Periodicity["Biweekly"] = "b";
48
+ Periodicity["Monthly"] = "m";
49
+ Periodicity["Bimonthly"] = "B";
50
+ Periodicity["Quarterly"] = "q";
51
+ Periodicity["Semiannually"] = "s";
52
+ Periodicity["Annually"] = "a";
53
+ })(Periodicity || (Periodicity = {}));
54
+ /**
55
+ * Možnosti platby sa dajú kombinovať. Oddeľujú sa medzerou a treba uviesť vždy
56
+ * aspoň jednu z možností:
57
+ *
58
+ * - paymentorder: platobný príkaz
59
+ * - standingorder: trvalý príkaz, údaje sa vyplnia do StandingOrderExt
60
+ * - directdebit: inkaso, údaje sa vyplnia do DirectDebitExt
61
+ */
62
+ export var PaymentOptions;
63
+ (function (PaymentOptions) {
64
+ PaymentOptions[PaymentOptions["PaymentOrder"] = 1] = "PaymentOrder";
65
+ PaymentOptions[PaymentOptions["StandingOrder"] = 2] = "StandingOrder";
66
+ PaymentOptions[PaymentOptions["DirectDebit"] = 4] = "DirectDebit";
67
+ })(PaymentOptions || (PaymentOptions = {}));
68
+ /**
69
+ * Inksaná schéma. Uvádza ja jedna z možností:
70
+ *
71
+ * SEPA - Inkaso zodpovedá schéme
72
+ * SEPA. other - iné
73
+ */
74
+ export var DirectDebitScheme;
75
+ (function (DirectDebitScheme) {
76
+ DirectDebitScheme[DirectDebitScheme["Other"] = 0] = "Other";
77
+ DirectDebitScheme[DirectDebitScheme["Sepa"] = 1] = "Sepa";
78
+ })(DirectDebitScheme || (DirectDebitScheme = {}));
79
+ /**
80
+ * Maximálna dĺžka 1
81
+ *
82
+ * Typ inkasa. Uvádza ja jedna z možností:
83
+ *
84
+ * one-off - jednorázové inkaso
85
+ * recurrent - opakované inkaso
86
+ */
87
+ export var DirectDebitType;
88
+ (function (DirectDebitType) {
89
+ DirectDebitType[DirectDebitType["OneOff"] = 0] = "OneOff";
90
+ DirectDebitType[DirectDebitType["Recurrent"] = 1] = "Recurrent";
91
+ })(DirectDebitType || (DirectDebitType = {}));
92
+ /**
93
+ * ISO-4217
94
+ */
95
+ export var CurrencyCode;
96
+ (function (CurrencyCode) {
97
+ CurrencyCode["AED"] = "AED";
98
+ CurrencyCode["AFN"] = "AFN";
99
+ CurrencyCode["ALL"] = "ALL";
100
+ CurrencyCode["AMD"] = "AMD";
101
+ CurrencyCode["ANG"] = "ANG";
102
+ CurrencyCode["AOA"] = "AOA";
103
+ CurrencyCode["ARS"] = "ARS";
104
+ CurrencyCode["AUD"] = "AUD";
105
+ CurrencyCode["AWG"] = "AWG";
106
+ CurrencyCode["AZN"] = "AZN";
107
+ CurrencyCode["BAM"] = "BAM";
108
+ CurrencyCode["BBD"] = "BBD";
109
+ CurrencyCode["BDT"] = "BDT";
110
+ CurrencyCode["BGN"] = "BGN";
111
+ CurrencyCode["BHD"] = "BHD";
112
+ CurrencyCode["BIF"] = "BIF";
113
+ CurrencyCode["BMD"] = "BMD";
114
+ CurrencyCode["BND"] = "BND";
115
+ CurrencyCode["BOB"] = "BOB";
116
+ CurrencyCode["BRL"] = "BRL";
117
+ CurrencyCode["BSD"] = "BSD";
118
+ CurrencyCode["BTN"] = "BTN";
119
+ CurrencyCode["BWP"] = "BWP";
120
+ CurrencyCode["BYN"] = "BYN";
121
+ CurrencyCode["BZD"] = "BZD";
122
+ CurrencyCode["CAD"] = "CAD";
123
+ CurrencyCode["CDF"] = "CDF";
124
+ CurrencyCode["CHF"] = "CHF";
125
+ CurrencyCode["CLP"] = "CLP";
126
+ CurrencyCode["CNY"] = "CNY";
127
+ CurrencyCode["COP"] = "COP";
128
+ CurrencyCode["CRC"] = "CRC";
129
+ CurrencyCode["CUC"] = "CUC";
130
+ CurrencyCode["CUP"] = "CUP";
131
+ CurrencyCode["CVE"] = "CVE";
132
+ CurrencyCode["CZK"] = "CZK";
133
+ CurrencyCode["DJF"] = "DJF";
134
+ CurrencyCode["DKK"] = "DKK";
135
+ CurrencyCode["DOP"] = "DOP";
136
+ CurrencyCode["DZD"] = "DZD";
137
+ CurrencyCode["EGP"] = "EGP";
138
+ CurrencyCode["ERN"] = "ERN";
139
+ CurrencyCode["ETB"] = "ETB";
140
+ CurrencyCode["EUR"] = "EUR";
141
+ CurrencyCode["FJD"] = "FJD";
142
+ CurrencyCode["FKP"] = "FKP";
143
+ CurrencyCode["GBP"] = "GBP";
144
+ CurrencyCode["GEL"] = "GEL";
145
+ CurrencyCode["GHS"] = "GHS";
146
+ CurrencyCode["GIP"] = "GIP";
147
+ CurrencyCode["GMD"] = "GMD";
148
+ CurrencyCode["GNF"] = "GNF";
149
+ CurrencyCode["GTQ"] = "GTQ";
150
+ CurrencyCode["GYD"] = "GYD";
151
+ CurrencyCode["HKD"] = "HKD";
152
+ CurrencyCode["HNL"] = "HNL";
153
+ CurrencyCode["HRK"] = "HRK";
154
+ CurrencyCode["HTG"] = "HTG";
155
+ CurrencyCode["HUF"] = "HUF";
156
+ CurrencyCode["IDR"] = "IDR";
157
+ CurrencyCode["ILS"] = "ILS";
158
+ CurrencyCode["INR"] = "INR";
159
+ CurrencyCode["IQD"] = "IQD";
160
+ CurrencyCode["IRR"] = "IRR";
161
+ CurrencyCode["ISK"] = "ISK";
162
+ CurrencyCode["JMD"] = "JMD";
163
+ CurrencyCode["JOD"] = "JOD";
164
+ CurrencyCode["JPY"] = "JPY";
165
+ CurrencyCode["KES"] = "KES";
166
+ CurrencyCode["KGS"] = "KGS";
167
+ CurrencyCode["KHR"] = "KHR";
168
+ CurrencyCode["KMF"] = "KMF";
169
+ CurrencyCode["KPW"] = "KPW";
170
+ CurrencyCode["KRW"] = "KRW";
171
+ CurrencyCode["KWD"] = "KWD";
172
+ CurrencyCode["KYD"] = "KYD";
173
+ CurrencyCode["KZT"] = "KZT";
174
+ CurrencyCode["LAK"] = "LAK";
175
+ CurrencyCode["LBP"] = "LBP";
176
+ CurrencyCode["LKR"] = "LKR";
177
+ CurrencyCode["LRD"] = "LRD";
178
+ CurrencyCode["LSL"] = "LSL";
179
+ CurrencyCode["LYD"] = "LYD";
180
+ CurrencyCode["MAD"] = "MAD";
181
+ CurrencyCode["MDL"] = "MDL";
182
+ CurrencyCode["MGA"] = "MGA";
183
+ CurrencyCode["MKD"] = "MKD";
184
+ CurrencyCode["MMK"] = "MMK";
185
+ CurrencyCode["MNT"] = "MNT";
186
+ CurrencyCode["MOP"] = "MOP";
187
+ CurrencyCode["MRU"] = "MRU";
188
+ CurrencyCode["MUR"] = "MUR";
189
+ CurrencyCode["MVR"] = "MVR";
190
+ CurrencyCode["MWK"] = "MWK";
191
+ CurrencyCode["MXN"] = "MXN";
192
+ CurrencyCode["MYR"] = "MYR";
193
+ CurrencyCode["MZN"] = "MZN";
194
+ CurrencyCode["NAD"] = "NAD";
195
+ CurrencyCode["NGN"] = "NGN";
196
+ CurrencyCode["NIO"] = "NIO";
197
+ CurrencyCode["NOK"] = "NOK";
198
+ CurrencyCode["NPR"] = "NPR";
199
+ CurrencyCode["NZD"] = "NZD";
200
+ CurrencyCode["OMR"] = "OMR";
201
+ CurrencyCode["PAB"] = "PAB";
202
+ CurrencyCode["PEN"] = "PEN";
203
+ CurrencyCode["PGK"] = "PGK";
204
+ CurrencyCode["PHP"] = "PHP";
205
+ CurrencyCode["PKR"] = "PKR";
206
+ CurrencyCode["PLN"] = "PLN";
207
+ CurrencyCode["PYG"] = "PYG";
208
+ CurrencyCode["QAR"] = "QAR";
209
+ CurrencyCode["RON"] = "RON";
210
+ CurrencyCode["RSD"] = "RSD";
211
+ CurrencyCode["RUB"] = "RUB";
212
+ CurrencyCode["RWF"] = "RWF";
213
+ CurrencyCode["SAR"] = "SAR";
214
+ CurrencyCode["SBD"] = "SBD";
215
+ CurrencyCode["SCR"] = "SCR";
216
+ CurrencyCode["SDG"] = "SDG";
217
+ CurrencyCode["SEK"] = "SEK";
218
+ CurrencyCode["SGD"] = "SGD";
219
+ CurrencyCode["SHP"] = "SHP";
220
+ CurrencyCode["SLL"] = "SLL";
221
+ CurrencyCode["SOS"] = "SOS";
222
+ CurrencyCode["SRD"] = "SRD";
223
+ CurrencyCode["SSP"] = "SSP";
224
+ CurrencyCode["STN"] = "STN";
225
+ CurrencyCode["SVC"] = "SVC";
226
+ CurrencyCode["SYP"] = "SYP";
227
+ CurrencyCode["SZL"] = "SZL";
228
+ CurrencyCode["THB"] = "THB";
229
+ CurrencyCode["TJS"] = "TJS";
230
+ CurrencyCode["TMT"] = "TMT";
231
+ CurrencyCode["TND"] = "TND";
232
+ CurrencyCode["TOP"] = "TOP";
233
+ CurrencyCode["TRY"] = "TRY";
234
+ CurrencyCode["TTD"] = "TTD";
235
+ CurrencyCode["TWD"] = "TWD";
236
+ CurrencyCode["TZS"] = "TZS";
237
+ CurrencyCode["UAH"] = "UAH";
238
+ CurrencyCode["UGX"] = "UGX";
239
+ CurrencyCode["USD"] = "USD";
240
+ CurrencyCode["UYU"] = "UYU";
241
+ CurrencyCode["UZS"] = "UZS";
242
+ CurrencyCode["VES"] = "VES";
243
+ CurrencyCode["VND"] = "VND";
244
+ CurrencyCode["VUV"] = "VUV";
245
+ CurrencyCode["WST"] = "WST";
246
+ CurrencyCode["XAF"] = "XAF";
247
+ CurrencyCode["XCD"] = "XCD";
248
+ CurrencyCode["XOF"] = "XOF";
249
+ CurrencyCode["XPF"] = "XPF";
250
+ CurrencyCode["YER"] = "YER";
251
+ CurrencyCode["ZAR"] = "ZAR";
252
+ CurrencyCode["ZMW"] = "ZMW";
253
+ CurrencyCode["ZWL"] = "ZWL";
254
+ })(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.8.1",
4
+ "version": "2.8.2",
5
5
  "license": "Apache-2.0",
6
6
  "funding": "https://github.com/sponsors/xseman",
7
7
  "homepage": "https://github.com/xseman/bysquare#readme",