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