@paydock/client-sdk 1.121.0 → 1.122.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +283 -1
- package/bundles/index.cjs +2067 -93
- package/bundles/index.cjs.d.ts +349 -6
- package/bundles/index.mjs +2067 -93
- package/bundles/index.mjs.d.ts +349 -6
- package/bundles/types/checkout/checkout.d.ts +2 -0
- package/bundles/types/checkout/checkout.d.ts.map +1 -1
- package/bundles/types/checkout/layout-widgets/payment-methods-template.d.ts.map +1 -1
- package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
- package/bundles/types/checkout/layout-widgets/payment-template.d.ts +1 -1
- package/bundles/types/checkout/layout-widgets/payment-template.d.ts.map +1 -1
- package/bundles/types/components/link.d.ts +1 -1
- package/bundles/types/components/link.d.ts.map +1 -1
- package/bundles/types/components/wallet-background.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/afterpay.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/flypay-v2.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/paypal.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts +70 -13
- package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/enum/event.enum.d.ts +3 -1
- package/bundles/types/wallet-buttons-express/enum/event.enum.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/index.d.ts +109 -1
- package/bundles/types/wallet-buttons-express/index.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/charge-wallet-token-meta.interface.d.ts +30 -0
- package/bundles/types/wallet-buttons-express/interfaces/charge-wallet-token-meta.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-click-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-click-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-close-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-close-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-error-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-error-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-error-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-error-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-in-review-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-in-review-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-successful-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-successful-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-data.interface.d.ts +21 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-data.interface.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-response.interface.d.ts +9 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-response.interface.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-data.interface.d.ts +13 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-data.interface.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-response.interface.d.ts +9 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-response.interface.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-unavailable-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-unavailable-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts +7 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-events.constant.d.ts +5 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-events.constant.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/interfaces/apple-pay-wallet-meta.interface.d.ts +7 -3
- package/bundles/types/wallet-buttons-express/services/apple-pay/interfaces/apple-pay-wallet-meta.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-contact-editing-mode.type.d.ts +5 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-contact-editing-mode.type.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-data.d.ts +21 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-data.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-method.type.d.ts +21 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-method.type.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-sdk.interface.d.ts +164 -0
- package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-sdk.interface.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts +1 -1
- package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts +9 -3
- package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/types/shipping-event-to-response.type.d.ts +6 -0
- package/bundles/types/wallet-buttons-express/types/shipping-event-to-response.type.d.ts.map +1 -0
- package/bundles/widget.umd.js +2069 -93
- package/bundles/widget.umd.js.d.ts +349 -6
- package/bundles/widget.umd.js.min.d.ts +349 -6
- package/bundles/widget.umd.min.js +1 -1
- package/docs/wallet-buttons-express.md +283 -1
- package/package.json +1 -1
package/bundles/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('isomorphic-dompurify');
|
|
4
|
-
|
|
5
3
|
function _arrayLikeToArray(r, a) {
|
|
6
4
|
(null == a || a > r.length) && (a = r.length);
|
|
7
5
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -927,7 +925,7 @@ SDK.headerKeys = Object.freeze({
|
|
|
927
925
|
version: 'x-sdk-version',
|
|
928
926
|
type: 'x-sdk-type'
|
|
929
927
|
});
|
|
930
|
-
SDK._version = 'v1.
|
|
928
|
+
SDK._version = 'v1.122.2-beta';
|
|
931
929
|
|
|
932
930
|
/******************************************************************************
|
|
933
931
|
Copyright (c) Microsoft Corporation.
|
|
@@ -4203,8 +4201,8 @@ function createNewrelicConfig() {
|
|
|
4203
4201
|
var params = {
|
|
4204
4202
|
enabled: 'true',
|
|
4205
4203
|
accountId: '974691',
|
|
4206
|
-
agentId: '
|
|
4207
|
-
applicationId: '
|
|
4204
|
+
agentId: '1386157150',
|
|
4205
|
+
applicationId: '1386157150',
|
|
4208
4206
|
licenseKey: '4848a32285',
|
|
4209
4207
|
trustKey: '974691'
|
|
4210
4208
|
};
|
|
@@ -4712,7 +4710,7 @@ var VAULT_DISPLAY_WIDGET_LINK = '/vault-display';
|
|
|
4712
4710
|
var PAYMENT_SOURCE_LINK = '/payment-sources';
|
|
4713
4711
|
var SECURE_3D = '/3ds/webhook';
|
|
4714
4712
|
var FLYPAY_LINK = '/wallet/flypay';
|
|
4715
|
-
var FLYPAY_LOGO_LINK = '/images/logo.png';
|
|
4713
|
+
var FLYPAY_LOGO_LINK = '/images/coles-pay-logo.png';
|
|
4716
4714
|
var MESSAGE_WIDGET_LINK = '/message-widget';
|
|
4717
4715
|
var MASTERCARD_SRC = '/secure-remote-commerce/mastercard';
|
|
4718
4716
|
var Link = /*#__PURE__*/function () {
|
|
@@ -10083,6 +10081,10 @@ var AfterPayWalletService = /*#__PURE__*/function (_WalletService) {
|
|
|
10083
10081
|
resolve(res);
|
|
10084
10082
|
},
|
|
10085
10083
|
onError: function onError(message) {
|
|
10084
|
+
console.error('Error generating order id', message);
|
|
10085
|
+
_this5.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
|
|
10086
|
+
message: message
|
|
10087
|
+
});
|
|
10086
10088
|
reject(message);
|
|
10087
10089
|
}
|
|
10088
10090
|
});
|
|
@@ -10136,6 +10138,1581 @@ var AfterPayWalletService = /*#__PURE__*/function (_WalletService) {
|
|
|
10136
10138
|
}]);
|
|
10137
10139
|
}(WalletService);
|
|
10138
10140
|
|
|
10141
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
10142
|
+
|
|
10143
|
+
var purify = {exports: {}};
|
|
10144
|
+
|
|
10145
|
+
/*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */
|
|
10146
|
+
|
|
10147
|
+
var hasRequiredPurify;
|
|
10148
|
+
|
|
10149
|
+
function requirePurify () {
|
|
10150
|
+
if (hasRequiredPurify) return purify.exports;
|
|
10151
|
+
hasRequiredPurify = 1;
|
|
10152
|
+
(function (module, exports) {
|
|
10153
|
+
(function (global, factory) {
|
|
10154
|
+
module.exports = factory() ;
|
|
10155
|
+
})(commonjsGlobal, (function () {
|
|
10156
|
+
const {
|
|
10157
|
+
entries,
|
|
10158
|
+
setPrototypeOf,
|
|
10159
|
+
isFrozen,
|
|
10160
|
+
getPrototypeOf,
|
|
10161
|
+
getOwnPropertyDescriptor
|
|
10162
|
+
} = Object;
|
|
10163
|
+
let {
|
|
10164
|
+
freeze,
|
|
10165
|
+
seal,
|
|
10166
|
+
create
|
|
10167
|
+
} = Object; // eslint-disable-line import/no-mutable-exports
|
|
10168
|
+
let {
|
|
10169
|
+
apply,
|
|
10170
|
+
construct
|
|
10171
|
+
} = typeof Reflect !== 'undefined' && Reflect;
|
|
10172
|
+
if (!freeze) {
|
|
10173
|
+
freeze = function freeze(x) {
|
|
10174
|
+
return x;
|
|
10175
|
+
};
|
|
10176
|
+
}
|
|
10177
|
+
if (!seal) {
|
|
10178
|
+
seal = function seal(x) {
|
|
10179
|
+
return x;
|
|
10180
|
+
};
|
|
10181
|
+
}
|
|
10182
|
+
if (!apply) {
|
|
10183
|
+
apply = function apply(fun, thisValue, args) {
|
|
10184
|
+
return fun.apply(thisValue, args);
|
|
10185
|
+
};
|
|
10186
|
+
}
|
|
10187
|
+
if (!construct) {
|
|
10188
|
+
construct = function construct(Func, args) {
|
|
10189
|
+
return new Func(...args);
|
|
10190
|
+
};
|
|
10191
|
+
}
|
|
10192
|
+
const arrayForEach = unapply(Array.prototype.forEach);
|
|
10193
|
+
const arrayPop = unapply(Array.prototype.pop);
|
|
10194
|
+
const arrayPush = unapply(Array.prototype.push);
|
|
10195
|
+
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
10196
|
+
const stringToString = unapply(String.prototype.toString);
|
|
10197
|
+
const stringMatch = unapply(String.prototype.match);
|
|
10198
|
+
const stringReplace = unapply(String.prototype.replace);
|
|
10199
|
+
const stringIndexOf = unapply(String.prototype.indexOf);
|
|
10200
|
+
const stringTrim = unapply(String.prototype.trim);
|
|
10201
|
+
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
10202
|
+
const regExpTest = unapply(RegExp.prototype.test);
|
|
10203
|
+
const typeErrorCreate = unconstruct(TypeError);
|
|
10204
|
+
|
|
10205
|
+
/**
|
|
10206
|
+
* Creates a new function that calls the given function with a specified thisArg and arguments.
|
|
10207
|
+
*
|
|
10208
|
+
* @param {Function} func - The function to be wrapped and called.
|
|
10209
|
+
* @returns {Function} A new function that calls the given function with a specified thisArg and arguments.
|
|
10210
|
+
*/
|
|
10211
|
+
function unapply(func) {
|
|
10212
|
+
return function (thisArg) {
|
|
10213
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
10214
|
+
args[_key - 1] = arguments[_key];
|
|
10215
|
+
}
|
|
10216
|
+
return apply(func, thisArg, args);
|
|
10217
|
+
};
|
|
10218
|
+
}
|
|
10219
|
+
|
|
10220
|
+
/**
|
|
10221
|
+
* Creates a new function that constructs an instance of the given constructor function with the provided arguments.
|
|
10222
|
+
*
|
|
10223
|
+
* @param {Function} func - The constructor function to be wrapped and called.
|
|
10224
|
+
* @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments.
|
|
10225
|
+
*/
|
|
10226
|
+
function unconstruct(func) {
|
|
10227
|
+
return function () {
|
|
10228
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
10229
|
+
args[_key2] = arguments[_key2];
|
|
10230
|
+
}
|
|
10231
|
+
return construct(func, args);
|
|
10232
|
+
};
|
|
10233
|
+
}
|
|
10234
|
+
|
|
10235
|
+
/**
|
|
10236
|
+
* Add properties to a lookup table
|
|
10237
|
+
*
|
|
10238
|
+
* @param {Object} set - The set to which elements will be added.
|
|
10239
|
+
* @param {Array} array - The array containing elements to be added to the set.
|
|
10240
|
+
* @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set.
|
|
10241
|
+
* @returns {Object} The modified set with added elements.
|
|
10242
|
+
*/
|
|
10243
|
+
function addToSet(set, array) {
|
|
10244
|
+
let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
|
|
10245
|
+
if (setPrototypeOf) {
|
|
10246
|
+
// Make 'in' and truthy checks like Boolean(set.constructor)
|
|
10247
|
+
// independent of any properties defined on Object.prototype.
|
|
10248
|
+
// Prevent prototype setters from intercepting set as a this value.
|
|
10249
|
+
setPrototypeOf(set, null);
|
|
10250
|
+
}
|
|
10251
|
+
let l = array.length;
|
|
10252
|
+
while (l--) {
|
|
10253
|
+
let element = array[l];
|
|
10254
|
+
if (typeof element === 'string') {
|
|
10255
|
+
const lcElement = transformCaseFunc(element);
|
|
10256
|
+
if (lcElement !== element) {
|
|
10257
|
+
// Config presets (e.g. tags.js, attrs.js) are immutable.
|
|
10258
|
+
if (!isFrozen(array)) {
|
|
10259
|
+
array[l] = lcElement;
|
|
10260
|
+
}
|
|
10261
|
+
element = lcElement;
|
|
10262
|
+
}
|
|
10263
|
+
}
|
|
10264
|
+
set[element] = true;
|
|
10265
|
+
}
|
|
10266
|
+
return set;
|
|
10267
|
+
}
|
|
10268
|
+
|
|
10269
|
+
/**
|
|
10270
|
+
* Clean up an array to harden against CSPP
|
|
10271
|
+
*
|
|
10272
|
+
* @param {Array} array - The array to be cleaned.
|
|
10273
|
+
* @returns {Array} The cleaned version of the array
|
|
10274
|
+
*/
|
|
10275
|
+
function cleanArray(array) {
|
|
10276
|
+
for (let index = 0; index < array.length; index++) {
|
|
10277
|
+
const isPropertyExist = objectHasOwnProperty(array, index);
|
|
10278
|
+
if (!isPropertyExist) {
|
|
10279
|
+
array[index] = null;
|
|
10280
|
+
}
|
|
10281
|
+
}
|
|
10282
|
+
return array;
|
|
10283
|
+
}
|
|
10284
|
+
|
|
10285
|
+
/**
|
|
10286
|
+
* Shallow clone an object
|
|
10287
|
+
*
|
|
10288
|
+
* @param {Object} object - The object to be cloned.
|
|
10289
|
+
* @returns {Object} A new object that copies the original.
|
|
10290
|
+
*/
|
|
10291
|
+
function clone(object) {
|
|
10292
|
+
const newObject = create(null);
|
|
10293
|
+
for (const [property, value] of entries(object)) {
|
|
10294
|
+
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
10295
|
+
if (isPropertyExist) {
|
|
10296
|
+
if (Array.isArray(value)) {
|
|
10297
|
+
newObject[property] = cleanArray(value);
|
|
10298
|
+
} else if (value && typeof value === 'object' && value.constructor === Object) {
|
|
10299
|
+
newObject[property] = clone(value);
|
|
10300
|
+
} else {
|
|
10301
|
+
newObject[property] = value;
|
|
10302
|
+
}
|
|
10303
|
+
}
|
|
10304
|
+
}
|
|
10305
|
+
return newObject;
|
|
10306
|
+
}
|
|
10307
|
+
|
|
10308
|
+
/**
|
|
10309
|
+
* This method automatically checks if the prop is function or getter and behaves accordingly.
|
|
10310
|
+
*
|
|
10311
|
+
* @param {Object} object - The object to look up the getter function in its prototype chain.
|
|
10312
|
+
* @param {String} prop - The property name for which to find the getter function.
|
|
10313
|
+
* @returns {Function} The getter function found in the prototype chain or a fallback function.
|
|
10314
|
+
*/
|
|
10315
|
+
function lookupGetter(object, prop) {
|
|
10316
|
+
while (object !== null) {
|
|
10317
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
10318
|
+
if (desc) {
|
|
10319
|
+
if (desc.get) {
|
|
10320
|
+
return unapply(desc.get);
|
|
10321
|
+
}
|
|
10322
|
+
if (typeof desc.value === 'function') {
|
|
10323
|
+
return unapply(desc.value);
|
|
10324
|
+
}
|
|
10325
|
+
}
|
|
10326
|
+
object = getPrototypeOf(object);
|
|
10327
|
+
}
|
|
10328
|
+
function fallbackValue() {
|
|
10329
|
+
return null;
|
|
10330
|
+
}
|
|
10331
|
+
return fallbackValue;
|
|
10332
|
+
}
|
|
10333
|
+
|
|
10334
|
+
const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
|
|
10335
|
+
|
|
10336
|
+
// SVG
|
|
10337
|
+
const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
|
|
10338
|
+
const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
|
|
10339
|
+
|
|
10340
|
+
// List of SVG elements that are disallowed by default.
|
|
10341
|
+
// We still need to know them so that we can do namespace
|
|
10342
|
+
// checks properly in case one wants to add them to
|
|
10343
|
+
// allow-list.
|
|
10344
|
+
const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
|
|
10345
|
+
const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);
|
|
10346
|
+
|
|
10347
|
+
// Similarly to SVG, we want to know all MathML elements,
|
|
10348
|
+
// even those that we disallow by default.
|
|
10349
|
+
const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
10350
|
+
const text = freeze(['#text']);
|
|
10351
|
+
|
|
10352
|
+
const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);
|
|
10353
|
+
const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
10354
|
+
const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
|
|
10355
|
+
const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
10356
|
+
|
|
10357
|
+
// eslint-disable-next-line unicorn/better-regex
|
|
10358
|
+
const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
|
10359
|
+
const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
|
10360
|
+
const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
|
|
10361
|
+
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
|
|
10362
|
+
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
10363
|
+
const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
|
|
10364
|
+
);
|
|
10365
|
+
const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
10366
|
+
const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
|
|
10367
|
+
);
|
|
10368
|
+
const DOCTYPE_NAME = seal(/^html$/i);
|
|
10369
|
+
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
10370
|
+
|
|
10371
|
+
var EXPRESSIONS = /*#__PURE__*/Object.freeze({
|
|
10372
|
+
__proto__: null,
|
|
10373
|
+
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
|
10374
|
+
ERB_EXPR: ERB_EXPR,
|
|
10375
|
+
TMPLIT_EXPR: TMPLIT_EXPR,
|
|
10376
|
+
DATA_ATTR: DATA_ATTR,
|
|
10377
|
+
ARIA_ATTR: ARIA_ATTR,
|
|
10378
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
|
10379
|
+
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
|
10380
|
+
ATTR_WHITESPACE: ATTR_WHITESPACE,
|
|
10381
|
+
DOCTYPE_NAME: DOCTYPE_NAME,
|
|
10382
|
+
CUSTOM_ELEMENT: CUSTOM_ELEMENT
|
|
10383
|
+
});
|
|
10384
|
+
|
|
10385
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
|
10386
|
+
const NODE_TYPE = {
|
|
10387
|
+
element: 1,
|
|
10388
|
+
attribute: 2,
|
|
10389
|
+
text: 3,
|
|
10390
|
+
cdataSection: 4,
|
|
10391
|
+
entityReference: 5,
|
|
10392
|
+
// Deprecated
|
|
10393
|
+
entityNode: 6,
|
|
10394
|
+
// Deprecated
|
|
10395
|
+
progressingInstruction: 7,
|
|
10396
|
+
comment: 8,
|
|
10397
|
+
document: 9,
|
|
10398
|
+
documentType: 10,
|
|
10399
|
+
documentFragment: 11,
|
|
10400
|
+
notation: 12 // Deprecated
|
|
10401
|
+
};
|
|
10402
|
+
const getGlobal = function getGlobal() {
|
|
10403
|
+
return typeof window === 'undefined' ? null : window;
|
|
10404
|
+
};
|
|
10405
|
+
|
|
10406
|
+
/**
|
|
10407
|
+
* Creates a no-op policy for internal use only.
|
|
10408
|
+
* Don't export this function outside this module!
|
|
10409
|
+
* @param {TrustedTypePolicyFactory} trustedTypes The policy factory.
|
|
10410
|
+
* @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
|
|
10411
|
+
* @return {TrustedTypePolicy} The policy created (or null, if Trusted Types
|
|
10412
|
+
* are not supported or creating the policy failed).
|
|
10413
|
+
*/
|
|
10414
|
+
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
|
10415
|
+
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
|
10416
|
+
return null;
|
|
10417
|
+
}
|
|
10418
|
+
|
|
10419
|
+
// Allow the callers to control the unique policy name
|
|
10420
|
+
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
|
10421
|
+
// Policy creation with duplicate names throws in Trusted Types.
|
|
10422
|
+
let suffix = null;
|
|
10423
|
+
const ATTR_NAME = 'data-tt-policy-suffix';
|
|
10424
|
+
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
|
|
10425
|
+
suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
|
10426
|
+
}
|
|
10427
|
+
const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
|
|
10428
|
+
try {
|
|
10429
|
+
return trustedTypes.createPolicy(policyName, {
|
|
10430
|
+
createHTML(html) {
|
|
10431
|
+
return html;
|
|
10432
|
+
},
|
|
10433
|
+
createScriptURL(scriptUrl) {
|
|
10434
|
+
return scriptUrl;
|
|
10435
|
+
}
|
|
10436
|
+
});
|
|
10437
|
+
} catch (_) {
|
|
10438
|
+
// Policy creation failed (most likely another DOMPurify script has
|
|
10439
|
+
// already run). Skip creating the policy, as this will only cause errors
|
|
10440
|
+
// if TT are enforced.
|
|
10441
|
+
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
|
10442
|
+
return null;
|
|
10443
|
+
}
|
|
10444
|
+
};
|
|
10445
|
+
function createDOMPurify() {
|
|
10446
|
+
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
10447
|
+
const DOMPurify = root => createDOMPurify(root);
|
|
10448
|
+
|
|
10449
|
+
/**
|
|
10450
|
+
* Version label, exposed for easier checks
|
|
10451
|
+
* if DOMPurify is up to date or not
|
|
10452
|
+
*/
|
|
10453
|
+
DOMPurify.version = '3.1.6';
|
|
10454
|
+
|
|
10455
|
+
/**
|
|
10456
|
+
* Array of elements that DOMPurify removed during sanitation.
|
|
10457
|
+
* Empty if nothing was removed.
|
|
10458
|
+
*/
|
|
10459
|
+
DOMPurify.removed = [];
|
|
10460
|
+
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document) {
|
|
10461
|
+
// Not running in a browser, provide a factory function
|
|
10462
|
+
// so that you can pass your own Window
|
|
10463
|
+
DOMPurify.isSupported = false;
|
|
10464
|
+
return DOMPurify;
|
|
10465
|
+
}
|
|
10466
|
+
let {
|
|
10467
|
+
document
|
|
10468
|
+
} = window;
|
|
10469
|
+
const originalDocument = document;
|
|
10470
|
+
const currentScript = originalDocument.currentScript;
|
|
10471
|
+
const {
|
|
10472
|
+
DocumentFragment,
|
|
10473
|
+
HTMLTemplateElement,
|
|
10474
|
+
Node,
|
|
10475
|
+
Element,
|
|
10476
|
+
NodeFilter,
|
|
10477
|
+
NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
|
|
10478
|
+
HTMLFormElement,
|
|
10479
|
+
DOMParser,
|
|
10480
|
+
trustedTypes
|
|
10481
|
+
} = window;
|
|
10482
|
+
const ElementPrototype = Element.prototype;
|
|
10483
|
+
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
10484
|
+
const remove = lookupGetter(ElementPrototype, 'remove');
|
|
10485
|
+
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
10486
|
+
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
10487
|
+
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
10488
|
+
|
|
10489
|
+
// As per issue #47, the web-components registry is inherited by a
|
|
10490
|
+
// new document created via createHTMLDocument. As per the spec
|
|
10491
|
+
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
10492
|
+
// a new empty registry is used when creating a template contents owner
|
|
10493
|
+
// document, so we use that as our parent document to ensure nothing
|
|
10494
|
+
// is inherited.
|
|
10495
|
+
if (typeof HTMLTemplateElement === 'function') {
|
|
10496
|
+
const template = document.createElement('template');
|
|
10497
|
+
if (template.content && template.content.ownerDocument) {
|
|
10498
|
+
document = template.content.ownerDocument;
|
|
10499
|
+
}
|
|
10500
|
+
}
|
|
10501
|
+
let trustedTypesPolicy;
|
|
10502
|
+
let emptyHTML = '';
|
|
10503
|
+
const {
|
|
10504
|
+
implementation,
|
|
10505
|
+
createNodeIterator,
|
|
10506
|
+
createDocumentFragment,
|
|
10507
|
+
getElementsByTagName
|
|
10508
|
+
} = document;
|
|
10509
|
+
const {
|
|
10510
|
+
importNode
|
|
10511
|
+
} = originalDocument;
|
|
10512
|
+
let hooks = {};
|
|
10513
|
+
|
|
10514
|
+
/**
|
|
10515
|
+
* Expose whether this browser supports running the full DOMPurify.
|
|
10516
|
+
*/
|
|
10517
|
+
DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
|
|
10518
|
+
const {
|
|
10519
|
+
MUSTACHE_EXPR,
|
|
10520
|
+
ERB_EXPR,
|
|
10521
|
+
TMPLIT_EXPR,
|
|
10522
|
+
DATA_ATTR,
|
|
10523
|
+
ARIA_ATTR,
|
|
10524
|
+
IS_SCRIPT_OR_DATA,
|
|
10525
|
+
ATTR_WHITESPACE,
|
|
10526
|
+
CUSTOM_ELEMENT
|
|
10527
|
+
} = EXPRESSIONS;
|
|
10528
|
+
let {
|
|
10529
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
10530
|
+
} = EXPRESSIONS;
|
|
10531
|
+
|
|
10532
|
+
/**
|
|
10533
|
+
* We consider the elements and attributes below to be safe. Ideally
|
|
10534
|
+
* don't add any new ones but feel free to remove unwanted ones.
|
|
10535
|
+
*/
|
|
10536
|
+
|
|
10537
|
+
/* allowed element names */
|
|
10538
|
+
let ALLOWED_TAGS = null;
|
|
10539
|
+
const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
|
|
10540
|
+
|
|
10541
|
+
/* Allowed attribute names */
|
|
10542
|
+
let ALLOWED_ATTR = null;
|
|
10543
|
+
const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
|
|
10544
|
+
|
|
10545
|
+
/*
|
|
10546
|
+
* Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
|
|
10547
|
+
* @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
|
|
10548
|
+
* @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
|
|
10549
|
+
* @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
|
|
10550
|
+
*/
|
|
10551
|
+
let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
10552
|
+
tagNameCheck: {
|
|
10553
|
+
writable: true,
|
|
10554
|
+
configurable: false,
|
|
10555
|
+
enumerable: true,
|
|
10556
|
+
value: null
|
|
10557
|
+
},
|
|
10558
|
+
attributeNameCheck: {
|
|
10559
|
+
writable: true,
|
|
10560
|
+
configurable: false,
|
|
10561
|
+
enumerable: true,
|
|
10562
|
+
value: null
|
|
10563
|
+
},
|
|
10564
|
+
allowCustomizedBuiltInElements: {
|
|
10565
|
+
writable: true,
|
|
10566
|
+
configurable: false,
|
|
10567
|
+
enumerable: true,
|
|
10568
|
+
value: false
|
|
10569
|
+
}
|
|
10570
|
+
}));
|
|
10571
|
+
|
|
10572
|
+
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
|
10573
|
+
let FORBID_TAGS = null;
|
|
10574
|
+
|
|
10575
|
+
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
10576
|
+
let FORBID_ATTR = null;
|
|
10577
|
+
|
|
10578
|
+
/* Decide if ARIA attributes are okay */
|
|
10579
|
+
let ALLOW_ARIA_ATTR = true;
|
|
10580
|
+
|
|
10581
|
+
/* Decide if custom data attributes are okay */
|
|
10582
|
+
let ALLOW_DATA_ATTR = true;
|
|
10583
|
+
|
|
10584
|
+
/* Decide if unknown protocols are okay */
|
|
10585
|
+
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
10586
|
+
|
|
10587
|
+
/* Decide if self-closing tags in attributes are allowed.
|
|
10588
|
+
* Usually removed due to a mXSS issue in jQuery 3.0 */
|
|
10589
|
+
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
10590
|
+
|
|
10591
|
+
/* Output should be safe for common template engines.
|
|
10592
|
+
* This means, DOMPurify removes data attributes, mustaches and ERB
|
|
10593
|
+
*/
|
|
10594
|
+
let SAFE_FOR_TEMPLATES = false;
|
|
10595
|
+
|
|
10596
|
+
/* Output should be safe even for XML used within HTML and alike.
|
|
10597
|
+
* This means, DOMPurify removes comments when containing risky content.
|
|
10598
|
+
*/
|
|
10599
|
+
let SAFE_FOR_XML = true;
|
|
10600
|
+
|
|
10601
|
+
/* Decide if document with <html>... should be returned */
|
|
10602
|
+
let WHOLE_DOCUMENT = false;
|
|
10603
|
+
|
|
10604
|
+
/* Track whether config is already set on this instance of DOMPurify. */
|
|
10605
|
+
let SET_CONFIG = false;
|
|
10606
|
+
|
|
10607
|
+
/* Decide if all elements (e.g. style, script) must be children of
|
|
10608
|
+
* document.body. By default, browsers might move them to document.head */
|
|
10609
|
+
let FORCE_BODY = false;
|
|
10610
|
+
|
|
10611
|
+
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
|
10612
|
+
* string (or a TrustedHTML object if Trusted Types are supported).
|
|
10613
|
+
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
|
10614
|
+
*/
|
|
10615
|
+
let RETURN_DOM = false;
|
|
10616
|
+
|
|
10617
|
+
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
|
10618
|
+
* string (or a TrustedHTML object if Trusted Types are supported) */
|
|
10619
|
+
let RETURN_DOM_FRAGMENT = false;
|
|
10620
|
+
|
|
10621
|
+
/* Try to return a Trusted Type object instead of a string, return a string in
|
|
10622
|
+
* case Trusted Types are not supported */
|
|
10623
|
+
let RETURN_TRUSTED_TYPE = false;
|
|
10624
|
+
|
|
10625
|
+
/* Output should be free from DOM clobbering attacks?
|
|
10626
|
+
* This sanitizes markups named with colliding, clobberable built-in DOM APIs.
|
|
10627
|
+
*/
|
|
10628
|
+
let SANITIZE_DOM = true;
|
|
10629
|
+
|
|
10630
|
+
/* Achieve full DOM Clobbering protection by isolating the namespace of named
|
|
10631
|
+
* properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
|
|
10632
|
+
*
|
|
10633
|
+
* HTML/DOM spec rules that enable DOM Clobbering:
|
|
10634
|
+
* - Named Access on Window (§7.3.3)
|
|
10635
|
+
* - DOM Tree Accessors (§3.1.5)
|
|
10636
|
+
* - Form Element Parent-Child Relations (§4.10.3)
|
|
10637
|
+
* - Iframe srcdoc / Nested WindowProxies (§4.8.5)
|
|
10638
|
+
* - HTMLCollection (§4.2.10.2)
|
|
10639
|
+
*
|
|
10640
|
+
* Namespace isolation is implemented by prefixing `id` and `name` attributes
|
|
10641
|
+
* with a constant string, i.e., `user-content-`
|
|
10642
|
+
*/
|
|
10643
|
+
let SANITIZE_NAMED_PROPS = false;
|
|
10644
|
+
const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
|
|
10645
|
+
|
|
10646
|
+
/* Keep element content when removing element? */
|
|
10647
|
+
let KEEP_CONTENT = true;
|
|
10648
|
+
|
|
10649
|
+
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
|
10650
|
+
* of importing it into a new Document and returning a sanitized copy */
|
|
10651
|
+
let IN_PLACE = false;
|
|
10652
|
+
|
|
10653
|
+
/* Allow usage of profiles like html, svg and mathMl */
|
|
10654
|
+
let USE_PROFILES = {};
|
|
10655
|
+
|
|
10656
|
+
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
10657
|
+
let FORBID_CONTENTS = null;
|
|
10658
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
|
10659
|
+
|
|
10660
|
+
/* Tags that are safe for data: URIs */
|
|
10661
|
+
let DATA_URI_TAGS = null;
|
|
10662
|
+
const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
10663
|
+
|
|
10664
|
+
/* Attributes safe for values like "javascript:" */
|
|
10665
|
+
let URI_SAFE_ATTRIBUTES = null;
|
|
10666
|
+
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
|
10667
|
+
const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
10668
|
+
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
10669
|
+
const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
10670
|
+
/* Document namespace */
|
|
10671
|
+
let NAMESPACE = HTML_NAMESPACE;
|
|
10672
|
+
let IS_EMPTY_INPUT = false;
|
|
10673
|
+
|
|
10674
|
+
/* Allowed XHTML+XML namespaces */
|
|
10675
|
+
let ALLOWED_NAMESPACES = null;
|
|
10676
|
+
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
10677
|
+
|
|
10678
|
+
/* Parsing of strict XHTML documents */
|
|
10679
|
+
let PARSER_MEDIA_TYPE = null;
|
|
10680
|
+
const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
|
10681
|
+
const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
|
10682
|
+
let transformCaseFunc = null;
|
|
10683
|
+
|
|
10684
|
+
/* Keep a reference to config to pass to hooks */
|
|
10685
|
+
let CONFIG = null;
|
|
10686
|
+
|
|
10687
|
+
/* Ideally, do not touch anything below this line */
|
|
10688
|
+
/* ______________________________________________ */
|
|
10689
|
+
|
|
10690
|
+
const formElement = document.createElement('form');
|
|
10691
|
+
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
10692
|
+
return testValue instanceof RegExp || testValue instanceof Function;
|
|
10693
|
+
};
|
|
10694
|
+
|
|
10695
|
+
/**
|
|
10696
|
+
* _parseConfig
|
|
10697
|
+
*
|
|
10698
|
+
* @param {Object} cfg optional config literal
|
|
10699
|
+
*/
|
|
10700
|
+
// eslint-disable-next-line complexity
|
|
10701
|
+
const _parseConfig = function _parseConfig() {
|
|
10702
|
+
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10703
|
+
if (CONFIG && CONFIG === cfg) {
|
|
10704
|
+
return;
|
|
10705
|
+
}
|
|
10706
|
+
|
|
10707
|
+
/* Shield configuration object from tampering */
|
|
10708
|
+
if (!cfg || typeof cfg !== 'object') {
|
|
10709
|
+
cfg = {};
|
|
10710
|
+
}
|
|
10711
|
+
|
|
10712
|
+
/* Shield configuration object from prototype pollution */
|
|
10713
|
+
cfg = clone(cfg);
|
|
10714
|
+
PARSER_MEDIA_TYPE =
|
|
10715
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
10716
|
+
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
10717
|
+
|
|
10718
|
+
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
10719
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
10720
|
+
|
|
10721
|
+
/* Set configuration parameters */
|
|
10722
|
+
ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
10723
|
+
ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
10724
|
+
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
10725
|
+
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES),
|
|
10726
|
+
// eslint-disable-line indent
|
|
10727
|
+
cfg.ADD_URI_SAFE_ATTR,
|
|
10728
|
+
// eslint-disable-line indent
|
|
10729
|
+
transformCaseFunc // eslint-disable-line indent
|
|
10730
|
+
) // eslint-disable-line indent
|
|
10731
|
+
: DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
10732
|
+
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS),
|
|
10733
|
+
// eslint-disable-line indent
|
|
10734
|
+
cfg.ADD_DATA_URI_TAGS,
|
|
10735
|
+
// eslint-disable-line indent
|
|
10736
|
+
transformCaseFunc // eslint-disable-line indent
|
|
10737
|
+
) // eslint-disable-line indent
|
|
10738
|
+
: DEFAULT_DATA_URI_TAGS;
|
|
10739
|
+
FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
10740
|
+
FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
|
10741
|
+
FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
|
10742
|
+
USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;
|
|
10743
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
10744
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
10745
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
10746
|
+
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
|
|
10747
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
|
|
10748
|
+
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
|
|
10749
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
|
|
10750
|
+
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
|
|
10751
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
|
|
10752
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
|
|
10753
|
+
FORCE_BODY = cfg.FORCE_BODY || false; // Default false
|
|
10754
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
|
|
10755
|
+
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
|
|
10756
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
10757
|
+
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
10758
|
+
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
|
|
10759
|
+
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
10760
|
+
CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
|
|
10761
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
|
10762
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
|
10763
|
+
}
|
|
10764
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
|
|
10765
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
|
|
10766
|
+
}
|
|
10767
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
|
|
10768
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
|
|
10769
|
+
}
|
|
10770
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
10771
|
+
ALLOW_DATA_ATTR = false;
|
|
10772
|
+
}
|
|
10773
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
10774
|
+
RETURN_DOM = true;
|
|
10775
|
+
}
|
|
10776
|
+
|
|
10777
|
+
/* Parse profile info */
|
|
10778
|
+
if (USE_PROFILES) {
|
|
10779
|
+
ALLOWED_TAGS = addToSet({}, text);
|
|
10780
|
+
ALLOWED_ATTR = [];
|
|
10781
|
+
if (USE_PROFILES.html === true) {
|
|
10782
|
+
addToSet(ALLOWED_TAGS, html$1);
|
|
10783
|
+
addToSet(ALLOWED_ATTR, html);
|
|
10784
|
+
}
|
|
10785
|
+
if (USE_PROFILES.svg === true) {
|
|
10786
|
+
addToSet(ALLOWED_TAGS, svg$1);
|
|
10787
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
10788
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
10789
|
+
}
|
|
10790
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
10791
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
10792
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
10793
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
10794
|
+
}
|
|
10795
|
+
if (USE_PROFILES.mathMl === true) {
|
|
10796
|
+
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
10797
|
+
addToSet(ALLOWED_ATTR, mathMl);
|
|
10798
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
10799
|
+
}
|
|
10800
|
+
}
|
|
10801
|
+
|
|
10802
|
+
/* Merge configuration parameters */
|
|
10803
|
+
if (cfg.ADD_TAGS) {
|
|
10804
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
10805
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
10806
|
+
}
|
|
10807
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
10808
|
+
}
|
|
10809
|
+
if (cfg.ADD_ATTR) {
|
|
10810
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
10811
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
10812
|
+
}
|
|
10813
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
10814
|
+
}
|
|
10815
|
+
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
10816
|
+
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
10817
|
+
}
|
|
10818
|
+
if (cfg.FORBID_CONTENTS) {
|
|
10819
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
10820
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
10821
|
+
}
|
|
10822
|
+
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
10823
|
+
}
|
|
10824
|
+
|
|
10825
|
+
/* Add #text in case KEEP_CONTENT is set to true */
|
|
10826
|
+
if (KEEP_CONTENT) {
|
|
10827
|
+
ALLOWED_TAGS['#text'] = true;
|
|
10828
|
+
}
|
|
10829
|
+
|
|
10830
|
+
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
|
10831
|
+
if (WHOLE_DOCUMENT) {
|
|
10832
|
+
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
|
10833
|
+
}
|
|
10834
|
+
|
|
10835
|
+
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
|
10836
|
+
if (ALLOWED_TAGS.table) {
|
|
10837
|
+
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
10838
|
+
delete FORBID_TAGS.tbody;
|
|
10839
|
+
}
|
|
10840
|
+
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
10841
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
|
|
10842
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
10843
|
+
}
|
|
10844
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
|
|
10845
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
10846
|
+
}
|
|
10847
|
+
|
|
10848
|
+
// Overwrite existing TrustedTypes policy.
|
|
10849
|
+
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
10850
|
+
|
|
10851
|
+
// Sign local variables required by `sanitize`.
|
|
10852
|
+
emptyHTML = trustedTypesPolicy.createHTML('');
|
|
10853
|
+
} else {
|
|
10854
|
+
// Uninitialized policy, attempt to initialize the internal dompurify policy.
|
|
10855
|
+
if (trustedTypesPolicy === undefined) {
|
|
10856
|
+
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
10857
|
+
}
|
|
10858
|
+
|
|
10859
|
+
// If creating the internal policy succeeded sign internal variables.
|
|
10860
|
+
if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
|
|
10861
|
+
emptyHTML = trustedTypesPolicy.createHTML('');
|
|
10862
|
+
}
|
|
10863
|
+
}
|
|
10864
|
+
|
|
10865
|
+
// Prevent further manipulation of configuration.
|
|
10866
|
+
// Not available in IE8, Safari 5, etc.
|
|
10867
|
+
if (freeze) {
|
|
10868
|
+
freeze(cfg);
|
|
10869
|
+
}
|
|
10870
|
+
CONFIG = cfg;
|
|
10871
|
+
};
|
|
10872
|
+
const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
10873
|
+
const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']);
|
|
10874
|
+
|
|
10875
|
+
// Certain elements are allowed in both SVG and HTML
|
|
10876
|
+
// namespace. We need to specify them explicitly
|
|
10877
|
+
// so that they don't get erroneously deleted from
|
|
10878
|
+
// HTML namespace.
|
|
10879
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
10880
|
+
|
|
10881
|
+
/* Keep track of all possible SVG and MathML tags
|
|
10882
|
+
* so that we can perform the namespace checks
|
|
10883
|
+
* correctly. */
|
|
10884
|
+
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
10885
|
+
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
10886
|
+
|
|
10887
|
+
/**
|
|
10888
|
+
* @param {Element} element a DOM element whose namespace is being checked
|
|
10889
|
+
* @returns {boolean} Return false if the element has a
|
|
10890
|
+
* namespace that a spec-compliant parser would never
|
|
10891
|
+
* return. Return true otherwise.
|
|
10892
|
+
*/
|
|
10893
|
+
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
10894
|
+
let parent = getParentNode(element);
|
|
10895
|
+
|
|
10896
|
+
// In JSDOM, if we're inside shadow DOM, then parentNode
|
|
10897
|
+
// can be null. We just simulate parent in this case.
|
|
10898
|
+
if (!parent || !parent.tagName) {
|
|
10899
|
+
parent = {
|
|
10900
|
+
namespaceURI: NAMESPACE,
|
|
10901
|
+
tagName: 'template'
|
|
10902
|
+
};
|
|
10903
|
+
}
|
|
10904
|
+
const tagName = stringToLowerCase(element.tagName);
|
|
10905
|
+
const parentTagName = stringToLowerCase(parent.tagName);
|
|
10906
|
+
if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
10907
|
+
return false;
|
|
10908
|
+
}
|
|
10909
|
+
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
10910
|
+
// The only way to switch from HTML namespace to SVG
|
|
10911
|
+
// is via <svg>. If it happens via any other tag, then
|
|
10912
|
+
// it should be killed.
|
|
10913
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
10914
|
+
return tagName === 'svg';
|
|
10915
|
+
}
|
|
10916
|
+
|
|
10917
|
+
// The only way to switch from MathML to SVG is via`
|
|
10918
|
+
// svg if parent is either <annotation-xml> or MathML
|
|
10919
|
+
// text integration points.
|
|
10920
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
10921
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
10922
|
+
}
|
|
10923
|
+
|
|
10924
|
+
// We only allow elements that are defined in SVG
|
|
10925
|
+
// spec. All others are disallowed in SVG namespace.
|
|
10926
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
10927
|
+
}
|
|
10928
|
+
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
10929
|
+
// The only way to switch from HTML namespace to MathML
|
|
10930
|
+
// is via <math>. If it happens via any other tag, then
|
|
10931
|
+
// it should be killed.
|
|
10932
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
10933
|
+
return tagName === 'math';
|
|
10934
|
+
}
|
|
10935
|
+
|
|
10936
|
+
// The only way to switch from SVG to MathML is via
|
|
10937
|
+
// <math> and HTML integration points
|
|
10938
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
10939
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
10940
|
+
}
|
|
10941
|
+
|
|
10942
|
+
// We only allow elements that are defined in MathML
|
|
10943
|
+
// spec. All others are disallowed in MathML namespace.
|
|
10944
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
10945
|
+
}
|
|
10946
|
+
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
10947
|
+
// The only way to switch from SVG to HTML is via
|
|
10948
|
+
// HTML integration points, and from MathML to HTML
|
|
10949
|
+
// is via MathML text integration points
|
|
10950
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
10951
|
+
return false;
|
|
10952
|
+
}
|
|
10953
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
10954
|
+
return false;
|
|
10955
|
+
}
|
|
10956
|
+
|
|
10957
|
+
// We disallow tags that are specific for MathML
|
|
10958
|
+
// or SVG and should never appear in HTML namespace
|
|
10959
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
10960
|
+
}
|
|
10961
|
+
|
|
10962
|
+
// For XHTML and XML documents that support custom namespaces
|
|
10963
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
10964
|
+
return true;
|
|
10965
|
+
}
|
|
10966
|
+
|
|
10967
|
+
// The code should never reach this place (this means
|
|
10968
|
+
// that the element somehow got namespace that is not
|
|
10969
|
+
// HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
|
|
10970
|
+
// Return false just in case.
|
|
10971
|
+
return false;
|
|
10972
|
+
};
|
|
10973
|
+
|
|
10974
|
+
/**
|
|
10975
|
+
* _forceRemove
|
|
10976
|
+
*
|
|
10977
|
+
* @param {Node} node a DOM node
|
|
10978
|
+
*/
|
|
10979
|
+
const _forceRemove = function _forceRemove(node) {
|
|
10980
|
+
arrayPush(DOMPurify.removed, {
|
|
10981
|
+
element: node
|
|
10982
|
+
});
|
|
10983
|
+
try {
|
|
10984
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
10985
|
+
getParentNode(node).removeChild(node);
|
|
10986
|
+
} catch (_) {
|
|
10987
|
+
remove(node);
|
|
10988
|
+
}
|
|
10989
|
+
};
|
|
10990
|
+
|
|
10991
|
+
/**
|
|
10992
|
+
* _removeAttribute
|
|
10993
|
+
*
|
|
10994
|
+
* @param {String} name an Attribute name
|
|
10995
|
+
* @param {Node} node a DOM node
|
|
10996
|
+
*/
|
|
10997
|
+
const _removeAttribute = function _removeAttribute(name, node) {
|
|
10998
|
+
try {
|
|
10999
|
+
arrayPush(DOMPurify.removed, {
|
|
11000
|
+
attribute: node.getAttributeNode(name),
|
|
11001
|
+
from: node
|
|
11002
|
+
});
|
|
11003
|
+
} catch (_) {
|
|
11004
|
+
arrayPush(DOMPurify.removed, {
|
|
11005
|
+
attribute: null,
|
|
11006
|
+
from: node
|
|
11007
|
+
});
|
|
11008
|
+
}
|
|
11009
|
+
node.removeAttribute(name);
|
|
11010
|
+
|
|
11011
|
+
// We void attribute values for unremovable "is"" attributes
|
|
11012
|
+
if (name === 'is' && !ALLOWED_ATTR[name]) {
|
|
11013
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
11014
|
+
try {
|
|
11015
|
+
_forceRemove(node);
|
|
11016
|
+
} catch (_) {}
|
|
11017
|
+
} else {
|
|
11018
|
+
try {
|
|
11019
|
+
node.setAttribute(name, '');
|
|
11020
|
+
} catch (_) {}
|
|
11021
|
+
}
|
|
11022
|
+
}
|
|
11023
|
+
};
|
|
11024
|
+
|
|
11025
|
+
/**
|
|
11026
|
+
* _initDocument
|
|
11027
|
+
*
|
|
11028
|
+
* @param {String} dirty a string of dirty markup
|
|
11029
|
+
* @return {Document} a DOM, filled with the dirty markup
|
|
11030
|
+
*/
|
|
11031
|
+
const _initDocument = function _initDocument(dirty) {
|
|
11032
|
+
/* Create a HTML document */
|
|
11033
|
+
let doc = null;
|
|
11034
|
+
let leadingWhitespace = null;
|
|
11035
|
+
if (FORCE_BODY) {
|
|
11036
|
+
dirty = '<remove></remove>' + dirty;
|
|
11037
|
+
} else {
|
|
11038
|
+
/* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
|
|
11039
|
+
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
11040
|
+
leadingWhitespace = matches && matches[0];
|
|
11041
|
+
}
|
|
11042
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
|
|
11043
|
+
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
11044
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
11045
|
+
}
|
|
11046
|
+
const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
11047
|
+
/*
|
|
11048
|
+
* Use the DOMParser API by default, fallback later if needs be
|
|
11049
|
+
* DOMParser not work for svg when has multiple root element.
|
|
11050
|
+
*/
|
|
11051
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
11052
|
+
try {
|
|
11053
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
11054
|
+
} catch (_) {}
|
|
11055
|
+
}
|
|
11056
|
+
|
|
11057
|
+
/* Use createHTMLDocument in case DOMParser is not available */
|
|
11058
|
+
if (!doc || !doc.documentElement) {
|
|
11059
|
+
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
|
11060
|
+
try {
|
|
11061
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
|
11062
|
+
} catch (_) {
|
|
11063
|
+
// Syntax error if dirtyPayload is invalid xml
|
|
11064
|
+
}
|
|
11065
|
+
}
|
|
11066
|
+
const body = doc.body || doc.documentElement;
|
|
11067
|
+
if (dirty && leadingWhitespace) {
|
|
11068
|
+
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
11069
|
+
}
|
|
11070
|
+
|
|
11071
|
+
/* Work on whole document or just its body */
|
|
11072
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
11073
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
|
11074
|
+
}
|
|
11075
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
11076
|
+
};
|
|
11077
|
+
|
|
11078
|
+
/**
|
|
11079
|
+
* Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
|
|
11080
|
+
*
|
|
11081
|
+
* @param {Node} root The root element or node to start traversing on.
|
|
11082
|
+
* @return {NodeIterator} The created NodeIterator
|
|
11083
|
+
*/
|
|
11084
|
+
const _createNodeIterator = function _createNodeIterator(root) {
|
|
11085
|
+
return createNodeIterator.call(root.ownerDocument || root, root,
|
|
11086
|
+
// eslint-disable-next-line no-bitwise
|
|
11087
|
+
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
11088
|
+
};
|
|
11089
|
+
|
|
11090
|
+
/**
|
|
11091
|
+
* _isClobbered
|
|
11092
|
+
*
|
|
11093
|
+
* @param {Node} elm element to check for clobbering attacks
|
|
11094
|
+
* @return {Boolean} true if clobbered, false if safe
|
|
11095
|
+
*/
|
|
11096
|
+
const _isClobbered = function _isClobbered(elm) {
|
|
11097
|
+
return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
|
|
11098
|
+
};
|
|
11099
|
+
|
|
11100
|
+
/**
|
|
11101
|
+
* Checks whether the given object is a DOM node.
|
|
11102
|
+
*
|
|
11103
|
+
* @param {Node} object object to check whether it's a DOM node
|
|
11104
|
+
* @return {Boolean} true is object is a DOM node
|
|
11105
|
+
*/
|
|
11106
|
+
const _isNode = function _isNode(object) {
|
|
11107
|
+
return typeof Node === 'function' && object instanceof Node;
|
|
11108
|
+
};
|
|
11109
|
+
|
|
11110
|
+
/**
|
|
11111
|
+
* _executeHook
|
|
11112
|
+
* Execute user configurable hooks
|
|
11113
|
+
*
|
|
11114
|
+
* @param {String} entryPoint Name of the hook's entry point
|
|
11115
|
+
* @param {Node} currentNode node to work on with the hook
|
|
11116
|
+
* @param {Object} data additional hook parameters
|
|
11117
|
+
*/
|
|
11118
|
+
const _executeHook = function _executeHook(entryPoint, currentNode, data) {
|
|
11119
|
+
if (!hooks[entryPoint]) {
|
|
11120
|
+
return;
|
|
11121
|
+
}
|
|
11122
|
+
arrayForEach(hooks[entryPoint], hook => {
|
|
11123
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
11124
|
+
});
|
|
11125
|
+
};
|
|
11126
|
+
|
|
11127
|
+
/**
|
|
11128
|
+
* _sanitizeElements
|
|
11129
|
+
*
|
|
11130
|
+
* @protect nodeName
|
|
11131
|
+
* @protect textContent
|
|
11132
|
+
* @protect removeChild
|
|
11133
|
+
*
|
|
11134
|
+
* @param {Node} currentNode to check for permission to exist
|
|
11135
|
+
* @return {Boolean} true if node was killed, false if left alive
|
|
11136
|
+
*/
|
|
11137
|
+
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
11138
|
+
let content = null;
|
|
11139
|
+
|
|
11140
|
+
/* Execute a hook if present */
|
|
11141
|
+
_executeHook('beforeSanitizeElements', currentNode, null);
|
|
11142
|
+
|
|
11143
|
+
/* Check if element is clobbered or can clobber */
|
|
11144
|
+
if (_isClobbered(currentNode)) {
|
|
11145
|
+
_forceRemove(currentNode);
|
|
11146
|
+
return true;
|
|
11147
|
+
}
|
|
11148
|
+
|
|
11149
|
+
/* Now let's check the element's type and name */
|
|
11150
|
+
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
11151
|
+
|
|
11152
|
+
/* Execute a hook if present */
|
|
11153
|
+
_executeHook('uponSanitizeElement', currentNode, {
|
|
11154
|
+
tagName,
|
|
11155
|
+
allowedTags: ALLOWED_TAGS
|
|
11156
|
+
});
|
|
11157
|
+
|
|
11158
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
11159
|
+
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
|
11160
|
+
_forceRemove(currentNode);
|
|
11161
|
+
return true;
|
|
11162
|
+
}
|
|
11163
|
+
|
|
11164
|
+
/* Remove any occurrence of processing instructions */
|
|
11165
|
+
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
11166
|
+
_forceRemove(currentNode);
|
|
11167
|
+
return true;
|
|
11168
|
+
}
|
|
11169
|
+
|
|
11170
|
+
/* Remove any kind of possibly harmful comments */
|
|
11171
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
|
11172
|
+
_forceRemove(currentNode);
|
|
11173
|
+
return true;
|
|
11174
|
+
}
|
|
11175
|
+
|
|
11176
|
+
/* Remove element if anything forbids its presence */
|
|
11177
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
11178
|
+
/* Check if we have a custom element to handle */
|
|
11179
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
11180
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
11181
|
+
return false;
|
|
11182
|
+
}
|
|
11183
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
11184
|
+
return false;
|
|
11185
|
+
}
|
|
11186
|
+
}
|
|
11187
|
+
|
|
11188
|
+
/* Keep content except for bad-listed elements */
|
|
11189
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
11190
|
+
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
11191
|
+
const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
11192
|
+
if (childNodes && parentNode) {
|
|
11193
|
+
const childCount = childNodes.length;
|
|
11194
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
11195
|
+
const childClone = cloneNode(childNodes[i], true);
|
|
11196
|
+
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
|
11197
|
+
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
11198
|
+
}
|
|
11199
|
+
}
|
|
11200
|
+
}
|
|
11201
|
+
_forceRemove(currentNode);
|
|
11202
|
+
return true;
|
|
11203
|
+
}
|
|
11204
|
+
|
|
11205
|
+
/* Check whether element has a valid namespace */
|
|
11206
|
+
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
11207
|
+
_forceRemove(currentNode);
|
|
11208
|
+
return true;
|
|
11209
|
+
}
|
|
11210
|
+
|
|
11211
|
+
/* Make sure that older browsers don't get fallback-tag mXSS */
|
|
11212
|
+
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
|
|
11213
|
+
_forceRemove(currentNode);
|
|
11214
|
+
return true;
|
|
11215
|
+
}
|
|
11216
|
+
|
|
11217
|
+
/* Sanitize element content to be template-safe */
|
|
11218
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
11219
|
+
/* Get the element's text content */
|
|
11220
|
+
content = currentNode.textContent;
|
|
11221
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
11222
|
+
content = stringReplace(content, expr, ' ');
|
|
11223
|
+
});
|
|
11224
|
+
if (currentNode.textContent !== content) {
|
|
11225
|
+
arrayPush(DOMPurify.removed, {
|
|
11226
|
+
element: currentNode.cloneNode()
|
|
11227
|
+
});
|
|
11228
|
+
currentNode.textContent = content;
|
|
11229
|
+
}
|
|
11230
|
+
}
|
|
11231
|
+
|
|
11232
|
+
/* Execute a hook if present */
|
|
11233
|
+
_executeHook('afterSanitizeElements', currentNode, null);
|
|
11234
|
+
return false;
|
|
11235
|
+
};
|
|
11236
|
+
|
|
11237
|
+
/**
|
|
11238
|
+
* _isValidAttribute
|
|
11239
|
+
*
|
|
11240
|
+
* @param {string} lcTag Lowercase tag name of containing element.
|
|
11241
|
+
* @param {string} lcName Lowercase attribute name.
|
|
11242
|
+
* @param {string} value Attribute value.
|
|
11243
|
+
* @return {Boolean} Returns true if `value` is valid, otherwise false.
|
|
11244
|
+
*/
|
|
11245
|
+
// eslint-disable-next-line complexity
|
|
11246
|
+
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
11247
|
+
/* Make sure attribute cannot clobber */
|
|
11248
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
11249
|
+
return false;
|
|
11250
|
+
}
|
|
11251
|
+
|
|
11252
|
+
/* Allow valid data-* attributes: At least one character after "-"
|
|
11253
|
+
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
11254
|
+
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
11255
|
+
We don't need to check the value; it's always URI safe. */
|
|
11256
|
+
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
11257
|
+
if (
|
|
11258
|
+
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
11259
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
11260
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
11261
|
+
_isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) ||
|
|
11262
|
+
// Alternative, second condition checks if it's an `is`-attribute, AND
|
|
11263
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
11264
|
+
lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
|
|
11265
|
+
return false;
|
|
11266
|
+
}
|
|
11267
|
+
/* Check value is safe. First, is attr inert? If so, is safe */
|
|
11268
|
+
} else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
|
|
11269
|
+
return false;
|
|
11270
|
+
} else ;
|
|
11271
|
+
return true;
|
|
11272
|
+
};
|
|
11273
|
+
|
|
11274
|
+
/**
|
|
11275
|
+
* _isBasicCustomElement
|
|
11276
|
+
* checks if at least one dash is included in tagName, and it's not the first char
|
|
11277
|
+
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
|
|
11278
|
+
*
|
|
11279
|
+
* @param {string} tagName name of the tag of the node to sanitize
|
|
11280
|
+
* @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
|
11281
|
+
*/
|
|
11282
|
+
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
11283
|
+
return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);
|
|
11284
|
+
};
|
|
11285
|
+
|
|
11286
|
+
/**
|
|
11287
|
+
* _sanitizeAttributes
|
|
11288
|
+
*
|
|
11289
|
+
* @protect attributes
|
|
11290
|
+
* @protect nodeName
|
|
11291
|
+
* @protect removeAttribute
|
|
11292
|
+
* @protect setAttribute
|
|
11293
|
+
*
|
|
11294
|
+
* @param {Node} currentNode to sanitize
|
|
11295
|
+
*/
|
|
11296
|
+
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
11297
|
+
/* Execute a hook if present */
|
|
11298
|
+
_executeHook('beforeSanitizeAttributes', currentNode, null);
|
|
11299
|
+
const {
|
|
11300
|
+
attributes
|
|
11301
|
+
} = currentNode;
|
|
11302
|
+
|
|
11303
|
+
/* Check if we have attributes; if not we might have a text node */
|
|
11304
|
+
if (!attributes) {
|
|
11305
|
+
return;
|
|
11306
|
+
}
|
|
11307
|
+
const hookEvent = {
|
|
11308
|
+
attrName: '',
|
|
11309
|
+
attrValue: '',
|
|
11310
|
+
keepAttr: true,
|
|
11311
|
+
allowedAttributes: ALLOWED_ATTR
|
|
11312
|
+
};
|
|
11313
|
+
let l = attributes.length;
|
|
11314
|
+
|
|
11315
|
+
/* Go backwards over all attributes; safely remove bad ones */
|
|
11316
|
+
while (l--) {
|
|
11317
|
+
const attr = attributes[l];
|
|
11318
|
+
const {
|
|
11319
|
+
name,
|
|
11320
|
+
namespaceURI,
|
|
11321
|
+
value: attrValue
|
|
11322
|
+
} = attr;
|
|
11323
|
+
const lcName = transformCaseFunc(name);
|
|
11324
|
+
let value = name === 'value' ? attrValue : stringTrim(attrValue);
|
|
11325
|
+
|
|
11326
|
+
/* Execute a hook if present */
|
|
11327
|
+
hookEvent.attrName = lcName;
|
|
11328
|
+
hookEvent.attrValue = value;
|
|
11329
|
+
hookEvent.keepAttr = true;
|
|
11330
|
+
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
11331
|
+
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
|
|
11332
|
+
value = hookEvent.attrValue;
|
|
11333
|
+
|
|
11334
|
+
/* Work around a security issue with comments inside attributes */
|
|
11335
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
|
11336
|
+
_removeAttribute(name, currentNode);
|
|
11337
|
+
continue;
|
|
11338
|
+
}
|
|
11339
|
+
|
|
11340
|
+
/* Did the hooks approve of the attribute? */
|
|
11341
|
+
if (hookEvent.forceKeepAttr) {
|
|
11342
|
+
continue;
|
|
11343
|
+
}
|
|
11344
|
+
|
|
11345
|
+
/* Remove attribute */
|
|
11346
|
+
_removeAttribute(name, currentNode);
|
|
11347
|
+
|
|
11348
|
+
/* Did the hooks approve of the attribute? */
|
|
11349
|
+
if (!hookEvent.keepAttr) {
|
|
11350
|
+
continue;
|
|
11351
|
+
}
|
|
11352
|
+
|
|
11353
|
+
/* Work around a security issue in jQuery 3.0 */
|
|
11354
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
|
11355
|
+
_removeAttribute(name, currentNode);
|
|
11356
|
+
continue;
|
|
11357
|
+
}
|
|
11358
|
+
|
|
11359
|
+
/* Sanitize attribute content to be template-safe */
|
|
11360
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
11361
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
11362
|
+
value = stringReplace(value, expr, ' ');
|
|
11363
|
+
});
|
|
11364
|
+
}
|
|
11365
|
+
|
|
11366
|
+
/* Is `value` valid for this attribute? */
|
|
11367
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
11368
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
11369
|
+
continue;
|
|
11370
|
+
}
|
|
11371
|
+
|
|
11372
|
+
/* Full DOM Clobbering protection via namespace isolation,
|
|
11373
|
+
* Prefix id and name attributes with `user-content-`
|
|
11374
|
+
*/
|
|
11375
|
+
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
11376
|
+
// Remove the attribute with this value
|
|
11377
|
+
_removeAttribute(name, currentNode);
|
|
11378
|
+
|
|
11379
|
+
// Prefix the value and later re-create the attribute with the sanitized value
|
|
11380
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
11381
|
+
}
|
|
11382
|
+
|
|
11383
|
+
/* Handle attributes that require Trusted Types */
|
|
11384
|
+
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
|
11385
|
+
if (namespaceURI) ; else {
|
|
11386
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
11387
|
+
case 'TrustedHTML':
|
|
11388
|
+
{
|
|
11389
|
+
value = trustedTypesPolicy.createHTML(value);
|
|
11390
|
+
break;
|
|
11391
|
+
}
|
|
11392
|
+
case 'TrustedScriptURL':
|
|
11393
|
+
{
|
|
11394
|
+
value = trustedTypesPolicy.createScriptURL(value);
|
|
11395
|
+
break;
|
|
11396
|
+
}
|
|
11397
|
+
}
|
|
11398
|
+
}
|
|
11399
|
+
}
|
|
11400
|
+
|
|
11401
|
+
/* Handle invalid data-* attribute set by try-catching it */
|
|
11402
|
+
try {
|
|
11403
|
+
if (namespaceURI) {
|
|
11404
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
11405
|
+
} else {
|
|
11406
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
11407
|
+
currentNode.setAttribute(name, value);
|
|
11408
|
+
}
|
|
11409
|
+
if (_isClobbered(currentNode)) {
|
|
11410
|
+
_forceRemove(currentNode);
|
|
11411
|
+
} else {
|
|
11412
|
+
arrayPop(DOMPurify.removed);
|
|
11413
|
+
}
|
|
11414
|
+
} catch (_) {}
|
|
11415
|
+
}
|
|
11416
|
+
|
|
11417
|
+
/* Execute a hook if present */
|
|
11418
|
+
_executeHook('afterSanitizeAttributes', currentNode, null);
|
|
11419
|
+
};
|
|
11420
|
+
|
|
11421
|
+
/**
|
|
11422
|
+
* _sanitizeShadowDOM
|
|
11423
|
+
*
|
|
11424
|
+
* @param {DocumentFragment} fragment to iterate over recursively
|
|
11425
|
+
*/
|
|
11426
|
+
const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
11427
|
+
let shadowNode = null;
|
|
11428
|
+
const shadowIterator = _createNodeIterator(fragment);
|
|
11429
|
+
|
|
11430
|
+
/* Execute a hook if present */
|
|
11431
|
+
_executeHook('beforeSanitizeShadowDOM', fragment, null);
|
|
11432
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
11433
|
+
/* Execute a hook if present */
|
|
11434
|
+
_executeHook('uponSanitizeShadowNode', shadowNode, null);
|
|
11435
|
+
|
|
11436
|
+
/* Sanitize tags and elements */
|
|
11437
|
+
if (_sanitizeElements(shadowNode)) {
|
|
11438
|
+
continue;
|
|
11439
|
+
}
|
|
11440
|
+
|
|
11441
|
+
/* Deep shadow DOM detected */
|
|
11442
|
+
if (shadowNode.content instanceof DocumentFragment) {
|
|
11443
|
+
_sanitizeShadowDOM(shadowNode.content);
|
|
11444
|
+
}
|
|
11445
|
+
|
|
11446
|
+
/* Check attributes, sanitize if necessary */
|
|
11447
|
+
_sanitizeAttributes(shadowNode);
|
|
11448
|
+
}
|
|
11449
|
+
|
|
11450
|
+
/* Execute a hook if present */
|
|
11451
|
+
_executeHook('afterSanitizeShadowDOM', fragment, null);
|
|
11452
|
+
};
|
|
11453
|
+
|
|
11454
|
+
/**
|
|
11455
|
+
* Sanitize
|
|
11456
|
+
* Public method providing core sanitation functionality
|
|
11457
|
+
*
|
|
11458
|
+
* @param {String|Node} dirty string or DOM node
|
|
11459
|
+
* @param {Object} cfg object
|
|
11460
|
+
*/
|
|
11461
|
+
// eslint-disable-next-line complexity
|
|
11462
|
+
DOMPurify.sanitize = function (dirty) {
|
|
11463
|
+
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
11464
|
+
let body = null;
|
|
11465
|
+
let importedNode = null;
|
|
11466
|
+
let currentNode = null;
|
|
11467
|
+
let returnNode = null;
|
|
11468
|
+
/* Make sure we have a string to sanitize.
|
|
11469
|
+
DO NOT return early, as this will return the wrong type if
|
|
11470
|
+
the user has requested a DOM object rather than a string */
|
|
11471
|
+
IS_EMPTY_INPUT = !dirty;
|
|
11472
|
+
if (IS_EMPTY_INPUT) {
|
|
11473
|
+
dirty = '<!-->';
|
|
11474
|
+
}
|
|
11475
|
+
|
|
11476
|
+
/* Stringify, in case dirty is an object */
|
|
11477
|
+
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
11478
|
+
if (typeof dirty.toString === 'function') {
|
|
11479
|
+
dirty = dirty.toString();
|
|
11480
|
+
if (typeof dirty !== 'string') {
|
|
11481
|
+
throw typeErrorCreate('dirty is not a string, aborting');
|
|
11482
|
+
}
|
|
11483
|
+
} else {
|
|
11484
|
+
throw typeErrorCreate('toString is not a function');
|
|
11485
|
+
}
|
|
11486
|
+
}
|
|
11487
|
+
|
|
11488
|
+
/* Return dirty HTML if DOMPurify cannot run */
|
|
11489
|
+
if (!DOMPurify.isSupported) {
|
|
11490
|
+
return dirty;
|
|
11491
|
+
}
|
|
11492
|
+
|
|
11493
|
+
/* Assign config vars */
|
|
11494
|
+
if (!SET_CONFIG) {
|
|
11495
|
+
_parseConfig(cfg);
|
|
11496
|
+
}
|
|
11497
|
+
|
|
11498
|
+
/* Clean up removed elements */
|
|
11499
|
+
DOMPurify.removed = [];
|
|
11500
|
+
|
|
11501
|
+
/* Check if dirty is correctly typed for IN_PLACE */
|
|
11502
|
+
if (typeof dirty === 'string') {
|
|
11503
|
+
IN_PLACE = false;
|
|
11504
|
+
}
|
|
11505
|
+
if (IN_PLACE) {
|
|
11506
|
+
/* Do some early pre-sanitization to avoid unsafe root nodes */
|
|
11507
|
+
if (dirty.nodeName) {
|
|
11508
|
+
const tagName = transformCaseFunc(dirty.nodeName);
|
|
11509
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
11510
|
+
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
|
11511
|
+
}
|
|
11512
|
+
}
|
|
11513
|
+
} else if (dirty instanceof Node) {
|
|
11514
|
+
/* If dirty is a DOM element, append to an empty document to avoid
|
|
11515
|
+
elements being stripped by the parser */
|
|
11516
|
+
body = _initDocument('<!---->');
|
|
11517
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
11518
|
+
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
|
|
11519
|
+
/* Node is already a body, use as is */
|
|
11520
|
+
body = importedNode;
|
|
11521
|
+
} else if (importedNode.nodeName === 'HTML') {
|
|
11522
|
+
body = importedNode;
|
|
11523
|
+
} else {
|
|
11524
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
11525
|
+
body.appendChild(importedNode);
|
|
11526
|
+
}
|
|
11527
|
+
} else {
|
|
11528
|
+
/* Exit directly if we have nothing to do */
|
|
11529
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
11530
|
+
// eslint-disable-next-line unicorn/prefer-includes
|
|
11531
|
+
dirty.indexOf('<') === -1) {
|
|
11532
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
11533
|
+
}
|
|
11534
|
+
|
|
11535
|
+
/* Initialize the document to work on */
|
|
11536
|
+
body = _initDocument(dirty);
|
|
11537
|
+
|
|
11538
|
+
/* Check we have a DOM node from the data */
|
|
11539
|
+
if (!body) {
|
|
11540
|
+
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
|
11541
|
+
}
|
|
11542
|
+
}
|
|
11543
|
+
|
|
11544
|
+
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
11545
|
+
if (body && FORCE_BODY) {
|
|
11546
|
+
_forceRemove(body.firstChild);
|
|
11547
|
+
}
|
|
11548
|
+
|
|
11549
|
+
/* Get node iterator */
|
|
11550
|
+
const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
|
|
11551
|
+
|
|
11552
|
+
/* Now start iterating over the created document */
|
|
11553
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
11554
|
+
/* Sanitize tags and elements */
|
|
11555
|
+
if (_sanitizeElements(currentNode)) {
|
|
11556
|
+
continue;
|
|
11557
|
+
}
|
|
11558
|
+
|
|
11559
|
+
/* Shadow DOM detected, sanitize it */
|
|
11560
|
+
if (currentNode.content instanceof DocumentFragment) {
|
|
11561
|
+
_sanitizeShadowDOM(currentNode.content);
|
|
11562
|
+
}
|
|
11563
|
+
|
|
11564
|
+
/* Check attributes, sanitize if necessary */
|
|
11565
|
+
_sanitizeAttributes(currentNode);
|
|
11566
|
+
}
|
|
11567
|
+
|
|
11568
|
+
/* If we sanitized `dirty` in-place, return it. */
|
|
11569
|
+
if (IN_PLACE) {
|
|
11570
|
+
return dirty;
|
|
11571
|
+
}
|
|
11572
|
+
|
|
11573
|
+
/* Return sanitized string or DOM */
|
|
11574
|
+
if (RETURN_DOM) {
|
|
11575
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
11576
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
11577
|
+
while (body.firstChild) {
|
|
11578
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
11579
|
+
returnNode.appendChild(body.firstChild);
|
|
11580
|
+
}
|
|
11581
|
+
} else {
|
|
11582
|
+
returnNode = body;
|
|
11583
|
+
}
|
|
11584
|
+
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
|
|
11585
|
+
/*
|
|
11586
|
+
AdoptNode() is not used because internal state is not reset
|
|
11587
|
+
(e.g. the past names map of a HTMLFormElement), this is safe
|
|
11588
|
+
in theory but we would rather not risk another attack vector.
|
|
11589
|
+
The state that is cloned by importNode() is explicitly defined
|
|
11590
|
+
by the specs.
|
|
11591
|
+
*/
|
|
11592
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
11593
|
+
}
|
|
11594
|
+
return returnNode;
|
|
11595
|
+
}
|
|
11596
|
+
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
11597
|
+
|
|
11598
|
+
/* Serialize doctype if allowed */
|
|
11599
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
11600
|
+
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
|
11601
|
+
}
|
|
11602
|
+
|
|
11603
|
+
/* Sanitize final string template-safe */
|
|
11604
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
11605
|
+
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
11606
|
+
serializedHTML = stringReplace(serializedHTML, expr, ' ');
|
|
11607
|
+
});
|
|
11608
|
+
}
|
|
11609
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
11610
|
+
};
|
|
11611
|
+
|
|
11612
|
+
/**
|
|
11613
|
+
* Public method to set the configuration once
|
|
11614
|
+
* setConfig
|
|
11615
|
+
*
|
|
11616
|
+
* @param {Object} cfg configuration object
|
|
11617
|
+
*/
|
|
11618
|
+
DOMPurify.setConfig = function () {
|
|
11619
|
+
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11620
|
+
_parseConfig(cfg);
|
|
11621
|
+
SET_CONFIG = true;
|
|
11622
|
+
};
|
|
11623
|
+
|
|
11624
|
+
/**
|
|
11625
|
+
* Public method to remove the configuration
|
|
11626
|
+
* clearConfig
|
|
11627
|
+
*
|
|
11628
|
+
*/
|
|
11629
|
+
DOMPurify.clearConfig = function () {
|
|
11630
|
+
CONFIG = null;
|
|
11631
|
+
SET_CONFIG = false;
|
|
11632
|
+
};
|
|
11633
|
+
|
|
11634
|
+
/**
|
|
11635
|
+
* Public method to check if an attribute value is valid.
|
|
11636
|
+
* Uses last set config, if any. Otherwise, uses config defaults.
|
|
11637
|
+
* isValidAttribute
|
|
11638
|
+
*
|
|
11639
|
+
* @param {String} tag Tag name of containing element.
|
|
11640
|
+
* @param {String} attr Attribute name.
|
|
11641
|
+
* @param {String} value Attribute value.
|
|
11642
|
+
* @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
|
|
11643
|
+
*/
|
|
11644
|
+
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
11645
|
+
/* Initialize shared config vars if necessary. */
|
|
11646
|
+
if (!CONFIG) {
|
|
11647
|
+
_parseConfig({});
|
|
11648
|
+
}
|
|
11649
|
+
const lcTag = transformCaseFunc(tag);
|
|
11650
|
+
const lcName = transformCaseFunc(attr);
|
|
11651
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
11652
|
+
};
|
|
11653
|
+
|
|
11654
|
+
/**
|
|
11655
|
+
* AddHook
|
|
11656
|
+
* Public method to add DOMPurify hooks
|
|
11657
|
+
*
|
|
11658
|
+
* @param {String} entryPoint entry point for the hook to add
|
|
11659
|
+
* @param {Function} hookFunction function to execute
|
|
11660
|
+
*/
|
|
11661
|
+
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
11662
|
+
if (typeof hookFunction !== 'function') {
|
|
11663
|
+
return;
|
|
11664
|
+
}
|
|
11665
|
+
hooks[entryPoint] = hooks[entryPoint] || [];
|
|
11666
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
11667
|
+
};
|
|
11668
|
+
|
|
11669
|
+
/**
|
|
11670
|
+
* RemoveHook
|
|
11671
|
+
* Public method to remove a DOMPurify hook at a given entryPoint
|
|
11672
|
+
* (pops it from the stack of hooks if more are present)
|
|
11673
|
+
*
|
|
11674
|
+
* @param {String} entryPoint entry point for the hook to remove
|
|
11675
|
+
* @return {Function} removed(popped) hook
|
|
11676
|
+
*/
|
|
11677
|
+
DOMPurify.removeHook = function (entryPoint) {
|
|
11678
|
+
if (hooks[entryPoint]) {
|
|
11679
|
+
return arrayPop(hooks[entryPoint]);
|
|
11680
|
+
}
|
|
11681
|
+
};
|
|
11682
|
+
|
|
11683
|
+
/**
|
|
11684
|
+
* RemoveHooks
|
|
11685
|
+
* Public method to remove all DOMPurify hooks at a given entryPoint
|
|
11686
|
+
*
|
|
11687
|
+
* @param {String} entryPoint entry point for the hooks to remove
|
|
11688
|
+
*/
|
|
11689
|
+
DOMPurify.removeHooks = function (entryPoint) {
|
|
11690
|
+
if (hooks[entryPoint]) {
|
|
11691
|
+
hooks[entryPoint] = [];
|
|
11692
|
+
}
|
|
11693
|
+
};
|
|
11694
|
+
|
|
11695
|
+
/**
|
|
11696
|
+
* RemoveAllHooks
|
|
11697
|
+
* Public method to remove all DOMPurify hooks
|
|
11698
|
+
*/
|
|
11699
|
+
DOMPurify.removeAllHooks = function () {
|
|
11700
|
+
hooks = {};
|
|
11701
|
+
};
|
|
11702
|
+
return DOMPurify;
|
|
11703
|
+
}
|
|
11704
|
+
var purify = createDOMPurify();
|
|
11705
|
+
|
|
11706
|
+
return purify;
|
|
11707
|
+
|
|
11708
|
+
}));
|
|
11709
|
+
|
|
11710
|
+
} (purify));
|
|
11711
|
+
return purify.exports;
|
|
11712
|
+
}
|
|
11713
|
+
|
|
11714
|
+
window.DOMPurify || (window.DOMPurify = requirePurify().default || requirePurify());
|
|
11715
|
+
|
|
10139
11716
|
// src/utils/entries-to-string.ts
|
|
10140
11717
|
function entriesToString(obj, separator = "=") {
|
|
10141
11718
|
return !!Object.keys(obj).length ? Object.entries(obj).reduce((str, [key, value]) => [...str, `${key}${separator}${value}`], []).join(",") : "";
|
|
@@ -10319,7 +11896,7 @@ var Checkout$1 = class Checkout {
|
|
|
10319
11896
|
};
|
|
10320
11897
|
|
|
10321
11898
|
var TEMPLATE$1 = "\n <div class=\"checkout-container\">\n <div class=\"checkout-bg-logo\"></div>\n <a href=\"#\" data-continue>Continue</a>\n <a href=\"#\" data-close>Close</a>\n </div>\n";
|
|
10322
|
-
var STYLES$3 = "\n .checkout-bg-logo {\n display: block;\n background: url({{url}}) no-repeat;\n width: 100px;\n height: 50px;\n margin: 0 auto;\n border-radius: 10px;\n background-size: contain;\n }\n [data-continue] {\n margin-top: 24px;\n display: block;\n font-family: Helvetica, sans-serif;\n text-decoration: none;\n color: #fff !important;\n border: 1px solid white;\n width: 100px;\n border-radius: 16px;\n padding: 5px;\n }\n [data-continue]:hover {\n background-color: #f2f2f2;\n border: none;\n color: rgba(0, 0, 0, 0.7) !important;\n }\n .checkout-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .checkout-overlay {\n z-index: 2147483647;\n }\n\n .checkout-container [data-close] {\n opacity: 1;\n }\n .checkout-container [data-close]:before,\n .checkout-container [data-close]:after {\n background-color: #fff;\n }\n";
|
|
11899
|
+
var STYLES$3 = "\n .checkout-bg-logo {\n display: block;\n background: url({{url}}) no-repeat;\n width: 100px;\n height: 50px;\n margin: 0 auto;\n border-radius: 10px;\n background-size: contain;\n background-position: 50% 50%;\n }\n [data-continue] {\n margin-top: 24px;\n display: block;\n font-family: Helvetica, sans-serif;\n text-decoration: none;\n color: #fff !important;\n border: 1px solid white;\n width: 100px;\n border-radius: 16px;\n padding: 5px;\n }\n [data-continue]:hover {\n background-color: #f2f2f2;\n border: none;\n color: rgba(0, 0, 0, 0.7) !important;\n }\n .checkout-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .checkout-overlay {\n z-index: 2147483647;\n }\n\n .checkout-container [data-close] {\n opacity: 1;\n }\n .checkout-container [data-close]:before,\n .checkout-container [data-close]:after {\n background-color: #fff;\n }\n";
|
|
10323
11900
|
var WalletBackground = /*#__PURE__*/function (_Background) {
|
|
10324
11901
|
function WalletBackground(bgImageUrl) {
|
|
10325
11902
|
var _this;
|
|
@@ -10393,10 +11970,10 @@ function getOverlayId(widgetId) {
|
|
|
10393
11970
|
}
|
|
10394
11971
|
function createFlypayV2ButtonStyle(widgetId) {
|
|
10395
11972
|
var widgetClassName = getWidgetClassName(widgetId);
|
|
10396
|
-
return "\n .".concat(widgetClassName, " {\n position: relative;\n height: 100%;\n width: 100%;\n border: none; /* Remove borders */\n background: transparent; /* Make the button background transparent */\n cursor: pointer; /* Make it look clickable */\n outline: none; /* Remove focus outline */\n padding: 0; /* Remove any default padding */\n }\n\n .").concat(widgetClassName, " .paydock-flypay-button {\n background-color: #212121;\n border-radius: 9999px;\n width: 100%; /* set hard pixel dimensions here for a button with intrinsic dimensions */\n height: 100%; /* and leave the 100% settings for the Coles use case (enabled by extra param object flag) */\n display: grid;\n grid-template-columns: 20% 1fr 20%;\n grid-template-rows: 20% 1fr 20%;\n grid-template-areas:\n \". . .\"\n \". center .\"\n \". . .\";\n box-sizing: border-box;\n }\n
|
|
11973
|
+
return "\n .".concat(widgetClassName, " {\n position: relative;\n height: 100%;\n width: 100%;\n border: none; /* Remove borders */\n background: transparent; /* Make the button background transparent */\n cursor: pointer; /* Make it look clickable */\n outline: none; /* Remove focus outline */\n padding: 0; /* Remove any default padding */\n }\n\n .").concat(widgetClassName, " .paydock-flypay-button {\n background-color: #212121;\n border-radius: 9999px;\n width: 100%; /* set hard pixel dimensions here for a button with intrinsic dimensions */\n height: 100%; /* and leave the 100% settings for the Coles use case (enabled by extra param object flag) */\n display: grid;\n grid-template-columns: 20% 1fr 20%;\n grid-template-rows: 20% 1fr 20%;\n grid-template-areas:\n \". . .\"\n \". center .\"\n \". . .\";\n box-sizing: border-box;\n }\n\n .").concat(widgetClassName, " .paydock-flypay-button:hover {\n background-color: #3d3d3d;\n }\n\n .").concat(widgetClassName, " .paydock-flypay-button:focus-visible {\n outline-color: transparent;\n box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #2670ee;\n outline-color: transparent;\n }\n\n .").concat(widgetClassName, " .paydock-flypay-button:active {\n background-color: #6f6f6f;\n }\n\n .").concat(widgetClassName, " .paydock-flypay-button:disabled,\n .").concat(widgetClassName, " .paydock-flypay-button__disabled {\n opacity: 25%;\n cursor: not-allowed;\n }\n\n #").concat(widgetId, "-loading-overlay {\n position: absolute;\n height: 100%;\n width: 100%;\n background: rgba(255, 255, 255, 0.7);\n display: none;\n justify-content: center;\n align-items: center;\n cursor: not-allowed; /* Make it look not clickable */\n }\n\n #").concat(widgetId, "-loading-overlay::after {\n content: \"\";\n height: 60%;\n aspect-ratio: 1 / 1;\n display: inline-block;\n border: 4px solid #ccc;\n border-top-color: #333;\n border-radius: 50%;\n /* Vendor prefixes for animation property */\n -webkit-animation: spin 1s infinite linear;\n -moz-animation: spin 1s infinite linear;\n -o-animation: spin 1s infinite linear;\n animation: spin 1s infinite linear;\n }\n\n @-webkit-keyframes spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n\n @-moz-keyframes spin {\n 0% {\n -moz-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -moz-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n\n @-o-keyframes spin {\n 0% {\n -o-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -o-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n\n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n ");
|
|
10397
11974
|
}
|
|
10398
11975
|
function getButtonWithClassNames(classNames, containerId) {
|
|
10399
|
-
return "\n <div id=\"".concat(containerId, "-loading-overlay\"></div>\n <div class=\"").concat(classNames, "\" tabindex=\"0\">\n <svg
|
|
11976
|
+
return "\n <div id=\"".concat(containerId, "-loading-overlay\"></div>\n <div class=\"").concat(classNames, "\" tabindex=\"0\">\n <svg\n viewBox=\"0 0 356 74\"\n data-name=\"pay-with-coles-pay\"\n fill=\"none\"\n style=\"grid-area: center; width: 100%; height: 100%\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M274.326 54.9868H280.946L282.661 45.6527C284.218 47.6804 286.291 48.3936 288.803 48.3936C295.623 48.3936 301.962 42.0781 301.962 34.2162C301.962 28.3776 298.69 24.8447 293.149 24.8447C290.275 24.8447 287.766 25.9146 285.693 28.0209H285.57L286.009 25.5993H279.787L274.326 54.9868ZM283.973 37.6743C283.973 34.1788 287.203 31.0023 290.633 31.0023L290.631 30.9983C293.502 30.9983 295.255 32.9058 295.255 35.6051C295.255 38.9847 292.103 42.24 288.558 42.24C285.888 42.24 283.973 40.4153 283.973 37.6743ZM318.51 47.643L318.946 45.2588H318.868C317.311 47.3237 314.641 48.3976 311.81 48.3976C306.306 48.3976 302.638 44.7818 302.638 39.1837C302.638 31.1228 309.298 24.8447 316.156 24.8447C318.988 24.8447 321.304 25.9185 322.098 27.9421H322.178L322.614 25.5993H329.236L325.125 47.643H318.51ZM320.663 35.5305C320.663 32.7896 318.825 31.0023 315.994 31.0023C312.646 31.0023 309.416 34.1414 309.416 37.5957C309.416 40.3367 311.131 42.244 313.963 42.244C317.593 42.244 320.663 39.0677 320.663 35.5305ZM329.356 54.991L334.419 46.5317L330.112 25.5993H337.17L339.204 38.3877H339.281L345.901 25.5993H352.922L336.372 54.991H329.356Z\" fill=\"white\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M221.032 18.351H226.224V48.4268H221.032V18.351ZM250.228 37.6828C250.261 37.2972 250.277 36.9033 250.277 36.5052C250.299 27.764 243.627 24.82 239.026 24.8158C234.423 24.8158 227.755 27.764 227.772 36.5052C227.76 43.7494 233.044 48.4228 239.031 48.4228C244.006 48.4353 248.383 45.1468 249.731 40.3781H244.64C243.599 42.5303 241.424 43.907 239.026 43.9402C235.888 43.9402 233.084 41.5268 232.585 37.6828H250.228ZM239.026 29.0661C241.876 29.067 244.381 30.9494 245.165 33.6814H232.887C233.669 30.9494 236.173 29.067 239.026 29.0661ZM260.582 48.3605C254.591 48.3605 251.156 45.4868 251.156 40.4776V40.3741H255.84V40.4736C256.047 43.14 257.729 44.4419 260.994 44.4419C263.706 44.4419 265.39 43.339 265.39 41.5642C265.39 40.063 264.245 39.495 261.988 38.931L258.678 38.0976C256.214 37.4962 254.565 36.783 253.495 35.8626C252.313 34.8341 251.677 33.3207 251.771 31.7574C251.717 29.8332 252.563 27.988 254.059 26.7729C255.585 25.5289 257.793 24.8779 260.441 24.8779C263.088 24.8779 265.482 25.5539 267.093 26.8353C268.684 28.0793 269.593 29.999 269.541 32.0103V32.0517H264.895V32.0103C264.771 29.8539 263.18 28.7136 260.29 28.7136C258.016 28.7136 256.61 29.6094 256.61 31.044C256.61 32.6447 258.009 33.2875 260.266 33.7974L263.072 34.4235C267.685 35.4894 270.184 36.8494 270.184 40.9713C270.262 43.0652 269.334 45.0765 267.685 46.3826C266.052 47.6598 263.576 48.3565 260.591 48.3565L260.582 48.3605ZM219.496 36.6172C219.496 30.0986 214.191 24.8158 207.646 24.8158C201.101 24.8158 195.796 30.0986 195.796 36.6172C195.796 43.1357 201.101 48.4186 207.646 48.4186C214.191 48.4186 219.496 43.1357 219.496 36.6172ZM214.754 36.6172C214.754 40.5275 211.568 43.6998 207.641 43.6998C203.716 43.6998 200.531 40.5275 200.531 36.6172C200.531 32.7068 203.716 29.5346 207.641 29.5346C211.568 29.5346 214.754 32.7068 214.754 36.6172ZM180.333 25.1765C186.679 23.58 193.122 27.4075 194.727 33.727V33.731H189.725C189.009 32.1388 187.732 30.8699 186.137 30.1567C182.552 28.5602 178.347 30.1609 176.744 33.731C175.14 37.3014 176.748 41.4894 180.333 43.0859C183.918 44.6823 188.123 43.0819 189.725 39.5115H194.727C193.659 43.7162 190.363 47.0005 186.142 48.0619C179.795 49.6583 173.35 45.831 171.747 39.5115C170.144 33.192 173.987 26.7729 180.333 25.1765Z\" fill=\"white\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M8.47326 37.2345H14.5938C17.7883 37.2345 20.2454 36.531 21.9652 35.1263C23.6873 33.7192 24.5472 31.3145 24.5472 27.9192C24.5472 24.8063 23.6873 22.5075 21.9652 21.0251C20.2454 19.5404 17.9367 18.7969 15.0437 18.7969H2.48941V47.5875H8.47326V37.2345ZM18.5822 27.9569C18.5822 29.4557 18.1911 30.5498 17.409 31.2392C16.6151 31.9286 15.5055 32.2745 14.0849 32.2745H8.47326V23.7969H14.0849C15.5055 23.7969 16.608 24.1169 17.3901 24.7545C18.1841 25.3922 18.5822 26.4604 18.5822 27.9569ZM37.0049 25.7898C33.4193 25.7898 30.8891 26.7263 29.4167 28.6016C28.4909 29.8016 27.9702 31.331 27.8525 33.1898H33.2308C33.3604 32.371 33.6219 31.7216 34.013 31.2369C34.5595 30.5875 35.4925 30.2628 36.8094 30.2628C37.9826 30.2628 38.8684 30.4322 39.4668 30.771C40.0816 31.0957 40.3879 31.6933 40.3879 32.5663C40.3879 33.2839 39.9898 33.811 39.1935 34.1498C38.7506 34.3451 38.0132 34.5075 36.9837 34.6369L35.0873 34.8722C32.9364 35.1451 31.3061 35.6016 30.1989 36.2369C28.1776 37.411 27.1669 39.3051 27.1669 41.9216C27.1669 43.9404 27.7936 45.5028 29.0445 46.611C30.3096 47.7028 31.9069 48.251 33.8363 48.251C35.3488 48.251 36.7034 47.9051 37.9025 47.2157C38.891 46.6432 39.7876 45.9253 40.5622 45.0863C40.6023 45.5686 40.6541 45.9992 40.7201 46.3757C40.7837 46.7522 40.9015 47.1569 41.0711 47.5875H47.1327V46.7663C46.8069 46.6282 46.5237 46.4056 46.3129 46.1216C46.1291 45.8628 46.0184 45.3686 45.9807 44.6392C45.9548 43.6745 45.9406 42.8533 45.9406 42.1757V32.411C45.9406 29.8463 45.0336 28.1004 43.222 27.1757C41.4104 26.251 39.3372 25.7898 37.0049 25.7898ZM35.4783 44.2086C34.7221 44.2086 34.0837 43.9922 33.563 43.5639C33.0282 43.1475 32.7597 42.4628 32.7597 41.5122C32.7597 40.4439 33.1908 39.6581 34.0507 39.1498C34.5595 38.8486 35.4006 38.5945 36.5738 38.3875L37.8248 38.1522C38.4514 38.0345 38.9391 37.9122 39.2924 37.7828C39.6576 37.6392 40.0157 37.4557 40.3667 37.2345V39.3051C40.329 41.1663 39.8013 42.4486 38.7836 43.1522C37.8207 43.843 36.664 44.2129 35.4783 44.2086Z\" fill=\"white\"/>\n <path d=\"M63.9699 26.3L59.5716 42.0035L54.9164 26.3H48.7182L56.5396 48.5258C56.5914 48.6811 56.4736 49.1141 56.1886 49.8153C55.9129 50.5188 55.6138 50.98 55.2887 51.2035C54.9494 51.4364 54.5324 51.5847 54.0377 51.6506C53.5185 51.7164 52.9941 51.736 52.4711 51.7094L51.769 51.6694V56.1235C52.3674 56.1635 52.8174 56.1823 53.1166 56.1823C53.4181 56.1941 53.8139 56.2011 54.311 56.2011C56.7752 56.2011 58.4172 55.7141 59.2394 54.7376C60.0592 53.7729 61.1736 51.2741 62.5824 47.2364L69.8949 26.3H63.9699ZM97.1756 32.0811L100.519 47.587H106.25L112.43 26.3H106.62L103.296 41.6317L100.05 26.3H94.3981L91.3284 41.5729L88.0043 26.3H82.0204L88.0043 47.5894H93.7926L97.1756 32.0811ZM121.248 47.5894V26.3H115.596V47.5894H121.248ZM121.248 23.7611V18.6223H115.596V23.7611H121.248ZM136.424 47.7847V43.6247L135.856 43.6623H135.329C134.193 43.6623 133.517 43.5588 133.295 43.3494C133.074 43.1282 132.961 42.5823 132.961 41.7094V30.46H136.424V26.4953H132.961V20.5541H127.448V26.4929H124.475V30.46H127.448V43.5658C127.448 44.8929 127.759 45.8764 128.386 46.5141C129.352 47.5164 131.149 47.9729 133.783 47.8811L136.424 47.7847ZM159.264 47.5894V35.0882C159.264 33.187 159.198 31.82 159.068 30.987C158.918 30.0906 158.548 29.2451 157.992 28.5258C157.315 27.5988 156.395 26.876 155.334 26.4364C154.2 25.9687 152.983 25.7364 151.756 25.7541C150.58 25.7541 149.461 25.9988 148.392 26.4953C147.336 26.9753 146.403 27.8364 145.595 29.0717V18.8976H140.04V47.5894H145.595V36.0647C145.595 34.2411 145.972 32.8411 146.729 31.8647C147.499 30.8764 148.62 30.3823 150.093 30.3823C151.513 30.3823 152.479 30.8764 152.986 31.8647C153.379 32.5705 153.575 33.4929 153.575 34.6411V47.5894H159.264Z\" fill=\"white\"/>\n </svg>\n </div>\n ");
|
|
10400
11977
|
}
|
|
10401
11978
|
|
|
10402
11979
|
/**
|
|
@@ -10500,7 +12077,7 @@ var FlypayV2WalletService = /*#__PURE__*/function (_WalletService) {
|
|
|
10500
12077
|
this.flypayV2Button = document.createElement('button');
|
|
10501
12078
|
this.flypayV2Button.classList.add(getWidgetClassName(this.widgetId));
|
|
10502
12079
|
this.flypayV2Button.setAttribute('type', 'button');
|
|
10503
|
-
this.flypayV2Button.setAttribute('aria-label', 'Pay with
|
|
12080
|
+
this.flypayV2Button.setAttribute('aria-label', 'Pay with Coles Pay');
|
|
10504
12081
|
this.flypayV2Button.setAttribute('id', this.widgetId);
|
|
10505
12082
|
this.flypayV2Button.innerHTML = getFlypayV2Button(this.widgetId);
|
|
10506
12083
|
return this.flypayV2Button;
|
|
@@ -10540,7 +12117,11 @@ var FlypayV2WalletService = /*#__PURE__*/function (_WalletService) {
|
|
|
10540
12117
|
return resolve(res.id);
|
|
10541
12118
|
},
|
|
10542
12119
|
onError: function onError(message, code) {
|
|
10543
|
-
|
|
12120
|
+
console.error('Error generating order id', message);
|
|
12121
|
+
_this4.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
|
|
12122
|
+
message: message
|
|
12123
|
+
});
|
|
12124
|
+
reject({
|
|
10544
12125
|
message: message,
|
|
10545
12126
|
code: code
|
|
10546
12127
|
});
|
|
@@ -11192,7 +12773,11 @@ var AppleWalletService = /*#__PURE__*/function (_WalletService) {
|
|
|
11192
12773
|
return resolve(res);
|
|
11193
12774
|
},
|
|
11194
12775
|
onError: function onError(message) {
|
|
11195
|
-
|
|
12776
|
+
console.error('Error generating order id', message);
|
|
12777
|
+
_this4.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
|
|
12778
|
+
message: message
|
|
12779
|
+
});
|
|
12780
|
+
reject(message);
|
|
11196
12781
|
}
|
|
11197
12782
|
});
|
|
11198
12783
|
});
|
|
@@ -11848,8 +13433,12 @@ var PaypalWalletService = /*#__PURE__*/function (_WalletService) {
|
|
|
11848
13433
|
onSuccess: function onSuccess(res) {
|
|
11849
13434
|
return resolve(res.id);
|
|
11850
13435
|
},
|
|
11851
|
-
onError: function onError(
|
|
11852
|
-
|
|
13436
|
+
onError: function onError(error) {
|
|
13437
|
+
console.error('Error generating order id', error);
|
|
13438
|
+
_this4.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
|
|
13439
|
+
error: error
|
|
13440
|
+
});
|
|
13441
|
+
reject(error);
|
|
11853
13442
|
}
|
|
11854
13443
|
});
|
|
11855
13444
|
});
|
|
@@ -15454,18 +17043,18 @@ var InstructionCardFormShow = /*#__PURE__*/function (_InstructionHandler) {
|
|
|
15454
17043
|
}(InstructionHandler);
|
|
15455
17044
|
InstructionCardFormShow = __decorate([Instruction('instruction.card_form.show')], InstructionCardFormShow);
|
|
15456
17045
|
|
|
15457
|
-
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 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";
|
|
17046
|
+
var TEMPLATE = "\n<style>\n @import url('https://fonts.cdnfonts.com/css/segoe-ui-4');\n @import url('https://fonts.cdnfonts.com/css/droid-sans-2');\n @import url('https://fonts.cdnfonts.com/css/helvetica-neue-55');\n @import url('https://fonts.googleapis.com/css2?family=Cantarell&family=Fira+Sans&family=Oxygen&family=Roboto&family=Ubuntu&display=swap');\n \n /* RESET DEFAULT STYLES */\n *,\n *:before,\n *:after {\n box-sizing: border-box;\n }\n\n html,\n body,\n div,\n span,\n applet,\n object,\n iframe,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n p,\n blockquote,\n pre,\n a,\n abbr,\n acronym,\n address,\n big,\n cite,\n code,\n del,\n dfn,\n em,\n img,\n ins,\n kbd,\n q,\n s,\n samp,\n small,\n strike,\n strong,\n sub,\n sup,\n tt,\n var,\n b,\n u,\n i,\n center,\n dl,\n dt,\n dd,\n ol,\n ul,\n li,\n fieldset,\n form,\n label,\n legend,\n table,\n caption,\n tbody,\n tfoot,\n thead,\n tr,\n th,\n td,\n article,\n aside,\n canvas,\n details,\n embed,\n figure,\n figcaption,\n footer,\n header,\n hgroup,\n menu,\n nav,\n output,\n ruby,\n section,\n summary,\n time,\n mark,\n audio,\n video,\n input {\n margin: 0;\n padding: 0;\n border: 0;\n font-size: 100%;\n font: inherit;\n vertical-align: baseline;\n }\n\n article,\n aside,\n details,\n figcaption,\n figure,\n footer,\n header,\n hgroup,\n menu,\n nav,\n section {\n display: block;\n }\n\n body {\n line-height: 1;\n }\n\n ol,\n ul {\n list-style: none;\n }\n\n ul {\n padding: 0;\n margin: 0;\n }\n\n /* MAIN STYLES */\n .wrap {\n padding: 10px;\n background-color: {{background_color}};\n }\n\n .widget-body {\n background-color: #fff;\n border: 1px solid {{border_color}};\n }\n\n .payment-source {\n cursor: pointer;\n padding: 1em 0.8em;\n display: flex;\n align-items: center;\n height: 70px;\n }\n\n .payment-source:not(:last-child) {\n border-bottom: 1px solid {{border_color}};\n }\n\n .payment-source__wrap {\n display: flex;\n align-items: center;\n font-family: {{font_family}};\n font-size: {{font_size}};\n color: {{text_color}}\n }\n\n .payment-source__radio {\n margin-right: 2em;\n width: 18px;\n min-width: 18px;\n height: 18px;\n border: 1px solid {{button_color}};\n border-radius: 50%;\n appearance: none;\n cursor: pointer;\n\n @media screen and (max-width: 380px) {\n margin-right: 1em;\n }\n }\n\n .payment-source__radio::before {\n content: \"\";\n display: block;\n width: 100%;\n height: 100%;\n background-color: #fff;\n border-radius: 50%;\n }\n\n .payment-source__radio:checked::before {\n border: 4px solid {{button_color}};\n outline: 1px solid {{button_color}};\n }\n\n .payment-source__title {\n margin-right: 2em;\n font-weight: 400;\n line-height: 1.2;\n\n @media screen and (max-width: 380px) {\n margin-right: 1em;\n font-size: 14px;\n }\n }\n\n .payment-source__icon {\n margin-right: 2em;\n max-height: 35px;\n\n @media screen and (max-width: 380px) {\n margin-right: 1em;\n }\n }\n\n .payment-source .card__scheme {\n margin-left: auto;\n display: flex;\n align-items: center;\n }\n\n .payment-source .card__scheme__item:not(:last-child) {\n margin-right: 10px;\n }\n\n .payment-source .card__scheme__img {\n max-width: 50px;\n\n @media screen and (max-width: 460px) {\n max-width: 40px;\n }\n\n @media screen and (max-width: 410px) {\n max-width: 30px;\n }\n }\n\n .payment-source__form {\n margin-top: 1em;\n margin-bottom: 1em;\n margin-left: calc(2em + 18px);\n\n @media screen and (max-width: 380px) {\n margin-left: calc(1em + 18px);\n }\n }\n\n .payment-source__form .form-group:not(:last-child) {\n margin-bottom: 1.5em;\n }\n\n .payment-source__form .form-control {\n padding: 10px 2px 10px 10px;\n height: 40px;\n background: #F9F9F9;\n border: 1px solid {{border_color}};\n }\n\n .payment-source__form .form-control:not(:last-child) {\n margin-right: 1.5em;\n }\n\n .payment-source__form .form-control.col-12 {\n width: calc(100% - 1.5em);\n }\n\n .payment-source__form .form-control.col-3 {\n width: calc(33.33% - 1.5em);\n }\n\n .footer__pay-btn {\n margin-left: auto;\n padding: 10px 2em;\n height: 50px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #F6F0EB;\n font-size: 16px;\n background-color: {{button_color}};\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.10), 0 0 0 0.5px rgba(0, 0, 0, 0.10);\n border: none;\n border-radius: 6px;\n cursor: pointer;\n }\n\n .footer__pay-btn--paypal {\n padding: 5px 2em;\n background-color: #FFC43A;\n }\n\n .footer__pay-btn--gpay {\n font-size: 22px;\n }\n\n .footer__pay-btn--gpay img {\n margin-left: 5px;\n }\n\n .footer__pay-btn img {\n max-height: 100%;\n }\n</style>\n<main class=\"wrap\">\n <div class=\"widget-body\">\n <ul class=\"payment-sources__list\">\n {{paymentMethods}}\n </ul>\n </div>\n</main>\n</div>\n";
|
|
15458
17047
|
|
|
15459
17048
|
var PAYMENT_METHOD = {
|
|
15460
|
-
card: "<
|
|
15461
|
-
bank_account: "<
|
|
15462
|
-
paypal_wallet: "<
|
|
15463
|
-
googlepay_wallet: "<
|
|
15464
|
-
flypay: "<li class=\"payment-source\">\n<div class=\"payment-source__wrap\">\n
|
|
15465
|
-
zip_checkout: "<li class=\"payment-source\">\n
|
|
15466
|
-
applepay_wallet: "<li class=\"payment-source\">\n
|
|
15467
|
-
afterpay_wallet: "<li class=\"payment-source\">\n<div class=\"payment-source__wrap\">\n
|
|
15468
|
-
afterpay_checkout: "<li class=\"payment-source\">\n<div class=\"payment-source__wrap\">\n
|
|
17049
|
+
card: "<label class=\"payment-source\">\n <li class=\"payment-source\">\n <div class=\"payment-source__wrap\">\n <input class=\"payment-source__radio\" pm-button=\"card\" type=\"radio\" name=\"radio-group\" />\n <h2 class=\"payment-source__title\">Pay with Credit or Debit card</h2>\n </div>\n </li>\n </label>",
|
|
17050
|
+
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>",
|
|
17051
|
+
paypal_wallet: "<label class=\"payment-source\">\n <li class=\"payment-source\">\n <div class=\"payment-source__wrap\">\n <input class=\"payment-source__radio\" pm-button=\"paypal_wallet\" type=\"radio\" name=\"radio-group\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"28\" viewBox=\"0 0 338.667 89.785\" xmlns:v=\"https://vecta.io/nano\"><g transform=\"translate(936.898 -21.779)\"><path clip-path=\"none\" d=\"M-828.604 39.734c-.697 0-1.289.506-1.398 1.195l-8.068 51.165a1.31 1.31 0 0 0 1.294 1.513h9.568c.696 0 1.289-.507 1.398-1.195l2.37-15.025c.108-.688.701-1.195 1.398-1.195h8.699c10.164 0 18.792-7.416 20.368-17.465 1.589-10.134-6.328-18.971-17.549-18.993zm9.301 11.422h6.96c5.73 0 7.596 3.381 7.006 7.12-.59 3.747-3.488 6.507-9.031 6.507h-7.084zm45.788 3.478c-2.416.009-5.196.504-8.317 1.804-7.159 2.984-10.597 9.151-12.057 13.647 0 0-4.647 13.717 5.852 21.253 0 0 9.737 7.255 20.698-.447l-.189 1.203a1.31 1.31 0 0 0 1.292 1.513h9.083c.697 0 1.289-.507 1.398-1.195l5.525-35.038a1.31 1.31 0 0 0-1.292-1.515h-9.083c-.697 0-1.29.507-1.398 1.195l-.297 1.886s-3.967-4.333-11.216-4.306zm.297 11.067c1.043 0 1.997.144 2.853.419 3.919 1.258 6.141 5.023 5.498 9.104-.793 5.025-4.914 8.725-10.199 8.725-1.042 0-1.996-.143-2.853-.418-3.918-1.258-6.154-5.023-5.511-9.104.793-5.025 4.927-8.727 10.212-8.727z\" fill=\"#003087\"/><path clip-path=\"none\" d=\"M-697.804 39.734c-.697 0-1.289.506-1.398 1.195l-8.068 51.165a1.31 1.31 0 0 0 1.294 1.513h9.568c.696 0 1.289-.507 1.398-1.195l2.37-15.025c.108-.688.701-1.195 1.398-1.195h8.699c10.164 0 18.791-7.416 20.366-17.465 1.59-10.134-6.326-18.971-17.547-18.993zm9.301 11.422h6.96c5.73 0 7.596 3.381 7.006 7.12-.59 3.747-3.487 6.507-9.031 6.507h-7.084zm45.787 3.478c-2.416.009-5.196.504-8.317 1.804-7.159 2.984-10.597 9.151-12.057 13.647 0 0-4.645 13.717 5.854 21.253 0 0 9.735 7.255 20.697-.447l-.189 1.203a1.31 1.31 0 0 0 1.294 1.513h9.082c.697 0 1.289-.507 1.398-1.195l5.527-35.038a1.31 1.31 0 0 0-1.294-1.515h-9.083c-.697 0-1.29.507-1.398 1.195l-.297 1.886s-3.967-4.333-11.216-4.306zm.297 11.067c1.043 0 1.997.144 2.853.419 3.919 1.258 6.141 5.023 5.498 9.104-.793 5.025-4.914 8.725-10.199 8.725-1.042 0-1.996-.143-2.853-.418-3.918-1.258-6.154-5.023-5.511-9.104.793-5.025 4.927-8.727 10.212-8.727z\" fill=\"#0070e0\"/><path clip-path=\"none\" d=\"M-745.92 55.859c-.72 0-1.232.703-1.012 1.388l9.958 30.901-9.004 14.562c-.437.707.071 1.62.902 1.62h10.642a1.77 1.77 0 0 0 1.513-.854l27.811-46.007c.427-.707-.083-1.611-.909-1.611h-10.641a1.77 1.77 0 0 0-1.522.869l-10.947 18.482-5.557-18.345c-.181-.597-.732-1.006-1.355-1.006z\" fill=\"#003087\"/><path clip-path=\"none\" d=\"M-609.107 39.734c-.696 0-1.289.507-1.398 1.195l-8.07 51.163a1.31 1.31 0 0 0 1.294 1.515h9.568c.696 0 1.289-.507 1.398-1.195l8.068-51.165a1.31 1.31 0 0 0-1.292-1.513z\" fill=\"#0070e0\"/><path clip-path=\"none\" d=\"M-908.37 39.734a2.59 2.59 0 0 0-2.556 2.185l-4.247 26.936c.198-1.258 1.282-2.185 2.556-2.185h12.445c12.525 0 23.153-9.137 25.095-21.519a20.76 20.76 0 0 0 .245-2.793c-3.183-1.669-6.922-2.624-11.019-2.624z\" fill=\"#001c64\"/><path clip-path=\"none\" d=\"M-874.832 42.359a20.76 20.76 0 0 1-.245 2.793c-1.942 12.382-12.571 21.519-25.095 21.519h-12.445c-1.273 0-2.358.926-2.556 2.185l-3.905 24.752-2.446 15.528a2.1 2.1 0 0 0 2.075 2.43h13.508a2.59 2.59 0 0 0 2.556-2.185l3.558-22.567a2.59 2.59 0 0 1 2.558-2.185h7.953c12.525 0 23.153-9.137 25.095-21.519 1.379-8.788-3.047-16.784-10.611-20.75z\" fill=\"#0070e0\"/><path clip-path=\"none\" d=\"M-923.716 21.779c-1.273 0-2.358.926-2.556 2.183l-10.6 67.216c-.201 1.276.785 2.43 2.077 2.43h15.719l3.903-24.752 4.247-26.936a2.59 2.59 0 0 1 2.556-2.185h22.519c4.098 0 7.836.956 11.019 2.624.218-11.273-9.084-20.58-21.873-20.58z\" fill=\"#003087\"/></g></svg>\n </div>\n </li>\n </label>",
|
|
17052
|
+
googlepay_wallet: "<label class=\"payment-source\">\n <li class=\"payment-source\">\n <div max-height: \"28px\" class=\"payment-source__wrap\">\n <input class=\"payment-source__radio\" pm-button=\"googlepay_wallet\" type=\"radio\" name=\"radio-group\" />\n <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" \n width=\"80px\" height=\"38px\" viewBox=\"0 0 80 38.1\" xml:space=\"preserve\">\n <style type=\"text/css\">\n .st0{fill:#5F6368;}\n .st1{fill:#4285F4;}\n .st2{fill:#34A853;}\n .st3{fill:#FBBC04;}\n .st4{fill:#EA4335;}\n </style>\n <path class=\"st0\" d=\"M37.8,19.7V29h-3V6h7.8c1.9,0,3.7,0.7,5.1,2c1.4,1.2,2.1,3,2.1,4.9c0,1.9-0.7,3.6-2.1,4.9c-1.4,1.3-3.1,2-5.1,2\n L37.8,19.7L37.8,19.7z M37.8,8.8v8h5c1.1,0,2.2-0.4,2.9-1.2c1.6-1.5,1.6-4,0.1-5.5c0,0-0.1-0.1-0.1-0.1c-0.8-0.8-1.8-1.3-2.9-1.2\n L37.8,8.8L37.8,8.8z\"/>\n <path class=\"st0\" d=\"M56.7,12.8c2.2,0,3.9,0.6,5.2,1.8s1.9,2.8,1.9,4.8V29H61v-2.2h-0.1c-1.2,1.8-2.9,2.7-4.9,2.7\n c-1.7,0-3.2-0.5-4.4-1.5c-1.1-1-1.8-2.4-1.8-3.9c0-1.6,0.6-2.9,1.8-3.9c1.2-1,2.9-1.4,4.9-1.4c1.8,0,3.2,0.3,4.3,1v-0.7\n c0-1-0.4-2-1.2-2.6c-0.8-0.7-1.8-1.1-2.9-1.1c-1.7,0-3,0.7-3.9,2.1l-2.6-1.6C51.8,13.8,53.9,12.8,56.7,12.8z M52.9,24.2\n c0,0.8,0.4,1.5,1,1.9c0.7,0.5,1.5,0.8,2.3,0.8c1.2,0,2.4-0.5,3.3-1.4c1-0.9,1.5-2,1.5-3.2c-0.9-0.7-2.2-1.1-3.9-1.1\n c-1.2,0-2.2,0.3-3,0.9C53.3,22.6,52.9,23.3,52.9,24.2z\"/>\n <path class=\"st0\" d=\"M80,13.3l-9.9,22.7h-3l3.7-7.9l-6.5-14.7h3.2l4.7,11.3h0.1l4.6-11.3H80z\"/>\n <path class=\"st1\" d=\"M25.9,17.7c0-0.9-0.1-1.8-0.2-2.7H13.2v5.1h7.1c-0.3,1.6-1.2,3.1-2.6,4v3.3H22C24.5,25.1,25.9,21.7,25.9,17.7z\"\n />\n <path class=\"st2\" d=\"M13.2,30.6c3.6,0,6.6-1.2,8.8-3.2l-4.3-3.3c-1.2,0.8-2.7,1.3-4.5,1.3c-3.4,0-6.4-2.3-7.4-5.5H1.4v3.4\n C3.7,27.8,8.2,30.6,13.2,30.6z\"/>\n <path class=\"st3\" d=\"M5.8,19.9c-0.6-1.6-0.6-3.4,0-5.1v-3.4H1.4c-1.9,3.7-1.9,8.1,0,11.9L5.8,19.9z\"/>\n <path class=\"st4\" d=\"M13.2,9.4c1.9,0,3.7,0.7,5.1,2l0,0l3.8-3.8c-2.4-2.2-5.6-3.5-8.8-3.4c-5,0-9.6,2.8-11.8,7.3l4.4,3.4\n C6.8,11.7,9.8,9.4,13.2,9.4z\"/>\n </svg>\n </div>\n </li>\n </label>",
|
|
17053
|
+
flypay: "<label class=\"payment-source\">\n <li class=\"payment-source\">\n <div class=\"payment-source__wrap\">\n <input class=\"payment-source__radio\" pm-button=\"flypay\" type=\"radio\" name=\"radio-group\" />\n <div class=\"payment-source__icon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"38\" viewBox=\"0 0 82 40\" fill=\"none\">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M18.2312 5.46959C18.2312 4.98803 18.6216 4.59766 19.1031 4.59766H77.3212C80.3349 4.59766 82.5618 7.40629 81.8747 10.3406L77.3202 29.7913C76.5899 32.9099 73.8086 35.1152 70.6056 35.1152H34.1637C33.6822 35.1152 33.2918 34.7248 33.2918 34.2432C33.2918 33.7617 33.6822 33.3713 34.1637 33.3713H70.6056C72.9986 33.3713 75.0766 31.7237 75.6222 29.3937L80.1768 9.94303C80.6077 8.10286 79.2111 6.34151 77.3212 6.34151H19.1031C18.6216 6.34151 18.2312 5.95114 18.2312 5.46959Z\" fill=\"black\"/>\n <path d=\"M4.29622 16.0912V27.204H0V13.6759C0 7.20014 3.7341 4.69238 7.7376 4.69238H11.5729V8.47799H7.7376C4.9845 8.47799 4.29622 11.0155 4.29622 12.2865H9.44925V16.0912H4.29622Z\" fill=\"black\"/>\n <path d=\"M17.2811 4.677L13.0007 5.78525V27.1886H17.2811V4.677Z\" fill=\"black\"/>\n <path d=\"M32.9749 29.2495V12.2073L28.7738 13.4755V19.579C28.7738 22.2741 28.0128 23.5424 25.9202 23.5424C23.8275 23.5424 23.1458 21.957 23.1458 20.1339V12.2073L19.1033 13.4755V20.451C19.1033 22.0363 19.3601 24.0179 21.2435 25.7618C23.3944 27.7535 27.0299 27.4 28.7738 26.7923V28.3776C28.7738 31.9287 27.7433 33.1336 25.0482 33.1336V36.9384C30.3591 36.9384 32.9749 33.9262 32.9749 29.2495Z\" fill=\"black\"/>\n <path d=\"M67.6141 27.1889H64.1264L65.6302 21.3583L62.72 12.2192H66.1873L68.0897 18.311L73.1558 12.2192H76.809L69.0409 21.6442L67.6141 27.1889Z\" fill=\"black\"/>\n <path d=\"M58.3963 23.8804H52.1572L50.166 27.1889H46.5293L56.4376 12.2192H59.9253L62.1448 27.1889H58.7363L58.3963 23.8804ZM57.8959 21.006L57.3095 16.3293L54.2181 21.006H57.8959Z\" fill=\"black\"/>\n <path d=\"M39.0708 27.1886H35.6699L39.1218 12.219H45.2077C49.3432 12.219 50.6898 15.7935 49.2718 19.256C47.7393 22.9981 43.469 22.5543 40.1532 22.5543L39.0708 27.1886ZM40.6637 19.8061C42.0281 19.8061 43.578 19.9845 44.8707 19.4997C46.1635 19.015 46.6087 18.4033 46.6087 16.9632C46.6087 15.3689 45.0509 15.2193 43.8905 15.2193H41.6848L40.6637 19.8061Z\" fill=\"black\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M23.2249 0.713641C23.2249 0.319643 23.5443 0.000244169 23.9382 0.000244203L47.7181 0.000246282C48.1121 0.000246316 48.4315 0.319645 48.4315 0.713643C48.4315 1.10764 48.1121 1.42704 47.7181 1.42704L23.9382 1.42704C23.5443 1.42704 23.2249 1.10764 23.2249 0.713641Z\" fill=\"black\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M39.2368 38.6028C39.2368 38.2088 39.5562 37.8894 39.9502 37.8894L63.7301 37.8894C64.1241 37.8894 64.4435 38.2088 64.4435 38.6028C64.4435 38.9968 64.1241 39.3162 63.7301 39.3162L39.9502 39.3162C39.5562 39.3162 39.2368 38.9968 39.2368 38.6028Z\" fill=\"black\"/>\n </svg>\n </div>\n </div>\n </li>\n </label>",
|
|
17054
|
+
zip_checkout: "<label class=\"payment-source\">\n <li class=\"payment-source\">\n <div class=\"payment-source__wrap\">\n <input class=\"payment-source__radio\" pm-button=\"zip_checkout\" type=\"radio\" name=\"radio-group\" />\n <svg height=\"30\" viewBox=\"0 0 768 285\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g clip-path=\"url(#clip0)\">\n <path d=\"M19.53 227.27L26.19 281.53H259.36L251.73 219.39H143.01L142.06 211.69L242.19 141.72L235.5 87.3601H2.34998L9.97998 149.49H118.88L119.83 157.26L19.53 227.27Z\" fill=\"black\"/>\n <path d=\"M262.59 87.3601L286.44 281.53H519.78L495.93 87.3601H262.59Z\" fill=\"#AA8FFF\"/>\n <path d=\"M764.47 157.26C759.09 113.62 724.81 87.1701 678.21 87.3601H523L546.84 281.54H616.67L611.89 242.7H685.78C743.93 242.69 770.54 206.46 764.47 157.26ZM678.23 188.26L605.23 188.34L599.51 141.74L672.92 141.8C690.18 142.01 699.01 151.73 700.44 165.03C701.32 173.59 697.4 188.25 678.23 188.25V188.26Z\" fill=\"black\"/>\n <path d=\"M332.303 61.5598C344.584 48.3762 342.443 26.4212 327.522 12.522C312.601 -1.37727 290.549 -1.95741 278.269 11.2262C265.988 24.4098 268.129 46.3647 283.05 60.264C297.971 74.1632 320.023 74.7434 332.303 61.5598Z\" fill=\"black\"/>\n </g>\n <defs>\n <clipPath id=\"clip0\">\n <rect width=\"768\" height=\"285\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n </div>\n </li>\n ",
|
|
17055
|
+
applepay_wallet: "<label class=\"payment-source\">\n <li class=\"payment-source\">\n <div class=\"payment-source__wrap\">\n <input class=\"payment-source__radio\" pm-button=\"applepay_wallet\" type=\"radio\" name=\"radio-group\" />\n <svg version=\"1.1\" baseProfile=\"tiny\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n width=\"78px\" height=\"32px\" viewBox=\"0 0 512 210.2\" xml:space=\"preserve\">\n <path id=\"XMLID_34_\" d=\"M93.6,27.1C87.6,34.2,78,39.8,68.4,39c-1.2-9.6,3.5-19.8,9-26.1c6-7.3,16.5-12.5,25-12.9\n C103.4,10,99.5,19.8,93.6,27.1 M102.3,40.9c-13.9-0.8-25.8,7.9-32.4,7.9c-6.7,0-16.8-7.5-27.8-7.3c-14.3,0.2-27.6,8.3-34.9,21.2\n c-15,25.8-3.9,64,10.6,85c7.1,10.4,15.6,21.8,26.8,21.4c10.6-0.4,14.8-6.9,27.6-6.9c12.9,0,16.6,6.9,27.8,6.7\n c11.6-0.2,18.9-10.4,26-20.8c8.1-11.8,11.4-23.3,11.6-23.9c-0.2-0.2-22.4-8.7-22.6-34.3c-0.2-21.4,17.5-31.6,18.3-32.2\n C123.3,42.9,107.7,41.3,102.3,40.9 M182.6,11.9v155.9h24.2v-53.3h33.5c30.6,0,52.1-21,52.1-51.4c0-30.4-21.1-51.2-51.3-51.2H182.6z\n M206.8,32.3h27.9c21,0,33,11.2,33,30.9c0,19.7-12,31-33.1,31h-27.8V32.3z M336.6,169c15.2,0,29.3-7.7,35.7-19.9h0.5v18.7h22.4V90.2\n c0-22.5-18-37-45.7-37c-25.7,0-44.7,14.7-45.4,34.9h21.8c1.8-9.6,10.7-15.9,22.9-15.9c14.8,0,23.1,6.9,23.1,19.6v8.6l-30.2,1.8\n c-28.1,1.7-43.3,13.2-43.3,33.2C298.4,155.6,314.1,169,336.6,169z M343.1,150.5c-12.9,0-21.1-6.2-21.1-15.7c0-9.8,7.9-15.5,23-16.4\n l26.9-1.7v8.8C371.9,140.1,359.5,150.5,343.1,150.5z M425.1,210.2c23.6,0,34.7-9,44.4-36.3L512,54.7h-24.6l-28.5,92.1h-0.5\n l-28.5-92.1h-25.3l41,113.5l-2.2,6.9c-3.7,11.7-9.7,16.2-20.4,16.2c-1.9,0-5.6-0.2-7.1-0.4v18.7C417.3,210,423.3,210.2,425.1,210.2z\n \"/>\n </svg>\n </div>\n </li>\n </label>",
|
|
17056
|
+
afterpay_wallet: "<label class=\"payment-source\">\n <li class=\"payment-source\">\n <div class=\"payment-source__wrap\">\n <input class=\"payment-source__radio\" pm-button=\"afterpay_wallet\" type=\"radio\" name=\"radio-group\">\n ".concat(getIcon(paymentMethods.AFTERPAY), "\n </div>\n </li>\n </label>"),
|
|
17057
|
+
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>")
|
|
15469
17058
|
};
|
|
15470
17059
|
|
|
15471
17060
|
var PAYMENTS_METHODS = {
|
|
@@ -15629,7 +17218,15 @@ var PaymentMethods = /*#__PURE__*/function () {
|
|
|
15629
17218
|
var iframeDocument = iframe.contentDocument || ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document);
|
|
15630
17219
|
if (iframeDocument) {
|
|
15631
17220
|
var radiosButtons = iframeDocument.querySelectorAll('input[type="radio"].payment-source__radio');
|
|
17221
|
+
var labels = iframeDocument.querySelectorAll('.payment-source');
|
|
17222
|
+
labels.forEach(function (label) {
|
|
17223
|
+
label.style.cursor = "not-allowed";
|
|
17224
|
+
});
|
|
15632
17225
|
radiosButtons.forEach(function (radioButton) {
|
|
17226
|
+
var labels = iframeDocument.querySelectorAll('.payment-source');
|
|
17227
|
+
labels.forEach(function (label) {
|
|
17228
|
+
label.style.cursor = "not-allowed";
|
|
17229
|
+
});
|
|
15633
17230
|
radioButton.style.cursor = "not-allowed";
|
|
15634
17231
|
if (!radioButton.checked) {
|
|
15635
17232
|
radioButton.style.border = "9px solid #EBEBE4";
|
|
@@ -16248,9 +17845,19 @@ var Checkout = /*#__PURE__*/function () {
|
|
|
16248
17845
|
var tokenContent = AccessToken.validateJWT(intentToken);
|
|
16249
17846
|
if (!tokenContent) throw new Error('Intent token is broken or expired. Please, issue new one.');
|
|
16250
17847
|
var payload = AccessToken.extractData(tokenContent.body);
|
|
16251
|
-
|
|
17848
|
+
var allowed = this.validateJWTWhitelistedDomains(payload.whitelist_domains);
|
|
17849
|
+
if (!allowed) {
|
|
17850
|
+
throw new Error("Intent Token is not valid for current domain");
|
|
17851
|
+
}
|
|
17852
|
+
if (!payload || !payload.intent_id || !payload.version || !payload.env || !payload.env_alias) throw new Error("Inconsistent structure of intent token. Please, be sure that you are using correct token.");
|
|
16252
17853
|
return payload;
|
|
16253
17854
|
}
|
|
17855
|
+
}, {
|
|
17856
|
+
key: "validateJWTWhitelistedDomains",
|
|
17857
|
+
value: function validateJWTWhitelistedDomains(whitelist_domains) {
|
|
17858
|
+
if (!whitelist_domains) return true;
|
|
17859
|
+
return whitelist_domains.includes(window.location.hostname);
|
|
17860
|
+
}
|
|
16254
17861
|
}, {
|
|
16255
17862
|
key: "ready",
|
|
16256
17863
|
value: function ready() {
|
|
@@ -16405,12 +18012,15 @@ var EVENT;
|
|
|
16405
18012
|
EVENT["PAYMENT_IN_REVIEW"] = "paymentInReview";
|
|
16406
18013
|
EVENT["ON_CLICK"] = "onClick";
|
|
16407
18014
|
EVENT["ON_CHECKOUT_CLOSE"] = "onCheckoutClose";
|
|
18015
|
+
EVENT["ON_SHIPPING_ADDRESS_CHANGE"] = "onShippingAddressChange";
|
|
18016
|
+
EVENT["ON_SHIPPING_OPTIONS_CHANGE"] = "onShippingOptionsChange";
|
|
16408
18017
|
})(EVENT || (EVENT = {}));
|
|
16409
18018
|
|
|
16410
18019
|
var BaseWalletButton = /*#__PURE__*/function () {
|
|
16411
18020
|
function BaseWalletButton(selector, publicKeyOrAccessToken, gatewayId, meta, requiredMetaFields) {
|
|
16412
18021
|
_classCallCheck(this, BaseWalletButton);
|
|
16413
18022
|
this.env = DEFAULT_ENV;
|
|
18023
|
+
this.onShippingOptionsChangeHandlerRegistered = false;
|
|
16414
18024
|
this.eventEmitter = new EventEmitter();
|
|
16415
18025
|
this.container = new Container(selector);
|
|
16416
18026
|
this.api = new ApiInternal(publicKeyOrAccessToken, this.getApiAuthType(publicKeyOrAccessToken));
|
|
@@ -16421,11 +18031,8 @@ var BaseWalletButton = /*#__PURE__*/function () {
|
|
|
16421
18031
|
return _createClass(BaseWalletButton, [{
|
|
16422
18032
|
key: "getApiAuthType",
|
|
16423
18033
|
value: function getApiAuthType(publicKeyOrAccessToken) {
|
|
16424
|
-
if (AccessToken.validateJWT(publicKeyOrAccessToken))
|
|
16425
|
-
|
|
16426
|
-
} else {
|
|
16427
|
-
return API_AUTH_TYPE.PUBLIC_KEY;
|
|
16428
|
-
}
|
|
18034
|
+
if (AccessToken.validateJWT(publicKeyOrAccessToken)) return API_AUTH_TYPE.TOKEN;
|
|
18035
|
+
return API_AUTH_TYPE.PUBLIC_KEY;
|
|
16429
18036
|
}
|
|
16430
18037
|
/**
|
|
16431
18038
|
* Current method can change environment. By default environment = sandbox.
|
|
@@ -16592,6 +18199,67 @@ var BaseWalletButton = /*#__PURE__*/function () {
|
|
|
16592
18199
|
});
|
|
16593
18200
|
});
|
|
16594
18201
|
}
|
|
18202
|
+
/**
|
|
18203
|
+
* Callback for onShippingAddressChange method.
|
|
18204
|
+
*
|
|
18205
|
+
* @callback OnShippingAddressChangeCallback
|
|
18206
|
+
* @param {OnShippingAddressChangeEventData} data
|
|
18207
|
+
* @return {Promise<OnShippingAddressChangeEventResponse>} Address update result
|
|
18208
|
+
*/
|
|
18209
|
+
/**
|
|
18210
|
+
* If shipping address data is updated, the function passed as parameter will be called.
|
|
18211
|
+
* Use this method to listen for shipping address selection or input from customer when shipping is enabled.
|
|
18212
|
+
* The event handler needs to return a new token in case a backend to backend wallet update call was executed.
|
|
18213
|
+
* In addition, if any error occured, an error string must be supplied.
|
|
18214
|
+
* By default, the event handler will be processed successfuly if neither token nor error is returned.
|
|
18215
|
+
*
|
|
18216
|
+
* @example
|
|
18217
|
+
* button.onShippingAddressChange((data) => {
|
|
18218
|
+
* const responseData = await fetch('https://your-server.com/update-shipping-info');
|
|
18219
|
+
* return { error: null, token: responseData.walletToken };
|
|
18220
|
+
* });
|
|
18221
|
+
*
|
|
18222
|
+
* @param {OnShippingAddressChangeCallback} [handler] - Function to be called when the shipping address data is updated.
|
|
18223
|
+
*/
|
|
18224
|
+
}, {
|
|
18225
|
+
key: "onShippingAddressChange",
|
|
18226
|
+
value: function onShippingAddressChange(handler) {
|
|
18227
|
+
if (typeof handler === 'function') {
|
|
18228
|
+
return this.eventEmitter.subscribe(EVENT.ON_SHIPPING_ADDRESS_CHANGE, handler);
|
|
18229
|
+
}
|
|
18230
|
+
this.handleOnError(new Error('onShippingAddressChange event handler is required to return the wallet token string or reject.'));
|
|
18231
|
+
}
|
|
18232
|
+
/**
|
|
18233
|
+
* Callback for onShippingOptionsChange method.
|
|
18234
|
+
*
|
|
18235
|
+
* @callback OnShippingOptionsChangeCallback
|
|
18236
|
+
* @param {OnShippingOptionChangeEventData} data
|
|
18237
|
+
* @return {Promise<OnShippingOptionChangeEventResponse>} Address update result
|
|
18238
|
+
*/
|
|
18239
|
+
/**
|
|
18240
|
+
* If shipping options data is updated, the function passed as parameter will be called.
|
|
18241
|
+
* Use this method to listen for shipping option selection from customer when shipping is enabled.
|
|
18242
|
+
* The event handler needs to return a new token in case a backend to backend wallet update call was executed.
|
|
18243
|
+
* In addition, if any error occured, an error string must be supplied.
|
|
18244
|
+
* By default, the event handler will be processed successfuly if neither token nor error is returned.
|
|
18245
|
+
*
|
|
18246
|
+
* @example
|
|
18247
|
+
* button.onShippingOptionsChange((data) => {
|
|
18248
|
+
* const responseData = await fetch('https://your-server.com/update-shipping-info');
|
|
18249
|
+
* return { error: null, token: responseData.walletToken };
|
|
18250
|
+
* });
|
|
18251
|
+
*
|
|
18252
|
+
* @param {OnShippingOptionsChangeCallback} [handler] - Function to be called when the shipping options data is updated.
|
|
18253
|
+
*/
|
|
18254
|
+
}, {
|
|
18255
|
+
key: "onShippingOptionsChange",
|
|
18256
|
+
value: function onShippingOptionsChange(handler) {
|
|
18257
|
+
if (typeof handler === 'function') {
|
|
18258
|
+
this.onShippingOptionsChangeHandlerRegistered = true;
|
|
18259
|
+
return this.eventEmitter.subscribe(EVENT.ON_SHIPPING_OPTIONS_CHANGE, handler);
|
|
18260
|
+
}
|
|
18261
|
+
this.handleOnError(new Error('onShippingOptionsChange event handler is required to return the wallet token string or reject.'));
|
|
18262
|
+
}
|
|
16595
18263
|
/**
|
|
16596
18264
|
* Callback for onUnavailable method.
|
|
16597
18265
|
*
|
|
@@ -16716,6 +18384,7 @@ var BaseWalletButton = /*#__PURE__*/function () {
|
|
|
16716
18384
|
return this.eventEmitter.emitWithResult(EVENT.ON_CLICK, {
|
|
16717
18385
|
event: EVENT.ON_CLICK
|
|
16718
18386
|
}).then(function (result) {
|
|
18387
|
+
var _a;
|
|
16719
18388
|
if (!result || result.length === 0) {
|
|
16720
18389
|
var error = new Error('No result from onClick event');
|
|
16721
18390
|
_this10.handleOnError(error);
|
|
@@ -16733,15 +18402,50 @@ var BaseWalletButton = /*#__PURE__*/function () {
|
|
|
16733
18402
|
_this10.handleOnError(_error2);
|
|
16734
18403
|
throw _error2;
|
|
16735
18404
|
}
|
|
18405
|
+
if (((_a = _this10.chargeWalletTokenMeta.charge.shipping) === null || _a === void 0 ? void 0 : _a.options) && _this10.chargeWalletTokenMeta.charge.shipping.options.length > 0) {
|
|
18406
|
+
if (!_this10.onShippingOptionsChangeHandlerRegistered) {
|
|
18407
|
+
var _error3 = new Error("There is no event handler registered for shipping options change. Consider using \"onShippingOptionsChange\" SDK method to register the event handler.");
|
|
18408
|
+
_this10.handleOnError(_error3);
|
|
18409
|
+
throw _error3;
|
|
18410
|
+
}
|
|
18411
|
+
}
|
|
16736
18412
|
});
|
|
16737
18413
|
}
|
|
18414
|
+
}, {
|
|
18415
|
+
key: "handleMerchantOnShippingChangedEvent",
|
|
18416
|
+
value: function handleMerchantOnShippingChangedEvent(eventData) {
|
|
18417
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
18418
|
+
var _this11 = this;
|
|
18419
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18420
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18421
|
+
case 0:
|
|
18422
|
+
return _context.abrupt("return", this.eventEmitter.emitWithResult(eventData.event, eventData).then(function (result) {
|
|
18423
|
+
if (!result || result.length === 0) {
|
|
18424
|
+
var error = new Error('No result from shippingUpdate event');
|
|
18425
|
+
_this11.handleOnError(error);
|
|
18426
|
+
throw error;
|
|
18427
|
+
}
|
|
18428
|
+
var shippingResponse = result[0];
|
|
18429
|
+
if (shippingResponse.token) _this11.setWalletToken(shippingResponse.token, {
|
|
18430
|
+
skipApiAuth: true
|
|
18431
|
+
});
|
|
18432
|
+
return shippingResponse;
|
|
18433
|
+
}));
|
|
18434
|
+
case 1:
|
|
18435
|
+
case "end":
|
|
18436
|
+
return _context.stop();
|
|
18437
|
+
}
|
|
18438
|
+
}, _callee, this);
|
|
18439
|
+
}));
|
|
18440
|
+
}
|
|
16738
18441
|
}, {
|
|
16739
18442
|
key: "setWalletToken",
|
|
16740
|
-
value: function setWalletToken(token) {
|
|
18443
|
+
value: function setWalletToken(token, opts) {
|
|
16741
18444
|
var parsedToken = AccessToken.validateJWT(token);
|
|
16742
18445
|
if (!parsedToken) return this.handleOnError(new Error("Invalid charge token"));
|
|
16743
18446
|
this.chargeWalletTokenMeta = AccessToken.extractMeta(parsedToken.body);
|
|
16744
18447
|
if (!this.chargeWalletTokenMeta) return this.handleOnError(new Error('Invalid charge token'));
|
|
18448
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.skipApiAuth) === true) return;
|
|
16745
18449
|
this.api.auth = token;
|
|
16746
18450
|
this.api.authType = API_AUTH_TYPE.TOKEN;
|
|
16747
18451
|
}
|
|
@@ -16777,6 +18481,7 @@ var BaseWalletButton = /*#__PURE__*/function () {
|
|
|
16777
18481
|
data: error
|
|
16778
18482
|
}));
|
|
16779
18483
|
}
|
|
18484
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
16780
18485
|
}, {
|
|
16781
18486
|
key: "eventDataFromApiError",
|
|
16782
18487
|
value: function eventDataFromApiError(err) {
|
|
@@ -16789,13 +18494,14 @@ var BaseWalletButton = /*#__PURE__*/function () {
|
|
|
16789
18494
|
}, {
|
|
16790
18495
|
key: "validateRequiredMetaFields",
|
|
16791
18496
|
value: function validateRequiredMetaFields(requiredMetaFields) {
|
|
16792
|
-
var
|
|
18497
|
+
var _this12 = this;
|
|
16793
18498
|
if (!this.meta) throw new Error('Meta is required');
|
|
16794
18499
|
if (typeof this.meta.amount !== 'number') throw new Error('meta.amount needs to be numeric');
|
|
16795
18500
|
if (typeof this.meta.currency !== 'string') throw new Error('meta.amount needs to be a string');
|
|
18501
|
+
// biome-ignore lint/complexity/noForEach: <explanation>
|
|
16796
18502
|
requiredMetaFields.forEach(function (field) {
|
|
16797
18503
|
var keys = field.split('.');
|
|
16798
|
-
var current =
|
|
18504
|
+
var current = _this12.meta;
|
|
16799
18505
|
// Traverse the nested structure
|
|
16800
18506
|
var _iterator = _createForOfIteratorHelper(keys),
|
|
16801
18507
|
_step;
|
|
@@ -16819,6 +18525,12 @@ var generateApplePayButtonStyles = function generateApplePayButtonStyles() {
|
|
|
16819
18525
|
return "\n apple-pay-button {\n display: inline-block;\n --apple-pay-button-width: 100%;\n --apple-pay-button-height: 40px;\n --apple-pay-button-border-radius: 5px;\n --apple-pay-button-padding: 5px 0px;\n }\n ";
|
|
16820
18526
|
};
|
|
16821
18527
|
|
|
18528
|
+
var ContactShippingEditingMode;
|
|
18529
|
+
(function (ContactShippingEditingMode) {
|
|
18530
|
+
ContactShippingEditingMode["AVAILABLE"] = "available";
|
|
18531
|
+
ContactShippingEditingMode["STORE_PICKUP"] = "store_pickup";
|
|
18532
|
+
})(ContactShippingEditingMode || (ContactShippingEditingMode = {}));
|
|
18533
|
+
|
|
16822
18534
|
var DEFAULT_APPLE_PAY_CAPABILITIES = ['paymentCredentialsAvailable'];
|
|
16823
18535
|
/**
|
|
16824
18536
|
* Class ApplePayWalletButtonExpress to work with Apple Pay Wallet.
|
|
@@ -16841,6 +18553,19 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
16841
18553
|
var _this;
|
|
16842
18554
|
_classCallCheck(this, ApplePayWalletButtonExpress);
|
|
16843
18555
|
_this = _callSuper(this, ApplePayWalletButtonExpress, [selector, publicKeyOrAccessToken, gatewayId, meta, ['amount_label', 'country']]);
|
|
18556
|
+
_this.onApplePayButtonClicked = function () {
|
|
18557
|
+
return _this.handleMerchantOnExpressButtonClickEvent().then(function () {
|
|
18558
|
+
_this.paymentSession = new ApplePaySession(14, _this.createRequest());
|
|
18559
|
+
_this.paymentSession.onvalidatemerchant = _this.onValidateMerchant;
|
|
18560
|
+
_this.paymentSession.onpaymentauthorized = _this.onPaymentAuthorized;
|
|
18561
|
+
_this.paymentSession.oncancel = _this.onCancelPayment;
|
|
18562
|
+
_this.paymentSession.onshippingmethodselected = _this.onApplePayShippingMethodUpdate;
|
|
18563
|
+
_this.paymentSession.onshippingcontactselected = _this.onApplePayShippingContactUpdate;
|
|
18564
|
+
_this.paymentSession.begin();
|
|
18565
|
+
})["catch"](function () {
|
|
18566
|
+
_this.handleCheckoutClose();
|
|
18567
|
+
});
|
|
18568
|
+
};
|
|
16844
18569
|
_this.onValidateMerchant = function (event) {
|
|
16845
18570
|
_this.handleMerchantOnExpressButtonClickEvent().then(function () {
|
|
16846
18571
|
_this.getMerchantSession().then(function (merchantSession) {
|
|
@@ -16886,6 +18611,70 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
16886
18611
|
_this.onCancelPayment = function () {
|
|
16887
18612
|
return _this.handleCheckoutClose();
|
|
16888
18613
|
};
|
|
18614
|
+
_this.onApplePayShippingContactUpdate = function (data) {
|
|
18615
|
+
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
18616
|
+
var _this2 = this;
|
|
18617
|
+
var _a;
|
|
18618
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18619
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18620
|
+
case 0:
|
|
18621
|
+
return _context.abrupt("return", this.handleMerchantOnShippingChangedEvent({
|
|
18622
|
+
event: EVENT.ON_SHIPPING_ADDRESS_CHANGE,
|
|
18623
|
+
chargeId: (_a = this.chargeWalletTokenMeta) === null || _a === void 0 ? void 0 : _a.charge.id,
|
|
18624
|
+
data: this.parseShippingContactUpdateEvent(data)
|
|
18625
|
+
}).then(function (response) {
|
|
18626
|
+
var _a, _b, _c, _d, _e, _f;
|
|
18627
|
+
var mappedErrors = [];
|
|
18628
|
+
var mappedNewShippingMethods = [];
|
|
18629
|
+
if (((_c = (_b = (_a = _this2.chargeWalletTokenMeta.charge) === null || _a === void 0 ? void 0 : _a.shipping) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
18630
|
+
mappedNewShippingMethods = _this2.parseShippingMethod(_this2.chargeWalletTokenMeta.charge.shipping.options);
|
|
18631
|
+
}
|
|
18632
|
+
if ((_d = response.error) === null || _d === void 0 ? void 0 : _d.code) {
|
|
18633
|
+
mappedErrors = [_this2.formatErrorFields(response.error)];
|
|
18634
|
+
}
|
|
18635
|
+
_this2.paymentSession.completeShippingContactSelection({
|
|
18636
|
+
newTotal: {
|
|
18637
|
+
label: _this2.meta.amount_label,
|
|
18638
|
+
amount: String((_f = (_e = _this2.chargeWalletTokenMeta.charge.shipping) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : _this2.chargeWalletTokenMeta.charge.amount)
|
|
18639
|
+
},
|
|
18640
|
+
newShippingMethods: mappedNewShippingMethods,
|
|
18641
|
+
errors: mappedErrors
|
|
18642
|
+
});
|
|
18643
|
+
}));
|
|
18644
|
+
case 1:
|
|
18645
|
+
case "end":
|
|
18646
|
+
return _context.stop();
|
|
18647
|
+
}
|
|
18648
|
+
}, _callee, this);
|
|
18649
|
+
}));
|
|
18650
|
+
};
|
|
18651
|
+
_this.onApplePayShippingMethodUpdate = function (data) {
|
|
18652
|
+
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
18653
|
+
var _this3 = this;
|
|
18654
|
+
var _b;
|
|
18655
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
18656
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
18657
|
+
case 0:
|
|
18658
|
+
return _context2.abrupt("return", this.handleMerchantOnShippingChangedEvent({
|
|
18659
|
+
event: EVENT.ON_SHIPPING_OPTIONS_CHANGE,
|
|
18660
|
+
chargeId: (_b = this.chargeWalletTokenMeta) === null || _b === void 0 ? void 0 : _b.charge.id,
|
|
18661
|
+
data: this.parseShippingMethodUpdateEvent(data)
|
|
18662
|
+
}).then(function (_response) {
|
|
18663
|
+
var _a, _b;
|
|
18664
|
+
_this3.paymentSession.completeShippingMethodSelection({
|
|
18665
|
+
newTotal: {
|
|
18666
|
+
label: _this3.meta.amount_label,
|
|
18667
|
+
amount: String((_b = (_a = _this3.chargeWalletTokenMeta.charge.shipping) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : _this3.chargeWalletTokenMeta.charge.amount)
|
|
18668
|
+
}
|
|
18669
|
+
});
|
|
18670
|
+
}));
|
|
18671
|
+
case 1:
|
|
18672
|
+
case "end":
|
|
18673
|
+
return _context2.stop();
|
|
18674
|
+
}
|
|
18675
|
+
}, _callee2, this);
|
|
18676
|
+
}));
|
|
18677
|
+
};
|
|
16889
18678
|
return _this;
|
|
16890
18679
|
}
|
|
16891
18680
|
/**
|
|
@@ -16900,27 +18689,27 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
16900
18689
|
return _createClass(ApplePayWalletButtonExpress, [{
|
|
16901
18690
|
key: "load",
|
|
16902
18691
|
value: function load() {
|
|
16903
|
-
var
|
|
18692
|
+
var _this4 = this;
|
|
16904
18693
|
if (!window.Promise) return this.handleOnUnavailable();
|
|
16905
18694
|
var applePayScript = document.createElement('script');
|
|
16906
18695
|
applePayScript.src = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";
|
|
16907
18696
|
applePayScript.type = "text/javascript";
|
|
16908
18697
|
applePayScript.crossOrigin = 'anonymous';
|
|
16909
18698
|
applePayScript.onload = function () {
|
|
16910
|
-
|
|
18699
|
+
_this4.getGatewayWalletConfig().then(function (config) {
|
|
16911
18700
|
if (!config || config.type !== 'MasterCard' || !config.credentials || !config.credentials.apple || !config.credentials.apple.merchant) throw new Error('Invalid configuration');
|
|
16912
|
-
return
|
|
18701
|
+
return _this4.checkAvailability(config);
|
|
16913
18702
|
}).then(function (available) {
|
|
16914
|
-
if (!available) return
|
|
16915
|
-
return
|
|
18703
|
+
if (!available) return _this4.handleOnUnavailable();
|
|
18704
|
+
return _this4.mount();
|
|
16916
18705
|
})["catch"](function (err) {
|
|
16917
|
-
if (err)
|
|
16918
|
-
|
|
18706
|
+
if (err) _this4.handleOnError(err);
|
|
18707
|
+
_this4.handleOnUnavailable();
|
|
16919
18708
|
});
|
|
16920
18709
|
};
|
|
16921
18710
|
applePayScript.onerror = function (err) {
|
|
16922
18711
|
console.error("ApplePayWalletButtonExpress: Error loading ApplePay script", err);
|
|
16923
|
-
|
|
18712
|
+
_this4.handleOnUnavailable();
|
|
16924
18713
|
return;
|
|
16925
18714
|
};
|
|
16926
18715
|
document.head.appendChild(applePayScript);
|
|
@@ -16942,15 +18731,15 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
16942
18731
|
}, {
|
|
16943
18732
|
key: "checkAvailability",
|
|
16944
18733
|
value: function checkAvailability(config) {
|
|
16945
|
-
var
|
|
18734
|
+
var _this5 = this;
|
|
16946
18735
|
return new Promise(function (resolve, _reject) {
|
|
16947
18736
|
var _a;
|
|
16948
18737
|
if (!window.ApplePaySession || !ApplePaySession) {
|
|
16949
18738
|
resolve(false);
|
|
16950
18739
|
}
|
|
16951
18740
|
var formattedCapabilities = DEFAULT_APPLE_PAY_CAPABILITIES;
|
|
16952
|
-
if (((_a =
|
|
16953
|
-
formattedCapabilities =
|
|
18741
|
+
if (((_a = _this5.meta.apple_pay_capabilities) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
18742
|
+
formattedCapabilities = _this5.formatCapabilities(_this5.meta.apple_pay_capabilities);
|
|
16954
18743
|
}
|
|
16955
18744
|
ApplePaySession.applePayCapabilities(config.credentials[WALLET_TYPE.APPLE].merchant).then(function (capabilities) {
|
|
16956
18745
|
var canMakePayment = formattedCapabilities.includes(capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus);
|
|
@@ -16979,21 +18768,16 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
16979
18768
|
}
|
|
16980
18769
|
applePayButton.addEventListener('click', this.onApplePayButtonClicked.bind(this));
|
|
16981
18770
|
}
|
|
16982
|
-
}, {
|
|
16983
|
-
key: "onApplePayButtonClicked",
|
|
16984
|
-
value: function onApplePayButtonClicked() {
|
|
16985
|
-
this.paymentSession = new ApplePaySession(14, this.createRequest());
|
|
16986
|
-
this.paymentSession.onvalidatemerchant = this.onValidateMerchant;
|
|
16987
|
-
this.paymentSession.onpaymentauthorized = this.onPaymentAuthorized;
|
|
16988
|
-
this.paymentSession.oncancel = this.onCancelPayment;
|
|
16989
|
-
this.paymentSession.begin();
|
|
16990
|
-
}
|
|
16991
18771
|
}, {
|
|
16992
18772
|
key: "createRequest",
|
|
16993
18773
|
value: function createRequest() {
|
|
18774
|
+
var _a, _b, _c, _d;
|
|
16994
18775
|
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest
|
|
16995
|
-
var
|
|
16996
|
-
|
|
18776
|
+
var shippingContactEditingMode;
|
|
18777
|
+
if (this.meta.shipping_editing_mode) {
|
|
18778
|
+
shippingContactEditingMode = this.meta.shipping_editing_mode === ContactShippingEditingMode.AVAILABLE ? 'available' : 'storePickup';
|
|
18779
|
+
}
|
|
18780
|
+
return _extends(_extends({
|
|
16997
18781
|
countryCode: this.meta.country,
|
|
16998
18782
|
currencyCode: this.meta.currency,
|
|
16999
18783
|
merchantCapabilities: this.meta.merchant_capabilities || ['supports3DS', 'supportsCredit', 'supportsDebit'],
|
|
@@ -17006,7 +18790,12 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
17006
18790
|
amount: (_a = this.meta.amount) === null || _a === void 0 ? void 0 : _a.toFixed(2),
|
|
17007
18791
|
type: 'final'
|
|
17008
18792
|
}
|
|
17009
|
-
}
|
|
18793
|
+
}, shippingContactEditingMode && {
|
|
18794
|
+
shippingContactEditingMode: shippingContactEditingMode
|
|
18795
|
+
}), {
|
|
18796
|
+
shippingContact: this.parseShippingContact(),
|
|
18797
|
+
shippingMethods: this.parseShippingMethod((_d = (_c = (_b = this.chargeWalletTokenMeta) === null || _b === void 0 ? void 0 : _b.charge) === null || _c === void 0 ? void 0 : _c.shipping) === null || _d === void 0 ? void 0 : _d.options)
|
|
18798
|
+
});
|
|
17010
18799
|
}
|
|
17011
18800
|
}, {
|
|
17012
18801
|
key: "getMerchantSession",
|
|
@@ -17029,6 +18818,93 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
17029
18818
|
return fieldMap[capability] || capability;
|
|
17030
18819
|
});
|
|
17031
18820
|
}
|
|
18821
|
+
}, {
|
|
18822
|
+
key: "parseShippingContact",
|
|
18823
|
+
value: function parseShippingContact() {
|
|
18824
|
+
var _a, _b, _c, _d, _e;
|
|
18825
|
+
if (!((_b = (_a = this.chargeWalletTokenMeta) === null || _a === void 0 ? void 0 : _a.charge) === null || _b === void 0 ? void 0 : _b.shipping)) return {};
|
|
18826
|
+
return _extends(_extends({}, ((_e = (_d = (_c = this.chargeWalletTokenMeta) === null || _c === void 0 ? void 0 : _c.charge) === null || _d === void 0 ? void 0 : _d.shipping) === null || _e === void 0 ? void 0 : _e.contact) && {
|
|
18827
|
+
phoneNumber: this.chargeWalletTokenMeta.charge.shipping.contact.phone,
|
|
18828
|
+
emailAddress: this.chargeWalletTokenMeta.charge.shipping.contact.email,
|
|
18829
|
+
givenName: this.chargeWalletTokenMeta.charge.shipping.contact.first_name,
|
|
18830
|
+
familyName: this.chargeWalletTokenMeta.charge.shipping.contact.last_name
|
|
18831
|
+
}), {
|
|
18832
|
+
addressLines: [this.chargeWalletTokenMeta.charge.shipping.address_line1, this.chargeWalletTokenMeta.charge.shipping.address_line2, this.chargeWalletTokenMeta.charge.shipping.address_line3].filter(Boolean),
|
|
18833
|
+
locality: this.chargeWalletTokenMeta.charge.shipping.address_city,
|
|
18834
|
+
postalCode: this.chargeWalletTokenMeta.charge.shipping.address_postcode,
|
|
18835
|
+
administrativeArea: this.chargeWalletTokenMeta.charge.shipping.address_state,
|
|
18836
|
+
country: this.chargeWalletTokenMeta.charge.shipping.address_country,
|
|
18837
|
+
countryCode: this.chargeWalletTokenMeta.charge.shipping.address_country
|
|
18838
|
+
});
|
|
18839
|
+
}
|
|
18840
|
+
}, {
|
|
18841
|
+
key: "parseShippingMethod",
|
|
18842
|
+
value: function parseShippingMethod() {
|
|
18843
|
+
var shippingOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
18844
|
+
return shippingOptions.map(function (option) {
|
|
18845
|
+
return {
|
|
18846
|
+
label: option.label,
|
|
18847
|
+
detail: option.detail,
|
|
18848
|
+
amount: option.amount,
|
|
18849
|
+
identifier: option.id
|
|
18850
|
+
};
|
|
18851
|
+
});
|
|
18852
|
+
}
|
|
18853
|
+
}, {
|
|
18854
|
+
key: "parseShippingMethodUpdateEvent",
|
|
18855
|
+
value: function parseShippingMethodUpdateEvent(data) {
|
|
18856
|
+
return {
|
|
18857
|
+
shipping_option_id: data.shippingMethod.identifier,
|
|
18858
|
+
label: data.shippingMethod.label,
|
|
18859
|
+
detail: data.shippingMethod.detail,
|
|
18860
|
+
amount: data.shippingMethod.amount
|
|
18861
|
+
};
|
|
18862
|
+
}
|
|
18863
|
+
}, {
|
|
18864
|
+
key: "parseShippingContactUpdateEvent",
|
|
18865
|
+
value: function parseShippingContactUpdateEvent(data) {
|
|
18866
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
18867
|
+
return _extends(_extends(_extends({
|
|
18868
|
+
contact: {
|
|
18869
|
+
phone: (_e = (_d = (_c = (_b = (_a = this.chargeWalletTokenMeta) === null || _a === void 0 ? void 0 : _a.charge) === null || _b === void 0 ? void 0 : _b.shipping) === null || _c === void 0 ? void 0 : _c.contact) === null || _d === void 0 ? void 0 : _d.phone) !== null && _e !== void 0 ? _e : data.shippingContact.phoneNumber,
|
|
18870
|
+
email: (_k = (_j = (_h = (_g = (_f = this.chargeWalletTokenMeta) === null || _f === void 0 ? void 0 : _f.charge) === null || _g === void 0 ? void 0 : _g.shipping) === null || _h === void 0 ? void 0 : _h.contact) === null || _j === void 0 ? void 0 : _j.email) !== null && _k !== void 0 ? _k : data.shippingContact.emailAddress,
|
|
18871
|
+
first_name: (_q = (_p = (_o = (_m = (_l = this.chargeWalletTokenMeta) === null || _l === void 0 ? void 0 : _l.charge) === null || _m === void 0 ? void 0 : _m.shipping) === null || _o === void 0 ? void 0 : _o.contact) === null || _p === void 0 ? void 0 : _p.first_name) !== null && _q !== void 0 ? _q : data.shippingContact.givenName,
|
|
18872
|
+
last_name: (_v = (_u = (_t = (_s = (_r = this.chargeWalletTokenMeta) === null || _r === void 0 ? void 0 : _r.charge) === null || _s === void 0 ? void 0 : _s.shipping) === null || _t === void 0 ? void 0 : _t.contact) === null || _u === void 0 ? void 0 : _u.last_name) !== null && _v !== void 0 ? _v : data.shippingContact.familyName
|
|
18873
|
+
}
|
|
18874
|
+
}, ((_w = data.shippingContact.addressLines) === null || _w === void 0 ? void 0 : _w[0]) && {
|
|
18875
|
+
address_line1: data.shippingContact.addressLines[0]
|
|
18876
|
+
}), ((_x = data.shippingContact.addressLines) === null || _x === void 0 ? void 0 : _x[1]) && {
|
|
18877
|
+
address_line2: data.shippingContact.addressLines[1]
|
|
18878
|
+
}), {
|
|
18879
|
+
address_city: data.shippingContact.locality,
|
|
18880
|
+
address_postcode: data.shippingContact.postalCode,
|
|
18881
|
+
address_state: data.shippingContact.administrativeArea,
|
|
18882
|
+
address_country: data.shippingContact.countryCode
|
|
18883
|
+
});
|
|
18884
|
+
}
|
|
18885
|
+
}, {
|
|
18886
|
+
key: "formatErrorFields",
|
|
18887
|
+
value: function formatErrorFields(error) {
|
|
18888
|
+
var fieldMap = {
|
|
18889
|
+
phone: "phoneNumber",
|
|
18890
|
+
email: "emailAddress",
|
|
18891
|
+
phonetic_name: "phoneticName",
|
|
18892
|
+
address_lines: "addressLines",
|
|
18893
|
+
address_city: "locality",
|
|
18894
|
+
address_postcode: "postalCode",
|
|
18895
|
+
address_state: "administrativeArea",
|
|
18896
|
+
address_country: "country",
|
|
18897
|
+
address_country_code: "countryCode"
|
|
18898
|
+
};
|
|
18899
|
+
var contactField = fieldMap[error.field] || error.field;
|
|
18900
|
+
var codeMap = {
|
|
18901
|
+
address_error: "addressUnserviceable",
|
|
18902
|
+
shipping_contact_invalid: "shippingContactInvalid",
|
|
18903
|
+
billing_contact_invalid: "billingContactInvalid"
|
|
18904
|
+
};
|
|
18905
|
+
var code = codeMap[error.code] || 'unknown';
|
|
18906
|
+
return new ApplePayError(code, contactField, error.message);
|
|
18907
|
+
}
|
|
17032
18908
|
}]);
|
|
17033
18909
|
}(BaseWalletButton);
|
|
17034
18910
|
|
|
@@ -17050,8 +18926,11 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
17050
18926
|
var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
17051
18927
|
/** @constructs */ // constructs added for correct parse classes jsdoc2md
|
|
17052
18928
|
function PaypalWalletButtonExpress(selector, publicKeyOrAccessToken, gatewayId, meta) {
|
|
18929
|
+
var _this;
|
|
17053
18930
|
_classCallCheck(this, PaypalWalletButtonExpress);
|
|
17054
|
-
|
|
18931
|
+
_this = _callSuper(this, PaypalWalletButtonExpress, [selector, publicKeyOrAccessToken, gatewayId, meta, []]);
|
|
18932
|
+
_this.shippingRequested = false;
|
|
18933
|
+
return _this;
|
|
17055
18934
|
}
|
|
17056
18935
|
/**
|
|
17057
18936
|
* Initializes the availability checks and inserts the button if possible.
|
|
@@ -17065,15 +18944,15 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
17065
18944
|
return _createClass(PaypalWalletButtonExpress, [{
|
|
17066
18945
|
key: "load",
|
|
17067
18946
|
value: function load() {
|
|
17068
|
-
var
|
|
18947
|
+
var _this2 = this;
|
|
17069
18948
|
if (!window.Promise) return this.handleOnUnavailable();
|
|
17070
18949
|
this.getGatewayWalletConfig().then(function (config) {
|
|
17071
18950
|
if (!config || config.type !== 'Paypal' || !config.credentials || !config.credentials.client_auth) throw new Error('Invalid configuration');
|
|
17072
|
-
|
|
17073
|
-
|
|
18951
|
+
_this2.config = config;
|
|
18952
|
+
_this2.renderPaypalButton();
|
|
17074
18953
|
})["catch"](function (err) {
|
|
17075
|
-
if (err)
|
|
17076
|
-
|
|
18954
|
+
if (err) _this2.handleOnError(err);
|
|
18955
|
+
_this2.handleOnUnavailable();
|
|
17077
18956
|
});
|
|
17078
18957
|
}
|
|
17079
18958
|
/**
|
|
@@ -17102,18 +18981,18 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
17102
18981
|
}, {
|
|
17103
18982
|
key: "renderPaypalCommonComponent",
|
|
17104
18983
|
value: function renderPaypalCommonComponent() {
|
|
17105
|
-
var
|
|
18984
|
+
var _this3 = this;
|
|
17106
18985
|
var _a, _b;
|
|
17107
18986
|
var buttonId = ((_a = this.container.getElement()) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
17108
18987
|
var paypalScript = document.createElement("script");
|
|
17109
|
-
paypalScript.src = "https://www.paypal.com/sdk/js?client-id=".concat((_b = this.config.credentials) === null || _b === void 0 ? void 0 : _b.client_auth, "¤cy=").concat(this.meta.currency).concat(this.meta.pay_later === true ? '&enable-funding=paylater&disable-funding=card' :
|
|
18988
|
+
paypalScript.src = "https://www.paypal.com/sdk/js?client-id=".concat((_b = this.config.credentials) === null || _b === void 0 ? void 0 : _b.client_auth, "¤cy=").concat(this.meta.currency).concat(this.meta.pay_later === true ? '&enable-funding=paylater&disable-funding=card' : '&disable-funding=credit,card').concat(!this.meta.capture ? '&intent=authorize' : '');
|
|
17110
18989
|
paypalScript.async = true;
|
|
17111
18990
|
paypalScript.onload = function () {
|
|
17112
18991
|
if (window.paypal) {
|
|
17113
|
-
|
|
17114
|
-
|
|
18992
|
+
_this3.paypal = window.paypal;
|
|
18993
|
+
_this3.paypal.Buttons(_extends({}, _this3.paypalSharedProps())).render("#".concat(buttonId));
|
|
17115
18994
|
} else {
|
|
17116
|
-
|
|
18995
|
+
_this3.handleOnUnavailable();
|
|
17117
18996
|
}
|
|
17118
18997
|
};
|
|
17119
18998
|
document.head.appendChild(paypalScript);
|
|
@@ -17121,38 +19000,38 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
17121
19000
|
}, {
|
|
17122
19001
|
key: "renderPaypalStandaloneComponent",
|
|
17123
19002
|
value: function renderPaypalStandaloneComponent() {
|
|
17124
|
-
var
|
|
19003
|
+
var _this4 = this;
|
|
17125
19004
|
var _a, _b, _c;
|
|
17126
19005
|
var buttonId = ((_a = this.container.getElement()) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
17127
19006
|
var paypalScript = document.createElement("script");
|
|
17128
19007
|
// buyer-country is only used in Sandbox. It shouldn't be used in production. Based on buyer's geolocation this parameter determine which funding sources are eligible for a given buyer. Refer the link https://developer.paypal.com/sdk/js/configuration/#link-buyercountry
|
|
17129
|
-
paypalScript.src = "https://www.paypal.com/sdk/js?client-id=".concat((_b = this.config.credentials) === null || _b === void 0 ? void 0 : _b.client_auth, "¤cy=").concat(this.meta.currency, "&components=buttons,funding-eligibility,messages&enable-funding=paylater").concat(!this.meta.capture ?
|
|
19008
|
+
paypalScript.src = "https://www.paypal.com/sdk/js?client-id=".concat((_b = this.config.credentials) === null || _b === void 0 ? void 0 : _b.client_auth, "¤cy=").concat(this.meta.currency, "&components=buttons,funding-eligibility,messages&enable-funding=paylater").concat(!this.meta.capture ? '&intent=authorize' : '').concat(((_c = this.config) === null || _c === void 0 ? void 0 : _c.mode) === 'live' ? '' : '&buyer-country=AU');
|
|
17130
19009
|
paypalScript.async = true;
|
|
17131
19010
|
paypalScript.onload = function () {
|
|
17132
19011
|
var _a;
|
|
17133
19012
|
if (window.paypal) {
|
|
17134
|
-
|
|
17135
|
-
var isPayLater = !!
|
|
17136
|
-
var button =
|
|
17137
|
-
fundingSource: isPayLater ?
|
|
17138
|
-
},
|
|
19013
|
+
_this4.paypal = window.paypal;
|
|
19014
|
+
var isPayLater = !!_this4.meta.pay_later;
|
|
19015
|
+
var button = _this4.paypal.Buttons(_extends({
|
|
19016
|
+
fundingSource: isPayLater ? _this4.paypal.FUNDING.PAYLATER : _this4.paypal.FUNDING.PAYPAL
|
|
19017
|
+
}, _this4.paypalSharedProps()));
|
|
17139
19018
|
if (button.isEligible()) {
|
|
17140
19019
|
button.render("#".concat(buttonId));
|
|
17141
|
-
if (isPayLater && !
|
|
17142
|
-
var messaging =
|
|
17143
|
-
amount:
|
|
17144
|
-
currency:
|
|
19020
|
+
if (isPayLater && !_this4.meta.hide_message) {
|
|
19021
|
+
var messaging = _this4.paypal.Messages(_extends({
|
|
19022
|
+
amount: _this4.meta.amount,
|
|
19023
|
+
currency: _this4.meta.currency,
|
|
17145
19024
|
placement: 'payment'
|
|
17146
|
-
}, ((_a =
|
|
17147
|
-
style:
|
|
19025
|
+
}, ((_a = _this4.meta.style) === null || _a === void 0 ? void 0 : _a.messages) && {
|
|
19026
|
+
style: _this4.meta.style.messages
|
|
17148
19027
|
}));
|
|
17149
19028
|
messaging.render("#".concat(buttonId));
|
|
17150
19029
|
}
|
|
17151
19030
|
} else {
|
|
17152
|
-
|
|
19031
|
+
_this4.handleOnUnavailable();
|
|
17153
19032
|
}
|
|
17154
19033
|
} else {
|
|
17155
|
-
|
|
19034
|
+
_this4.handleOnUnavailable();
|
|
17156
19035
|
}
|
|
17157
19036
|
};
|
|
17158
19037
|
document.head.appendChild(paypalScript);
|
|
@@ -17160,23 +19039,32 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
17160
19039
|
}, {
|
|
17161
19040
|
key: "paypalSharedProps",
|
|
17162
19041
|
value: function paypalSharedProps() {
|
|
17163
|
-
var
|
|
19042
|
+
var _this5 = this;
|
|
17164
19043
|
return _extends(_extends({}, this.meta.style && {
|
|
17165
19044
|
style: this.meta.style
|
|
17166
19045
|
}), {
|
|
17167
19046
|
onClick: function onClick(_data, actions) {
|
|
17168
|
-
return
|
|
19047
|
+
return _this5.handleMerchantOnExpressButtonClickEvent().then(function () {
|
|
17169
19048
|
return actions.resolve();
|
|
17170
19049
|
})["catch"](function () {
|
|
17171
|
-
|
|
19050
|
+
_this5.handleCheckoutClose();
|
|
17172
19051
|
return actions.reject();
|
|
17173
19052
|
});
|
|
17174
19053
|
},
|
|
17175
19054
|
createOrder: function createOrder() {
|
|
17176
19055
|
return new Promise(function (resolve, reject) {
|
|
17177
|
-
|
|
17178
|
-
return
|
|
17179
|
-
|
|
19056
|
+
var _a, _b;
|
|
19057
|
+
if (!_this5.api.auth) return reject(new Error('Wallet Token not injected. Please handle onClick correctly.'));
|
|
19058
|
+
var shipping = (_b = (_a = _this5.chargeWalletTokenMeta) === null || _a === void 0 ? void 0 : _a.charge) === null || _b === void 0 ? void 0 : _b.shipping;
|
|
19059
|
+
if (shipping) {
|
|
19060
|
+
var hasCompleteShippingAddress = ['address_line1', 'address_city', 'address_country', 'address_state', 'address_postcode'].every(function (key) {
|
|
19061
|
+
return Boolean(shipping[key]);
|
|
19062
|
+
});
|
|
19063
|
+
_this5.shippingRequested = !hasCompleteShippingAddress;
|
|
19064
|
+
}
|
|
19065
|
+
return _this5.executeWalletCallback({
|
|
19066
|
+
request_type: 'CREATE_TRANSACTION',
|
|
19067
|
+
request_shipping: _this5.shippingRequested
|
|
17180
19068
|
}).then(function (res) {
|
|
17181
19069
|
resolve(res.id);
|
|
17182
19070
|
})["catch"](function (err) {
|
|
@@ -17185,8 +19073,8 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
17185
19073
|
});
|
|
17186
19074
|
},
|
|
17187
19075
|
onApprove: function onApprove(data) {
|
|
17188
|
-
if (
|
|
17189
|
-
|
|
19076
|
+
if (_this5.pendingApprovalPromise) return _this5.pendingApprovalPromise;
|
|
19077
|
+
_this5.pendingApprovalPromise = _this5.executeWalletCapture({
|
|
17190
19078
|
payment_method_id: data.orderID,
|
|
17191
19079
|
customer: {
|
|
17192
19080
|
payment_source: {
|
|
@@ -17195,19 +19083,105 @@ var PaypalWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
|
|
|
17195
19083
|
}
|
|
17196
19084
|
}
|
|
17197
19085
|
})["finally"](function () {
|
|
17198
|
-
|
|
19086
|
+
_this5.pendingApprovalPromise = undefined;
|
|
17199
19087
|
});
|
|
17200
|
-
return
|
|
19088
|
+
return _this5.pendingApprovalPromise;
|
|
17201
19089
|
},
|
|
17202
19090
|
onCancel: function onCancel() {
|
|
17203
|
-
return
|
|
19091
|
+
return _this5.handleCheckoutClose();
|
|
17204
19092
|
},
|
|
17205
19093
|
onError: function onError() {
|
|
17206
19094
|
// Error handling so that paypal does not throw an uncaught error
|
|
17207
19095
|
// We're already handling errors and notifying Merchants at "wallet-buttons.ts"
|
|
19096
|
+
},
|
|
19097
|
+
onShippingAddressChange: function onShippingAddressChange(data, actions) {
|
|
19098
|
+
return _this5.handleShippingAddressUpdate(data, actions);
|
|
19099
|
+
},
|
|
19100
|
+
onShippingOptionsChange: function onShippingOptionsChange(data, actions) {
|
|
19101
|
+
return _this5.handleShippingOptionsUpdate(data, actions);
|
|
17208
19102
|
}
|
|
17209
19103
|
});
|
|
17210
19104
|
}
|
|
19105
|
+
}, {
|
|
19106
|
+
key: "handleShippingAddressUpdate",
|
|
19107
|
+
value: function handleShippingAddressUpdate(data, actions) {
|
|
19108
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
19109
|
+
var _a;
|
|
19110
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19111
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19112
|
+
case 0:
|
|
19113
|
+
if (this.shippingRequested) {
|
|
19114
|
+
_context.next = 2;
|
|
19115
|
+
break;
|
|
19116
|
+
}
|
|
19117
|
+
return _context.abrupt("return");
|
|
19118
|
+
case 2:
|
|
19119
|
+
return _context.abrupt("return", this.handleMerchantOnShippingChangedEvent({
|
|
19120
|
+
event: EVENT.ON_SHIPPING_ADDRESS_CHANGE,
|
|
19121
|
+
chargeId: (_a = this.chargeWalletTokenMeta) === null || _a === void 0 ? void 0 : _a.charge.id,
|
|
19122
|
+
data: {
|
|
19123
|
+
address_city: data.shippingAddress.city,
|
|
19124
|
+
address_state: data.shippingAddress.state,
|
|
19125
|
+
address_postcode: data.shippingAddress.postalCode,
|
|
19126
|
+
address_country: data.shippingAddress.countryCode
|
|
19127
|
+
}
|
|
19128
|
+
}).then(function (response) {
|
|
19129
|
+
var _a;
|
|
19130
|
+
if ((_a = response.error) === null || _a === void 0 ? void 0 : _a.code) {
|
|
19131
|
+
var errorKey = response.error.code.toUpperCase();
|
|
19132
|
+
var errorMessage = data.errors[errorKey];
|
|
19133
|
+
if (errorMessage) {
|
|
19134
|
+
return actions.reject(errorMessage);
|
|
19135
|
+
}
|
|
19136
|
+
return actions.reject();
|
|
19137
|
+
}
|
|
19138
|
+
})["catch"](function (err) {
|
|
19139
|
+
// If err is not one of Paypal's data.errros, it defaults to "Unable to update address. Please try again" by Paypal
|
|
19140
|
+
return actions.reject(err);
|
|
19141
|
+
}));
|
|
19142
|
+
case 3:
|
|
19143
|
+
case "end":
|
|
19144
|
+
return _context.stop();
|
|
19145
|
+
}
|
|
19146
|
+
}, _callee, this);
|
|
19147
|
+
}));
|
|
19148
|
+
}
|
|
19149
|
+
}, {
|
|
19150
|
+
key: "handleShippingOptionsUpdate",
|
|
19151
|
+
value: function handleShippingOptionsUpdate(data, actions) {
|
|
19152
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
19153
|
+
var _a;
|
|
19154
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
19155
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
19156
|
+
case 0:
|
|
19157
|
+
return _context2.abrupt("return", this.handleMerchantOnShippingChangedEvent({
|
|
19158
|
+
event: EVENT.ON_SHIPPING_OPTIONS_CHANGE,
|
|
19159
|
+
chargeId: (_a = this.chargeWalletTokenMeta) === null || _a === void 0 ? void 0 : _a.charge.id,
|
|
19160
|
+
data: {
|
|
19161
|
+
shipping_option_id: data.selectedShippingOption.id,
|
|
19162
|
+
amount: data.selectedShippingOption.amount.value
|
|
19163
|
+
}
|
|
19164
|
+
}).then(function (response) {
|
|
19165
|
+
var _a;
|
|
19166
|
+
if ((_a = response.error) === null || _a === void 0 ? void 0 : _a.code) {
|
|
19167
|
+
var errorKey = response.error.code.toUpperCase();
|
|
19168
|
+
var errorMessage = data.errors[errorKey];
|
|
19169
|
+
if (errorMessage) {
|
|
19170
|
+
return actions.reject(errorMessage);
|
|
19171
|
+
}
|
|
19172
|
+
return actions.reject();
|
|
19173
|
+
}
|
|
19174
|
+
})["catch"](function (err) {
|
|
19175
|
+
// If err is not one of Paypal's data.errros, it defaults to "Unable to update address. Please try again" by Paypal
|
|
19176
|
+
return actions.reject(err);
|
|
19177
|
+
}));
|
|
19178
|
+
case 1:
|
|
19179
|
+
case "end":
|
|
19180
|
+
return _context2.stop();
|
|
19181
|
+
}
|
|
19182
|
+
}, _callee2, this);
|
|
19183
|
+
}));
|
|
19184
|
+
}
|
|
17211
19185
|
}]);
|
|
17212
19186
|
}(BaseWalletButton);
|
|
17213
19187
|
|