@digigov/ui 1.1.2 → 1.1.4
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 +15 -1
- package/app/QrCodeScanner/__stories__/Default/index.js +6 -2
- package/app/QrCodeScanner/index.js +6 -7
- package/cjs/app/QrCodeScanner/__stories__/Default/index.js +6 -2
- package/cjs/app/QrCodeScanner/index.js +6 -7
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/app/QrCodeScanner/__stories__/Default.tsx +6 -2
- package/src/app/QrCodeScanner/index.tsx +6 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @digigov/ui
|
|
2
2
|
|
|
3
|
-
This log was last generated on Fri, 16 Feb 2024
|
|
3
|
+
This log was last generated on Fri, 16 Feb 2024 10:49:05 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 1.1.4
|
|
6
|
+
Fri, 16 Feb 2024 10:49:05 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Avoid handlers and validator running all the time when no data is parsed
|
|
11
|
+
|
|
12
|
+
## 1.1.3
|
|
13
|
+
Fri, 16 Feb 2024 10:23:15 GMT
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- Remove debugger statement left over in the code
|
|
4
18
|
|
|
5
19
|
## 1.1.2
|
|
6
20
|
Fri, 16 Feb 2024 09:57:32 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) {
|
|
@@ -38,7 +38,6 @@ export var QrCodeScanner = function QrCodeScanner(_ref) {
|
|
|
38
38
|
}
|
|
39
39
|
var handleOnScan = function handleOnScan(data) {
|
|
40
40
|
if (data) {
|
|
41
|
-
debugger;
|
|
42
41
|
if (dataType === 'url') {
|
|
43
42
|
try {
|
|
44
43
|
new URL(data);
|
|
@@ -46,13 +45,13 @@ export var QrCodeScanner = function QrCodeScanner(_ref) {
|
|
|
46
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);
|
|
47
46
|
}
|
|
48
47
|
}
|
|
48
|
+
// run a validator function provided by the application code
|
|
49
|
+
if (validate && !validate(data)) {
|
|
50
|
+
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
51
|
+
}
|
|
52
|
+
// proceed with application defined callback function
|
|
53
|
+
onScan(data);
|
|
49
54
|
}
|
|
50
|
-
// run a validator function provided by the application code
|
|
51
|
-
if (validate && !validate(data)) {
|
|
52
|
-
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
53
|
-
}
|
|
54
|
-
// proceed with application defined callback function
|
|
55
|
-
onScan(data);
|
|
56
55
|
};
|
|
57
56
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(QrReader, _extends({
|
|
58
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) {
|
|
@@ -50,7 +50,6 @@ var QrCodeScanner = exports.QrCodeScanner = function QrCodeScanner(_ref) {
|
|
|
50
50
|
}
|
|
51
51
|
var handleOnScan = function handleOnScan(data) {
|
|
52
52
|
if (data) {
|
|
53
|
-
debugger;
|
|
54
53
|
if (dataType === 'url') {
|
|
55
54
|
try {
|
|
56
55
|
new URL(data);
|
|
@@ -58,13 +57,13 @@ var QrCodeScanner = exports.QrCodeScanner = function QrCodeScanner(_ref) {
|
|
|
58
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);
|
|
59
58
|
}
|
|
60
59
|
}
|
|
60
|
+
// run a validator function provided by the application code
|
|
61
|
+
if (validate && !validate(data)) {
|
|
62
|
+
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
63
|
+
}
|
|
64
|
+
// proceed with application defined callback function
|
|
65
|
+
onScan(data);
|
|
61
66
|
}
|
|
62
|
-
// run a validator function provided by the application code
|
|
63
|
-
if (validate && !validate(data)) {
|
|
64
|
-
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
65
|
-
}
|
|
66
|
-
// proceed with application defined callback function
|
|
67
|
-
onScan(data);
|
|
68
67
|
};
|
|
69
68
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(QrReader, (0, _extends2["default"])({
|
|
70
69
|
delay: 100,
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -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) {
|
|
@@ -57,7 +57,6 @@ In order to be safe, you can:
|
|
|
57
57
|
}
|
|
58
58
|
const handleOnScan = (data) => {
|
|
59
59
|
if (data) {
|
|
60
|
-
debugger;
|
|
61
60
|
if (dataType === 'url') {
|
|
62
61
|
try {
|
|
63
62
|
new URL(data);
|
|
@@ -69,13 +68,13 @@ In order to be safe, you can:
|
|
|
69
68
|
);
|
|
70
69
|
}
|
|
71
70
|
}
|
|
71
|
+
// run a validator function provided by the application code
|
|
72
|
+
if (validate && !validate(data)) {
|
|
73
|
+
return onError(new Error('Custom QR Code payload validation failed'), data);
|
|
74
|
+
}
|
|
75
|
+
// proceed with application defined callback function
|
|
76
|
+
onScan(data);
|
|
72
77
|
}
|
|
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'), data);
|
|
76
|
-
}
|
|
77
|
-
// proceed with application defined callback function
|
|
78
|
-
onScan(data);
|
|
79
78
|
}
|
|
80
79
|
return (
|
|
81
80
|
<>
|