@bigbinary/neeto-payments-frontend 1.3.7 → 1.3.9
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/app/javascript/src/translations/en.json +43 -3
- package/dist/index.cjs.js +2219 -71
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +2391 -263
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +5 -0
package/dist/index.cjs.js
CHANGED
|
@@ -28,10 +28,32 @@ var require$$0 = require('util');
|
|
|
28
28
|
var reactRouterDom$1 = require('react-router-dom/cjs/react-router-dom');
|
|
29
29
|
var classNames = require('classnames');
|
|
30
30
|
var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
|
|
31
|
+
var neetointegrations = require('neetointegrations');
|
|
32
|
+
var formik = require('@bigbinary/neetoui/formik');
|
|
33
|
+
var yup = require('yup');
|
|
31
34
|
|
|
32
35
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
33
36
|
|
|
37
|
+
function _interopNamespace(e) {
|
|
38
|
+
if (e && e.__esModule) return e;
|
|
39
|
+
var n = Object.create(null);
|
|
40
|
+
if (e) {
|
|
41
|
+
Object.keys(e).forEach(function (k) {
|
|
42
|
+
if (k !== 'default') {
|
|
43
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
44
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () { return e[k]; }
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
n["default"] = e;
|
|
52
|
+
return Object.freeze(n);
|
|
53
|
+
}
|
|
54
|
+
|
|
34
55
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
56
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
35
57
|
var Header__default = /*#__PURE__*/_interopDefaultLegacy(Header);
|
|
36
58
|
var SubHeader__default = /*#__PURE__*/_interopDefaultLegacy(SubHeader);
|
|
37
59
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
@@ -41,6 +63,7 @@ var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
|
|
|
41
63
|
var TableWrapper__default = /*#__PURE__*/_interopDefaultLegacy(TableWrapper);
|
|
42
64
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
43
65
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
66
|
+
var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
|
|
44
67
|
|
|
45
68
|
function _arrayWithHoles(arr) {
|
|
46
69
|
if (Array.isArray(arr)) return arr;
|
|
@@ -688,8 +711,8 @@ var buildStripePayoutLink = function buildStripePayoutLink(identifier) {
|
|
|
688
711
|
return "".concat(STRIPE_DASHBOARD_LINK).concat(isLive ? "" : "test/", "payouts/").concat(identifier);
|
|
689
712
|
};
|
|
690
713
|
|
|
691
|
-
function ownKeys$
|
|
692
|
-
function _objectSpread$
|
|
714
|
+
function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
715
|
+
function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$b(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
693
716
|
var ExportModal$2 = function ExportModal(_ref) {
|
|
694
717
|
var showExportModal = _ref.showExportModal,
|
|
695
718
|
setShowExportModal = _ref.setShowExportModal,
|
|
@@ -721,7 +744,7 @@ var ExportModal$2 = function ExportModal(_ref) {
|
|
|
721
744
|
}
|
|
722
745
|
};
|
|
723
746
|
var handleGenerateClick = function handleGenerateClick() {
|
|
724
|
-
var payload = _objectSpread$
|
|
747
|
+
var payload = _objectSpread$b({
|
|
725
748
|
kind: "account",
|
|
726
749
|
token: token,
|
|
727
750
|
filters: JSON.stringify(filters),
|
|
@@ -801,8 +824,8 @@ var useURLSearchParams = function useURLSearchParams() {
|
|
|
801
824
|
}, [search]);
|
|
802
825
|
};
|
|
803
826
|
|
|
804
|
-
function ownKeys$
|
|
805
|
-
function _objectSpread$
|
|
827
|
+
function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
828
|
+
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$a(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
806
829
|
var processSortProperties = function processSortProperties(sortProperties) {
|
|
807
830
|
if (sortProperties.sortBy === "payment_amount") {
|
|
808
831
|
return ramda.assoc("sortBy", "neeto_payments_engine_stripe_transactions.amount", sortProperties);
|
|
@@ -810,11 +833,14 @@ var processSortProperties = function processSortProperties(sortProperties) {
|
|
|
810
833
|
if (sortProperties.sortBy === "email" || sortProperties.sortBy === "first_name") {
|
|
811
834
|
return ramda.modify("sortBy", ramda.concat("users."), sortProperties);
|
|
812
835
|
}
|
|
836
|
+
if (sortProperties.sortBy === "payable,ends_at") {
|
|
837
|
+
return ramda.assoc("sortBy", "bookings.ends_at", sortProperties);
|
|
838
|
+
}
|
|
813
839
|
return sortProperties;
|
|
814
840
|
};
|
|
815
841
|
var buildDefaultPageProperties = function buildDefaultPageProperties(tabs) {
|
|
816
842
|
return tabs.reduce(function (pageProperties, tab) {
|
|
817
|
-
return _objectSpread$
|
|
843
|
+
return _objectSpread$a(_objectSpread$a({}, pageProperties), {}, _defineProperty({}, tab, DEFAULT_PAGE_VALUES));
|
|
818
844
|
}, {});
|
|
819
845
|
};
|
|
820
846
|
var buildPayload = function buildPayload(_ref) {
|
|
@@ -826,7 +852,7 @@ var buildPayload = function buildPayload(_ref) {
|
|
|
826
852
|
sortProperties = _ref$sortProperties === void 0 ? {} : _ref$sortProperties,
|
|
827
853
|
_ref$payoutId = _ref.payoutId,
|
|
828
854
|
payoutId = _ref$payoutId === void 0 ? null : _ref$payoutId;
|
|
829
|
-
return _objectSpread$
|
|
855
|
+
return _objectSpread$a({
|
|
830
856
|
tab: neetoCist.camelToSnakeCase(tab),
|
|
831
857
|
payoutId: payoutId,
|
|
832
858
|
page: (_pageProperties$tab = pageProperties[tab]) === null || _pageProperties$tab === void 0 ? void 0 : _pageProperties$tab.page,
|
|
@@ -842,7 +868,7 @@ var buildRowData = function buildRowData(_ref2) {
|
|
|
842
868
|
tab = _ref2$tab === void 0 ? "all" : _ref2$tab;
|
|
843
869
|
return data.map(function (element, index) {
|
|
844
870
|
var _pageProperties$tab3, _pageProperties$tab4;
|
|
845
|
-
return _objectSpread$
|
|
871
|
+
return _objectSpread$a(_objectSpread$a({}, element), {}, {
|
|
846
872
|
payable: element.payable,
|
|
847
873
|
identifier: element,
|
|
848
874
|
id: ramda.isEmpty(pageProperties) ? index + 1 : ((_pageProperties$tab3 = pageProperties[tab]) === null || _pageProperties$tab3 === void 0 ? void 0 : _pageProperties$tab3.pageSize) * (((_pageProperties$tab4 = pageProperties[tab]) === null || _pageProperties$tab4 === void 0 ? void 0 : _pageProperties$tab4.page) - 1) + index + 1
|
|
@@ -984,8 +1010,8 @@ var COLUMNS$3 = [{
|
|
|
984
1010
|
sorter: true
|
|
985
1011
|
}];
|
|
986
1012
|
|
|
987
|
-
function ownKeys$
|
|
988
|
-
function _objectSpread$
|
|
1013
|
+
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1014
|
+
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
989
1015
|
var useFiltersAndPagination$3 = function useFiltersAndPagination() {
|
|
990
1016
|
var urlSearchParams = useURLSearchParams();
|
|
991
1017
|
var _useState = React.useState(false),
|
|
@@ -1015,7 +1041,7 @@ var useFiltersAndPagination$3 = function useFiltersAndPagination() {
|
|
|
1015
1041
|
var _getQueryParams = utils$3.getQueryParams(),
|
|
1016
1042
|
_getQueryParams$searc = _getQueryParams.searchTerm,
|
|
1017
1043
|
searchTerm = _getQueryParams$searc === void 0 ? "" : _getQueryParams$searc;
|
|
1018
|
-
var searchKeywordProps = _objectSpread$
|
|
1044
|
+
var searchKeywordProps = _objectSpread$9(_objectSpread$9({}, SEARCH_PROPS$1), {}, {
|
|
1019
1045
|
key: "search_term",
|
|
1020
1046
|
value: searchTerm.trim()
|
|
1021
1047
|
});
|
|
@@ -1315,8 +1341,8 @@ var AccountsDashboard = function AccountsDashboard() {
|
|
|
1315
1341
|
};
|
|
1316
1342
|
var index$3 = reactUtils.withTitle(withReactQuery(AccountsDashboard), i18next.t("neetoPayments.title.account"));
|
|
1317
1343
|
|
|
1318
|
-
function _extends() {
|
|
1319
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
1344
|
+
function _extends$1() {
|
|
1345
|
+
_extends$1 = Object.assign ? Object.assign.bind() : function (target) {
|
|
1320
1346
|
for (var i = 1; i < arguments.length; i++) {
|
|
1321
1347
|
var source = arguments[i];
|
|
1322
1348
|
for (var key in source) {
|
|
@@ -1327,7 +1353,7 @@ function _extends() {
|
|
|
1327
1353
|
}
|
|
1328
1354
|
return target;
|
|
1329
1355
|
};
|
|
1330
|
-
return _extends.apply(this, arguments);
|
|
1356
|
+
return _extends$1.apply(this, arguments);
|
|
1331
1357
|
}
|
|
1332
1358
|
|
|
1333
1359
|
var TAB$2 = {
|
|
@@ -1908,8 +1934,8 @@ var modifySearchProps = function modifySearchProps(_ref5) {
|
|
|
1908
1934
|
}, searchProps);
|
|
1909
1935
|
};
|
|
1910
1936
|
|
|
1911
|
-
function ownKeys$
|
|
1912
|
-
function _objectSpread$
|
|
1937
|
+
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1938
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1913
1939
|
var ExportModal$1 = function ExportModal(_ref) {
|
|
1914
1940
|
var showExportModal = _ref.showExportModal,
|
|
1915
1941
|
setShowExportModal = _ref.setShowExportModal,
|
|
@@ -1943,7 +1969,7 @@ var ExportModal$1 = function ExportModal(_ref) {
|
|
|
1943
1969
|
}
|
|
1944
1970
|
};
|
|
1945
1971
|
var handleGenerateClick = function handleGenerateClick() {
|
|
1946
|
-
var payload = _objectSpread$
|
|
1972
|
+
var payload = _objectSpread$8({
|
|
1947
1973
|
kind: isTransferKind(kind) ? "connected" : kind,
|
|
1948
1974
|
token: token,
|
|
1949
1975
|
filters: JSON.stringify(filters),
|
|
@@ -2000,8 +2026,8 @@ var ExportModal$1 = function ExportModal(_ref) {
|
|
|
2000
2026
|
}))));
|
|
2001
2027
|
};
|
|
2002
2028
|
|
|
2003
|
-
function ownKeys$
|
|
2004
|
-
function _objectSpread$
|
|
2029
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2030
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2005
2031
|
var useFiltersAndPagination$2 = function useFiltersAndPagination(_ref) {
|
|
2006
2032
|
var payableEntityColumns = _ref.payableEntityColumns,
|
|
2007
2033
|
kind = _ref.kind,
|
|
@@ -2040,7 +2066,7 @@ var useFiltersAndPagination$2 = function useFiltersAndPagination(_ref) {
|
|
|
2040
2066
|
var _getQueryParams = utils$3.getQueryParams(),
|
|
2041
2067
|
_getQueryParams$searc = _getQueryParams.searchTerm,
|
|
2042
2068
|
searchTerm = _getQueryParams$searc === void 0 ? "" : _getQueryParams$searc;
|
|
2043
|
-
var searchKeywordProps = _objectSpread$
|
|
2069
|
+
var searchKeywordProps = _objectSpread$7(_objectSpread$7({}, modifySearchProps({
|
|
2044
2070
|
searchProps: searchProps,
|
|
2045
2071
|
kind: kind
|
|
2046
2072
|
})), {}, {
|
|
@@ -2112,8 +2138,20 @@ var useFiltersAndPagination$2 = function useFiltersAndPagination(_ref) {
|
|
|
2112
2138
|
var show$5 = function show(holdableId) {
|
|
2113
2139
|
return axios__default["default"].get("".concat(BASE_URL, "/api/v1/stripe/holdable/").concat(holdableId, "/account"));
|
|
2114
2140
|
};
|
|
2141
|
+
var create$1 = function create(payload) {
|
|
2142
|
+
return axios__default["default"].post("".concat(BASE_URL, "/api/v1/stripe/accounts"), payload);
|
|
2143
|
+
};
|
|
2144
|
+
var creationStatus = function creationStatus(jobId) {
|
|
2145
|
+
return axios__default["default"].get("".concat(BASE_URL, "/api/v1/stripe/accounts/").concat(jobId, "/creation_status"));
|
|
2146
|
+
};
|
|
2147
|
+
var destroy = function destroy(accountId) {
|
|
2148
|
+
return axios__default["default"]["delete"]("".concat(BASE_URL, "/api/v1/stripe/accounts/").concat(accountId));
|
|
2149
|
+
};
|
|
2115
2150
|
var accountsApi$2 = {
|
|
2116
|
-
show: show$5
|
|
2151
|
+
show: show$5,
|
|
2152
|
+
create: create$1,
|
|
2153
|
+
creationStatus: creationStatus,
|
|
2154
|
+
destroy: destroy
|
|
2117
2155
|
};
|
|
2118
2156
|
|
|
2119
2157
|
var list$7 = function list(payload) {
|
|
@@ -4208,6 +4246,8 @@ var transactionsApi$1 = {
|
|
|
4208
4246
|
list: list$6
|
|
4209
4247
|
};
|
|
4210
4248
|
|
|
4249
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4250
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4211
4251
|
var useFetchConnectedStripeAccount = function useFetchConnectedStripeAccount(holdableId) {
|
|
4212
4252
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4213
4253
|
return reactQuery.useQuery([QUERY_KEYS.CONNECTED_ACCOUNT, holdableId], function () {
|
|
@@ -4237,6 +4277,34 @@ var useShowStripePayout = function useShowStripePayout(id) {
|
|
|
4237
4277
|
return payoutsApi$1.show(id);
|
|
4238
4278
|
}, options);
|
|
4239
4279
|
};
|
|
4280
|
+
var usePollingStripeAccount = function usePollingStripeAccount(holdableId, _ref) {
|
|
4281
|
+
var refetchInterval = _ref.refetchInterval;
|
|
4282
|
+
return reactQuery.useQuery(QUERY_KEYS.STRIPE_ACCOUNT_DETAILS, function () {
|
|
4283
|
+
return accountsApi$2.show(holdableId);
|
|
4284
|
+
}, {
|
|
4285
|
+
refetchInterval: refetchInterval
|
|
4286
|
+
});
|
|
4287
|
+
};
|
|
4288
|
+
var usePollingStripeAccountCreationStatus = function usePollingStripeAccountCreationStatus(jobId, options) {
|
|
4289
|
+
return reactQuery.useQuery([QUERY_KEYS.STRIPE_ACCOUNT_DETAILS, jobId], function () {
|
|
4290
|
+
return accountsApi$2.creationStatus(jobId);
|
|
4291
|
+
}, _objectSpread$6({}, options));
|
|
4292
|
+
};
|
|
4293
|
+
var useDestroyStripeAccount = function useDestroyStripeAccount(_ref2) {
|
|
4294
|
+
var onSuccess = _ref2.onSuccess,
|
|
4295
|
+
holdableId = _ref2.holdableId;
|
|
4296
|
+
return reactUtils.useMutationWithInvalidation(accountsApi$2.destroy, {
|
|
4297
|
+
keysToInvalidate: [QUERY_KEYS.STRIPE_ACCOUNT_DETAILS, [QUERY_KEYS.CONNECTED_ACCOUNT, holdableId]],
|
|
4298
|
+
onSuccess: onSuccess
|
|
4299
|
+
});
|
|
4300
|
+
};
|
|
4301
|
+
var useCreateStripeAccount = function useCreateStripeAccount(_ref3) {
|
|
4302
|
+
var onSuccess = _ref3.onSuccess;
|
|
4303
|
+
return reactUtils.useMutationWithInvalidation(accountsApi$2.create, {
|
|
4304
|
+
keysToInvalidate: [QUERY_KEYS.STRIPE_ACCOUNT_DETAILS],
|
|
4305
|
+
onSuccess: onSuccess
|
|
4306
|
+
});
|
|
4307
|
+
};
|
|
4240
4308
|
|
|
4241
4309
|
var list$5 = function list(payload) {
|
|
4242
4310
|
return axios__default["default"].get("".concat(BASE_URL, "/api/v1/stripe/holdable/refunds"), {
|
|
@@ -4442,8 +4510,8 @@ var ExpandedRow = function ExpandedRow() {
|
|
|
4442
4510
|
})));
|
|
4443
4511
|
};
|
|
4444
4512
|
|
|
4445
|
-
function ownKeys$
|
|
4446
|
-
function _objectSpread$
|
|
4513
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4514
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4447
4515
|
var useFetchData$2 = function useFetchData(_ref) {
|
|
4448
4516
|
var _data$kind, _data$kind2, _data$kind3, _data$kind4;
|
|
4449
4517
|
var kind = _ref.kind,
|
|
@@ -4451,7 +4519,7 @@ var useFetchData$2 = function useFetchData(_ref) {
|
|
|
4451
4519
|
payload = _ref.payload,
|
|
4452
4520
|
isPlatformEnabled = _ref.isPlatformEnabled;
|
|
4453
4521
|
var data = {};
|
|
4454
|
-
data.transfer = data.connected = useFetchStripeTransactions(holdableId, _objectSpread$
|
|
4522
|
+
data.transfer = data.connected = useFetchStripeTransactions(holdableId, _objectSpread$5(_objectSpread$5({}, payload), {}, {
|
|
4455
4523
|
kind: kind
|
|
4456
4524
|
}), {
|
|
4457
4525
|
enabled: isTransferKind(kind) || isConnectedKind(kind)
|
|
@@ -4538,7 +4606,7 @@ var Details = function Details(_ref) {
|
|
|
4538
4606
|
live = _useFetchStripePlatfo3.live,
|
|
4539
4607
|
_useFetchStripePlatfo4 = _useFetchStripePlatfo3.splits,
|
|
4540
4608
|
splits = _useFetchStripePlatfo4 === void 0 ? [] : _useFetchStripePlatfo4;
|
|
4541
|
-
return /*#__PURE__*/React__default["default"].createElement(neetoui.Pane, _extends({}, paneProps, {
|
|
4609
|
+
return /*#__PURE__*/React__default["default"].createElement(neetoui.Pane, _extends$1({}, paneProps, {
|
|
4542
4610
|
size: "large"
|
|
4543
4611
|
}), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Header, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
4544
4612
|
style: "h2"
|
|
@@ -4677,7 +4745,7 @@ var List$2 = function List(_ref) {
|
|
|
4677
4745
|
}, [urlSearchParams]);
|
|
4678
4746
|
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
4679
4747
|
setSortProperties(neetocist.isPresent(sorter === null || sorter === void 0 ? void 0 : sorter.column) ? {
|
|
4680
|
-
sortBy: neetocist.camelToSnakeCase(sorter.field),
|
|
4748
|
+
sortBy: neetocist.camelToSnakeCase(processDataIndex(sorter.field)),
|
|
4681
4749
|
orderBy: sorter.order === "ascend" ? "ASC" : "DESC"
|
|
4682
4750
|
} : DEFAULT_SORT_PROPERTIES$1);
|
|
4683
4751
|
};
|
|
@@ -4726,7 +4794,7 @@ var List$2 = function List(_ref) {
|
|
|
4726
4794
|
total: dataSize
|
|
4727
4795
|
},
|
|
4728
4796
|
onChange: handleTableChange
|
|
4729
|
-
})), /*#__PURE__*/React__default["default"].createElement(Details, _extends({}, paneStatus, {
|
|
4797
|
+
})), /*#__PURE__*/React__default["default"].createElement(Details, _extends$1({}, paneStatus, {
|
|
4730
4798
|
onClose: function onClose() {
|
|
4731
4799
|
return setPaneStatus(INITIAL_PANE_STATUS);
|
|
4732
4800
|
}
|
|
@@ -4784,14 +4852,14 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
4784
4852
|
handleTabChange = _useFiltersAndPaginat.handleTabChange,
|
|
4785
4853
|
setDataSize = _useFiltersAndPaginat.setDataSize,
|
|
4786
4854
|
setSortProperties = _useFiltersAndPaginat.setSortProperties;
|
|
4787
|
-
var isTabsVisible = isFilterButtonVisible || tab !== "all";
|
|
4855
|
+
var isTabsVisible = (isFilterButtonVisible || tab !== "all") && neetoCist.isNotPresent(payoutId);
|
|
4788
4856
|
var titleKind = kind === "transfer" && !isPlatformEnabled ? KIND.connected : kind;
|
|
4789
4857
|
var handleFiltersChange = function handleFiltersChange(filters) {
|
|
4790
4858
|
startTransition(function () {
|
|
4791
4859
|
setFilters(filters);
|
|
4792
4860
|
});
|
|
4793
4861
|
};
|
|
4794
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Header__default["default"], _extends({}, headerProps, {
|
|
4862
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Header__default["default"], _extends$1({}, headerProps, {
|
|
4795
4863
|
title: t("neetoPayments.title.".concat(titleKind)),
|
|
4796
4864
|
searchProps: {
|
|
4797
4865
|
placeholder: searchKeywordProps.placeholder,
|
|
@@ -4905,8 +4973,8 @@ var DEFAULT_SORT_PROPERTIES = {
|
|
|
4905
4973
|
orderBy: "DESC"
|
|
4906
4974
|
};
|
|
4907
4975
|
|
|
4908
|
-
function ownKeys$
|
|
4909
|
-
function _objectSpread$
|
|
4976
|
+
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4977
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4910
4978
|
var ExportModal = function ExportModal(_ref) {
|
|
4911
4979
|
var showExportModal = _ref.showExportModal,
|
|
4912
4980
|
setShowExportModal = _ref.setShowExportModal,
|
|
@@ -4938,7 +5006,7 @@ var ExportModal = function ExportModal(_ref) {
|
|
|
4938
5006
|
}
|
|
4939
5007
|
};
|
|
4940
5008
|
var handleGenerateClick = function handleGenerateClick() {
|
|
4941
|
-
var payload = _objectSpread$
|
|
5009
|
+
var payload = _objectSpread$4({
|
|
4942
5010
|
kind: "payout",
|
|
4943
5011
|
token: token,
|
|
4944
5012
|
filters: JSON.stringify(filters),
|
|
@@ -5059,8 +5127,8 @@ var renderPayoutIdentifier$1 = ramda.curry(function (route, _ref) {
|
|
|
5059
5127
|
}));
|
|
5060
5128
|
});
|
|
5061
5129
|
|
|
5062
|
-
function ownKeys$
|
|
5063
|
-
function _objectSpread$
|
|
5130
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5131
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5064
5132
|
var useFiltersAndPagination$1 = function useFiltersAndPagination(payoutsPageRoute) {
|
|
5065
5133
|
var urlSearchParams = useURLSearchParams();
|
|
5066
5134
|
var _useState = React.useState(false),
|
|
@@ -5090,7 +5158,7 @@ var useFiltersAndPagination$1 = function useFiltersAndPagination(payoutsPageRout
|
|
|
5090
5158
|
var _getQueryParams = utils$3.getQueryParams(),
|
|
5091
5159
|
_getQueryParams$searc = _getQueryParams.searchTerm,
|
|
5092
5160
|
searchTerm = _getQueryParams$searc === void 0 ? "" : _getQueryParams$searc;
|
|
5093
|
-
var searchKeywordProps = _objectSpread$
|
|
5161
|
+
var searchKeywordProps = _objectSpread$3(_objectSpread$3({}, SEARCH_PROPS), {}, {
|
|
5094
5162
|
key: "search_term",
|
|
5095
5163
|
value: searchTerm.trim()
|
|
5096
5164
|
});
|
|
@@ -5498,7 +5566,7 @@ var PayoutsPage = function PayoutsPage(_ref) {
|
|
|
5498
5566
|
}, t("neetoPayments.payoutsPage.failureMessage")), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
5499
5567
|
className: "neeto-ui-text-black font-medium",
|
|
5500
5568
|
style: "body2"
|
|
5501
|
-
}, failureMessage)))), isAutomatic && /*#__PURE__*/React__default["default"].createElement(Dashboard$1, _extends({}, isPlatformEnabled, {
|
|
5569
|
+
}, failureMessage)))), isAutomatic && /*#__PURE__*/React__default["default"].createElement(Dashboard$1, _extends$1({}, isPlatformEnabled, {
|
|
5502
5570
|
kind: "connected"
|
|
5503
5571
|
}, otherProps, {
|
|
5504
5572
|
headerProps: {
|
|
@@ -5996,8 +6064,8 @@ var SquareCard = function SquareCard(_ref) {
|
|
|
5996
6064
|
}, !card && /*#__PURE__*/React__default["default"].createElement(neetoui.Spinner, null));
|
|
5997
6065
|
};
|
|
5998
6066
|
|
|
5999
|
-
function ownKeys$
|
|
6000
|
-
function _objectSpread$
|
|
6067
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6068
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6001
6069
|
var FilterWrapper = function FilterWrapper(_ref) {
|
|
6002
6070
|
var searchProps = _ref.searchProps,
|
|
6003
6071
|
_ref$headerProps = _ref.headerProps,
|
|
@@ -6022,7 +6090,7 @@ var FilterWrapper = function FilterWrapper(_ref) {
|
|
|
6022
6090
|
var _useTranslation = reactI18next.useTranslation(),
|
|
6023
6091
|
t = _useTranslation.t;
|
|
6024
6092
|
var isTabsVisible = isFilterButtonVisible || tab !== "all";
|
|
6025
|
-
var searchKeywordProps = _objectSpread$
|
|
6093
|
+
var searchKeywordProps = _objectSpread$2(_objectSpread$2({}, searchProps), {}, {
|
|
6026
6094
|
value: searchTerm.trim(),
|
|
6027
6095
|
setValue: neetocist.noop
|
|
6028
6096
|
});
|
|
@@ -6031,7 +6099,7 @@ var FilterWrapper = function FilterWrapper(_ref) {
|
|
|
6031
6099
|
setFilters(filters);
|
|
6032
6100
|
});
|
|
6033
6101
|
};
|
|
6034
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Header__default["default"], _extends({}, _objectSpread$
|
|
6102
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Header__default["default"], _extends$1({}, _objectSpread$2(_objectSpread$2({}, headerProps), {}, {
|
|
6035
6103
|
title: title
|
|
6036
6104
|
}), {
|
|
6037
6105
|
searchProps: {
|
|
@@ -6051,8 +6119,11 @@ var FilterWrapper = function FilterWrapper(_ref) {
|
|
|
6051
6119
|
leftActionBlock: isTabsVisible && dataSize !== 0 && /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
6052
6120
|
className: "neeto-ui-gray-800 mr-2 font-semibold",
|
|
6053
6121
|
component: "h4"
|
|
6054
|
-
}, t("neetoPayments.countOf.".concat(kind), {
|
|
6122
|
+
}, tab === "all" ? t("neetoPayments.countOf.".concat(kind), {
|
|
6055
6123
|
count: dataSize
|
|
6124
|
+
}) : t("neetoPayments.countOf.".concat(kind, "WithStatus"), {
|
|
6125
|
+
count: dataSize,
|
|
6126
|
+
status: tab
|
|
6056
6127
|
})),
|
|
6057
6128
|
rightActionBlock: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(neetoFiltersFrontend.Bar, {
|
|
6058
6129
|
columns: filterableColumns,
|
|
@@ -6112,6 +6183,7 @@ var COLUMNS = [{
|
|
|
6112
6183
|
title: i18next.t("neetoPayments.common.status"),
|
|
6113
6184
|
dataIndex: "status",
|
|
6114
6185
|
key: "status",
|
|
6186
|
+
sorter: true,
|
|
6115
6187
|
render: renderStatus("payment")
|
|
6116
6188
|
}, {
|
|
6117
6189
|
title: i18next.t("neetoPayments.common.identifier"),
|
|
@@ -6123,6 +6195,7 @@ var COLUMNS = [{
|
|
|
6123
6195
|
title: i18next.t("neetoPayments.common.status"),
|
|
6124
6196
|
dataIndex: "status",
|
|
6125
6197
|
key: "refundStatus",
|
|
6198
|
+
sorter: true,
|
|
6126
6199
|
render: renderStatus("refund")
|
|
6127
6200
|
}, {
|
|
6128
6201
|
title: i18next.t("neetoPayments.common.paymentIdentifier"),
|
|
@@ -6134,11 +6207,13 @@ var COLUMNS = [{
|
|
|
6134
6207
|
title: i18next.t("neetoPayments.common.amount"),
|
|
6135
6208
|
dataIndex: "amount",
|
|
6136
6209
|
key: "amount",
|
|
6210
|
+
sorter: true,
|
|
6137
6211
|
width: "150px"
|
|
6138
6212
|
}, {
|
|
6139
6213
|
title: i18next.t("neetoPayments.common.paymentTime"),
|
|
6140
6214
|
dataIndex: "updatedAt",
|
|
6141
6215
|
key: "paymentTime",
|
|
6216
|
+
sorter: true,
|
|
6142
6217
|
width: "220px",
|
|
6143
6218
|
render: renderDate
|
|
6144
6219
|
}];
|
|
@@ -6209,31 +6284,35 @@ var useFiltersAndPagination = function useFiltersAndPagination(_ref) {
|
|
|
6209
6284
|
var _tabMetaData$tab;
|
|
6210
6285
|
return !((_tabMetaData$tab = tabMetaData[tab]) !== null && _tabMetaData$tab !== void 0 && (_tabMetaData$tab = _tabMetaData$tab.isHidden) !== null && _tabMetaData$tab !== void 0 && _tabMetaData$tab[kind]);
|
|
6211
6286
|
});
|
|
6212
|
-
var _useState = React.useState(
|
|
6287
|
+
var _useState = React.useState(DEFAULT_SORT_PROPERTIES$1),
|
|
6213
6288
|
_useState2 = _slicedToArray(_useState, 2),
|
|
6214
|
-
|
|
6215
|
-
|
|
6289
|
+
sortProperties = _useState2[0],
|
|
6290
|
+
setSortProperties = _useState2[1];
|
|
6216
6291
|
var _useState3 = React.useState(false),
|
|
6217
6292
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
var _useState5 = React.useState(
|
|
6293
|
+
isFilterButtonVisible = _useState4[0],
|
|
6294
|
+
setIsFilterButtonVisible = _useState4[1];
|
|
6295
|
+
var _useState5 = React.useState(false),
|
|
6221
6296
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
var _useState7 = React.useState(
|
|
6297
|
+
isFilterPaneOpen = _useState6[0],
|
|
6298
|
+
setIsFilterPaneOpen = _useState6[1];
|
|
6299
|
+
var _useState7 = React.useState(buildDefaultPageProperties(tabs)),
|
|
6225
6300
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
var
|
|
6229
|
-
var _useState9 = React.useState(neetoFiltersFrontend.buildFiltersFromURL(filterableColumns)),
|
|
6301
|
+
pageProperties = _useState8[0],
|
|
6302
|
+
setPageProperties = _useState8[1];
|
|
6303
|
+
var _useState9 = React.useState("all"),
|
|
6230
6304
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
var
|
|
6305
|
+
tab = _useState10[0],
|
|
6306
|
+
setTab = _useState10[1];
|
|
6307
|
+
var filterableColumns = buildFilterColumns(payableEntityColumns);
|
|
6308
|
+
var _useState11 = React.useState(neetoFiltersFrontend.buildFiltersFromURL(filterableColumns)),
|
|
6234
6309
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
6235
|
-
|
|
6236
|
-
|
|
6310
|
+
filters = _useState12[0],
|
|
6311
|
+
setFilters = _useState12[1];
|
|
6312
|
+
var _useState13 = React.useState(0),
|
|
6313
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
6314
|
+
dataSize = _useState14[0],
|
|
6315
|
+
setDataSize = _useState14[1];
|
|
6237
6316
|
var _getQueryParams = utils$3.getQueryParams(),
|
|
6238
6317
|
_getQueryParams$searc = _getQueryParams.searchTerm,
|
|
6239
6318
|
searchTerm = _getQueryParams$searc === void 0 ? "" : _getQueryParams$searc;
|
|
@@ -6257,9 +6336,11 @@ var useFiltersAndPagination = function useFiltersAndPagination(_ref) {
|
|
|
6257
6336
|
tab: tab,
|
|
6258
6337
|
filterableColumns: filterableColumns,
|
|
6259
6338
|
dataSize: dataSize,
|
|
6339
|
+
sortProperties: sortProperties,
|
|
6260
6340
|
setIsFilterButtonVisible: setIsFilterButtonVisible,
|
|
6261
6341
|
setIsFilterPaneOpen: setIsFilterPaneOpen,
|
|
6262
6342
|
setPageProperties: setPageProperties,
|
|
6343
|
+
setSortProperties: setSortProperties,
|
|
6263
6344
|
setFilters: setFilters,
|
|
6264
6345
|
setTab: setTab,
|
|
6265
6346
|
handleTabChange: handleTabChange,
|
|
@@ -6363,7 +6444,7 @@ var useFetchSquareRefunds = function useFetchSquareRefunds() {
|
|
|
6363
6444
|
};
|
|
6364
6445
|
|
|
6365
6446
|
var useFetchSquareData = function useFetchSquareData(_ref) {
|
|
6366
|
-
var _data$kind, _data$kind2, _data$kind3, _data$kind4;
|
|
6447
|
+
var _data$kind, _data$kind2, _data$kind3, _data$kind4, _data$kind5;
|
|
6367
6448
|
var kind = _ref.kind,
|
|
6368
6449
|
holdableId = _ref.holdableId,
|
|
6369
6450
|
payload = _ref.payload;
|
|
@@ -6377,7 +6458,8 @@ var useFetchSquareData = function useFetchSquareData(_ref) {
|
|
|
6377
6458
|
return {
|
|
6378
6459
|
data: isPaymentKind(kind) ? (_data$kind = data[kind]) === null || _data$kind === void 0 || (_data$kind = _data$kind.data) === null || _data$kind === void 0 ? void 0 : _data$kind.payments : (_data$kind2 = data[kind]) === null || _data$kind2 === void 0 || (_data$kind2 = _data$kind2.data) === null || _data$kind2 === void 0 ? void 0 : _data$kind2.refunds,
|
|
6379
6460
|
dataSize: (_data$kind3 = data[kind]) === null || _data$kind3 === void 0 || (_data$kind3 = _data$kind3.data) === null || _data$kind3 === void 0 || (_data$kind3 = _data$kind3.views) === null || _data$kind3 === void 0 ? void 0 : _data$kind3[payload === null || payload === void 0 ? void 0 : payload.tab],
|
|
6380
|
-
isDataLoading: (_data$kind4 = data[kind]) === null || _data$kind4 === void 0 ? void 0 : _data$kind4.isLoading
|
|
6461
|
+
isDataLoading: (_data$kind4 = data[kind]) === null || _data$kind4 === void 0 ? void 0 : _data$kind4.isLoading,
|
|
6462
|
+
isDataFetching: (_data$kind5 = data[kind]) === null || _data$kind5 === void 0 ? void 0 : _data$kind5.isFetching
|
|
6381
6463
|
};
|
|
6382
6464
|
};
|
|
6383
6465
|
|
|
@@ -6394,6 +6476,8 @@ var List = function List(_ref) {
|
|
|
6394
6476
|
tab = _ref.tab,
|
|
6395
6477
|
tabs = _ref.tabs,
|
|
6396
6478
|
handleTabChange = _ref.handleTabChange,
|
|
6479
|
+
sortProperties = _ref.sortProperties,
|
|
6480
|
+
setSortProperties = _ref.setSortProperties,
|
|
6397
6481
|
setDataSize = _ref.setDataSize;
|
|
6398
6482
|
var urlSearchParams = useURLSearchParams();
|
|
6399
6483
|
var history = reactRouterDom.useHistory();
|
|
@@ -6415,11 +6499,13 @@ var List = function List(_ref) {
|
|
|
6415
6499
|
payload: buildPayload({
|
|
6416
6500
|
tab: tab,
|
|
6417
6501
|
filters: filters,
|
|
6418
|
-
pageProperties: pageProperties
|
|
6502
|
+
pageProperties: pageProperties,
|
|
6503
|
+
sortProperties: sortProperties
|
|
6419
6504
|
})
|
|
6420
6505
|
}),
|
|
6421
6506
|
data = _useFetchSquareData.data,
|
|
6422
6507
|
isDataLoading = _useFetchSquareData.isDataLoading,
|
|
6508
|
+
isDataFetching = _useFetchSquareData.isDataFetching,
|
|
6423
6509
|
dataSize = _useFetchSquareData.dataSize;
|
|
6424
6510
|
React.useEffect(function () {
|
|
6425
6511
|
setIsFilterButtonVisible(neetocist.isPresent(data) || neetocist.isPresent(filters));
|
|
@@ -6446,6 +6532,12 @@ var List = function List(_ref) {
|
|
|
6446
6532
|
urlSearchParams.set("tab", validatedTab);
|
|
6447
6533
|
handleTablePaginaton(pageIndex, pageSize);
|
|
6448
6534
|
}, [urlSearchParams]);
|
|
6535
|
+
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
6536
|
+
setSortProperties(neetocist.isPresent(sorter === null || sorter === void 0 ? void 0 : sorter.column) ? {
|
|
6537
|
+
sortBy: neetocist.camelToSnakeCase(sorter.field),
|
|
6538
|
+
orderBy: sorter.order === "ascend" ? "ASC" : "DESC"
|
|
6539
|
+
} : DEFAULT_SORT_PROPERTIES$1);
|
|
6540
|
+
};
|
|
6449
6541
|
if (isSquareAccountLoading || isDataLoading) {
|
|
6450
6542
|
return /*#__PURE__*/React__default["default"].createElement(PageLoader__default["default"], null);
|
|
6451
6543
|
}
|
|
@@ -6453,7 +6545,9 @@ var List = function List(_ref) {
|
|
|
6453
6545
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
6454
6546
|
className: "flex h-full w-full items-center justify-center"
|
|
6455
6547
|
}, /*#__PURE__*/React__default["default"].createElement(neetoui.NoData, {
|
|
6456
|
-
title:
|
|
6548
|
+
title: tab === TAB.all ? t("neetoPayments.emptyState.".concat(kind)) : t("neetoPayments.emptyState.".concat(kind, "WithStatus"), {
|
|
6549
|
+
status: tab
|
|
6550
|
+
})
|
|
6457
6551
|
}));
|
|
6458
6552
|
}
|
|
6459
6553
|
return /*#__PURE__*/React__default["default"].createElement(TableWrapper__default["default"], {
|
|
@@ -6464,24 +6558,27 @@ var List = function List(_ref) {
|
|
|
6464
6558
|
columnData: columnData,
|
|
6465
6559
|
currentPageNumber: (_pageProperties$tab4 = pageProperties[tab]) === null || _pageProperties$tab4 === void 0 ? void 0 : _pageProperties$tab4.page,
|
|
6466
6560
|
handlePageChange: handleTablePaginaton,
|
|
6561
|
+
loading: isDataFetching,
|
|
6467
6562
|
rowData: buildRowData({
|
|
6468
6563
|
data: data,
|
|
6469
6564
|
pageProperties: pageProperties,
|
|
6470
6565
|
tab: tab
|
|
6471
6566
|
}),
|
|
6472
6567
|
rowSelection: false,
|
|
6568
|
+
sortDirections: SORT_DIRECTIONS,
|
|
6473
6569
|
totalCount: dataSize,
|
|
6474
6570
|
paginationProps: {
|
|
6475
6571
|
showSizeChanger: true,
|
|
6476
6572
|
hideOnSinglePage: true,
|
|
6477
6573
|
pageSize: (_pageProperties$tab5 = pageProperties[tab]) === null || _pageProperties$tab5 === void 0 ? void 0 : _pageProperties$tab5.pageSize,
|
|
6478
6574
|
total: dataSize
|
|
6479
|
-
}
|
|
6575
|
+
},
|
|
6576
|
+
onChange: handleTableChange
|
|
6480
6577
|
}));
|
|
6481
6578
|
};
|
|
6482
6579
|
|
|
6483
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6484
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6580
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6581
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6485
6582
|
var SquareDashboard = function SquareDashboard(_ref) {
|
|
6486
6583
|
var searchProps = _ref.searchProps,
|
|
6487
6584
|
_ref$headerProps = _ref.headerProps,
|
|
@@ -6492,6 +6589,8 @@ var SquareDashboard = function SquareDashboard(_ref) {
|
|
|
6492
6589
|
payableEntityColumns = _ref$payableEntityCol === void 0 ? [] : _ref$payableEntityCol,
|
|
6493
6590
|
_ref$kind = _ref.kind,
|
|
6494
6591
|
kind = _ref$kind === void 0 ? "squarePayment" : _ref$kind;
|
|
6592
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
6593
|
+
t = _useTranslation.t;
|
|
6495
6594
|
var filterPaginationState = useFiltersAndPagination({
|
|
6496
6595
|
payableEntityColumns: payableEntityColumns,
|
|
6497
6596
|
kind: kind,
|
|
@@ -6502,13 +6601,15 @@ var SquareDashboard = function SquareDashboard(_ref) {
|
|
|
6502
6601
|
setIsFilterButtonVisible = filterPaginationState.setIsFilterButtonVisible,
|
|
6503
6602
|
pageProperties = filterPaginationState.pageProperties,
|
|
6504
6603
|
setPageProperties = filterPaginationState.setPageProperties,
|
|
6604
|
+
sortProperties = filterPaginationState.sortProperties,
|
|
6605
|
+
setSortProperties = filterPaginationState.setSortProperties,
|
|
6505
6606
|
tab = filterPaginationState.tab,
|
|
6506
6607
|
tabs = filterPaginationState.tabs,
|
|
6507
6608
|
handleTabChange = filterPaginationState.handleTabChange,
|
|
6508
6609
|
setDataSize = filterPaginationState.setDataSize;
|
|
6509
|
-
return /*#__PURE__*/React__default["default"].createElement(FilterWrapper, _extends({
|
|
6510
|
-
title: isPaymentKind(kind) ?
|
|
6511
|
-
}, _objectSpread({
|
|
6610
|
+
return /*#__PURE__*/React__default["default"].createElement(FilterWrapper, _extends$1({
|
|
6611
|
+
title: isPaymentKind(kind) ? t("neetoPayments.title.squarePayment") : t("neetoPayments.title.squareRefund")
|
|
6612
|
+
}, _objectSpread$1({
|
|
6512
6613
|
headerProps: headerProps,
|
|
6513
6614
|
kind: kind,
|
|
6514
6615
|
searchProps: searchProps
|
|
@@ -6523,7 +6624,9 @@ var SquareDashboard = function SquareDashboard(_ref) {
|
|
|
6523
6624
|
setIsFilterButtonVisible: setIsFilterButtonVisible,
|
|
6524
6625
|
setPageProperties: setPageProperties,
|
|
6525
6626
|
tab: tab,
|
|
6526
|
-
tabs: tabs
|
|
6627
|
+
tabs: tabs,
|
|
6628
|
+
sortProperties: sortProperties,
|
|
6629
|
+
setSortProperties: setSortProperties
|
|
6527
6630
|
}));
|
|
6528
6631
|
};
|
|
6529
6632
|
var index$1 = reactUtils.withTitle(withReactQuery(SquareDashboard), i18next.t("neetoPayments.common.squarePayments"));
|
|
@@ -6548,7 +6651,7 @@ var PaymentKindRestrictionAlert = function PaymentKindRestrictionAlert(_ref) {
|
|
|
6548
6651
|
_ref$onClose = _ref.onClose,
|
|
6549
6652
|
onClose = _ref$onClose === void 0 ? neetocist.noop : _ref$onClose,
|
|
6550
6653
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
6551
|
-
return /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, _extends({
|
|
6654
|
+
return /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, _extends$1({
|
|
6552
6655
|
isOpen: isOpen,
|
|
6553
6656
|
onClose: onClose,
|
|
6554
6657
|
message: STRIPE_ALERT_PAYMENT_KIND_CONTENT[paymentKind].message,
|
|
@@ -6653,6 +6756,2050 @@ var useStripePromise = function useStripePromise(stripeAccountIdentifier) {
|
|
|
6653
6756
|
return stripePromise;
|
|
6654
6757
|
};
|
|
6655
6758
|
|
|
6759
|
+
var _path, _path2, _path3;
|
|
6760
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
6761
|
+
const SvgStripe = props => /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
6762
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6763
|
+
width: 54,
|
|
6764
|
+
height: 54,
|
|
6765
|
+
fill: "#6772e5",
|
|
6766
|
+
viewBox: "0 0 32 32"
|
|
6767
|
+
}, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
|
|
6768
|
+
fillRule: "evenodd",
|
|
6769
|
+
d: "M111.328 15.602c0-4.97-2.415-8.9-7.013-8.9s-7.423 3.924-7.423 8.863c0 5.85 3.32 8.8 8.036 8.8 2.318 0 4.06-.528 5.377-1.26V19.22a10.246 10.246 0 0 1-4.764 1.075c-1.9 0-3.556-.67-3.774-2.943h9.497a39.64 39.64 0 0 0 .063-1.748zm-9.606-1.835c0-2.186 1.35-3.1 2.56-3.1s2.454.906 2.454 3.1zM89.4 6.712a5.434 5.434 0 0 0-3.801 1.509l-.254-1.208h-4.27v22.64l4.85-1.032v-5.488a5.434 5.434 0 0 0 3.444 1.265c3.472 0 6.64-2.792 6.64-8.957.003-5.66-3.206-8.73-6.614-8.73zM88.23 20.1a2.898 2.898 0 0 1-2.288-.906l-.03-7.2a2.928 2.928 0 0 1 2.315-.96c1.775 0 2.998 2 2.998 4.528.003 2.593-1.198 4.546-2.995 4.546zM79.25.57l-4.87 1.035v3.95l4.87-1.032z"
|
|
6770
|
+
})), _path2 || (_path2 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
6771
|
+
d: "M74.38 7.035h4.87V24.04h-4.87z"
|
|
6772
|
+
})), _path3 || (_path3 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
6773
|
+
fillRule: "evenodd",
|
|
6774
|
+
d: "m69.164 8.47-.302-1.434h-4.196V24.04h4.848V12.5c1.147-1.5 3.082-1.208 3.698-1.017V7.038c-.646-.232-2.913-.658-4.048 1.43zm-9.73-5.646L54.698 3.83l-.02 15.562c0 2.87 2.158 4.993 5.038 4.993 1.585 0 2.756-.302 3.405-.643v-3.95c-.622.248-3.683 1.138-3.683-1.72v-6.9h3.683V7.035h-3.683zM46.3 11.97c0-.758.63-1.05 1.648-1.05a10.868 10.868 0 0 1 4.83 1.25V7.6a12.815 12.815 0 0 0-4.83-.888c-3.924 0-6.557 2.056-6.557 5.488 0 5.37 7.375 4.498 7.375 6.813 0 .906-.78 1.186-1.863 1.186-1.606 0-3.68-.664-5.307-1.55v4.63a13.461 13.461 0 0 0 5.307 1.117c4.033 0 6.813-1.992 6.813-5.485 0-5.796-7.417-4.76-7.417-6.943zM13.88 9.515c0-1.37 1.14-1.9 2.982-1.9A19.661 19.661 0 0 1 25.6 9.876v-8.27A23.184 23.184 0 0 0 16.862.001C9.762.001 5 3.72 5 9.93c0 9.716 13.342 8.138 13.342 12.326 0 1.638-1.4 2.146-3.37 2.146-2.905 0-6.657-1.202-9.6-2.802v8.378A24.353 24.353 0 0 0 14.973 32C22.27 32 27.3 28.395 27.3 22.077c0-10.486-13.42-8.613-13.42-12.56z"
|
|
6775
|
+
})));
|
|
6776
|
+
|
|
6777
|
+
var fetchCountries = function fetchCountries() {
|
|
6778
|
+
return axios__default["default"].get("".concat(BASE_URL, "/api/v1/stripe/countries"));
|
|
6779
|
+
};
|
|
6780
|
+
var countriesApi = {
|
|
6781
|
+
fetchCountries: fetchCountries
|
|
6782
|
+
};
|
|
6783
|
+
|
|
6784
|
+
var useFetchStripeCountries = function useFetchStripeCountries() {
|
|
6785
|
+
return reactQuery.useQuery(QUERY_KEYS.STRIPE_COUNTRIES, function () {
|
|
6786
|
+
return countriesApi.fetchCountries();
|
|
6787
|
+
});
|
|
6788
|
+
};
|
|
6789
|
+
|
|
6790
|
+
var POLLING_INTERVAL = 5000;
|
|
6791
|
+
var MAX_POLLING_TIME = 30000;
|
|
6792
|
+
var INITIAL_VALUES = {
|
|
6793
|
+
country: "",
|
|
6794
|
+
return_url: ""
|
|
6795
|
+
};
|
|
6796
|
+
var VALIDATION_SCHEMA = yup__namespace.object().shape({
|
|
6797
|
+
country: yup__namespace.object().required(i18next.t("neetoPayments.validations.countryRequired")),
|
|
6798
|
+
returnUrl: yup__namespace.string().url(i18next.t("neetoPayments.validations.invalidUrl"))
|
|
6799
|
+
});
|
|
6800
|
+
|
|
6801
|
+
var STEPS = {
|
|
6802
|
+
connect: "connect",
|
|
6803
|
+
configure: "configure",
|
|
6804
|
+
finish: "finish",
|
|
6805
|
+
demo: "demo"
|
|
6806
|
+
};
|
|
6807
|
+
var INTEGRATION_STEPS = [{
|
|
6808
|
+
step: "1",
|
|
6809
|
+
label: i18next.t("neetoPayments.common.connect"),
|
|
6810
|
+
isActive: false,
|
|
6811
|
+
isCompleted: false
|
|
6812
|
+
}, {
|
|
6813
|
+
step: "2",
|
|
6814
|
+
label: i18next.t("neetoPayments.common.configure"),
|
|
6815
|
+
isActive: false,
|
|
6816
|
+
isCompleted: false
|
|
6817
|
+
}, {
|
|
6818
|
+
step: "3",
|
|
6819
|
+
label: i18next.t("neetoPayments.common.finish"),
|
|
6820
|
+
isActive: false,
|
|
6821
|
+
isCompleted: true
|
|
6822
|
+
}
|
|
6823
|
+
// { step: "4", label: "demo", isActive: false, isCompleted: false },
|
|
6824
|
+
];
|
|
6825
|
+
|
|
6826
|
+
var INTEGRATION_METHOD = {
|
|
6827
|
+
useExistingAccount: "use_existing_account",
|
|
6828
|
+
createNewAccount: "create_new_account"
|
|
6829
|
+
};
|
|
6830
|
+
var STRIPE_CONNECT_URL = "/".concat(BASE_URL, "/api/v1/integrations/connect/stripe");
|
|
6831
|
+
|
|
6832
|
+
var buildRefreshUrl = function buildRefreshUrl(accountId, returnUrl) {
|
|
6833
|
+
return "/payments/api/v1/stripe/callbacks/".concat(accountId, "/refresh?return_url=").concat(returnUrl);
|
|
6834
|
+
};
|
|
6835
|
+
var buildCountryOptions = function buildCountryOptions(countries) {
|
|
6836
|
+
var _Object$entries;
|
|
6837
|
+
return (_Object$entries = Object.entries(countries)) === null || _Object$entries === void 0 ? void 0 : _Object$entries.map(function (country) {
|
|
6838
|
+
return {
|
|
6839
|
+
label: neetocist.humanize(country[0]),
|
|
6840
|
+
value: country[1]
|
|
6841
|
+
};
|
|
6842
|
+
});
|
|
6843
|
+
};
|
|
6844
|
+
|
|
6845
|
+
var AccountForm = function AccountForm(_ref) {
|
|
6846
|
+
var holdableId = _ref.holdableId,
|
|
6847
|
+
returnUrl = _ref.returnUrl;
|
|
6848
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
6849
|
+
t = _useTranslation.t;
|
|
6850
|
+
var _useState = React.useState(false),
|
|
6851
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6852
|
+
isPolling = _useState2[0],
|
|
6853
|
+
setIsPolling = _useState2[1];
|
|
6854
|
+
var submitButtonLabel = isPolling ? t("neetoPayments.integrationModal.creating") : t("neetoPayments.common.connect");
|
|
6855
|
+
var refetchInterval = function refetchInterval() {
|
|
6856
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
6857
|
+
jobStatus = _ref2.jobStatus,
|
|
6858
|
+
onboarding = _ref2.onboarding;
|
|
6859
|
+
if (jobStatus === "complete") {
|
|
6860
|
+
window.open(onboarding === null || onboarding === void 0 ? void 0 : onboarding.url, "_self");
|
|
6861
|
+
return false;
|
|
6862
|
+
}
|
|
6863
|
+
return POLLING_INTERVAL;
|
|
6864
|
+
};
|
|
6865
|
+
var _useCreateStripeAccou = useCreateStripeAccount({
|
|
6866
|
+
onSuccess: function onSuccess() {
|
|
6867
|
+
return setIsPolling(true);
|
|
6868
|
+
}
|
|
6869
|
+
}),
|
|
6870
|
+
isCreating = _useCreateStripeAccou.isLoading,
|
|
6871
|
+
_useCreateStripeAccou2 = _useCreateStripeAccou.data,
|
|
6872
|
+
_useCreateStripeAccou3 = _useCreateStripeAccou2 === void 0 ? {} : _useCreateStripeAccou2,
|
|
6873
|
+
jobId = _useCreateStripeAccou3.jobId,
|
|
6874
|
+
createStripeAccount = _useCreateStripeAccou.mutate;
|
|
6875
|
+
usePollingStripeAccountCreationStatus(jobId, {
|
|
6876
|
+
refetchInterval: refetchInterval,
|
|
6877
|
+
enabled: neetocist.isPresent(jobId)
|
|
6878
|
+
});
|
|
6879
|
+
var _useFetchStripeCountr = useFetchStripeCountries(),
|
|
6880
|
+
isLoading = _useFetchStripeCountr.isLoading,
|
|
6881
|
+
_useFetchStripeCountr2 = _useFetchStripeCountr.data,
|
|
6882
|
+
_useFetchStripeCountr3 = _useFetchStripeCountr2 === void 0 ? {} : _useFetchStripeCountr2,
|
|
6883
|
+
_useFetchStripeCountr4 = _useFetchStripeCountr3.countries,
|
|
6884
|
+
countries = _useFetchStripeCountr4 === void 0 ? {} : _useFetchStripeCountr4;
|
|
6885
|
+
var handleSubmit = function handleSubmit(_ref3) {
|
|
6886
|
+
var country = _ref3.country;
|
|
6887
|
+
var payload = {
|
|
6888
|
+
returnUrl: returnUrl,
|
|
6889
|
+
country: country.value,
|
|
6890
|
+
holdableId: holdableId
|
|
6891
|
+
};
|
|
6892
|
+
createStripeAccount(payload);
|
|
6893
|
+
};
|
|
6894
|
+
if (isLoading) {
|
|
6895
|
+
return /*#__PURE__*/React__default["default"].createElement(PageLoader__default["default"], null);
|
|
6896
|
+
}
|
|
6897
|
+
return /*#__PURE__*/React__default["default"].createElement(formik.Form, {
|
|
6898
|
+
formikProps: {
|
|
6899
|
+
enableReinitialize: true,
|
|
6900
|
+
initialValues: INITIAL_VALUES,
|
|
6901
|
+
validationSchema: VALIDATION_SCHEMA,
|
|
6902
|
+
onSubmit: handleSubmit
|
|
6903
|
+
}
|
|
6904
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
6905
|
+
className: "space-y-3"
|
|
6906
|
+
}, /*#__PURE__*/React__default["default"].createElement(formik.Select, {
|
|
6907
|
+
required: true,
|
|
6908
|
+
helpText: t("neetoPayments.integrationModal.form.helpText"),
|
|
6909
|
+
label: t("neetoPayments.integrationModal.form.label"),
|
|
6910
|
+
name: "country",
|
|
6911
|
+
options: buildCountryOptions(countries),
|
|
6912
|
+
placeholder: t("neetoPayments.integrationModal.form.placeholder")
|
|
6913
|
+
}), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
|
|
6914
|
+
disabled: isCreating || isPolling,
|
|
6915
|
+
label: submitButtonLabel,
|
|
6916
|
+
loading: isCreating || isPolling,
|
|
6917
|
+
type: "submit"
|
|
6918
|
+
})));
|
|
6919
|
+
};
|
|
6920
|
+
|
|
6921
|
+
var AccountDetails = function AccountDetails(_ref) {
|
|
6922
|
+
var holdableId = _ref.holdableId;
|
|
6923
|
+
var _useFetchConnectedStr = useFetchConnectedStripeAccount(holdableId),
|
|
6924
|
+
_useFetchConnectedStr2 = _useFetchConnectedStr.data,
|
|
6925
|
+
_useFetchConnectedStr3 = _useFetchConnectedStr2 === void 0 ? {} : _useFetchConnectedStr2,
|
|
6926
|
+
stripeAccount = _useFetchConnectedStr3.account;
|
|
6927
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
6928
|
+
t = _useTranslation.t;
|
|
6929
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
6930
|
+
className: "mb-6 space-y-3"
|
|
6931
|
+
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
6932
|
+
style: "h5",
|
|
6933
|
+
weight: "medium"
|
|
6934
|
+
}, t("neetoPayments.integrationModal.account.title")), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
6935
|
+
className: "grid grid-cols-4 gap-y-3"
|
|
6936
|
+
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Label, {
|
|
6937
|
+
className: "neeto-ui-text-gray-800"
|
|
6938
|
+
}, t("neetoPayments.common.id")), /*#__PURE__*/React__default["default"].createElement(neetoui.Label, {
|
|
6939
|
+
className: "neeto-ui-text-gray-800 col-span-3"
|
|
6940
|
+
}, stripeAccount === null || stripeAccount === void 0 ? void 0 : stripeAccount.identifier), /*#__PURE__*/React__default["default"].createElement(neetoui.Label, {
|
|
6941
|
+
className: "neeto-ui-text-gray-800"
|
|
6942
|
+
}, t("neetoPayments.common.email")), /*#__PURE__*/React__default["default"].createElement(neetoui.Label, {
|
|
6943
|
+
className: "neeto-ui-text-gray-800 col-span-3"
|
|
6944
|
+
}, stripeAccount === null || stripeAccount === void 0 ? void 0 : stripeAccount.email), /*#__PURE__*/React__default["default"].createElement(neetoui.Label, {
|
|
6945
|
+
className: "neeto-ui-text-gray-800"
|
|
6946
|
+
}, t("neetoPayments.common.country")), /*#__PURE__*/React__default["default"].createElement(neetoui.Label, {
|
|
6947
|
+
className: "neeto-ui-text-gray-800 col-span-3"
|
|
6948
|
+
}, stripeAccount === null || stripeAccount === void 0 ? void 0 : stripeAccount.country)));
|
|
6949
|
+
};
|
|
6950
|
+
|
|
6951
|
+
var AccountProcessing = function AccountProcessing(_ref) {
|
|
6952
|
+
var holdableId = _ref.holdableId,
|
|
6953
|
+
returnUrl = _ref.returnUrl;
|
|
6954
|
+
var _useState = React.useState(false),
|
|
6955
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6956
|
+
isAlertOpen = _useState2[0],
|
|
6957
|
+
setIsAlertOpen = _useState2[1];
|
|
6958
|
+
var _useState3 = React.useState(false),
|
|
6959
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
6960
|
+
isPolling = _useState4[0],
|
|
6961
|
+
setIsPolling = _useState4[1];
|
|
6962
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
6963
|
+
t = _useTranslation.t;
|
|
6964
|
+
var urlSearchParams = useURLSearchParams();
|
|
6965
|
+
var isStripeCallback = urlSearchParams.get("app") === "stripe";
|
|
6966
|
+
React.useEffect(function () {
|
|
6967
|
+
if (!isStripeCallback) return;
|
|
6968
|
+
setIsPolling(true);
|
|
6969
|
+
setInterval(function () {
|
|
6970
|
+
setIsPolling(false);
|
|
6971
|
+
}, MAX_POLLING_TIME);
|
|
6972
|
+
}, [isStripeCallback]);
|
|
6973
|
+
var _useFetchConnectedStr = useFetchConnectedStripeAccount(holdableId),
|
|
6974
|
+
_useFetchConnectedStr2 = _useFetchConnectedStr.data,
|
|
6975
|
+
_useFetchConnectedStr3 = _useFetchConnectedStr2 === void 0 ? {} : _useFetchConnectedStr2,
|
|
6976
|
+
stripeAccount = _useFetchConnectedStr3.account;
|
|
6977
|
+
var _useDestroyStripeAcco = useDestroyStripeAccount({
|
|
6978
|
+
onSuccess: function onSuccess() {
|
|
6979
|
+
return setIsAlertOpen(false);
|
|
6980
|
+
},
|
|
6981
|
+
holdableId: holdableId
|
|
6982
|
+
}),
|
|
6983
|
+
isStripeAccountDestroying = _useDestroyStripeAcco.isLoading,
|
|
6984
|
+
destroyStripeAccount = _useDestroyStripeAcco.mutate;
|
|
6985
|
+
var refetchInterval = function refetchInterval() {
|
|
6986
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
6987
|
+
account = _ref2.account;
|
|
6988
|
+
if (isStripeCallback && !(account !== null && account !== void 0 && account.isConnected) && isPolling) {
|
|
6989
|
+
return POLLING_INTERVAL;
|
|
6990
|
+
}
|
|
6991
|
+
if (account !== null && account !== void 0 && account.isConnected) {
|
|
6992
|
+
setIsPolling(false);
|
|
6993
|
+
}
|
|
6994
|
+
return false;
|
|
6995
|
+
};
|
|
6996
|
+
usePollingStripeAccount(holdableId, {
|
|
6997
|
+
refetchInterval: refetchInterval
|
|
6998
|
+
});
|
|
6999
|
+
var isAccountProcessingFailed = isStripeCallback && !isPolling && !(stripeAccount !== null && stripeAccount !== void 0 && stripeAccount.isConnected);
|
|
7000
|
+
var buttonLabel = function buttonLabel() {
|
|
7001
|
+
if (isPolling) {
|
|
7002
|
+
return t("neetoPayments.integrationModal.creating");
|
|
7003
|
+
}
|
|
7004
|
+
if (isAccountProcessingFailed) {
|
|
7005
|
+
return t("neetoPayments.integrationModal.failedButton");
|
|
7006
|
+
}
|
|
7007
|
+
return t("neetoPayments.common.continue");
|
|
7008
|
+
};
|
|
7009
|
+
var handleUseAnotherStripeAccount = function handleUseAnotherStripeAccount() {
|
|
7010
|
+
destroyStripeAccount(stripeAccount === null || stripeAccount === void 0 ? void 0 : stripeAccount.id);
|
|
7011
|
+
};
|
|
7012
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(AccountDetails, null), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7013
|
+
className: "flex flex-col items-start space-y-2"
|
|
7014
|
+
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
|
|
7015
|
+
disabled: isPolling,
|
|
7016
|
+
href: buildRefreshUrl(stripeAccount === null || stripeAccount === void 0 ? void 0 : stripeAccount.id, returnUrl),
|
|
7017
|
+
label: buttonLabel(),
|
|
7018
|
+
loading: isPolling,
|
|
7019
|
+
size: "small"
|
|
7020
|
+
}), !isPolling && !isAccountProcessingFailed && /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
|
|
7021
|
+
disabled: isStripeAccountDestroying || isPolling,
|
|
7022
|
+
label: t("neetoPayments.integrationModal.anotherAccount"),
|
|
7023
|
+
size: "small",
|
|
7024
|
+
style: "link",
|
|
7025
|
+
onClick: function onClick() {
|
|
7026
|
+
return setIsAlertOpen(true);
|
|
7027
|
+
}
|
|
7028
|
+
})), /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, {
|
|
7029
|
+
isOpen: isAlertOpen,
|
|
7030
|
+
title: t("neetoPayments.integrationModal.alert.changeTitle"),
|
|
7031
|
+
message: /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
|
|
7032
|
+
i18nKey: "neetoPayments.integrationModal.alert.changeMessage",
|
|
7033
|
+
values: {
|
|
7034
|
+
account: stripeAccount === null || stripeAccount === void 0 ? void 0 : stripeAccount.email
|
|
7035
|
+
}
|
|
7036
|
+
}),
|
|
7037
|
+
onClose: function onClose() {
|
|
7038
|
+
return setIsAlertOpen(false);
|
|
7039
|
+
},
|
|
7040
|
+
onSubmit: handleUseAnotherStripeAccount
|
|
7041
|
+
}));
|
|
7042
|
+
};
|
|
7043
|
+
|
|
7044
|
+
var Configure = function Configure(_ref) {
|
|
7045
|
+
var holdableId = _ref.holdableId,
|
|
7046
|
+
returnUrl = _ref.returnUrl;
|
|
7047
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
7048
|
+
t = _useTranslation.t;
|
|
7049
|
+
var _useFetchConnectedStr = useFetchConnectedStripeAccount(holdableId),
|
|
7050
|
+
_useFetchConnectedStr2 = _useFetchConnectedStr.data,
|
|
7051
|
+
_useFetchConnectedStr3 = _useFetchConnectedStr2 === void 0 ? {} : _useFetchConnectedStr2,
|
|
7052
|
+
stripeAccount = _useFetchConnectedStr3.account;
|
|
7053
|
+
var handleStripeAccountCreated = function handleStripeAccountCreated(_ref2) {
|
|
7054
|
+
var onboarding = _ref2.onboarding;
|
|
7055
|
+
window.open(onboarding === null || onboarding === void 0 ? void 0 : onboarding.url, "_self");
|
|
7056
|
+
};
|
|
7057
|
+
var connectDescription = neetocist.isPresent(stripeAccount) ? t("neetoPayments.integrationModal.linkedDescription") : t("neetoPayments.integrationModal.subtitle");
|
|
7058
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7059
|
+
className: "mx-auto w-full max-w-lg space-y-8"
|
|
7060
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7061
|
+
className: "space-y-2"
|
|
7062
|
+
}, /*#__PURE__*/React__default["default"].createElement(SvgStripe, null), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
7063
|
+
"data-cy": "configure-payment-title",
|
|
7064
|
+
style: "h2",
|
|
7065
|
+
weight: "semibold"
|
|
7066
|
+
}, t("neetoPayments.integrationModal.title")), /*#__PURE__*/React__default["default"].createElement(neetoui.Label, {
|
|
7067
|
+
className: "leading-snug"
|
|
7068
|
+
}, connectDescription)), neetocist.isPresent(stripeAccount) ? /*#__PURE__*/React__default["default"].createElement(AccountProcessing, {
|
|
7069
|
+
onAccountCreated: handleStripeAccountCreated,
|
|
7070
|
+
holdableId: holdableId,
|
|
7071
|
+
returnUrl: returnUrl
|
|
7072
|
+
}) : /*#__PURE__*/React__default["default"].createElement(AccountForm, {
|
|
7073
|
+
holdableId: holdableId,
|
|
7074
|
+
returnUrl: returnUrl,
|
|
7075
|
+
onAccountCreated: handleStripeAccountCreated
|
|
7076
|
+
}));
|
|
7077
|
+
};
|
|
7078
|
+
|
|
7079
|
+
/*! @license DOMPurify 3.0.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.2/LICENSE */
|
|
7080
|
+
|
|
7081
|
+
const {
|
|
7082
|
+
entries,
|
|
7083
|
+
setPrototypeOf,
|
|
7084
|
+
isFrozen,
|
|
7085
|
+
getPrototypeOf,
|
|
7086
|
+
getOwnPropertyDescriptor
|
|
7087
|
+
} = Object;
|
|
7088
|
+
let {
|
|
7089
|
+
freeze,
|
|
7090
|
+
seal,
|
|
7091
|
+
create
|
|
7092
|
+
} = Object; // eslint-disable-line import/no-mutable-exports
|
|
7093
|
+
|
|
7094
|
+
let {
|
|
7095
|
+
apply,
|
|
7096
|
+
construct
|
|
7097
|
+
} = typeof Reflect !== 'undefined' && Reflect;
|
|
7098
|
+
|
|
7099
|
+
if (!apply) {
|
|
7100
|
+
apply = function apply(fun, thisValue, args) {
|
|
7101
|
+
return fun.apply(thisValue, args);
|
|
7102
|
+
};
|
|
7103
|
+
}
|
|
7104
|
+
|
|
7105
|
+
if (!freeze) {
|
|
7106
|
+
freeze = function freeze(x) {
|
|
7107
|
+
return x;
|
|
7108
|
+
};
|
|
7109
|
+
}
|
|
7110
|
+
|
|
7111
|
+
if (!seal) {
|
|
7112
|
+
seal = function seal(x) {
|
|
7113
|
+
return x;
|
|
7114
|
+
};
|
|
7115
|
+
}
|
|
7116
|
+
|
|
7117
|
+
if (!construct) {
|
|
7118
|
+
construct = function construct(Func, args) {
|
|
7119
|
+
return new Func(...args);
|
|
7120
|
+
};
|
|
7121
|
+
}
|
|
7122
|
+
|
|
7123
|
+
const arrayForEach = unapply(Array.prototype.forEach);
|
|
7124
|
+
const arrayPop = unapply(Array.prototype.pop);
|
|
7125
|
+
const arrayPush = unapply(Array.prototype.push);
|
|
7126
|
+
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
7127
|
+
const stringToString = unapply(String.prototype.toString);
|
|
7128
|
+
const stringMatch = unapply(String.prototype.match);
|
|
7129
|
+
const stringReplace = unapply(String.prototype.replace);
|
|
7130
|
+
const stringIndexOf = unapply(String.prototype.indexOf);
|
|
7131
|
+
const stringTrim = unapply(String.prototype.trim);
|
|
7132
|
+
const regExpTest = unapply(RegExp.prototype.test);
|
|
7133
|
+
const typeErrorCreate = unconstruct(TypeError);
|
|
7134
|
+
function unapply(func) {
|
|
7135
|
+
return function (thisArg) {
|
|
7136
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
7137
|
+
args[_key - 1] = arguments[_key];
|
|
7138
|
+
}
|
|
7139
|
+
|
|
7140
|
+
return apply(func, thisArg, args);
|
|
7141
|
+
};
|
|
7142
|
+
}
|
|
7143
|
+
function unconstruct(func) {
|
|
7144
|
+
return function () {
|
|
7145
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
7146
|
+
args[_key2] = arguments[_key2];
|
|
7147
|
+
}
|
|
7148
|
+
|
|
7149
|
+
return construct(func, args);
|
|
7150
|
+
};
|
|
7151
|
+
}
|
|
7152
|
+
/* Add properties to a lookup table */
|
|
7153
|
+
|
|
7154
|
+
function addToSet(set, array, transformCaseFunc) {
|
|
7155
|
+
transformCaseFunc = transformCaseFunc ? transformCaseFunc : stringToLowerCase;
|
|
7156
|
+
|
|
7157
|
+
if (setPrototypeOf) {
|
|
7158
|
+
// Make 'in' and truthy checks like Boolean(set.constructor)
|
|
7159
|
+
// independent of any properties defined on Object.prototype.
|
|
7160
|
+
// Prevent prototype setters from intercepting set as a this value.
|
|
7161
|
+
setPrototypeOf(set, null);
|
|
7162
|
+
}
|
|
7163
|
+
|
|
7164
|
+
let l = array.length;
|
|
7165
|
+
|
|
7166
|
+
while (l--) {
|
|
7167
|
+
let element = array[l];
|
|
7168
|
+
|
|
7169
|
+
if (typeof element === 'string') {
|
|
7170
|
+
const lcElement = transformCaseFunc(element);
|
|
7171
|
+
|
|
7172
|
+
if (lcElement !== element) {
|
|
7173
|
+
// Config presets (e.g. tags.js, attrs.js) are immutable.
|
|
7174
|
+
if (!isFrozen(array)) {
|
|
7175
|
+
array[l] = lcElement;
|
|
7176
|
+
}
|
|
7177
|
+
|
|
7178
|
+
element = lcElement;
|
|
7179
|
+
}
|
|
7180
|
+
}
|
|
7181
|
+
|
|
7182
|
+
set[element] = true;
|
|
7183
|
+
}
|
|
7184
|
+
|
|
7185
|
+
return set;
|
|
7186
|
+
}
|
|
7187
|
+
/* Shallow clone an object */
|
|
7188
|
+
|
|
7189
|
+
function clone(object) {
|
|
7190
|
+
const newObject = create(null);
|
|
7191
|
+
|
|
7192
|
+
for (const [property, value] of entries(object)) {
|
|
7193
|
+
newObject[property] = value;
|
|
7194
|
+
}
|
|
7195
|
+
|
|
7196
|
+
return newObject;
|
|
7197
|
+
}
|
|
7198
|
+
/* This method automatically checks if the prop is function
|
|
7199
|
+
* or getter and behaves accordingly. */
|
|
7200
|
+
|
|
7201
|
+
function lookupGetter(object, prop) {
|
|
7202
|
+
while (object !== null) {
|
|
7203
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
7204
|
+
|
|
7205
|
+
if (desc) {
|
|
7206
|
+
if (desc.get) {
|
|
7207
|
+
return unapply(desc.get);
|
|
7208
|
+
}
|
|
7209
|
+
|
|
7210
|
+
if (typeof desc.value === 'function') {
|
|
7211
|
+
return unapply(desc.value);
|
|
7212
|
+
}
|
|
7213
|
+
}
|
|
7214
|
+
|
|
7215
|
+
object = getPrototypeOf(object);
|
|
7216
|
+
}
|
|
7217
|
+
|
|
7218
|
+
function fallbackValue(element) {
|
|
7219
|
+
console.warn('fallback value for', element);
|
|
7220
|
+
return null;
|
|
7221
|
+
}
|
|
7222
|
+
|
|
7223
|
+
return fallbackValue;
|
|
7224
|
+
}
|
|
7225
|
+
|
|
7226
|
+
const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); // SVG
|
|
7227
|
+
|
|
7228
|
+
const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
|
|
7229
|
+
const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); // List of SVG elements that are disallowed by default.
|
|
7230
|
+
// We still need to know them so that we can do namespace
|
|
7231
|
+
// checks properly in case one wants to add them to
|
|
7232
|
+
// allow-list.
|
|
7233
|
+
|
|
7234
|
+
const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
|
|
7235
|
+
const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); // Similarly to SVG, we want to know all MathML elements,
|
|
7236
|
+
// even those that we disallow by default.
|
|
7237
|
+
|
|
7238
|
+
const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
7239
|
+
const text = freeze(['#text']);
|
|
7240
|
+
|
|
7241
|
+
const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
|
|
7242
|
+
const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
7243
|
+
const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
|
|
7244
|
+
const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
7245
|
+
|
|
7246
|
+
const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
|
7247
|
+
|
|
7248
|
+
const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
|
7249
|
+
const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
|
|
7250
|
+
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
|
|
7251
|
+
|
|
7252
|
+
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
7253
|
+
|
|
7254
|
+
const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
|
|
7255
|
+
);
|
|
7256
|
+
const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
7257
|
+
const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
|
|
7258
|
+
);
|
|
7259
|
+
const DOCTYPE_NAME = seal(/^html$/i);
|
|
7260
|
+
|
|
7261
|
+
var EXPRESSIONS = /*#__PURE__*/Object.freeze({
|
|
7262
|
+
__proto__: null,
|
|
7263
|
+
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
|
7264
|
+
ERB_EXPR: ERB_EXPR,
|
|
7265
|
+
TMPLIT_EXPR: TMPLIT_EXPR,
|
|
7266
|
+
DATA_ATTR: DATA_ATTR,
|
|
7267
|
+
ARIA_ATTR: ARIA_ATTR,
|
|
7268
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
|
7269
|
+
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
|
7270
|
+
ATTR_WHITESPACE: ATTR_WHITESPACE,
|
|
7271
|
+
DOCTYPE_NAME: DOCTYPE_NAME
|
|
7272
|
+
});
|
|
7273
|
+
|
|
7274
|
+
const getGlobal = () => typeof window === 'undefined' ? null : window;
|
|
7275
|
+
/**
|
|
7276
|
+
* Creates a no-op policy for internal use only.
|
|
7277
|
+
* Don't export this function outside this module!
|
|
7278
|
+
* @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
|
|
7279
|
+
* @param {Document} document The document object (to determine policy name suffix)
|
|
7280
|
+
* @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
|
|
7281
|
+
* are not supported).
|
|
7282
|
+
*/
|
|
7283
|
+
|
|
7284
|
+
|
|
7285
|
+
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
|
|
7286
|
+
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
|
7287
|
+
return null;
|
|
7288
|
+
} // Allow the callers to control the unique policy name
|
|
7289
|
+
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
|
7290
|
+
// Policy creation with duplicate names throws in Trusted Types.
|
|
7291
|
+
|
|
7292
|
+
|
|
7293
|
+
let suffix = null;
|
|
7294
|
+
const ATTR_NAME = 'data-tt-policy-suffix';
|
|
7295
|
+
|
|
7296
|
+
if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
|
|
7297
|
+
suffix = document.currentScript.getAttribute(ATTR_NAME);
|
|
7298
|
+
}
|
|
7299
|
+
|
|
7300
|
+
const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
|
|
7301
|
+
|
|
7302
|
+
try {
|
|
7303
|
+
return trustedTypes.createPolicy(policyName, {
|
|
7304
|
+
createHTML(html) {
|
|
7305
|
+
return html;
|
|
7306
|
+
},
|
|
7307
|
+
|
|
7308
|
+
createScriptURL(scriptUrl) {
|
|
7309
|
+
return scriptUrl;
|
|
7310
|
+
}
|
|
7311
|
+
|
|
7312
|
+
});
|
|
7313
|
+
} catch (_) {
|
|
7314
|
+
// Policy creation failed (most likely another DOMPurify script has
|
|
7315
|
+
// already run). Skip creating the policy, as this will only cause errors
|
|
7316
|
+
// if TT are enforced.
|
|
7317
|
+
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
|
7318
|
+
return null;
|
|
7319
|
+
}
|
|
7320
|
+
};
|
|
7321
|
+
|
|
7322
|
+
function createDOMPurify() {
|
|
7323
|
+
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
7324
|
+
|
|
7325
|
+
const DOMPurify = root => createDOMPurify(root);
|
|
7326
|
+
/**
|
|
7327
|
+
* Version label, exposed for easier checks
|
|
7328
|
+
* if DOMPurify is up to date or not
|
|
7329
|
+
*/
|
|
7330
|
+
|
|
7331
|
+
|
|
7332
|
+
DOMPurify.version = '3.0.2';
|
|
7333
|
+
/**
|
|
7334
|
+
* Array of elements that DOMPurify removed during sanitation.
|
|
7335
|
+
* Empty if nothing was removed.
|
|
7336
|
+
*/
|
|
7337
|
+
|
|
7338
|
+
DOMPurify.removed = [];
|
|
7339
|
+
|
|
7340
|
+
if (!window || !window.document || window.document.nodeType !== 9) {
|
|
7341
|
+
// Not running in a browser, provide a factory function
|
|
7342
|
+
// so that you can pass your own Window
|
|
7343
|
+
DOMPurify.isSupported = false;
|
|
7344
|
+
return DOMPurify;
|
|
7345
|
+
}
|
|
7346
|
+
|
|
7347
|
+
const originalDocument = window.document;
|
|
7348
|
+
let {
|
|
7349
|
+
document
|
|
7350
|
+
} = window;
|
|
7351
|
+
const {
|
|
7352
|
+
DocumentFragment,
|
|
7353
|
+
HTMLTemplateElement,
|
|
7354
|
+
Node,
|
|
7355
|
+
Element,
|
|
7356
|
+
NodeFilter,
|
|
7357
|
+
NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
|
|
7358
|
+
HTMLFormElement,
|
|
7359
|
+
DOMParser,
|
|
7360
|
+
trustedTypes
|
|
7361
|
+
} = window;
|
|
7362
|
+
const ElementPrototype = Element.prototype;
|
|
7363
|
+
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
7364
|
+
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
7365
|
+
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
7366
|
+
const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a
|
|
7367
|
+
// new document created via createHTMLDocument. As per the spec
|
|
7368
|
+
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
7369
|
+
// a new empty registry is used when creating a template contents owner
|
|
7370
|
+
// document, so we use that as our parent document to ensure nothing
|
|
7371
|
+
// is inherited.
|
|
7372
|
+
|
|
7373
|
+
if (typeof HTMLTemplateElement === 'function') {
|
|
7374
|
+
const template = document.createElement('template');
|
|
7375
|
+
|
|
7376
|
+
if (template.content && template.content.ownerDocument) {
|
|
7377
|
+
document = template.content.ownerDocument;
|
|
7378
|
+
}
|
|
7379
|
+
}
|
|
7380
|
+
|
|
7381
|
+
const trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
|
|
7382
|
+
|
|
7383
|
+
const emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML('') : '';
|
|
7384
|
+
const {
|
|
7385
|
+
implementation,
|
|
7386
|
+
createNodeIterator,
|
|
7387
|
+
createDocumentFragment,
|
|
7388
|
+
getElementsByTagName
|
|
7389
|
+
} = document;
|
|
7390
|
+
const {
|
|
7391
|
+
importNode
|
|
7392
|
+
} = originalDocument;
|
|
7393
|
+
let hooks = {};
|
|
7394
|
+
/**
|
|
7395
|
+
* Expose whether this browser supports running the full DOMPurify.
|
|
7396
|
+
*/
|
|
7397
|
+
|
|
7398
|
+
DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined';
|
|
7399
|
+
const {
|
|
7400
|
+
MUSTACHE_EXPR,
|
|
7401
|
+
ERB_EXPR,
|
|
7402
|
+
TMPLIT_EXPR,
|
|
7403
|
+
DATA_ATTR,
|
|
7404
|
+
ARIA_ATTR,
|
|
7405
|
+
IS_SCRIPT_OR_DATA,
|
|
7406
|
+
ATTR_WHITESPACE
|
|
7407
|
+
} = EXPRESSIONS;
|
|
7408
|
+
let {
|
|
7409
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
7410
|
+
} = EXPRESSIONS;
|
|
7411
|
+
/**
|
|
7412
|
+
* We consider the elements and attributes below to be safe. Ideally
|
|
7413
|
+
* don't add any new ones but feel free to remove unwanted ones.
|
|
7414
|
+
*/
|
|
7415
|
+
|
|
7416
|
+
/* allowed element names */
|
|
7417
|
+
|
|
7418
|
+
let ALLOWED_TAGS = null;
|
|
7419
|
+
const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
|
|
7420
|
+
/* Allowed attribute names */
|
|
7421
|
+
|
|
7422
|
+
let ALLOWED_ATTR = null;
|
|
7423
|
+
const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
|
|
7424
|
+
/*
|
|
7425
|
+
* Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
|
|
7426
|
+
* @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
|
|
7427
|
+
* @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
|
|
7428
|
+
* @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
|
|
7429
|
+
*/
|
|
7430
|
+
|
|
7431
|
+
let CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
|
|
7432
|
+
tagNameCheck: {
|
|
7433
|
+
writable: true,
|
|
7434
|
+
configurable: false,
|
|
7435
|
+
enumerable: true,
|
|
7436
|
+
value: null
|
|
7437
|
+
},
|
|
7438
|
+
attributeNameCheck: {
|
|
7439
|
+
writable: true,
|
|
7440
|
+
configurable: false,
|
|
7441
|
+
enumerable: true,
|
|
7442
|
+
value: null
|
|
7443
|
+
},
|
|
7444
|
+
allowCustomizedBuiltInElements: {
|
|
7445
|
+
writable: true,
|
|
7446
|
+
configurable: false,
|
|
7447
|
+
enumerable: true,
|
|
7448
|
+
value: false
|
|
7449
|
+
}
|
|
7450
|
+
}));
|
|
7451
|
+
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
|
7452
|
+
|
|
7453
|
+
let FORBID_TAGS = null;
|
|
7454
|
+
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
7455
|
+
|
|
7456
|
+
let FORBID_ATTR = null;
|
|
7457
|
+
/* Decide if ARIA attributes are okay */
|
|
7458
|
+
|
|
7459
|
+
let ALLOW_ARIA_ATTR = true;
|
|
7460
|
+
/* Decide if custom data attributes are okay */
|
|
7461
|
+
|
|
7462
|
+
let ALLOW_DATA_ATTR = true;
|
|
7463
|
+
/* Decide if unknown protocols are okay */
|
|
7464
|
+
|
|
7465
|
+
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
7466
|
+
/* Decide if self-closing tags in attributes are allowed.
|
|
7467
|
+
* Usually removed due to a mXSS issue in jQuery 3.0 */
|
|
7468
|
+
|
|
7469
|
+
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
7470
|
+
/* Output should be safe for common template engines.
|
|
7471
|
+
* This means, DOMPurify removes data attributes, mustaches and ERB
|
|
7472
|
+
*/
|
|
7473
|
+
|
|
7474
|
+
let SAFE_FOR_TEMPLATES = false;
|
|
7475
|
+
/* Decide if document with <html>... should be returned */
|
|
7476
|
+
|
|
7477
|
+
let WHOLE_DOCUMENT = false;
|
|
7478
|
+
/* Track whether config is already set on this instance of DOMPurify. */
|
|
7479
|
+
|
|
7480
|
+
let SET_CONFIG = false;
|
|
7481
|
+
/* Decide if all elements (e.g. style, script) must be children of
|
|
7482
|
+
* document.body. By default, browsers might move them to document.head */
|
|
7483
|
+
|
|
7484
|
+
let FORCE_BODY = false;
|
|
7485
|
+
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
|
7486
|
+
* string (or a TrustedHTML object if Trusted Types are supported).
|
|
7487
|
+
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
|
7488
|
+
*/
|
|
7489
|
+
|
|
7490
|
+
let RETURN_DOM = false;
|
|
7491
|
+
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
|
7492
|
+
* string (or a TrustedHTML object if Trusted Types are supported) */
|
|
7493
|
+
|
|
7494
|
+
let RETURN_DOM_FRAGMENT = false;
|
|
7495
|
+
/* Try to return a Trusted Type object instead of a string, return a string in
|
|
7496
|
+
* case Trusted Types are not supported */
|
|
7497
|
+
|
|
7498
|
+
let RETURN_TRUSTED_TYPE = false;
|
|
7499
|
+
/* Output should be free from DOM clobbering attacks?
|
|
7500
|
+
* This sanitizes markups named with colliding, clobberable built-in DOM APIs.
|
|
7501
|
+
*/
|
|
7502
|
+
|
|
7503
|
+
let SANITIZE_DOM = true;
|
|
7504
|
+
/* Achieve full DOM Clobbering protection by isolating the namespace of named
|
|
7505
|
+
* properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
|
|
7506
|
+
*
|
|
7507
|
+
* HTML/DOM spec rules that enable DOM Clobbering:
|
|
7508
|
+
* - Named Access on Window (§7.3.3)
|
|
7509
|
+
* - DOM Tree Accessors (§3.1.5)
|
|
7510
|
+
* - Form Element Parent-Child Relations (§4.10.3)
|
|
7511
|
+
* - Iframe srcdoc / Nested WindowProxies (§4.8.5)
|
|
7512
|
+
* - HTMLCollection (§4.2.10.2)
|
|
7513
|
+
*
|
|
7514
|
+
* Namespace isolation is implemented by prefixing `id` and `name` attributes
|
|
7515
|
+
* with a constant string, i.e., `user-content-`
|
|
7516
|
+
*/
|
|
7517
|
+
|
|
7518
|
+
let SANITIZE_NAMED_PROPS = false;
|
|
7519
|
+
const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
|
|
7520
|
+
/* Keep element content when removing element? */
|
|
7521
|
+
|
|
7522
|
+
let KEEP_CONTENT = true;
|
|
7523
|
+
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
|
7524
|
+
* of importing it into a new Document and returning a sanitized copy */
|
|
7525
|
+
|
|
7526
|
+
let IN_PLACE = false;
|
|
7527
|
+
/* Allow usage of profiles like html, svg and mathMl */
|
|
7528
|
+
|
|
7529
|
+
let USE_PROFILES = {};
|
|
7530
|
+
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
7531
|
+
|
|
7532
|
+
let FORBID_CONTENTS = null;
|
|
7533
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
|
7534
|
+
/* Tags that are safe for data: URIs */
|
|
7535
|
+
|
|
7536
|
+
let DATA_URI_TAGS = null;
|
|
7537
|
+
const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
7538
|
+
/* Attributes safe for values like "javascript:" */
|
|
7539
|
+
|
|
7540
|
+
let URI_SAFE_ATTRIBUTES = null;
|
|
7541
|
+
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
|
7542
|
+
const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
7543
|
+
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
7544
|
+
const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
7545
|
+
/* Document namespace */
|
|
7546
|
+
|
|
7547
|
+
let NAMESPACE = HTML_NAMESPACE;
|
|
7548
|
+
let IS_EMPTY_INPUT = false;
|
|
7549
|
+
/* Allowed XHTML+XML namespaces */
|
|
7550
|
+
|
|
7551
|
+
let ALLOWED_NAMESPACES = null;
|
|
7552
|
+
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
7553
|
+
/* Parsing of strict XHTML documents */
|
|
7554
|
+
|
|
7555
|
+
let PARSER_MEDIA_TYPE;
|
|
7556
|
+
const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
|
7557
|
+
const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
|
7558
|
+
let transformCaseFunc;
|
|
7559
|
+
/* Keep a reference to config to pass to hooks */
|
|
7560
|
+
|
|
7561
|
+
let CONFIG = null;
|
|
7562
|
+
/* Ideally, do not touch anything below this line */
|
|
7563
|
+
|
|
7564
|
+
/* ______________________________________________ */
|
|
7565
|
+
|
|
7566
|
+
const formElement = document.createElement('form');
|
|
7567
|
+
|
|
7568
|
+
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
7569
|
+
return testValue instanceof RegExp || testValue instanceof Function;
|
|
7570
|
+
};
|
|
7571
|
+
/**
|
|
7572
|
+
* _parseConfig
|
|
7573
|
+
*
|
|
7574
|
+
* @param {Object} cfg optional config literal
|
|
7575
|
+
*/
|
|
7576
|
+
// eslint-disable-next-line complexity
|
|
7577
|
+
|
|
7578
|
+
|
|
7579
|
+
const _parseConfig = function _parseConfig(cfg) {
|
|
7580
|
+
if (CONFIG && CONFIG === cfg) {
|
|
7581
|
+
return;
|
|
7582
|
+
}
|
|
7583
|
+
/* Shield configuration object from tampering */
|
|
7584
|
+
|
|
7585
|
+
|
|
7586
|
+
if (!cfg || typeof cfg !== 'object') {
|
|
7587
|
+
cfg = {};
|
|
7588
|
+
}
|
|
7589
|
+
/* Shield configuration object from prototype pollution */
|
|
7590
|
+
|
|
7591
|
+
|
|
7592
|
+
cfg = clone(cfg);
|
|
7593
|
+
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
|
|
7594
|
+
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
7595
|
+
|
|
7596
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
7597
|
+
/* Set configuration parameters */
|
|
7598
|
+
|
|
7599
|
+
ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
7600
|
+
ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
7601
|
+
ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
7602
|
+
URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent
|
|
7603
|
+
cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent
|
|
7604
|
+
transformCaseFunc // eslint-disable-line indent
|
|
7605
|
+
) // eslint-disable-line indent
|
|
7606
|
+
: DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
7607
|
+
DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent
|
|
7608
|
+
cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent
|
|
7609
|
+
transformCaseFunc // eslint-disable-line indent
|
|
7610
|
+
) // eslint-disable-line indent
|
|
7611
|
+
: DEFAULT_DATA_URI_TAGS;
|
|
7612
|
+
FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
7613
|
+
FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
|
7614
|
+
FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
|
7615
|
+
USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
|
|
7616
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
7617
|
+
|
|
7618
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
7619
|
+
|
|
7620
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
7621
|
+
|
|
7622
|
+
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
|
|
7623
|
+
|
|
7624
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
|
|
7625
|
+
|
|
7626
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
|
|
7627
|
+
|
|
7628
|
+
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
|
|
7629
|
+
|
|
7630
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
|
|
7631
|
+
|
|
7632
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
|
|
7633
|
+
|
|
7634
|
+
FORCE_BODY = cfg.FORCE_BODY || false; // Default false
|
|
7635
|
+
|
|
7636
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
|
|
7637
|
+
|
|
7638
|
+
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
|
|
7639
|
+
|
|
7640
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
7641
|
+
|
|
7642
|
+
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
7643
|
+
|
|
7644
|
+
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
|
|
7645
|
+
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
7646
|
+
CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
|
|
7647
|
+
|
|
7648
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
|
7649
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
|
7650
|
+
}
|
|
7651
|
+
|
|
7652
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
|
|
7653
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
|
|
7654
|
+
}
|
|
7655
|
+
|
|
7656
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
|
|
7657
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
|
|
7658
|
+
}
|
|
7659
|
+
|
|
7660
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
7661
|
+
ALLOW_DATA_ATTR = false;
|
|
7662
|
+
}
|
|
7663
|
+
|
|
7664
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
7665
|
+
RETURN_DOM = true;
|
|
7666
|
+
}
|
|
7667
|
+
/* Parse profile info */
|
|
7668
|
+
|
|
7669
|
+
|
|
7670
|
+
if (USE_PROFILES) {
|
|
7671
|
+
ALLOWED_TAGS = addToSet({}, [...text]);
|
|
7672
|
+
ALLOWED_ATTR = [];
|
|
7673
|
+
|
|
7674
|
+
if (USE_PROFILES.html === true) {
|
|
7675
|
+
addToSet(ALLOWED_TAGS, html$1);
|
|
7676
|
+
addToSet(ALLOWED_ATTR, html);
|
|
7677
|
+
}
|
|
7678
|
+
|
|
7679
|
+
if (USE_PROFILES.svg === true) {
|
|
7680
|
+
addToSet(ALLOWED_TAGS, svg$1);
|
|
7681
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
7682
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
7683
|
+
}
|
|
7684
|
+
|
|
7685
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
7686
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
7687
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
7688
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
7689
|
+
}
|
|
7690
|
+
|
|
7691
|
+
if (USE_PROFILES.mathMl === true) {
|
|
7692
|
+
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
7693
|
+
addToSet(ALLOWED_ATTR, mathMl);
|
|
7694
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
7695
|
+
}
|
|
7696
|
+
}
|
|
7697
|
+
/* Merge configuration parameters */
|
|
7698
|
+
|
|
7699
|
+
|
|
7700
|
+
if (cfg.ADD_TAGS) {
|
|
7701
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
7702
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
7703
|
+
}
|
|
7704
|
+
|
|
7705
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
7706
|
+
}
|
|
7707
|
+
|
|
7708
|
+
if (cfg.ADD_ATTR) {
|
|
7709
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
7710
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
7711
|
+
}
|
|
7712
|
+
|
|
7713
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
7714
|
+
}
|
|
7715
|
+
|
|
7716
|
+
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
7717
|
+
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
7718
|
+
}
|
|
7719
|
+
|
|
7720
|
+
if (cfg.FORBID_CONTENTS) {
|
|
7721
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
7722
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
7723
|
+
}
|
|
7724
|
+
|
|
7725
|
+
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
7726
|
+
}
|
|
7727
|
+
/* Add #text in case KEEP_CONTENT is set to true */
|
|
7728
|
+
|
|
7729
|
+
|
|
7730
|
+
if (KEEP_CONTENT) {
|
|
7731
|
+
ALLOWED_TAGS['#text'] = true;
|
|
7732
|
+
}
|
|
7733
|
+
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
|
7734
|
+
|
|
7735
|
+
|
|
7736
|
+
if (WHOLE_DOCUMENT) {
|
|
7737
|
+
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
|
7738
|
+
}
|
|
7739
|
+
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
|
7740
|
+
|
|
7741
|
+
|
|
7742
|
+
if (ALLOWED_TAGS.table) {
|
|
7743
|
+
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
7744
|
+
delete FORBID_TAGS.tbody;
|
|
7745
|
+
} // Prevent further manipulation of configuration.
|
|
7746
|
+
// Not available in IE8, Safari 5, etc.
|
|
7747
|
+
|
|
7748
|
+
|
|
7749
|
+
if (freeze) {
|
|
7750
|
+
freeze(cfg);
|
|
7751
|
+
}
|
|
7752
|
+
|
|
7753
|
+
CONFIG = cfg;
|
|
7754
|
+
};
|
|
7755
|
+
|
|
7756
|
+
const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
7757
|
+
const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML
|
|
7758
|
+
// namespace. We need to specify them explicitly
|
|
7759
|
+
// so that they don't get erroneously deleted from
|
|
7760
|
+
// HTML namespace.
|
|
7761
|
+
|
|
7762
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
7763
|
+
/* Keep track of all possible SVG and MathML tags
|
|
7764
|
+
* so that we can perform the namespace checks
|
|
7765
|
+
* correctly. */
|
|
7766
|
+
|
|
7767
|
+
const ALL_SVG_TAGS = addToSet({}, svg$1);
|
|
7768
|
+
addToSet(ALL_SVG_TAGS, svgFilters);
|
|
7769
|
+
addToSet(ALL_SVG_TAGS, svgDisallowed);
|
|
7770
|
+
const ALL_MATHML_TAGS = addToSet({}, mathMl$1);
|
|
7771
|
+
addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
|
|
7772
|
+
/**
|
|
7773
|
+
*
|
|
7774
|
+
*
|
|
7775
|
+
* @param {Element} element a DOM element whose namespace is being checked
|
|
7776
|
+
* @returns {boolean} Return false if the element has a
|
|
7777
|
+
* namespace that a spec-compliant parser would never
|
|
7778
|
+
* return. Return true otherwise.
|
|
7779
|
+
*/
|
|
7780
|
+
|
|
7781
|
+
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
7782
|
+
let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
|
|
7783
|
+
// can be null. We just simulate parent in this case.
|
|
7784
|
+
|
|
7785
|
+
if (!parent || !parent.tagName) {
|
|
7786
|
+
parent = {
|
|
7787
|
+
namespaceURI: NAMESPACE,
|
|
7788
|
+
tagName: 'template'
|
|
7789
|
+
};
|
|
7790
|
+
}
|
|
7791
|
+
|
|
7792
|
+
const tagName = stringToLowerCase(element.tagName);
|
|
7793
|
+
const parentTagName = stringToLowerCase(parent.tagName);
|
|
7794
|
+
|
|
7795
|
+
if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
7796
|
+
return false;
|
|
7797
|
+
}
|
|
7798
|
+
|
|
7799
|
+
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
7800
|
+
// The only way to switch from HTML namespace to SVG
|
|
7801
|
+
// is via <svg>. If it happens via any other tag, then
|
|
7802
|
+
// it should be killed.
|
|
7803
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
7804
|
+
return tagName === 'svg';
|
|
7805
|
+
} // The only way to switch from MathML to SVG is via`
|
|
7806
|
+
// svg if parent is either <annotation-xml> or MathML
|
|
7807
|
+
// text integration points.
|
|
7808
|
+
|
|
7809
|
+
|
|
7810
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
7811
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
7812
|
+
} // We only allow elements that are defined in SVG
|
|
7813
|
+
// spec. All others are disallowed in SVG namespace.
|
|
7814
|
+
|
|
7815
|
+
|
|
7816
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
7817
|
+
}
|
|
7818
|
+
|
|
7819
|
+
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
7820
|
+
// The only way to switch from HTML namespace to MathML
|
|
7821
|
+
// is via <math>. If it happens via any other tag, then
|
|
7822
|
+
// it should be killed.
|
|
7823
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
7824
|
+
return tagName === 'math';
|
|
7825
|
+
} // The only way to switch from SVG to MathML is via
|
|
7826
|
+
// <math> and HTML integration points
|
|
7827
|
+
|
|
7828
|
+
|
|
7829
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
7830
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
7831
|
+
} // We only allow elements that are defined in MathML
|
|
7832
|
+
// spec. All others are disallowed in MathML namespace.
|
|
7833
|
+
|
|
7834
|
+
|
|
7835
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
7836
|
+
}
|
|
7837
|
+
|
|
7838
|
+
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
7839
|
+
// The only way to switch from SVG to HTML is via
|
|
7840
|
+
// HTML integration points, and from MathML to HTML
|
|
7841
|
+
// is via MathML text integration points
|
|
7842
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
7843
|
+
return false;
|
|
7844
|
+
}
|
|
7845
|
+
|
|
7846
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
7847
|
+
return false;
|
|
7848
|
+
} // We disallow tags that are specific for MathML
|
|
7849
|
+
// or SVG and should never appear in HTML namespace
|
|
7850
|
+
|
|
7851
|
+
|
|
7852
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
7853
|
+
} // For XHTML and XML documents that support custom namespaces
|
|
7854
|
+
|
|
7855
|
+
|
|
7856
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
7857
|
+
return true;
|
|
7858
|
+
} // The code should never reach this place (this means
|
|
7859
|
+
// that the element somehow got namespace that is not
|
|
7860
|
+
// HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
|
|
7861
|
+
// Return false just in case.
|
|
7862
|
+
|
|
7863
|
+
|
|
7864
|
+
return false;
|
|
7865
|
+
};
|
|
7866
|
+
/**
|
|
7867
|
+
* _forceRemove
|
|
7868
|
+
*
|
|
7869
|
+
* @param {Node} node a DOM node
|
|
7870
|
+
*/
|
|
7871
|
+
|
|
7872
|
+
|
|
7873
|
+
const _forceRemove = function _forceRemove(node) {
|
|
7874
|
+
arrayPush(DOMPurify.removed, {
|
|
7875
|
+
element: node
|
|
7876
|
+
});
|
|
7877
|
+
|
|
7878
|
+
try {
|
|
7879
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
7880
|
+
node.parentNode.removeChild(node);
|
|
7881
|
+
} catch (_) {
|
|
7882
|
+
node.remove();
|
|
7883
|
+
}
|
|
7884
|
+
};
|
|
7885
|
+
/**
|
|
7886
|
+
* _removeAttribute
|
|
7887
|
+
*
|
|
7888
|
+
* @param {String} name an Attribute name
|
|
7889
|
+
* @param {Node} node a DOM node
|
|
7890
|
+
*/
|
|
7891
|
+
|
|
7892
|
+
|
|
7893
|
+
const _removeAttribute = function _removeAttribute(name, node) {
|
|
7894
|
+
try {
|
|
7895
|
+
arrayPush(DOMPurify.removed, {
|
|
7896
|
+
attribute: node.getAttributeNode(name),
|
|
7897
|
+
from: node
|
|
7898
|
+
});
|
|
7899
|
+
} catch (_) {
|
|
7900
|
+
arrayPush(DOMPurify.removed, {
|
|
7901
|
+
attribute: null,
|
|
7902
|
+
from: node
|
|
7903
|
+
});
|
|
7904
|
+
}
|
|
7905
|
+
|
|
7906
|
+
node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes
|
|
7907
|
+
|
|
7908
|
+
if (name === 'is' && !ALLOWED_ATTR[name]) {
|
|
7909
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
7910
|
+
try {
|
|
7911
|
+
_forceRemove(node);
|
|
7912
|
+
} catch (_) {}
|
|
7913
|
+
} else {
|
|
7914
|
+
try {
|
|
7915
|
+
node.setAttribute(name, '');
|
|
7916
|
+
} catch (_) {}
|
|
7917
|
+
}
|
|
7918
|
+
}
|
|
7919
|
+
};
|
|
7920
|
+
/**
|
|
7921
|
+
* _initDocument
|
|
7922
|
+
*
|
|
7923
|
+
* @param {String} dirty a string of dirty markup
|
|
7924
|
+
* @return {Document} a DOM, filled with the dirty markup
|
|
7925
|
+
*/
|
|
7926
|
+
|
|
7927
|
+
|
|
7928
|
+
const _initDocument = function _initDocument(dirty) {
|
|
7929
|
+
/* Create a HTML document */
|
|
7930
|
+
let doc;
|
|
7931
|
+
let leadingWhitespace;
|
|
7932
|
+
|
|
7933
|
+
if (FORCE_BODY) {
|
|
7934
|
+
dirty = '<remove></remove>' + dirty;
|
|
7935
|
+
} else {
|
|
7936
|
+
/* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
|
|
7937
|
+
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
7938
|
+
leadingWhitespace = matches && matches[0];
|
|
7939
|
+
}
|
|
7940
|
+
|
|
7941
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
|
|
7942
|
+
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
7943
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
7944
|
+
}
|
|
7945
|
+
|
|
7946
|
+
const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
7947
|
+
/*
|
|
7948
|
+
* Use the DOMParser API by default, fallback later if needs be
|
|
7949
|
+
* DOMParser not work for svg when has multiple root element.
|
|
7950
|
+
*/
|
|
7951
|
+
|
|
7952
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
7953
|
+
try {
|
|
7954
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
7955
|
+
} catch (_) {}
|
|
7956
|
+
}
|
|
7957
|
+
/* Use createHTMLDocument in case DOMParser is not available */
|
|
7958
|
+
|
|
7959
|
+
|
|
7960
|
+
if (!doc || !doc.documentElement) {
|
|
7961
|
+
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
|
7962
|
+
|
|
7963
|
+
try {
|
|
7964
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
|
7965
|
+
} catch (_) {// Syntax error if dirtyPayload is invalid xml
|
|
7966
|
+
}
|
|
7967
|
+
}
|
|
7968
|
+
|
|
7969
|
+
const body = doc.body || doc.documentElement;
|
|
7970
|
+
|
|
7971
|
+
if (dirty && leadingWhitespace) {
|
|
7972
|
+
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
7973
|
+
}
|
|
7974
|
+
/* Work on whole document or just its body */
|
|
7975
|
+
|
|
7976
|
+
|
|
7977
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
7978
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
|
7979
|
+
}
|
|
7980
|
+
|
|
7981
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
7982
|
+
};
|
|
7983
|
+
/**
|
|
7984
|
+
* _createIterator
|
|
7985
|
+
*
|
|
7986
|
+
* @param {Document} root document/fragment to create iterator for
|
|
7987
|
+
* @return {Iterator} iterator instance
|
|
7988
|
+
*/
|
|
7989
|
+
|
|
7990
|
+
|
|
7991
|
+
const _createIterator = function _createIterator(root) {
|
|
7992
|
+
return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
|
|
7993
|
+
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
|
|
7994
|
+
};
|
|
7995
|
+
/**
|
|
7996
|
+
* _isClobbered
|
|
7997
|
+
*
|
|
7998
|
+
* @param {Node} elm element to check for clobbering attacks
|
|
7999
|
+
* @return {Boolean} true if clobbered, false if safe
|
|
8000
|
+
*/
|
|
8001
|
+
|
|
8002
|
+
|
|
8003
|
+
const _isClobbered = function _isClobbered(elm) {
|
|
8004
|
+
return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
|
|
8005
|
+
};
|
|
8006
|
+
/**
|
|
8007
|
+
* _isNode
|
|
8008
|
+
*
|
|
8009
|
+
* @param {Node} obj object to check whether it's a DOM node
|
|
8010
|
+
* @return {Boolean} true is object is a DOM node
|
|
8011
|
+
*/
|
|
8012
|
+
|
|
8013
|
+
|
|
8014
|
+
const _isNode = function _isNode(object) {
|
|
8015
|
+
return typeof Node === 'object' ? object instanceof Node : object && typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
|
|
8016
|
+
};
|
|
8017
|
+
/**
|
|
8018
|
+
* _executeHook
|
|
8019
|
+
* Execute user configurable hooks
|
|
8020
|
+
*
|
|
8021
|
+
* @param {String} entryPoint Name of the hook's entry point
|
|
8022
|
+
* @param {Node} currentNode node to work on with the hook
|
|
8023
|
+
* @param {Object} data additional hook parameters
|
|
8024
|
+
*/
|
|
8025
|
+
|
|
8026
|
+
|
|
8027
|
+
const _executeHook = function _executeHook(entryPoint, currentNode, data) {
|
|
8028
|
+
if (!hooks[entryPoint]) {
|
|
8029
|
+
return;
|
|
8030
|
+
}
|
|
8031
|
+
|
|
8032
|
+
arrayForEach(hooks[entryPoint], hook => {
|
|
8033
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
8034
|
+
});
|
|
8035
|
+
};
|
|
8036
|
+
/**
|
|
8037
|
+
* _sanitizeElements
|
|
8038
|
+
*
|
|
8039
|
+
* @protect nodeName
|
|
8040
|
+
* @protect textContent
|
|
8041
|
+
* @protect removeChild
|
|
8042
|
+
*
|
|
8043
|
+
* @param {Node} currentNode to check for permission to exist
|
|
8044
|
+
* @return {Boolean} true if node was killed, false if left alive
|
|
8045
|
+
*/
|
|
8046
|
+
|
|
8047
|
+
|
|
8048
|
+
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
8049
|
+
let content;
|
|
8050
|
+
/* Execute a hook if present */
|
|
8051
|
+
|
|
8052
|
+
_executeHook('beforeSanitizeElements', currentNode, null);
|
|
8053
|
+
/* Check if element is clobbered or can clobber */
|
|
8054
|
+
|
|
8055
|
+
|
|
8056
|
+
if (_isClobbered(currentNode)) {
|
|
8057
|
+
_forceRemove(currentNode);
|
|
8058
|
+
|
|
8059
|
+
return true;
|
|
8060
|
+
}
|
|
8061
|
+
/* Now let's check the element's type and name */
|
|
8062
|
+
|
|
8063
|
+
|
|
8064
|
+
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
8065
|
+
/* Execute a hook if present */
|
|
8066
|
+
|
|
8067
|
+
_executeHook('uponSanitizeElement', currentNode, {
|
|
8068
|
+
tagName,
|
|
8069
|
+
allowedTags: ALLOWED_TAGS
|
|
8070
|
+
});
|
|
8071
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
8072
|
+
|
|
8073
|
+
|
|
8074
|
+
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
|
8075
|
+
_forceRemove(currentNode);
|
|
8076
|
+
|
|
8077
|
+
return true;
|
|
8078
|
+
}
|
|
8079
|
+
/* Remove element if anything forbids its presence */
|
|
8080
|
+
|
|
8081
|
+
|
|
8082
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
8083
|
+
/* Check if we have a custom element to handle */
|
|
8084
|
+
if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
|
|
8085
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
|
|
8086
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
|
|
8087
|
+
}
|
|
8088
|
+
/* Keep content except for bad-listed elements */
|
|
8089
|
+
|
|
8090
|
+
|
|
8091
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
8092
|
+
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
8093
|
+
const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
8094
|
+
|
|
8095
|
+
if (childNodes && parentNode) {
|
|
8096
|
+
const childCount = childNodes.length;
|
|
8097
|
+
|
|
8098
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
8099
|
+
parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
|
|
8100
|
+
}
|
|
8101
|
+
}
|
|
8102
|
+
}
|
|
8103
|
+
|
|
8104
|
+
_forceRemove(currentNode);
|
|
8105
|
+
|
|
8106
|
+
return true;
|
|
8107
|
+
}
|
|
8108
|
+
/* Check whether element has a valid namespace */
|
|
8109
|
+
|
|
8110
|
+
|
|
8111
|
+
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
8112
|
+
_forceRemove(currentNode);
|
|
8113
|
+
|
|
8114
|
+
return true;
|
|
8115
|
+
}
|
|
8116
|
+
/* Make sure that older browsers don't get noscript mXSS */
|
|
8117
|
+
|
|
8118
|
+
|
|
8119
|
+
if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
|
|
8120
|
+
_forceRemove(currentNode);
|
|
8121
|
+
|
|
8122
|
+
return true;
|
|
8123
|
+
}
|
|
8124
|
+
/* Sanitize element content to be template-safe */
|
|
8125
|
+
|
|
8126
|
+
|
|
8127
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
|
|
8128
|
+
/* Get the element's text content */
|
|
8129
|
+
content = currentNode.textContent;
|
|
8130
|
+
content = stringReplace(content, MUSTACHE_EXPR, ' ');
|
|
8131
|
+
content = stringReplace(content, ERB_EXPR, ' ');
|
|
8132
|
+
content = stringReplace(content, TMPLIT_EXPR, ' ');
|
|
8133
|
+
|
|
8134
|
+
if (currentNode.textContent !== content) {
|
|
8135
|
+
arrayPush(DOMPurify.removed, {
|
|
8136
|
+
element: currentNode.cloneNode()
|
|
8137
|
+
});
|
|
8138
|
+
currentNode.textContent = content;
|
|
8139
|
+
}
|
|
8140
|
+
}
|
|
8141
|
+
/* Execute a hook if present */
|
|
8142
|
+
|
|
8143
|
+
|
|
8144
|
+
_executeHook('afterSanitizeElements', currentNode, null);
|
|
8145
|
+
|
|
8146
|
+
return false;
|
|
8147
|
+
};
|
|
8148
|
+
/**
|
|
8149
|
+
* _isValidAttribute
|
|
8150
|
+
*
|
|
8151
|
+
* @param {string} lcTag Lowercase tag name of containing element.
|
|
8152
|
+
* @param {string} lcName Lowercase attribute name.
|
|
8153
|
+
* @param {string} value Attribute value.
|
|
8154
|
+
* @return {Boolean} Returns true if `value` is valid, otherwise false.
|
|
8155
|
+
*/
|
|
8156
|
+
// eslint-disable-next-line complexity
|
|
8157
|
+
|
|
8158
|
+
|
|
8159
|
+
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
8160
|
+
/* Make sure attribute cannot clobber */
|
|
8161
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
8162
|
+
return false;
|
|
8163
|
+
}
|
|
8164
|
+
/* Allow valid data-* attributes: At least one character after "-"
|
|
8165
|
+
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
8166
|
+
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
8167
|
+
We don't need to check the value; it's always URI safe. */
|
|
8168
|
+
|
|
8169
|
+
|
|
8170
|
+
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
8171
|
+
if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
8172
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
8173
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
8174
|
+
_basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || // Alternative, second condition checks if it's an `is`-attribute, AND
|
|
8175
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
8176
|
+
lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
|
|
8177
|
+
return false;
|
|
8178
|
+
}
|
|
8179
|
+
/* Check value is safe. First, is attr inert? If so, is safe */
|
|
8180
|
+
|
|
8181
|
+
} else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (!value) ; else {
|
|
8182
|
+
return false;
|
|
8183
|
+
}
|
|
8184
|
+
|
|
8185
|
+
return true;
|
|
8186
|
+
};
|
|
8187
|
+
/**
|
|
8188
|
+
* _basicCustomElementCheck
|
|
8189
|
+
* checks if at least one dash is included in tagName, and it's not the first char
|
|
8190
|
+
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
|
|
8191
|
+
* @param {string} tagName name of the tag of the node to sanitize
|
|
8192
|
+
*/
|
|
8193
|
+
|
|
8194
|
+
|
|
8195
|
+
const _basicCustomElementTest = function _basicCustomElementTest(tagName) {
|
|
8196
|
+
return tagName.indexOf('-') > 0;
|
|
8197
|
+
};
|
|
8198
|
+
/**
|
|
8199
|
+
* _sanitizeAttributes
|
|
8200
|
+
*
|
|
8201
|
+
* @protect attributes
|
|
8202
|
+
* @protect nodeName
|
|
8203
|
+
* @protect removeAttribute
|
|
8204
|
+
* @protect setAttribute
|
|
8205
|
+
*
|
|
8206
|
+
* @param {Node} currentNode to sanitize
|
|
8207
|
+
*/
|
|
8208
|
+
|
|
8209
|
+
|
|
8210
|
+
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
8211
|
+
let attr;
|
|
8212
|
+
let value;
|
|
8213
|
+
let lcName;
|
|
8214
|
+
let l;
|
|
8215
|
+
/* Execute a hook if present */
|
|
8216
|
+
|
|
8217
|
+
_executeHook('beforeSanitizeAttributes', currentNode, null);
|
|
8218
|
+
|
|
8219
|
+
const {
|
|
8220
|
+
attributes
|
|
8221
|
+
} = currentNode;
|
|
8222
|
+
/* Check if we have attributes; if not we might have a text node */
|
|
8223
|
+
|
|
8224
|
+
if (!attributes) {
|
|
8225
|
+
return;
|
|
8226
|
+
}
|
|
8227
|
+
|
|
8228
|
+
const hookEvent = {
|
|
8229
|
+
attrName: '',
|
|
8230
|
+
attrValue: '',
|
|
8231
|
+
keepAttr: true,
|
|
8232
|
+
allowedAttributes: ALLOWED_ATTR
|
|
8233
|
+
};
|
|
8234
|
+
l = attributes.length;
|
|
8235
|
+
/* Go backwards over all attributes; safely remove bad ones */
|
|
8236
|
+
|
|
8237
|
+
while (l--) {
|
|
8238
|
+
attr = attributes[l];
|
|
8239
|
+
const {
|
|
8240
|
+
name,
|
|
8241
|
+
namespaceURI
|
|
8242
|
+
} = attr;
|
|
8243
|
+
value = name === 'value' ? attr.value : stringTrim(attr.value);
|
|
8244
|
+
lcName = transformCaseFunc(name);
|
|
8245
|
+
/* Execute a hook if present */
|
|
8246
|
+
|
|
8247
|
+
hookEvent.attrName = lcName;
|
|
8248
|
+
hookEvent.attrValue = value;
|
|
8249
|
+
hookEvent.keepAttr = true;
|
|
8250
|
+
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
8251
|
+
|
|
8252
|
+
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
|
|
8253
|
+
|
|
8254
|
+
value = hookEvent.attrValue;
|
|
8255
|
+
/* Did the hooks approve of the attribute? */
|
|
8256
|
+
|
|
8257
|
+
if (hookEvent.forceKeepAttr) {
|
|
8258
|
+
continue;
|
|
8259
|
+
}
|
|
8260
|
+
/* Remove attribute */
|
|
8261
|
+
|
|
8262
|
+
|
|
8263
|
+
_removeAttribute(name, currentNode);
|
|
8264
|
+
/* Did the hooks approve of the attribute? */
|
|
8265
|
+
|
|
8266
|
+
|
|
8267
|
+
if (!hookEvent.keepAttr) {
|
|
8268
|
+
continue;
|
|
8269
|
+
}
|
|
8270
|
+
/* Work around a security issue in jQuery 3.0 */
|
|
8271
|
+
|
|
8272
|
+
|
|
8273
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
|
8274
|
+
_removeAttribute(name, currentNode);
|
|
8275
|
+
|
|
8276
|
+
continue;
|
|
8277
|
+
}
|
|
8278
|
+
/* Sanitize attribute content to be template-safe */
|
|
8279
|
+
|
|
8280
|
+
|
|
8281
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
8282
|
+
value = stringReplace(value, MUSTACHE_EXPR, ' ');
|
|
8283
|
+
value = stringReplace(value, ERB_EXPR, ' ');
|
|
8284
|
+
value = stringReplace(value, TMPLIT_EXPR, ' ');
|
|
8285
|
+
}
|
|
8286
|
+
/* Is `value` valid for this attribute? */
|
|
8287
|
+
|
|
8288
|
+
|
|
8289
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
8290
|
+
|
|
8291
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
8292
|
+
continue;
|
|
8293
|
+
}
|
|
8294
|
+
/* Full DOM Clobbering protection via namespace isolation,
|
|
8295
|
+
* Prefix id and name attributes with `user-content-`
|
|
8296
|
+
*/
|
|
8297
|
+
|
|
8298
|
+
|
|
8299
|
+
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
8300
|
+
// Remove the attribute with this value
|
|
8301
|
+
_removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value
|
|
8302
|
+
|
|
8303
|
+
|
|
8304
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
8305
|
+
}
|
|
8306
|
+
/* Handle attributes that require Trusted Types */
|
|
8307
|
+
|
|
8308
|
+
|
|
8309
|
+
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
|
8310
|
+
if (namespaceURI) ; else {
|
|
8311
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
8312
|
+
case 'TrustedHTML':
|
|
8313
|
+
value = trustedTypesPolicy.createHTML(value);
|
|
8314
|
+
break;
|
|
8315
|
+
|
|
8316
|
+
case 'TrustedScriptURL':
|
|
8317
|
+
value = trustedTypesPolicy.createScriptURL(value);
|
|
8318
|
+
break;
|
|
8319
|
+
}
|
|
8320
|
+
}
|
|
8321
|
+
}
|
|
8322
|
+
/* Handle invalid data-* attribute set by try-catching it */
|
|
8323
|
+
|
|
8324
|
+
|
|
8325
|
+
try {
|
|
8326
|
+
if (namespaceURI) {
|
|
8327
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
8328
|
+
} else {
|
|
8329
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
8330
|
+
currentNode.setAttribute(name, value);
|
|
8331
|
+
}
|
|
8332
|
+
|
|
8333
|
+
arrayPop(DOMPurify.removed);
|
|
8334
|
+
} catch (_) {}
|
|
8335
|
+
}
|
|
8336
|
+
/* Execute a hook if present */
|
|
8337
|
+
|
|
8338
|
+
|
|
8339
|
+
_executeHook('afterSanitizeAttributes', currentNode, null);
|
|
8340
|
+
};
|
|
8341
|
+
/**
|
|
8342
|
+
* _sanitizeShadowDOM
|
|
8343
|
+
*
|
|
8344
|
+
* @param {DocumentFragment} fragment to iterate over recursively
|
|
8345
|
+
*/
|
|
8346
|
+
|
|
8347
|
+
|
|
8348
|
+
const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
8349
|
+
let shadowNode;
|
|
8350
|
+
|
|
8351
|
+
const shadowIterator = _createIterator(fragment);
|
|
8352
|
+
/* Execute a hook if present */
|
|
8353
|
+
|
|
8354
|
+
|
|
8355
|
+
_executeHook('beforeSanitizeShadowDOM', fragment, null);
|
|
8356
|
+
|
|
8357
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
8358
|
+
/* Execute a hook if present */
|
|
8359
|
+
_executeHook('uponSanitizeShadowNode', shadowNode, null);
|
|
8360
|
+
/* Sanitize tags and elements */
|
|
8361
|
+
|
|
8362
|
+
|
|
8363
|
+
if (_sanitizeElements(shadowNode)) {
|
|
8364
|
+
continue;
|
|
8365
|
+
}
|
|
8366
|
+
/* Deep shadow DOM detected */
|
|
8367
|
+
|
|
8368
|
+
|
|
8369
|
+
if (shadowNode.content instanceof DocumentFragment) {
|
|
8370
|
+
_sanitizeShadowDOM(shadowNode.content);
|
|
8371
|
+
}
|
|
8372
|
+
/* Check attributes, sanitize if necessary */
|
|
8373
|
+
|
|
8374
|
+
|
|
8375
|
+
_sanitizeAttributes(shadowNode);
|
|
8376
|
+
}
|
|
8377
|
+
/* Execute a hook if present */
|
|
8378
|
+
|
|
8379
|
+
|
|
8380
|
+
_executeHook('afterSanitizeShadowDOM', fragment, null);
|
|
8381
|
+
};
|
|
8382
|
+
/**
|
|
8383
|
+
* Sanitize
|
|
8384
|
+
* Public method providing core sanitation functionality
|
|
8385
|
+
*
|
|
8386
|
+
* @param {String|Node} dirty string or DOM node
|
|
8387
|
+
* @param {Object} configuration object
|
|
8388
|
+
*/
|
|
8389
|
+
// eslint-disable-next-line complexity
|
|
8390
|
+
|
|
8391
|
+
|
|
8392
|
+
DOMPurify.sanitize = function (dirty) {
|
|
8393
|
+
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
8394
|
+
let body;
|
|
8395
|
+
let importedNode;
|
|
8396
|
+
let currentNode;
|
|
8397
|
+
let returnNode;
|
|
8398
|
+
/* Make sure we have a string to sanitize.
|
|
8399
|
+
DO NOT return early, as this will return the wrong type if
|
|
8400
|
+
the user has requested a DOM object rather than a string */
|
|
8401
|
+
|
|
8402
|
+
IS_EMPTY_INPUT = !dirty;
|
|
8403
|
+
|
|
8404
|
+
if (IS_EMPTY_INPUT) {
|
|
8405
|
+
dirty = '<!-->';
|
|
8406
|
+
}
|
|
8407
|
+
/* Stringify, in case dirty is an object */
|
|
8408
|
+
|
|
8409
|
+
|
|
8410
|
+
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
8411
|
+
// eslint-disable-next-line no-negated-condition
|
|
8412
|
+
if (typeof dirty.toString !== 'function') {
|
|
8413
|
+
throw typeErrorCreate('toString is not a function');
|
|
8414
|
+
} else {
|
|
8415
|
+
dirty = dirty.toString();
|
|
8416
|
+
|
|
8417
|
+
if (typeof dirty !== 'string') {
|
|
8418
|
+
throw typeErrorCreate('dirty is not a string, aborting');
|
|
8419
|
+
}
|
|
8420
|
+
}
|
|
8421
|
+
}
|
|
8422
|
+
/* Return dirty HTML if DOMPurify cannot run */
|
|
8423
|
+
|
|
8424
|
+
|
|
8425
|
+
if (!DOMPurify.isSupported) {
|
|
8426
|
+
return dirty;
|
|
8427
|
+
}
|
|
8428
|
+
/* Assign config vars */
|
|
8429
|
+
|
|
8430
|
+
|
|
8431
|
+
if (!SET_CONFIG) {
|
|
8432
|
+
_parseConfig(cfg);
|
|
8433
|
+
}
|
|
8434
|
+
/* Clean up removed elements */
|
|
8435
|
+
|
|
8436
|
+
|
|
8437
|
+
DOMPurify.removed = [];
|
|
8438
|
+
/* Check if dirty is correctly typed for IN_PLACE */
|
|
8439
|
+
|
|
8440
|
+
if (typeof dirty === 'string') {
|
|
8441
|
+
IN_PLACE = false;
|
|
8442
|
+
}
|
|
8443
|
+
|
|
8444
|
+
if (IN_PLACE) {
|
|
8445
|
+
/* Do some early pre-sanitization to avoid unsafe root nodes */
|
|
8446
|
+
if (dirty.nodeName) {
|
|
8447
|
+
const tagName = transformCaseFunc(dirty.nodeName);
|
|
8448
|
+
|
|
8449
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
8450
|
+
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
|
8451
|
+
}
|
|
8452
|
+
}
|
|
8453
|
+
} else if (dirty instanceof Node) {
|
|
8454
|
+
/* If dirty is a DOM element, append to an empty document to avoid
|
|
8455
|
+
elements being stripped by the parser */
|
|
8456
|
+
body = _initDocument('<!---->');
|
|
8457
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
8458
|
+
|
|
8459
|
+
if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
|
|
8460
|
+
/* Node is already a body, use as is */
|
|
8461
|
+
body = importedNode;
|
|
8462
|
+
} else if (importedNode.nodeName === 'HTML') {
|
|
8463
|
+
body = importedNode;
|
|
8464
|
+
} else {
|
|
8465
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
8466
|
+
body.appendChild(importedNode);
|
|
8467
|
+
}
|
|
8468
|
+
} else {
|
|
8469
|
+
/* Exit directly if we have nothing to do */
|
|
8470
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
|
|
8471
|
+
dirty.indexOf('<') === -1) {
|
|
8472
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
8473
|
+
}
|
|
8474
|
+
/* Initialize the document to work on */
|
|
8475
|
+
|
|
8476
|
+
|
|
8477
|
+
body = _initDocument(dirty);
|
|
8478
|
+
/* Check we have a DOM node from the data */
|
|
8479
|
+
|
|
8480
|
+
if (!body) {
|
|
8481
|
+
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
|
8482
|
+
}
|
|
8483
|
+
}
|
|
8484
|
+
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
8485
|
+
|
|
8486
|
+
|
|
8487
|
+
if (body && FORCE_BODY) {
|
|
8488
|
+
_forceRemove(body.firstChild);
|
|
8489
|
+
}
|
|
8490
|
+
/* Get node iterator */
|
|
8491
|
+
|
|
8492
|
+
|
|
8493
|
+
const nodeIterator = _createIterator(IN_PLACE ? dirty : body);
|
|
8494
|
+
/* Now start iterating over the created document */
|
|
8495
|
+
|
|
8496
|
+
|
|
8497
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
8498
|
+
/* Sanitize tags and elements */
|
|
8499
|
+
if (_sanitizeElements(currentNode)) {
|
|
8500
|
+
continue;
|
|
8501
|
+
}
|
|
8502
|
+
/* Shadow DOM detected, sanitize it */
|
|
8503
|
+
|
|
8504
|
+
|
|
8505
|
+
if (currentNode.content instanceof DocumentFragment) {
|
|
8506
|
+
_sanitizeShadowDOM(currentNode.content);
|
|
8507
|
+
}
|
|
8508
|
+
/* Check attributes, sanitize if necessary */
|
|
8509
|
+
|
|
8510
|
+
|
|
8511
|
+
_sanitizeAttributes(currentNode);
|
|
8512
|
+
}
|
|
8513
|
+
/* If we sanitized `dirty` in-place, return it. */
|
|
8514
|
+
|
|
8515
|
+
|
|
8516
|
+
if (IN_PLACE) {
|
|
8517
|
+
return dirty;
|
|
8518
|
+
}
|
|
8519
|
+
/* Return sanitized string or DOM */
|
|
8520
|
+
|
|
8521
|
+
|
|
8522
|
+
if (RETURN_DOM) {
|
|
8523
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
8524
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
8525
|
+
|
|
8526
|
+
while (body.firstChild) {
|
|
8527
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
8528
|
+
returnNode.appendChild(body.firstChild);
|
|
8529
|
+
}
|
|
8530
|
+
} else {
|
|
8531
|
+
returnNode = body;
|
|
8532
|
+
}
|
|
8533
|
+
|
|
8534
|
+
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmod) {
|
|
8535
|
+
/*
|
|
8536
|
+
AdoptNode() is not used because internal state is not reset
|
|
8537
|
+
(e.g. the past names map of a HTMLFormElement), this is safe
|
|
8538
|
+
in theory but we would rather not risk another attack vector.
|
|
8539
|
+
The state that is cloned by importNode() is explicitly defined
|
|
8540
|
+
by the specs.
|
|
8541
|
+
*/
|
|
8542
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
8543
|
+
}
|
|
8544
|
+
|
|
8545
|
+
return returnNode;
|
|
8546
|
+
}
|
|
8547
|
+
|
|
8548
|
+
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
8549
|
+
/* Serialize doctype if allowed */
|
|
8550
|
+
|
|
8551
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
8552
|
+
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
|
8553
|
+
}
|
|
8554
|
+
/* Sanitize final string template-safe */
|
|
8555
|
+
|
|
8556
|
+
|
|
8557
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
8558
|
+
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR, ' ');
|
|
8559
|
+
serializedHTML = stringReplace(serializedHTML, ERB_EXPR, ' ');
|
|
8560
|
+
serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR, ' ');
|
|
8561
|
+
}
|
|
8562
|
+
|
|
8563
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
8564
|
+
};
|
|
8565
|
+
/**
|
|
8566
|
+
* Public method to set the configuration once
|
|
8567
|
+
* setConfig
|
|
8568
|
+
*
|
|
8569
|
+
* @param {Object} cfg configuration object
|
|
8570
|
+
*/
|
|
8571
|
+
|
|
8572
|
+
|
|
8573
|
+
DOMPurify.setConfig = function (cfg) {
|
|
8574
|
+
_parseConfig(cfg);
|
|
8575
|
+
|
|
8576
|
+
SET_CONFIG = true;
|
|
8577
|
+
};
|
|
8578
|
+
/**
|
|
8579
|
+
* Public method to remove the configuration
|
|
8580
|
+
* clearConfig
|
|
8581
|
+
*
|
|
8582
|
+
*/
|
|
8583
|
+
|
|
8584
|
+
|
|
8585
|
+
DOMPurify.clearConfig = function () {
|
|
8586
|
+
CONFIG = null;
|
|
8587
|
+
SET_CONFIG = false;
|
|
8588
|
+
};
|
|
8589
|
+
/**
|
|
8590
|
+
* Public method to check if an attribute value is valid.
|
|
8591
|
+
* Uses last set config, if any. Otherwise, uses config defaults.
|
|
8592
|
+
* isValidAttribute
|
|
8593
|
+
*
|
|
8594
|
+
* @param {string} tag Tag name of containing element.
|
|
8595
|
+
* @param {string} attr Attribute name.
|
|
8596
|
+
* @param {string} value Attribute value.
|
|
8597
|
+
* @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
|
|
8598
|
+
*/
|
|
8599
|
+
|
|
8600
|
+
|
|
8601
|
+
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
8602
|
+
/* Initialize shared config vars if necessary. */
|
|
8603
|
+
if (!CONFIG) {
|
|
8604
|
+
_parseConfig({});
|
|
8605
|
+
}
|
|
8606
|
+
|
|
8607
|
+
const lcTag = transformCaseFunc(tag);
|
|
8608
|
+
const lcName = transformCaseFunc(attr);
|
|
8609
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
8610
|
+
};
|
|
8611
|
+
/**
|
|
8612
|
+
* AddHook
|
|
8613
|
+
* Public method to add DOMPurify hooks
|
|
8614
|
+
*
|
|
8615
|
+
* @param {String} entryPoint entry point for the hook to add
|
|
8616
|
+
* @param {Function} hookFunction function to execute
|
|
8617
|
+
*/
|
|
8618
|
+
|
|
8619
|
+
|
|
8620
|
+
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
8621
|
+
if (typeof hookFunction !== 'function') {
|
|
8622
|
+
return;
|
|
8623
|
+
}
|
|
8624
|
+
|
|
8625
|
+
hooks[entryPoint] = hooks[entryPoint] || [];
|
|
8626
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
8627
|
+
};
|
|
8628
|
+
/**
|
|
8629
|
+
* RemoveHook
|
|
8630
|
+
* Public method to remove a DOMPurify hook at a given entryPoint
|
|
8631
|
+
* (pops it from the stack of hooks if more are present)
|
|
8632
|
+
*
|
|
8633
|
+
* @param {String} entryPoint entry point for the hook to remove
|
|
8634
|
+
* @return {Function} removed(popped) hook
|
|
8635
|
+
*/
|
|
8636
|
+
|
|
8637
|
+
|
|
8638
|
+
DOMPurify.removeHook = function (entryPoint) {
|
|
8639
|
+
if (hooks[entryPoint]) {
|
|
8640
|
+
return arrayPop(hooks[entryPoint]);
|
|
8641
|
+
}
|
|
8642
|
+
};
|
|
8643
|
+
/**
|
|
8644
|
+
* RemoveHooks
|
|
8645
|
+
* Public method to remove all DOMPurify hooks at a given entryPoint
|
|
8646
|
+
*
|
|
8647
|
+
* @param {String} entryPoint entry point for the hooks to remove
|
|
8648
|
+
*/
|
|
8649
|
+
|
|
8650
|
+
|
|
8651
|
+
DOMPurify.removeHooks = function (entryPoint) {
|
|
8652
|
+
if (hooks[entryPoint]) {
|
|
8653
|
+
hooks[entryPoint] = [];
|
|
8654
|
+
}
|
|
8655
|
+
};
|
|
8656
|
+
/**
|
|
8657
|
+
* RemoveAllHooks
|
|
8658
|
+
* Public method to remove all DOMPurify hooks
|
|
8659
|
+
*
|
|
8660
|
+
*/
|
|
8661
|
+
|
|
8662
|
+
|
|
8663
|
+
DOMPurify.removeAllHooks = function () {
|
|
8664
|
+
hooks = {};
|
|
8665
|
+
};
|
|
8666
|
+
|
|
8667
|
+
return DOMPurify;
|
|
8668
|
+
}
|
|
8669
|
+
|
|
8670
|
+
var purify = createDOMPurify();
|
|
8671
|
+
|
|
8672
|
+
var getInitialTab = function getInitialTab(stripeAccount) {
|
|
8673
|
+
if (stripeAccount !== null && stripeAccount !== void 0 && stripeAccount.isConnected) {
|
|
8674
|
+
return STEPS.finish;
|
|
8675
|
+
}
|
|
8676
|
+
if (neetocist.isPresent(stripeAccount)) {
|
|
8677
|
+
return STEPS.configure;
|
|
8678
|
+
}
|
|
8679
|
+
return STEPS.connect;
|
|
8680
|
+
};
|
|
8681
|
+
var buildStripeConnectUrl = function buildStripeConnectUrl(holdableId, returnUrl) {
|
|
8682
|
+
return utils$3.buildUrl(STRIPE_CONNECT_URL, {
|
|
8683
|
+
holdable_id: holdableId,
|
|
8684
|
+
return_url: returnUrl
|
|
8685
|
+
});
|
|
8686
|
+
};
|
|
8687
|
+
|
|
8688
|
+
var Connect = function Connect(_ref) {
|
|
8689
|
+
var setActiveTab = _ref.setActiveTab,
|
|
8690
|
+
holdableId = _ref.holdableId,
|
|
8691
|
+
returnUrl = _ref.returnUrl;
|
|
8692
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
8693
|
+
t = _useTranslation.t;
|
|
8694
|
+
var _useState = React.useState(INTEGRATION_METHOD.createNewAccount),
|
|
8695
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
8696
|
+
selectedOption = _useState2[0],
|
|
8697
|
+
setSelectedOption = _useState2[1];
|
|
8698
|
+
var stripeConnectUrl = buildStripeConnectUrl(holdableId, returnUrl);
|
|
8699
|
+
var handleSubmit = function handleSubmit() {
|
|
8700
|
+
if (selectedOption !== INTEGRATION_METHOD.useExistingAccount) {
|
|
8701
|
+
setActiveTab(STEPS.configure);
|
|
8702
|
+
return;
|
|
8703
|
+
}
|
|
8704
|
+
window.location.href = purify.sanitize(stripeConnectUrl);
|
|
8705
|
+
};
|
|
8706
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
8707
|
+
className: "mx-auto w-full max-w-lg space-y-8"
|
|
8708
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
8709
|
+
className: "space-y-2"
|
|
8710
|
+
}, /*#__PURE__*/React__default["default"].createElement(SvgStripe, null), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
8711
|
+
"data-cy": "configure-payment-title",
|
|
8712
|
+
style: "h2",
|
|
8713
|
+
weight: "semibold"
|
|
8714
|
+
}, t("neetoPayments.integrationModal.title")), /*#__PURE__*/React__default["default"].createElement(neetoui.Label, {
|
|
8715
|
+
className: "leading-snug"
|
|
8716
|
+
}, t("neetoPayments.integrationModal.subtitle"))), /*#__PURE__*/React__default["default"].createElement(neetoui.Radio, {
|
|
8717
|
+
stacked: true,
|
|
8718
|
+
value: selectedOption,
|
|
8719
|
+
onChange: function onChange(event) {
|
|
8720
|
+
return setSelectedOption(event.target.value);
|
|
8721
|
+
}
|
|
8722
|
+
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Radio.Item, {
|
|
8723
|
+
className: "neeto-ui-border-black w-96 py-2",
|
|
8724
|
+
label: t("neetoPayments.integrationModal.createAccount"),
|
|
8725
|
+
name: "accountMethod",
|
|
8726
|
+
value: INTEGRATION_METHOD.createNewAccount
|
|
8727
|
+
}), /*#__PURE__*/React__default["default"].createElement(neetoui.Radio.Item, {
|
|
8728
|
+
className: "neeto-ui-border-black w-96 py-2",
|
|
8729
|
+
label: t("neetoPayments.integrationModal.connectAccount"),
|
|
8730
|
+
name: "accountMethod",
|
|
8731
|
+
value: INTEGRATION_METHOD.useExistingAccount
|
|
8732
|
+
})), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
|
|
8733
|
+
label: t("neetoPayments.common.continue"),
|
|
8734
|
+
onClick: handleSubmit
|
|
8735
|
+
}));
|
|
8736
|
+
};
|
|
8737
|
+
|
|
8738
|
+
var Finish = reactUtils.withT(function (_ref) {
|
|
8739
|
+
var t = _ref.t,
|
|
8740
|
+
onSuccess = _ref.onSuccess;
|
|
8741
|
+
return /*#__PURE__*/React__default["default"].createElement(neetointegrations.Finish, {
|
|
8742
|
+
title: t("v2.payment.finishTitle"),
|
|
8743
|
+
onClick: onSuccess
|
|
8744
|
+
}, /*#__PURE__*/React__default["default"].createElement(AccountDetails, null));
|
|
8745
|
+
});
|
|
8746
|
+
|
|
8747
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8748
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8749
|
+
var StripeConnect = function StripeConnect(_ref) {
|
|
8750
|
+
var _ref$holdableId = _ref.holdableId,
|
|
8751
|
+
holdableId = _ref$holdableId === void 0 ? null : _ref$holdableId,
|
|
8752
|
+
isOpen = _ref.isOpen,
|
|
8753
|
+
onClose = _ref.onClose,
|
|
8754
|
+
_ref$isPlatform = _ref.isPlatform,
|
|
8755
|
+
isPlatform = _ref$isPlatform === void 0 ? false : _ref$isPlatform,
|
|
8756
|
+
returnUrl = _ref.returnUrl;
|
|
8757
|
+
var _useFetchConnectedStr = useFetchConnectedStripeAccount(holdableId),
|
|
8758
|
+
_useFetchConnectedStr2 = _useFetchConnectedStr.data,
|
|
8759
|
+
_useFetchConnectedStr3 = _useFetchConnectedStr2 === void 0 ? {} : _useFetchConnectedStr2,
|
|
8760
|
+
stripeAccount = _useFetchConnectedStr3.account;
|
|
8761
|
+
var _useStateWithDependen = reactUtils.useStateWithDependency(getInitialTab(stripeAccount), [stripeAccount]),
|
|
8762
|
+
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
|
|
8763
|
+
activeTab = _useStateWithDependen2[0],
|
|
8764
|
+
setActiveTab = _useStateWithDependen2[1];
|
|
8765
|
+
var steps = React.useMemo(function () {
|
|
8766
|
+
var _INTEGRATION_STEPS = _slicedToArray(INTEGRATION_STEPS, 4),
|
|
8767
|
+
connect = _INTEGRATION_STEPS[0],
|
|
8768
|
+
configure = _INTEGRATION_STEPS[1],
|
|
8769
|
+
finish = _INTEGRATION_STEPS[2],
|
|
8770
|
+
demo = _INTEGRATION_STEPS[3];
|
|
8771
|
+
return [_objectSpread(_objectSpread({}, connect), {}, {
|
|
8772
|
+
isActive: activeTab === STEPS.connect,
|
|
8773
|
+
isCompleted: neetocist.isPresent(stripeAccount) || activeTab === STEPS.configure || isPlatform
|
|
8774
|
+
}), _objectSpread(_objectSpread({}, configure), {}, {
|
|
8775
|
+
isActive: activeTab === STEPS.configure,
|
|
8776
|
+
isCompleted: !!(stripeAccount !== null && stripeAccount !== void 0 && stripeAccount.isConnected)
|
|
8777
|
+
}), _objectSpread(_objectSpread({}, finish), {}, {
|
|
8778
|
+
isActive: activeTab === STEPS.finish,
|
|
8779
|
+
isCompleted: activeTab === STEPS.finish || activeTab === STEPS.demo
|
|
8780
|
+
}), _objectSpread(_objectSpread({}, demo), {}, {
|
|
8781
|
+
isActive: activeTab === STEPS.demo,
|
|
8782
|
+
isCompleted: activeTab === STEPS.demo
|
|
8783
|
+
})];
|
|
8784
|
+
}, [activeTab, stripeAccount]);
|
|
8785
|
+
return /*#__PURE__*/React__default["default"].createElement(neetointegrations.Modal, {
|
|
8786
|
+
isOpen: isOpen,
|
|
8787
|
+
onClose: onClose,
|
|
8788
|
+
steps: steps
|
|
8789
|
+
}, activeTab === STEPS.connect && /*#__PURE__*/React__default["default"].createElement(Connect, {
|
|
8790
|
+
holdableId: holdableId,
|
|
8791
|
+
returnUrl: returnUrl,
|
|
8792
|
+
setActiveTab: setActiveTab
|
|
8793
|
+
}), activeTab === STEPS.configure && /*#__PURE__*/React__default["default"].createElement(Configure, {
|
|
8794
|
+
holdableId: holdableId,
|
|
8795
|
+
returnUrl: returnUrl
|
|
8796
|
+
}), activeTab === STEPS.finish && /*#__PURE__*/React__default["default"].createElement(Finish, {
|
|
8797
|
+
onSuccess: onClose
|
|
8798
|
+
}), activeTab === STEPS.demo && /*#__PURE__*/React__default["default"].createElement(neetointegrations.Demo, {
|
|
8799
|
+
onClose: onClose
|
|
8800
|
+
}));
|
|
8801
|
+
};
|
|
8802
|
+
|
|
6656
8803
|
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
6657
8804
|
|
|
6658
8805
|
var css = ".ant-table-cell-row-hover .identifier-copy-button{visibility:visible!important}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL19jb3B5LWJ1dHRvbi5zY3NzIiwiYXBwL2phdmFzY3JpcHQvc3JjL3N0eWxlc2hlZXRzL21haW4uc2NzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDRSxrREFDRSw0QkNBSiIsInNvdXJjZXNDb250ZW50IjpbIi5hbnQtdGFibGUtY2VsbC1yb3ctaG92ZXIge1xuICAuaWRlbnRpZmllci1jb3B5LWJ1dHRvbiB7XG4gICAgdmlzaWJpbGl0eTogdmlzaWJsZSAhaW1wb3J0YW50O1xuICB9XG59XG4iLCIuYW50LXRhYmxlLWNlbGwtcm93LWhvdmVyIC5pZGVudGlmaWVyLWNvcHktYnV0dG9uIHtcbiAgdmlzaWJpbGl0eTogdmlzaWJsZSAhaW1wb3J0YW50O1xufSJdfQ== */";
|
|
@@ -6806,6 +8953,7 @@ exports.PayoutsDashboard = index$2;
|
|
|
6806
8953
|
exports.PayoutsPage = PayoutsPage;
|
|
6807
8954
|
exports.SquareCard = SquareCard;
|
|
6808
8955
|
exports.SquareDashboard = index$1;
|
|
8956
|
+
exports.StripeConnect = StripeConnect;
|
|
6809
8957
|
exports.buildStripeTransactionLink = buildStripeTransactionLink;
|
|
6810
8958
|
exports.useSquareCard = useSquareCard;
|
|
6811
8959
|
exports.useStripePromise = useStripePromise;
|