@paydock/client-sdk 1.122.3-beta → 1.123.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -5
- package/bundles/index.cjs +2472 -1735
- package/bundles/index.cjs.d.ts +314 -25
- package/bundles/index.mjs +2471 -1736
- package/bundles/index.mjs.d.ts +314 -25
- package/bundles/types/api/api-base.d.ts +1 -1
- package/bundles/types/api/api-base.d.ts.map +1 -1
- package/bundles/types/checkout/helpers/instruction-module.d.ts +1 -1
- package/bundles/types/checkout/helpers/instruction-module.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/index.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.fraud_service.show.d.ts +21 -0
- package/bundles/types/checkout/instructions/v1/instruction.fraud_service.show.d.ts.map +1 -0
- package/bundles/types/checkout/instructions/v1/instruction.payment_methods.show.d.ts.map +1 -1
- package/bundles/types/checkout/layout-widgets/additionals.d.ts +1 -1
- package/bundles/types/checkout/layout-widgets/payment-methods.d.ts +6 -4
- package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
- package/bundles/types/configs/env/environment.cba.d.ts +8 -7
- package/bundles/types/configs/env/environment.cba.d.ts.map +1 -1
- package/bundles/types/configs/env/environment.interface.d.ts +6 -6
- package/bundles/types/configs/env/environment.interface.d.ts.map +1 -1
- package/bundles/types/configs/env/environment.paydock.d.ts +8 -7
- package/bundles/types/configs/env/environment.paydock.d.ts.map +1 -1
- package/bundles/types/fraud-prevention/fraud-prevention.constants.d.ts +9 -0
- package/bundles/types/fraud-prevention/fraud-prevention.constants.d.ts.map +1 -0
- package/bundles/types/fraud-prevention/fraud-prevention.events.d.ts +42 -0
- package/bundles/types/fraud-prevention/fraud-prevention.events.d.ts.map +1 -0
- package/bundles/types/fraud-prevention/fraud-prevention.service.d.ts +163 -0
- package/bundles/types/fraud-prevention/fraud-prevention.service.d.ts.map +1 -0
- package/bundles/types/fraud-prevention/index.d.ts +3 -0
- package/bundles/types/fraud-prevention/index.d.ts.map +1 -0
- package/bundles/types/fraud-prevention/providers/forter/forter-device-agent.service.d.ts +79 -0
- package/bundles/types/fraud-prevention/providers/forter/forter-device-agent.service.d.ts.map +1 -0
- package/bundles/types/fraud-prevention/providers/forter/templates/forter-snippet-2025-02-06t14:19:34z.template.d.ts +2 -0
- package/bundles/types/fraud-prevention/providers/forter/templates/forter-snippet-2025-02-06t14:19:34z.template.d.ts.map +1 -0
- package/bundles/types/fraud-prevention/resources/find-service-config.repository.d.ts +20 -0
- package/bundles/types/fraud-prevention/resources/find-service-config.repository.d.ts.map +1 -0
- package/bundles/types/helper/access-token.d.ts +1 -0
- package/bundles/types/helper/access-token.d.ts.map +1 -1
- package/bundles/types/helper/browser.d.ts.map +1 -1
- package/bundles/types/helper/deep-clone.d.ts +13 -0
- package/bundles/types/helper/deep-clone.d.ts.map +1 -0
- package/bundles/types/index-cba.d.ts +1 -0
- package/bundles/types/index-cba.d.ts.map +1 -1
- package/bundles/types/index.d.ts +2 -1
- package/bundles/types/index.d.ts.map +1 -1
- package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts +1 -1
- package/bundles/types/secure-remote-commerce/click-to-pay-secure-remote-commerce.d.ts.map +1 -1
- package/bundles/types/shared/device/device-info.service.d.ts +13 -0
- package/bundles/types/shared/device/device-info.service.d.ts.map +1 -0
- package/bundles/types/shared/http/authorization-strategy.d.ts +41 -0
- package/bundles/types/shared/http/authorization-strategy.d.ts.map +1 -0
- package/bundles/types/shared/http/http-fetcher.d.ts +29 -0
- package/bundles/types/shared/http/http-fetcher.d.ts.map +1 -0
- package/bundles/types/shared/http/http-fetcher.factory.d.ts +17 -0
- package/bundles/types/shared/http/http-fetcher.factory.d.ts.map +1 -0
- package/bundles/types/shared/http/http-request.d.ts +1 -1
- package/bundles/types/shared/http/http-request.d.ts.map +1 -1
- package/bundles/types/shared/http/http-response.dto.d.ts +19 -0
- package/bundles/types/shared/http/http-response.dto.d.ts.map +1 -0
- package/bundles/types/shared/services/instrumentation/instrumentation.types.d.ts +1 -1
- package/bundles/types/shared/services/instrumentation/instrumentation.types.d.ts.map +1 -1
- package/bundles/types/shared/services/instrumentation/repositories/action.repository.d.ts.map +1 -1
- package/bundles/types/shared/services/instrumentation/repositories/error.repository.d.ts.map +1 -1
- package/bundles/types/shared/services/instrumentation/repositories/event.repository.d.ts.map +1 -1
- package/bundles/types/shared/shared.constants.d.ts +6 -0
- package/bundles/types/shared/shared.constants.d.ts.map +1 -0
- package/bundles/types/widget/configuration.d.ts +1 -1
- package/bundles/types/widget/configuration.d.ts.map +1 -1
- package/bundles/types/widget/html-widget.d.ts +14 -14
- package/bundles/types/widget/html-widget.d.ts.map +1 -1
- package/bundles/widget.umd.js +2472 -1735
- package/bundles/widget.umd.js.d.ts +314 -25
- package/bundles/widget.umd.js.min.d.ts +314 -25
- package/bundles/widget.umd.min.js +1 -1
- package/docs/api-widget.md +4 -4
- package/docs/fraud-prevention-examples.md +154 -0
- package/docs/fraud-prevention.md +0 -0
- package/docs/install/npm.example.md +1 -1
- package/package.json +17 -9
- package/slate.md +156 -1
- package/bundles/types/shared/http/index.d.ts +0 -2
- package/bundles/types/shared/http/index.d.ts.map +0 -1
package/bundles/index.mjs
CHANGED
|
@@ -497,10 +497,10 @@ function _superPropBase(t, o) {
|
|
|
497
497
|
for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););
|
|
498
498
|
return t;
|
|
499
499
|
}
|
|
500
|
-
function _superPropGet(t,
|
|
501
|
-
var p = _get(_getPrototypeOf(t.prototype ),
|
|
500
|
+
function _superPropGet(t, o, e, r) {
|
|
501
|
+
var p = _get(_getPrototypeOf(t.prototype ), o, e);
|
|
502
502
|
return "function" == typeof p ? function (t) {
|
|
503
|
-
return p.apply(
|
|
503
|
+
return p.apply(e, t);
|
|
504
504
|
} : p;
|
|
505
505
|
}
|
|
506
506
|
function _toConsumableArray(r) {
|
|
@@ -863,46 +863,75 @@ var DEFAULT_ALIAS = {
|
|
|
863
863
|
PAYDOCK: 'paydock.com',
|
|
864
864
|
KOVENA: 'kovena.com'
|
|
865
865
|
};
|
|
866
|
+
// TODO @ingeniousraccoons we should take advantage of TypeScript mechanism for static environmentId checking and simplified runtime validation
|
|
867
|
+
// TODO @ingeniousraccoons unify `environment.paydock.ts` and `environment.cba.ts` making them configuration driven
|
|
866
868
|
var Env = /*#__PURE__*/function () {
|
|
867
869
|
function Env(configs) {
|
|
868
870
|
var defaultEnv = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_ENV;
|
|
869
871
|
_classCallCheck(this, Env);
|
|
870
|
-
this.
|
|
872
|
+
this.environmentConfigurations = configs;
|
|
871
873
|
this.setEnv(defaultEnv);
|
|
872
874
|
}
|
|
873
875
|
return _createClass(Env, [{
|
|
874
876
|
key: "setEnv",
|
|
875
|
-
value: function setEnv(
|
|
876
|
-
|
|
877
|
-
this.
|
|
878
|
-
|
|
879
|
-
if (alias)
|
|
877
|
+
value: function setEnv(environmentId, alias) {
|
|
878
|
+
this.validateAlias(alias);
|
|
879
|
+
this.validateEnvironmentId(environmentId);
|
|
880
|
+
this.environmentId = environmentId;
|
|
881
|
+
if (alias) {
|
|
882
|
+
this.alias = alias;
|
|
883
|
+
} else if (ADDITIONAL_ENV.includes(this.environmentId)) {
|
|
884
|
+
this.alias = DEFAULT_ALIAS.KOVENA;
|
|
885
|
+
} else {
|
|
886
|
+
this.alias = DEFAULT_ALIAS.PAYDOCK;
|
|
887
|
+
}
|
|
880
888
|
}
|
|
881
889
|
}, {
|
|
882
890
|
key: "getEnv",
|
|
883
891
|
value: function getEnv() {
|
|
884
|
-
return this.
|
|
892
|
+
return this.environmentId;
|
|
885
893
|
}
|
|
886
894
|
}, {
|
|
887
895
|
key: "getConf",
|
|
888
896
|
value: function getConf() {
|
|
889
|
-
for (var index in this.
|
|
890
|
-
if (!this.
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
897
|
+
for (var index in this.environmentConfigurations) {
|
|
898
|
+
if (!Object.hasOwn(this.environmentConfigurations, index)) {
|
|
899
|
+
continue;
|
|
900
|
+
}
|
|
901
|
+
if (this.environmentConfigurations[index].env === this.getEnv()) {
|
|
902
|
+
return {
|
|
903
|
+
url: this.environmentConfigurations[index].url.indexOf('localhost') !== -1 ? this.environmentConfigurations[index].url : this.environmentConfigurations[index].url + this.alias,
|
|
904
|
+
env: this.environmentConfigurations[index].env
|
|
905
|
+
};
|
|
906
|
+
}
|
|
895
907
|
}
|
|
896
|
-
throw new Error('
|
|
908
|
+
throw new Error('Env could not obtain configuration. Unknown environmentId.');
|
|
897
909
|
}
|
|
898
910
|
}, {
|
|
899
|
-
key: "
|
|
900
|
-
value: function
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
911
|
+
key: "validateAlias",
|
|
912
|
+
value: function validateAlias(alias) {
|
|
913
|
+
if (typeof alias === 'undefined') {
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
if (typeof alias !== 'string') {
|
|
917
|
+
throw new TypeError("Env expects parameter 'alias' to be of type 'string' or 'undefined'.");
|
|
918
|
+
}
|
|
919
|
+
if (!alias.match(REGEX_ALIAS)) {
|
|
920
|
+
throw new Error("Env received malformed alias: ".concat(alias, ". Ensure it satisfies the regex: '").concat(REGEX_ALIAS, "'."));
|
|
904
921
|
}
|
|
905
|
-
|
|
922
|
+
}
|
|
923
|
+
}, {
|
|
924
|
+
key: "validateEnvironmentId",
|
|
925
|
+
value: function validateEnvironmentId(environmentId) {
|
|
926
|
+
for (var index in this.environmentConfigurations) {
|
|
927
|
+
if (!Object.hasOwn(this.environmentConfigurations, index)) {
|
|
928
|
+
continue;
|
|
929
|
+
}
|
|
930
|
+
if (this.environmentConfigurations[index].env === environmentId) {
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
throw new TypeError("Env received unknown environmentId: ".concat(environmentId));
|
|
906
935
|
}
|
|
907
936
|
}]);
|
|
908
937
|
}();
|
|
@@ -923,7 +952,7 @@ SDK.headerKeys = Object.freeze({
|
|
|
923
952
|
version: 'x-sdk-version',
|
|
924
953
|
type: 'x-sdk-type'
|
|
925
954
|
});
|
|
926
|
-
SDK._version = 'v1.
|
|
955
|
+
SDK._version = 'v1.123.2-beta';
|
|
927
956
|
|
|
928
957
|
/******************************************************************************
|
|
929
958
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1787,6 +1816,12 @@ var AccessToken = /*#__PURE__*/function () {
|
|
|
1787
1816
|
value: function getAccessHeaderNameByToken(token) {
|
|
1788
1817
|
return !!AccessToken.validateJWT(token) ? ACCESS_HEADER_NAME.accessToken : ACCESS_HEADER_NAME.publicKey;
|
|
1789
1818
|
}
|
|
1819
|
+
}, {
|
|
1820
|
+
key: "isJwt",
|
|
1821
|
+
value: function isJwt(value) {
|
|
1822
|
+
var jwtPattern = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
1823
|
+
return jwtPattern.test(value);
|
|
1824
|
+
}
|
|
1790
1825
|
}]);
|
|
1791
1826
|
}();
|
|
1792
1827
|
|
|
@@ -4321,7 +4356,7 @@ var ActionRepository = /*#__PURE__*/function () {
|
|
|
4321
4356
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4322
4357
|
while (1) switch (_context.prev = _context.next) {
|
|
4323
4358
|
case 0:
|
|
4324
|
-
(_this$agent = this.agent).
|
|
4359
|
+
(_this$agent = this.agent).call.apply(_this$agent, ['addPageAction'].concat(args));
|
|
4325
4360
|
case 1:
|
|
4326
4361
|
case "end":
|
|
4327
4362
|
return _context.stop();
|
|
@@ -4349,7 +4384,7 @@ var ErrorRepository = /*#__PURE__*/function () {
|
|
|
4349
4384
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4350
4385
|
while (1) switch (_context.prev = _context.next) {
|
|
4351
4386
|
case 0:
|
|
4352
|
-
(_this$agent = this.agent).
|
|
4387
|
+
(_this$agent = this.agent).call.apply(_this$agent, ['noticeError'].concat(args));
|
|
4353
4388
|
case 1:
|
|
4354
4389
|
case "end":
|
|
4355
4390
|
return _context.stop();
|
|
@@ -4377,7 +4412,7 @@ var EventRepository = /*#__PURE__*/function () {
|
|
|
4377
4412
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4378
4413
|
while (1) switch (_context.prev = _context.next) {
|
|
4379
4414
|
case 0:
|
|
4380
|
-
(_this$agent = this.agent).
|
|
4415
|
+
(_this$agent = this.agent).call.apply(_this$agent, ['addPageAction'].concat(args));
|
|
4381
4416
|
case 1:
|
|
4382
4417
|
case "end":
|
|
4383
4418
|
return _context.stop();
|
|
@@ -8943,6 +8978,829 @@ var PaypalCheckoutButton = /*#__PURE__*/function (_CheckoutButton) {
|
|
|
8943
8978
|
return _createClass(PaypalCheckoutButton);
|
|
8944
8979
|
}(CheckoutButton);
|
|
8945
8980
|
|
|
8981
|
+
var MODES = ['live', 'test'];
|
|
8982
|
+
function isValidMode(val) {
|
|
8983
|
+
return MODES.includes(val);
|
|
8984
|
+
}
|
|
8985
|
+
var PROVIDERS = {
|
|
8986
|
+
FORTER: 'forter'
|
|
8987
|
+
};
|
|
8988
|
+
|
|
8989
|
+
var NAMESPACE = 'fraudPrevention';
|
|
8990
|
+
var TYPES = {
|
|
8991
|
+
FINGERPRINT_TOKEN_ERROR: 'fingerprint-token-error',
|
|
8992
|
+
FINTERPRINT_TOKEN_READY: 'fingerprint-token-ready'
|
|
8993
|
+
};
|
|
8994
|
+
var FRAUD_PREVENTION_EVENTS = {
|
|
8995
|
+
NAMESPACE: NAMESPACE,
|
|
8996
|
+
TYPES: TYPES,
|
|
8997
|
+
PROVIDERS: PROVIDERS
|
|
8998
|
+
};
|
|
8999
|
+
|
|
9000
|
+
var AuthorizationStrategy = /*#__PURE__*/_createClass(function AuthorizationStrategy() {
|
|
9001
|
+
_classCallCheck(this, AuthorizationStrategy);
|
|
9002
|
+
});
|
|
9003
|
+
/**
|
|
9004
|
+
* Implementation of AuthorizationStrategy that uses an access token for authorization.
|
|
9005
|
+
*
|
|
9006
|
+
* This strategy configures the SDK Services and Widgets to use access token authentication.
|
|
9007
|
+
*/
|
|
9008
|
+
var AccessTokenStrategy = /*#__PURE__*/function (_AuthorizationStrateg) {
|
|
9009
|
+
/**
|
|
9010
|
+
* @constructor Creates an instance of AuthorizationStrategy which enables authorization by access token
|
|
9011
|
+
*
|
|
9012
|
+
* @param accessToken
|
|
9013
|
+
*/
|
|
9014
|
+
function AccessTokenStrategy(accessToken) {
|
|
9015
|
+
var _this;
|
|
9016
|
+
_classCallCheck(this, AccessTokenStrategy);
|
|
9017
|
+
_this = _callSuper(this, AccessTokenStrategy);
|
|
9018
|
+
_this.accessToken = accessToken;
|
|
9019
|
+
if (typeof accessToken !== 'string') {
|
|
9020
|
+
throw new TypeError("AccessTokenStrategy expects parameter 'accessToken' to be of type string.");
|
|
9021
|
+
}
|
|
9022
|
+
return _this;
|
|
9023
|
+
}
|
|
9024
|
+
_inherits(AccessTokenStrategy, _AuthorizationStrateg);
|
|
9025
|
+
return _createClass(AccessTokenStrategy, [{
|
|
9026
|
+
key: "apply",
|
|
9027
|
+
value: function apply(httpFetch) {
|
|
9028
|
+
httpFetch.setAccessToken(this.accessToken);
|
|
9029
|
+
}
|
|
9030
|
+
}]);
|
|
9031
|
+
}(AuthorizationStrategy);
|
|
9032
|
+
/**
|
|
9033
|
+
* Implementation of AuthorizationStrategy that preserves Services and Widgets in an anonymous state.
|
|
9034
|
+
*/
|
|
9035
|
+
var AnonymousStrategy = /*#__PURE__*/function (_AuthorizationStrateg2) {
|
|
9036
|
+
function AnonymousStrategy() {
|
|
9037
|
+
_classCallCheck(this, AnonymousStrategy);
|
|
9038
|
+
return _callSuper(this, AnonymousStrategy, arguments);
|
|
9039
|
+
}
|
|
9040
|
+
_inherits(AnonymousStrategy, _AuthorizationStrateg2);
|
|
9041
|
+
return _createClass(AnonymousStrategy, [{
|
|
9042
|
+
key: "apply",
|
|
9043
|
+
value: function apply(_) {
|
|
9044
|
+
// no-op
|
|
9045
|
+
}
|
|
9046
|
+
}]);
|
|
9047
|
+
}(AuthorizationStrategy);
|
|
9048
|
+
/**
|
|
9049
|
+
* Implementation of AuthorizationStrategy that uses a public key for authorization.
|
|
9050
|
+
*
|
|
9051
|
+
* This strategy configures the SDK Services and Widgets to use public key authentication.
|
|
9052
|
+
*/
|
|
9053
|
+
var PublicKeyStrategy = /*#__PURE__*/function (_AuthorizationStrateg3) {
|
|
9054
|
+
/**
|
|
9055
|
+
* @constructor Creates an instance of AuthorizationStrategy which enables authorization by public key
|
|
9056
|
+
*
|
|
9057
|
+
* @param publicKey
|
|
9058
|
+
*/
|
|
9059
|
+
function PublicKeyStrategy(publicKey) {
|
|
9060
|
+
var _this2;
|
|
9061
|
+
_classCallCheck(this, PublicKeyStrategy);
|
|
9062
|
+
_this2 = _callSuper(this, PublicKeyStrategy);
|
|
9063
|
+
_this2.publicKey = publicKey;
|
|
9064
|
+
if (typeof publicKey !== 'string') {
|
|
9065
|
+
throw new TypeError("AccessTokenStrategy expects parameter 'publicKey' to be of type string.");
|
|
9066
|
+
}
|
|
9067
|
+
return _this2;
|
|
9068
|
+
}
|
|
9069
|
+
_inherits(PublicKeyStrategy, _AuthorizationStrateg3);
|
|
9070
|
+
return _createClass(PublicKeyStrategy, [{
|
|
9071
|
+
key: "apply",
|
|
9072
|
+
value: function apply(httpFetch) {
|
|
9073
|
+
httpFetch.setPublicKey(this.publicKey);
|
|
9074
|
+
}
|
|
9075
|
+
}]);
|
|
9076
|
+
}(AuthorizationStrategy);
|
|
9077
|
+
|
|
9078
|
+
/**
|
|
9079
|
+
* Deep clones a value.
|
|
9080
|
+
*
|
|
9081
|
+
* @param value - The value to clone.
|
|
9082
|
+
* @param visited - A WeakMap to track visited objects.
|
|
9083
|
+
* @returns A deep clone of the value.
|
|
9084
|
+
*
|
|
9085
|
+
* Warning: Only own enumerable properties of objects are cloned. Thus, not suitable for cloning custom instances with getters, setters, methods or static properties.
|
|
9086
|
+
* Warning: Functions are cloned by reference.
|
|
9087
|
+
* Warning: Circular references are cloned by reference.
|
|
9088
|
+
*/
|
|
9089
|
+
function deepClone(value) {
|
|
9090
|
+
var visited = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
|
|
9091
|
+
// Handle null, undefined, and primitive types
|
|
9092
|
+
if (value === null || value === undefined || _typeof$1(value) !== 'object') {
|
|
9093
|
+
return value;
|
|
9094
|
+
}
|
|
9095
|
+
// Handle circular references - Copy by reference if already visited
|
|
9096
|
+
if (visited.has(value)) {
|
|
9097
|
+
return visited.get(value);
|
|
9098
|
+
}
|
|
9099
|
+
// Handle Date objects
|
|
9100
|
+
if (value instanceof Date) {
|
|
9101
|
+
return new Date(value.getTime());
|
|
9102
|
+
}
|
|
9103
|
+
// Handle Array objects
|
|
9104
|
+
if (Array.isArray(value)) {
|
|
9105
|
+
var _clone = [];
|
|
9106
|
+
visited.set(value, _clone);
|
|
9107
|
+
_clone.push.apply(_clone, _toConsumableArray(value.map(function (item) {
|
|
9108
|
+
return deepClone(item, visited);
|
|
9109
|
+
})));
|
|
9110
|
+
return _clone;
|
|
9111
|
+
}
|
|
9112
|
+
// Handle Map objects
|
|
9113
|
+
if (value instanceof Map) {
|
|
9114
|
+
var _clone2 = new Map();
|
|
9115
|
+
visited.set(value, _clone2);
|
|
9116
|
+
value.forEach(function (val, key) {
|
|
9117
|
+
_clone2.set(deepClone(key, visited), deepClone(val, visited));
|
|
9118
|
+
});
|
|
9119
|
+
return _clone2;
|
|
9120
|
+
}
|
|
9121
|
+
// Handle Set objects
|
|
9122
|
+
if (value instanceof Set) {
|
|
9123
|
+
var _clone3 = new Set();
|
|
9124
|
+
visited.set(value, _clone3);
|
|
9125
|
+
var _iterator = _createForOfIteratorHelper(value),
|
|
9126
|
+
_step;
|
|
9127
|
+
try {
|
|
9128
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
9129
|
+
var val = _step.value;
|
|
9130
|
+
_clone3.add(deepClone(val, visited));
|
|
9131
|
+
}
|
|
9132
|
+
} catch (err) {
|
|
9133
|
+
_iterator.e(err);
|
|
9134
|
+
} finally {
|
|
9135
|
+
_iterator.f();
|
|
9136
|
+
}
|
|
9137
|
+
return _clone3;
|
|
9138
|
+
}
|
|
9139
|
+
// For objects, create a plain object (ignoring prototype, getters, setters and methods) and clone own enumerable properties
|
|
9140
|
+
var clone = {};
|
|
9141
|
+
var keys = Object.keys(value);
|
|
9142
|
+
visited.set(value, clone);
|
|
9143
|
+
for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
|
|
9144
|
+
var key = _keys[_i];
|
|
9145
|
+
clone[key] = deepClone(value[key], visited);
|
|
9146
|
+
}
|
|
9147
|
+
return clone;
|
|
9148
|
+
}
|
|
9149
|
+
|
|
9150
|
+
var failureResult = function failureResult(data) {
|
|
9151
|
+
return [null, data];
|
|
9152
|
+
};
|
|
9153
|
+
var successResult = function successResult(data) {
|
|
9154
|
+
return [data, null];
|
|
9155
|
+
};
|
|
9156
|
+
|
|
9157
|
+
var HttpFetcher = /*#__PURE__*/function () {
|
|
9158
|
+
function HttpFetcher() {
|
|
9159
|
+
_classCallCheck(this, HttpFetcher);
|
|
9160
|
+
this.reportError = function (repository, err, ctx) {
|
|
9161
|
+
repository.createError(err, ctx);
|
|
9162
|
+
};
|
|
9163
|
+
this.baseUrl = '';
|
|
9164
|
+
this.headers = {};
|
|
9165
|
+
}
|
|
9166
|
+
return _createClass(HttpFetcher, [{
|
|
9167
|
+
key: "setAccessToken",
|
|
9168
|
+
value: function setAccessToken(accessToken) {
|
|
9169
|
+
this.headers['x-access-token'] = accessToken;
|
|
9170
|
+
return this;
|
|
9171
|
+
}
|
|
9172
|
+
}, {
|
|
9173
|
+
key: "setBaseUrl",
|
|
9174
|
+
value: function setBaseUrl(baseUrl) {
|
|
9175
|
+
this.baseUrl = baseUrl;
|
|
9176
|
+
return this;
|
|
9177
|
+
}
|
|
9178
|
+
}, {
|
|
9179
|
+
key: "setBody",
|
|
9180
|
+
value: function setBody(body) {
|
|
9181
|
+
if (_typeof$1(body) === 'symbol' || typeof body === 'function' || typeof body === 'undefined') {
|
|
9182
|
+
throw new TypeError("HttpFetcher setBody: expected parameter 'body' to be serializable.");
|
|
9183
|
+
}
|
|
9184
|
+
this.body = body;
|
|
9185
|
+
return this;
|
|
9186
|
+
}
|
|
9187
|
+
}, {
|
|
9188
|
+
key: "setContentTypeJson",
|
|
9189
|
+
value: function setContentTypeJson() {
|
|
9190
|
+
this.headers['Content-Type'] = 'application/json; charset=UTF-8';
|
|
9191
|
+
return this;
|
|
9192
|
+
}
|
|
9193
|
+
}, {
|
|
9194
|
+
key: "setContentTypeText",
|
|
9195
|
+
value: function setContentTypeText() {
|
|
9196
|
+
this.headers['Content-Type'] = 'text/plain; charset=UTF-8';
|
|
9197
|
+
return this;
|
|
9198
|
+
}
|
|
9199
|
+
}, {
|
|
9200
|
+
key: "setHeaders",
|
|
9201
|
+
value: function setHeaders(headers) {
|
|
9202
|
+
_extends(this.headers, headers);
|
|
9203
|
+
return this;
|
|
9204
|
+
}
|
|
9205
|
+
}, {
|
|
9206
|
+
key: "setPublicKey",
|
|
9207
|
+
value: function setPublicKey(publicKey) {
|
|
9208
|
+
this.headers['x-user-public-key'] = publicKey;
|
|
9209
|
+
return this;
|
|
9210
|
+
}
|
|
9211
|
+
}, {
|
|
9212
|
+
key: "setSdkVersion",
|
|
9213
|
+
value: function setSdkVersion() {
|
|
9214
|
+
if (SDK.version) {
|
|
9215
|
+
this.headers[SDK.headerKeys.version] = SDK.version;
|
|
9216
|
+
this.headers[SDK.headerKeys.type] = SDK.type;
|
|
9217
|
+
}
|
|
9218
|
+
return this;
|
|
9219
|
+
}
|
|
9220
|
+
}, {
|
|
9221
|
+
key: "execute",
|
|
9222
|
+
value: function execute(method, path) {
|
|
9223
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
9224
|
+
var url, response, responseContentType, text, json;
|
|
9225
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9226
|
+
while (1) switch (_context.prev = _context.next) {
|
|
9227
|
+
case 0:
|
|
9228
|
+
url = "".concat(this.baseUrl).concat(path);
|
|
9229
|
+
_context.prev = 1;
|
|
9230
|
+
_context.next = 4;
|
|
9231
|
+
return fetch(url, {
|
|
9232
|
+
method: method,
|
|
9233
|
+
body: this.body ? JSON.stringify(this.body) : undefined,
|
|
9234
|
+
headers: this.headers
|
|
9235
|
+
});
|
|
9236
|
+
case 4:
|
|
9237
|
+
response = _context.sent;
|
|
9238
|
+
responseContentType = response.headers.get('Content-Type') || '';
|
|
9239
|
+
if (!responseContentType.includes('text/plain')) {
|
|
9240
|
+
_context.next = 11;
|
|
9241
|
+
break;
|
|
9242
|
+
}
|
|
9243
|
+
_context.next = 9;
|
|
9244
|
+
return response.text();
|
|
9245
|
+
case 9:
|
|
9246
|
+
text = _context.sent;
|
|
9247
|
+
return _context.abrupt("return", successResult({
|
|
9248
|
+
statusCode: response.status,
|
|
9249
|
+
body: text
|
|
9250
|
+
}));
|
|
9251
|
+
case 11:
|
|
9252
|
+
_context.next = 13;
|
|
9253
|
+
return response.json();
|
|
9254
|
+
case 13:
|
|
9255
|
+
json = _context.sent;
|
|
9256
|
+
if (response.ok) {
|
|
9257
|
+
_context.next = 16;
|
|
9258
|
+
break;
|
|
9259
|
+
}
|
|
9260
|
+
return _context.abrupt("return", failureResult({
|
|
9261
|
+
statusCode: response.status,
|
|
9262
|
+
body: json
|
|
9263
|
+
}));
|
|
9264
|
+
case 16:
|
|
9265
|
+
if (!('error' in json && json.error !== null)) {
|
|
9266
|
+
_context.next = 18;
|
|
9267
|
+
break;
|
|
9268
|
+
}
|
|
9269
|
+
return _context.abrupt("return", failureResult({
|
|
9270
|
+
statusCode: response.status,
|
|
9271
|
+
body: json
|
|
9272
|
+
}));
|
|
9273
|
+
case 18:
|
|
9274
|
+
return _context.abrupt("return", successResult({
|
|
9275
|
+
statusCode: response.status,
|
|
9276
|
+
body: json
|
|
9277
|
+
}));
|
|
9278
|
+
case 21:
|
|
9279
|
+
_context.prev = 21;
|
|
9280
|
+
_context.t0 = _context["catch"](1);
|
|
9281
|
+
this.reportError(errorRepository, _context.t0, {
|
|
9282
|
+
sdkVersion: SDK.version,
|
|
9283
|
+
className: HttpFetcher.name,
|
|
9284
|
+
classMethod: 'send',
|
|
9285
|
+
environment: this.baseUrl
|
|
9286
|
+
});
|
|
9287
|
+
throw _context.t0;
|
|
9288
|
+
case 25:
|
|
9289
|
+
case "end":
|
|
9290
|
+
return _context.stop();
|
|
9291
|
+
}
|
|
9292
|
+
}, _callee, this, [[1, 21]]);
|
|
9293
|
+
}));
|
|
9294
|
+
}
|
|
9295
|
+
}, {
|
|
9296
|
+
key: "value",
|
|
9297
|
+
value: function value() {
|
|
9298
|
+
return {
|
|
9299
|
+
baseUrl: this.baseUrl,
|
|
9300
|
+
headers: deepClone(this.headers),
|
|
9301
|
+
body: deepClone(this.body)
|
|
9302
|
+
};
|
|
9303
|
+
}
|
|
9304
|
+
}]);
|
|
9305
|
+
}();
|
|
9306
|
+
|
|
9307
|
+
var HttpFetcherFactory = /*#__PURE__*/function () {
|
|
9308
|
+
function HttpFetcherFactory(config) {
|
|
9309
|
+
_classCallCheck(this, HttpFetcherFactory);
|
|
9310
|
+
this.authorizationStrategyReference = config.authorizationStrategy;
|
|
9311
|
+
this.environment = config.environment;
|
|
9312
|
+
}
|
|
9313
|
+
return _createClass(HttpFetcherFactory, [{
|
|
9314
|
+
key: "createFetcher",
|
|
9315
|
+
value: function createFetcher() {
|
|
9316
|
+
var baseUrl = this.environment.getConf().url;
|
|
9317
|
+
var fetcher = new HttpFetcher().setBaseUrl(baseUrl).setContentTypeJson().setSdkVersion();
|
|
9318
|
+
this.authorizationStrategyValue.apply(fetcher);
|
|
9319
|
+
return fetcher;
|
|
9320
|
+
}
|
|
9321
|
+
}, {
|
|
9322
|
+
key: "authorizationStrategyValue",
|
|
9323
|
+
get: function get() {
|
|
9324
|
+
return typeof this.authorizationStrategyReference === 'function' ? this.authorizationStrategyReference() : this.authorizationStrategyReference;
|
|
9325
|
+
}
|
|
9326
|
+
}]);
|
|
9327
|
+
}();
|
|
9328
|
+
|
|
9329
|
+
var FORTER_SDK_SCRIPT_TEMPLATE = "\n(function () {\n var merchantConfig = {\n csp: %CSP%\n };\n\n var siteId = \"%SITE_ID%\";\n\n function t(t,e){for(var n=t.split(\"\"),r=0;r<n.length;++r)n[r]=String.fromCharCode(n[r].charCodeAt(0)+e);return n.join(\"\")}function e(e){return t(e,-_).replace(/%SN%/g,siteId)}function n(t){try{if(\"number\"==typeof t&&window.location&&window.location.pathname){for(var e=window.location.pathname.split(\"/\"),n=[],r=0;r<=Math.min(e.length-1,Math.abs(t));r++)n.push(e[r]);return n.join(\"/\")||\"/\"}}catch(t){}return\"/\"}function r(t){try{Q.ex=t,o()&&-1===Q.ex.indexOf(X.uB)&&(Q.ex+=X.uB),i()&&-1===Q.ex.indexOf(X.uBr)&&(Q.ex+=X.uBr),a()&&-1===Q.ex.indexOf(X.nIL)&&(Q.ex+=X.nIL),window.ftr__snp_cwc||(Q.ex+=X.s),B(Q)}catch(t){}}function o(){var t=\"no\"+\"op\"+\"fn\",e=\"g\"+\"a\",n=\"n\"+\"ame\";return window[e]&&window[e][n]===t}function i(){return!(!navigator.brave||\"function\"!=typeof navigator.brave.isBrave)}function a(){return document.currentScript&&document.currentScript.src}function c(t,e){function n(o){try{o.blockedURI===t&&(e(),document.removeEventListener(r,n))}catch(t){document.removeEventListener(r,n)}}var r=\"securitypolicyviolation\";document.addEventListener(r,n),setTimeout(function(){document.removeEventListener(r,n)},2*60*1e3)}function u(t,e,n,r){var o=!1;t=\"https://\"+t,c(t,function(){r(!0),o=!0});var i=document.createElement(\"script\");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=n,i.type=\"text/javascript\",i.id=\"ftr__script\",i.async=!0,i.src=t;var a=document.getElementsByTagName(\"script\")[0];a.parentNode.insertBefore(i,a)}function f(){tt(X.uDF),setTimeout(w,N,X.uDF)}function s(t,e,n,r){var o=!1,i=new XMLHttpRequest;if(c(\"https:\"+t,function(){n(new Error(\"CSP Violation\"),!0),o=!0}),\"//\"===t.slice(0,2)&&(t=\"https:\"+t),\"withCredentials\"in i)i.open(\"GET\",t,!0);else{if(\"undefined\"==typeof XDomainRequest)return;i=new XDomainRequest,i.open(\"GET\",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){\"function\"==typeof e&&e(i)},i.onerror=function(t){if(\"function\"==typeof n&&!o)try{n(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){\"function\"==typeof n&&n(\"tim\"+\"eo\"+\"ut\",!1)},setTimeout(function(){i.send()},0)}function d(t,siteId,e){function n(t){var e=t.toString(16);return e.length%2?\"0\"+e:e}function r(t){if(t<=0)return\"\";for(var e=\"0123456789abcdef\",n=\"\",r=0;r<t;r++)n+=e[Math.floor(Math.random()*e.length)];return n}function o(t){for(var e=\"\",r=0;r<t.length;r++)e+=n(t.charCodeAt(r));return e}function i(t){for(var e=t.split(\"\"),n=0;n<e.length;++n)e[n]=String.fromCharCode(255^e[n].charCodeAt(0));return e.join(\"\")}e=e?\"1\":\"0\";var a=[];return a.push(t),a.push(siteId),a.push(e),function(t){var e=40,n=\"\";return t.length<e/2&&(n=\",\"+r(e/2-t.length-1)),o(i(t+n))}(a.join(\",\"))}function h(){function t(){F&&(tt(X.dUAL),setTimeout(w,N,X.dUAL))}function e(t,e){r(e?X.uAS+X.uF+X.cP:X.uAS+X.uF),F=\"F\"+\"T\"+\"R\"+\"A\"+\"U\",setTimeout(w,N,X.uAS)}window.ftr__fdad(t,e)}function l(){function t(){F&&setTimeout(w,N,X.uDAD)}function e(t,e){r(e?X.uDS+X.uF+X.cP:X.uDS+X.uF),F=\"F\"+\"T\"+\"R\"+\"A\"+\"U\",setTimeout(w,N,X.uDS)}window.ftr__radd(t,e)}function w(t){try{var e;switch(t){case X.uFP:e=O;break;case X.uDF:e=M;break;default:e=F}if(!e)return;var n=function(){try{et(),r(t+X.uS)}catch(t){}},o=function(e){try{et(),Q.td=1*new Date-Q.ts,r(e?t+X.uF+X.cP:t+X.uF),t===X.uFP&&f(),t===X.uDF&&(I?l():h()),t!==X.uAS&&t!==X.dUAL||I||l(),t!==X.uDS&&t!==X.uDAD||I&&h()}catch(t){r(X.eUoe)}};if(e===\"F\"+\"T\"+\"R\"+\"A\"+\"U\")return void o();u(e,void 0,n,o)}catch(e){r(t+X.eTlu)}}var g=\"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv\",v=\"fort\",p=\"erTo\",m=\"ken\",_=3;window.ftr__config={m:merchantConfig,s:\"24\",si:siteId};var y=!1,U=!1,T=v+p+m,x=400*24*60,A=10,S={write:function(t,e,r,o){void 0===o&&(o=!0);var i=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(i=window.ftr__config.m.ckDepth);var a,c,u=n(i);if(r?(a=new Date,a.setTime(a.getTime()+60*r*1e3),c=\"; expires=\"+a.toGMTString()):c=\"\",!o)return void(document.cookie=escape(t)+\"=\"+escape(e)+c+\"; path=\"+u);for(var f=1,s=document.domain.split(\".\"),d=A,h=!0;h&&s.length>=f&&d>0;){var l=s.slice(-f).join(\".\");document.cookie=escape(t)+\"=\"+escape(e)+c+\"; path=\"+u+\"; domain=\"+l;var w=S.read(t);null!=w&&w==e||(l=\".\"+l,document.cookie=escape(t)+\"=\"+escape(e)+c+\"; path=\"+u+\"; domain=\"+l),h=-1===document.cookie.indexOf(t+\"=\"+e),f++,d--}},read:function(t){var e=null;try{for(var n=escape(t)+\"=\",r=document.cookie.split(\";\"),o=32,i=0;i<r.length;i++){for(var a=r[i];a.charCodeAt(0)===o;)a=a.substring(1,a.length);0===a.indexOf(n)&&(e=unescape(a.substring(n.length,a.length)))}}finally{return e}}},D=window.ftr__config.s;D+=\"ck\";var L=function(t){var e=!1,n=null,r=function(){try{if(!n||!e)return;n.remove&&\"function\"==typeof n.remove?n.remove():document.head.removeChild(n),e=!1}catch(t){}};document.head&&(!function(){n=document.createElement(\"link\"),n.setAttribute(\"rel\",\"pre\"+\"con\"+\"nect\"),n.setAttribute(\"cros\"+\"sori\"+\"gin\",\"anonymous\"),n.onload=r,n.onerror=r,n.setAttribute(\"href\",t),document.head.appendChild(n),e=!0}(),setTimeout(r,3e3))},E=e(g||\"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv\"),C=t(\"[0Uhtxhvw0LG\",-_),R=t(\"[0Fruuhodwlrq0LG\",-_),P=t(\"Li0Qrqh0Pdwfk\",-_),k=e(\"dss1vlwhshuirupdqfhwhvw1qhw\"),q=e(\"2241414142gqv0txhu|\"),F,b=\"fgq71iruwhu1frp\",M=e(\"(VQ(1\"+b+\"2vq2(VQ(2vfulsw1mv\"),V=e(\"(VQ(1\"+b+\"2vqV2(VQ(2vfulsw1mv\"),O;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(O=window.ftr__config.m.fpi+e(\"2vq2(VQ(2vfulsw1mv\"));var I=!1,N=10;window.ftr__startScriptLoad=1*new Date;var j=function(t){var e=\"ft\"+\"r:tok\"+\"enR\"+\"eady\";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+=\"_tt\";var n=document.createEvent(\"Event\");n.initEvent(e,!1,!1),n.detail=t,document.dispatchEvent(n)}catch(t){}},1e3)},B=function(t){var e=function(t){return t||\"\"},n=e(t.id)+\"_\"+e(t.ts)+\"_\"+e(t.td)+\"_\"+e(t.ex)+\"_\"+e(D),r=x;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),S.write(T,n,r,!0),j(n),window.ftr__gt=n},G=function(){var t=S.read(T)||\"\",e=t.split(\"_\"),n=function(t){return e[t]||void 0};return{id:n(0),ts:n(1),td:n(2),ex:n(3),vr:n(4)}},H=function(){for(var t={},e=\"fgu\",n=[],r=0;r<256;r++)n[r]=(r<16?\"0\":\"\")+r.toString(16);var o=function(t,e,r,o,i){var a=i?\"-\":\"\";return n[255&t]+n[t>>8&255]+n[t>>16&255]+n[t>>24&255]+a+n[255&e]+n[e>>8&255]+a+n[e>>16&15|64]+n[e>>24&255]+a+n[63&r|128]+n[r>>8&255]+a+n[r>>16&255]+n[r>>24&255]+n[255&o]+n[o>>8&255]+n[o>>16&255]+n[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},a=function(){var t=\"\",e=function(t,e){for(var n=\"\",r=t;r>0;--r)n+=e.charAt(1e3*Math.random()%e.length);return n};return t+=e(2,\"0123456789\"),t+=e(1,\"123456789\"),t+=e(8,\"0123456789\")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return e+a()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(e)&&t.length>=12},t}(),X={uDF:\"UDF\",dUAL:\"dUAL\",uAS:\"UAS\",uDS:\"UDS\",uDAD:\"UDAD\",uFP:\"UFP\",mLd:\"1\",eTlu:\"2\",eUoe:\"3\",uS:\"4\",uF:\"9\",tmos:[\"T5\",\"T10\",\"T15\",\"T30\",\"T60\"],tmosSecs:[5,10,15,30,60],bIR:\"43\",uB:\"u\",uBr:\"b\",cP:\"c\",nIL:\"i\",s:\"s\"};try{var Q=G();try{Q.id&&(H.isValidNumericalToken(Q.id)||H.isValidUUIDToken(Q.id)||H.isValidFGUToken(Q.id))?window.ftr__ncd=!1:(Q.id=H.safeGenerateNoDash(),window.ftr__ncd=!0),Q.ts=window.ftr__startScriptLoad,B(Q),window.ftr__snp_cwc=!!S.read(T),window.ftr__snp_cwc||(M=V);for(var $=\"for\"+\"ter\"+\".co\"+\"m\",z=\"ht\"+\"tps://c\"+\"dn9.\"+$,J=\"ht\"+\"tps://\"+Q.id+\"-\"+siteId+\".cd\"+\"n.\"+$,K=\"http\"+\"s://cd\"+\"n3.\"+$,W=[z,J,K],Y=0;Y<W.length;Y++)L(W[Y]);var Z=new Array(X.tmosSecs.length),tt=function(t){for(var e=0;e<X.tmosSecs.length;e++)Z[e]=setTimeout(r,1e3*X.tmosSecs[e],t+X.tmos[e])},et=function(){for(var t=0;t<X.tmosSecs.length;t++)clearTimeout(Z[t])};window.ftr__fdad=function(e,n){if(!y){y=!0;var r={};r[P]=d(window.ftr__config.s,siteId,window.ftr__config.m.csp),s(E,function(n){try{var r=n.getAllResponseHeaders().toLowerCase();if(r.indexOf(R.toLowerCase())>=0){var o=n.getResponseHeader(R);window.ftr__altd2=t(atob(o),-_-1)}if(r.indexOf(C.toLowerCase())<0)return;var i=n.getResponseHeader(C),a=t(atob(i),-_-1);if(a){var c=a.split(\":\");if(c&&2===c.length){for(var u=c[0],f=c[1],s=\"\",d=0,h=0;d<20;++d)s+=d%3>0&&h<12?siteId.charAt(h++):Q.id.charAt(d);var l=f.split(\",\");if(l.length>1){var w=l[0],g=l[1];F=u+\"/\"+w+\".\"+s+\".\"+g}}}e()}catch(t){}},function(t,e){n&&n(t,e)},r)}},window.ftr__radd=function(t,e){function n(e){try{var n=e.response,r=function(t){function e(t,o,i){try{if(i>=n)return{name:\"\",nextOffsetToProcess:o,error:\"Max pointer dereference depth exceeded\"};for(var a=[],c=o,u=t.getUint8(c),f=0;f<r;){if(f++,192==(192&u)){var s=(63&u)<<8|t.getUint8(c+1),d=e(t,s,i+1);if(d.error)return d;var h=d.name;return a.push(h),{name:a.join(\".\"),nextOffsetToProcess:c+2}}if(!(u>0)){if(0!==u)return{name:\"\",nextOffsetToProcess:c,error:\"Unexpected length at the end of name: \"+u.toString()};return{name:a.join(\".\"),nextOffsetToProcess:c+1}}for(var l=\"\",w=1;w<=u;w++)l+=String.fromCharCode(t.getUint8(c+w));a.push(l),c+=u+1,u=t.getUint8(c)}return{name:\"\",nextOffsetToProcess:c,error:\"Max iterations exceeded\"}}catch(t){return{name:\"\",nextOffsetToProcess:o,error:\"Unexpected error while parsing response: \"+t.toString()}}}for(var n=4,r=100,o=16,i=new DataView(t),a=i.getUint16(0),c=i.getUint16(2),u=i.getUint16(4),f=i.getUint16(6),s=i.getUint16(8),d=i.getUint16(10),h=12,l=[],w=0;w<u;w++){var g=e(i,h,0);if(g.error)throw new Error(g.error);if(h=g.nextOffsetToProcess,!Number.isInteger(h))throw new Error(\"invalid returned offset\");var v=g.name,p=i.getUint16(h);h+=2;var m=i.getUint16(h);h+=2,l.push({qname:v,qtype:p,qclass:m})}for(var _=[],w=0;w<f;w++){var g=e(i,h,0);if(g.error)throw new Error(g.error);if(h=g.nextOffsetToProcess,!Number.isInteger(h))throw new Error(\"invalid returned offset\");var y=g.name,U=i.getUint16(h);if(U!==o)throw new Error(\"Unexpected record type: \"+U.toString());h+=2;var T=i.getUint16(h);h+=2;var x=i.getUint32(h);h+=4;var A=i.getUint16(h);h+=2;for(var S=\"\",D=h,L=0;D<h+A&&L<r;){L++;var E=i.getUint8(D);D+=1;S+=(new TextDecoder).decode(t.slice(D,D+E)),D+=E}if(L>=r)throw new Error(\"Max iterations exceeded while reading TXT data\");h+=A,_.push({name:y,type:U,class:T,ttl:x,data:S})}return{transactionId:a,flags:c,questionCount:u,answerCount:f,authorityCount:s,additionalCount:d,questions:l,answers:_}}(n);if(!r)throw new Error(\"Error parsing DNS response\");if(!(\"answers\"in r))throw new Error(\"Unexpected response\");var o=r.answers;if(0===o.length)throw new Error(\"No answers found\");var i=o[0].data;if(i=i.replace(/^\"(.*)\"$/,\"$1\"),decodedVal=function(t){var e=40,n=32,r=126;try{for(var o=atob(t),i=\"\",a=0;a<o.length;a++)i+=function(t){var o=t.charCodeAt(0),i=o-e;return i<n&&(i=r-(n-i)+1),String.fromCharCode(i)}(o[a]);return atob(i)}catch(t){return}}(i),!decodedVal)throw new Error(\"failed to decode the value\");var a=function(t){var e=\"_\"+\"D\"+\"L\"+\"M\"+\"_\",n=t.split(e);if(!(n.length<2)){var r=n[0],o=n[1];if(!(r.split(\".\").length-1<1))return{jURL:r,eURL:o}}}(decodedVal);if(!a)throw new Error(\"failed to parse the value\");var c=a.jURL,u=a.eURL;F=function(t){for(var e=\"\",n=0,r=0;n<20;++n)e+=n%3>0&&r<12?siteId.charAt(r++):Q.id.charAt(n);return t.replace(\"/PRM1\",\"\").replace(\"/PRM2\",\"/main.\").replace(\"/PRM3\",e).replace(\"/PRM4\",\".js\")}(c),window.ftr__altd3=u,t()}catch(t){}}function r(t,n){e&&e(t,n)}if(!U){window.ftr__config.m.dr===\"N\"+\"D\"+\"R\"&&e(new Error(\"N\"+\"D\"+\"R\"),!1),q&&k||e(new Error(\"D\"+\"P\"+\"P\"),!1),U=!0;try{var o=function(t){for(var e=new Uint8Array([0,0]),n=new Uint8Array([1,0]),r=new Uint8Array([0,1]),o=new Uint8Array([0,0]),i=new Uint8Array([0,0]),a=new Uint8Array([0,0]),c=t.split(\".\"),u=[],f=0;f<c.length;f++){var s=c[f];u.push(s.length);for(var d=0;d<s.length;d++)u.push(s.charCodeAt(d))}u.push(0);var h=16,l=new Uint8Array([0,h]),w=new Uint8Array([0,1]),g=new Uint8Array(e.length+n.length+r.length+o.length+i.length+a.length+u.length+l.length+w.length);return g.set(e,0),g.set(n,e.length),g.set(r,e.length+n.length),g.set(o,e.length+n.length+r.length),g.set(i,e.length+n.length+r.length+o.length),g.set(a,e.length+n.length+r.length+o.length+i.length),g.set(u,e.length+n.length+r.length+o.length+i.length+a.length),g.set(l,e.length+n.length+r.length+o.length+i.length+a.length+u.length),g.set(w,e.length+n.length+r.length+o.length+i.length+a.length+u.length+l.length),g}(k);!function(t,e,n,r,o){var i=!1,a=new XMLHttpRequest;if(c(\"https:\"+t,function(){o(new Error(\"CSP Violation\"),!0),i=!0}),\"//\"===t.slice(0,2)&&(t=\"https:\"+t),\"withCredentials\"in a)a.open(\"POST\",t,!0);else{if(\"undefined\"==typeof XDomainRequest)return;a=new XDomainRequest,a.open(\"POST\",t)}a.responseType=\"arraybuffer\",a.setRequestHeader(\"Content-Type\",e),a.onload=function(){\"function\"==typeof r&&r(a)},a.onerror=function(t){if(\"function\"==typeof o&&!i)try{o(t,!1),i=!0}catch(t){}},a.onprogress=function(){},a.ontimeout=function(){\"function\"==typeof o&&o(\"tim\"+\"eo\"+\"ut\",!1)},setTimeout(function(){a.send(n)},0)}(q,\"application/dns-message\",o,n,r)}catch(t){e(t,!1)}}};var nt=O?X.uFP:X.uDF;tt(nt),setTimeout(w,N,nt)}catch(t){r(X.mLd)}}catch(t){}}\n)();\n";
|
|
9330
|
+
|
|
9331
|
+
var FORTER_SDK_EVENTS = {
|
|
9332
|
+
TOKEN_READY: 'ftr:tokenReady'
|
|
9333
|
+
};
|
|
9334
|
+
/**
|
|
9335
|
+
* A class that manages Forter's device fingerprinting integration.
|
|
9336
|
+
* It handles script injection and token management.
|
|
9337
|
+
*
|
|
9338
|
+
* @example
|
|
9339
|
+
*
|
|
9340
|
+
* ```js
|
|
9341
|
+
* const agent = new ForterDeviceAgent({
|
|
9342
|
+
* siteId: 'your-site-id',
|
|
9343
|
+
* csp: false,
|
|
9344
|
+
* mode: 'test'
|
|
9345
|
+
* }).init();
|
|
9346
|
+
*
|
|
9347
|
+
* // Later, access the token
|
|
9348
|
+
* const token = agent.token;
|
|
9349
|
+
* ```
|
|
9350
|
+
*/
|
|
9351
|
+
var ForterDeviceAgent = /*#__PURE__*/function () {
|
|
9352
|
+
/**
|
|
9353
|
+
* Creates a new instance of ForterDeviceAgent
|
|
9354
|
+
*
|
|
9355
|
+
* @param {ForterDeviceAgentConfig} config - Configuration object for Forter integration
|
|
9356
|
+
*/
|
|
9357
|
+
function ForterDeviceAgent(config) {
|
|
9358
|
+
_classCallCheck(this, ForterDeviceAgent);
|
|
9359
|
+
this.cookieToken = null;
|
|
9360
|
+
this.validateCsp(config.csp);
|
|
9361
|
+
this.validateMode(config.mode);
|
|
9362
|
+
this.validateSiteId(config.siteId);
|
|
9363
|
+
this.config = config;
|
|
9364
|
+
}
|
|
9365
|
+
/**
|
|
9366
|
+
* Returns the current Forter token if available
|
|
9367
|
+
*
|
|
9368
|
+
* @returns {string | null} The Forter token or null if not yet available
|
|
9369
|
+
*
|
|
9370
|
+
* @example
|
|
9371
|
+
*
|
|
9372
|
+
* ```js
|
|
9373
|
+
* const token = forterAgent.token;
|
|
9374
|
+
* if (token) {
|
|
9375
|
+
* // Use the token
|
|
9376
|
+
* }
|
|
9377
|
+
* ```
|
|
9378
|
+
*/
|
|
9379
|
+
return _createClass(ForterDeviceAgent, [{
|
|
9380
|
+
key: "token",
|
|
9381
|
+
get: function get() {
|
|
9382
|
+
return this.cookieToken;
|
|
9383
|
+
}
|
|
9384
|
+
/**
|
|
9385
|
+
* Initializes the Forter Device Agent by injecting the required script
|
|
9386
|
+
* and setting up event listeners.
|
|
9387
|
+
*
|
|
9388
|
+
* @returns {ForterDeviceAgent} The current instance for method chaining
|
|
9389
|
+
*
|
|
9390
|
+
* @example
|
|
9391
|
+
*
|
|
9392
|
+
* ```js
|
|
9393
|
+
* const agent = new ForterDeviceAgent(config).init();
|
|
9394
|
+
* ```
|
|
9395
|
+
*/
|
|
9396
|
+
}, {
|
|
9397
|
+
key: "init",
|
|
9398
|
+
value: function init() {
|
|
9399
|
+
this.subscribeSdkEvents();
|
|
9400
|
+
this.injectScript();
|
|
9401
|
+
return this;
|
|
9402
|
+
}
|
|
9403
|
+
}, {
|
|
9404
|
+
key: "emit",
|
|
9405
|
+
value: function emit(detail) {
|
|
9406
|
+
var evt = new CustomEvent(FRAUD_PREVENTION_EVENTS.NAMESPACE, {
|
|
9407
|
+
detail: detail
|
|
9408
|
+
});
|
|
9409
|
+
document.dispatchEvent(evt);
|
|
9410
|
+
}
|
|
9411
|
+
}, {
|
|
9412
|
+
key: "emitFingerprintTokenWrongTypeError",
|
|
9413
|
+
value: function emitFingerprintTokenWrongTypeError() {
|
|
9414
|
+
this.emit({
|
|
9415
|
+
type: FRAUD_PREVENTION_EVENTS.TYPES.FINGERPRINT_TOKEN_ERROR,
|
|
9416
|
+
provider: FRAUD_PREVENTION_EVENTS.PROVIDERS.FORTER,
|
|
9417
|
+
payload: {
|
|
9418
|
+
code: 'unexpected_token_type',
|
|
9419
|
+
message: 'Forter JavaScript SDK created a fingerprint token but it was not of the expected string type. Please contact our support team if the issue persists.'
|
|
9420
|
+
}
|
|
9421
|
+
});
|
|
9422
|
+
}
|
|
9423
|
+
}, {
|
|
9424
|
+
key: "emitFingerprintTokenReady",
|
|
9425
|
+
value: function emitFingerprintTokenReady() {
|
|
9426
|
+
this.emit({
|
|
9427
|
+
type: FRAUD_PREVENTION_EVENTS.TYPES.FINTERPRINT_TOKEN_READY,
|
|
9428
|
+
provider: FRAUD_PREVENTION_EVENTS.PROVIDERS.FORTER,
|
|
9429
|
+
payload: {
|
|
9430
|
+
token: this.cookieToken
|
|
9431
|
+
}
|
|
9432
|
+
});
|
|
9433
|
+
}
|
|
9434
|
+
}, {
|
|
9435
|
+
key: "getScriptContent",
|
|
9436
|
+
value: function getScriptContent() {
|
|
9437
|
+
var template = FORTER_SDK_SCRIPT_TEMPLATE.replace('%CSP%', String(this.config.csp)).replace('%SITE_ID%', this.config.siteId);
|
|
9438
|
+
return template;
|
|
9439
|
+
}
|
|
9440
|
+
}, {
|
|
9441
|
+
key: "injectScript",
|
|
9442
|
+
value: function injectScript() {
|
|
9443
|
+
var script = document.createElement('script');
|
|
9444
|
+
script.type = 'text/javascript';
|
|
9445
|
+
script.id = this.config.siteId;
|
|
9446
|
+
script.textContent = this.getScriptContent();
|
|
9447
|
+
document.body.appendChild(script);
|
|
9448
|
+
}
|
|
9449
|
+
}, {
|
|
9450
|
+
key: "subscribeSdkEvents",
|
|
9451
|
+
value: function subscribeSdkEvents() {
|
|
9452
|
+
var _this = this;
|
|
9453
|
+
document.addEventListener(FORTER_SDK_EVENTS.TOKEN_READY, function (evt) {
|
|
9454
|
+
if (typeof evt.detail === 'string') {
|
|
9455
|
+
_this.cookieToken = evt.detail;
|
|
9456
|
+
_this.emitFingerprintTokenReady();
|
|
9457
|
+
} else {
|
|
9458
|
+
_this.emitFingerprintTokenWrongTypeError();
|
|
9459
|
+
}
|
|
9460
|
+
});
|
|
9461
|
+
}
|
|
9462
|
+
}, {
|
|
9463
|
+
key: "validateCsp",
|
|
9464
|
+
value: function validateCsp(csp) {
|
|
9465
|
+
if (typeof csp !== 'undefined' && typeof csp !== 'boolean') {
|
|
9466
|
+
throw new TypeError("ForterDeviceAgent config 'csp' is optional, when set it must be of type boolean.");
|
|
9467
|
+
}
|
|
9468
|
+
}
|
|
9469
|
+
}, {
|
|
9470
|
+
key: "validateMode",
|
|
9471
|
+
value: function validateMode(mode) {
|
|
9472
|
+
if (!isValidMode(mode)) {
|
|
9473
|
+
throw new TypeError("ForterDeviceAgent: forter integration can not be initiated with the provided mode '".concat(mode, "'"));
|
|
9474
|
+
}
|
|
9475
|
+
}
|
|
9476
|
+
}, {
|
|
9477
|
+
key: "validateSiteId",
|
|
9478
|
+
value: function validateSiteId(siteId) {
|
|
9479
|
+
if (typeof siteId !== 'string') {
|
|
9480
|
+
throw new TypeError("ForterDeviceAgent config 'siteId' is required and must be of type string.");
|
|
9481
|
+
}
|
|
9482
|
+
}
|
|
9483
|
+
}]);
|
|
9484
|
+
}();
|
|
9485
|
+
|
|
9486
|
+
// TODO @ingeniousraccoons add more credentials types as more providers are supported
|
|
9487
|
+
// type SomeOtherProviderCredentials = {
|
|
9488
|
+
// provider: typeof providers.someOther;
|
|
9489
|
+
// someField: string;
|
|
9490
|
+
// };
|
|
9491
|
+
function findServiceConfig(httpFetcher, provider, providerId) {
|
|
9492
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
9493
|
+
var _yield$httpFetcher$ex, _yield$httpFetcher$ex2, response, error;
|
|
9494
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9495
|
+
while (1) switch (_context.prev = _context.next) {
|
|
9496
|
+
case 0:
|
|
9497
|
+
_context.next = 2;
|
|
9498
|
+
return httpFetcher.execute('GET', "/v1/services/".concat(providerId, "/config"));
|
|
9499
|
+
case 2:
|
|
9500
|
+
_yield$httpFetcher$ex = _context.sent;
|
|
9501
|
+
_yield$httpFetcher$ex2 = _slicedToArray(_yield$httpFetcher$ex, 2);
|
|
9502
|
+
response = _yield$httpFetcher$ex2[0];
|
|
9503
|
+
error = _yield$httpFetcher$ex2[1];
|
|
9504
|
+
if (!error) {
|
|
9505
|
+
_context.next = 8;
|
|
9506
|
+
break;
|
|
9507
|
+
}
|
|
9508
|
+
return _context.abrupt("return", [null, error.body.error]);
|
|
9509
|
+
case 8:
|
|
9510
|
+
_context.t0 = provider;
|
|
9511
|
+
_context.next = _context.t0 === PROVIDERS.FORTER ? 11 : 12;
|
|
9512
|
+
break;
|
|
9513
|
+
case 11:
|
|
9514
|
+
return _context.abrupt("return", [{
|
|
9515
|
+
provider: PROVIDERS.FORTER,
|
|
9516
|
+
siteId: response.body.resource.data.username,
|
|
9517
|
+
subsiteId: response.body.resource.data.merchant
|
|
9518
|
+
}, null]);
|
|
9519
|
+
case 12:
|
|
9520
|
+
throw new Error("findServiceConfig does not support provider ".concat(provider, "."));
|
|
9521
|
+
case 13:
|
|
9522
|
+
case "end":
|
|
9523
|
+
return _context.stop();
|
|
9524
|
+
}
|
|
9525
|
+
}, _callee);
|
|
9526
|
+
}));
|
|
9527
|
+
}
|
|
9528
|
+
|
|
9529
|
+
/**
|
|
9530
|
+
* A class to manage integration fraud prevention integrations.
|
|
9531
|
+
*
|
|
9532
|
+
* @example
|
|
9533
|
+
*
|
|
9534
|
+
* ```js
|
|
9535
|
+
* const fps = new FraudPreventionService({
|
|
9536
|
+
* environmentId: 'production',
|
|
9537
|
+
* mode: 'live',
|
|
9538
|
+
* });
|
|
9539
|
+
* ```
|
|
9540
|
+
*/
|
|
9541
|
+
var FraudPreventionService = /*#__PURE__*/function () {
|
|
9542
|
+
/**
|
|
9543
|
+
* @constructs
|
|
9544
|
+
*
|
|
9545
|
+
* @param {Object} config - FraudPreventionService configuration object
|
|
9546
|
+
* @param {string} config.mode - Environment mode, must be either 'test' or 'live'
|
|
9547
|
+
* @param {string} config.environmentId - Environment identifier
|
|
9548
|
+
* @param {string} [config.environmentAlias] - Optional environment alias for API requests
|
|
9549
|
+
*/
|
|
9550
|
+
function FraudPreventionService(config) {
|
|
9551
|
+
var _this = this;
|
|
9552
|
+
_classCallCheck(this, FraudPreventionService);
|
|
9553
|
+
this.authorizationStrategy = new AnonymousStrategy();
|
|
9554
|
+
this.forterDeviceAgent = null;
|
|
9555
|
+
this.validateEnvironmentId(config.environmentId);
|
|
9556
|
+
this.validateEnvironmentAlias(config.environmentAlias);
|
|
9557
|
+
this.environment = new Env(API_URL);
|
|
9558
|
+
this.environment.setEnv(config.environmentId, config.environmentAlias);
|
|
9559
|
+
this.validateMode(config.mode);
|
|
9560
|
+
this.mode = config.mode;
|
|
9561
|
+
/**
|
|
9562
|
+
* Use lazy authorizationStrategy as some functionalities can work without Paydock
|
|
9563
|
+
* configurations. E.g., forter device agent can initialized using just a `siteId`.
|
|
9564
|
+
*/
|
|
9565
|
+
this.httpFetcherFactory = new HttpFetcherFactory({
|
|
9566
|
+
authorizationStrategy: function authorizationStrategy() {
|
|
9567
|
+
return _this.authorizationStrategy;
|
|
9568
|
+
},
|
|
9569
|
+
environment: this.environment
|
|
9570
|
+
});
|
|
9571
|
+
}
|
|
9572
|
+
/**
|
|
9573
|
+
* Automatically detects and sets the authorization strategy the service should use
|
|
9574
|
+
* based on the shape of the provided string.
|
|
9575
|
+
*
|
|
9576
|
+
* If the value is a JWT token, it will use an access token strategy, otherwise it will use
|
|
9577
|
+
* a public key strategy.
|
|
9578
|
+
*
|
|
9579
|
+
* @param value - The authorization value (either JWT token or public key)
|
|
9580
|
+
*
|
|
9581
|
+
* @returns The FraudPreventionService instance for method chaining
|
|
9582
|
+
*
|
|
9583
|
+
* @example
|
|
9584
|
+
* ```ts
|
|
9585
|
+
* // With JWT token
|
|
9586
|
+
* fps.withAuthorization('eyJhbGciOiJIUzI1NiIs...');
|
|
9587
|
+
*
|
|
9588
|
+
* // With public key
|
|
9589
|
+
* fps.withAuthorization('pk_example_...');
|
|
9590
|
+
* ```
|
|
9591
|
+
*/
|
|
9592
|
+
return _createClass(FraudPreventionService, [{
|
|
9593
|
+
key: "withAuthorization",
|
|
9594
|
+
value: function withAuthorization(value) {
|
|
9595
|
+
if (AccessToken.isJwt(value)) {
|
|
9596
|
+
return this.withAccessTokenStrategy(value);
|
|
9597
|
+
}
|
|
9598
|
+
return this.withPublicKeyStrategy(value);
|
|
9599
|
+
}
|
|
9600
|
+
/**
|
|
9601
|
+
* Sets the authorization strategy to use access token authentication.
|
|
9602
|
+
*
|
|
9603
|
+
* @param accessToken - The JWT access token
|
|
9604
|
+
* @returns The FraudPreventionService instance for method chaining
|
|
9605
|
+
*
|
|
9606
|
+
* @example
|
|
9607
|
+
*
|
|
9608
|
+
* ```ts
|
|
9609
|
+
* fps.withAccessTokenStrategy('eyJhbGciOiJIUzI1NiIs...');
|
|
9610
|
+
* ```
|
|
9611
|
+
*/
|
|
9612
|
+
}, {
|
|
9613
|
+
key: "withAccessTokenStrategy",
|
|
9614
|
+
value: function withAccessTokenStrategy(accessToken) {
|
|
9615
|
+
this.authorizationStrategy = new AccessTokenStrategy(accessToken);
|
|
9616
|
+
return this;
|
|
9617
|
+
}
|
|
9618
|
+
/**
|
|
9619
|
+
* Sets the authorization strategy to use public key authentication.
|
|
9620
|
+
*
|
|
9621
|
+
* @param publicKey - The public key
|
|
9622
|
+
* @returns The FraudPreventionService instance for method chaining
|
|
9623
|
+
*
|
|
9624
|
+
* @example
|
|
9625
|
+
*
|
|
9626
|
+
* ```ts
|
|
9627
|
+
* fps.withPublicKeyStrategy('pk_example_...');
|
|
9628
|
+
* ```
|
|
9629
|
+
*/
|
|
9630
|
+
}, {
|
|
9631
|
+
key: "withPublicKeyStrategy",
|
|
9632
|
+
value: function withPublicKeyStrategy(publicKey) {
|
|
9633
|
+
this.authorizationStrategy = new PublicKeyStrategy(publicKey);
|
|
9634
|
+
return this;
|
|
9635
|
+
}
|
|
9636
|
+
/**
|
|
9637
|
+
* Initializes Forter integration with the provided configuration. This method injects
|
|
9638
|
+
* Forter's JavaScript snippet into the page and starts tracking user behavior.
|
|
9639
|
+
*
|
|
9640
|
+
* @param {Object} config - Configuration object for Forter integration
|
|
9641
|
+
* @param {string} [config.siteId] - Your Forter site ID or subsite merchant ID
|
|
9642
|
+
* @param {string} [config.providerId] - Your Paydock integrated Forter Service ID.
|
|
9643
|
+
* @param {boolean} [config.csp] - Set to true if your site uses Content-Security-Policies
|
|
9644
|
+
*
|
|
9645
|
+
* @throws If neither siteId nor providerId are provided in the configuration
|
|
9646
|
+
* @throws If providerId fails to resolve to a siteId through Paydock integration services
|
|
9647
|
+
*
|
|
9648
|
+
* @returns Promise with existing FraudPreventionService instance
|
|
9649
|
+
*
|
|
9650
|
+
* @example
|
|
9651
|
+
*
|
|
9652
|
+
* ```js
|
|
9653
|
+
* await fps.withForter({
|
|
9654
|
+
* providerId: 'your-paydock-forter-service-id'
|
|
9655
|
+
* });
|
|
9656
|
+
* ```
|
|
9657
|
+
*
|
|
9658
|
+
* @example
|
|
9659
|
+
*
|
|
9660
|
+
* ```js
|
|
9661
|
+
* await fps.withForter({
|
|
9662
|
+
* siteId: 'your-forter-site-id',
|
|
9663
|
+
* });
|
|
9664
|
+
* ```
|
|
9665
|
+
*/
|
|
9666
|
+
}, {
|
|
9667
|
+
key: "withForter",
|
|
9668
|
+
value: function withForter(config) {
|
|
9669
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
9670
|
+
var _this2 = this;
|
|
9671
|
+
var useForterDeviceAgent, usingOwnCredentials, usingIntegratedCredentials, _yield$this$getProvid, _yield$this$getProvid2, credentials, error;
|
|
9672
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
9673
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
9674
|
+
case 0:
|
|
9675
|
+
useForterDeviceAgent = function useForterDeviceAgent(siteId, subsiteId) {
|
|
9676
|
+
return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
9677
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9678
|
+
while (1) switch (_context.prev = _context.next) {
|
|
9679
|
+
case 0:
|
|
9680
|
+
this.forterDeviceAgent = new ForterDeviceAgent({
|
|
9681
|
+
csp: config.csp,
|
|
9682
|
+
mode: this.mode,
|
|
9683
|
+
siteId: siteId !== null && siteId !== void 0 ? siteId : subsiteId
|
|
9684
|
+
}).init();
|
|
9685
|
+
return _context.abrupt("return", Promise.resolve(this));
|
|
9686
|
+
case 2:
|
|
9687
|
+
case "end":
|
|
9688
|
+
return _context.stop();
|
|
9689
|
+
}
|
|
9690
|
+
}, _callee, this);
|
|
9691
|
+
}));
|
|
9692
|
+
};
|
|
9693
|
+
usingOwnCredentials = 'siteId' in config && typeof config.siteId === 'string';
|
|
9694
|
+
if (!usingOwnCredentials) {
|
|
9695
|
+
_context2.next = 4;
|
|
9696
|
+
break;
|
|
9697
|
+
}
|
|
9698
|
+
return _context2.abrupt("return", useForterDeviceAgent(config.siteId, undefined));
|
|
9699
|
+
case 4:
|
|
9700
|
+
usingIntegratedCredentials = 'providerId' in config && typeof config.providerId === 'string';
|
|
9701
|
+
if (!(usingIntegratedCredentials && this.authorizationStrategy)) {
|
|
9702
|
+
_context2.next = 15;
|
|
9703
|
+
break;
|
|
9704
|
+
}
|
|
9705
|
+
_context2.next = 8;
|
|
9706
|
+
return this.getProviderCredentials(PROVIDERS.FORTER, config.providerId);
|
|
9707
|
+
case 8:
|
|
9708
|
+
_yield$this$getProvid = _context2.sent;
|
|
9709
|
+
_yield$this$getProvid2 = _slicedToArray(_yield$this$getProvid, 2);
|
|
9710
|
+
credentials = _yield$this$getProvid2[0];
|
|
9711
|
+
error = _yield$this$getProvid2[1];
|
|
9712
|
+
if (!error) {
|
|
9713
|
+
_context2.next = 14;
|
|
9714
|
+
break;
|
|
9715
|
+
}
|
|
9716
|
+
throw new Error("FraudPreventionService could not obtain forter integration credentials from providerId '".concat(config.providerId, "'. Cause: ").concat(error instanceof Error ? error.message : JSON.stringify(error), ";"));
|
|
9717
|
+
case 14:
|
|
9718
|
+
return _context2.abrupt("return", useForterDeviceAgent(credentials.siteId, credentials.subsiteId));
|
|
9719
|
+
case 15:
|
|
9720
|
+
throw new TypeError("FraudPreventionService withForter expects either config 'siteId' or config 'providerId' to be of type string.");
|
|
9721
|
+
case 16:
|
|
9722
|
+
case "end":
|
|
9723
|
+
return _context2.stop();
|
|
9724
|
+
}
|
|
9725
|
+
}, _callee2, this);
|
|
9726
|
+
}));
|
|
9727
|
+
}
|
|
9728
|
+
/**
|
|
9729
|
+
* Returns the initialized Forter device agent instance if available.
|
|
9730
|
+
*
|
|
9731
|
+
* Make sure to call withForter() before accessing this getter.
|
|
9732
|
+
*
|
|
9733
|
+
* @returns {ForterDeviceAgent | null} The Forter device agent instance or null if not initialized
|
|
9734
|
+
*
|
|
9735
|
+
* @example
|
|
9736
|
+
*
|
|
9737
|
+
* ```js
|
|
9738
|
+
* const fps = new FraudPreventionService();
|
|
9739
|
+
*
|
|
9740
|
+
* fps.withForter({
|
|
9741
|
+
* siteId: 'your-site-id',
|
|
9742
|
+
* mode: 'test'
|
|
9743
|
+
* });
|
|
9744
|
+
*
|
|
9745
|
+
* const token = fps.forter?.token;
|
|
9746
|
+
* ```
|
|
9747
|
+
*/
|
|
9748
|
+
}, {
|
|
9749
|
+
key: "forter",
|
|
9750
|
+
get: function get() {
|
|
9751
|
+
return this.forterDeviceAgent;
|
|
9752
|
+
}
|
|
9753
|
+
/**
|
|
9754
|
+
* Gets the credentials for a specific fraud prevention provider.
|
|
9755
|
+
*
|
|
9756
|
+
* Returns different credential types based on the selected provider.
|
|
9757
|
+
*
|
|
9758
|
+
* @param provider - The fraud prevention provider
|
|
9759
|
+
* @param providerId - The ID of the provider instance
|
|
9760
|
+
*
|
|
9761
|
+
* @returns a tuple with shape [providerSpecificCredentials, error]
|
|
9762
|
+
*/
|
|
9763
|
+
}, {
|
|
9764
|
+
key: "getProviderCredentials",
|
|
9765
|
+
value: function getProviderCredentials(provider, providerId) {
|
|
9766
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
9767
|
+
var fetcher;
|
|
9768
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
9769
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
9770
|
+
case 0:
|
|
9771
|
+
fetcher = this.httpFetcherFactory.createFetcher();
|
|
9772
|
+
return _context3.abrupt("return", findServiceConfig(fetcher, provider, providerId));
|
|
9773
|
+
case 2:
|
|
9774
|
+
case "end":
|
|
9775
|
+
return _context3.stop();
|
|
9776
|
+
}
|
|
9777
|
+
}, _callee3, this);
|
|
9778
|
+
}));
|
|
9779
|
+
}
|
|
9780
|
+
}, {
|
|
9781
|
+
key: "validateEnvironmentId",
|
|
9782
|
+
value: function validateEnvironmentId(environmentId) {
|
|
9783
|
+
if (typeof environmentId !== 'string') {
|
|
9784
|
+
throw new TypeError("FraudPreventionService expects config 'environmentId' to be of type string.");
|
|
9785
|
+
}
|
|
9786
|
+
}
|
|
9787
|
+
}, {
|
|
9788
|
+
key: "validateEnvironmentAlias",
|
|
9789
|
+
value: function validateEnvironmentAlias(environmentAlias) {
|
|
9790
|
+
if (environmentAlias && typeof environmentAlias !== 'string') {
|
|
9791
|
+
throw new TypeError("FraudPreventionService expects config 'domain' to be of type string when it is provided.");
|
|
9792
|
+
}
|
|
9793
|
+
}
|
|
9794
|
+
}, {
|
|
9795
|
+
key: "validateMode",
|
|
9796
|
+
value: function validateMode(mode) {
|
|
9797
|
+
if (!isValidMode(mode)) {
|
|
9798
|
+
throw new TypeError("FraudPreventionService expects config 'mode' to be of type string and one of ".concat(MODES.join(','), "."));
|
|
9799
|
+
}
|
|
9800
|
+
}
|
|
9801
|
+
}]);
|
|
9802
|
+
}();
|
|
9803
|
+
|
|
8946
9804
|
var ObjectHelper = /*#__PURE__*/function () {
|
|
8947
9805
|
function ObjectHelper() {
|
|
8948
9806
|
_classCallCheck(this, ObjectHelper);
|
|
@@ -10136,1580 +10994,1355 @@ var AfterPayWalletService = /*#__PURE__*/function (_WalletService) {
|
|
|
10136
10994
|
}]);
|
|
10137
10995
|
}(WalletService);
|
|
10138
10996
|
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
var
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
|
|
10200
|
-
|
|
10201
|
-
|
|
10202
|
-
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
|
|
10206
|
-
|
|
10207
|
-
|
|
10208
|
-
|
|
10209
|
-
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
10223
|
-
|
|
10224
|
-
|
|
10225
|
-
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
10316
|
-
|
|
10317
|
-
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
|
|
10399
|
-
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10413
|
-
|
|
10414
|
-
|
|
10415
|
-
|
|
10416
|
-
|
|
10417
|
-
|
|
10418
|
-
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
|
|
10431
|
-
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10480
|
-
|
|
10481
|
-
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10542
|
-
|
|
10543
|
-
|
|
10544
|
-
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10549
|
-
|
|
10550
|
-
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
|
|
10703
|
-
|
|
10704
|
-
|
|
10705
|
-
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10721
|
-
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
|
|
10742
|
-
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
|
|
10986
|
-
|
|
10987
|
-
|
|
10988
|
-
|
|
10989
|
-
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
|
|
10998
|
-
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
-
|
|
11003
|
-
|
|
11004
|
-
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11041
|
-
|
|
11042
|
-
|
|
11043
|
-
|
|
11044
|
-
|
|
11045
|
-
|
|
11046
|
-
|
|
11047
|
-
|
|
11048
|
-
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
|
|
11064
|
-
|
|
11065
|
-
|
|
11066
|
-
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
|
|
11070
|
-
|
|
11071
|
-
|
|
11072
|
-
|
|
11073
|
-
|
|
11074
|
-
|
|
11075
|
-
|
|
11076
|
-
|
|
11077
|
-
|
|
11078
|
-
|
|
11079
|
-
|
|
11080
|
-
|
|
11081
|
-
|
|
11082
|
-
|
|
11083
|
-
|
|
11084
|
-
|
|
11085
|
-
|
|
11086
|
-
|
|
11087
|
-
|
|
11088
|
-
|
|
11089
|
-
|
|
11090
|
-
|
|
11091
|
-
|
|
11092
|
-
|
|
11093
|
-
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
|
|
11112
|
-
|
|
11113
|
-
|
|
11114
|
-
|
|
11115
|
-
|
|
11116
|
-
|
|
11117
|
-
|
|
11118
|
-
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
-
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11135
|
-
|
|
11136
|
-
|
|
11137
|
-
|
|
11138
|
-
|
|
11139
|
-
|
|
11140
|
-
|
|
11141
|
-
|
|
11142
|
-
|
|
11143
|
-
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
|
|
11153
|
-
|
|
11154
|
-
|
|
11155
|
-
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11196
|
-
|
|
11197
|
-
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
|
|
11360
|
-
|
|
11361
|
-
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
|
|
11380
|
-
|
|
11381
|
-
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
|
|
11391
|
-
|
|
11392
|
-
|
|
11393
|
-
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
|
|
11399
|
-
|
|
11400
|
-
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
11434
|
-
|
|
11435
|
-
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
return dirty;
|
|
11489
|
-
}
|
|
11490
|
-
|
|
11491
|
-
/* Assign config vars */
|
|
11492
|
-
if (!SET_CONFIG) {
|
|
11493
|
-
_parseConfig(cfg);
|
|
11494
|
-
}
|
|
11495
|
-
|
|
11496
|
-
/* Clean up removed elements */
|
|
11497
|
-
DOMPurify.removed = [];
|
|
11498
|
-
|
|
11499
|
-
/* Check if dirty is correctly typed for IN_PLACE */
|
|
11500
|
-
if (typeof dirty === 'string') {
|
|
11501
|
-
IN_PLACE = false;
|
|
11502
|
-
}
|
|
11503
|
-
if (IN_PLACE) {
|
|
11504
|
-
/* Do some early pre-sanitization to avoid unsafe root nodes */
|
|
11505
|
-
if (dirty.nodeName) {
|
|
11506
|
-
const tagName = transformCaseFunc(dirty.nodeName);
|
|
11507
|
-
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
11508
|
-
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
|
11509
|
-
}
|
|
11510
|
-
}
|
|
11511
|
-
} else if (dirty instanceof Node) {
|
|
11512
|
-
/* If dirty is a DOM element, append to an empty document to avoid
|
|
11513
|
-
elements being stripped by the parser */
|
|
11514
|
-
body = _initDocument('<!---->');
|
|
11515
|
-
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
11516
|
-
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
|
|
11517
|
-
/* Node is already a body, use as is */
|
|
11518
|
-
body = importedNode;
|
|
11519
|
-
} else if (importedNode.nodeName === 'HTML') {
|
|
11520
|
-
body = importedNode;
|
|
11521
|
-
} else {
|
|
11522
|
-
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
11523
|
-
body.appendChild(importedNode);
|
|
11524
|
-
}
|
|
11525
|
-
} else {
|
|
11526
|
-
/* Exit directly if we have nothing to do */
|
|
11527
|
-
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
11528
|
-
// eslint-disable-next-line unicorn/prefer-includes
|
|
11529
|
-
dirty.indexOf('<') === -1) {
|
|
11530
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
11531
|
-
}
|
|
11532
|
-
|
|
11533
|
-
/* Initialize the document to work on */
|
|
11534
|
-
body = _initDocument(dirty);
|
|
11535
|
-
|
|
11536
|
-
/* Check we have a DOM node from the data */
|
|
11537
|
-
if (!body) {
|
|
11538
|
-
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
|
11539
|
-
}
|
|
11540
|
-
}
|
|
11541
|
-
|
|
11542
|
-
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
11543
|
-
if (body && FORCE_BODY) {
|
|
11544
|
-
_forceRemove(body.firstChild);
|
|
11545
|
-
}
|
|
11546
|
-
|
|
11547
|
-
/* Get node iterator */
|
|
11548
|
-
const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
|
|
11549
|
-
|
|
11550
|
-
/* Now start iterating over the created document */
|
|
11551
|
-
while (currentNode = nodeIterator.nextNode()) {
|
|
11552
|
-
/* Sanitize tags and elements */
|
|
11553
|
-
if (_sanitizeElements(currentNode)) {
|
|
11554
|
-
continue;
|
|
11555
|
-
}
|
|
11556
|
-
|
|
11557
|
-
/* Shadow DOM detected, sanitize it */
|
|
11558
|
-
if (currentNode.content instanceof DocumentFragment) {
|
|
11559
|
-
_sanitizeShadowDOM(currentNode.content);
|
|
11560
|
-
}
|
|
11561
|
-
|
|
11562
|
-
/* Check attributes, sanitize if necessary */
|
|
11563
|
-
_sanitizeAttributes(currentNode);
|
|
11564
|
-
}
|
|
11565
|
-
|
|
11566
|
-
/* If we sanitized `dirty` in-place, return it. */
|
|
11567
|
-
if (IN_PLACE) {
|
|
11568
|
-
return dirty;
|
|
11569
|
-
}
|
|
11570
|
-
|
|
11571
|
-
/* Return sanitized string or DOM */
|
|
11572
|
-
if (RETURN_DOM) {
|
|
11573
|
-
if (RETURN_DOM_FRAGMENT) {
|
|
11574
|
-
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
11575
|
-
while (body.firstChild) {
|
|
11576
|
-
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
11577
|
-
returnNode.appendChild(body.firstChild);
|
|
11578
|
-
}
|
|
11579
|
-
} else {
|
|
11580
|
-
returnNode = body;
|
|
11581
|
-
}
|
|
11582
|
-
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
|
|
11583
|
-
/*
|
|
11584
|
-
AdoptNode() is not used because internal state is not reset
|
|
11585
|
-
(e.g. the past names map of a HTMLFormElement), this is safe
|
|
11586
|
-
in theory but we would rather not risk another attack vector.
|
|
11587
|
-
The state that is cloned by importNode() is explicitly defined
|
|
11588
|
-
by the specs.
|
|
11589
|
-
*/
|
|
11590
|
-
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
11591
|
-
}
|
|
11592
|
-
return returnNode;
|
|
11593
|
-
}
|
|
11594
|
-
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
11595
|
-
|
|
11596
|
-
/* Serialize doctype if allowed */
|
|
11597
|
-
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
11598
|
-
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
|
11599
|
-
}
|
|
11600
|
-
|
|
11601
|
-
/* Sanitize final string template-safe */
|
|
11602
|
-
if (SAFE_FOR_TEMPLATES) {
|
|
11603
|
-
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
11604
|
-
serializedHTML = stringReplace(serializedHTML, expr, ' ');
|
|
11605
|
-
});
|
|
11606
|
-
}
|
|
11607
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
11608
|
-
};
|
|
11609
|
-
|
|
11610
|
-
/**
|
|
11611
|
-
* Public method to set the configuration once
|
|
11612
|
-
* setConfig
|
|
11613
|
-
*
|
|
11614
|
-
* @param {Object} cfg configuration object
|
|
11615
|
-
*/
|
|
11616
|
-
DOMPurify.setConfig = function () {
|
|
11617
|
-
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11618
|
-
_parseConfig(cfg);
|
|
11619
|
-
SET_CONFIG = true;
|
|
11620
|
-
};
|
|
11621
|
-
|
|
11622
|
-
/**
|
|
11623
|
-
* Public method to remove the configuration
|
|
11624
|
-
* clearConfig
|
|
11625
|
-
*
|
|
11626
|
-
*/
|
|
11627
|
-
DOMPurify.clearConfig = function () {
|
|
11628
|
-
CONFIG = null;
|
|
11629
|
-
SET_CONFIG = false;
|
|
11630
|
-
};
|
|
11631
|
-
|
|
11632
|
-
/**
|
|
11633
|
-
* Public method to check if an attribute value is valid.
|
|
11634
|
-
* Uses last set config, if any. Otherwise, uses config defaults.
|
|
11635
|
-
* isValidAttribute
|
|
11636
|
-
*
|
|
11637
|
-
* @param {String} tag Tag name of containing element.
|
|
11638
|
-
* @param {String} attr Attribute name.
|
|
11639
|
-
* @param {String} value Attribute value.
|
|
11640
|
-
* @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
|
|
11641
|
-
*/
|
|
11642
|
-
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
11643
|
-
/* Initialize shared config vars if necessary. */
|
|
11644
|
-
if (!CONFIG) {
|
|
11645
|
-
_parseConfig({});
|
|
11646
|
-
}
|
|
11647
|
-
const lcTag = transformCaseFunc(tag);
|
|
11648
|
-
const lcName = transformCaseFunc(attr);
|
|
11649
|
-
return _isValidAttribute(lcTag, lcName, value);
|
|
11650
|
-
};
|
|
11651
|
-
|
|
11652
|
-
/**
|
|
11653
|
-
* AddHook
|
|
11654
|
-
* Public method to add DOMPurify hooks
|
|
11655
|
-
*
|
|
11656
|
-
* @param {String} entryPoint entry point for the hook to add
|
|
11657
|
-
* @param {Function} hookFunction function to execute
|
|
11658
|
-
*/
|
|
11659
|
-
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
11660
|
-
if (typeof hookFunction !== 'function') {
|
|
11661
|
-
return;
|
|
11662
|
-
}
|
|
11663
|
-
hooks[entryPoint] = hooks[entryPoint] || [];
|
|
11664
|
-
arrayPush(hooks[entryPoint], hookFunction);
|
|
11665
|
-
};
|
|
11666
|
-
|
|
11667
|
-
/**
|
|
11668
|
-
* RemoveHook
|
|
11669
|
-
* Public method to remove a DOMPurify hook at a given entryPoint
|
|
11670
|
-
* (pops it from the stack of hooks if more are present)
|
|
11671
|
-
*
|
|
11672
|
-
* @param {String} entryPoint entry point for the hook to remove
|
|
11673
|
-
* @return {Function} removed(popped) hook
|
|
11674
|
-
*/
|
|
11675
|
-
DOMPurify.removeHook = function (entryPoint) {
|
|
11676
|
-
if (hooks[entryPoint]) {
|
|
11677
|
-
return arrayPop(hooks[entryPoint]);
|
|
11678
|
-
}
|
|
11679
|
-
};
|
|
11680
|
-
|
|
11681
|
-
/**
|
|
11682
|
-
* RemoveHooks
|
|
11683
|
-
* Public method to remove all DOMPurify hooks at a given entryPoint
|
|
11684
|
-
*
|
|
11685
|
-
* @param {String} entryPoint entry point for the hooks to remove
|
|
11686
|
-
*/
|
|
11687
|
-
DOMPurify.removeHooks = function (entryPoint) {
|
|
11688
|
-
if (hooks[entryPoint]) {
|
|
11689
|
-
hooks[entryPoint] = [];
|
|
11690
|
-
}
|
|
11691
|
-
};
|
|
11692
|
-
|
|
11693
|
-
/**
|
|
11694
|
-
* RemoveAllHooks
|
|
11695
|
-
* Public method to remove all DOMPurify hooks
|
|
11696
|
-
*/
|
|
11697
|
-
DOMPurify.removeAllHooks = function () {
|
|
11698
|
-
hooks = {};
|
|
11699
|
-
};
|
|
11700
|
-
return DOMPurify;
|
|
11701
|
-
}
|
|
11702
|
-
var purify = createDOMPurify();
|
|
11703
|
-
|
|
11704
|
-
return purify;
|
|
11705
|
-
|
|
11706
|
-
}));
|
|
11707
|
-
|
|
11708
|
-
} (purify));
|
|
11709
|
-
return purify.exports;
|
|
11710
|
-
}
|
|
11711
|
-
|
|
11712
|
-
window.DOMPurify || (window.DOMPurify = requirePurify().default || requirePurify());
|
|
10997
|
+
/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */
|
|
10998
|
+
|
|
10999
|
+
var purify_cjs;
|
|
11000
|
+
var hasRequiredPurify_cjs;
|
|
11001
|
+
|
|
11002
|
+
function requirePurify_cjs () {
|
|
11003
|
+
if (hasRequiredPurify_cjs) return purify_cjs;
|
|
11004
|
+
hasRequiredPurify_cjs = 1;
|
|
11005
|
+
|
|
11006
|
+
const {
|
|
11007
|
+
entries,
|
|
11008
|
+
setPrototypeOf,
|
|
11009
|
+
isFrozen,
|
|
11010
|
+
getPrototypeOf,
|
|
11011
|
+
getOwnPropertyDescriptor
|
|
11012
|
+
} = Object;
|
|
11013
|
+
let {
|
|
11014
|
+
freeze,
|
|
11015
|
+
seal,
|
|
11016
|
+
create
|
|
11017
|
+
} = Object; // eslint-disable-line import/no-mutable-exports
|
|
11018
|
+
let {
|
|
11019
|
+
apply,
|
|
11020
|
+
construct
|
|
11021
|
+
} = typeof Reflect !== 'undefined' && Reflect;
|
|
11022
|
+
if (!freeze) {
|
|
11023
|
+
freeze = function freeze(x) {
|
|
11024
|
+
return x;
|
|
11025
|
+
};
|
|
11026
|
+
}
|
|
11027
|
+
if (!seal) {
|
|
11028
|
+
seal = function seal(x) {
|
|
11029
|
+
return x;
|
|
11030
|
+
};
|
|
11031
|
+
}
|
|
11032
|
+
if (!apply) {
|
|
11033
|
+
apply = function apply(fun, thisValue, args) {
|
|
11034
|
+
return fun.apply(thisValue, args);
|
|
11035
|
+
};
|
|
11036
|
+
}
|
|
11037
|
+
if (!construct) {
|
|
11038
|
+
construct = function construct(Func, args) {
|
|
11039
|
+
return new Func(...args);
|
|
11040
|
+
};
|
|
11041
|
+
}
|
|
11042
|
+
const arrayForEach = unapply(Array.prototype.forEach);
|
|
11043
|
+
const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
11044
|
+
const arrayPop = unapply(Array.prototype.pop);
|
|
11045
|
+
const arrayPush = unapply(Array.prototype.push);
|
|
11046
|
+
const arraySplice = unapply(Array.prototype.splice);
|
|
11047
|
+
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
11048
|
+
const stringToString = unapply(String.prototype.toString);
|
|
11049
|
+
const stringMatch = unapply(String.prototype.match);
|
|
11050
|
+
const stringReplace = unapply(String.prototype.replace);
|
|
11051
|
+
const stringIndexOf = unapply(String.prototype.indexOf);
|
|
11052
|
+
const stringTrim = unapply(String.prototype.trim);
|
|
11053
|
+
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
11054
|
+
const regExpTest = unapply(RegExp.prototype.test);
|
|
11055
|
+
const typeErrorCreate = unconstruct(TypeError);
|
|
11056
|
+
/**
|
|
11057
|
+
* Creates a new function that calls the given function with a specified thisArg and arguments.
|
|
11058
|
+
*
|
|
11059
|
+
* @param func - The function to be wrapped and called.
|
|
11060
|
+
* @returns A new function that calls the given function with a specified thisArg and arguments.
|
|
11061
|
+
*/
|
|
11062
|
+
function unapply(func) {
|
|
11063
|
+
return function (thisArg) {
|
|
11064
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
11065
|
+
args[_key - 1] = arguments[_key];
|
|
11066
|
+
}
|
|
11067
|
+
return apply(func, thisArg, args);
|
|
11068
|
+
};
|
|
11069
|
+
}
|
|
11070
|
+
/**
|
|
11071
|
+
* Creates a new function that constructs an instance of the given constructor function with the provided arguments.
|
|
11072
|
+
*
|
|
11073
|
+
* @param func - The constructor function to be wrapped and called.
|
|
11074
|
+
* @returns A new function that constructs an instance of the given constructor function with the provided arguments.
|
|
11075
|
+
*/
|
|
11076
|
+
function unconstruct(func) {
|
|
11077
|
+
return function () {
|
|
11078
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
11079
|
+
args[_key2] = arguments[_key2];
|
|
11080
|
+
}
|
|
11081
|
+
return construct(func, args);
|
|
11082
|
+
};
|
|
11083
|
+
}
|
|
11084
|
+
/**
|
|
11085
|
+
* Add properties to a lookup table
|
|
11086
|
+
*
|
|
11087
|
+
* @param set - The set to which elements will be added.
|
|
11088
|
+
* @param array - The array containing elements to be added to the set.
|
|
11089
|
+
* @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
|
|
11090
|
+
* @returns The modified set with added elements.
|
|
11091
|
+
*/
|
|
11092
|
+
function addToSet(set, array) {
|
|
11093
|
+
let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
|
|
11094
|
+
if (setPrototypeOf) {
|
|
11095
|
+
// Make 'in' and truthy checks like Boolean(set.constructor)
|
|
11096
|
+
// independent of any properties defined on Object.prototype.
|
|
11097
|
+
// Prevent prototype setters from intercepting set as a this value.
|
|
11098
|
+
setPrototypeOf(set, null);
|
|
11099
|
+
}
|
|
11100
|
+
let l = array.length;
|
|
11101
|
+
while (l--) {
|
|
11102
|
+
let element = array[l];
|
|
11103
|
+
if (typeof element === 'string') {
|
|
11104
|
+
const lcElement = transformCaseFunc(element);
|
|
11105
|
+
if (lcElement !== element) {
|
|
11106
|
+
// Config presets (e.g. tags.js, attrs.js) are immutable.
|
|
11107
|
+
if (!isFrozen(array)) {
|
|
11108
|
+
array[l] = lcElement;
|
|
11109
|
+
}
|
|
11110
|
+
element = lcElement;
|
|
11111
|
+
}
|
|
11112
|
+
}
|
|
11113
|
+
set[element] = true;
|
|
11114
|
+
}
|
|
11115
|
+
return set;
|
|
11116
|
+
}
|
|
11117
|
+
/**
|
|
11118
|
+
* Clean up an array to harden against CSPP
|
|
11119
|
+
*
|
|
11120
|
+
* @param array - The array to be cleaned.
|
|
11121
|
+
* @returns The cleaned version of the array
|
|
11122
|
+
*/
|
|
11123
|
+
function cleanArray(array) {
|
|
11124
|
+
for (let index = 0; index < array.length; index++) {
|
|
11125
|
+
const isPropertyExist = objectHasOwnProperty(array, index);
|
|
11126
|
+
if (!isPropertyExist) {
|
|
11127
|
+
array[index] = null;
|
|
11128
|
+
}
|
|
11129
|
+
}
|
|
11130
|
+
return array;
|
|
11131
|
+
}
|
|
11132
|
+
/**
|
|
11133
|
+
* Shallow clone an object
|
|
11134
|
+
*
|
|
11135
|
+
* @param object - The object to be cloned.
|
|
11136
|
+
* @returns A new object that copies the original.
|
|
11137
|
+
*/
|
|
11138
|
+
function clone(object) {
|
|
11139
|
+
const newObject = create(null);
|
|
11140
|
+
for (const [property, value] of entries(object)) {
|
|
11141
|
+
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
11142
|
+
if (isPropertyExist) {
|
|
11143
|
+
if (Array.isArray(value)) {
|
|
11144
|
+
newObject[property] = cleanArray(value);
|
|
11145
|
+
} else if (value && typeof value === 'object' && value.constructor === Object) {
|
|
11146
|
+
newObject[property] = clone(value);
|
|
11147
|
+
} else {
|
|
11148
|
+
newObject[property] = value;
|
|
11149
|
+
}
|
|
11150
|
+
}
|
|
11151
|
+
}
|
|
11152
|
+
return newObject;
|
|
11153
|
+
}
|
|
11154
|
+
/**
|
|
11155
|
+
* This method automatically checks if the prop is function or getter and behaves accordingly.
|
|
11156
|
+
*
|
|
11157
|
+
* @param object - The object to look up the getter function in its prototype chain.
|
|
11158
|
+
* @param prop - The property name for which to find the getter function.
|
|
11159
|
+
* @returns The getter function found in the prototype chain or a fallback function.
|
|
11160
|
+
*/
|
|
11161
|
+
function lookupGetter(object, prop) {
|
|
11162
|
+
while (object !== null) {
|
|
11163
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
11164
|
+
if (desc) {
|
|
11165
|
+
if (desc.get) {
|
|
11166
|
+
return unapply(desc.get);
|
|
11167
|
+
}
|
|
11168
|
+
if (typeof desc.value === 'function') {
|
|
11169
|
+
return unapply(desc.value);
|
|
11170
|
+
}
|
|
11171
|
+
}
|
|
11172
|
+
object = getPrototypeOf(object);
|
|
11173
|
+
}
|
|
11174
|
+
function fallbackValue() {
|
|
11175
|
+
return null;
|
|
11176
|
+
}
|
|
11177
|
+
return fallbackValue;
|
|
11178
|
+
}
|
|
11179
|
+
|
|
11180
|
+
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']);
|
|
11181
|
+
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']);
|
|
11182
|
+
const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
|
|
11183
|
+
// List of SVG elements that are disallowed by default.
|
|
11184
|
+
// We still need to know them so that we can do namespace
|
|
11185
|
+
// checks properly in case one wants to add them to
|
|
11186
|
+
// allow-list.
|
|
11187
|
+
const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', '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']);
|
|
11188
|
+
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']);
|
|
11189
|
+
// Similarly to SVG, we want to know all MathML elements,
|
|
11190
|
+
// even those that we disallow by default.
|
|
11191
|
+
const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
11192
|
+
const text = freeze(['#text']);
|
|
11193
|
+
|
|
11194
|
+
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', 'popover', 'popovertarget', 'popovertargetaction', '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', 'wrap', 'xmlns', 'slot']);
|
|
11195
|
+
const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', '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', 'exponent', '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', 'intercept', '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', 'slope', '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', 'tablevalues', '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']);
|
|
11196
|
+
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']);
|
|
11197
|
+
const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
11198
|
+
|
|
11199
|
+
// eslint-disable-next-line unicorn/better-regex
|
|
11200
|
+
const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
|
11201
|
+
const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
|
11202
|
+
const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex
|
|
11203
|
+
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
|
|
11204
|
+
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
11205
|
+
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
|
|
11206
|
+
);
|
|
11207
|
+
const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
11208
|
+
const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
|
|
11209
|
+
);
|
|
11210
|
+
const DOCTYPE_NAME = seal(/^html$/i);
|
|
11211
|
+
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
11212
|
+
|
|
11213
|
+
var EXPRESSIONS = /*#__PURE__*/Object.freeze({
|
|
11214
|
+
__proto__: null,
|
|
11215
|
+
ARIA_ATTR: ARIA_ATTR,
|
|
11216
|
+
ATTR_WHITESPACE: ATTR_WHITESPACE,
|
|
11217
|
+
CUSTOM_ELEMENT: CUSTOM_ELEMENT,
|
|
11218
|
+
DATA_ATTR: DATA_ATTR,
|
|
11219
|
+
DOCTYPE_NAME: DOCTYPE_NAME,
|
|
11220
|
+
ERB_EXPR: ERB_EXPR,
|
|
11221
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
|
11222
|
+
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
|
11223
|
+
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
|
11224
|
+
TMPLIT_EXPR: TMPLIT_EXPR
|
|
11225
|
+
});
|
|
11226
|
+
|
|
11227
|
+
/* eslint-disable @typescript-eslint/indent */
|
|
11228
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
|
11229
|
+
const NODE_TYPE = {
|
|
11230
|
+
element: 1,
|
|
11231
|
+
attribute: 2,
|
|
11232
|
+
text: 3,
|
|
11233
|
+
cdataSection: 4,
|
|
11234
|
+
entityReference: 5,
|
|
11235
|
+
// Deprecated
|
|
11236
|
+
entityNode: 6,
|
|
11237
|
+
// Deprecated
|
|
11238
|
+
progressingInstruction: 7,
|
|
11239
|
+
comment: 8,
|
|
11240
|
+
document: 9,
|
|
11241
|
+
documentType: 10,
|
|
11242
|
+
documentFragment: 11,
|
|
11243
|
+
notation: 12 // Deprecated
|
|
11244
|
+
};
|
|
11245
|
+
const getGlobal = function getGlobal() {
|
|
11246
|
+
return typeof window === 'undefined' ? null : window;
|
|
11247
|
+
};
|
|
11248
|
+
/**
|
|
11249
|
+
* Creates a no-op policy for internal use only.
|
|
11250
|
+
* Don't export this function outside this module!
|
|
11251
|
+
* @param trustedTypes The policy factory.
|
|
11252
|
+
* @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
|
|
11253
|
+
* @return The policy created (or null, if Trusted Types
|
|
11254
|
+
* are not supported or creating the policy failed).
|
|
11255
|
+
*/
|
|
11256
|
+
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
|
11257
|
+
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
|
11258
|
+
return null;
|
|
11259
|
+
}
|
|
11260
|
+
// Allow the callers to control the unique policy name
|
|
11261
|
+
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
|
11262
|
+
// Policy creation with duplicate names throws in Trusted Types.
|
|
11263
|
+
let suffix = null;
|
|
11264
|
+
const ATTR_NAME = 'data-tt-policy-suffix';
|
|
11265
|
+
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
|
|
11266
|
+
suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
|
11267
|
+
}
|
|
11268
|
+
const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
|
|
11269
|
+
try {
|
|
11270
|
+
return trustedTypes.createPolicy(policyName, {
|
|
11271
|
+
createHTML(html) {
|
|
11272
|
+
return html;
|
|
11273
|
+
},
|
|
11274
|
+
createScriptURL(scriptUrl) {
|
|
11275
|
+
return scriptUrl;
|
|
11276
|
+
}
|
|
11277
|
+
});
|
|
11278
|
+
} catch (_) {
|
|
11279
|
+
// Policy creation failed (most likely another DOMPurify script has
|
|
11280
|
+
// already run). Skip creating the policy, as this will only cause errors
|
|
11281
|
+
// if TT are enforced.
|
|
11282
|
+
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
|
11283
|
+
return null;
|
|
11284
|
+
}
|
|
11285
|
+
};
|
|
11286
|
+
const _createHooksMap = function _createHooksMap() {
|
|
11287
|
+
return {
|
|
11288
|
+
afterSanitizeAttributes: [],
|
|
11289
|
+
afterSanitizeElements: [],
|
|
11290
|
+
afterSanitizeShadowDOM: [],
|
|
11291
|
+
beforeSanitizeAttributes: [],
|
|
11292
|
+
beforeSanitizeElements: [],
|
|
11293
|
+
beforeSanitizeShadowDOM: [],
|
|
11294
|
+
uponSanitizeAttribute: [],
|
|
11295
|
+
uponSanitizeElement: [],
|
|
11296
|
+
uponSanitizeShadowNode: []
|
|
11297
|
+
};
|
|
11298
|
+
};
|
|
11299
|
+
function createDOMPurify() {
|
|
11300
|
+
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
11301
|
+
const DOMPurify = root => createDOMPurify(root);
|
|
11302
|
+
DOMPurify.version = '3.2.4';
|
|
11303
|
+
DOMPurify.removed = [];
|
|
11304
|
+
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
11305
|
+
// Not running in a browser, provide a factory function
|
|
11306
|
+
// so that you can pass your own Window
|
|
11307
|
+
DOMPurify.isSupported = false;
|
|
11308
|
+
return DOMPurify;
|
|
11309
|
+
}
|
|
11310
|
+
let {
|
|
11311
|
+
document
|
|
11312
|
+
} = window;
|
|
11313
|
+
const originalDocument = document;
|
|
11314
|
+
const currentScript = originalDocument.currentScript;
|
|
11315
|
+
const {
|
|
11316
|
+
DocumentFragment,
|
|
11317
|
+
HTMLTemplateElement,
|
|
11318
|
+
Node,
|
|
11319
|
+
Element,
|
|
11320
|
+
NodeFilter,
|
|
11321
|
+
NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
|
|
11322
|
+
HTMLFormElement,
|
|
11323
|
+
DOMParser,
|
|
11324
|
+
trustedTypes
|
|
11325
|
+
} = window;
|
|
11326
|
+
const ElementPrototype = Element.prototype;
|
|
11327
|
+
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
11328
|
+
const remove = lookupGetter(ElementPrototype, 'remove');
|
|
11329
|
+
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
11330
|
+
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
11331
|
+
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
11332
|
+
// As per issue #47, the web-components registry is inherited by a
|
|
11333
|
+
// new document created via createHTMLDocument. As per the spec
|
|
11334
|
+
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
11335
|
+
// a new empty registry is used when creating a template contents owner
|
|
11336
|
+
// document, so we use that as our parent document to ensure nothing
|
|
11337
|
+
// is inherited.
|
|
11338
|
+
if (typeof HTMLTemplateElement === 'function') {
|
|
11339
|
+
const template = document.createElement('template');
|
|
11340
|
+
if (template.content && template.content.ownerDocument) {
|
|
11341
|
+
document = template.content.ownerDocument;
|
|
11342
|
+
}
|
|
11343
|
+
}
|
|
11344
|
+
let trustedTypesPolicy;
|
|
11345
|
+
let emptyHTML = '';
|
|
11346
|
+
const {
|
|
11347
|
+
implementation,
|
|
11348
|
+
createNodeIterator,
|
|
11349
|
+
createDocumentFragment,
|
|
11350
|
+
getElementsByTagName
|
|
11351
|
+
} = document;
|
|
11352
|
+
const {
|
|
11353
|
+
importNode
|
|
11354
|
+
} = originalDocument;
|
|
11355
|
+
let hooks = _createHooksMap();
|
|
11356
|
+
/**
|
|
11357
|
+
* Expose whether this browser supports running the full DOMPurify.
|
|
11358
|
+
*/
|
|
11359
|
+
DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
|
|
11360
|
+
const {
|
|
11361
|
+
MUSTACHE_EXPR,
|
|
11362
|
+
ERB_EXPR,
|
|
11363
|
+
TMPLIT_EXPR,
|
|
11364
|
+
DATA_ATTR,
|
|
11365
|
+
ARIA_ATTR,
|
|
11366
|
+
IS_SCRIPT_OR_DATA,
|
|
11367
|
+
ATTR_WHITESPACE,
|
|
11368
|
+
CUSTOM_ELEMENT
|
|
11369
|
+
} = EXPRESSIONS;
|
|
11370
|
+
let {
|
|
11371
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
11372
|
+
} = EXPRESSIONS;
|
|
11373
|
+
/**
|
|
11374
|
+
* We consider the elements and attributes below to be safe. Ideally
|
|
11375
|
+
* don't add any new ones but feel free to remove unwanted ones.
|
|
11376
|
+
*/
|
|
11377
|
+
/* allowed element names */
|
|
11378
|
+
let ALLOWED_TAGS = null;
|
|
11379
|
+
const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
|
|
11380
|
+
/* Allowed attribute names */
|
|
11381
|
+
let ALLOWED_ATTR = null;
|
|
11382
|
+
const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
|
|
11383
|
+
/*
|
|
11384
|
+
* Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
|
|
11385
|
+
* @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
|
|
11386
|
+
* @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
|
|
11387
|
+
* @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
|
|
11388
|
+
*/
|
|
11389
|
+
let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
11390
|
+
tagNameCheck: {
|
|
11391
|
+
writable: true,
|
|
11392
|
+
configurable: false,
|
|
11393
|
+
enumerable: true,
|
|
11394
|
+
value: null
|
|
11395
|
+
},
|
|
11396
|
+
attributeNameCheck: {
|
|
11397
|
+
writable: true,
|
|
11398
|
+
configurable: false,
|
|
11399
|
+
enumerable: true,
|
|
11400
|
+
value: null
|
|
11401
|
+
},
|
|
11402
|
+
allowCustomizedBuiltInElements: {
|
|
11403
|
+
writable: true,
|
|
11404
|
+
configurable: false,
|
|
11405
|
+
enumerable: true,
|
|
11406
|
+
value: false
|
|
11407
|
+
}
|
|
11408
|
+
}));
|
|
11409
|
+
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
|
11410
|
+
let FORBID_TAGS = null;
|
|
11411
|
+
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
11412
|
+
let FORBID_ATTR = null;
|
|
11413
|
+
/* Decide if ARIA attributes are okay */
|
|
11414
|
+
let ALLOW_ARIA_ATTR = true;
|
|
11415
|
+
/* Decide if custom data attributes are okay */
|
|
11416
|
+
let ALLOW_DATA_ATTR = true;
|
|
11417
|
+
/* Decide if unknown protocols are okay */
|
|
11418
|
+
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
11419
|
+
/* Decide if self-closing tags in attributes are allowed.
|
|
11420
|
+
* Usually removed due to a mXSS issue in jQuery 3.0 */
|
|
11421
|
+
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
11422
|
+
/* Output should be safe for common template engines.
|
|
11423
|
+
* This means, DOMPurify removes data attributes, mustaches and ERB
|
|
11424
|
+
*/
|
|
11425
|
+
let SAFE_FOR_TEMPLATES = false;
|
|
11426
|
+
/* Output should be safe even for XML used within HTML and alike.
|
|
11427
|
+
* This means, DOMPurify removes comments when containing risky content.
|
|
11428
|
+
*/
|
|
11429
|
+
let SAFE_FOR_XML = true;
|
|
11430
|
+
/* Decide if document with <html>... should be returned */
|
|
11431
|
+
let WHOLE_DOCUMENT = false;
|
|
11432
|
+
/* Track whether config is already set on this instance of DOMPurify. */
|
|
11433
|
+
let SET_CONFIG = false;
|
|
11434
|
+
/* Decide if all elements (e.g. style, script) must be children of
|
|
11435
|
+
* document.body. By default, browsers might move them to document.head */
|
|
11436
|
+
let FORCE_BODY = false;
|
|
11437
|
+
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
|
11438
|
+
* string (or a TrustedHTML object if Trusted Types are supported).
|
|
11439
|
+
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
|
11440
|
+
*/
|
|
11441
|
+
let RETURN_DOM = false;
|
|
11442
|
+
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
|
11443
|
+
* string (or a TrustedHTML object if Trusted Types are supported) */
|
|
11444
|
+
let RETURN_DOM_FRAGMENT = false;
|
|
11445
|
+
/* Try to return a Trusted Type object instead of a string, return a string in
|
|
11446
|
+
* case Trusted Types are not supported */
|
|
11447
|
+
let RETURN_TRUSTED_TYPE = false;
|
|
11448
|
+
/* Output should be free from DOM clobbering attacks?
|
|
11449
|
+
* This sanitizes markups named with colliding, clobberable built-in DOM APIs.
|
|
11450
|
+
*/
|
|
11451
|
+
let SANITIZE_DOM = true;
|
|
11452
|
+
/* Achieve full DOM Clobbering protection by isolating the namespace of named
|
|
11453
|
+
* properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
|
|
11454
|
+
*
|
|
11455
|
+
* HTML/DOM spec rules that enable DOM Clobbering:
|
|
11456
|
+
* - Named Access on Window (§7.3.3)
|
|
11457
|
+
* - DOM Tree Accessors (§3.1.5)
|
|
11458
|
+
* - Form Element Parent-Child Relations (§4.10.3)
|
|
11459
|
+
* - Iframe srcdoc / Nested WindowProxies (§4.8.5)
|
|
11460
|
+
* - HTMLCollection (§4.2.10.2)
|
|
11461
|
+
*
|
|
11462
|
+
* Namespace isolation is implemented by prefixing `id` and `name` attributes
|
|
11463
|
+
* with a constant string, i.e., `user-content-`
|
|
11464
|
+
*/
|
|
11465
|
+
let SANITIZE_NAMED_PROPS = false;
|
|
11466
|
+
const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
|
|
11467
|
+
/* Keep element content when removing element? */
|
|
11468
|
+
let KEEP_CONTENT = true;
|
|
11469
|
+
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
|
11470
|
+
* of importing it into a new Document and returning a sanitized copy */
|
|
11471
|
+
let IN_PLACE = false;
|
|
11472
|
+
/* Allow usage of profiles like html, svg and mathMl */
|
|
11473
|
+
let USE_PROFILES = {};
|
|
11474
|
+
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
11475
|
+
let FORBID_CONTENTS = null;
|
|
11476
|
+
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']);
|
|
11477
|
+
/* Tags that are safe for data: URIs */
|
|
11478
|
+
let DATA_URI_TAGS = null;
|
|
11479
|
+
const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
11480
|
+
/* Attributes safe for values like "javascript:" */
|
|
11481
|
+
let URI_SAFE_ATTRIBUTES = null;
|
|
11482
|
+
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
|
11483
|
+
const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
11484
|
+
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
11485
|
+
const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
11486
|
+
/* Document namespace */
|
|
11487
|
+
let NAMESPACE = HTML_NAMESPACE;
|
|
11488
|
+
let IS_EMPTY_INPUT = false;
|
|
11489
|
+
/* Allowed XHTML+XML namespaces */
|
|
11490
|
+
let ALLOWED_NAMESPACES = null;
|
|
11491
|
+
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
11492
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
11493
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
|
|
11494
|
+
// Certain elements are allowed in both SVG and HTML
|
|
11495
|
+
// namespace. We need to specify them explicitly
|
|
11496
|
+
// so that they don't get erroneously deleted from
|
|
11497
|
+
// HTML namespace.
|
|
11498
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
11499
|
+
/* Parsing of strict XHTML documents */
|
|
11500
|
+
let PARSER_MEDIA_TYPE = null;
|
|
11501
|
+
const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
|
11502
|
+
const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
|
11503
|
+
let transformCaseFunc = null;
|
|
11504
|
+
/* Keep a reference to config to pass to hooks */
|
|
11505
|
+
let CONFIG = null;
|
|
11506
|
+
/* Ideally, do not touch anything below this line */
|
|
11507
|
+
/* ______________________________________________ */
|
|
11508
|
+
const formElement = document.createElement('form');
|
|
11509
|
+
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
11510
|
+
return testValue instanceof RegExp || testValue instanceof Function;
|
|
11511
|
+
};
|
|
11512
|
+
/**
|
|
11513
|
+
* _parseConfig
|
|
11514
|
+
*
|
|
11515
|
+
* @param cfg optional config literal
|
|
11516
|
+
*/
|
|
11517
|
+
// eslint-disable-next-line complexity
|
|
11518
|
+
const _parseConfig = function _parseConfig() {
|
|
11519
|
+
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11520
|
+
if (CONFIG && CONFIG === cfg) {
|
|
11521
|
+
return;
|
|
11522
|
+
}
|
|
11523
|
+
/* Shield configuration object from tampering */
|
|
11524
|
+
if (!cfg || typeof cfg !== 'object') {
|
|
11525
|
+
cfg = {};
|
|
11526
|
+
}
|
|
11527
|
+
/* Shield configuration object from prototype pollution */
|
|
11528
|
+
cfg = clone(cfg);
|
|
11529
|
+
PARSER_MEDIA_TYPE =
|
|
11530
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
11531
|
+
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
11532
|
+
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
11533
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
11534
|
+
/* Set configuration parameters */
|
|
11535
|
+
ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
11536
|
+
ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
11537
|
+
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
11538
|
+
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
11539
|
+
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
|
|
11540
|
+
FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
11541
|
+
FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
|
11542
|
+
FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
|
11543
|
+
USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;
|
|
11544
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
11545
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
11546
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
11547
|
+
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
|
|
11548
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
|
|
11549
|
+
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
|
|
11550
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
|
|
11551
|
+
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
|
|
11552
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
|
|
11553
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
|
|
11554
|
+
FORCE_BODY = cfg.FORCE_BODY || false; // Default false
|
|
11555
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
|
|
11556
|
+
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
|
|
11557
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
11558
|
+
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
11559
|
+
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
|
|
11560
|
+
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
11561
|
+
MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
|
|
11562
|
+
HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
|
|
11563
|
+
CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
|
|
11564
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
|
11565
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
|
11566
|
+
}
|
|
11567
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
|
|
11568
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
|
|
11569
|
+
}
|
|
11570
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
|
|
11571
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
|
|
11572
|
+
}
|
|
11573
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
11574
|
+
ALLOW_DATA_ATTR = false;
|
|
11575
|
+
}
|
|
11576
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
11577
|
+
RETURN_DOM = true;
|
|
11578
|
+
}
|
|
11579
|
+
/* Parse profile info */
|
|
11580
|
+
if (USE_PROFILES) {
|
|
11581
|
+
ALLOWED_TAGS = addToSet({}, text);
|
|
11582
|
+
ALLOWED_ATTR = [];
|
|
11583
|
+
if (USE_PROFILES.html === true) {
|
|
11584
|
+
addToSet(ALLOWED_TAGS, html$1);
|
|
11585
|
+
addToSet(ALLOWED_ATTR, html);
|
|
11586
|
+
}
|
|
11587
|
+
if (USE_PROFILES.svg === true) {
|
|
11588
|
+
addToSet(ALLOWED_TAGS, svg$1);
|
|
11589
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
11590
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
11591
|
+
}
|
|
11592
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
11593
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
11594
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
11595
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
11596
|
+
}
|
|
11597
|
+
if (USE_PROFILES.mathMl === true) {
|
|
11598
|
+
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
11599
|
+
addToSet(ALLOWED_ATTR, mathMl);
|
|
11600
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
11601
|
+
}
|
|
11602
|
+
}
|
|
11603
|
+
/* Merge configuration parameters */
|
|
11604
|
+
if (cfg.ADD_TAGS) {
|
|
11605
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
11606
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
11607
|
+
}
|
|
11608
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
11609
|
+
}
|
|
11610
|
+
if (cfg.ADD_ATTR) {
|
|
11611
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
11612
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
11613
|
+
}
|
|
11614
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
11615
|
+
}
|
|
11616
|
+
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
11617
|
+
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
11618
|
+
}
|
|
11619
|
+
if (cfg.FORBID_CONTENTS) {
|
|
11620
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
11621
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
11622
|
+
}
|
|
11623
|
+
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
11624
|
+
}
|
|
11625
|
+
/* Add #text in case KEEP_CONTENT is set to true */
|
|
11626
|
+
if (KEEP_CONTENT) {
|
|
11627
|
+
ALLOWED_TAGS['#text'] = true;
|
|
11628
|
+
}
|
|
11629
|
+
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
|
11630
|
+
if (WHOLE_DOCUMENT) {
|
|
11631
|
+
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
|
11632
|
+
}
|
|
11633
|
+
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
|
11634
|
+
if (ALLOWED_TAGS.table) {
|
|
11635
|
+
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
11636
|
+
delete FORBID_TAGS.tbody;
|
|
11637
|
+
}
|
|
11638
|
+
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
11639
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
|
|
11640
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
11641
|
+
}
|
|
11642
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
|
|
11643
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
11644
|
+
}
|
|
11645
|
+
// Overwrite existing TrustedTypes policy.
|
|
11646
|
+
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
11647
|
+
// Sign local variables required by `sanitize`.
|
|
11648
|
+
emptyHTML = trustedTypesPolicy.createHTML('');
|
|
11649
|
+
} else {
|
|
11650
|
+
// Uninitialized policy, attempt to initialize the internal dompurify policy.
|
|
11651
|
+
if (trustedTypesPolicy === undefined) {
|
|
11652
|
+
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
11653
|
+
}
|
|
11654
|
+
// If creating the internal policy succeeded sign internal variables.
|
|
11655
|
+
if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
|
|
11656
|
+
emptyHTML = trustedTypesPolicy.createHTML('');
|
|
11657
|
+
}
|
|
11658
|
+
}
|
|
11659
|
+
// Prevent further manipulation of configuration.
|
|
11660
|
+
// Not available in IE8, Safari 5, etc.
|
|
11661
|
+
if (freeze) {
|
|
11662
|
+
freeze(cfg);
|
|
11663
|
+
}
|
|
11664
|
+
CONFIG = cfg;
|
|
11665
|
+
};
|
|
11666
|
+
/* Keep track of all possible SVG and MathML tags
|
|
11667
|
+
* so that we can perform the namespace checks
|
|
11668
|
+
* correctly. */
|
|
11669
|
+
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
11670
|
+
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
11671
|
+
/**
|
|
11672
|
+
* @param element a DOM element whose namespace is being checked
|
|
11673
|
+
* @returns Return false if the element has a
|
|
11674
|
+
* namespace that a spec-compliant parser would never
|
|
11675
|
+
* return. Return true otherwise.
|
|
11676
|
+
*/
|
|
11677
|
+
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
11678
|
+
let parent = getParentNode(element);
|
|
11679
|
+
// In JSDOM, if we're inside shadow DOM, then parentNode
|
|
11680
|
+
// can be null. We just simulate parent in this case.
|
|
11681
|
+
if (!parent || !parent.tagName) {
|
|
11682
|
+
parent = {
|
|
11683
|
+
namespaceURI: NAMESPACE,
|
|
11684
|
+
tagName: 'template'
|
|
11685
|
+
};
|
|
11686
|
+
}
|
|
11687
|
+
const tagName = stringToLowerCase(element.tagName);
|
|
11688
|
+
const parentTagName = stringToLowerCase(parent.tagName);
|
|
11689
|
+
if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
11690
|
+
return false;
|
|
11691
|
+
}
|
|
11692
|
+
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
11693
|
+
// The only way to switch from HTML namespace to SVG
|
|
11694
|
+
// is via <svg>. If it happens via any other tag, then
|
|
11695
|
+
// it should be killed.
|
|
11696
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
11697
|
+
return tagName === 'svg';
|
|
11698
|
+
}
|
|
11699
|
+
// The only way to switch from MathML to SVG is via`
|
|
11700
|
+
// svg if parent is either <annotation-xml> or MathML
|
|
11701
|
+
// text integration points.
|
|
11702
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
11703
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
11704
|
+
}
|
|
11705
|
+
// We only allow elements that are defined in SVG
|
|
11706
|
+
// spec. All others are disallowed in SVG namespace.
|
|
11707
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
11708
|
+
}
|
|
11709
|
+
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
11710
|
+
// The only way to switch from HTML namespace to MathML
|
|
11711
|
+
// is via <math>. If it happens via any other tag, then
|
|
11712
|
+
// it should be killed.
|
|
11713
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
11714
|
+
return tagName === 'math';
|
|
11715
|
+
}
|
|
11716
|
+
// The only way to switch from SVG to MathML is via
|
|
11717
|
+
// <math> and HTML integration points
|
|
11718
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
11719
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
11720
|
+
}
|
|
11721
|
+
// We only allow elements that are defined in MathML
|
|
11722
|
+
// spec. All others are disallowed in MathML namespace.
|
|
11723
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
11724
|
+
}
|
|
11725
|
+
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
11726
|
+
// The only way to switch from SVG to HTML is via
|
|
11727
|
+
// HTML integration points, and from MathML to HTML
|
|
11728
|
+
// is via MathML text integration points
|
|
11729
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
11730
|
+
return false;
|
|
11731
|
+
}
|
|
11732
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
11733
|
+
return false;
|
|
11734
|
+
}
|
|
11735
|
+
// We disallow tags that are specific for MathML
|
|
11736
|
+
// or SVG and should never appear in HTML namespace
|
|
11737
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
11738
|
+
}
|
|
11739
|
+
// For XHTML and XML documents that support custom namespaces
|
|
11740
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
11741
|
+
return true;
|
|
11742
|
+
}
|
|
11743
|
+
// The code should never reach this place (this means
|
|
11744
|
+
// that the element somehow got namespace that is not
|
|
11745
|
+
// HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
|
|
11746
|
+
// Return false just in case.
|
|
11747
|
+
return false;
|
|
11748
|
+
};
|
|
11749
|
+
/**
|
|
11750
|
+
* _forceRemove
|
|
11751
|
+
*
|
|
11752
|
+
* @param node a DOM node
|
|
11753
|
+
*/
|
|
11754
|
+
const _forceRemove = function _forceRemove(node) {
|
|
11755
|
+
arrayPush(DOMPurify.removed, {
|
|
11756
|
+
element: node
|
|
11757
|
+
});
|
|
11758
|
+
try {
|
|
11759
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
11760
|
+
getParentNode(node).removeChild(node);
|
|
11761
|
+
} catch (_) {
|
|
11762
|
+
remove(node);
|
|
11763
|
+
}
|
|
11764
|
+
};
|
|
11765
|
+
/**
|
|
11766
|
+
* _removeAttribute
|
|
11767
|
+
*
|
|
11768
|
+
* @param name an Attribute name
|
|
11769
|
+
* @param element a DOM node
|
|
11770
|
+
*/
|
|
11771
|
+
const _removeAttribute = function _removeAttribute(name, element) {
|
|
11772
|
+
try {
|
|
11773
|
+
arrayPush(DOMPurify.removed, {
|
|
11774
|
+
attribute: element.getAttributeNode(name),
|
|
11775
|
+
from: element
|
|
11776
|
+
});
|
|
11777
|
+
} catch (_) {
|
|
11778
|
+
arrayPush(DOMPurify.removed, {
|
|
11779
|
+
attribute: null,
|
|
11780
|
+
from: element
|
|
11781
|
+
});
|
|
11782
|
+
}
|
|
11783
|
+
element.removeAttribute(name);
|
|
11784
|
+
// We void attribute values for unremovable "is" attributes
|
|
11785
|
+
if (name === 'is') {
|
|
11786
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
11787
|
+
try {
|
|
11788
|
+
_forceRemove(element);
|
|
11789
|
+
} catch (_) {}
|
|
11790
|
+
} else {
|
|
11791
|
+
try {
|
|
11792
|
+
element.setAttribute(name, '');
|
|
11793
|
+
} catch (_) {}
|
|
11794
|
+
}
|
|
11795
|
+
}
|
|
11796
|
+
};
|
|
11797
|
+
/**
|
|
11798
|
+
* _initDocument
|
|
11799
|
+
*
|
|
11800
|
+
* @param dirty - a string of dirty markup
|
|
11801
|
+
* @return a DOM, filled with the dirty markup
|
|
11802
|
+
*/
|
|
11803
|
+
const _initDocument = function _initDocument(dirty) {
|
|
11804
|
+
/* Create a HTML document */
|
|
11805
|
+
let doc = null;
|
|
11806
|
+
let leadingWhitespace = null;
|
|
11807
|
+
if (FORCE_BODY) {
|
|
11808
|
+
dirty = '<remove></remove>' + dirty;
|
|
11809
|
+
} else {
|
|
11810
|
+
/* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
|
|
11811
|
+
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
11812
|
+
leadingWhitespace = matches && matches[0];
|
|
11813
|
+
}
|
|
11814
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
|
|
11815
|
+
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
11816
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
11817
|
+
}
|
|
11818
|
+
const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
11819
|
+
/*
|
|
11820
|
+
* Use the DOMParser API by default, fallback later if needs be
|
|
11821
|
+
* DOMParser not work for svg when has multiple root element.
|
|
11822
|
+
*/
|
|
11823
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
11824
|
+
try {
|
|
11825
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
11826
|
+
} catch (_) {}
|
|
11827
|
+
}
|
|
11828
|
+
/* Use createHTMLDocument in case DOMParser is not available */
|
|
11829
|
+
if (!doc || !doc.documentElement) {
|
|
11830
|
+
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
|
11831
|
+
try {
|
|
11832
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
|
11833
|
+
} catch (_) {
|
|
11834
|
+
// Syntax error if dirtyPayload is invalid xml
|
|
11835
|
+
}
|
|
11836
|
+
}
|
|
11837
|
+
const body = doc.body || doc.documentElement;
|
|
11838
|
+
if (dirty && leadingWhitespace) {
|
|
11839
|
+
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
11840
|
+
}
|
|
11841
|
+
/* Work on whole document or just its body */
|
|
11842
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
11843
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
|
11844
|
+
}
|
|
11845
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
11846
|
+
};
|
|
11847
|
+
/**
|
|
11848
|
+
* Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
|
|
11849
|
+
*
|
|
11850
|
+
* @param root The root element or node to start traversing on.
|
|
11851
|
+
* @return The created NodeIterator
|
|
11852
|
+
*/
|
|
11853
|
+
const _createNodeIterator = function _createNodeIterator(root) {
|
|
11854
|
+
return createNodeIterator.call(root.ownerDocument || root, root,
|
|
11855
|
+
// eslint-disable-next-line no-bitwise
|
|
11856
|
+
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
11857
|
+
};
|
|
11858
|
+
/**
|
|
11859
|
+
* _isClobbered
|
|
11860
|
+
*
|
|
11861
|
+
* @param element element to check for clobbering attacks
|
|
11862
|
+
* @return true if clobbered, false if safe
|
|
11863
|
+
*/
|
|
11864
|
+
const _isClobbered = function _isClobbered(element) {
|
|
11865
|
+
return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
|
|
11866
|
+
};
|
|
11867
|
+
/**
|
|
11868
|
+
* Checks whether the given object is a DOM node.
|
|
11869
|
+
*
|
|
11870
|
+
* @param value object to check whether it's a DOM node
|
|
11871
|
+
* @return true is object is a DOM node
|
|
11872
|
+
*/
|
|
11873
|
+
const _isNode = function _isNode(value) {
|
|
11874
|
+
return typeof Node === 'function' && value instanceof Node;
|
|
11875
|
+
};
|
|
11876
|
+
function _executeHooks(hooks, currentNode, data) {
|
|
11877
|
+
arrayForEach(hooks, hook => {
|
|
11878
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
11879
|
+
});
|
|
11880
|
+
}
|
|
11881
|
+
/**
|
|
11882
|
+
* _sanitizeElements
|
|
11883
|
+
*
|
|
11884
|
+
* @protect nodeName
|
|
11885
|
+
* @protect textContent
|
|
11886
|
+
* @protect removeChild
|
|
11887
|
+
* @param currentNode to check for permission to exist
|
|
11888
|
+
* @return true if node was killed, false if left alive
|
|
11889
|
+
*/
|
|
11890
|
+
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
11891
|
+
let content = null;
|
|
11892
|
+
/* Execute a hook if present */
|
|
11893
|
+
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
11894
|
+
/* Check if element is clobbered or can clobber */
|
|
11895
|
+
if (_isClobbered(currentNode)) {
|
|
11896
|
+
_forceRemove(currentNode);
|
|
11897
|
+
return true;
|
|
11898
|
+
}
|
|
11899
|
+
/* Now let's check the element's type and name */
|
|
11900
|
+
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
11901
|
+
/* Execute a hook if present */
|
|
11902
|
+
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
11903
|
+
tagName,
|
|
11904
|
+
allowedTags: ALLOWED_TAGS
|
|
11905
|
+
});
|
|
11906
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
11907
|
+
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
|
11908
|
+
_forceRemove(currentNode);
|
|
11909
|
+
return true;
|
|
11910
|
+
}
|
|
11911
|
+
/* Remove any occurrence of processing instructions */
|
|
11912
|
+
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
11913
|
+
_forceRemove(currentNode);
|
|
11914
|
+
return true;
|
|
11915
|
+
}
|
|
11916
|
+
/* Remove any kind of possibly harmful comments */
|
|
11917
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
|
11918
|
+
_forceRemove(currentNode);
|
|
11919
|
+
return true;
|
|
11920
|
+
}
|
|
11921
|
+
/* Remove element if anything forbids its presence */
|
|
11922
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
11923
|
+
/* Check if we have a custom element to handle */
|
|
11924
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
11925
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
11926
|
+
return false;
|
|
11927
|
+
}
|
|
11928
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
11929
|
+
return false;
|
|
11930
|
+
}
|
|
11931
|
+
}
|
|
11932
|
+
/* Keep content except for bad-listed elements */
|
|
11933
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
11934
|
+
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
11935
|
+
const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
11936
|
+
if (childNodes && parentNode) {
|
|
11937
|
+
const childCount = childNodes.length;
|
|
11938
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
11939
|
+
const childClone = cloneNode(childNodes[i], true);
|
|
11940
|
+
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
|
11941
|
+
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
11942
|
+
}
|
|
11943
|
+
}
|
|
11944
|
+
}
|
|
11945
|
+
_forceRemove(currentNode);
|
|
11946
|
+
return true;
|
|
11947
|
+
}
|
|
11948
|
+
/* Check whether element has a valid namespace */
|
|
11949
|
+
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
11950
|
+
_forceRemove(currentNode);
|
|
11951
|
+
return true;
|
|
11952
|
+
}
|
|
11953
|
+
/* Make sure that older browsers don't get fallback-tag mXSS */
|
|
11954
|
+
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
|
|
11955
|
+
_forceRemove(currentNode);
|
|
11956
|
+
return true;
|
|
11957
|
+
}
|
|
11958
|
+
/* Sanitize element content to be template-safe */
|
|
11959
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
11960
|
+
/* Get the element's text content */
|
|
11961
|
+
content = currentNode.textContent;
|
|
11962
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
11963
|
+
content = stringReplace(content, expr, ' ');
|
|
11964
|
+
});
|
|
11965
|
+
if (currentNode.textContent !== content) {
|
|
11966
|
+
arrayPush(DOMPurify.removed, {
|
|
11967
|
+
element: currentNode.cloneNode()
|
|
11968
|
+
});
|
|
11969
|
+
currentNode.textContent = content;
|
|
11970
|
+
}
|
|
11971
|
+
}
|
|
11972
|
+
/* Execute a hook if present */
|
|
11973
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
11974
|
+
return false;
|
|
11975
|
+
};
|
|
11976
|
+
/**
|
|
11977
|
+
* _isValidAttribute
|
|
11978
|
+
*
|
|
11979
|
+
* @param lcTag Lowercase tag name of containing element.
|
|
11980
|
+
* @param lcName Lowercase attribute name.
|
|
11981
|
+
* @param value Attribute value.
|
|
11982
|
+
* @return Returns true if `value` is valid, otherwise false.
|
|
11983
|
+
*/
|
|
11984
|
+
// eslint-disable-next-line complexity
|
|
11985
|
+
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
11986
|
+
/* Make sure attribute cannot clobber */
|
|
11987
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
11988
|
+
return false;
|
|
11989
|
+
}
|
|
11990
|
+
/* Allow valid data-* attributes: At least one character after "-"
|
|
11991
|
+
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
11992
|
+
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
11993
|
+
We don't need to check the value; it's always URI safe. */
|
|
11994
|
+
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]) {
|
|
11995
|
+
if (
|
|
11996
|
+
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
11997
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
11998
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
11999
|
+
_isBasicCustomElement(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)) ||
|
|
12000
|
+
// Alternative, second condition checks if it's an `is`-attribute, AND
|
|
12001
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
12002
|
+
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 {
|
|
12003
|
+
return false;
|
|
12004
|
+
}
|
|
12005
|
+
/* Check value is safe. First, is attr inert? If so, is safe */
|
|
12006
|
+
} 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) {
|
|
12007
|
+
return false;
|
|
12008
|
+
} else ;
|
|
12009
|
+
return true;
|
|
12010
|
+
};
|
|
12011
|
+
/**
|
|
12012
|
+
* _isBasicCustomElement
|
|
12013
|
+
* checks if at least one dash is included in tagName, and it's not the first char
|
|
12014
|
+
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
|
|
12015
|
+
*
|
|
12016
|
+
* @param tagName name of the tag of the node to sanitize
|
|
12017
|
+
* @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
|
12018
|
+
*/
|
|
12019
|
+
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
12020
|
+
return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);
|
|
12021
|
+
};
|
|
12022
|
+
/**
|
|
12023
|
+
* _sanitizeAttributes
|
|
12024
|
+
*
|
|
12025
|
+
* @protect attributes
|
|
12026
|
+
* @protect nodeName
|
|
12027
|
+
* @protect removeAttribute
|
|
12028
|
+
* @protect setAttribute
|
|
12029
|
+
*
|
|
12030
|
+
* @param currentNode to sanitize
|
|
12031
|
+
*/
|
|
12032
|
+
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
12033
|
+
/* Execute a hook if present */
|
|
12034
|
+
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
12035
|
+
const {
|
|
12036
|
+
attributes
|
|
12037
|
+
} = currentNode;
|
|
12038
|
+
/* Check if we have attributes; if not we might have a text node */
|
|
12039
|
+
if (!attributes || _isClobbered(currentNode)) {
|
|
12040
|
+
return;
|
|
12041
|
+
}
|
|
12042
|
+
const hookEvent = {
|
|
12043
|
+
attrName: '',
|
|
12044
|
+
attrValue: '',
|
|
12045
|
+
keepAttr: true,
|
|
12046
|
+
allowedAttributes: ALLOWED_ATTR,
|
|
12047
|
+
forceKeepAttr: undefined
|
|
12048
|
+
};
|
|
12049
|
+
let l = attributes.length;
|
|
12050
|
+
/* Go backwards over all attributes; safely remove bad ones */
|
|
12051
|
+
while (l--) {
|
|
12052
|
+
const attr = attributes[l];
|
|
12053
|
+
const {
|
|
12054
|
+
name,
|
|
12055
|
+
namespaceURI,
|
|
12056
|
+
value: attrValue
|
|
12057
|
+
} = attr;
|
|
12058
|
+
const lcName = transformCaseFunc(name);
|
|
12059
|
+
let value = name === 'value' ? attrValue : stringTrim(attrValue);
|
|
12060
|
+
/* Execute a hook if present */
|
|
12061
|
+
hookEvent.attrName = lcName;
|
|
12062
|
+
hookEvent.attrValue = value;
|
|
12063
|
+
hookEvent.keepAttr = true;
|
|
12064
|
+
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
12065
|
+
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
12066
|
+
value = hookEvent.attrValue;
|
|
12067
|
+
/* Full DOM Clobbering protection via namespace isolation,
|
|
12068
|
+
* Prefix id and name attributes with `user-content-`
|
|
12069
|
+
*/
|
|
12070
|
+
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
12071
|
+
// Remove the attribute with this value
|
|
12072
|
+
_removeAttribute(name, currentNode);
|
|
12073
|
+
// Prefix the value and later re-create the attribute with the sanitized value
|
|
12074
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
12075
|
+
}
|
|
12076
|
+
/* Work around a security issue with comments inside attributes */
|
|
12077
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
|
12078
|
+
_removeAttribute(name, currentNode);
|
|
12079
|
+
continue;
|
|
12080
|
+
}
|
|
12081
|
+
/* Did the hooks approve of the attribute? */
|
|
12082
|
+
if (hookEvent.forceKeepAttr) {
|
|
12083
|
+
continue;
|
|
12084
|
+
}
|
|
12085
|
+
/* Remove attribute */
|
|
12086
|
+
_removeAttribute(name, currentNode);
|
|
12087
|
+
/* Did the hooks approve of the attribute? */
|
|
12088
|
+
if (!hookEvent.keepAttr) {
|
|
12089
|
+
continue;
|
|
12090
|
+
}
|
|
12091
|
+
/* Work around a security issue in jQuery 3.0 */
|
|
12092
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
|
12093
|
+
_removeAttribute(name, currentNode);
|
|
12094
|
+
continue;
|
|
12095
|
+
}
|
|
12096
|
+
/* Sanitize attribute content to be template-safe */
|
|
12097
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
12098
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
12099
|
+
value = stringReplace(value, expr, ' ');
|
|
12100
|
+
});
|
|
12101
|
+
}
|
|
12102
|
+
/* Is `value` valid for this attribute? */
|
|
12103
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
12104
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
12105
|
+
continue;
|
|
12106
|
+
}
|
|
12107
|
+
/* Handle attributes that require Trusted Types */
|
|
12108
|
+
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
|
12109
|
+
if (namespaceURI) ; else {
|
|
12110
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
12111
|
+
case 'TrustedHTML':
|
|
12112
|
+
{
|
|
12113
|
+
value = trustedTypesPolicy.createHTML(value);
|
|
12114
|
+
break;
|
|
12115
|
+
}
|
|
12116
|
+
case 'TrustedScriptURL':
|
|
12117
|
+
{
|
|
12118
|
+
value = trustedTypesPolicy.createScriptURL(value);
|
|
12119
|
+
break;
|
|
12120
|
+
}
|
|
12121
|
+
}
|
|
12122
|
+
}
|
|
12123
|
+
}
|
|
12124
|
+
/* Handle invalid data-* attribute set by try-catching it */
|
|
12125
|
+
try {
|
|
12126
|
+
if (namespaceURI) {
|
|
12127
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
12128
|
+
} else {
|
|
12129
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
12130
|
+
currentNode.setAttribute(name, value);
|
|
12131
|
+
}
|
|
12132
|
+
if (_isClobbered(currentNode)) {
|
|
12133
|
+
_forceRemove(currentNode);
|
|
12134
|
+
} else {
|
|
12135
|
+
arrayPop(DOMPurify.removed);
|
|
12136
|
+
}
|
|
12137
|
+
} catch (_) {}
|
|
12138
|
+
}
|
|
12139
|
+
/* Execute a hook if present */
|
|
12140
|
+
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
12141
|
+
};
|
|
12142
|
+
/**
|
|
12143
|
+
* _sanitizeShadowDOM
|
|
12144
|
+
*
|
|
12145
|
+
* @param fragment to iterate over recursively
|
|
12146
|
+
*/
|
|
12147
|
+
const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
12148
|
+
let shadowNode = null;
|
|
12149
|
+
const shadowIterator = _createNodeIterator(fragment);
|
|
12150
|
+
/* Execute a hook if present */
|
|
12151
|
+
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
12152
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
12153
|
+
/* Execute a hook if present */
|
|
12154
|
+
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
12155
|
+
/* Sanitize tags and elements */
|
|
12156
|
+
_sanitizeElements(shadowNode);
|
|
12157
|
+
/* Check attributes next */
|
|
12158
|
+
_sanitizeAttributes(shadowNode);
|
|
12159
|
+
/* Deep shadow DOM detected */
|
|
12160
|
+
if (shadowNode.content instanceof DocumentFragment) {
|
|
12161
|
+
_sanitizeShadowDOM(shadowNode.content);
|
|
12162
|
+
}
|
|
12163
|
+
}
|
|
12164
|
+
/* Execute a hook if present */
|
|
12165
|
+
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
12166
|
+
};
|
|
12167
|
+
// eslint-disable-next-line complexity
|
|
12168
|
+
DOMPurify.sanitize = function (dirty) {
|
|
12169
|
+
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12170
|
+
let body = null;
|
|
12171
|
+
let importedNode = null;
|
|
12172
|
+
let currentNode = null;
|
|
12173
|
+
let returnNode = null;
|
|
12174
|
+
/* Make sure we have a string to sanitize.
|
|
12175
|
+
DO NOT return early, as this will return the wrong type if
|
|
12176
|
+
the user has requested a DOM object rather than a string */
|
|
12177
|
+
IS_EMPTY_INPUT = !dirty;
|
|
12178
|
+
if (IS_EMPTY_INPUT) {
|
|
12179
|
+
dirty = '<!-->';
|
|
12180
|
+
}
|
|
12181
|
+
/* Stringify, in case dirty is an object */
|
|
12182
|
+
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
12183
|
+
if (typeof dirty.toString === 'function') {
|
|
12184
|
+
dirty = dirty.toString();
|
|
12185
|
+
if (typeof dirty !== 'string') {
|
|
12186
|
+
throw typeErrorCreate('dirty is not a string, aborting');
|
|
12187
|
+
}
|
|
12188
|
+
} else {
|
|
12189
|
+
throw typeErrorCreate('toString is not a function');
|
|
12190
|
+
}
|
|
12191
|
+
}
|
|
12192
|
+
/* Return dirty HTML if DOMPurify cannot run */
|
|
12193
|
+
if (!DOMPurify.isSupported) {
|
|
12194
|
+
return dirty;
|
|
12195
|
+
}
|
|
12196
|
+
/* Assign config vars */
|
|
12197
|
+
if (!SET_CONFIG) {
|
|
12198
|
+
_parseConfig(cfg);
|
|
12199
|
+
}
|
|
12200
|
+
/* Clean up removed elements */
|
|
12201
|
+
DOMPurify.removed = [];
|
|
12202
|
+
/* Check if dirty is correctly typed for IN_PLACE */
|
|
12203
|
+
if (typeof dirty === 'string') {
|
|
12204
|
+
IN_PLACE = false;
|
|
12205
|
+
}
|
|
12206
|
+
if (IN_PLACE) {
|
|
12207
|
+
/* Do some early pre-sanitization to avoid unsafe root nodes */
|
|
12208
|
+
if (dirty.nodeName) {
|
|
12209
|
+
const tagName = transformCaseFunc(dirty.nodeName);
|
|
12210
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
12211
|
+
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
|
12212
|
+
}
|
|
12213
|
+
}
|
|
12214
|
+
} else if (dirty instanceof Node) {
|
|
12215
|
+
/* If dirty is a DOM element, append to an empty document to avoid
|
|
12216
|
+
elements being stripped by the parser */
|
|
12217
|
+
body = _initDocument('<!---->');
|
|
12218
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
12219
|
+
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
|
|
12220
|
+
/* Node is already a body, use as is */
|
|
12221
|
+
body = importedNode;
|
|
12222
|
+
} else if (importedNode.nodeName === 'HTML') {
|
|
12223
|
+
body = importedNode;
|
|
12224
|
+
} else {
|
|
12225
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
12226
|
+
body.appendChild(importedNode);
|
|
12227
|
+
}
|
|
12228
|
+
} else {
|
|
12229
|
+
/* Exit directly if we have nothing to do */
|
|
12230
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
12231
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
12232
|
+
dirty.indexOf('<') === -1) {
|
|
12233
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
12234
|
+
}
|
|
12235
|
+
/* Initialize the document to work on */
|
|
12236
|
+
body = _initDocument(dirty);
|
|
12237
|
+
/* Check we have a DOM node from the data */
|
|
12238
|
+
if (!body) {
|
|
12239
|
+
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
|
12240
|
+
}
|
|
12241
|
+
}
|
|
12242
|
+
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
12243
|
+
if (body && FORCE_BODY) {
|
|
12244
|
+
_forceRemove(body.firstChild);
|
|
12245
|
+
}
|
|
12246
|
+
/* Get node iterator */
|
|
12247
|
+
const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
|
|
12248
|
+
/* Now start iterating over the created document */
|
|
12249
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
12250
|
+
/* Sanitize tags and elements */
|
|
12251
|
+
_sanitizeElements(currentNode);
|
|
12252
|
+
/* Check attributes next */
|
|
12253
|
+
_sanitizeAttributes(currentNode);
|
|
12254
|
+
/* Shadow DOM detected, sanitize it */
|
|
12255
|
+
if (currentNode.content instanceof DocumentFragment) {
|
|
12256
|
+
_sanitizeShadowDOM(currentNode.content);
|
|
12257
|
+
}
|
|
12258
|
+
}
|
|
12259
|
+
/* If we sanitized `dirty` in-place, return it. */
|
|
12260
|
+
if (IN_PLACE) {
|
|
12261
|
+
return dirty;
|
|
12262
|
+
}
|
|
12263
|
+
/* Return sanitized string or DOM */
|
|
12264
|
+
if (RETURN_DOM) {
|
|
12265
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
12266
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
12267
|
+
while (body.firstChild) {
|
|
12268
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
12269
|
+
returnNode.appendChild(body.firstChild);
|
|
12270
|
+
}
|
|
12271
|
+
} else {
|
|
12272
|
+
returnNode = body;
|
|
12273
|
+
}
|
|
12274
|
+
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
|
|
12275
|
+
/*
|
|
12276
|
+
AdoptNode() is not used because internal state is not reset
|
|
12277
|
+
(e.g. the past names map of a HTMLFormElement), this is safe
|
|
12278
|
+
in theory but we would rather not risk another attack vector.
|
|
12279
|
+
The state that is cloned by importNode() is explicitly defined
|
|
12280
|
+
by the specs.
|
|
12281
|
+
*/
|
|
12282
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
12283
|
+
}
|
|
12284
|
+
return returnNode;
|
|
12285
|
+
}
|
|
12286
|
+
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
12287
|
+
/* Serialize doctype if allowed */
|
|
12288
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
12289
|
+
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
|
12290
|
+
}
|
|
12291
|
+
/* Sanitize final string template-safe */
|
|
12292
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
12293
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
12294
|
+
serializedHTML = stringReplace(serializedHTML, expr, ' ');
|
|
12295
|
+
});
|
|
12296
|
+
}
|
|
12297
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
12298
|
+
};
|
|
12299
|
+
DOMPurify.setConfig = function () {
|
|
12300
|
+
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
12301
|
+
_parseConfig(cfg);
|
|
12302
|
+
SET_CONFIG = true;
|
|
12303
|
+
};
|
|
12304
|
+
DOMPurify.clearConfig = function () {
|
|
12305
|
+
CONFIG = null;
|
|
12306
|
+
SET_CONFIG = false;
|
|
12307
|
+
};
|
|
12308
|
+
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
12309
|
+
/* Initialize shared config vars if necessary. */
|
|
12310
|
+
if (!CONFIG) {
|
|
12311
|
+
_parseConfig({});
|
|
12312
|
+
}
|
|
12313
|
+
const lcTag = transformCaseFunc(tag);
|
|
12314
|
+
const lcName = transformCaseFunc(attr);
|
|
12315
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
12316
|
+
};
|
|
12317
|
+
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
12318
|
+
if (typeof hookFunction !== 'function') {
|
|
12319
|
+
return;
|
|
12320
|
+
}
|
|
12321
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
12322
|
+
};
|
|
12323
|
+
DOMPurify.removeHook = function (entryPoint, hookFunction) {
|
|
12324
|
+
if (hookFunction !== undefined) {
|
|
12325
|
+
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
12326
|
+
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
12327
|
+
}
|
|
12328
|
+
return arrayPop(hooks[entryPoint]);
|
|
12329
|
+
};
|
|
12330
|
+
DOMPurify.removeHooks = function (entryPoint) {
|
|
12331
|
+
hooks[entryPoint] = [];
|
|
12332
|
+
};
|
|
12333
|
+
DOMPurify.removeAllHooks = function () {
|
|
12334
|
+
hooks = _createHooksMap();
|
|
12335
|
+
};
|
|
12336
|
+
return DOMPurify;
|
|
12337
|
+
}
|
|
12338
|
+
var purify = createDOMPurify();
|
|
12339
|
+
|
|
12340
|
+
purify_cjs = purify;
|
|
12341
|
+
|
|
12342
|
+
return purify_cjs;
|
|
12343
|
+
}
|
|
12344
|
+
|
|
12345
|
+
window.DOMPurify || (window.DOMPurify = requirePurify_cjs().default || requirePurify_cjs());
|
|
11713
12346
|
|
|
11714
12347
|
// src/utils/entries-to-string.ts
|
|
11715
12348
|
function entriesToString(obj, separator = "=") {
|
|
@@ -16470,10 +17103,18 @@ var HtmlWidget = /*#__PURE__*/function (_HtmlMultiWidget) {
|
|
|
16470
17103
|
}, {
|
|
16471
17104
|
key: "setFormElements",
|
|
16472
17105
|
value: function setFormElements(elements) {
|
|
16473
|
-
var
|
|
16474
|
-
|
|
16475
|
-
|
|
16476
|
-
|
|
17106
|
+
var _iterator = _createForOfIteratorHelper(elements),
|
|
17107
|
+
_step;
|
|
17108
|
+
try {
|
|
17109
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
17110
|
+
var element = _step.value;
|
|
17111
|
+
this.setFormElement(element);
|
|
17112
|
+
}
|
|
17113
|
+
} catch (err) {
|
|
17114
|
+
_iterator.e(err);
|
|
17115
|
+
} finally {
|
|
17116
|
+
_iterator.f();
|
|
17117
|
+
}
|
|
16477
17118
|
}
|
|
16478
17119
|
}, {
|
|
16479
17120
|
key: "setFormElement",
|
|
@@ -16484,17 +17125,17 @@ var HtmlWidget = /*#__PURE__*/function (_HtmlMultiWidget) {
|
|
|
16484
17125
|
})]);
|
|
16485
17126
|
}
|
|
16486
17127
|
/**
|
|
16487
|
-
|
|
16488
|
-
|
|
16489
|
-
|
|
16490
|
-
|
|
16491
|
-
|
|
16492
|
-
|
|
16493
|
-
|
|
16494
|
-
|
|
16495
|
-
|
|
16496
|
-
|
|
16497
|
-
|
|
17128
|
+
* The method to set meta information for the checkout page
|
|
17129
|
+
*
|
|
17130
|
+
* @example
|
|
17131
|
+
* config.setMeta({
|
|
17132
|
+
brand_name: 'paydock',
|
|
17133
|
+
reference: '15',
|
|
17134
|
+
email: 'wault@paydock.com'
|
|
17135
|
+
});
|
|
17136
|
+
*
|
|
17137
|
+
* @param {IPayPalMeta | IBamboraMeta} object - data which can be shown on checkout page [IPayPalMeta]{@link IPayPalMeta} [IBamboraMeta]{@link IBamboraMeta}
|
|
17138
|
+
*/
|
|
16498
17139
|
}, {
|
|
16499
17140
|
key: "setMeta",
|
|
16500
17141
|
value: function setMeta(meta) {
|
|
@@ -16508,6 +17149,37 @@ var HtmlWidget = /*#__PURE__*/function (_HtmlMultiWidget) {
|
|
|
16508
17149
|
}]);
|
|
16509
17150
|
}(HtmlMultiWidget);
|
|
16510
17151
|
|
|
17152
|
+
var InstructionModule$1 = /*#__PURE__*/function () {
|
|
17153
|
+
function InstructionModule() {
|
|
17154
|
+
_classCallCheck(this, InstructionModule);
|
|
17155
|
+
this.instructions = [];
|
|
17156
|
+
}
|
|
17157
|
+
return _createClass(InstructionModule, [{
|
|
17158
|
+
key: "getInstruction",
|
|
17159
|
+
value: function getInstruction(id) {
|
|
17160
|
+
return this.instructions.find(function (instructionClass) {
|
|
17161
|
+
return instructionClass.instruction == id;
|
|
17162
|
+
});
|
|
17163
|
+
}
|
|
17164
|
+
}]);
|
|
17165
|
+
}();
|
|
17166
|
+
|
|
17167
|
+
function InstructionModule(config) {
|
|
17168
|
+
return function (constructor) {
|
|
17169
|
+
return /*#__PURE__*/function (_constructor) {
|
|
17170
|
+
function _class() {
|
|
17171
|
+
var _this;
|
|
17172
|
+
_classCallCheck(this, _class);
|
|
17173
|
+
_this = _callSuper(this, _class, arguments);
|
|
17174
|
+
_this.instructions = config;
|
|
17175
|
+
return _this;
|
|
17176
|
+
}
|
|
17177
|
+
_inherits(_class, _constructor);
|
|
17178
|
+
return _createClass(_class);
|
|
17179
|
+
}(constructor);
|
|
17180
|
+
};
|
|
17181
|
+
}
|
|
17182
|
+
|
|
16511
17183
|
var InstructionHandler = /*#__PURE__*/function () {
|
|
16512
17184
|
function InstructionHandler(selector, formSelector, api, checkoutWidget) {
|
|
16513
17185
|
_classCallCheck(this, InstructionHandler);
|
|
@@ -17041,8 +17713,6 @@ var InstructionCardFormShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
|
17041
17713
|
}(InstructionHandler);
|
|
17042
17714
|
InstructionCardFormShow = __decorate([Instruction('instruction.card_form.show')], InstructionCardFormShow);
|
|
17043
17715
|
|
|
17044
|
-
var TEMPLATE = "\n<style>\n @import url('https://fonts.cdnfonts.com/css/segoe-ui-4');\n @import url('https://fonts.cdnfonts.com/css/droid-sans-2');\n @import url('https://fonts.cdnfonts.com/css/helvetica-neue-55');\n @import url('https://fonts.googleapis.com/css2?family=Cantarell&family=Fira+Sans&family=Oxygen&family=Roboto&family=Ubuntu&display=swap');\n \n /* RESET DEFAULT STYLES */\n *,\n *:before,\n *:after {\n box-sizing: border-box;\n }\n\n html,\n body,\n div,\n span,\n applet,\n object,\n iframe,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n p,\n blockquote,\n pre,\n a,\n abbr,\n acronym,\n address,\n big,\n cite,\n code,\n del,\n dfn,\n em,\n img,\n ins,\n kbd,\n q,\n s,\n samp,\n small,\n strike,\n strong,\n sub,\n sup,\n tt,\n var,\n b,\n u,\n i,\n center,\n dl,\n dt,\n dd,\n ol,\n ul,\n li,\n fieldset,\n form,\n label,\n legend,\n table,\n caption,\n tbody,\n tfoot,\n thead,\n tr,\n th,\n td,\n article,\n aside,\n canvas,\n details,\n embed,\n figure,\n figcaption,\n footer,\n header,\n hgroup,\n menu,\n nav,\n output,\n ruby,\n section,\n summary,\n time,\n mark,\n audio,\n video,\n input {\n margin: 0;\n padding: 0;\n border: 0;\n font-size: 100%;\n font: inherit;\n vertical-align: baseline;\n }\n\n article,\n aside,\n details,\n figcaption,\n figure,\n footer,\n header,\n hgroup,\n menu,\n nav,\n section {\n display: block;\n }\n\n body {\n line-height: 1;\n }\n\n ol,\n ul {\n list-style: none;\n }\n\n ul {\n padding: 0;\n margin: 0;\n }\n\n /* MAIN STYLES */\n .wrap {\n padding: 10px;\n background-color: {{background_color}};\n }\n\n .widget-body {\n background-color: #fff;\n border: 1px solid {{border_color}};\n }\n\n .payment-source {\n cursor: pointer;\n padding: 1em 0.8em;\n display: flex;\n align-items: center;\n height: 70px;\n }\n\n .payment-source:not(:last-child) {\n border-bottom: 1px solid {{border_color}};\n }\n\n .payment-source__wrap {\n display: flex;\n align-items: center;\n font-family: {{font_family}};\n font-size: {{font_size}};\n color: {{text_color}}\n }\n\n .payment-source__radio {\n margin-right: 2em;\n width: 18px;\n min-width: 18px;\n height: 18px;\n border: 1px solid {{button_color}};\n border-radius: 50%;\n appearance: none;\n cursor: pointer;\n\n @media screen and (max-width: 380px) {\n margin-right: 1em;\n }\n }\n\n .payment-source__radio::before {\n content: \"\";\n display: block;\n width: 100%;\n height: 100%;\n background-color: #fff;\n border-radius: 50%;\n }\n\n .payment-source__radio:checked::before {\n border: 4px solid {{button_color}};\n outline: 1px solid {{button_color}};\n }\n\n .payment-source__title {\n margin-right: 2em;\n font-weight: 400;\n line-height: 1.2;\n\n @media screen and (max-width: 380px) {\n margin-right: 1em;\n font-size: 14px;\n }\n }\n\n .payment-source__icon {\n margin-right: 2em;\n max-height: 35px;\n\n @media screen and (max-width: 380px) {\n margin-right: 1em;\n }\n }\n\n .payment-source .card__scheme {\n margin-left: auto;\n display: flex;\n align-items: center;\n }\n\n .payment-source .card__scheme__item:not(:last-child) {\n margin-right: 10px;\n }\n\n .payment-source .card__scheme__img {\n max-width: 50px;\n\n @media screen and (max-width: 460px) {\n max-width: 40px;\n }\n\n @media screen and (max-width: 410px) {\n max-width: 30px;\n }\n }\n\n .payment-source__form {\n margin-top: 1em;\n margin-bottom: 1em;\n margin-left: calc(2em + 18px);\n\n @media screen and (max-width: 380px) {\n margin-left: calc(1em + 18px);\n }\n }\n\n .payment-source__form .form-group:not(:last-child) {\n margin-bottom: 1.5em;\n }\n\n .payment-source__form .form-control {\n padding: 10px 2px 10px 10px;\n height: 40px;\n background: #F9F9F9;\n border: 1px solid {{border_color}};\n }\n\n .payment-source__form .form-control:not(:last-child) {\n margin-right: 1.5em;\n }\n\n .payment-source__form .form-control.col-12 {\n width: calc(100% - 1.5em);\n }\n\n .payment-source__form .form-control.col-3 {\n width: calc(33.33% - 1.5em);\n }\n\n .footer__pay-btn {\n margin-left: auto;\n padding: 10px 2em;\n height: 50px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #F6F0EB;\n font-size: 16px;\n background-color: {{button_color}};\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.10), 0 0 0 0.5px rgba(0, 0, 0, 0.10);\n border: none;\n border-radius: 6px;\n cursor: pointer;\n }\n\n .footer__pay-btn--paypal {\n padding: 5px 2em;\n background-color: #FFC43A;\n }\n\n .footer__pay-btn--gpay {\n font-size: 22px;\n }\n\n .footer__pay-btn--gpay img {\n margin-left: 5px;\n }\n\n .footer__pay-btn img {\n max-height: 100%;\n }\n</style>\n<main class=\"wrap\">\n <div class=\"widget-body\">\n <ul class=\"payment-sources__list\">\n {{paymentMethods}}\n </ul>\n </div>\n</main>\n</div>\n";
|
|
17045
|
-
|
|
17046
17716
|
var PAYMENT_METHOD = {
|
|
17047
17717
|
card: "<label class=\"payment-source\">\n <li class=\"payment-source\">\n <div class=\"payment-source__wrap\">\n <input class=\"payment-source__radio\" pm-button=\"card\" type=\"radio\" name=\"radio-group\" />\n <h2 class=\"payment-source__title\">Pay with Credit or Debit card</h2>\n </div>\n </li>\n </label>",
|
|
17048
17718
|
bank_account: "<label class=\"payment-source\">\n <li class=\"payment-source\">\n <div class=\"payment-source__wrap\">\n <input class=\"payment-source__radio\" pm-button=\"bank_account\" type=\"radio\" name=\"radio-group\" />\n <h2 class=\"payment-source__title\">Pay Bank Account</h2>\n </div>\n </li>\n </label>",
|
|
@@ -17055,11 +17725,13 @@ var PAYMENT_METHOD = {
|
|
|
17055
17725
|
afterpay_checkout: "<label class=\"payment-source\">\n <li class=\"payment-source\">\n <div class=\"payment-source__wrap\">\n <input class=\"payment-source__radio\" pm-button=\"afterpay_checkout\" type=\"radio\" name=\"radio-group\">\n ".concat(getIcon(paymentMethods.AFTERPAY), "\n </div>\n </li>\n </label>")
|
|
17056
17726
|
};
|
|
17057
17727
|
|
|
17728
|
+
var TEMPLATE = "\n<style>\n @import url('https://fonts.cdnfonts.com/css/segoe-ui-4');\n @import url('https://fonts.cdnfonts.com/css/droid-sans-2');\n @import url('https://fonts.cdnfonts.com/css/helvetica-neue-55');\n @import url('https://fonts.googleapis.com/css2?family=Cantarell&family=Fira+Sans&family=Oxygen&family=Roboto&family=Ubuntu&display=swap');\n \n /* RESET DEFAULT STYLES */\n *,\n *:before,\n *:after {\n box-sizing: border-box;\n }\n\n html,\n body,\n div,\n span,\n applet,\n object,\n iframe,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n p,\n blockquote,\n pre,\n a,\n abbr,\n acronym,\n address,\n big,\n cite,\n code,\n del,\n dfn,\n em,\n img,\n ins,\n kbd,\n q,\n s,\n samp,\n small,\n strike,\n strong,\n sub,\n sup,\n tt,\n var,\n b,\n u,\n i,\n center,\n dl,\n dt,\n dd,\n ol,\n ul,\n li,\n fieldset,\n form,\n label,\n legend,\n table,\n caption,\n tbody,\n tfoot,\n thead,\n tr,\n th,\n td,\n article,\n aside,\n canvas,\n details,\n embed,\n figure,\n figcaption,\n footer,\n header,\n hgroup,\n menu,\n nav,\n output,\n ruby,\n section,\n summary,\n time,\n mark,\n audio,\n video,\n input {\n margin: 0;\n padding: 0;\n border: 0;\n font-size: 100%;\n font: inherit;\n vertical-align: baseline;\n }\n\n article,\n aside,\n details,\n figcaption,\n figure,\n footer,\n header,\n hgroup,\n menu,\n nav,\n section {\n display: block;\n }\n\n body {\n line-height: 1;\n }\n\n ol,\n ul {\n list-style: none;\n }\n\n ul {\n padding: 0;\n margin: 0;\n }\n\n /* MAIN STYLES */\n .wrap {\n padding: 10px;\n background-color: {{background_color}};\n }\n\n .widget-body {\n background-color: #fff;\n border: 1px solid {{border_color}};\n }\n\n .payment-source {\n cursor: pointer;\n padding: 1em 0.8em;\n display: flex;\n align-items: center;\n height: 70px;\n }\n\n .payment-source:not(:last-child) {\n border-bottom: 1px solid {{border_color}};\n }\n\n .payment-source__wrap {\n display: flex;\n align-items: center;\n font-family: {{font_family}};\n font-size: {{font_size}};\n color: {{text_color}}\n }\n\n .payment-source__radio {\n margin-right: 2em;\n width: 18px;\n min-width: 18px;\n height: 18px;\n border: 1px solid {{button_color}};\n border-radius: 50%;\n appearance: none;\n cursor: pointer;\n\n @media screen and (max-width: 380px) {\n margin-right: 1em;\n }\n }\n\n .payment-source__radio::before {\n content: \"\";\n display: block;\n width: 100%;\n height: 100%;\n background-color: #fff;\n border-radius: 50%;\n }\n\n .payment-source__radio:checked::before {\n border: 4px solid {{button_color}};\n outline: 1px solid {{button_color}};\n }\n\n .payment-source__title {\n margin-right: 2em;\n font-weight: 400;\n line-height: 1.2;\n\n @media screen and (max-width: 380px) {\n margin-right: 1em;\n font-size: 14px;\n }\n }\n\n .payment-source__icon {\n margin-right: 2em;\n max-height: 35px;\n\n @media screen and (max-width: 380px) {\n margin-right: 1em;\n }\n }\n\n .payment-source .card__scheme {\n margin-left: auto;\n display: flex;\n align-items: center;\n }\n\n .payment-source .card__scheme__item:not(:last-child) {\n margin-right: 10px;\n }\n\n .payment-source .card__scheme__img {\n max-width: 50px;\n\n @media screen and (max-width: 460px) {\n max-width: 40px;\n }\n\n @media screen and (max-width: 410px) {\n max-width: 30px;\n }\n }\n\n .payment-source__form {\n margin-top: 1em;\n margin-bottom: 1em;\n margin-left: calc(2em + 18px);\n\n @media screen and (max-width: 380px) {\n margin-left: calc(1em + 18px);\n }\n }\n\n .payment-source__form .form-group:not(:last-child) {\n margin-bottom: 1.5em;\n }\n\n .payment-source__form .form-control {\n padding: 10px 2px 10px 10px;\n height: 40px;\n background: #F9F9F9;\n border: 1px solid {{border_color}};\n }\n\n .payment-source__form .form-control:not(:last-child) {\n margin-right: 1.5em;\n }\n\n .payment-source__form .form-control.col-12 {\n width: calc(100% - 1.5em);\n }\n\n .payment-source__form .form-control.col-3 {\n width: calc(33.33% - 1.5em);\n }\n\n .footer__pay-btn {\n margin-left: auto;\n padding: 10px 2em;\n height: 50px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #F6F0EB;\n font-size: 16px;\n background-color: {{button_color}};\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.10), 0 0 0 0.5px rgba(0, 0, 0, 0.10);\n border: none;\n border-radius: 6px;\n cursor: pointer;\n }\n\n .footer__pay-btn--paypal {\n padding: 5px 2em;\n background-color: #FFC43A;\n }\n\n .footer__pay-btn--gpay {\n font-size: 22px;\n }\n\n .footer__pay-btn--gpay img {\n margin-left: 5px;\n }\n\n .footer__pay-btn img {\n max-height: 100%;\n }\n</style>\n<main class=\"wrap\">\n <div class=\"widget-body\">\n <ul class=\"payment-sources__list\">\n {{paymentMethods}}\n </ul>\n </div>\n</main>\n</div>\n";
|
|
17729
|
+
|
|
17058
17730
|
var PAYMENTS_METHODS = {
|
|
17059
|
-
APPLE_PAY:
|
|
17060
|
-
GOOGLE_PAY:
|
|
17731
|
+
APPLE_PAY: 'applepay_wallet',
|
|
17732
|
+
GOOGLE_PAY: 'googlepay_wallet'
|
|
17061
17733
|
};
|
|
17062
|
-
var PAYMENT_METHOD_ORDER = [
|
|
17734
|
+
var PAYMENT_METHOD_ORDER = ['card', 'afterpay_checkout', 'applepay_wallet', 'googlepay_wallet', 'paypal_wallet', 'zip_checkout'];
|
|
17063
17735
|
var PaymentMethods = /*#__PURE__*/function () {
|
|
17064
17736
|
function PaymentMethods(selector, methods, styles, chosen, instruction_token) {
|
|
17065
17737
|
var skip = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
@@ -17083,51 +17755,24 @@ var PaymentMethods = /*#__PURE__*/function () {
|
|
|
17083
17755
|
var _this = this;
|
|
17084
17756
|
this.setPaymentMethodsOrder();
|
|
17085
17757
|
this.setStylesToStandaloneWidget();
|
|
17086
|
-
var initState = new Promise(function (resolve,
|
|
17087
|
-
|
|
17088
|
-
|
|
17089
|
-
|
|
17090
|
-
|
|
17091
|
-
|
|
17092
|
-
|
|
17093
|
-
|
|
17094
|
-
|
|
17095
|
-
_iterator.s();
|
|
17096
|
-
case 4:
|
|
17097
|
-
if ((_step = _iterator.n()).done) {
|
|
17098
|
-
_context.next = 11;
|
|
17099
|
-
break;
|
|
17100
|
-
}
|
|
17101
|
-
method = _step.value;
|
|
17102
|
-
if (!(method === PAYMENTS_METHODS.APPLE_PAY && !this.isApplePaySupported())) {
|
|
17103
|
-
_context.next = 8;
|
|
17104
|
-
break;
|
|
17105
|
-
}
|
|
17106
|
-
return _context.abrupt("continue", 9);
|
|
17107
|
-
case 8:
|
|
17108
|
-
paymentMethodsAllowed.push(PAYMENT_METHOD[method]);
|
|
17109
|
-
case 9:
|
|
17110
|
-
_context.next = 4;
|
|
17111
|
-
break;
|
|
17112
|
-
case 11:
|
|
17113
|
-
_context.next = 16;
|
|
17114
|
-
break;
|
|
17115
|
-
case 13:
|
|
17116
|
-
_context.prev = 13;
|
|
17117
|
-
_context.t0 = _context["catch"](2);
|
|
17118
|
-
_iterator.e(_context.t0);
|
|
17119
|
-
case 16:
|
|
17120
|
-
_context.prev = 16;
|
|
17121
|
-
_iterator.f();
|
|
17122
|
-
return _context.finish(16);
|
|
17123
|
-
case 19:
|
|
17124
|
-
resolve(paymentMethodsAllowed.join(' '));
|
|
17125
|
-
case 20:
|
|
17126
|
-
case "end":
|
|
17127
|
-
return _context.stop();
|
|
17758
|
+
var initState = new Promise(function (resolve, _reject) {
|
|
17759
|
+
var paymentMethodsAllowed = [];
|
|
17760
|
+
var _iterator = _createForOfIteratorHelper(_this.methods),
|
|
17761
|
+
_step;
|
|
17762
|
+
try {
|
|
17763
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
17764
|
+
var method = _step.value;
|
|
17765
|
+
if (method === PAYMENTS_METHODS.APPLE_PAY && !_this.isApplePaySupported()) {
|
|
17766
|
+
continue;
|
|
17128
17767
|
}
|
|
17129
|
-
|
|
17130
|
-
|
|
17768
|
+
paymentMethodsAllowed.push(PAYMENT_METHOD[method]);
|
|
17769
|
+
}
|
|
17770
|
+
} catch (err) {
|
|
17771
|
+
_iterator.e(err);
|
|
17772
|
+
} finally {
|
|
17773
|
+
_iterator.f();
|
|
17774
|
+
}
|
|
17775
|
+
resolve(paymentMethodsAllowed.join(' '));
|
|
17131
17776
|
});
|
|
17132
17777
|
initState.then(function (content) {
|
|
17133
17778
|
var template = _this.setStyles(content);
|
|
@@ -17139,7 +17784,7 @@ var PaymentMethods = /*#__PURE__*/function () {
|
|
|
17139
17784
|
_this.setListenerButtons(iframeDocument);
|
|
17140
17785
|
_this.iFrame.setIframeHeight(iframeElement, iframeDocument, '.wrap');
|
|
17141
17786
|
} else {
|
|
17142
|
-
_this.iFrame.getElement().addEventListener(
|
|
17787
|
+
_this.iFrame.getElement().addEventListener('load', function (event) {
|
|
17143
17788
|
_this.setListenerButtons(iframeDocument);
|
|
17144
17789
|
_this.iFrame.setIframeHeight(iframeElement, iframeDocument, '.wrap');
|
|
17145
17790
|
});
|
|
@@ -17150,26 +17795,37 @@ var PaymentMethods = /*#__PURE__*/function () {
|
|
|
17150
17795
|
key: "setListenerButtons",
|
|
17151
17796
|
value: function setListenerButtons(iframeDocument) {
|
|
17152
17797
|
var _this2 = this;
|
|
17153
|
-
var selectedPaymentMethod =
|
|
17798
|
+
var selectedPaymentMethod = '';
|
|
17154
17799
|
Spinner.hide();
|
|
17155
17800
|
var buttons = iframeDocument.querySelectorAll('[pm-button]');
|
|
17156
|
-
|
|
17157
|
-
|
|
17158
|
-
|
|
17159
|
-
|
|
17160
|
-
|
|
17161
|
-
|
|
17162
|
-
|
|
17163
|
-
|
|
17164
|
-
|
|
17165
|
-
|
|
17166
|
-
|
|
17801
|
+
var _iterator2 = _createForOfIteratorHelper(buttons),
|
|
17802
|
+
_step2;
|
|
17803
|
+
try {
|
|
17804
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
17805
|
+
var button = _step2.value;
|
|
17806
|
+
button.addEventListener('click', function (event) {
|
|
17807
|
+
var clickedButton = event.target;
|
|
17808
|
+
var customAttributeValue = clickedButton.getAttribute('pm-button');
|
|
17809
|
+
if (selectedPaymentMethod !== customAttributeValue && !_this2.disablePaymentMethodOptions) {
|
|
17810
|
+
_this2.chosen(customAttributeValue);
|
|
17811
|
+
selectedPaymentMethod = customAttributeValue;
|
|
17812
|
+
Spinner.show();
|
|
17813
|
+
}
|
|
17814
|
+
});
|
|
17815
|
+
}
|
|
17816
|
+
} catch (err) {
|
|
17817
|
+
_iterator2.e(err);
|
|
17818
|
+
} finally {
|
|
17819
|
+
_iterator2.f();
|
|
17820
|
+
}
|
|
17167
17821
|
}
|
|
17168
17822
|
}, {
|
|
17169
17823
|
key: "setEnv",
|
|
17170
17824
|
value: function setEnv(instruction_token) {
|
|
17171
17825
|
var tokenContent = AccessToken.validateJWT(instruction_token);
|
|
17172
|
-
if (!tokenContent)
|
|
17826
|
+
if (!tokenContent) {
|
|
17827
|
+
throw new Error('Invalid instruction token.');
|
|
17828
|
+
}
|
|
17173
17829
|
return AccessToken.extractEnv(tokenContent.body);
|
|
17174
17830
|
}
|
|
17175
17831
|
}, {
|
|
@@ -17178,7 +17834,9 @@ var PaymentMethods = /*#__PURE__*/function () {
|
|
|
17178
17834
|
var _a, _b, _c, _d, _e, _f;
|
|
17179
17835
|
var template = TEMPLATE.replace('{{paymentMethods}}', content);
|
|
17180
17836
|
var listElement = document === null || document === void 0 ? void 0 : document.querySelector(SELECTORS.LIST);
|
|
17181
|
-
if (listElement)
|
|
17837
|
+
if (listElement) {
|
|
17838
|
+
listElement.style.backgroundColor = this.styles.background_color || DEFAULT_VARIABLES.BG_COLOR;
|
|
17839
|
+
}
|
|
17182
17840
|
template = ((_a = this.styles) === null || _a === void 0 ? void 0 : _a.button_color) ? template.replace(/{{button_color}}/g, this.styles.button_color) : template.replace(/{{button_color}}/g, DEFAULT_VARIABLES.BTN_COLOR);
|
|
17183
17841
|
template = ((_b = this.styles) === null || _b === void 0 ? void 0 : _b.border_color) ? template.replace(/{{border_color}}/g, this.styles.border_color) : template.replace(/{{border_color}}/g, DEFAULT_VARIABLES.BORDER_COLOR);
|
|
17184
17842
|
template = ((_c = this.styles) === null || _c === void 0 ? void 0 : _c.background_color) ? template.replace(/{{background_color}}/g, this.styles.background_color) : template.replace(/{{background_color}}/g, DEFAULT_VARIABLES.BG_COLOR);
|
|
@@ -17202,7 +17860,9 @@ var PaymentMethods = /*#__PURE__*/function () {
|
|
|
17202
17860
|
key: "setPaymentMethodsOrder",
|
|
17203
17861
|
value: function setPaymentMethodsOrder() {
|
|
17204
17862
|
var _a;
|
|
17205
|
-
if (!((_a = this.methods) === null || _a === void 0 ? void 0 : _a.length))
|
|
17863
|
+
if (!((_a = this.methods) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
17864
|
+
return this.methods;
|
|
17865
|
+
}
|
|
17206
17866
|
this.methods.sort(function (a, b) {
|
|
17207
17867
|
return PAYMENT_METHOD_ORDER.indexOf(a) - PAYMENT_METHOD_ORDER.indexOf(b);
|
|
17208
17868
|
});
|
|
@@ -17215,25 +17875,62 @@ var PaymentMethods = /*#__PURE__*/function () {
|
|
|
17215
17875
|
var iframe = document === null || document === void 0 ? void 0 : document.querySelector("".concat(SELECTORS.LIST, " iframe"));
|
|
17216
17876
|
var iframeDocument = iframe.contentDocument || ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document);
|
|
17217
17877
|
if (iframeDocument) {
|
|
17218
|
-
var
|
|
17219
|
-
var
|
|
17220
|
-
|
|
17221
|
-
|
|
17222
|
-
|
|
17223
|
-
|
|
17224
|
-
|
|
17225
|
-
labels.forEach(function (label) {
|
|
17226
|
-
label.style.cursor = "not-allowed";
|
|
17227
|
-
});
|
|
17228
|
-
radioButton.style.cursor = "not-allowed";
|
|
17229
|
-
if (!radioButton.checked) {
|
|
17230
|
-
radioButton.style.border = "9px solid #EBEBE4";
|
|
17878
|
+
var labels = this.queryAllPaymentSource(iframeDocument);
|
|
17879
|
+
var _iterator3 = _createForOfIteratorHelper(labels),
|
|
17880
|
+
_step3;
|
|
17881
|
+
try {
|
|
17882
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
17883
|
+
var label = _step3.value;
|
|
17884
|
+
label.style.cursor = 'not-allowed';
|
|
17231
17885
|
}
|
|
17232
|
-
|
|
17233
|
-
|
|
17234
|
-
}
|
|
17886
|
+
} catch (err) {
|
|
17887
|
+
_iterator3.e(err);
|
|
17888
|
+
} finally {
|
|
17889
|
+
_iterator3.f();
|
|
17890
|
+
}
|
|
17891
|
+
var radiosButtons = this.queryAllPaymentSourceRadioButtons(iframeDocument);
|
|
17892
|
+
var _iterator4 = _createForOfIteratorHelper(radiosButtons),
|
|
17893
|
+
_step4;
|
|
17894
|
+
try {
|
|
17895
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
17896
|
+
var radioButton = _step4.value;
|
|
17897
|
+
var _labels = this.queryAllPaymentSource(iframeDocument);
|
|
17898
|
+
var _iterator5 = _createForOfIteratorHelper(_labels),
|
|
17899
|
+
_step5;
|
|
17900
|
+
try {
|
|
17901
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
17902
|
+
var _label = _step5.value;
|
|
17903
|
+
_label.style.cursor = 'not-allowed';
|
|
17904
|
+
}
|
|
17905
|
+
} catch (err) {
|
|
17906
|
+
_iterator5.e(err);
|
|
17907
|
+
} finally {
|
|
17908
|
+
_iterator5.f();
|
|
17909
|
+
}
|
|
17910
|
+
radioButton.style.cursor = 'not-allowed';
|
|
17911
|
+
if (!radioButton.checked) {
|
|
17912
|
+
radioButton.style.border = '9px solid #EBEBE4';
|
|
17913
|
+
}
|
|
17914
|
+
radioButton.disabled = true;
|
|
17915
|
+
radioButton.classList.add('disabled');
|
|
17916
|
+
}
|
|
17917
|
+
} catch (err) {
|
|
17918
|
+
_iterator4.e(err);
|
|
17919
|
+
} finally {
|
|
17920
|
+
_iterator4.f();
|
|
17921
|
+
}
|
|
17235
17922
|
}
|
|
17236
17923
|
}
|
|
17924
|
+
}, {
|
|
17925
|
+
key: "queryAllPaymentSource",
|
|
17926
|
+
value: function queryAllPaymentSource(iframeDocument) {
|
|
17927
|
+
return iframeDocument.querySelectorAll('.payment-source');
|
|
17928
|
+
}
|
|
17929
|
+
}, {
|
|
17930
|
+
key: "queryAllPaymentSourceRadioButtons",
|
|
17931
|
+
value: function queryAllPaymentSourceRadioButtons(iframeDocument) {
|
|
17932
|
+
return iframeDocument.querySelectorAll('input[type="radio"].payment-source__radio');
|
|
17933
|
+
}
|
|
17237
17934
|
}]);
|
|
17238
17935
|
}();
|
|
17239
17936
|
|
|
@@ -17264,6 +17961,78 @@ var instructionDisablePaymentMethod = /*#__PURE__*/function (_InstructionHandler
|
|
|
17264
17961
|
}(InstructionHandler);
|
|
17265
17962
|
instructionDisablePaymentMethod = __decorate([Instruction("instruction.disable_payment_method_event.emit")], instructionDisablePaymentMethod);
|
|
17266
17963
|
|
|
17964
|
+
var InstructionFraudServiceShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
17965
|
+
function InstructionFraudServiceShow() {
|
|
17966
|
+
_classCallCheck(this, InstructionFraudServiceShow);
|
|
17967
|
+
return _callSuper(this, InstructionFraudServiceShow, arguments);
|
|
17968
|
+
}
|
|
17969
|
+
_inherits(InstructionFraudServiceShow, _InstructionHandler);
|
|
17970
|
+
return _createClass(InstructionFraudServiceShow, [{
|
|
17971
|
+
key: "handle",
|
|
17972
|
+
value: function handle(context) {
|
|
17973
|
+
var _this = this;
|
|
17974
|
+
var _a;
|
|
17975
|
+
document.addEventListener(FRAUD_PREVENTION_EVENTS.NAMESPACE, function (event) {
|
|
17976
|
+
switch (event.detail.type) {
|
|
17977
|
+
case FRAUD_PREVENTION_EVENTS.TYPES.FINTERPRINT_TOKEN_READY:
|
|
17978
|
+
{
|
|
17979
|
+
_this.api.checkout().callback({
|
|
17980
|
+
event: 'callback.fraud_service.status',
|
|
17981
|
+
payload: {
|
|
17982
|
+
status: 'success',
|
|
17983
|
+
fraud_service_token: event.detail.payload.token
|
|
17984
|
+
}
|
|
17985
|
+
}).then(function () {
|
|
17986
|
+
return console.info('callback.fraud_service.status: ok');
|
|
17987
|
+
})["catch"](function (response) {
|
|
17988
|
+
console.error('callback.fraud_service.status: ok', response);
|
|
17989
|
+
Spinner.hide();
|
|
17990
|
+
});
|
|
17991
|
+
break;
|
|
17992
|
+
}
|
|
17993
|
+
case FRAUD_PREVENTION_EVENTS.TYPES.FINGERPRINT_TOKEN_ERROR:
|
|
17994
|
+
{
|
|
17995
|
+
_this.api.checkout().callback({
|
|
17996
|
+
event: 'callback.fraud_service.status',
|
|
17997
|
+
payload: {
|
|
17998
|
+
status: 'error',
|
|
17999
|
+
message: event.detail.payload.code || 'error in fraud service widget'
|
|
18000
|
+
}
|
|
18001
|
+
}).then(function () {
|
|
18002
|
+
return console.info('callback.fraud_service.status: ok');
|
|
18003
|
+
})["catch"](function (response) {
|
|
18004
|
+
Spinner.hide();
|
|
18005
|
+
console.error('callback.fraud_service.status: error', response);
|
|
18006
|
+
});
|
|
18007
|
+
break;
|
|
18008
|
+
}
|
|
18009
|
+
default:
|
|
18010
|
+
{
|
|
18011
|
+
throw new Error("".concat(FRAUD_PREVENTION_EVENTS.NAMESPACE, " emitted an unsupported event: ").concat(JSON.stringify(event.detail), "."));
|
|
18012
|
+
}
|
|
18013
|
+
}
|
|
18014
|
+
});
|
|
18015
|
+
this.fps = new FraudPreventionService({
|
|
18016
|
+
environmentId: this.getEnv(context.instruction_token),
|
|
18017
|
+
mode: 'live'
|
|
18018
|
+
});
|
|
18019
|
+
this.fps.withAccessTokenStrategy(context.instruction_token).withForter({
|
|
18020
|
+
providerId: context.payload.gateway_id,
|
|
18021
|
+
csp: false
|
|
18022
|
+
});
|
|
18023
|
+
if (context.next_instruction) {
|
|
18024
|
+
(_a = this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
|
|
18025
|
+
}
|
|
18026
|
+
}
|
|
18027
|
+
}, {
|
|
18028
|
+
key: "destroy",
|
|
18029
|
+
value: function destroy() {
|
|
18030
|
+
// document.querySelector(this.formSelector).innerHTML = '';
|
|
18031
|
+
}
|
|
18032
|
+
}]);
|
|
18033
|
+
}(InstructionHandler);
|
|
18034
|
+
InstructionFraudServiceShow = __decorate([Instruction('instruction.fraud_service.show')], InstructionFraudServiceShow);
|
|
18035
|
+
|
|
17267
18036
|
var MESSAGE_WIDGET_STYLE = {
|
|
17268
18037
|
TEXT_COLOR: 'text_color',
|
|
17269
18038
|
FONT_SIZE: 'font_size',
|
|
@@ -17470,39 +18239,6 @@ var InstructionMerchantEventEmit = /*#__PURE__*/function (_InstructionHandler) {
|
|
|
17470
18239
|
}(InstructionHandler);
|
|
17471
18240
|
InstructionMerchantEventEmit = __decorate([Instruction("instruction.merchant_event.emit")], InstructionMerchantEventEmit);
|
|
17472
18241
|
|
|
17473
|
-
var InstructionModule$1 = /*#__PURE__*/function () {
|
|
17474
|
-
function InstructionModule() {
|
|
17475
|
-
_classCallCheck(this, InstructionModule);
|
|
17476
|
-
this.instructions = [];
|
|
17477
|
-
}
|
|
17478
|
-
return _createClass(InstructionModule, [{
|
|
17479
|
-
key: "getInstruction",
|
|
17480
|
-
value: function getInstruction(id) {
|
|
17481
|
-
return this.instructions
|
|
17482
|
-
// tslint:disable-next-line:triple-equals
|
|
17483
|
-
.find(function (instructionClass) {
|
|
17484
|
-
return instructionClass.instruction == id;
|
|
17485
|
-
});
|
|
17486
|
-
}
|
|
17487
|
-
}]);
|
|
17488
|
-
}();
|
|
17489
|
-
|
|
17490
|
-
function InstructionModule(config) {
|
|
17491
|
-
return function (constructor) {
|
|
17492
|
-
return /*#__PURE__*/function (_constructor) {
|
|
17493
|
-
function _class() {
|
|
17494
|
-
var _this;
|
|
17495
|
-
_classCallCheck(this, _class);
|
|
17496
|
-
_this = _callSuper(this, _class, arguments);
|
|
17497
|
-
_this.instructions = config;
|
|
17498
|
-
return _this;
|
|
17499
|
-
}
|
|
17500
|
-
_inherits(_class, _constructor);
|
|
17501
|
-
return _createClass(_class);
|
|
17502
|
-
}(constructor);
|
|
17503
|
-
};
|
|
17504
|
-
}
|
|
17505
|
-
|
|
17506
18242
|
var InstructionPaymentMethodShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
17507
18243
|
function InstructionPaymentMethodShow() {
|
|
17508
18244
|
_classCallCheck(this, InstructionPaymentMethodShow);
|
|
@@ -17514,7 +18250,6 @@ var InstructionPaymentMethodShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
|
17514
18250
|
value: function handle(context) {
|
|
17515
18251
|
var _this = this;
|
|
17516
18252
|
var _a;
|
|
17517
|
-
// tslint:disable-next-line:no-unused-expression
|
|
17518
18253
|
new PaymentMethods(this.selector, context.payload.allowed_payment_method_types, ((_a = context.payload.customisation) === null || _a === void 0 ? void 0 : _a.base) || {}, function (type) {
|
|
17519
18254
|
var _a;
|
|
17520
18255
|
(_a = _this.checkoutWidget) === null || _a === void 0 ? void 0 : _a.fetchInstruction();
|
|
@@ -17724,7 +18459,7 @@ var InstructionModuleV1 = /*#__PURE__*/function (_Module) {
|
|
|
17724
18459
|
_inherits(InstructionModuleV1, _Module);
|
|
17725
18460
|
return _createClass(InstructionModuleV1);
|
|
17726
18461
|
}(InstructionModule$1);
|
|
17727
|
-
InstructionModuleV1 = __decorate([InstructionModule([InstructionAfterpayCheckoutFormShow, InstructionAfterpayWalletFormShow, InstructionApplePayFormShow, InstructionBankAccountFormShow, InstructionCanvas3dsShow, InstructionCardFormShow,
|
|
18462
|
+
InstructionModuleV1 = __decorate([InstructionModule([InstructionAfterpayCheckoutFormShow, InstructionAfterpayWalletFormShow, InstructionApplePayFormShow, InstructionBankAccountFormShow, InstructionCanvas3dsShow, InstructionCardFormShow, InstructionFraudServiceShow, InstructionGenericShowMessage, InstructionGooglePayFormShow, InstructionMerchantEventEmit, InstructionPaymentMethodShow, InstructionPaypalFormShow, InstructionZipCheckoutFormShow, InstructionZipCheckoutFormShow, instructionDisablePaymentMethod])], InstructionModuleV1);
|
|
17728
18463
|
|
|
17729
18464
|
function getVersionInstructions(version) {
|
|
17730
18465
|
switch (version) {
|
|
@@ -17735,7 +18470,7 @@ function getVersionInstructions(version) {
|
|
|
17735
18470
|
}
|
|
17736
18471
|
}
|
|
17737
18472
|
|
|
17738
|
-
var additional = "\n<style>\n #standaloneWidget iframe[title=\"3d secure authentication\"],\n #standaloneWidget .threeDSecure-iframe {\n height: 420px;\n }\n #standaloneWidget iframe, #list iframe {\n display: block;\n max-width: 640px;\n min-width:
|
|
18473
|
+
var additional = "\n<style>\n #standaloneWidget iframe[title=\"3d secure authentication\"],\n #standaloneWidget .threeDSecure-iframe {\n height: 420px;\n }\n #standaloneWidget iframe, #list iframe {\n display: block;\n max-width: 640px;\n min-width: 200px;\n width: 100%;\n border-width: 0;\n }\n .spinner-wrapper {\n position: absolute;\n width: calc(100% + 1px);\n height: calc(100% + 1px);\n top: 0;\n left: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n z-index: 999;\n }\n \n .spinner-wrapper svg {\n position: absolute;\n\n height: 50px;\n width: 50px;\n z-index: 1000;\n }\n \n .spinner-wrapper .background {\n margin: 0 !important;\n background: #f9f9f9;\n color: #f9f9f9;\n word-break: break-all;\n white-space: pre-wrap;\n width: 100%;\n height: 100%;\n }\n \n .spinner-wrapper--hidden {\n display: none;\n }\n @media screen and (max-width: 450px) {\n #standaloneWidget button {\n width: 100% !important;\n }\n }\n @media screen and (max-width: 450px) {\n #standaloneWidget .paypal-buttons {\n margin: 0 10px 10px 10px;\n }\n }\n @media screen and (min-width: 451px) {\n #standaloneWidget .paypal-buttons {\n padding-bottom: 12px;\n right: 10px;\n max-width: 320px;\n }\n }\n @media screen and (min-width: 451px) {\n #standaloneWidget #gpay-button-online-api-id {\n max-width: 311px;\n margin-bottom: 11px;\n right: 11px;\n }\n }\n @media screen and (max-width: 450px) {\n #standaloneWidget .gpay-card-info-container-fill {\n margin: 0 10px 5px 10px;\n }\n }\n \n apple-pay-button {\n padding: 0 10px 20px;\n max-width: 320px;\n }\n \n @media screen and (max-width: 450px) {\n apple-pay-button {\n max-width: 100%;\n }\n }\n</style>\n<div id=\"spinner\" class=\"spinner-wrapper spinner-wrapper--hidden\">\n <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><radialGradient id='a5' cx='.66' fx='.66' cy='.3125' fy='.3125' gradientTransform='scale(1.5)'><stop offset='0' stop-color='#191919'></stop><stop offset='.3' stop-color='#191919' stop-opacity='.9'></stop><stop offset='.6' stop-color='#191919' stop-opacity='.6'></stop><stop offset='.8' stop-color='#191919' stop-opacity='.3'></stop><stop offset='1' stop-color='#191919' stop-opacity='0'></stop></radialGradient><circle transform-origin='center' fill='none' stroke='url(#a5)' stroke-width='30' stroke-linecap='round' stroke-dasharray='200 1000' stroke-dashoffset='0' cx='100' cy='100' r='70'><animateTransform type='rotate' attributeName='transform' calcMode='spline' dur='1' values='360;0' keyTimes='0;1' keySplines='0 0 1 1' repeatCount='indefinite'></animateTransform></circle><circle transform-origin='center' fill='none' opacity='.2' stroke='#191919' stroke-width='30' stroke-linecap='round' cx='100' cy='100' r='70'></circle></svg>\n <pre class=\"background\"></pre>\n</div>\n";
|
|
17739
18474
|
|
|
17740
18475
|
var EVENT$1 = {
|
|
17741
18476
|
PAYMENT_SUCCESSFUL: 'paymentSuccessful',
|
|
@@ -17748,13 +18483,13 @@ var SELECTORS = {
|
|
|
17748
18483
|
};
|
|
17749
18484
|
var IFRAME_ELEMENTS_STYLES = {
|
|
17750
18485
|
'max-width': '640px',
|
|
17751
|
-
'min-width': '
|
|
18486
|
+
'min-width': '200px',
|
|
17752
18487
|
'display': 'flex',
|
|
17753
18488
|
'margin': 'auto'
|
|
17754
18489
|
};
|
|
17755
18490
|
var WIDGET_STYLES = {
|
|
17756
18491
|
'max-width': '640px',
|
|
17757
|
-
'min-width': '
|
|
18492
|
+
'min-width': '200px',
|
|
17758
18493
|
'margin': 'auto',
|
|
17759
18494
|
'position': 'relative'
|
|
17760
18495
|
};
|
|
@@ -37778,4 +38513,4 @@ var browser = /*#__PURE__*/Object.freeze({
|
|
|
37778
38513
|
strToU8: strToU8
|
|
37779
38514
|
});
|
|
37780
38515
|
|
|
37781
|
-
export { AfterpayCheckoutButton, Api, ApplePayWalletButtonExpress, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, ClickToPay, Configuration, ELEMENT, EVENT$4 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD$1 as FORM_FIELD, HtmlMultiWidget, HtmlPaymentSourceWidget, HtmlWidget, InstructionDebugger, MultiWidget, PAYMENT_TYPE, PURPOSE, PayPalDataCollector, PayPalSavePaymentSourceWidget, Builder as PaymentSourceBuilder, PaymentSourceWidget, PaypalCheckoutButton, PaypalWalletButtonExpress, STYLABLE_ELEMENT, STYLABLE_ELEMENT_STATE, STYLE$2 as STYLE, SUPPORTED_CARD_TYPES, TEXT, TRIGGER$1 as TRIGGER, TYPE, VAULT_DISPLAY_STYLE, VaultDisplayWidget, WalletButtons, ZipmoneyCheckoutButton };
|
|
38516
|
+
export { AfterpayCheckoutButton, Api, ApplePayWalletButtonExpress, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, ClickToPay, Configuration, ELEMENT, EVENT$4 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD$1 as FORM_FIELD, FRAUD_PREVENTION_EVENTS, FraudPreventionService, HtmlMultiWidget, HtmlPaymentSourceWidget, HtmlWidget, InstructionDebugger, MultiWidget, PAYMENT_TYPE, PURPOSE, PayPalDataCollector, PayPalSavePaymentSourceWidget, Builder as PaymentSourceBuilder, PaymentSourceWidget, PaypalCheckoutButton, PaypalWalletButtonExpress, STYLABLE_ELEMENT, STYLABLE_ELEMENT_STATE, STYLE$2 as STYLE, SUPPORTED_CARD_TYPES, TEXT, TRIGGER$1 as TRIGGER, TYPE, VAULT_DISPLAY_STYLE, VaultDisplayWidget, WalletButtons, ZipmoneyCheckoutButton };
|