bysquare 2.8.0 → 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/README.md +58 -43
- package/dist/cli.js +13 -13
- package/dist/decode.d.ts +0 -1
- package/dist/decode.js +52 -49
- package/dist/encode.js +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.js +19 -0
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# bysquare
|
|
2
2
|
|
|
3
|
-
![version][version]
|
|
4
|
-
![build][build]
|
|
5
|
-
|
|
6
3
|
Simple JavaScript library to encode and decode "PAY by square" string.
|
|
7
4
|
|
|
8
5
|
**What is `PAY by square`?**
|
|
@@ -17,55 +14,58 @@ This library doesn't have a specific opinion and how the QR code string is
|
|
|
17
14
|
transformed into images depends on how you implement it. See
|
|
18
15
|
[examples](./docs/examples/).
|
|
19
16
|
|
|
20
|
-
##
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- Encode data to qr string
|
|
20
|
+
- Decode data to json
|
|
21
|
+
- Detect bysquare from qr string
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
21
24
|
|
|
22
25
|
**NOTE**: This package is native [ESM][mozzila-esm] and no longer provides a
|
|
23
26
|
CommonJS export. If your project uses CommonJS, you will have to convert to ESM
|
|
24
27
|
or use the dynamic [`import()`][mozzila-import] function.
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
[mozzila-esm]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
30
|
+
[mozzila-import]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import
|
|
31
|
+
|
|
32
|
+
### npm registry
|
|
27
33
|
|
|
28
34
|
```sh
|
|
29
35
|
npm install bysquare
|
|
30
36
|
```
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
### CLI Node `v18+`
|
|
33
39
|
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
import { encode, decode } from "https://esm.sh/bysquare@2.7.1/";
|
|
37
|
-
</script>
|
|
40
|
+
```sh
|
|
41
|
+
npm install --global bysquare
|
|
38
42
|
```
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
### deno
|
|
45
|
+
|
|
46
|
+
Since `v1.28+` import from npm registry using `npm:` prefix.
|
|
41
47
|
|
|
42
48
|
```ts
|
|
43
|
-
import {
|
|
49
|
+
import { decode, encode } from "npm:bysquare@2.8.0";
|
|
44
50
|
```
|
|
45
51
|
|
|
46
|
-
|
|
52
|
+
### Browser
|
|
47
53
|
|
|
48
|
-
```
|
|
49
|
-
|
|
54
|
+
```html
|
|
55
|
+
<script type="module">
|
|
56
|
+
import { encode, decode } from "https://esm.sh/bysquare@2.8.0/";
|
|
57
|
+
</script>
|
|
50
58
|
```
|
|
51
59
|
|
|
52
|
-
|
|
60
|
+
## How it works
|
|
53
61
|
|
|
54
|
-
|
|
62
|
+
### Encoding sequence
|
|
55
63
|
|
|
56
64
|

|
|
57
65
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
```ts
|
|
61
|
-
encode(model: DataModel, options?: Options): string
|
|
62
|
-
decode(qr: string): DataModel
|
|
63
|
-
detect(qr: string): Boolean
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
# Usage
|
|
66
|
+
## Usage
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
### Encode
|
|
69
69
|
|
|
70
70
|
```ts
|
|
71
71
|
import { CurrencyCode, DataModel, encode, PaymentOptions } from "bysquare";
|
|
@@ -89,13 +89,13 @@ const qrString = encode({
|
|
|
89
89
|
});
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
### Decode
|
|
93
93
|
|
|
94
94
|
```ts
|
|
95
95
|
import { decode } from "bysquare";
|
|
96
96
|
|
|
97
97
|
const model = decode(
|
|
98
|
-
"0405QH8090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6CB54HSI0KH9FCRASHNQBSKAQD2LJ4AU400UVKDNDPFRKLOBEVVVU0QJ000"
|
|
98
|
+
"0405QH8090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6CB54HSI0KH9FCRASHNQBSKAQD2LJ4AU400UVKDNDPFRKLOBEVVVU0QJ000",
|
|
99
99
|
);
|
|
100
100
|
|
|
101
101
|
// {
|
|
@@ -115,9 +115,9 @@ const model = decode(
|
|
|
115
115
|
//
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
## CLI
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
### Encode
|
|
121
121
|
|
|
122
122
|
Encode JSON or JSONL data from files and print the corresponding QR code.
|
|
123
123
|
|
|
@@ -126,7 +126,7 @@ npx bysquare --encode file1.json file2.json...
|
|
|
126
126
|
npx bysquare --encode file.jsonl
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
### Decode
|
|
130
130
|
|
|
131
131
|
Decode the specified QR code string and print the corresponding JSON data. The
|
|
132
132
|
qrstring argument should be a valid QR code string.
|
|
@@ -135,16 +135,31 @@ qrstring argument should be a valid QR code string.
|
|
|
135
135
|
npx bysquare --decode <qrstring>
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
##
|
|
138
|
+
## Platform support
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
- <https://github.com/matusf/pay-by-square>
|
|
143
|
-
- <https://www.bsqr.co/schema/>
|
|
144
|
-
- <https://www.sbaonline.sk/wp-content/uploads/2020/03/pay-by-square-specifications-1_1_0.pdf>
|
|
145
|
-
- <https://www.vutbr.cz/studenti/zav-prace/detail/78439>
|
|
140
|
+
I mainly focus on LTS versions of Node.js and try to use the most idiomatic
|
|
141
|
+
ECMAScript possible to avoid specific runtime coupling.
|
|
146
142
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
143
|
+
This doesn't mean that the library won't work on older versions, but it might
|
|
144
|
+
not be as reliable.
|
|
145
|
+
|
|
146
|
+
As of `v1.28`, Deno now includes built-in support for npm modules and is ready
|
|
147
|
+
to use without additional setup, showing its improved maturity.
|
|
148
|
+
|
|
149
|
+
### Node.js & Deno
|
|
150
|
+
|
|
151
|
+
- Node.js `v18` and later.
|
|
152
|
+
- Deno `v1.28` and later.
|
|
153
|
+
|
|
154
|
+
### Browser
|
|
155
|
+
|
|
156
|
+
The latest version of Chrome, Firefox, and Safari.
|
|
157
|
+
|
|
158
|
+
## Related
|
|
159
|
+
|
|
160
|
+
- <https://bysquare.com/>
|
|
161
|
+
- <https://devel.cz/otazka/qr-kod-pay-by-square>
|
|
162
|
+
- <https://github.com/matusf/pay-by-square>
|
|
163
|
+
- <https://www.bsqr.co/schema/>
|
|
164
|
+
- <https://www.sbaonline.sk/wp-content/uploads/2020/03/pay-by-square-specifications-1_1_0.pdf>
|
|
165
|
+
- <https://www.vutbr.cz/studenti/zav-prace/detail/78439>
|
package/dist/cli.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { parseArgs } from "node:util";
|
|
4
3
|
import process from "node:process";
|
|
5
|
-
import {
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
6
5
|
import { decode } from "./decode.js";
|
|
6
|
+
import { encode } from "./encode.js";
|
|
7
7
|
const args = parseArgs({
|
|
8
8
|
allowPositionals: true,
|
|
9
9
|
options: {
|
|
10
10
|
decode: {
|
|
11
11
|
type: "string",
|
|
12
|
-
short: "d"
|
|
12
|
+
short: "d",
|
|
13
13
|
},
|
|
14
14
|
encode: {
|
|
15
15
|
type: "boolean",
|
|
16
|
-
short: "e"
|
|
16
|
+
short: "e",
|
|
17
17
|
},
|
|
18
18
|
help: {
|
|
19
19
|
type: "boolean",
|
|
20
|
-
short: "h"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
20
|
+
short: "h",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
23
|
});
|
|
24
24
|
if (process.stdin.isTTY) {
|
|
25
25
|
if (args.values.encode) {
|
|
@@ -32,14 +32,14 @@ if (process.stdin.isTTY) {
|
|
|
32
32
|
console.error(`File ${file} doesn't exist`);
|
|
33
33
|
process.exit(1);
|
|
34
34
|
}
|
|
35
|
-
if (file.endsWith(".json") === false
|
|
36
|
-
file.endsWith(".jsonl") === false) {
|
|
35
|
+
if (file.endsWith(".json") === false
|
|
36
|
+
&& file.endsWith(".jsonl") === false) {
|
|
37
37
|
console.error(`Unsupported file format for ${file}`);
|
|
38
38
|
process.exit(1);
|
|
39
39
|
}
|
|
40
40
|
const data = readFileSync(file, "utf8");
|
|
41
41
|
if (file.endsWith(".jsonl")) {
|
|
42
|
-
const lines = data.split(
|
|
42
|
+
const lines = data.split("\n");
|
|
43
43
|
for (const line of lines) {
|
|
44
44
|
if (!line)
|
|
45
45
|
continue;
|
|
@@ -58,8 +58,8 @@ if (process.stdin.isTTY) {
|
|
|
58
58
|
console.log(JSON.stringify(decode(qrstring), null, 4));
|
|
59
59
|
process.exit(0);
|
|
60
60
|
}
|
|
61
|
-
if (args.values.help
|
|
62
|
-
Object.keys(args.values).length === 0) {
|
|
61
|
+
if (args.values.help
|
|
62
|
+
|| Object.keys(args.values).length === 0) {
|
|
63
63
|
console.log([
|
|
64
64
|
"NAME",
|
|
65
65
|
" bysquare - Simple Node.js library to generate and parse PAY bysquare standard",
|
|
@@ -96,7 +96,7 @@ if (process.stdin.isTTY) {
|
|
|
96
96
|
` ${process.argv[1]} --decode <qrstring>`,
|
|
97
97
|
" Replace qrstring with the QR code string you want to decode.",
|
|
98
98
|
" The program will parse the QR code string and print the resulting JSON data.",
|
|
99
|
-
""
|
|
99
|
+
"",
|
|
100
100
|
].join("\n"));
|
|
101
101
|
}
|
|
102
102
|
}
|
package/dist/decode.d.ts
CHANGED
package/dist/decode.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decompress } from "lzma1";
|
|
2
2
|
import { base32hex } from "rfc4648";
|
|
3
|
-
import { PaymentOptions } from "./index.js";
|
|
3
|
+
import { CurrencyCode, PaymentOptions, Version, } from "./index.js";
|
|
4
4
|
function cleanUndefined(obj) {
|
|
5
5
|
Object.keys(obj).forEach((key) => {
|
|
6
6
|
if (typeof obj[key] === "undefined") {
|
|
@@ -14,27 +14,27 @@ function cleanUndefined(obj) {
|
|
|
14
14
|
* @see 3.14.
|
|
15
15
|
*/
|
|
16
16
|
export function deserialize(qr) {
|
|
17
|
-
const
|
|
18
|
-
const invoiceId =
|
|
17
|
+
const data = qr.split("\t");
|
|
18
|
+
const invoiceId = data.shift();
|
|
19
19
|
const output = {
|
|
20
20
|
invoiceId: invoiceId?.length ? invoiceId : undefined,
|
|
21
|
-
payments:
|
|
21
|
+
payments: new Array(),
|
|
22
22
|
};
|
|
23
|
-
const paymentslen = Number(
|
|
23
|
+
const paymentslen = Number(data.shift());
|
|
24
24
|
for (let i = 0; i < paymentslen; i++) {
|
|
25
|
-
const paymentOptions =
|
|
26
|
-
const ammount =
|
|
27
|
-
const currency =
|
|
28
|
-
const dueDate =
|
|
29
|
-
const variables =
|
|
30
|
-
const constants =
|
|
31
|
-
const specifics =
|
|
32
|
-
const originatorRefInfo =
|
|
33
|
-
const paymentNote =
|
|
25
|
+
const paymentOptions = data.shift();
|
|
26
|
+
const ammount = data.shift();
|
|
27
|
+
const currency = data.shift();
|
|
28
|
+
const dueDate = data.shift();
|
|
29
|
+
const variables = data.shift();
|
|
30
|
+
const constants = data.shift();
|
|
31
|
+
const specifics = data.shift();
|
|
32
|
+
const originatorRefInfo = data.shift();
|
|
33
|
+
const paymentNote = data.shift();
|
|
34
34
|
let payment = {
|
|
35
35
|
bankAccounts: [],
|
|
36
36
|
type: Number(paymentOptions),
|
|
37
|
-
currencyCode: currency,
|
|
37
|
+
currencyCode: currency ?? CurrencyCode.EUR,
|
|
38
38
|
amount: ammount?.length
|
|
39
39
|
? Number(ammount)
|
|
40
40
|
: undefined,
|
|
@@ -55,26 +55,26 @@ export function deserialize(qr) {
|
|
|
55
55
|
: undefined,
|
|
56
56
|
paymentNote: paymentNote?.length
|
|
57
57
|
? paymentNote
|
|
58
|
-
: undefined
|
|
58
|
+
: undefined,
|
|
59
59
|
};
|
|
60
|
-
const accountslen = Number(
|
|
60
|
+
const accountslen = Number(data.shift());
|
|
61
61
|
for (let j = 0; j < accountslen; j++) {
|
|
62
|
-
const iban =
|
|
62
|
+
const iban = data.shift();
|
|
63
63
|
if (iban === undefined || iban.length === 0) {
|
|
64
64
|
throw new Error("Missing IBAN");
|
|
65
65
|
}
|
|
66
|
-
const bic =
|
|
66
|
+
const bic = data.shift();
|
|
67
67
|
const account = {
|
|
68
68
|
iban: iban,
|
|
69
69
|
bic: bic?.length
|
|
70
70
|
? bic
|
|
71
|
-
: undefined
|
|
71
|
+
: undefined,
|
|
72
72
|
};
|
|
73
73
|
cleanUndefined(account);
|
|
74
74
|
payment.bankAccounts.push(account);
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
data.shift(); // StandingOrderExt
|
|
77
|
+
data.shift(); // DirectDebitExt
|
|
78
78
|
// narrowing payment type
|
|
79
79
|
switch (payment.type) {
|
|
80
80
|
case PaymentOptions.PaymentOrder:
|
|
@@ -82,22 +82,22 @@ export function deserialize(qr) {
|
|
|
82
82
|
case PaymentOptions.StandingOrder:
|
|
83
83
|
payment = {
|
|
84
84
|
...payment,
|
|
85
|
-
day: Number(
|
|
86
|
-
month: Number(
|
|
87
|
-
periodicity:
|
|
88
|
-
lastDate:
|
|
85
|
+
day: Number(data.shift()),
|
|
86
|
+
month: Number(data.shift()),
|
|
87
|
+
periodicity: data.shift(),
|
|
88
|
+
lastDate: data.shift(),
|
|
89
89
|
};
|
|
90
90
|
break;
|
|
91
91
|
case PaymentOptions.DirectDebit:
|
|
92
92
|
payment = {
|
|
93
93
|
...payment,
|
|
94
|
-
directDebitScheme: Number(
|
|
95
|
-
directDebitType: Number(
|
|
96
|
-
mandateId:
|
|
97
|
-
creditorId:
|
|
98
|
-
contractId:
|
|
99
|
-
maxAmount: Number(
|
|
100
|
-
validTillDate:
|
|
94
|
+
directDebitScheme: Number(data.shift()),
|
|
95
|
+
directDebitType: Number(data.shift()),
|
|
96
|
+
mandateId: data.shift(),
|
|
97
|
+
creditorId: data.shift(),
|
|
98
|
+
contractId: data.shift(),
|
|
99
|
+
maxAmount: Number(data.shift()),
|
|
100
|
+
validTillDate: data.shift(),
|
|
101
101
|
};
|
|
102
102
|
break;
|
|
103
103
|
default:
|
|
@@ -107,9 +107,9 @@ export function deserialize(qr) {
|
|
|
107
107
|
output.payments.push(payment);
|
|
108
108
|
}
|
|
109
109
|
for (let i = 0; i < paymentslen; i++) {
|
|
110
|
-
const name =
|
|
111
|
-
const addressLine1 =
|
|
112
|
-
const addressLine2 =
|
|
110
|
+
const name = data.shift();
|
|
111
|
+
const addressLine1 = data.shift();
|
|
112
|
+
const addressLine2 = data.shift();
|
|
113
113
|
if (Boolean(name) || Boolean(addressLine1) || Boolean(addressLine2)) {
|
|
114
114
|
const beneficiary = {
|
|
115
115
|
name: name?.length
|
|
@@ -120,7 +120,7 @@ export function deserialize(qr) {
|
|
|
120
120
|
: undefined,
|
|
121
121
|
city: addressLine2?.length
|
|
122
122
|
? addressLine2
|
|
123
|
-
: undefined
|
|
123
|
+
: undefined,
|
|
124
124
|
};
|
|
125
125
|
cleanUndefined(beneficiary);
|
|
126
126
|
output.payments[i].beneficiary = beneficiary;
|
|
@@ -145,14 +145,15 @@ function bysquareHeaderDecoder(header) {
|
|
|
145
145
|
bysquareType,
|
|
146
146
|
version,
|
|
147
147
|
documentType,
|
|
148
|
-
reserved
|
|
148
|
+
reserved,
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
export class DecodeError extends Error {
|
|
152
|
+
cause;
|
|
153
|
+
name = "DecodeError";
|
|
152
154
|
constructor(cause, msg) {
|
|
153
155
|
super(msg);
|
|
154
156
|
this.cause = cause;
|
|
155
|
-
this.name = "DecodeError";
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
/** @deprecated */
|
|
@@ -161,19 +162,18 @@ export const parse = decode;
|
|
|
161
162
|
* Decoding client data from QR Code 2005 symbol
|
|
162
163
|
*
|
|
163
164
|
* @see 3.16.
|
|
164
|
-
*
|
|
165
165
|
*/
|
|
166
166
|
export function decode(qr) {
|
|
167
167
|
try {
|
|
168
168
|
var bytes = base32hex.parse(qr, {
|
|
169
|
-
loose: true
|
|
169
|
+
loose: true,
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
catch (error) {
|
|
173
173
|
throw new DecodeError(error, "Unable to decode QR string base32hex encoding");
|
|
174
174
|
}
|
|
175
175
|
const bysquareHeader = bytes.slice(0, 2);
|
|
176
|
-
if ((bysquareHeaderDecoder(bysquareHeader).version >
|
|
176
|
+
if ((bysquareHeaderDecoder(bysquareHeader).version > Version["1.1.0"])) {
|
|
177
177
|
throw new Error("Unsupported Bysquare version");
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
@@ -195,22 +195,25 @@ export function decode(qr) {
|
|
|
195
195
|
const header = new Uint8Array([
|
|
196
196
|
...defaultProperties,
|
|
197
197
|
...defaultDictionarySize,
|
|
198
|
-
...uncompressedSize
|
|
198
|
+
...uncompressedSize,
|
|
199
199
|
]);
|
|
200
200
|
const payload = bytes.slice(4);
|
|
201
201
|
const body = new Uint8Array([
|
|
202
202
|
...header,
|
|
203
|
-
...payload
|
|
203
|
+
...payload,
|
|
204
204
|
]);
|
|
205
205
|
try {
|
|
206
|
-
var decompressed =
|
|
206
|
+
var decompressed = decompress(body);
|
|
207
207
|
}
|
|
208
208
|
catch (error) {
|
|
209
209
|
throw new DecodeError(error, "LZMA decompression failed");
|
|
210
210
|
}
|
|
211
|
+
if (typeof decompressed === "string") {
|
|
212
|
+
return deserialize(decompressed);
|
|
213
|
+
}
|
|
211
214
|
const _checksum = decompressed.slice(0, 4);
|
|
212
215
|
const decompressedBody = decompressed.slice(4);
|
|
213
|
-
const decoded = new TextDecoder("utf-8").decode(decompressedBody);
|
|
216
|
+
const decoded = new TextDecoder("utf-8").decode(decompressedBody.buffer);
|
|
214
217
|
return deserialize(decoded);
|
|
215
218
|
}
|
|
216
219
|
/**
|
|
@@ -222,7 +225,7 @@ export function decode(qr) {
|
|
|
222
225
|
export function detect(qr) {
|
|
223
226
|
try {
|
|
224
227
|
var parsed = base32hex.parse(qr, {
|
|
225
|
-
loose: true
|
|
228
|
+
loose: true,
|
|
226
229
|
});
|
|
227
230
|
}
|
|
228
231
|
catch {
|
|
@@ -232,11 +235,11 @@ export function detect(qr) {
|
|
|
232
235
|
return false;
|
|
233
236
|
}
|
|
234
237
|
const bysquareHeader = parsed.subarray(0, 2);
|
|
235
|
-
const { bysquareType, version, documentType, reserved } = bysquareHeaderDecoder(bysquareHeader);
|
|
238
|
+
const { bysquareType, version, documentType, reserved, } = bysquareHeaderDecoder(bysquareHeader);
|
|
236
239
|
const isValid = [bysquareType, version, documentType, reserved]
|
|
237
240
|
.every((nibble, index) => {
|
|
238
241
|
if (index === 1) {
|
|
239
|
-
return nibble <=
|
|
242
|
+
return nibble <= Version["1.1.0"];
|
|
240
243
|
}
|
|
241
244
|
return 0x00 <= nibble && nibble <= 0x0F;
|
|
242
245
|
});
|
package/dist/encode.js
CHANGED
|
@@ -28,11 +28,11 @@ header = [
|
|
|
28
28
|
if (!isValid) {
|
|
29
29
|
throw new Error("Invalid header byte value, valid range <0,15>");
|
|
30
30
|
}
|
|
31
|
-
const [bySquareType, version, documentType, reserved] = header;
|
|
31
|
+
const [bySquareType, version, documentType, reserved,] = header;
|
|
32
32
|
// Combine 4-nibbles to 2-bytes
|
|
33
33
|
const mergedNibbles = Uint8Array.from([
|
|
34
34
|
(bySquareType << 4) | (version << 0),
|
|
35
|
-
(documentType << 4) | (reserved << 0)
|
|
35
|
+
(documentType << 4) | (reserved << 0),
|
|
36
36
|
]);
|
|
37
37
|
return mergedNibbles;
|
|
38
38
|
}
|
|
@@ -59,7 +59,7 @@ export function addChecksum(serialized) {
|
|
|
59
59
|
const byteArray = new TextEncoder().encode(serialized);
|
|
60
60
|
return Uint8Array.from([
|
|
61
61
|
...new Uint8Array(checksum),
|
|
62
|
-
...Uint8Array.from(byteArray)
|
|
62
|
+
...Uint8Array.from(byteArray),
|
|
63
63
|
]);
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
@@ -158,9 +158,9 @@ export function encode(model, options = { deburr: true }) {
|
|
|
158
158
|
// ...headerBysquare([0x00, Version["1.1.0"], 0x00, 0x00]),
|
|
159
159
|
...headerBysquare([0x00, 0x00, 0x00, 0x00]),
|
|
160
160
|
...headerDataLength(withChecksum.byteLength),
|
|
161
|
-
...lzmaBody
|
|
161
|
+
...lzmaBody,
|
|
162
162
|
]);
|
|
163
163
|
return base32hex.stringify(output, {
|
|
164
|
-
pad: false
|
|
164
|
+
pad: false,
|
|
165
165
|
});
|
|
166
166
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
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
|
|
7
|
+
export declare enum Version {
|
|
8
8
|
/**
|
|
9
9
|
* 2013-02-22
|
|
10
10
|
* Created this document from original by square specifications
|
|
@@ -149,7 +149,7 @@ export type SimplePayment = {
|
|
|
149
149
|
*
|
|
150
150
|
* Mena v ISO 4217 formáte (3 písmená). Príklad: "EUR"
|
|
151
151
|
*/
|
|
152
|
-
currencyCode: CurrencyCode;
|
|
152
|
+
currencyCode: string | CurrencyCode;
|
|
153
153
|
/**
|
|
154
154
|
* Formát YYYYMMDD
|
|
155
155
|
*
|
|
@@ -210,7 +210,7 @@ export type StandingOrder = SimplePayment & {
|
|
|
210
210
|
* medzi 1 a 31. Deň v týždni je číslo medzi 1 a 7 (1 = pondelok, 2 =utorok,
|
|
211
211
|
* …, 7 = nedeľa).
|
|
212
212
|
*/
|
|
213
|
-
day?: Day;
|
|
213
|
+
day?: number | Day;
|
|
214
214
|
/**
|
|
215
215
|
* Medzerou oddelený zoznam mesiacov, v ktoré sa má platba uskutočniť.
|
|
216
216
|
*/
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
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 = {}));
|
|
1
20
|
/**
|
|
2
21
|
* Kalendárny mesiac.
|
|
3
22
|
*/
|
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.
|
|
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",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"prebuild": "tsc --build --clean",
|
|
21
21
|
"build": "tsc --build",
|
|
22
|
-
"
|
|
22
|
+
"fmt": "dprint fmt ./src/**/*",
|
|
23
23
|
"typecheck": "tsc --noEmit",
|
|
24
24
|
"version": "git checkout develop && npm test",
|
|
25
25
|
"postversion": "echo 'Now run npm run build && npm publish'",
|
|
26
|
-
"test": "node --test --loader
|
|
27
|
-
"test:watch": "node --test --watch --loader
|
|
26
|
+
"test": "TS_NODE_TRANSPILE_ONLY=true node --test --loader=ts-node/esm --no-warnings src/*.test.ts",
|
|
27
|
+
"test:watch": "TS_NODE_TRANSPILE_ONLY=true node --test --watch --loader=ts-node/esm --no-warnings src/*.test.ts"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"crc-32": "~1.2.0",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/lodash.deburr": "~4.1.0",
|
|
37
|
-
"@types/node": ">=
|
|
38
|
-
"dprint": "~0.
|
|
39
|
-
"
|
|
40
|
-
"typescript": "~5.
|
|
37
|
+
"@types/node": ">=18.18.2",
|
|
38
|
+
"dprint": "~0.43.0",
|
|
39
|
+
"ts-node": "~10.9.0",
|
|
40
|
+
"typescript": "~5.3.0"
|
|
41
41
|
},
|
|
42
42
|
"type": "module",
|
|
43
43
|
"bin": "./dist/cli.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"!dist/*.test.*"
|
|
54
54
|
],
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
56
|
+
"node": ">=18.18.2",
|
|
57
57
|
"npm": ">=7"
|
|
58
58
|
}
|
|
59
59
|
}
|