bysquare 2.8.3 → 2.9.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 +10 -2
- package/dist/cli.js +1 -1
- package/dist/deburr.d.ts +5 -0
- package/dist/deburr.js +78 -0
- package/dist/decode.js +3 -3
- package/dist/encode.js +2 -2
- package/package.json +4 -6
package/README.md
CHANGED
|
@@ -46,7 +46,10 @@ npm install --global bysquare
|
|
|
46
46
|
Since `v1.28+` import from npm registry using `npm:` prefix.
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
decode,
|
|
51
|
+
encode,
|
|
52
|
+
} from "npm:bysquare@2.8.0";
|
|
50
53
|
```
|
|
51
54
|
|
|
52
55
|
### Browser
|
|
@@ -68,7 +71,12 @@ import { decode, encode } from "npm:bysquare@2.8.0";
|
|
|
68
71
|
### Encode
|
|
69
72
|
|
|
70
73
|
```ts
|
|
71
|
-
import {
|
|
74
|
+
import {
|
|
75
|
+
CurrencyCode,
|
|
76
|
+
DataModel,
|
|
77
|
+
encode,
|
|
78
|
+
PaymentOptions,
|
|
79
|
+
} from "bysquare";
|
|
72
80
|
|
|
73
81
|
// string ready to be encoded to QR
|
|
74
82
|
const qrString = encode({
|
package/dist/cli.js
CHANGED
package/dist/deburr.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function deburrLetter(key: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* @desc Deburrs string by converting Latin-1 Supplement and Latin Extended-A letters to basic Latin letters and removing [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
|
|
4
|
+
*/
|
|
5
|
+
export declare function deburr(text: string): string;
|
package/dist/deburr.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Used to map Latin Unicode letters to basic Latin letters. */
|
|
2
|
+
/** dprint-ignore */
|
|
3
|
+
const deburredLettersMap = {
|
|
4
|
+
// Latin-1 Supplement block.
|
|
5
|
+
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
|
|
6
|
+
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
|
|
7
|
+
'\xc7': 'C', '\xe7': 'c',
|
|
8
|
+
'\xd0': 'D', '\xf0': 'd',
|
|
9
|
+
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
|
|
10
|
+
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
|
|
11
|
+
'\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
|
|
12
|
+
'\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
|
|
13
|
+
'\xd1': 'N', '\xf1': 'n',
|
|
14
|
+
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
|
|
15
|
+
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
|
|
16
|
+
'\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
|
|
17
|
+
'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
|
|
18
|
+
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
|
|
19
|
+
'\xc6': 'Ae', '\xe6': 'ae',
|
|
20
|
+
'\xde': 'Th', '\xfe': 'th',
|
|
21
|
+
'\xdf': 'ss',
|
|
22
|
+
// Latin Extended-A block.
|
|
23
|
+
'\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
|
|
24
|
+
'\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
|
|
25
|
+
'\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
|
|
26
|
+
'\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
|
|
27
|
+
'\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
|
|
28
|
+
'\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
|
|
29
|
+
'\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
|
|
30
|
+
'\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
|
|
31
|
+
'\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
|
|
32
|
+
'\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
|
|
33
|
+
'\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
|
|
34
|
+
'\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
|
|
35
|
+
'\u0134': 'J', '\u0135': 'j',
|
|
36
|
+
'\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
|
|
37
|
+
'\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
|
|
38
|
+
'\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
|
|
39
|
+
'\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
|
|
40
|
+
'\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
|
|
41
|
+
'\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
|
|
42
|
+
'\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
|
|
43
|
+
'\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
|
|
44
|
+
'\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
|
|
45
|
+
'\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
|
|
46
|
+
'\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
|
|
47
|
+
'\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
|
|
48
|
+
'\u0163': 't', '\u0165': 't', '\u0167': 't',
|
|
49
|
+
'\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
|
|
50
|
+
'\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
|
|
51
|
+
'\u0174': 'W', '\u0175': 'w',
|
|
52
|
+
'\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
|
|
53
|
+
'\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
|
|
54
|
+
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
|
|
55
|
+
'\u0132': 'IJ', '\u0133': 'ij',
|
|
56
|
+
'\u0152': 'Oe', '\u0153': 'oe',
|
|
57
|
+
'\u0149': "'n", '\u017f': 'ss'
|
|
58
|
+
};
|
|
59
|
+
export function deburrLetter(key) {
|
|
60
|
+
return deburredLettersMap[key];
|
|
61
|
+
}
|
|
62
|
+
/** Used to match Latin Unicode letters (excluding mathematical operators). */
|
|
63
|
+
const reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
|
64
|
+
/** Used to compose unicode character classes. */
|
|
65
|
+
const rsComboMarksRange = "\\u0300-\\u036f\\ufe20-\\ufe23", rsComboSymbolsRange = "\\u20d0-\\u20f0";
|
|
66
|
+
/** Used to compose unicode capture groups. */
|
|
67
|
+
const rsCombo = "[" + rsComboMarksRange + rsComboSymbolsRange + "]";
|
|
68
|
+
/**
|
|
69
|
+
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
|
|
70
|
+
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
|
|
71
|
+
*/
|
|
72
|
+
const reComboMark = RegExp(rsCombo, "g");
|
|
73
|
+
/**
|
|
74
|
+
* @desc Deburrs string by converting Latin-1 Supplement and Latin Extended-A letters to basic Latin letters and removing [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
|
|
75
|
+
*/
|
|
76
|
+
export function deburr(text) {
|
|
77
|
+
return text.replace(reLatin, deburrLetter).replace(reComboMark, "");
|
|
78
|
+
}
|
package/dist/decode.js
CHANGED
|
@@ -138,9 +138,9 @@ export function deserialize(qr) {
|
|
|
138
138
|
function bysquareHeaderDecoder(header) {
|
|
139
139
|
const bytes = (header[0] << 8) | header[1];
|
|
140
140
|
const bysquareType = bytes >> 12;
|
|
141
|
-
const version = (bytes >> 8) &
|
|
142
|
-
const documentType = (bytes >> 4) &
|
|
143
|
-
const reserved = bytes &
|
|
141
|
+
const version = (bytes >> 8) & 0b0000_1111;
|
|
142
|
+
const documentType = (bytes >> 4) & 0b0000_1111;
|
|
143
|
+
const reserved = bytes & 0b0000_1111;
|
|
144
144
|
return {
|
|
145
145
|
bysquareType,
|
|
146
146
|
version,
|
package/dist/encode.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import crc32 from "crc-32";
|
|
2
|
-
import deburr from "lodash.deburr";
|
|
3
2
|
import { compress } from "lzma1";
|
|
4
3
|
import { base32hex } from "rfc4648";
|
|
5
|
-
import {
|
|
4
|
+
import { deburr } from "./deburr.js";
|
|
5
|
+
import { PaymentOptions, } from "./types.js";
|
|
6
6
|
/**
|
|
7
7
|
* Returns a 2 byte buffer that represents the header of the bysquare
|
|
8
8
|
* specification
|
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
|
+
"version": "2.9.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"funding": "https://github.com/sponsors/xseman",
|
|
7
7
|
"homepage": "https://github.com/xseman/bysquare#readme",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"prebuild": "tsc --build --clean",
|
|
21
21
|
"build": "tsc --build",
|
|
22
|
-
"fmt": "dprint fmt
|
|
22
|
+
"fmt": "dprint fmt",
|
|
23
23
|
"typecheck": "tsc --noEmit",
|
|
24
24
|
"version": "git checkout develop && npm test",
|
|
25
25
|
"postversion": "echo 'Now run npm run build && npm publish'",
|
|
@@ -28,16 +28,14 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"crc-32": "~1.2.0",
|
|
31
|
-
"lodash.deburr": "~4.1.0",
|
|
32
31
|
"lzma1": "0.0.2",
|
|
33
32
|
"rfc4648": "~1.5.0"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"@types/lodash.deburr": "~4.1.0",
|
|
37
35
|
"@types/node": ">=18.18.2",
|
|
38
|
-
"dprint": "~0.
|
|
36
|
+
"dprint": "~0.47.0",
|
|
39
37
|
"ts-node": "~10.9.0",
|
|
40
|
-
"typescript": "~5.
|
|
38
|
+
"typescript": "~5.5.0"
|
|
41
39
|
},
|
|
42
40
|
"type": "module",
|
|
43
41
|
"bin": "./dist/cli.js",
|