@paypal/paypal-js
Advanced tools
Comparing version 3.1.7 to 3.1.8
@@ -5,2 +5,8 @@ # Changelog | ||
### [3.1.8](https://github.com/paypal/paypal-js/compare/v3.1.7...v3.1.8) (2021-04-21) | ||
### Bug Fixes | ||
- override tsconfig target in legacy build ([#76](https://github.com/paypal/paypal-js/issues/76)) ([3228e57](https://github.com/paypal/paypal-js/commit/3228e578d2fcc7659f59773d37569ed56a0ef289)) | ||
### [3.1.7](https://github.com/paypal/paypal-js/compare/v3.1.6...v3.1.7) (2021-04-10) | ||
@@ -7,0 +13,0 @@ |
/*! | ||
* paypal-js v3.1.7 (2021-04-10T17:17:47.380Z) | ||
* paypal-js v3.1.8 (2021-04-21T19:00:46.311Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -21,3 +21,3 @@ * | ||
function findScript(url, attributes) { | ||
var currentScript = document.querySelector("script[src=\"".concat(url, "\"]")); | ||
var currentScript = document.querySelector("script[src=\"" + url + "\"]"); | ||
if (currentScript === null) return null; | ||
@@ -42,7 +42,7 @@ var nextScript = createScriptElement(url, attributes); // ignore the data-uid-auto attribute that gets auto-assigned to every script tag | ||
} | ||
function insertScriptElement(_ref) { | ||
var url = _ref.url, | ||
attributes = _ref.attributes, | ||
onSuccess = _ref.onSuccess, | ||
onError = _ref.onError; | ||
function insertScriptElement(_a) { | ||
var url = _a.url, | ||
attributes = _a.attributes, | ||
onSuccess = _a.onSuccess, | ||
onError = _a.onError; | ||
var newScript = createScriptElement(url, attributes); | ||
@@ -64,3 +64,3 @@ newScript.onerror = onError; | ||
var _Object$keys$filter$r = Object.keys(newOptions).filter(function (key) { | ||
var _a = Object.keys(newOptions).filter(function (key) { | ||
return typeof newOptions[key] !== "undefined" && newOptions[key] !== null && newOptions[key] !== ""; | ||
@@ -81,7 +81,7 @@ }).reduce(function (accumulator, key) { | ||
}), | ||
queryParams = _Object$keys$filter$r.queryParams, | ||
dataAttributes = _Object$keys$filter$r.dataAttributes; | ||
queryParams = _a.queryParams, | ||
dataAttributes = _a.dataAttributes; | ||
return { | ||
url: "".concat(sdkBaseURL, "?").concat(objectToQueryString(queryParams)), | ||
url: sdkBaseURL + "?" + objectToQueryString(queryParams), | ||
dataAttributes: dataAttributes | ||
@@ -99,4 +99,7 @@ }; | ||
function createScriptElement(url) { | ||
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
function createScriptElement(url, attributes) { | ||
if (attributes === void 0) { | ||
attributes = {}; | ||
} | ||
var newScript = document.createElement("script"); | ||
@@ -146,4 +149,7 @@ newScript.src = url; | ||
function loadScript(options) { | ||
var PromisePonyfill = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getDefaultPromiseImplementation(); | ||
function loadScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { | ||
PromisePonyfill = getDefaultPromiseImplementation(); | ||
} | ||
validateArguments(options, PromisePonyfill); // resolve with null when running in Node | ||
@@ -153,5 +159,5 @@ | ||
var _processOptions = processOptions(options), | ||
url = _processOptions.url, | ||
dataAttributes = _processOptions.dataAttributes; | ||
var _a = processOptions(options), | ||
url = _a.url, | ||
dataAttributes = _a.dataAttributes; | ||
@@ -175,3 +181,3 @@ var namespace = dataAttributes["data-namespace"] || "paypal"; | ||
throw new Error("The window.".concat(namespace, " global variable is not available.")); | ||
throw new Error("The window." + namespace + " global variable is not available."); | ||
}); | ||
@@ -187,4 +193,7 @@ } | ||
function loadCustomScript(options) { | ||
var PromisePonyfill = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getDefaultPromiseImplementation(); | ||
function loadCustomScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { | ||
PromisePonyfill = getDefaultPromiseImplementation(); | ||
} | ||
validateArguments(options, PromisePonyfill); | ||
@@ -212,3 +221,3 @@ var url = options.url, | ||
onError: function onError() { | ||
return reject(new Error("The script \"".concat(url, "\" failed to load."))); | ||
return reject(new Error("The script \"" + url + "\" failed to load.")); | ||
} | ||
@@ -242,3 +251,3 @@ }); | ||
var version = "3.1.7"; | ||
var version = "3.1.8"; | ||
@@ -245,0 +254,0 @@ exports.loadCustomScript = loadCustomScript; |
/*! | ||
* paypal-js v3.1.7 (2021-04-10T17:17:47.380Z) | ||
* paypal-js v3.1.8 (2021-04-21T19:00:46.311Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -17,2 +17,2 @@ * | ||
*/ | ||
var paypalLoadScript=function(t){"use strict";function e(t,e){var r=document.querySelector('script[src="'.concat(t,'"]'));if(null===r)return null;var n=a(t,e),o=Object.assign({},r.dataset);if(delete o.uidAuto,Object.keys(o).length!==Object.keys(n.dataset).length)return null;var i=!0;return Object.keys(o).forEach((function(t){o[t]!==n.dataset[t]&&(i=!1)})),i?r:null}function r(t){var e=t.url,r=t.attributes,n=t.onSuccess,o=t.onError,i=a(e,r);i.onerror=o,i.onload=n,document.head.insertBefore(i,document.head.firstElementChild)}function n(t){var e="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(e=t.sdkBaseURL,delete t.sdkBaseURL);var r=function(t,e){var r="",n="";Array.isArray(t)?t.length>1?(r="*",n=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof e&&e.length>0&&(r="*",n=e);return{"merchant-id":r,"data-merchant-id":n}}(t["merchant-id"],t["data-merchant-id"]),n=Object.assign({},t,r),a=Object.keys(n).filter((function(t){return void 0!==n[t]&&null!==n[t]&&""!==n[t]})).reduce((function(t,e){var r=n[e].toString();return"data-"===e.substring(0,5)?t.dataAttributes[e]=r:t.queryParams[e]=r,t}),{queryParams:{},dataAttributes:{}}),i=a.queryParams,u=a.dataAttributes;return{url:"".concat(e,"?").concat(o(i)),dataAttributes:u}}function o(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function a(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement("script");return r.src=t,Object.keys(e).forEach((function(t){r.setAttribute(t,e[t]),"data-csp-nonce"===t&&r.setAttribute("nonce",e["data-csp-nonce"])})),r}function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u();s(t,e);var n=t.url,o=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new e((function(t,e){if("undefined"==typeof window)return t();r({url:n,attributes:o,onSuccess:function(){return t()},onError:function(){return e(new Error('The script "'.concat(n,'" failed to load.')))}})}))}function u(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function c(t){return window[t]}function s(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}return t.loadCustomScript=i,t.loadScript=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u();if(s(t,r),"undefined"==typeof window)return r.resolve(null);var o=n(t),a=o.url,d=o.dataAttributes,l=d["data-namespace"]||"paypal",f=c(l);return e(a,d)&&f?r.resolve(f):i({url:a,attributes:d},r).then((function(){var t=c(l);if(t)return t;throw new Error("The window.".concat(l," global variable is not available."))}))},t.version="3.1.7",Object.defineProperty(t,"__esModule",{value:!0}),t}({});window.paypalLoadCustomScript=paypalLoadScript.loadCustomScript,window.paypalLoadScript=paypalLoadScript.loadScript; | ||
var paypalLoadScript=function(t){"use strict";function e(t){var e="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(e=t.sdkBaseURL,delete t.sdkBaseURL);var n=function(t,e){var r="",n="";Array.isArray(t)?t.length>1?(r="*",n=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof e&&e.length>0&&(r="*",n=e);return{"merchant-id":r,"data-merchant-id":n}}(t["merchant-id"],t["data-merchant-id"]),o=Object.assign({},t,n),a=Object.keys(o).filter((function(t){return void 0!==o[t]&&null!==o[t]&&""!==o[t]})).reduce((function(t,e){var r=o[e].toString();return"data-"===e.substring(0,5)?t.dataAttributes[e]=r:t.queryParams[e]=r,t}),{queryParams:{},dataAttributes:{}}),i=a.queryParams,u=a.dataAttributes;return{url:e+"?"+r(i),dataAttributes:u}}function r(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function n(t,e){void 0===e&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach((function(t){r.setAttribute(t,e[t]),"data-csp-nonce"===t&&r.setAttribute("nonce",e["data-csp-nonce"])})),r}function o(t,e){void 0===e&&(e=a()),u(t,e);var r=t.url,o=t.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new e((function(t,e){if("undefined"==typeof window)return t();!function(t){var e=t.url,r=t.attributes,o=t.onSuccess,a=t.onError,i=n(e,r);i.onerror=a,i.onload=o,document.head.insertBefore(i,document.head.firstElementChild)}({url:r,attributes:o,onSuccess:function(){return t()},onError:function(){return e(new Error('The script "'+r+'" failed to load.'))}})}))}function a(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function i(t){return window[t]}function u(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}return t.loadCustomScript=o,t.loadScript=function(t,r){if(void 0===r&&(r=a()),u(t,r),"undefined"==typeof window)return r.resolve(null);var c=e(t),s=c.url,d=c.dataAttributes,l=d["data-namespace"]||"paypal",f=i(l);return function(t,e){var r=document.querySelector('script[src="'+t+'"]');if(null===r)return null;var o=n(t,e),a=Object.assign({},r.dataset);if(delete a.uidAuto,Object.keys(a).length!==Object.keys(o.dataset).length)return null;var i=!0;return Object.keys(a).forEach((function(t){a[t]!==o.dataset[t]&&(i=!1)})),i?r:null}(s,d)&&f?r.resolve(f):o({url:s,attributes:d},r).then((function(){var t=i(l);if(t)return t;throw new Error("The window."+l+" global variable is not available.")}))},t.version="3.1.8",Object.defineProperty(t,"__esModule",{value:!0}),t}({});window.paypalLoadCustomScript=paypalLoadScript.loadCustomScript,window.paypalLoadScript=paypalLoadScript.loadScript; |
/*! | ||
* paypal-js v3.1.7 (2021-04-10T17:17:47.380Z) | ||
* paypal-js v3.1.8 (2021-04-21T19:00:46.311Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -18,3 +18,3 @@ * | ||
function findScript(url, attributes) { | ||
var currentScript = document.querySelector("script[src=\"".concat(url, "\"]")); | ||
var currentScript = document.querySelector("script[src=\"" + url + "\"]"); | ||
if (currentScript === null) return null; | ||
@@ -39,7 +39,7 @@ var nextScript = createScriptElement(url, attributes); // ignore the data-uid-auto attribute that gets auto-assigned to every script tag | ||
} | ||
function insertScriptElement(_ref) { | ||
var url = _ref.url, | ||
attributes = _ref.attributes, | ||
onSuccess = _ref.onSuccess, | ||
onError = _ref.onError; | ||
function insertScriptElement(_a) { | ||
var url = _a.url, | ||
attributes = _a.attributes, | ||
onSuccess = _a.onSuccess, | ||
onError = _a.onError; | ||
var newScript = createScriptElement(url, attributes); | ||
@@ -61,3 +61,3 @@ newScript.onerror = onError; | ||
var _Object$keys$filter$r = Object.keys(newOptions).filter(function (key) { | ||
var _a = Object.keys(newOptions).filter(function (key) { | ||
return typeof newOptions[key] !== "undefined" && newOptions[key] !== null && newOptions[key] !== ""; | ||
@@ -78,7 +78,7 @@ }).reduce(function (accumulator, key) { | ||
}), | ||
queryParams = _Object$keys$filter$r.queryParams, | ||
dataAttributes = _Object$keys$filter$r.dataAttributes; | ||
queryParams = _a.queryParams, | ||
dataAttributes = _a.dataAttributes; | ||
return { | ||
url: "".concat(sdkBaseURL, "?").concat(objectToQueryString(queryParams)), | ||
url: sdkBaseURL + "?" + objectToQueryString(queryParams), | ||
dataAttributes: dataAttributes | ||
@@ -96,4 +96,7 @@ }; | ||
function createScriptElement(url) { | ||
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
function createScriptElement(url, attributes) { | ||
if (attributes === void 0) { | ||
attributes = {}; | ||
} | ||
var newScript = document.createElement("script"); | ||
@@ -143,4 +146,7 @@ newScript.src = url; | ||
function loadScript(options) { | ||
var PromisePonyfill = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getDefaultPromiseImplementation(); | ||
function loadScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { | ||
PromisePonyfill = getDefaultPromiseImplementation(); | ||
} | ||
validateArguments(options, PromisePonyfill); // resolve with null when running in Node | ||
@@ -150,5 +156,5 @@ | ||
var _processOptions = processOptions(options), | ||
url = _processOptions.url, | ||
dataAttributes = _processOptions.dataAttributes; | ||
var _a = processOptions(options), | ||
url = _a.url, | ||
dataAttributes = _a.dataAttributes; | ||
@@ -172,3 +178,3 @@ var namespace = dataAttributes["data-namespace"] || "paypal"; | ||
throw new Error("The window.".concat(namespace, " global variable is not available.")); | ||
throw new Error("The window." + namespace + " global variable is not available."); | ||
}); | ||
@@ -184,4 +190,7 @@ } | ||
function loadCustomScript(options) { | ||
var PromisePonyfill = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getDefaultPromiseImplementation(); | ||
function loadCustomScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { | ||
PromisePonyfill = getDefaultPromiseImplementation(); | ||
} | ||
validateArguments(options, PromisePonyfill); | ||
@@ -209,3 +218,3 @@ var url = options.url, | ||
onError: function onError() { | ||
return reject(new Error("The script \"".concat(url, "\" failed to load."))); | ||
return reject(new Error("The script \"" + url + "\" failed to load.")); | ||
} | ||
@@ -239,4 +248,4 @@ }); | ||
var version = "3.1.7"; | ||
var version = "3.1.8"; | ||
export { loadCustomScript, loadScript, version }; |
/*! | ||
* paypal-js v3.1.7 (2021-04-10T17:17:47.380Z) | ||
* paypal-js v3.1.8 (2021-04-21T19:00:46.311Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -342,8 +342,8 @@ * | ||
function findScript(url, attributes) { | ||
const currentScript = document.querySelector(`script[src="${url}"]`); | ||
var currentScript = document.querySelector("script[src=\"" + url + "\"]"); | ||
if (currentScript === null) | ||
return null; | ||
const nextScript = createScriptElement(url, attributes); | ||
var nextScript = createScriptElement(url, attributes); | ||
// ignore the data-uid-auto attribute that gets auto-assigned to every script tag | ||
const currentScriptDataset = Object.assign({}, currentScript.dataset); | ||
var currentScriptDataset = Object.assign({}, currentScript.dataset); | ||
delete currentScriptDataset.uidAuto; | ||
@@ -355,5 +355,5 @@ // check if the new script has the same number of data attributes | ||
} | ||
let isExactMatch = true; | ||
var isExactMatch = true; | ||
// check if the data attribute values are the same | ||
Object.keys(currentScriptDataset).forEach((key) => { | ||
Object.keys(currentScriptDataset).forEach(function (key) { | ||
if (currentScriptDataset[key] !== nextScript.dataset[key]) { | ||
@@ -365,4 +365,5 @@ isExactMatch = false; | ||
} | ||
function insertScriptElement({ url, attributes, onSuccess, onError, }) { | ||
const newScript = createScriptElement(url, attributes); | ||
function insertScriptElement(_a) { | ||
var url = _a.url, attributes = _a.attributes, onSuccess = _a.onSuccess, onError = _a.onError; | ||
var newScript = createScriptElement(url, attributes); | ||
newScript.onerror = onError; | ||
@@ -373,3 +374,3 @@ newScript.onload = onSuccess; | ||
function processOptions(options) { | ||
let sdkBaseURL = "https://www.paypal.com/sdk/js"; | ||
var sdkBaseURL = "https://www.paypal.com/sdk/js"; | ||
if (options.sdkBaseURL) { | ||
@@ -379,6 +380,6 @@ sdkBaseURL = options.sdkBaseURL; | ||
} | ||
const processedMerchantIDAttributes = processMerchantID(options["merchant-id"], options["data-merchant-id"]); | ||
const newOptions = Object.assign({}, options, processedMerchantIDAttributes); | ||
const { queryParams, dataAttributes } = Object.keys(newOptions) | ||
.filter((key) => { | ||
var processedMerchantIDAttributes = processMerchantID(options["merchant-id"], options["data-merchant-id"]); | ||
var newOptions = Object.assign({}, options, processedMerchantIDAttributes); | ||
var _a = Object.keys(newOptions) | ||
.filter(function (key) { | ||
return (typeof newOptions[key] !== "undefined" && | ||
@@ -388,4 +389,4 @@ newOptions[key] !== null && | ||
}) | ||
.reduce((accumulator, key) => { | ||
const value = newOptions[key].toString(); | ||
.reduce(function (accumulator, key) { | ||
var value = newOptions[key].toString(); | ||
if (key.substring(0, 5) === "data-") { | ||
@@ -401,11 +402,11 @@ accumulator.dataAttributes[key] = value; | ||
dataAttributes: {}, | ||
}); | ||
}), queryParams = _a.queryParams, dataAttributes = _a.dataAttributes; | ||
return { | ||
url: `${sdkBaseURL}?${objectToQueryString(queryParams)}`, | ||
dataAttributes, | ||
url: sdkBaseURL + "?" + objectToQueryString(queryParams), | ||
dataAttributes: dataAttributes, | ||
}; | ||
} | ||
function objectToQueryString(params) { | ||
let queryString = ""; | ||
Object.keys(params).forEach((key) => { | ||
var queryString = ""; | ||
Object.keys(params).forEach(function (key) { | ||
if (queryString.length !== 0) | ||
@@ -417,6 +418,7 @@ queryString += "&"; | ||
} | ||
function createScriptElement(url, attributes = {}) { | ||
const newScript = document.createElement("script"); | ||
function createScriptElement(url, attributes) { | ||
if (attributes === void 0) { attributes = {}; } | ||
var newScript = document.createElement("script"); | ||
newScript.src = url; | ||
Object.keys(attributes).forEach((key) => { | ||
Object.keys(attributes).forEach(function (key) { | ||
newScript.setAttribute(key, attributes[key]); | ||
@@ -430,4 +432,4 @@ if (key === "data-csp-nonce") { | ||
function processMerchantID(merchantID, dataMerchantID) { | ||
let newMerchantID = ""; | ||
let newDataMerchantID = ""; | ||
var newMerchantID = ""; | ||
var newDataMerchantID = ""; | ||
if (Array.isArray(merchantID)) { | ||
@@ -463,3 +465,4 @@ if (merchantID.length > 1) { | ||
*/ | ||
function loadScript$1(options, PromisePonyfill = getDefaultPromiseImplementation()) { | ||
function loadScript$1(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { PromisePonyfill = getDefaultPromiseImplementation(); } | ||
validateArguments(options, PromisePonyfill); | ||
@@ -469,5 +472,5 @@ // resolve with null when running in Node | ||
return PromisePonyfill.resolve(null); | ||
const { url, dataAttributes } = processOptions(options); | ||
const namespace = dataAttributes["data-namespace"] || "paypal"; | ||
const existingWindowNamespace = getPayPalWindowNamespace(namespace); | ||
var _a = processOptions(options), url = _a.url, dataAttributes = _a.dataAttributes; | ||
var namespace = dataAttributes["data-namespace"] || "paypal"; | ||
var existingWindowNamespace = getPayPalWindowNamespace(namespace); | ||
// resolve with the existing global paypal namespace when a script with the same params already exists | ||
@@ -478,10 +481,10 @@ if (findScript(url, dataAttributes) && existingWindowNamespace) { | ||
return loadCustomScript$1({ | ||
url, | ||
url: url, | ||
attributes: dataAttributes, | ||
}, PromisePonyfill).then(() => { | ||
const newWindowNamespace = getPayPalWindowNamespace(namespace); | ||
}, PromisePonyfill).then(function () { | ||
var newWindowNamespace = getPayPalWindowNamespace(namespace); | ||
if (newWindowNamespace) { | ||
return newWindowNamespace; | ||
} | ||
throw new Error(`The window.${namespace} global variable is not available.`); | ||
throw new Error("The window." + namespace + " global variable is not available."); | ||
}); | ||
@@ -496,5 +499,6 @@ } | ||
*/ | ||
function loadCustomScript$1(options, PromisePonyfill = getDefaultPromiseImplementation()) { | ||
function loadCustomScript$1(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { PromisePonyfill = getDefaultPromiseImplementation(); } | ||
validateArguments(options, PromisePonyfill); | ||
const { url, attributes } = options; | ||
var url = options.url, attributes = options.attributes; | ||
if (typeof url !== "string" || url.length === 0) { | ||
@@ -506,3 +510,3 @@ throw new Error("Invalid url."); | ||
} | ||
return new PromisePonyfill((resolve, reject) => { | ||
return new PromisePonyfill(function (resolve, reject) { | ||
// resolve with undefined when running in Node | ||
@@ -512,6 +516,8 @@ if (typeof window === "undefined") | ||
insertScriptElement({ | ||
url, | ||
attributes, | ||
onSuccess: () => resolve(), | ||
onError: () => reject(new Error(`The script "${url}" failed to load.`)), | ||
url: url, | ||
attributes: attributes, | ||
onSuccess: function () { return resolve(); }, | ||
onError: function () { | ||
return reject(new Error("The script \"" + url + "\" failed to load.")); | ||
}, | ||
}); | ||
@@ -547,3 +553,3 @@ }); | ||
// replaced with the package.json version at build time | ||
const version = "3.1.7"; | ||
var version = "3.1.8"; | ||
@@ -550,0 +556,0 @@ exports.loadCustomScript = loadCustomScript; |
/*! | ||
* paypal-js v3.1.7 (2021-04-10T17:17:47.380Z) | ||
* paypal-js v3.1.8 (2021-04-21T19:00:46.311Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -17,2 +17,2 @@ * | ||
*/ | ||
var paypalLoadScript=function(t){"use strict";var e=setTimeout;function n(t){return Boolean(t&&void 0!==t.length)}function r(){}function o(t){if(!(this instanceof o))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],f(t,this)}function i(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,o._immediateFn((function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var r;try{r=n(t._value)}catch(t){return void a(e.promise,t)}u(e.promise,r)}else(1===t._state?u:a)(e.promise,t._value)}))):t._deferreds.push(e)}function u(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof o)return t._state=3,t._value=e,void c(t);if("function"==typeof n)return void f((r=n,i=e,function(){r.apply(i,arguments)}),t)}t._state=1,t._value=e,c(t)}catch(e){a(t,e)}var r,i}function a(t,e){t._state=2,t._value=e,c(t)}function c(t){2===t._state&&0===t._deferreds.length&&o._immediateFn((function(){t._handled||o._unhandledRejectionFn(t._value)}));for(var e=0,n=t._deferreds.length;e<n;e++)i(t,t._deferreds[e]);t._deferreds=null}function s(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function f(t,e){var n=!1;try{t((function(t){n||(n=!0,u(e,t))}),(function(t){n||(n=!0,a(e,t))}))}catch(t){if(n)return;n=!0,a(e,t)}}function l(t){let e="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(e=t.sdkBaseURL,delete t.sdkBaseURL);const n=function(t,e){let n="",r="";Array.isArray(t)?t.length>1?(n="*",r=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof e&&e.length>0&&(n="*",r=e);return{"merchant-id":n,"data-merchant-id":r}}(t["merchant-id"],t["data-merchant-id"]),r=Object.assign({},t,n),{queryParams:o,dataAttributes:i}=Object.keys(r).filter((t=>void 0!==r[t]&&null!==r[t]&&""!==r[t])).reduce(((t,e)=>{const n=r[e].toString();return"data-"===e.substring(0,5)?t.dataAttributes[e]=n:t.queryParams[e]=n,t}),{queryParams:{},dataAttributes:{}});return{url:`${e}?${d(o)}`,dataAttributes:i}}function d(t){let e="";return Object.keys(t).forEach((n=>{0!==e.length&&(e+="&"),e+=n+"="+t[n]})),e}function p(t,e={}){const n=document.createElement("script");return n.src=t,Object.keys(e).forEach((t=>{n.setAttribute(t,e[t]),"data-csp-nonce"===t&&n.setAttribute("nonce",e["data-csp-nonce"])})),n}function h(t,e=v()){if(m(t,e),"undefined"==typeof window)return e.resolve(null);const{url:n,dataAttributes:r}=l(t),o=r["data-namespace"]||"paypal",i=w(o);return function(t,e){const n=document.querySelector(`script[src="${t}"]`);if(null===n)return null;const r=p(t,e),o=Object.assign({},n.dataset);if(delete o.uidAuto,Object.keys(o).length!==Object.keys(r.dataset).length)return null;let i=!0;return Object.keys(o).forEach((t=>{o[t]!==r.dataset[t]&&(i=!1)})),i?n:null}(n,r)&&i?e.resolve(i):y({url:n,attributes:r},e).then((()=>{const t=w(o);if(t)return t;throw new Error(`The window.${o} global variable is not available.`)}))}function y(t,e=v()){m(t,e);const{url:n,attributes:r}=t;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new e(((t,e)=>{if("undefined"==typeof window)return t();!function({url:t,attributes:e,onSuccess:n,onError:r}){const o=p(t,e);o.onerror=r,o.onload=n,document.head.insertBefore(o,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:()=>t(),onError:()=>e(new Error(`The script "${n}" failed to load.`))})}))}function v(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function w(t){return window[t]}function m(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}o.prototype.catch=function(t){return this.then(null,t)},o.prototype.then=function(t,e){var n=new this.constructor(r);return i(this,new s(t,e,n)),n},o.prototype.finally=function(t){var e=this.constructor;return this.then((function(n){return e.resolve(t()).then((function(){return n}))}),(function(n){return e.resolve(t()).then((function(){return e.reject(n)}))}))},o.all=function(t){return new o((function(e,r){if(!n(t))return r(new TypeError("Promise.all accepts an array"));var o=Array.prototype.slice.call(t);if(0===o.length)return e([]);var i=o.length;function u(t,n){try{if(n&&("object"==typeof n||"function"==typeof n)){var a=n.then;if("function"==typeof a)return void a.call(n,(function(e){u(t,e)}),r)}o[t]=n,0==--i&&e(o)}catch(t){r(t)}}for(var a=0;a<o.length;a++)u(a,o[a])}))},o.allSettled=function(t){return new this((function(e,n){if(!t||void 0===t.length)return n(new TypeError(typeof t+" "+t+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);var o=r.length;function i(t,n){if(n&&("object"==typeof n||"function"==typeof n)){var u=n.then;if("function"==typeof u)return void u.call(n,(function(e){i(t,e)}),(function(n){r[t]={status:"rejected",reason:n},0==--o&&e(r)}))}r[t]={status:"fulfilled",value:n},0==--o&&e(r)}for(var u=0;u<r.length;u++)i(u,r[u])}))},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o((function(e){e(t)}))},o.reject=function(t){return new o((function(e,n){n(t)}))},o.race=function(t){return new o((function(e,r){if(!n(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,u=t.length;i<u;i++)o.resolve(t[i]).then(e,r)}))},o._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){e(t,0)},o._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};return t.loadCustomScript=function(t){return y(t,o)},t.loadScript=function(t){return h(t,o)},t.version="3.1.7",Object.defineProperty(t,"__esModule",{value:!0}),t}({});window.paypalLoadCustomScript=paypalLoadScript.loadCustomScript,window.paypalLoadScript=paypalLoadScript.loadScript; | ||
var paypalLoadScript=function(t){"use strict";var e=setTimeout;function n(t){return Boolean(t&&void 0!==t.length)}function r(){}function o(t){if(!(this instanceof o))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(t,this)}function i(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,o._immediateFn((function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var r;try{r=n(t._value)}catch(t){return void a(e.promise,t)}u(e.promise,r)}else(1===t._state?u:a)(e.promise,t._value)}))):t._deferreds.push(e)}function u(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof o)return t._state=3,t._value=e,void c(t);if("function"==typeof n)return void s((r=n,i=e,function(){r.apply(i,arguments)}),t)}t._state=1,t._value=e,c(t)}catch(e){a(t,e)}var r,i}function a(t,e){t._state=2,t._value=e,c(t)}function c(t){2===t._state&&0===t._deferreds.length&&o._immediateFn((function(){t._handled||o._unhandledRejectionFn(t._value)}));for(var e=0,n=t._deferreds.length;e<n;e++)i(t,t._deferreds[e]);t._deferreds=null}function f(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function s(t,e){var n=!1;try{t((function(t){n||(n=!0,u(e,t))}),(function(t){n||(n=!0,a(e,t))}))}catch(t){if(n)return;n=!0,a(e,t)}}function l(t){var e="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(e=t.sdkBaseURL,delete t.sdkBaseURL);var n=function(t,e){var n="",r="";Array.isArray(t)?t.length>1?(n="*",r=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof e&&e.length>0&&(n="*",r=e);return{"merchant-id":n,"data-merchant-id":r}}(t["merchant-id"],t["data-merchant-id"]),r=Object.assign({},t,n),o=Object.keys(r).filter((function(t){return void 0!==r[t]&&null!==r[t]&&""!==r[t]})).reduce((function(t,e){var n=r[e].toString();return"data-"===e.substring(0,5)?t.dataAttributes[e]=n:t.queryParams[e]=n,t}),{queryParams:{},dataAttributes:{}}),i=o.queryParams,u=o.dataAttributes;return{url:e+"?"+d(i),dataAttributes:u}}function d(t){var e="";return Object.keys(t).forEach((function(n){0!==e.length&&(e+="&"),e+=n+"="+t[n]})),e}function p(t,e){void 0===e&&(e={});var n=document.createElement("script");return n.src=t,Object.keys(e).forEach((function(t){n.setAttribute(t,e[t]),"data-csp-nonce"===t&&n.setAttribute("nonce",e["data-csp-nonce"])})),n}function h(t,e){if(void 0===e&&(e=v()),m(t,e),"undefined"==typeof window)return e.resolve(null);var n=l(t),r=n.url,o=n.dataAttributes,i=o["data-namespace"]||"paypal",u=w(i);return function(t,e){var n=document.querySelector('script[src="'+t+'"]');if(null===n)return null;var r=p(t,e),o=Object.assign({},n.dataset);if(delete o.uidAuto,Object.keys(o).length!==Object.keys(r.dataset).length)return null;var i=!0;return Object.keys(o).forEach((function(t){o[t]!==r.dataset[t]&&(i=!1)})),i?n:null}(r,o)&&u?e.resolve(u):y({url:r,attributes:o},e).then((function(){var t=w(i);if(t)return t;throw new Error("The window."+i+" global variable is not available.")}))}function y(t,e){void 0===e&&(e=v()),m(t,e);var n=t.url,r=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new e((function(t,e){if("undefined"==typeof window)return t();!function(t){var e=t.url,n=t.attributes,r=t.onSuccess,o=t.onError,i=p(e,n);i.onerror=o,i.onload=r,document.head.insertBefore(i,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return t()},onError:function(){return e(new Error('The script "'+n+'" failed to load.'))}})}))}function v(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function w(t){return window[t]}function m(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}o.prototype.catch=function(t){return this.then(null,t)},o.prototype.then=function(t,e){var n=new this.constructor(r);return i(this,new f(t,e,n)),n},o.prototype.finally=function(t){var e=this.constructor;return this.then((function(n){return e.resolve(t()).then((function(){return n}))}),(function(n){return e.resolve(t()).then((function(){return e.reject(n)}))}))},o.all=function(t){return new o((function(e,r){if(!n(t))return r(new TypeError("Promise.all accepts an array"));var o=Array.prototype.slice.call(t);if(0===o.length)return e([]);var i=o.length;function u(t,n){try{if(n&&("object"==typeof n||"function"==typeof n)){var a=n.then;if("function"==typeof a)return void a.call(n,(function(e){u(t,e)}),r)}o[t]=n,0==--i&&e(o)}catch(t){r(t)}}for(var a=0;a<o.length;a++)u(a,o[a])}))},o.allSettled=function(t){return new this((function(e,n){if(!t||void 0===t.length)return n(new TypeError(typeof t+" "+t+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);var o=r.length;function i(t,n){if(n&&("object"==typeof n||"function"==typeof n)){var u=n.then;if("function"==typeof u)return void u.call(n,(function(e){i(t,e)}),(function(n){r[t]={status:"rejected",reason:n},0==--o&&e(r)}))}r[t]={status:"fulfilled",value:n},0==--o&&e(r)}for(var u=0;u<r.length;u++)i(u,r[u])}))},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o((function(e){e(t)}))},o.reject=function(t){return new o((function(e,n){n(t)}))},o.race=function(t){return new o((function(e,r){if(!n(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,u=t.length;i<u;i++)o.resolve(t[i]).then(e,r)}))},o._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){e(t,0)},o._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};return t.loadCustomScript=function(t){return y(t,o)},t.loadScript=function(t){return h(t,o)},t.version="3.1.8",Object.defineProperty(t,"__esModule",{value:!0}),t}({});window.paypalLoadCustomScript=paypalLoadScript.loadCustomScript,window.paypalLoadScript=paypalLoadScript.loadScript; |
/*! | ||
* paypal-js v3.1.7 (2021-04-10T17:17:47.380Z) | ||
* paypal-js v3.1.8 (2021-04-21T19:00:46.311Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -22,3 +22,3 @@ * | ||
function findScript(url, attributes) { | ||
var currentScript = document.querySelector("script[src=\"".concat(url, "\"]")); | ||
var currentScript = document.querySelector("script[src=\"" + url + "\"]"); | ||
if (currentScript === null) return null; | ||
@@ -43,7 +43,7 @@ var nextScript = createScriptElement(url, attributes); // ignore the data-uid-auto attribute that gets auto-assigned to every script tag | ||
} | ||
function insertScriptElement(_ref) { | ||
var url = _ref.url, | ||
attributes = _ref.attributes, | ||
onSuccess = _ref.onSuccess, | ||
onError = _ref.onError; | ||
function insertScriptElement(_a) { | ||
var url = _a.url, | ||
attributes = _a.attributes, | ||
onSuccess = _a.onSuccess, | ||
onError = _a.onError; | ||
var newScript = createScriptElement(url, attributes); | ||
@@ -65,3 +65,3 @@ newScript.onerror = onError; | ||
var _Object$keys$filter$r = Object.keys(newOptions).filter(function (key) { | ||
var _a = Object.keys(newOptions).filter(function (key) { | ||
return typeof newOptions[key] !== "undefined" && newOptions[key] !== null && newOptions[key] !== ""; | ||
@@ -82,7 +82,7 @@ }).reduce(function (accumulator, key) { | ||
}), | ||
queryParams = _Object$keys$filter$r.queryParams, | ||
dataAttributes = _Object$keys$filter$r.dataAttributes; | ||
queryParams = _a.queryParams, | ||
dataAttributes = _a.dataAttributes; | ||
return { | ||
url: "".concat(sdkBaseURL, "?").concat(objectToQueryString(queryParams)), | ||
url: sdkBaseURL + "?" + objectToQueryString(queryParams), | ||
dataAttributes: dataAttributes | ||
@@ -100,4 +100,7 @@ }; | ||
function createScriptElement(url) { | ||
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
function createScriptElement(url, attributes) { | ||
if (attributes === void 0) { | ||
attributes = {}; | ||
} | ||
var newScript = document.createElement("script"); | ||
@@ -147,4 +150,7 @@ newScript.src = url; | ||
function loadScript(options) { | ||
var PromisePonyfill = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getDefaultPromiseImplementation(); | ||
function loadScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { | ||
PromisePonyfill = getDefaultPromiseImplementation(); | ||
} | ||
validateArguments(options, PromisePonyfill); // resolve with null when running in Node | ||
@@ -154,5 +160,5 @@ | ||
var _processOptions = processOptions(options), | ||
url = _processOptions.url, | ||
dataAttributes = _processOptions.dataAttributes; | ||
var _a = processOptions(options), | ||
url = _a.url, | ||
dataAttributes = _a.dataAttributes; | ||
@@ -176,3 +182,3 @@ var namespace = dataAttributes["data-namespace"] || "paypal"; | ||
throw new Error("The window.".concat(namespace, " global variable is not available.")); | ||
throw new Error("The window." + namespace + " global variable is not available."); | ||
}); | ||
@@ -188,4 +194,7 @@ } | ||
function loadCustomScript(options) { | ||
var PromisePonyfill = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getDefaultPromiseImplementation(); | ||
function loadCustomScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { | ||
PromisePonyfill = getDefaultPromiseImplementation(); | ||
} | ||
validateArguments(options, PromisePonyfill); | ||
@@ -213,3 +222,3 @@ var url = options.url, | ||
onError: function onError() { | ||
return reject(new Error("The script \"".concat(url, "\" failed to load."))); | ||
return reject(new Error("The script \"" + url + "\" failed to load.")); | ||
} | ||
@@ -243,3 +252,3 @@ }); | ||
var version = "3.1.7"; | ||
var version = "3.1.8"; | ||
@@ -246,0 +255,0 @@ exports.loadCustomScript = loadCustomScript; |
{ | ||
"name": "@paypal/paypal-js", | ||
"version": "3.1.7", | ||
"version": "3.1.8", | ||
"description": "Client-side loader for the PayPal JS SDK", | ||
@@ -43,4 +43,4 @@ "main": "dist/paypal.node.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.13.14", | ||
"@babel/preset-env": "^7.13.12", | ||
"@babel/core": "^7.13.16", | ||
"@babel/preset-env": "^7.13.15", | ||
"@babel/preset-typescript": "^7.13.0", | ||
@@ -56,16 +56,16 @@ "@commitlint/cli": "^12.1.1", | ||
"@types/promise-polyfill": "^6.0.3", | ||
"@typescript-eslint/eslint-plugin": "^4.20.0", | ||
"@typescript-eslint/parser": "^4.20.0", | ||
"@typescript-eslint/eslint-plugin": "^4.22.0", | ||
"@typescript-eslint/parser": "^4.22.0", | ||
"babel-jest": "^26.6.3", | ||
"eslint": "^7.23.0", | ||
"eslint": "^7.24.0", | ||
"eslint-plugin-compat": "^3.9.0", | ||
"filesize": "^6.1.0", | ||
"filesize": "^6.3.0", | ||
"husky": "^6.0.0", | ||
"jest": "^26.6.3", | ||
"jest-puppeteer": "^4.4.0", | ||
"jest-puppeteer": "^5.0.1", | ||
"lint-staged": "^10.5.4", | ||
"pinst": "^2.1.6", | ||
"prettier": "2.2.1", | ||
"puppeteer": "^8.0.0", | ||
"rollup": "^2.44.0", | ||
"puppeteer": "^9.0.0", | ||
"rollup": "^2.45.2", | ||
"rollup-plugin-filesize": "^9.1.1", | ||
@@ -75,5 +75,5 @@ "rollup-plugin-terser": "^7.0.2", | ||
"shelljs": "^0.8.4", | ||
"standard-version": "^9.1.1", | ||
"tslib": "^2.1.0", | ||
"typescript": "^4.2.3" | ||
"standard-version": "^9.2.0", | ||
"tslib": "^2.2.0", | ||
"typescript": "^4.2.4" | ||
}, | ||
@@ -80,0 +80,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96219
1591