bysquare 2.1.0 → 2.2.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.md CHANGED
@@ -2,18 +2,19 @@
2
2
 
3
3
  ![version][version] ![build][build]
4
4
 
5
- Simple `Node.js` library to generate "PAY by square" `QR` string.
5
+ Simple JavaScript library to generate and parse "PAY by square" string.
6
6
 
7
7
  **What is `PAY by square`?**
8
8
 
9
- It's a national standard for payment QR codes adopted by Slovak Banking
10
- Association in 2013. It is part of a large number of invoices, reminders and
11
- other payment regulations.
9
+ It's a national standard for QR code payments that was adopted by the Slovak
10
+ Banking Association in 2013. It is incorporated into a variety of invoices,
11
+ reminders and other payment regulations.
12
12
 
13
13
  **Can I generate an image?**
14
14
 
15
- This library is un-opinionated. Image generation from qr-code string depends on
16
- your implementation. See [examples](examples).
15
+ This library doesn't have a specific opinion and how the QR code string is
16
+ transformed into images depends on how you implement it. See
17
+ [examples](examples).
17
18
 
18
19
  ## Install
19
20
 
@@ -31,6 +32,9 @@ npm install xseman/bysquare#master
31
32
 
32
33
  # latest unreleased changes
33
34
  npm install xseman/bysquare#develop
35
+
36
+ # specific tag version, e.g. v2.1.0
37
+ npm install xseman/bysquare#v2.1.0
34
38
  ```
35
39
 
36
40
  **CLI**
@@ -39,6 +43,12 @@ npm install xseman/bysquare#develop
39
43
  npm install --global bysquare
40
44
  ```
41
45
 
46
+ **Deno** `v1.28+`, just import `npm:bysquare` `v2.1.0+`
47
+
48
+ ```
49
+ import { generate, parse } from "npm:bysquare@2.1.0"
50
+ ```
51
+
42
52
  ## How it works
43
53
 
44
54
  ### Encoding sequence
@@ -53,49 +63,75 @@ parse(qr: string): DataModel
53
63
  detect(qr: string): Boolean
54
64
  ```
55
65
 
56
- **generate(model: DataModel, options?: Options): string**
66
+ ## Usage
67
+
68
+ Generate
57
69
 
58
70
  ```ts
59
- import { generate, DataModel, parse, PaymentOptions } from "bysquare"
71
+ import { DataModel, generate, PaymentOptions } from "bysquare"
60
72
 
61
- const model {
73
+ // long string ready to be encoded to QR
74
+ const qrString = generate({
62
75
  invoiceId: "random-id",
63
76
  payments: [
64
77
  {
65
78
  type: PaymentOptions.PaymentOrder,
66
79
  amount: 100.0,
67
80
  bankAccounts: [
68
- { iban: "SK9611000000002918599669" },
81
+ { iban: "SK9611000000002918599669" }
69
82
  ],
70
83
  currencyCode: "EUR",
71
- variableSymbol: "123",
84
+ variableSymbol: "123"
72
85
  }
73
86
  ]
74
- } satisfies DataModel
75
-
76
- const qr = generate(model)
87
+ })
77
88
  ```
78
89
 
79
- **parse(qr: string): DataModel**
90
+ Parse
80
91
 
81
92
  ```ts
82
93
  import { parse } from "bysquare"
83
94
 
84
- const qr = "0004A00090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6CB54HSI0KH9FCRASHNQBSKAQD2LJ4AU400UVKDNDPFRKLOBEVVVU0QJ000"
85
- const model = parse(qr)
86
- ```
95
+ const model =
96
+ parse("0405QH8090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6CB54HSI0KH9FCRASHNQBSKAQD2LJ4AU400UVKDNDPFRKLOBEVVVU0QJ000")
97
+
98
+ // {
99
+ // invoiceId: "random-id",
100
+ // payments: [
101
+ // {
102
+ // type: 1,
103
+ // amount: 100.0,
104
+ // bankAccounts: [
105
+ // { iban: "SK9611000000002918599669" },
106
+ // ],
107
+ // currencyCode: "EUR",
108
+ // variableSymbol: "123",
109
+ // }
110
+ // ]
111
+ // }
112
+ //
113
+ const qr =
114
+ "0004A00090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6CB54HSI0KH9FCRASHNQBSKAQD2LJ4AU400UVKDNDPFRKLOBEVVVU0QJ000"
87
115
 
88
- **detect(qr: string): Boolean**
89
-
90
- ```ts
91
- import { detect } from "bysquare"
92
-
93
- const qr = "0004A00090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6CB54HSI0KH9FCRASHNQBSKAQD2LJ4AU400UVKDNDPFRKLOBEVVVU0QJ000"
94
- const isBysquare = detect(qr)
116
+ const model = parse(qr)
117
+ /**
118
+ * {
119
+ * invoiceId: "random-id",
120
+ * payments: [
121
+ * {
122
+ * type: PaymentOptions.PaymentOrder,
123
+ * amount: 100.0,
124
+ * bankAccounts: [
125
+ * { iban: "SK9611000000002918599669" },
126
+ * ],
127
+ * currencyCode: "EUR",
128
+ * variableSymbol: "123",
129
+ * }
130
+ * ]
131
+ * }
132
+ */
95
133
  ```
96
134
 
97
- ## CLI
98
-
99
135
  You can use json file with valid model to generate qr-string.
100
136
 
101
137
  ```sh
@@ -114,7 +150,7 @@ You can use json file with valid model to generate qr-string.
114
150
  # }
115
151
 
116
152
  $ npx bysquare ./example.json
117
- $ 0004A00090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6CB54HSI0KH9FCRASHNQBSKAQD2LJ4AU400UVKDNDPFRKLOBEVVVU0QJ000
153
+ $ 0405QH8090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6CB54HSI0KH9FCRASHNQBSKAQD2LJ4AU400UVKDNDPFRKLOBEVVVU0QJ000
118
154
  ```
119
155
 
120
156
  You can also use stdin.
@@ -133,7 +169,7 @@ $ npx bysquare <<< '{
133
169
  ]
134
170
  }'
135
171
 
136
- $ 0004A00090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6CB54HSI0KH9FCRASHNQBSKAQD2LJ4AU400UVKDNDPFRKLOBEVVVU0QJ000
172
+ $ 0405QH8090IFU27IV0J6HGGLIOTIBVHNQQJQ6LAVGNBT363HR13JC6CB54HSI0KH9FCRASHNQBSKAQD2LJ4AU400UVKDNDPFRKLOBEVVVU0QJ000
137
173
  ```
138
174
 
139
175
  ## Related
package/lib/cjs/cli.js CHANGED
@@ -8,12 +8,10 @@ const node_fs_1 = require("node:fs");
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const node_readline_1 = require("node:readline");
10
10
  const generate_js_1 = require("./generate.js");
11
- if (process.stdin.isTTY) {
12
- // bysquare "file"
11
+ if /** bysquare "file" */ (process.stdin.isTTY) {
13
12
  handleInput(process.argv[2]);
14
- }
13
+ } /** bysquare <<< "data" */
15
14
  else {
16
- // echo "data" | bysquare
17
15
  ;
18
16
  (async () => {
19
17
  const stdin = await handleStdin();
@@ -85,6 +83,6 @@ function help() {
85
83
  " \"variableSymbol\": \"123\"",
86
84
  " }",
87
85
  " ]",
88
- " }\"",
86
+ " }\""
89
87
  ].join("\n");
90
88
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { DataModel } from "./types.js";
3
2
  /**
4
3
  * Returns a 2 byte buffer that represents the header of the bysquare
@@ -13,31 +12,34 @@ import { DataModel } from "./types.js";
13
12
  * | Reserved | 4 | 0-15 | bits reserved for future needs
14
13
  * ```
15
14
  *
16
- * @see 3.5. by square header
15
+ * @see 3.5.
17
16
  */
18
- export declare function bysquareHeader(header?: [
17
+ export declare function headerBysquare(
18
+ /** dprint-ignore */
19
+ header?: [
19
20
  bySquareType: number,
20
21
  version: number,
21
22
  documentType: number,
22
23
  reserved: number
23
24
  ]): Uint8Array;
24
25
  /**
25
- * @see 3.10 Appending CRC32 checksum
26
+ * Creates a one-byte array that represents the length of compressed data in
27
+ * combination with CRC32 in bytes.
26
28
  */
27
- export declare function checksum(intermediate: string): Buffer;
29
+ export declare function headerDataLength(length: number): Uint8Array;
28
30
  /**
29
31
  * Transfer object to a tabbed string and append a CRC32 checksum
30
32
  *
31
- * @see 3.10. Appending CRC32 checksum
33
+ * @see 3.10.
32
34
  */
33
- export declare function addChecksum(model: DataModel): Uint8Array;
35
+ export declare function addChecksum(serialized: string): Uint8Array;
34
36
  /**
35
37
  * Transform data to ordered tab-separated intermediate representation ready for
36
38
  * encoding
37
39
  *
38
- * @see Table 15 PAY by square sequence data model
40
+ * @see Table 15.
39
41
  */
40
- export declare function deserialize(data: DataModel): string;
42
+ export declare function serialize(data: DataModel): string;
41
43
  type Options = {
42
44
  /**
43
45
  * Many banking apps do not support diacritics, which results in errors when
@@ -1,15 +1,37 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generate = exports.deserialize = exports.addChecksum = exports.checksum = exports.bysquareHeader = void 0;
29
+ exports.generate = exports.serialize = exports.addChecksum = exports.headerDataLength = exports.headerBysquare = void 0;
7
30
  const crc_32_1 = __importDefault(require("crc-32"));
8
31
  const lodash_deburr_1 = __importDefault(require("lodash.deburr"));
32
+ const lzma = __importStar(require("lzma1"));
9
33
  const rfc4648_1 = require("rfc4648");
10
34
  const types_js_1 = require("./types.js");
11
- // @ts-ignore: missing types
12
- const lzma_1 = __importDefault(require("lzma"));
13
35
  /**
14
36
  * Returns a 2 byte buffer that represents the header of the bysquare
15
37
  * specification
@@ -23,63 +45,69 @@ const lzma_1 = __importDefault(require("lzma"));
23
45
  * | Reserved | 4 | 0-15 | bits reserved for future needs
24
46
  * ```
25
47
  *
26
- * @see 3.5. by square header
48
+ * @see 3.5.
27
49
  */
28
- function bysquareHeader(header = [
29
- 0, 0,
30
- 0, 0
50
+ function headerBysquare(
51
+ /** dprint-ignore */
52
+ header = [
53
+ 0x00, 0x00,
54
+ 0x00, 0x00
31
55
  ]) {
32
56
  const isValid = header.every((nibble) => 0 <= nibble && nibble <= 15);
33
57
  if (!isValid) {
34
- throw new Error(`Invalid header byte value, valid range <0,15>`);
58
+ throw new Error("Invalid header byte value, valid range <0,15>");
35
59
  }
36
60
  const [bySquareType, version, documentType, reserved] = header;
37
61
  // Combine 4-nibbles to 2-bytes
38
62
  const mergedNibbles = Uint8Array.from([
39
63
  (bySquareType << 4) | (version << 0),
40
- (documentType << 4) | (reserved << 0),
64
+ (documentType << 4) | (reserved << 0)
41
65
  ]);
42
66
  return mergedNibbles;
43
67
  }
44
- exports.bysquareHeader = bysquareHeader;
68
+ exports.headerBysquare = headerBysquare;
45
69
  /**
46
- * Allocates a new buffer of a 2 bytes that represents LZMA header which
47
- * contains 16-bit unsigned integer (word, little-endian), which is the size of
48
- * the decompressed data. Therefore the maximum size of compressed data is
49
- * limited to 65535
70
+ * The function first sets default values for the lc, lp, and pb properties,
71
+ * which represent the number of literal context bits, literal position bits,
72
+ * and position bits, respectively. These values are then used to calculate the
73
+ * properties value, which is a single byte that encodes all three properties.
50
74
  *
51
- * @see 3.11. LZMA Compression
75
+ * @see 3.11.
52
76
  */
53
- function datasizeHeader(data) {
54
- if (data.byteLength >= 2 ** 16) {
55
- throw new Error("The maximum compressed data size has been reached");
56
- }
57
- const header = new Uint8Array(2);
58
- header.set(Uint16Array.from([data.byteLength]));
59
- return header;
77
+ function headerLzmaProps() {
78
+ const lc = 3;
79
+ const lp = 0;
80
+ const pb = 2;
81
+ const properties = (((pb * 5) + lp) * 9) + lc;
82
+ const header = new ArrayBuffer(1);
83
+ new DataView(header).setUint8(0, properties);
84
+ return new Uint8Array(header);
60
85
  }
61
86
  /**
62
- * @see 3.10 Appending CRC32 checksum
87
+ * Creates a one-byte array that represents the length of compressed data in
88
+ * combination with CRC32 in bytes.
63
89
  */
64
- function checksum(intermediate) {
65
- const data = crc_32_1.default.str(intermediate);
66
- const checksum = Buffer.alloc(4);
67
- checksum.writeUInt32LE(data);
68
- return checksum;
90
+ function headerDataLength(length) {
91
+ if (length >= 2 ** 16) {
92
+ throw new Error("The maximum compressed data size has been reached");
93
+ }
94
+ const header = new ArrayBuffer(1);
95
+ new DataView(header).setUint8(0, length);
96
+ return new Uint8Array(header);
69
97
  }
70
- exports.checksum = checksum;
98
+ exports.headerDataLength = headerDataLength;
71
99
  /**
72
100
  * Transfer object to a tabbed string and append a CRC32 checksum
73
101
  *
74
- * @see 3.10. Appending CRC32 checksum
102
+ * @see 3.10.
75
103
  */
76
- function addChecksum(model) {
77
- const intermediate = deserialize(model);
78
- const checksum = Uint32Array.from([crc_32_1.default.str(intermediate)]);
79
- const byearray = [...intermediate].map(char => char.charCodeAt(0));
104
+ function addChecksum(serialized) {
105
+ const checksum = new ArrayBuffer(4);
106
+ new DataView(checksum).setUint32(0, crc_32_1.default.str(serialized), true);
107
+ const byteArray = new TextEncoder().encode(serialized);
80
108
  return Uint8Array.from([
81
- ...new Uint8Array(checksum.buffer),
82
- ...Uint8Array.from(byearray)
109
+ ...new Uint8Array(checksum),
110
+ ...Uint8Array.from(byteArray)
83
111
  ]);
84
112
  }
85
113
  exports.addChecksum = addChecksum;
@@ -87,62 +115,62 @@ exports.addChecksum = addChecksum;
87
115
  * Transform data to ordered tab-separated intermediate representation ready for
88
116
  * encoding
89
117
  *
90
- * @see Table 15 PAY by square sequence data model
118
+ * @see Table 15.
91
119
  */
92
- function deserialize(data) {
93
- const intermediate = new Array();
94
- intermediate.push(data.invoiceId?.toString());
95
- intermediate.push(data.payments.length.toString());
120
+ function serialize(data) {
121
+ const serialized = new Array();
122
+ serialized.push(data.invoiceId?.toString());
123
+ serialized.push(data.payments.length.toString());
96
124
  for (const p of data.payments) {
97
- intermediate.push(p.type.toString());
98
- intermediate.push(p.amount?.toString());
99
- intermediate.push(p.currencyCode);
100
- intermediate.push(p.paymentDueDate);
101
- intermediate.push(p.variableSymbol);
102
- intermediate.push(p.constantSymbol);
103
- intermediate.push(p.specificSymbol);
104
- intermediate.push(p.originatorRefInfo);
105
- intermediate.push(p.paymentNote);
106
- intermediate.push(p.bankAccounts.length.toString());
125
+ serialized.push(p.type.toString());
126
+ serialized.push(p.amount?.toString());
127
+ serialized.push(p.currencyCode);
128
+ serialized.push(p.paymentDueDate);
129
+ serialized.push(p.variableSymbol);
130
+ serialized.push(p.constantSymbol);
131
+ serialized.push(p.specificSymbol);
132
+ serialized.push(p.originatorRefInfo);
133
+ serialized.push(p.paymentNote);
134
+ serialized.push(p.bankAccounts.length.toString());
107
135
  for (const ba of p.bankAccounts) {
108
- intermediate.push(ba.iban);
109
- intermediate.push(ba.bic);
136
+ serialized.push(ba.iban);
137
+ serialized.push(ba.bic);
110
138
  }
111
139
  if (p.type === types_js_1.PaymentOptions.StandingOrder) {
112
- intermediate.push('1');
113
- intermediate.push(p.day?.toString());
114
- intermediate.push(p.month?.toString());
115
- intermediate.push(p.periodicity);
116
- intermediate.push(p.lastDate);
140
+ serialized.push("1");
141
+ serialized.push(p.day?.toString());
142
+ serialized.push(p.month?.toString());
143
+ serialized.push(p.periodicity);
144
+ serialized.push(p.lastDate);
117
145
  }
118
146
  else {
119
- intermediate.push('0');
147
+ serialized.push("0");
120
148
  }
121
149
  if (p.type === types_js_1.PaymentOptions.DirectDebit) {
122
- intermediate.push('1');
123
- intermediate.push(p.directDebitScheme?.toString());
124
- intermediate.push(p.directDebitType?.toString());
125
- intermediate.push(p.variableSymbol?.toString());
126
- intermediate.push(p.specificSymbol?.toString());
127
- intermediate.push(p.originatorRefInfo?.toString());
128
- intermediate.push(p.mandateId?.toString());
129
- intermediate.push(p.creditorId?.toString());
130
- intermediate.push(p.contractId?.toString());
131
- intermediate.push(p.maxAmount?.toString());
132
- intermediate.push(p.validTillDate?.toString());
150
+ serialized.push("1");
151
+ serialized.push(p.directDebitScheme?.toString());
152
+ serialized.push(p.directDebitType?.toString());
153
+ serialized.push(p.variableSymbol?.toString());
154
+ serialized.push(p.specificSymbol?.toString());
155
+ serialized.push(p.originatorRefInfo?.toString());
156
+ serialized.push(p.mandateId?.toString());
157
+ serialized.push(p.creditorId?.toString());
158
+ serialized.push(p.contractId?.toString());
159
+ serialized.push(p.maxAmount?.toString());
160
+ serialized.push(p.validTillDate?.toString());
133
161
  }
134
162
  else {
135
- intermediate.push('0');
163
+ serialized.push("0");
136
164
  }
137
165
  }
138
166
  for (const p of data.payments) {
139
- intermediate.push(p.beneficiary?.name);
140
- intermediate.push(p.beneficiary?.street);
141
- intermediate.push(p.beneficiary?.city);
167
+ serialized.push(p.beneficiary?.name);
168
+ serialized.push(p.beneficiary?.street);
169
+ serialized.push(p.beneficiary?.city);
142
170
  }
143
- return intermediate.join('\t');
171
+ return serialized.join("\t");
144
172
  }
145
- exports.deserialize = deserialize;
173
+ exports.serialize = serialize;
146
174
  function removeDiacritics(model) {
147
175
  for (const payment of model.payments) {
148
176
  if (payment.paymentNote) {
@@ -166,17 +194,17 @@ function generate(model, options = { deburr: true }) {
166
194
  if (options.deburr) {
167
195
  removeDiacritics(model);
168
196
  }
169
- const payload = addChecksum(model);
170
- const compressed = Uint8Array.from(lzma_1.default.compress(payload));
171
- /**
172
- * @see https://docs.fileformat.com/compression/lzma/#lzma-header
173
- */
174
- const _header = Uint8Array.from(compressed.subarray(0, 13));
175
- const data = Uint8Array.from(compressed.subarray(13));
197
+ const payload = serialize(model);
198
+ const withChecksum = addChecksum(payload);
199
+ const compressed = Uint8Array.from(lzma.compress(withChecksum));
200
+ /** Exclude the LZMA header and retain raw compressed data */
201
+ const _headerLzma = Uint8Array.from(compressed.subarray(0, 13));
202
+ const compressedPayload = Uint8Array.from(compressed.subarray(13));
176
203
  const output = Uint8Array.from([
177
- ...bysquareHeader(),
178
- ...datasizeHeader(payload),
179
- ...data
204
+ ...headerBysquare([0x00, 1 /* Version["1.1.0"] */, 0x00, 0x00]),
205
+ ...headerLzmaProps(),
206
+ ...headerDataLength(withChecksum.byteLength),
207
+ ...compressedPayload
180
208
  ]);
181
209
  return rfc4648_1.base32hex.stringify(output, {
182
210
  pad: false
@@ -1,14 +1,24 @@
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.1.0",
4
+ "version": "2.2.0",
5
5
  "license": "Apache-2.0",
6
- "type": "commonjs",
7
6
  "funding": "https://github.com/sponsors/xseman",
8
7
  "homepage": "https://github.com/xseman/bysquare#readme",
9
- "author": {
10
- "name": "Filip Seman",
11
- "email": "filip.seman@protonmail.com"
8
+ "author": "Filip Seman <filip.seman@pm.me>",
9
+ "keywords": [
10
+ "pay by square",
11
+ "by square",
12
+ "paybysquare",
13
+ "bysquare",
14
+ "payments",
15
+ "qr-string",
16
+ "generate",
17
+ "parse"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/xseman/bysquare.git"
12
22
  },
13
23
  "scripts": {
14
24
  "prebuild": "rm -rf ./lib || :",
@@ -27,17 +37,18 @@
27
37
  "dependencies": {
28
38
  "crc-32": "~1.2.0",
29
39
  "lodash.deburr": "~4.1.0",
30
- "lzma": "~2.3.0",
40
+ "lzma1": "~0.0.1",
31
41
  "rfc4648": "~1.5.0"
32
42
  },
33
43
  "devDependencies": {
34
44
  "@types/lodash.deburr": "~4.1.0",
35
- "@types/lzma-native": "^4.0.1",
36
- "@types/node": "~18.11.0",
45
+ "@types/node": ">=16.14",
46
+ "dprint": "~0.35.0",
37
47
  "tsx": "~3.12.0",
38
- "typescript": "~4.9.0",
48
+ "typescript": "~5.0.0",
39
49
  "xv": "~2.1.0"
40
50
  },
51
+ "type": "commonjs",
41
52
  "bin": "lib/mjs/cli.js",
42
53
  "types": "lib/mjs/index.d.ts",
43
54
  "exports": {
@@ -51,21 +62,7 @@
51
62
  "!lib/*.test.*"
52
63
  ],
53
64
  "engines": {
54
- "node": ">=16.0",
65
+ "node": ">=16.14",
55
66
  "npm": ">=7.0"
56
- },
57
- "repository": {
58
- "type": "git",
59
- "url": "git+https://github.com/xseman/bysquare.git"
60
- },
61
- "keywords": [
62
- "pay by square",
63
- "by square",
64
- "paybysquare",
65
- "bysquare",
66
- "payments",
67
- "qr-string",
68
- "qr",
69
- "cli"
70
- ]
67
+ }
71
68
  }
@@ -1,10 +1,19 @@
1
1
  import { DataModel } from "./index.js";
2
2
  /**
3
- * @see 3.14. Generating by square Code
3
+ * Generating by square Code
4
+ *
5
+ * @see 3.14.
4
6
  */
5
- export declare function serialize(qr: string): DataModel;
7
+ export declare function deserialize(qr: string): DataModel;
8
+ export declare class DecodeError extends Error {
9
+ cause: Error;
10
+ name: string;
11
+ constructor(cause: Error, msg?: string);
12
+ }
6
13
  /**
7
- * @see 3.16. Decoding client data from QR Code 2005 symbol
14
+ * Decoding client data from QR Code 2005 symbol
15
+ *
16
+ * @see 3.16.
8
17
  */
9
18
  export declare function parse(qr: string): DataModel;
10
19
  /**