Socket
Socket
Sign inDemoInstall

@stripe/stripe-js

Package Overview
Dependencies
Maintainers
8
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stripe/stripe-js - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

83

dist/stripe.esm.js

@@ -1,40 +0,53 @@

const V3_URL = 'https://js.stripe.com/v3';
const injectScript = () => {
const script = document.createElement('script');
script.src = V3_URL;
const headOrBody = document.head || document.body;
if (!headOrBody) {
throw new Error('Expected document.body not to be null. Stripe.js requires a <body> element.');
}
headOrBody.appendChild(script);
return script;
};
// Execute our own script injection after a tick to give users time to
var V3_URL = 'https://js.stripe.com/v3';
var injectScript = function injectScript() {
var script = document.createElement('script');
script.src = V3_URL;
var headOrBody = document.head || document.body;
if (!headOrBody) {
throw new Error('Expected document.body not to be null. Stripe.js requires a <body> element.');
}
headOrBody.appendChild(script);
return script;
}; // Execute our own script injection after a tick to give users time to
// do their own script injection.
const stripePromise = Promise.resolve().then(() => {
if (typeof window === 'undefined') {
// Resolve to null when imported server side. This makes the module
// safe to import in an isomorphic code base.
return null;
}
if (window.Stripe) {
return window.Stripe;
}
const script = document.querySelector(`script[src="${V3_URL}"]`) || injectScript();
return new Promise((resolve, reject) => {
script.addEventListener('load', () => {
if (window.Stripe) {
resolve(window.Stripe);
}
else {
reject(new Error('Failed to load Stripe.js'));
}
});
script.addEventListener('error', () => {
reject(new Error('Failed to load Stripe.js'));
});
var stripePromise = Promise.resolve().then(function () {
if (typeof window === 'undefined') {
// Resolve to null when imported server side. This makes the module
// safe to import in an isomorphic code base.
return null;
}
if (window.Stripe) {
return window.Stripe;
}
var script = document.querySelector("script[src=\"".concat(V3_URL, "\"]")) || injectScript();
return new Promise(function (resolve, reject) {
script.addEventListener('load', function () {
if (window.Stripe) {
resolve(window.Stripe);
} else {
reject(new Error('Failed to load Stripe.js'));
}
});
script.addEventListener('error', function () {
reject(new Error('Failed to load Stripe.js'));
});
});
});
const loadStripe = (...args) => stripePromise.then((maybeStripe) => maybeStripe ? maybeStripe(...args) : null);
var loadStripe = function loadStripe() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return stripePromise.then(function (maybeStripe) {
return maybeStripe ? maybeStripe.apply(void 0, args) : null;
});
};
export { loadStripe };

@@ -5,41 +5,54 @@ 'use strict';

const V3_URL = 'https://js.stripe.com/v3';
const injectScript = () => {
const script = document.createElement('script');
script.src = V3_URL;
const headOrBody = document.head || document.body;
if (!headOrBody) {
throw new Error('Expected document.body not to be null. Stripe.js requires a <body> element.');
}
headOrBody.appendChild(script);
return script;
};
// Execute our own script injection after a tick to give users time to
var V3_URL = 'https://js.stripe.com/v3';
var injectScript = function injectScript() {
var script = document.createElement('script');
script.src = V3_URL;
var headOrBody = document.head || document.body;
if (!headOrBody) {
throw new Error('Expected document.body not to be null. Stripe.js requires a <body> element.');
}
headOrBody.appendChild(script);
return script;
}; // Execute our own script injection after a tick to give users time to
// do their own script injection.
const stripePromise = Promise.resolve().then(() => {
if (typeof window === 'undefined') {
// Resolve to null when imported server side. This makes the module
// safe to import in an isomorphic code base.
return null;
}
if (window.Stripe) {
return window.Stripe;
}
const script = document.querySelector(`script[src="${V3_URL}"]`) || injectScript();
return new Promise((resolve, reject) => {
script.addEventListener('load', () => {
if (window.Stripe) {
resolve(window.Stripe);
}
else {
reject(new Error('Failed to load Stripe.js'));
}
});
script.addEventListener('error', () => {
reject(new Error('Failed to load Stripe.js'));
});
var stripePromise = Promise.resolve().then(function () {
if (typeof window === 'undefined') {
// Resolve to null when imported server side. This makes the module
// safe to import in an isomorphic code base.
return null;
}
if (window.Stripe) {
return window.Stripe;
}
var script = document.querySelector("script[src=\"".concat(V3_URL, "\"]")) || injectScript();
return new Promise(function (resolve, reject) {
script.addEventListener('load', function () {
if (window.Stripe) {
resolve(window.Stripe);
} else {
reject(new Error('Failed to load Stripe.js'));
}
});
script.addEventListener('error', function () {
reject(new Error('Failed to load Stripe.js'));
});
});
});
const loadStripe = (...args) => stripePromise.then((maybeStripe) => maybeStripe ? maybeStripe(...args) : null);
var loadStripe = function loadStripe() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return stripePromise.then(function (maybeStripe) {
return maybeStripe ? maybeStripe.apply(void 0, args) : null;
});
};
exports.loadStripe = loadStripe;
{
"name": "@stripe/stripe-js",
"version": "1.0.1",
"version": "1.0.2",
"description": "Stripe.js loading utility",

@@ -5,0 +5,0 @@ "main": "dist/stripe.js",

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