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