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

@datadog/browser-core

Package Overview
Dependencies
Maintainers
1
Versions
258
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-core - npm Package Compare versions

Comparing version 4.7.1 to 4.8.0

2

cjs/boot/init.js

@@ -9,3 +9,3 @@ "use strict";

var publicApi = (0, utils_1.assign)({
version: "4.7.1",
version: "4.8.0",
// This API method is intentionally not monitored, since the only thing executed is the

@@ -12,0 +12,0 @@ // user-provided 'callback'. All SDK usages executed in the callback should be monitored, and

@@ -28,5 +28,5 @@ "use strict";

var parameters = "ddsource=".concat(source || 'browser') +
"&ddtags=".concat(encodeURIComponent(["sdk_version:".concat("4.7.1")].concat(tags).join(','))) +
"&ddtags=".concat(encodeURIComponent(["sdk_version:".concat("4.8.0")].concat(tags).join(','))) +
"&dd-api-key=".concat(clientToken) +
"&dd-evp-origin-version=".concat(encodeURIComponent("4.7.1")) +
"&dd-evp-origin-version=".concat(encodeURIComponent("4.8.0")) +
'&dd-evp-origin=browser' +

@@ -33,0 +33,0 @@ "&dd-request-id=".concat((0, utils_1.generateUUID)());

@@ -36,3 +36,3 @@ "use strict";

service: 'browser-sdk',
version: "4.7.1",
version: "4.8.0",
source: 'browser',

@@ -39,0 +39,0 @@ _dd: {

@@ -12,2 +12,2 @@ export interface BrowserWindowWithEventBridge extends Window {

} | undefined;
export declare function canUseEventBridge(): boolean;
export declare function canUseEventBridge(hostname?: string): boolean;

@@ -20,5 +20,12 @@ "use strict";

exports.getEventBridge = getEventBridge;
function canUseEventBridge() {
function canUseEventBridge(hostname) {
var _a;
if (hostname === void 0) { hostname = (_a = (0, __1.getGlobalObject)().location) === null || _a === void 0 ? void 0 : _a.hostname; }
var bridge = getEventBridge();
return !!bridge && (0, __1.includes)(bridge.getAllowedWebViewHosts(), window.location.hostname);
return (!!bridge &&
bridge.getAllowedWebViewHosts().some(function (host) {
var escapedHost = host.replace(/\./g, '\\.');
var isDomainOrSubDomain = new RegExp("^(.+\\.)*".concat(escapedHost, "$"));
return isDomainOrSubDomain.test(hostname);
}));
}

@@ -25,0 +32,0 @@ exports.canUseEventBridge = canUseEventBridge;

@@ -6,3 +6,3 @@ import { setDebugMode } from '../domain/internalMonitoring';

var publicApi = assign({
version: "4.7.1",
version: "4.8.0",
// This API method is intentionally not monitored, since the only thing executed is the

@@ -9,0 +9,0 @@ // user-provided 'callback'. All SDK usages executed in the callback should be monitored, and

@@ -25,5 +25,5 @@ import { timeStampNow } from '../../tools/timeUtils';

var parameters = "ddsource=".concat(source || 'browser') +
"&ddtags=".concat(encodeURIComponent(["sdk_version:".concat("4.7.1")].concat(tags).join(','))) +
"&ddtags=".concat(encodeURIComponent(["sdk_version:".concat("4.8.0")].concat(tags).join(','))) +
"&dd-api-key=".concat(clientToken) +
"&dd-evp-origin-version=".concat(encodeURIComponent("4.7.1")) +
"&dd-evp-origin-version=".concat(encodeURIComponent("4.8.0")) +
'&dd-evp-origin=browser' +

@@ -30,0 +30,0 @@ "&dd-request-id=".concat(generateUUID());

@@ -33,3 +33,3 @@ import { display } from '../../tools/display';

service: 'browser-sdk',
version: "4.7.1",
version: "4.8.0",
source: 'browser',

@@ -36,0 +36,0 @@ _dd: {

@@ -12,2 +12,2 @@ export interface BrowserWindowWithEventBridge extends Window {

} | undefined;
export declare function canUseEventBridge(): boolean;
export declare function canUseEventBridge(hostname?: string): boolean;

@@ -1,2 +0,2 @@

import { getGlobalObject, includes } from '..';
import { getGlobalObject } from '..';
export function getEventBridge() {

@@ -16,5 +16,12 @@ var eventBridgeGlobal = getEventBridgeGlobal();

}
export function canUseEventBridge() {
export function canUseEventBridge(hostname) {
var _a;
if (hostname === void 0) { hostname = (_a = getGlobalObject().location) === null || _a === void 0 ? void 0 : _a.hostname; }
var bridge = getEventBridge();
return !!bridge && includes(bridge.getAllowedWebViewHosts(), window.location.hostname);
return (!!bridge &&
bridge.getAllowedWebViewHosts().some(function (host) {
var escapedHost = host.replace(/\./g, '\\.');
var isDomainOrSubDomain = new RegExp("^(.+\\.)*".concat(escapedHost, "$"));
return isDomainOrSubDomain.test(hostname);
}));
}

@@ -21,0 +28,0 @@ function getEventBridgeGlobal() {

{
"name": "@datadog/browser-core",
"version": "4.7.1",
"version": "4.8.0",
"license": "Apache-2.0",

@@ -24,3 +24,3 @@ "main": "cjs/index.js",

},
"gitHead": "d1c75e113a58ada996e860461dbab2e3847babd4"
"gitHead": "fad7cf72b9ba324be381286f266f421b0e06b9f3"
}

@@ -12,12 +12,22 @@ import { deleteEventBridgeStub, initEventBridgeStub } from '../../test/specHelper'

it('should detect when the bridge is present and the webView host is allowed', () => {
initEventBridgeStub()
expect(canUseEventBridge()).toBeTrue()
initEventBridgeStub(allowedWebViewHosts)
expect(canUseEventBridge('foo.bar')).toBeTrue()
expect(canUseEventBridge('baz.foo.bar')).toBeTrue()
expect(canUseEventBridge('www.foo.bar')).toBeTrue()
expect(canUseEventBridge('www.qux.foo.bar')).toBeTrue()
})
it('should not detect when the bridge is absent', () => {
expect(canUseEventBridge()).toBeFalse()
it('should not detect when the bridge is present and the webView host is not allowed', () => {
initEventBridgeStub(allowedWebViewHosts)
expect(canUseEventBridge('foo.com')).toBeFalse()
expect(canUseEventBridge('foo.bar.baz')).toBeFalse()
expect(canUseEventBridge('bazfoo.bar')).toBeFalse()
})
it('should not detect when the bridge is present and the webView host is not allowed', () => {
initEventBridgeStub(allowedWebViewHosts)
it('should not detect when the bridge on the parent domain if only the subdomain is allowed', () => {
initEventBridgeStub(['baz.foo.bar'])
expect(canUseEventBridge('foo.bar')).toBeFalse()
})
it('should not detect when the bridge is absent', () => {
expect(canUseEventBridge()).toBeFalse()

@@ -24,0 +34,0 @@ })

@@ -1,2 +0,2 @@

import { getGlobalObject, includes } from '..'
import { getGlobalObject } from '..'

@@ -29,6 +29,12 @@ export interface BrowserWindowWithEventBridge extends Window {

export function canUseEventBridge(): boolean {
export function canUseEventBridge(hostname = getGlobalObject<Window>().location?.hostname): boolean {
const bridge = getEventBridge()
return !!bridge && includes(bridge.getAllowedWebViewHosts(), window.location.hostname)
return (
!!bridge &&
bridge.getAllowedWebViewHosts().some((host) => {
const escapedHost = host.replace(/\./g, '\\.')
const isDomainOrSubDomain = new RegExp(`^(.+\\.)*${escapedHost}$`)
return isDomainOrSubDomain.test(hostname)
})
)
}

@@ -35,0 +41,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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