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

@paypal/sdk-client

Package Overview
Dependencies
Maintainers
22
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paypal/sdk-client - npm Package Compare versions

Comparing version

to
4.0.196

2

package.json
{
"name": "@paypal/sdk-client",
"version": "4.0.195",
"version": "4.0.196",
"description": "Shared config between PayPal/Braintree.",

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

@@ -83,1 +83,15 @@ /* @flow */

}
export function isPayPalTrustedUrl(href: string): boolean {
try {
// eslint-disable-next-line compat/compat
const url = new URL(href);
const domain = url.origin;
return (
Boolean(domain.match(getPayPalDomainRegex())) ||
Boolean(domain.match(getVenmoDomainRegex()))
);
} catch (err) {
return false;
}
}
/* @flow */
import { ENV } from "@paypal/sdk-constants/src";
import { describe, it, expect } from "vitest";
import {
describe,
it,
expect,
beforeEach,
afterEach,
beforeAll,
afterAll,
} from "vitest";

@@ -11,5 +19,14 @@ import {

isPayPalTrustedDomain,
isPayPalTrustedUrl,
} from "./domains";
describe(`domains test`, () => {
let env;
beforeEach(() => {
env = window.__ENV__;
});
afterEach(() => {
window.__ENV__ = env;
});
it("should successfully match valid paypal domain", () => {

@@ -108,1 +125,55 @@ const validDomains = [

});
describe(`isPayPalTrustedUrl test`, () => {
let env;
beforeAll(() => {
env = window.__ENV__;
window.__ENV__ = "production";
});
afterAll(() => {
window.__ENV__ = env;
});
const validUrls = [
"https://master.qa.paypal.com/abc/abc",
"https://master.qa.paypal.com",
"https://test-env.qa.paypal.com:3000/abc",
"https://geo.qa.paypal.com/abc",
"https://www.paypal.com:3080/abc",
"https://www.paypal.cn/abc",
"https://www.paypal.cn:3000/abc",
"https://www.mschina.qa.paypal.cn/abc",
"https://www.paypal.com/abc",
"https://www.paypal.com",
"https://venmo.com/abc",
"http://www.venmo.com",
"http://www.venmo.com/abc",
"https://id.venmo.com",
"http://www.venmo.com:8000",
"https://account.qa.venmo.com",
"http://www.account.qa.venmo.com",
"https://account.qa.venmo.com",
"https://account.venmo.com",
];
validUrls.forEach((url) => {
it(`isPayPalTrustedUrl(${url}) should be true`, () => {
const result = isPayPalTrustedUrl(url);
expect(result).toBe(true);
});
});
const unknownUrls = [
"https://www.paypal.com.example.com",
"https://www.paypal.cn.example.com",
"",
"---",
];
unknownUrls.forEach((url) => {
it(`isPayPalTrustedUrl(${url}) should be false`, () => {
const result = isPayPalTrustedUrl(url);
expect(result).toBe(false);
});
});
});