@sutech_jp/datatraveler-react-client 0.0.26 → 0.0.28
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.
|
@@ -3,11 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DataTravelerImport = void 0;
|
|
4
4
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
var react_1 = require("react");
|
|
6
|
+
var targetOrigin_1 = require("./util/targetOrigin");
|
|
6
7
|
var DataTravelerImport = function (_a) {
|
|
7
8
|
var application = _a.application, schema = _a.schema, session = _a.session, googleToken = _a.googleToken, _b = _a.importType, importType = _b === void 0 ? googleToken ? 'gss' : 'csv' : _b, _c = _a.currentData, currentData = _c === void 0 ? [] : _c, _d = _a.mapper, mapper = _d === void 0 ? {} : _d, _e = _a.binder, binder = _e === void 0 ? {} : _e, width = _a.width, height = _a.height, customStyles = _a.customStyles, report = _a.report, onImport = _a.onImport, onCancel = _a.onCancel;
|
|
8
9
|
var iframe = (0, react_1.useRef)(null);
|
|
9
10
|
var handleMessage = (0, react_1.useCallback)(function (e) {
|
|
10
11
|
var _a;
|
|
12
|
+
if ((0, targetOrigin_1.getTargetOrigin)(session === null || session === void 0 ? void 0 : session.newUrl) !== '*' && e.origin !== (0, targetOrigin_1.getTargetOrigin)(session === null || session === void 0 ? void 0 : session.newUrl)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
11
15
|
var message = e.data;
|
|
12
16
|
var from = message === null || message === void 0 ? void 0 : message.from;
|
|
13
17
|
var action = message === null || message === void 0 ? void 0 : message.action;
|
|
@@ -36,7 +40,7 @@ var DataTravelerImport = function (_a) {
|
|
|
36
40
|
},
|
|
37
41
|
customStyles: customStyles,
|
|
38
42
|
report: report,
|
|
39
|
-
},
|
|
43
|
+
}, (0, targetOrigin_1.getTargetOrigin)(session === null || session === void 0 ? void 0 : session.newUrl));
|
|
40
44
|
}
|
|
41
45
|
else if (action === 'onImport') {
|
|
42
46
|
onImport(payload);
|
|
@@ -45,9 +49,9 @@ var DataTravelerImport = function (_a) {
|
|
|
45
49
|
onCancel && onCancel();
|
|
46
50
|
}
|
|
47
51
|
}, [
|
|
52
|
+
importType,
|
|
48
53
|
application,
|
|
49
54
|
schema,
|
|
50
|
-
importType,
|
|
51
55
|
currentData,
|
|
52
56
|
mapper,
|
|
53
57
|
binder,
|
|
@@ -57,6 +61,7 @@ var DataTravelerImport = function (_a) {
|
|
|
57
61
|
height,
|
|
58
62
|
customStyles,
|
|
59
63
|
report,
|
|
64
|
+
session,
|
|
60
65
|
onImport,
|
|
61
66
|
]);
|
|
62
67
|
(0, react_1.useEffect)(function () {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTargetOrigin: (source: string | undefined) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTargetOrigin = void 0;
|
|
4
|
+
var getTargetOrigin = function (source) {
|
|
5
|
+
if (!source)
|
|
6
|
+
return '*';
|
|
7
|
+
try {
|
|
8
|
+
return new URL(source).origin;
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
return '*';
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
exports.getTargetOrigin = getTargetOrigin;
|