@digigov/ui 1.1.2-fd2cea11 → 1.1.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/CHANGELOG.md +16 -1
- package/app/QrCodeScanner/__stories__/Default/index.js +6 -2
- package/app/QrCodeScanner/index.d.ts +1 -1
- package/app/QrCodeScanner/index.js +10 -8
- package/cjs/app/QrCodeScanner/__stories__/Default/index.js +6 -2
- package/cjs/app/QrCodeScanner/index.js +10 -8
- package/index.js +1 -1
- package/package.json +6 -5
- package/src/app/QrCodeScanner/__stories__/Default.tsx +6 -2
- package/src/app/QrCodeScanner/index.tsx +13 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Change Log - @digigov/ui
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 16 Feb 2024 10:23:15 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 1.1.3
|
|
6
|
+
Fri, 16 Feb 2024 10:23:15 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Remove debugger statement left over in the code
|
|
11
|
+
|
|
12
|
+
## 1.1.2
|
|
13
|
+
Fri, 16 Feb 2024 09:57:32 GMT
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- Change empty array with results data add click event to arrow for all values option
|
|
18
|
+
- Improve URL parsing for QRCodeScanner when using dataType=`url`
|
|
4
19
|
|
|
5
20
|
## 1.1.1
|
|
6
21
|
Mon, 29 Jan 2024 17:45:11 GMT
|
|
@@ -12,8 +12,12 @@ export var Default = function Default() {
|
|
|
12
12
|
error = _useState2[0],
|
|
13
13
|
setError = _useState2[1];
|
|
14
14
|
var validate = function validate(rawData) {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
if (rawData) {
|
|
16
|
+
var url = new URL(rawData);
|
|
17
|
+
return url.origin === window.location.origin;
|
|
18
|
+
} else {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
17
21
|
};
|
|
18
22
|
var handleScan = function handleScan(data) {
|
|
19
23
|
if (data) {
|
|
@@ -5,7 +5,7 @@ export interface QrCodeScannerProps {
|
|
|
5
5
|
legacyMode?: boolean;
|
|
6
6
|
validate?: (...args: any[]) => boolean;
|
|
7
7
|
onScan: (...args: any[]) => void;
|
|
8
|
-
onError: (err: any) => void;
|
|
8
|
+
onError: (err: any, data: any) => void;
|
|
9
9
|
onLoad?: (...args: any[]) => void;
|
|
10
10
|
onImageLoad?: (...args: any[]) => void;
|
|
11
11
|
delay?: number;
|
|
@@ -39,17 +39,19 @@ export var QrCodeScanner = function QrCodeScanner(_ref) {
|
|
|
39
39
|
var handleOnScan = function handleOnScan(data) {
|
|
40
40
|
if (data) {
|
|
41
41
|
if (dataType === 'url') {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
try {
|
|
43
|
+
new URL(data);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
return onError(new Error('@digigov-ui XSS Validation failed: qr code payload should follow the pattern `https://dilosi.services.gov.gr/show/:reference_code`'), data);
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
|
-
// run a validator function provided by the application code
|
|
47
|
-
if (validate && !validate(data)) {
|
|
48
|
-
return onError(new Error('Custom QR Code payload validation failed'));
|
|
49
|
-
}
|
|
50
|
-
// proceed with application defined callback function
|
|
51
|
-
onScan(data);
|
|
52
48
|
}
|
|
49
|
+
// run a validator function provided by the application code
|
|
50
|
+
if (validate && !validate(data)) {
|
|
51
|
+
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
52
|
+
}
|
|
53
|
+
// proceed with application defined callback function
|
|
54
|
+
onScan(data);
|
|
53
55
|
};
|
|
54
56
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(QrReader, _extends({
|
|
55
57
|
delay: 100,
|
|
@@ -22,8 +22,12 @@ var Default = exports.Default = function Default() {
|
|
|
22
22
|
error = _useState2[0],
|
|
23
23
|
setError = _useState2[1];
|
|
24
24
|
var validate = function validate(rawData) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
if (rawData) {
|
|
26
|
+
var url = new URL(rawData);
|
|
27
|
+
return url.origin === window.location.origin;
|
|
28
|
+
} else {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
27
31
|
};
|
|
28
32
|
var handleScan = function handleScan(data) {
|
|
29
33
|
if (data) {
|
|
@@ -51,17 +51,19 @@ var QrCodeScanner = exports.QrCodeScanner = function QrCodeScanner(_ref) {
|
|
|
51
51
|
var handleOnScan = function handleOnScan(data) {
|
|
52
52
|
if (data) {
|
|
53
53
|
if (dataType === 'url') {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
try {
|
|
55
|
+
new URL(data);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
return onError(new Error('@digigov-ui XSS Validation failed: qr code payload should follow the pattern `https://dilosi.services.gov.gr/show/:reference_code`'), data);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
|
-
// run a validator function provided by the application code
|
|
59
|
-
if (validate && !validate(data)) {
|
|
60
|
-
return onError(new Error('Custom QR Code payload validation failed'));
|
|
61
|
-
}
|
|
62
|
-
// proceed with application defined callback function
|
|
63
|
-
onScan(data);
|
|
64
60
|
}
|
|
61
|
+
// run a validator function provided by the application code
|
|
62
|
+
if (validate && !validate(data)) {
|
|
63
|
+
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
64
|
+
}
|
|
65
|
+
// proceed with application defined callback function
|
|
66
|
+
onScan(data);
|
|
65
67
|
};
|
|
66
68
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(QrReader, (0, _extends2["default"])({
|
|
67
69
|
delay: 100,
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "@digigov reusable components toolkit",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"google-libphonenumber": "3.2.8",
|
|
8
9
|
"@uides/react-qr-reader": "3.0.0",
|
|
10
|
+
"react-query": "2.26.4",
|
|
9
11
|
"yup": "0.32.11",
|
|
10
12
|
"publint": "0.1.8",
|
|
11
|
-
"@digigov/react-icons": "1.1.2
|
|
13
|
+
"@digigov/react-icons": "1.1.2",
|
|
12
14
|
"dompurify": "3.0.6"
|
|
13
15
|
},
|
|
14
16
|
"peerDependencies": {
|
|
15
|
-
"react-query": "2.26.4",
|
|
16
17
|
"@material-ui/core": "4.11.3",
|
|
17
18
|
"@material-ui/icons": "4.11.2",
|
|
18
19
|
"clsx": "1.1.1",
|
|
19
20
|
"react": "^16.8.0 || ^17.0.0",
|
|
20
21
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
21
|
-
"@digigov/react-core": "1.2.0
|
|
22
|
-
"@digigov/css": "1.2.0
|
|
22
|
+
"@digigov/react-core": "1.2.0",
|
|
23
|
+
"@digigov/css": "1.2.0"
|
|
23
24
|
},
|
|
24
25
|
"gitHead": "c903a46306f77f55ad7fc4d2e274006f39a6c871",
|
|
25
26
|
"private": false,
|
|
@@ -6,8 +6,12 @@ import { Heading } from '@digigov/ui/typography/Heading';
|
|
|
6
6
|
export const Default = () => {
|
|
7
7
|
const [error, setError] = useState({ message: '' });
|
|
8
8
|
const validate = (rawData) => {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if (rawData) {
|
|
10
|
+
const url = new URL(rawData);
|
|
11
|
+
return url.origin === window.location.origin;
|
|
12
|
+
} else {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
11
15
|
};
|
|
12
16
|
const handleScan = (data) => {
|
|
13
17
|
if (data) {
|
|
@@ -8,7 +8,7 @@ export interface QrCodeScannerProps {
|
|
|
8
8
|
legacyMode?: boolean;
|
|
9
9
|
validate?: (...args) => boolean;
|
|
10
10
|
onScan: (...args) => void;
|
|
11
|
-
onError: (err: any) => void;
|
|
11
|
+
onError: (err: any, data: any) => void;
|
|
12
12
|
onLoad?: (...args) => void;
|
|
13
13
|
onImageLoad?: (...args) => void;
|
|
14
14
|
delay?: number;
|
|
@@ -58,26 +58,24 @@ In order to be safe, you can:
|
|
|
58
58
|
const handleOnScan = (data) => {
|
|
59
59
|
if (data) {
|
|
60
60
|
if (dataType === 'url') {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
) {
|
|
61
|
+
try {
|
|
62
|
+
new URL(data);
|
|
63
|
+
} catch (e) {
|
|
66
64
|
return onError(
|
|
67
65
|
new Error(
|
|
68
|
-
'@digigov-ui XSS Validation failed: qr code payload should follow the pattern `https://
|
|
69
|
-
)
|
|
66
|
+
'@digigov-ui XSS Validation failed: qr code payload should follow the pattern `https://dilosi.services.gov.gr/show/:reference_code`'
|
|
67
|
+
), data
|
|
70
68
|
);
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
|
-
// run a validator function provided by the application code
|
|
74
|
-
if (validate && !validate(data)) {
|
|
75
|
-
return onError(new Error('Custom QR Code payload validation failed'));
|
|
76
|
-
}
|
|
77
|
-
// proceed with application defined callback function
|
|
78
|
-
onScan(data);
|
|
79
71
|
}
|
|
80
|
-
|
|
72
|
+
// run a validator function provided by the application code
|
|
73
|
+
if (validate && !validate(data)) {
|
|
74
|
+
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
75
|
+
}
|
|
76
|
+
// proceed with application defined callback function
|
|
77
|
+
onScan(data);
|
|
78
|
+
}
|
|
81
79
|
return (
|
|
82
80
|
<>
|
|
83
81
|
<QrReader
|