Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@paypal/paypal-js

Package Overview
Dependencies
Maintainers
36
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paypal/paypal-js - npm Package Compare versions

Comparing version 4.0.12 to 4.1.0

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # Changelog

## [4.1.0](https://github.com/paypal/paypal-js/compare/v4.0.12...v4.1.0) (2021-10-06)
### Features
- **types:** enhance the hostedFields type ([#124](https://github.com/paypal/paypal-js/issues/124)) ([9f3a025](https://github.com/paypal/paypal-js/commit/9f3a025edde9eeb35c88e7859d2c7f6836baccd1))
### [4.0.12](https://github.com/paypal/paypal-js/compare/v4.0.11...v4.0.12) (2021-09-29)

@@ -7,0 +13,0 @@

4

dist/cjs/paypal-js.js
/*!
* paypal-js v4.0.12 (2021-09-29T18:08:53.845Z)
* paypal-js v4.1.0 (2021-10-06T21:12:47.247Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -242,3 +242,3 @@ *

var version = "4.0.12";
var version = "4.1.0";

@@ -245,0 +245,0 @@ exports.loadCustomScript = loadCustomScript;

/*!
* paypal-js v4.0.12 (2021-09-29T18:08:53.845Z)
* paypal-js v4.1.0 (2021-10-06T21:12:47.247Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -17,2 +17,2 @@ *

*/
"use strict";function t(t){var r="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(r=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),i=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:{}}),a=i.queryParams,u=i.dataAttributes;return{url:r+"?"+e(a),dataAttributes:u}}function e(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function r(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 n(t,e){void 0===e&&(e=o()),a(t,e);var n=t.url,i=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==i&&"object"!=typeof i)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,o=t.onSuccess,i=t.onError,a=r(e,n);a.onerror=i,a.onload=o,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:i,onSuccess:function(){return t()},onError:function(){return e(new Error('The script "'+n+'" failed to load.'))}})}))}function o(){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 a(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.")}Object.defineProperty(exports,"__esModule",{value:!0});exports.loadCustomScript=n,exports.loadScript=function(e,u){if(void 0===u&&(u=o()),a(e,u),"undefined"==typeof window)return u.resolve(null);var s=t(e),c=s.url,d=s.dataAttributes,l=d["data-namespace"]||"paypal",f=i(l);return function(t,e){var n=document.querySelector('script[src="'+t+'"]');if(null===n)return null;var o=r(t,e),i=Object.assign({},n.dataset);if(delete i.uidAuto,Object.keys(i).length!==Object.keys(o.dataset).length)return null;var a=!0;return Object.keys(i).forEach((function(t){i[t]!==o.dataset[t]&&(a=!1)})),a?n:null}(c,d)&&f?u.resolve(f):n({url:c,attributes:d},u).then((function(){var t=i(l);if(t)return t;throw new Error("The window."+l+" global variable is not available.")}))},exports.version="4.0.12";
"use strict";function t(t){var r="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(r=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),i=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:{}}),a=i.queryParams,u=i.dataAttributes;return{url:r+"?"+e(a),dataAttributes:u}}function e(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function r(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 n(t,e){void 0===e&&(e=o()),a(t,e);var n=t.url,i=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==i&&"object"!=typeof i)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,o=t.onSuccess,i=t.onError,a=r(e,n);a.onerror=i,a.onload=o,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:i,onSuccess:function(){return t()},onError:function(){return e(new Error('The script "'+n+'" failed to load.'))}})}))}function o(){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 a(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.")}Object.defineProperty(exports,"__esModule",{value:!0});exports.loadCustomScript=n,exports.loadScript=function(e,u){if(void 0===u&&(u=o()),a(e,u),"undefined"==typeof window)return u.resolve(null);var s=t(e),c=s.url,d=s.dataAttributes,l=d["data-namespace"]||"paypal",f=i(l);return function(t,e){var n=document.querySelector('script[src="'+t+'"]');if(null===n)return null;var o=r(t,e),i=Object.assign({},n.dataset);if(delete i.uidAuto,Object.keys(i).length!==Object.keys(o.dataset).length)return null;var a=!0;return Object.keys(i).forEach((function(t){i[t]!==o.dataset[t]&&(a=!1)})),a?n:null}(c,d)&&f?u.resolve(f):n({url:c,attributes:d},u).then((function(){var t=i(l);if(t)return t;throw new Error("The window."+l+" global variable is not available.")}))},exports.version="4.1.0";
/*!
* paypal-js v4.0.12 (2021-09-29T18:08:53.845Z)
* paypal-js v4.1.0 (2021-10-06T21:12:47.247Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -238,4 +238,4 @@ *

var version = "4.0.12";
var version = "4.1.0";
export { loadCustomScript, loadScript, version };
/*!
* paypal-js v4.0.12 (2021-09-29T18:08:53.845Z)
* paypal-js v4.1.0 (2021-10-06T21:12:47.247Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -17,2 +17,2 @@ *

*/
function t(t){var r="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(r=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),i=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:{}}),a=i.queryParams,u=i.dataAttributes;return{url:r+"?"+e(a),dataAttributes:u}}function e(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function r(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 n(e,n){if(void 0===n&&(n=i()),u(e,n),"undefined"==typeof window)return n.resolve(null);var s=t(e),c=s.url,d=s.dataAttributes,f=d["data-namespace"]||"paypal",l=a(f);return function(t,e){var n=document.querySelector('script[src="'+t+'"]');if(null===n)return null;var o=r(t,e),i=Object.assign({},n.dataset);if(delete i.uidAuto,Object.keys(i).length!==Object.keys(o.dataset).length)return null;var a=!0;return Object.keys(i).forEach((function(t){i[t]!==o.dataset[t]&&(a=!1)})),a?n:null}(c,d)&&l?n.resolve(l):o({url:c,attributes:d},n).then((function(){var t=a(f);if(t)return t;throw new Error("The window."+f+" global variable is not available.")}))}function o(t,e){void 0===e&&(e=i()),u(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();!function(t){var e=t.url,n=t.attributes,o=t.onSuccess,i=t.onError,a=r(e,n);a.onerror=i,a.onload=o,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:o,onSuccess:function(){return t()},onError:function(){return e(new Error('The script "'+n+'" failed to load.'))}})}))}function i(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function a(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.")}var s="4.0.12";export{o as loadCustomScript,n as loadScript,s as version};
function t(t){var r="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(r=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),i=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:{}}),a=i.queryParams,u=i.dataAttributes;return{url:r+"?"+e(a),dataAttributes:u}}function e(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function r(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 n(e,n){if(void 0===n&&(n=i()),u(e,n),"undefined"==typeof window)return n.resolve(null);var s=t(e),c=s.url,d=s.dataAttributes,f=d["data-namespace"]||"paypal",l=a(f);return function(t,e){var n=document.querySelector('script[src="'+t+'"]');if(null===n)return null;var o=r(t,e),i=Object.assign({},n.dataset);if(delete i.uidAuto,Object.keys(i).length!==Object.keys(o.dataset).length)return null;var a=!0;return Object.keys(i).forEach((function(t){i[t]!==o.dataset[t]&&(a=!1)})),a?n:null}(c,d)&&l?n.resolve(l):o({url:c,attributes:d},n).then((function(){var t=a(f);if(t)return t;throw new Error("The window."+f+" global variable is not available.")}))}function o(t,e){void 0===e&&(e=i()),u(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();!function(t){var e=t.url,n=t.attributes,o=t.onSuccess,i=t.onError,a=r(e,n);a.onerror=i,a.onload=o,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:o,onSuccess:function(){return t()},onError:function(){return e(new Error('The script "'+n+'" failed to load.'))}})}))}function i(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function a(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.")}var s="4.1.0";export{o as loadCustomScript,n as loadScript,s as version};
/*!
* paypal-js v4.0.12 (2021-09-29T18:08:53.845Z)
* paypal-js v4.1.0 (2021-10-06T21:12:47.247Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -241,3 +241,3 @@ *

var version = "4.0.12";
var version = "4.1.0";

@@ -244,0 +244,0 @@ exports.loadCustomScript = loadCustomScript;

/*!
* paypal-js v4.0.12 (2021-09-29T18:08:53.845Z)
* paypal-js v4.1.0 (2021-10-06T21:12:47.247Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -538,3 +538,3 @@ *

// replaced with the package.json version at build time
var version = "4.0.12";
var version = "4.1.0";

@@ -541,0 +541,0 @@ exports.loadCustomScript = loadCustomScript;

/*!
* paypal-js v4.0.12 (2021-09-29T18:08:53.845Z)
* paypal-js v4.1.0 (2021-10-06T21:12:47.247Z)
* 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=[],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="4.0.12",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="4.1.0",Object.defineProperty(t,"__esModule",{value:!0}),t}({});window.paypalLoadCustomScript=paypalLoadScript.loadCustomScript,window.paypalLoadScript=paypalLoadScript.loadScript;
/*!
* paypal-js v4.0.12 (2021-09-29T18:08:53.845Z)
* paypal-js v4.1.0 (2021-10-06T21:12:47.247Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -17,2 +17,2 @@ *

*/
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="4.0.12",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="4.1.0",Object.defineProperty(t,"__esModule",{value:!0}),t}({});window.paypalLoadCustomScript=paypalLoadScript.loadCustomScript,window.paypalLoadScript=paypalLoadScript.loadScript;
{
"name": "@paypal/paypal-js",
"version": "4.0.12",
"version": "4.1.0",
"description": "Client-side loader for the PayPal JS SDK",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -209,3 +209,3 @@ # paypal-js

```html
<script src="https://unpkg.com/@paypal/paypal-js@4.0.12/dist/iife/paypal-js.legacy.min.js"></script>
<script src="https://unpkg.com/@paypal/paypal-js@4.1.0/dist/iife/paypal-js.legacy.min.js"></script>
```

@@ -221,3 +221,3 @@

<head>
<script src="https://unpkg.com/@paypal/paypal-js@4.0.12/dist/iife/paypal-js.min.js"></script>
<script src="https://unpkg.com/@paypal/paypal-js@4.1.0/dist/iife/paypal-js.min.js"></script>
</head>

@@ -224,0 +224,0 @@ <body>

@@ -5,2 +5,62 @@ import type { CreateOrderRequestBody } from "../apis/orders";

type HostedFieldsCardTypes = {
[key in
| "amex"
| "discover"
| "elo"
| "hiper"
| "jcb"
| "mastercard"
| "visa"]: { eligible: boolean; valuable: boolean };
};
type HostedFieldsCardState = {
fields: {
[key in
| "number"
| "cvv"
| "expirationDate"
| "expirationMonth"
| "expirationYear"
| "postalCode"]?: {
container: HTMLElement;
isEmpty: boolean;
isFocused: boolean;
isPotentiallyValid: boolean;
isValid: boolean;
};
};
cards: {
type: string;
niceType: string;
lengths: number[];
gaps: number[];
code: {
name: string;
size: number;
};
}[];
};
type HostedFieldsTokenize = {
vault?: boolean;
authenticationInsight?: unknown;
fieldsToTokenize?: string[];
cardholderName?: string;
billingAddress?: {
postalCode?: string;
firstName?: string;
lastName?: string;
company?: string;
streetAddress?: string;
extendedAddress?: string;
locality?: string;
region?: string;
countryCodeNumeric?: string;
countryCodeAlpha2?: string;
countryCodeAlpha3?: string;
countryName?: string;
};
};
export type CreateOrderActions = {

@@ -30,8 +90,75 @@ order: {

type: string;
}
};
}
export interface HostedFieldsHandler {
/**
* Add a class to a field. Useful for updating field styles when events occur elsewhere in your checkout.
*/
addClass: (field: string, className: string) => Promise<void>;
/**
* Clear the value of a field.
*/
clear: (field: string) => Promise<void>;
/**
* Programmatically focus a field.
*/
focus: (field: string) => Promise<void>;
/**
* Get supported card types configured in the Braintree Control Panel.
*/
getCardTypes: () => HostedFieldsCardTypes;
/**
* Get the state of all the rendered fields.
*/
getState: () => HostedFieldsCardState;
/**
* Removes a supported attribute from a field.
*/
removeAttribute: (options: {
field: string;
attribute: string;
}) => Promise<void>;
/**
* Removes a class to a field. Useful for updating field styles when events occur elsewhere in your checkout.
*/
removeClass: (options: {
field: string;
className: string;
}) => Promise<void>;
/**
* Sets an attribute of a field. Supported attributes are aria-invalid,
* aria-required, disabled, and placeholder.
*/
setAttribute: (options: {
field: string;
attribute: string;
value: string;
}) => Promise<void>;
/**
* Sets a visually hidden message (for screen readers) on a field.
*/
setMessage: (options: { field: string; attribute: string }) => void;
/**
* Sets the month options for the expiration month field when presented as a select element.
*/
setMonthOptions: (options: unknown) => Promise<void>;
/**
* Sets the placeholder from a field.
*/
setPlaceholder: (field: string, placeholder: string) => Promise<void>;
/**
* Submit the form if is valid
*/
submit: (options?: UnknownObject) => Promise<HostedFieldsSubmitResponse>;
getCardTypes: () => UnknownObject;
/**
* Clean all the fields from the DOM
*/
teardown: () => Promise<void>;
/**
* Tokenize fields and returns a nonce payload.
*/
tokenize: (
options: HostedFieldsTokenize
) => Promise<Record<string, unknown>>;
}

@@ -38,0 +165,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc