bysquare 2.8.2 → 2.8.3
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 +14 -11
- package/package.json +1 -1
package/dist/decode.js
CHANGED
|
@@ -164,10 +164,9 @@ export const parse = decode;
|
|
|
164
164
|
* @see 3.16.
|
|
165
165
|
*/
|
|
166
166
|
export function decode(qr) {
|
|
167
|
+
let bytes;
|
|
167
168
|
try {
|
|
168
|
-
|
|
169
|
-
loose: true,
|
|
170
|
-
});
|
|
169
|
+
bytes = base32hex.parse(qr, { loose: true });
|
|
171
170
|
}
|
|
172
171
|
catch (error) {
|
|
173
172
|
throw new DecodeError(error, "Unable to decode QR string base32hex encoding");
|
|
@@ -202,8 +201,9 @@ export function decode(qr) {
|
|
|
202
201
|
...header,
|
|
203
202
|
...payload,
|
|
204
203
|
]);
|
|
204
|
+
let decompressed;
|
|
205
205
|
try {
|
|
206
|
-
|
|
206
|
+
decompressed = decompress(body);
|
|
207
207
|
}
|
|
208
208
|
catch (error) {
|
|
209
209
|
throw new DecodeError(error, "LZMA decompression failed");
|
|
@@ -223,21 +223,24 @@ export function decode(qr) {
|
|
|
223
223
|
* not very reliable, there is room for improvement for the future.
|
|
224
224
|
*/
|
|
225
225
|
export function detect(qr) {
|
|
226
|
+
let parsed;
|
|
226
227
|
try {
|
|
227
|
-
|
|
228
|
-
loose: true,
|
|
229
|
-
});
|
|
228
|
+
parsed = base32hex.parse(qr, { loose: true });
|
|
230
229
|
}
|
|
231
230
|
catch {
|
|
232
|
-
|
|
231
|
+
return false;
|
|
233
232
|
}
|
|
234
233
|
if (parsed.byteLength < 2) {
|
|
235
234
|
return false;
|
|
236
235
|
}
|
|
237
236
|
const bysquareHeader = parsed.subarray(0, 2);
|
|
238
|
-
const
|
|
239
|
-
const isValid = [
|
|
240
|
-
.
|
|
237
|
+
const header = bysquareHeaderDecoder(bysquareHeader);
|
|
238
|
+
const isValid = [
|
|
239
|
+
header.bysquareType,
|
|
240
|
+
header.version,
|
|
241
|
+
header.documentType,
|
|
242
|
+
header.reserved,
|
|
243
|
+
].every((nibble, index) => {
|
|
241
244
|
if (index === 1) {
|
|
242
245
|
return nibble <= Version["1.1.0"];
|
|
243
246
|
}
|
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.3",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"funding": "https://github.com/sponsors/xseman",
|
|
7
7
|
"homepage": "https://github.com/xseman/bysquare#readme",
|