New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stripe/stripe-js

Package Overview
Dependencies
Maintainers
0
Versions
149
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

to
5.10.0

src/testUtils.ts

20

dist/index.js

@@ -5,4 +5,10 @@ 'use strict';

var RELEASE_TRAIN = 'v3';
var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion(version) {
return version === 3 ? 'v3' : version;
};
var ORIGIN = 'https://js.stripe.com';
var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
var STRIPE_JS_URL = "".concat(ORIGIN, "/v3") ;
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;

@@ -53,3 +59,3 @@ var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;

name: 'stripe-js',
version: "5.9.2",
version: "5.10.0",
startTime: startTime

@@ -143,2 +149,12 @@ });

var pk = args[0];
var isTestKey = pk.match(/^pk_test/); // @ts-expect-error this is not publicly typed
var version = runtimeVersionToUrlVersion(maybeStripe.version);
var expectedVersion = RELEASE_TRAIN;
if (isTestKey && version !== expectedVersion) {
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("5.10.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
}
var stripe = maybeStripe.apply(undefined, args);

@@ -145,0 +161,0 @@ registerWrapper(stripe, startTime);

@@ -21,4 +21,10 @@ 'use strict';

var RELEASE_TRAIN = 'v3';
var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion(version) {
return version === 3 ? 'v3' : version;
};
var ORIGIN = 'https://js.stripe.com';
var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
var STRIPE_JS_URL = "".concat(ORIGIN, "/v3") ;
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;

@@ -69,3 +75,3 @@ var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;

name: 'stripe-js',
version: "5.9.2",
version: "5.10.0",
startTime: startTime

@@ -159,2 +165,12 @@ });

var pk = args[0];
var isTestKey = pk.match(/^pk_test/); // @ts-expect-error this is not publicly typed
var version = runtimeVersionToUrlVersion(maybeStripe.version);
var expectedVersion = RELEASE_TRAIN;
if (isTestKey && version !== expectedVersion) {
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("5.10.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
}
var stripe = maybeStripe.apply(undefined, args);

@@ -161,0 +177,0 @@ registerWrapper(stripe, startTime);

2

package.json
{
"name": "@stripe/stripe-js",
"version": "5.9.2",
"version": "5.10.0",
"description": "Stripe.js loading utility",

@@ -5,0 +5,0 @@ "repository": "github:stripe/stripe-js",

@@ -0,7 +1,7 @@

import {SCRIPT_SRC} from './testUtils';
import {RELEASE_TRAIN} from './shared';
/* eslint-disable @typescript-eslint/no-var-requires */
const dispatchScriptEvent = (eventType: string): void => {
const injectedScript = document.querySelector(
'script[src="https://js.stripe.com/v3"]'
);
const injectedScript = document.querySelector(`script[src="${SCRIPT_SRC}"]`);

@@ -18,3 +18,3 @@ if (!injectedScript) {

const script = document.querySelector(
'script[src="https://js.stripe.com/v3"], script[src="https://js.stripe.com/v3/"]'
'script[src^="https://js.stripe.com/"]'
);

@@ -24,2 +24,3 @@ if (script && script.parentElement) {

}
delete window.Stripe;

@@ -32,10 +33,8 @@ jest.resetModules();

expect(
document.querySelector('script[src="https://js.stripe.com/v3"]')
).toBe(null);
expect(document.querySelector(`script[src="${SCRIPT_SRC}"]`)).toBe(null);
return Promise.resolve().then(() => {
expect(
document.querySelector('script[src="https://js.stripe.com/v3"]')
).not.toBe(null);
expect(document.querySelector(`script[src="${SCRIPT_SRC}"]`)).not.toBe(
null
);
});

@@ -50,5 +49,3 @@ });

return new Promise((resolve) => setTimeout(resolve)).then(() => {
expect(
document.querySelector('script[src="https://js.stripe.com/v3"]')
).toBe(null);
expect(document.querySelector(`script[src="${SCRIPT_SRC}"]`)).toBe(null);
});

@@ -58,17 +55,17 @@ });

describe('does not inject a duplicate script when one is already present', () => {
test('when the script does not have a trailing slash', () => {
require('./index');
if (RELEASE_TRAIN === 'v3') {
test('when the script does not have a trailing slash', () => {
require('./index');
const script = document.createElement('script');
script.src = 'https://js.stripe.com/v3';
document.body.appendChild(script);
const script = document.createElement('script');
script.src = 'https://js.stripe.com/v3';
document.body.appendChild(script);
return Promise.resolve().then(() => {
expect(
document.querySelectorAll(
'script[src="https://js.stripe.com/v3"], script[src="https://js.stripe.com/v3/"]'
)
).toHaveLength(1);
return Promise.resolve().then(() => {
expect(
document.querySelectorAll(`script[src="${SCRIPT_SRC}"]`)
).toHaveLength(1);
});
});
});
}

@@ -79,3 +76,3 @@ test('when the script has a trailing slash', () => {

const script = document.createElement('script');
script.src = 'https://js.stripe.com/v3/';
script.src = SCRIPT_SRC;
document.body.appendChild(script);

@@ -85,5 +82,3 @@

expect(
document.querySelectorAll(
'script[src="https://js.stripe.com/v3"], script[src="https://js.stripe.com/v3/"]'
)
document.querySelectorAll(`script[src="${SCRIPT_SRC}"]`)
).toHaveLength(1);

@@ -103,3 +98,3 @@ });

expect(
document.querySelectorAll('script[src^="https://js.stripe.com/v3"]')
document.querySelectorAll('script[src^="https://js.stripe.com"]')
).toHaveLength(2);

@@ -113,5 +108,5 @@

expect(
document.querySelector('script[src="https://js.stripe.com/v3"]')
).not.toBe(null);
expect(document.querySelector(`script[src="${SCRIPT_SRC}"]`)).not.toBe(
null
);
});

@@ -118,0 +113,0 @@ });

/* eslint-disable @typescript-eslint/no-var-requires */
import {RELEASE_TRAIN} from './shared';
const SCRIPT_SELECTOR = 'script[src^="https://js.stripe.com/v3"]';
const SCRIPT_SRC =
RELEASE_TRAIN === 'v3'
? `https://js.stripe.com/v3`
: `https://js.stripe.com/acacia/stripe.js`;
const SCRIPT_SELECTOR = `script[src^="${SCRIPT_SRC}"]`;

@@ -46,3 +51,3 @@ describe('pure module', () => {

document.querySelector(
'script[src^="https://js.stripe.com/v3?advancedFraudSignals=false"]'
`script[src^="${SCRIPT_SRC}?advancedFraudSignals=false"]`
)

@@ -62,3 +67,3 @@ ).not.toBe(null);

const script = document.createElement('script');
script.src = 'https://js.stripe.com/v3';
script.src = SCRIPT_SRC;
document.body.appendChild(script);

@@ -81,3 +86,3 @@

const script = document.createElement('script');
script.src = 'https://js.stripe.com/v3';
script.src = SCRIPT_SRC;
document.body.appendChild(script);

@@ -108,3 +113,3 @@

const script = document.createElement('script');
script.src = 'https://js.stripe.com/v3';
script.src = SCRIPT_SRC;
document.body.appendChild(script);

@@ -111,0 +116,0 @@

@@ -15,4 +15,13 @@ import {Stripe, StripeConstructor} from '../types';

export const RELEASE_TRAIN = 'v3';
const runtimeVersionToUrlVersion = (version: string | number) =>
version === 3 ? 'v3' : version;
const ORIGIN = 'https://js.stripe.com';
const STRIPE_JS_URL = `${ORIGIN}/v3`;
const STRIPE_JS_URL =
RELEASE_TRAIN === 'v3'
? `${ORIGIN}/v3`
: `${ORIGIN}/${RELEASE_TRAIN}/stripe.js`;
const V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;

@@ -166,2 +175,14 @@ const STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;

const pk = args[0];
const isTestKey = pk.match(/^pk_test/);
// @ts-expect-error this is not publicly typed
const version = runtimeVersionToUrlVersion(maybeStripe.version);
const expectedVersion = RELEASE_TRAIN;
if (isTestKey && version !== expectedVersion) {
console.warn(
`Stripe.js@${version} was loaded on the page, but @stripe/stripe-js@${_VERSION} expected Stripe.js@${expectedVersion}. This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning`
);
}
const stripe = maybeStripe.apply(undefined, args);

@@ -168,0 +189,0 @@ registerWrapper(stripe, startTime);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet