@paystack/inline-js 2.22.1-dev.3 → 2.22.2-dev.1

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/dist/inline.js CHANGED
@@ -532,6 +532,9 @@ var PaystackPop = (function () {
532
532
  return highestZIndex;
533
533
  }
534
534
 
535
+ var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js';
536
+ var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-z/6BVHCcSypLSykOVpaT1PQWHOOgU45uOOlMkgi/bElX4yFqmChNMb7qiv80wFav';
537
+
535
538
  function createIframe(id) {
536
539
  var iframe = document.createElement('iframe');
537
540
  iframe.setAttribute('frameBorder', '0');
@@ -571,7 +574,9 @@ var PaystackPop = (function () {
571
574
  function getApplePayButton(container) {
572
575
  return container.querySelector('apple-pay-button') || container.querySelector('#apple-pay-button');
573
576
  }
574
- var loadScript = function loadScript(url, container) {
577
+ var loadScript = function loadScript(url, _ref) {
578
+ var container = _ref.container,
579
+ integrity = _ref.integrity;
575
580
  return new Promise(function (resolve, reject) {
576
581
  if (!url) {
577
582
  reject('No script url');
@@ -579,6 +584,12 @@ var PaystackPop = (function () {
579
584
 
580
585
  var script = document.createElement('script');
581
586
  script.src = url;
587
+ script.crossOrigin = 'anonymous';
588
+
589
+ if (integrity) {
590
+ script.integrity = integrity;
591
+ }
592
+
582
593
  script.addEventListener('load', function () {
583
594
  resolve(true);
584
595
  });
@@ -699,9 +710,9 @@ var PaystackPop = (function () {
699
710
  input.name = name;
700
711
  parent.appendChild(input);
701
712
  }
702
- function mountApplePayButton(container, _ref) {
703
- var styles = _ref.styles,
704
- theme = _ref.theme;
713
+ function mountApplePayButton(container, _ref2) {
714
+ var styles = _ref2.styles,
715
+ theme = _ref2.theme;
705
716
  var style = document.createElement('style');
706
717
  var applePayCSS = generateApplePayCSS(styles);
707
718
  style.type = 'text/css';
@@ -719,9 +730,9 @@ var PaystackPop = (function () {
719
730
  button.setAttribute('locale', styles.locale);
720
731
  container.appendChild(button);
721
732
  }
722
- function mountApplePayFallbackButton(container, _ref2) {
723
- var styles = _ref2.styles,
724
- theme = _ref2.theme;
733
+ function mountApplePayFallbackButton(container, _ref3) {
734
+ var styles = _ref3.styles,
735
+ theme = _ref3.theme;
725
736
  var style = document.createElement('style');
726
737
  var applePayCSS = generateApplePayFallbackCSS(styles);
727
738
  style.type = 'text/css';
@@ -744,11 +755,11 @@ var PaystackPop = (function () {
744
755
  function getPaymentRequestContainer(container) {
745
756
  return document.querySelector("#".concat(container));
746
757
  }
747
- function mountPaymentRequestButtons(container, _ref3, merchantId) {
748
- var _ref3$channels = _ref3.channels,
749
- channels = _ref3$channels === void 0 ? [] : _ref3$channels,
750
- _ref3$styles = _ref3.styles,
751
- styles = _ref3$styles === void 0 ? {} : _ref3$styles;
758
+ function mountPaymentRequestButtons(container, _ref4, merchantId) {
759
+ var _ref4$channels = _ref4.channels,
760
+ channels = _ref4$channels === void 0 ? [] : _ref4$channels,
761
+ _ref4$styles = _ref4.styles,
762
+ styles = _ref4$styles === void 0 ? {} : _ref4$styles;
752
763
  var mountedElements = {
753
764
  applePay: false
754
765
  };
@@ -761,7 +772,10 @@ var PaystackPop = (function () {
761
772
  return;
762
773
  }
763
774
 
764
- loadScript('https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js', container).then(function () {
775
+ loadScript(APPLE_PAY_SDK_SOURCE, {
776
+ container: container,
777
+ integrity: APPLE_PAY_SDK_INTEGRITY_HASH
778
+ }).then(function () {
765
779
  /**
766
780
  * We are currently attempting to deprecate the below code to check webpackjsonp is an array.
767
781
  * To do this safely, we are limiting this change to single test integration before rolling
@@ -914,13 +928,13 @@ var PaystackPop = (function () {
914
928
  content.classList.add('pre-checkout-modal__content');
915
929
  modal.appendChild(content);
916
930
 
917
- var _ref4 = transaction || {},
918
- merchantLogo = _ref4.merchant_logo,
919
- merchantName = _ref4.merchant_name,
920
- email = _ref4.email,
921
- amount = _ref4.amount,
922
- currency = _ref4.currency,
923
- label = _ref4.label;
931
+ var _ref5 = transaction || {},
932
+ merchantLogo = _ref5.merchant_logo,
933
+ merchantName = _ref5.merchant_name,
934
+ email = _ref5.email,
935
+ amount = _ref5.amount,
936
+ currency = _ref5.currency,
937
+ label = _ref5.label;
924
938
 
925
939
  var formattedAmount = new Intl.NumberFormat('en', {
926
940
  style: 'currency',
package/es/inline.js CHANGED
@@ -529,6 +529,9 @@ function findHighestZIndex() {
529
529
  return highestZIndex;
530
530
  }
531
531
 
532
+ var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js';
533
+ var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-z/6BVHCcSypLSykOVpaT1PQWHOOgU45uOOlMkgi/bElX4yFqmChNMb7qiv80wFav';
534
+
532
535
  function createIframe(id) {
533
536
  var iframe = document.createElement('iframe');
534
537
  iframe.setAttribute('frameBorder', '0');
@@ -568,7 +571,9 @@ function mountEmbedCheckoutIframe(id, src) {
568
571
  function getApplePayButton(container) {
569
572
  return container.querySelector('apple-pay-button') || container.querySelector('#apple-pay-button');
570
573
  }
571
- var loadScript = function loadScript(url, container) {
574
+ var loadScript = function loadScript(url, _ref) {
575
+ var container = _ref.container,
576
+ integrity = _ref.integrity;
572
577
  return new Promise(function (resolve, reject) {
573
578
  if (!url) {
574
579
  reject('No script url');
@@ -576,6 +581,12 @@ var loadScript = function loadScript(url, container) {
576
581
 
577
582
  var script = document.createElement('script');
578
583
  script.src = url;
584
+ script.crossOrigin = 'anonymous';
585
+
586
+ if (integrity) {
587
+ script.integrity = integrity;
588
+ }
589
+
579
590
  script.addEventListener('load', function () {
580
591
  resolve(true);
581
592
  });
@@ -696,9 +707,9 @@ function mountInput(options) {
696
707
  input.name = name;
697
708
  parent.appendChild(input);
698
709
  }
699
- function mountApplePayButton(container, _ref) {
700
- var styles = _ref.styles,
701
- theme = _ref.theme;
710
+ function mountApplePayButton(container, _ref2) {
711
+ var styles = _ref2.styles,
712
+ theme = _ref2.theme;
702
713
  var style = document.createElement('style');
703
714
  var applePayCSS = generateApplePayCSS(styles);
704
715
  style.type = 'text/css';
@@ -716,9 +727,9 @@ function mountApplePayButton(container, _ref) {
716
727
  button.setAttribute('locale', styles.locale);
717
728
  container.appendChild(button);
718
729
  }
719
- function mountApplePayFallbackButton(container, _ref2) {
720
- var styles = _ref2.styles,
721
- theme = _ref2.theme;
730
+ function mountApplePayFallbackButton(container, _ref3) {
731
+ var styles = _ref3.styles,
732
+ theme = _ref3.theme;
722
733
  var style = document.createElement('style');
723
734
  var applePayCSS = generateApplePayFallbackCSS(styles);
724
735
  style.type = 'text/css';
@@ -741,11 +752,11 @@ function mountApplePayFallbackButton(container, _ref2) {
741
752
  function getPaymentRequestContainer(container) {
742
753
  return document.querySelector("#".concat(container));
743
754
  }
744
- function mountPaymentRequestButtons(container, _ref3, merchantId) {
745
- var _ref3$channels = _ref3.channels,
746
- channels = _ref3$channels === void 0 ? [] : _ref3$channels,
747
- _ref3$styles = _ref3.styles,
748
- styles = _ref3$styles === void 0 ? {} : _ref3$styles;
755
+ function mountPaymentRequestButtons(container, _ref4, merchantId) {
756
+ var _ref4$channels = _ref4.channels,
757
+ channels = _ref4$channels === void 0 ? [] : _ref4$channels,
758
+ _ref4$styles = _ref4.styles,
759
+ styles = _ref4$styles === void 0 ? {} : _ref4$styles;
749
760
  var mountedElements = {
750
761
  applePay: false
751
762
  };
@@ -758,7 +769,10 @@ function mountPaymentRequestButtons(container, _ref3, merchantId) {
758
769
  return;
759
770
  }
760
771
 
761
- loadScript('https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js', container).then(function () {
772
+ loadScript(APPLE_PAY_SDK_SOURCE, {
773
+ container: container,
774
+ integrity: APPLE_PAY_SDK_INTEGRITY_HASH
775
+ }).then(function () {
762
776
  /**
763
777
  * We are currently attempting to deprecate the below code to check webpackjsonp is an array.
764
778
  * To do this safely, we are limiting this change to single test integration before rolling
@@ -911,13 +925,13 @@ function mountPreCheckoutModal(id, transaction) {
911
925
  content.classList.add('pre-checkout-modal__content');
912
926
  modal.appendChild(content);
913
927
 
914
- var _ref4 = transaction || {},
915
- merchantLogo = _ref4.merchant_logo,
916
- merchantName = _ref4.merchant_name,
917
- email = _ref4.email,
918
- amount = _ref4.amount,
919
- currency = _ref4.currency,
920
- label = _ref4.label;
928
+ var _ref5 = transaction || {},
929
+ merchantLogo = _ref5.merchant_logo,
930
+ merchantName = _ref5.merchant_name,
931
+ email = _ref5.email,
932
+ amount = _ref5.amount,
933
+ currency = _ref5.currency,
934
+ label = _ref5.label;
921
935
 
922
936
  var formattedAmount = new Intl.NumberFormat('en', {
923
937
  style: 'currency',
package/lib/inline.js CHANGED
@@ -531,6 +531,9 @@ function findHighestZIndex() {
531
531
  return highestZIndex;
532
532
  }
533
533
 
534
+ var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js';
535
+ var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-z/6BVHCcSypLSykOVpaT1PQWHOOgU45uOOlMkgi/bElX4yFqmChNMb7qiv80wFav';
536
+
534
537
  function createIframe(id) {
535
538
  var iframe = document.createElement('iframe');
536
539
  iframe.setAttribute('frameBorder', '0');
@@ -570,7 +573,9 @@ function mountEmbedCheckoutIframe(id, src) {
570
573
  function getApplePayButton(container) {
571
574
  return container.querySelector('apple-pay-button') || container.querySelector('#apple-pay-button');
572
575
  }
573
- var loadScript = function loadScript(url, container) {
576
+ var loadScript = function loadScript(url, _ref) {
577
+ var container = _ref.container,
578
+ integrity = _ref.integrity;
574
579
  return new Promise(function (resolve, reject) {
575
580
  if (!url) {
576
581
  reject('No script url');
@@ -578,6 +583,12 @@ var loadScript = function loadScript(url, container) {
578
583
 
579
584
  var script = document.createElement('script');
580
585
  script.src = url;
586
+ script.crossOrigin = 'anonymous';
587
+
588
+ if (integrity) {
589
+ script.integrity = integrity;
590
+ }
591
+
581
592
  script.addEventListener('load', function () {
582
593
  resolve(true);
583
594
  });
@@ -698,9 +709,9 @@ function mountInput(options) {
698
709
  input.name = name;
699
710
  parent.appendChild(input);
700
711
  }
701
- function mountApplePayButton(container, _ref) {
702
- var styles = _ref.styles,
703
- theme = _ref.theme;
712
+ function mountApplePayButton(container, _ref2) {
713
+ var styles = _ref2.styles,
714
+ theme = _ref2.theme;
704
715
  var style = document.createElement('style');
705
716
  var applePayCSS = generateApplePayCSS(styles);
706
717
  style.type = 'text/css';
@@ -718,9 +729,9 @@ function mountApplePayButton(container, _ref) {
718
729
  button.setAttribute('locale', styles.locale);
719
730
  container.appendChild(button);
720
731
  }
721
- function mountApplePayFallbackButton(container, _ref2) {
722
- var styles = _ref2.styles,
723
- theme = _ref2.theme;
732
+ function mountApplePayFallbackButton(container, _ref3) {
733
+ var styles = _ref3.styles,
734
+ theme = _ref3.theme;
724
735
  var style = document.createElement('style');
725
736
  var applePayCSS = generateApplePayFallbackCSS(styles);
726
737
  style.type = 'text/css';
@@ -743,11 +754,11 @@ function mountApplePayFallbackButton(container, _ref2) {
743
754
  function getPaymentRequestContainer(container) {
744
755
  return document.querySelector("#".concat(container));
745
756
  }
746
- function mountPaymentRequestButtons(container, _ref3, merchantId) {
747
- var _ref3$channels = _ref3.channels,
748
- channels = _ref3$channels === void 0 ? [] : _ref3$channels,
749
- _ref3$styles = _ref3.styles,
750
- styles = _ref3$styles === void 0 ? {} : _ref3$styles;
757
+ function mountPaymentRequestButtons(container, _ref4, merchantId) {
758
+ var _ref4$channels = _ref4.channels,
759
+ channels = _ref4$channels === void 0 ? [] : _ref4$channels,
760
+ _ref4$styles = _ref4.styles,
761
+ styles = _ref4$styles === void 0 ? {} : _ref4$styles;
751
762
  var mountedElements = {
752
763
  applePay: false
753
764
  };
@@ -760,7 +771,10 @@ function mountPaymentRequestButtons(container, _ref3, merchantId) {
760
771
  return;
761
772
  }
762
773
 
763
- loadScript('https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js', container).then(function () {
774
+ loadScript(APPLE_PAY_SDK_SOURCE, {
775
+ container: container,
776
+ integrity: APPLE_PAY_SDK_INTEGRITY_HASH
777
+ }).then(function () {
764
778
  /**
765
779
  * We are currently attempting to deprecate the below code to check webpackjsonp is an array.
766
780
  * To do this safely, we are limiting this change to single test integration before rolling
@@ -913,13 +927,13 @@ function mountPreCheckoutModal(id, transaction) {
913
927
  content.classList.add('pre-checkout-modal__content');
914
928
  modal.appendChild(content);
915
929
 
916
- var _ref4 = transaction || {},
917
- merchantLogo = _ref4.merchant_logo,
918
- merchantName = _ref4.merchant_name,
919
- email = _ref4.email,
920
- amount = _ref4.amount,
921
- currency = _ref4.currency,
922
- label = _ref4.label;
930
+ var _ref5 = transaction || {},
931
+ merchantLogo = _ref5.merchant_logo,
932
+ merchantName = _ref5.merchant_name,
933
+ email = _ref5.email,
934
+ amount = _ref5.amount,
935
+ currency = _ref5.currency,
936
+ label = _ref5.label;
923
937
 
924
938
  var formattedAmount = new Intl.NumberFormat('en', {
925
939
  style: 'currency',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/inline-js",
3
- "version": "2.22.1-dev.3",
3
+ "version": "2.22.2-dev.1",
4
4
  "description": "Client-side library to load the Paystack checkout form",
5
5
  "main": "lib/inline.js",
6
6
  "module": "es/inline.js",