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

@datadog/browser-core

Package Overview
Dependencies
Maintainers
1
Versions
259
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 1.18.1 to 1.19.0

6

cjs/configuration.d.ts

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

import { CookieOptions } from './cookie';
import { BuildEnv, Datacenter } from './init';

@@ -49,2 +50,5 @@ export declare const DEFAULT_CONFIGURATION: {

version?: string;
useCrossSiteSessionCookie?: boolean;
useSecureSessionCookie?: boolean;
trackSessionAcrossSubdomains?: boolean;
replica?: ReplicaUserConfiguration;

@@ -60,2 +64,3 @@ internalMonitoringEndpoint?: string;

export declare type Configuration = typeof DEFAULT_CONFIGURATION & {
cookieOptions: CookieOptions;
logsEndpoint: string;

@@ -77,2 +82,3 @@ rumEndpoint: string;

export declare function isIntakeRequest(url: string, configuration: Configuration): boolean | undefined;
export declare function mustUseSecureCookie(userConfiguration: UserConfiguration): boolean;
export {};

12

cjs/configuration.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var cookie_1 = require("./cookie");
var init_1 = require("./init");

@@ -51,3 +52,3 @@ var urlPolyfill_1 = require("./urlPolyfill");

: [];
var configuration = tslib_1.__assign({ isEnabled: function (feature) {
var configuration = tslib_1.__assign({ cookieOptions: {}, isEnabled: function (feature) {
return utils_1.includes(enableExperimentalFeatures, feature);

@@ -73,2 +74,7 @@ }, logsEndpoint: getEndpoint('browser', transportConfiguration), proxyHost: userConfiguration.proxyHost, rumEndpoint: getEndpoint('rum', transportConfiguration), traceEndpoint: getEndpoint('public-trace', transportConfiguration) }, exports.DEFAULT_CONFIGURATION);

}
configuration.cookieOptions.secure = mustUseSecureCookie(userConfiguration);
configuration.cookieOptions.crossSite = !!userConfiguration.useCrossSiteSessionCookie;
if (!!userConfiguration.trackSessionAcrossSubdomains) {
configuration.cookieOptions.domain = cookie_1.getCurrentSite();
}
if (transportConfiguration.buildMode === init_1.BuildMode.E2E_TEST) {

@@ -123,2 +129,6 @@ if (userConfiguration.internalMonitoringEndpoint !== undefined) {

exports.isIntakeRequest = isIntakeRequest;
function mustUseSecureCookie(userConfiguration) {
return !!userConfiguration.useSecureSessionCookie || !!userConfiguration.useCrossSiteSessionCookie;
}
exports.mustUseSecureCookie = mustUseSecureCookie;
//# sourceMappingURL=configuration.js.map
export declare const COOKIE_ACCESS_DELAY = 1000;
export interface CookieOptions {
secure?: boolean;
crossSite?: boolean;
domain?: string;
}
export interface CookieCache {

@@ -6,5 +11,11 @@ get: () => string | undefined;

}
export declare function cacheCookieAccess(name: string): CookieCache;
export declare function setCookie(name: string, value: string, expireDelay: number): void;
export declare function cacheCookieAccess(name: string, options: CookieOptions): CookieCache;
export declare function setCookie(name: string, value: string, expireDelay: number, options?: CookieOptions): void;
export declare function getCookie(name: string): string | undefined;
export declare function areCookiesAuthorized(): boolean;
export declare function areCookiesAuthorized(useSecureCookie: boolean): boolean;
/**
* No API to retrieve it, number of levels for subdomain and suffix are unknown
* strategy: find the minimal domain on which cookies are allowed to be set
* https://web.dev/same-site-same-origin/#site
*/
export declare function getCurrentSite(): string | undefined;

36

cjs/cookie.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
exports.COOKIE_ACCESS_DELAY = 1000;
function cacheCookieAccess(name) {
exports.COOKIE_ACCESS_DELAY = utils_1.ONE_SECOND;
function cacheCookieAccess(name, options) {
var timeout;

@@ -26,3 +26,3 @@ var cache;

set: function (value, expireDelay) {
setCookie(name, value, expireDelay);
setCookie(name, value, expireDelay, options);
cache = value;

@@ -34,7 +34,10 @@ cacheAccess();

exports.cacheCookieAccess = cacheCookieAccess;
function setCookie(name, value, expireDelay) {
function setCookie(name, value, expireDelay, options) {
var date = new Date();
date.setTime(date.getTime() + expireDelay);
var expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/;samesite=strict";
var sameSite = options && options.crossSite ? 'none' : 'strict';
var domain = options && options.domain ? ";domain=" + options.domain : '';
var secure = options && options.secure ? ";secure" : '';
document.cookie = name + "=" + value + ";" + expires + ";path=/;samesite=" + sameSite + domain + secure;
}

@@ -46,3 +49,3 @@ exports.setCookie = setCookie;

exports.getCookie = getCookie;
function areCookiesAuthorized() {
function areCookiesAuthorized(useSecureCookie) {
if (document.cookie === undefined || document.cookie === null) {

@@ -52,5 +55,5 @@ return false;

try {
var testCookieName = 'dd_rum_test';
var testCookieName = 'dd_cookie_test';
var testCookieValue = 'test';
setCookie(testCookieName, testCookieValue, 1000);
setCookie(testCookieName, testCookieValue, utils_1.ONE_SECOND, { secure: useSecureCookie });
return getCookie(testCookieName) === testCookieValue;

@@ -64,2 +67,19 @@ }

exports.areCookiesAuthorized = areCookiesAuthorized;
/**
* No API to retrieve it, number of levels for subdomain and suffix are unknown
* strategy: find the minimal domain on which cookies are allowed to be set
* https://web.dev/same-site-same-origin/#site
*/
function getCurrentSite() {
var testCookieName = 'dd_site_test';
var testCookieValue = 'test';
var domainLevels = window.location.hostname.split('.');
var candidateDomain = domainLevels.pop();
while (domainLevels.length && !getCookie(testCookieName)) {
candidateDomain = domainLevels.pop() + "." + candidateDomain;
setCookie(testCookieName, testCookieValue, utils_1.ONE_SECOND, { domain: candidateDomain });
}
return candidateDomain;
}
exports.getCurrentSite = getCurrentSite;
//# sourceMappingURL=cookie.js.map

@@ -23,7 +23,5 @@ "use strict";

var errorObservable = new observable_1.Observable();
if (configuration.isCollectingError) {
trackNetworkError(configuration, errorObservable);
startConsoleTracking(errorObservable);
startRuntimeErrorTracking(errorObservable);
}
trackNetworkError(configuration, errorObservable);
startConsoleTracking(errorObservable);
startRuntimeErrorTracking(errorObservable);
filteredErrorsObservable = filterErrors(configuration, errorObservable);

@@ -30,0 +28,0 @@ }

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

export { DEFAULT_CONFIGURATION, Configuration, UserConfiguration, isIntakeRequest } from './configuration';
export { DEFAULT_CONFIGURATION, Configuration, UserConfiguration, isIntakeRequest, mustUseSecureCookie, } from './configuration';
export { ErrorMessage, ErrorContext, HttpContext, ErrorOrigin, ErrorObservable } from './errorCollection';

@@ -3,0 +3,0 @@ export { BuildEnv, BuildMode, Datacenter, makeStub, makeGlobal, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './init';

@@ -7,2 +7,3 @@ "use strict";

exports.isIntakeRequest = configuration_1.isIntakeRequest;
exports.mustUseSecureCookie = configuration_1.mustUseSecureCookie;
var errorCollection_1 = require("./errorCollection");

@@ -9,0 +10,0 @@ exports.ErrorOrigin = errorCollection_1.ErrorOrigin;

@@ -27,3 +27,3 @@ import { UserConfiguration } from './configuration';

};
export declare function checkCookiesAuthorized(): boolean;
export declare function checkCookiesAuthorized(useSecureCookie: boolean): boolean;
export declare function checkIsNotLocalFile(): boolean;

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

var internalMonitoring_1 = require("./internalMonitoring");
var observable_1 = require("./observable");
function makeStub(methodName) {

@@ -45,3 +46,5 @@ console.warn("'" + methodName + "' not yet available, please call '.init()' first.");

var internalMonitoring = internalMonitoring_1.startInternalMonitoring(configuration);
var errorObservable = errorCollection_1.startErrorCollection(configuration);
var errorObservable = configuration.isCollectingError
? errorCollection_1.startErrorCollection(configuration)
: new observable_1.Observable();
return {

@@ -54,4 +57,4 @@ configuration: configuration,

exports.commonInit = commonInit;
function checkCookiesAuthorized() {
if (!cookie_1.areCookiesAuthorized()) {
function checkCookiesAuthorized(useSecureCookie) {
if (!cookie_1.areCookiesAuthorized(useSecureCookie)) {
console.warn('Cookies are not authorized, we will not send any data.');

@@ -58,0 +61,0 @@ return false;

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

import { CookieCache } from './cookie';
import { CookieCache, CookieOptions } from './cookie';
import { Observable } from './observable';

@@ -21,3 +21,3 @@ export declare const SESSION_COOKIE_NAME = "_dd_s";

*/
export declare function startSessionManagement<TrackingType extends string>(productKey: string, computeSessionState: (rawTrackingType?: string) => {
export declare function startSessionManagement<TrackingType extends string>(options: CookieOptions, productKey: string, computeSessionState: (rawTrackingType?: string) => {
trackingType: TrackingType;

@@ -24,0 +24,0 @@ isTracked: boolean;

@@ -16,4 +16,4 @@ "use strict";

*/
function startSessionManagement(productKey, computeSessionState) {
var sessionCookie = cookie_1.cacheCookieAccess(exports.SESSION_COOKIE_NAME);
function startSessionManagement(options, productKey, computeSessionState) {
var sessionCookie = cookie_1.cacheCookieAccess(exports.SESSION_COOKIE_NAME, options);
oldCookiesMigration_1.tryOldCookiesMigration(sessionCookie);

@@ -20,0 +20,0 @@ var renewObservable = new observable_1.Observable();

@@ -14,3 +14,4 @@ export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

TOUCH_START = "touchstart",
VISIBILITY_CHANGE = "visibilitychange"
VISIBILITY_CHANGE = "visibilitychange",
DOM_CONTENT_LOADED = "DOMContentLoaded"
}

@@ -17,0 +18,0 @@ export declare enum ResourceKind {

@@ -18,2 +18,3 @@ "use strict";

DOM_EVENT["VISIBILITY_CHANGE"] = "visibilitychange";
DOM_EVENT["DOM_CONTENT_LOADED"] = "DOMContentLoaded";
})(DOM_EVENT = exports.DOM_EVENT || (exports.DOM_EVENT = {}));

@@ -20,0 +21,0 @@ var ResourceKind;

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

import { CookieOptions } from './cookie';
import { BuildEnv, Datacenter } from './init';

@@ -49,2 +50,5 @@ export declare const DEFAULT_CONFIGURATION: {

version?: string;
useCrossSiteSessionCookie?: boolean;
useSecureSessionCookie?: boolean;
trackSessionAcrossSubdomains?: boolean;
replica?: ReplicaUserConfiguration;

@@ -60,2 +64,3 @@ internalMonitoringEndpoint?: string;

export declare type Configuration = typeof DEFAULT_CONFIGURATION & {
cookieOptions: CookieOptions;
logsEndpoint: string;

@@ -77,2 +82,3 @@ rumEndpoint: string;

export declare function isIntakeRequest(url: string, configuration: Configuration): boolean | undefined;
export declare function mustUseSecureCookie(userConfiguration: UserConfiguration): boolean;
export {};
import { __assign } from "tslib";
import { getCurrentSite } from './cookie';
import { BuildMode, Datacenter, INTAKE_SITE } from './init';

@@ -49,3 +50,3 @@ import { haveSameOrigin } from './urlPolyfill';

: [];
var configuration = __assign({ isEnabled: function (feature) {
var configuration = __assign({ cookieOptions: {}, isEnabled: function (feature) {
return includes(enableExperimentalFeatures, feature);

@@ -71,2 +72,7 @@ }, logsEndpoint: getEndpoint('browser', transportConfiguration), proxyHost: userConfiguration.proxyHost, rumEndpoint: getEndpoint('rum', transportConfiguration), traceEndpoint: getEndpoint('public-trace', transportConfiguration) }, DEFAULT_CONFIGURATION);

}
configuration.cookieOptions.secure = mustUseSecureCookie(userConfiguration);
configuration.cookieOptions.crossSite = !!userConfiguration.useCrossSiteSessionCookie;
if (!!userConfiguration.trackSessionAcrossSubdomains) {
configuration.cookieOptions.domain = getCurrentSite();
}
if (transportConfiguration.buildMode === BuildMode.E2E_TEST) {

@@ -119,2 +125,5 @@ if (userConfiguration.internalMonitoringEndpoint !== undefined) {

}
export function mustUseSecureCookie(userConfiguration) {
return !!userConfiguration.useSecureSessionCookie || !!userConfiguration.useCrossSiteSessionCookie;
}
//# sourceMappingURL=configuration.js.map
export declare const COOKIE_ACCESS_DELAY = 1000;
export interface CookieOptions {
secure?: boolean;
crossSite?: boolean;
domain?: string;
}
export interface CookieCache {

@@ -6,5 +11,11 @@ get: () => string | undefined;

}
export declare function cacheCookieAccess(name: string): CookieCache;
export declare function setCookie(name: string, value: string, expireDelay: number): void;
export declare function cacheCookieAccess(name: string, options: CookieOptions): CookieCache;
export declare function setCookie(name: string, value: string, expireDelay: number, options?: CookieOptions): void;
export declare function getCookie(name: string): string | undefined;
export declare function areCookiesAuthorized(): boolean;
export declare function areCookiesAuthorized(useSecureCookie: boolean): boolean;
/**
* No API to retrieve it, number of levels for subdomain and suffix are unknown
* strategy: find the minimal domain on which cookies are allowed to be set
* https://web.dev/same-site-same-origin/#site
*/
export declare function getCurrentSite(): string | undefined;

@@ -1,4 +0,4 @@

import { findCommaSeparatedValue } from './utils';
export var COOKIE_ACCESS_DELAY = 1000;
export function cacheCookieAccess(name) {
import { findCommaSeparatedValue, ONE_SECOND } from './utils';
export var COOKIE_ACCESS_DELAY = ONE_SECOND;
export function cacheCookieAccess(name, options) {
var timeout;

@@ -24,3 +24,3 @@ var cache;

set: function (value, expireDelay) {
setCookie(name, value, expireDelay);
setCookie(name, value, expireDelay, options);
cache = value;

@@ -31,7 +31,10 @@ cacheAccess();

}
export function setCookie(name, value, expireDelay) {
export function setCookie(name, value, expireDelay, options) {
var date = new Date();
date.setTime(date.getTime() + expireDelay);
var expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/;samesite=strict";
var sameSite = options && options.crossSite ? 'none' : 'strict';
var domain = options && options.domain ? ";domain=" + options.domain : '';
var secure = options && options.secure ? ";secure" : '';
document.cookie = name + "=" + value + ";" + expires + ";path=/;samesite=" + sameSite + domain + secure;
}

@@ -41,3 +44,3 @@ export function getCookie(name) {

}
export function areCookiesAuthorized() {
export function areCookiesAuthorized(useSecureCookie) {
if (document.cookie === undefined || document.cookie === null) {

@@ -47,5 +50,5 @@ return false;

try {
var testCookieName = 'dd_rum_test';
var testCookieName = 'dd_cookie_test';
var testCookieValue = 'test';
setCookie(testCookieName, testCookieValue, 1000);
setCookie(testCookieName, testCookieValue, ONE_SECOND, { secure: useSecureCookie });
return getCookie(testCookieName) === testCookieValue;

@@ -58,2 +61,18 @@ }

}
/**
* No API to retrieve it, number of levels for subdomain and suffix are unknown
* strategy: find the minimal domain on which cookies are allowed to be set
* https://web.dev/same-site-same-origin/#site
*/
export function getCurrentSite() {
var testCookieName = 'dd_site_test';
var testCookieValue = 'test';
var domainLevels = window.location.hostname.split('.');
var candidateDomain = domainLevels.pop();
while (domainLevels.length && !getCookie(testCookieName)) {
candidateDomain = domainLevels.pop() + "." + candidateDomain;
setCookie(testCookieName, testCookieValue, ONE_SECOND, { domain: candidateDomain });
}
return candidateDomain;
}
//# sourceMappingURL=cookie.js.map

@@ -21,7 +21,5 @@ import { __spreadArrays } from "tslib";

var errorObservable = new Observable();
if (configuration.isCollectingError) {
trackNetworkError(configuration, errorObservable);
startConsoleTracking(errorObservable);
startRuntimeErrorTracking(errorObservable);
}
trackNetworkError(configuration, errorObservable);
startConsoleTracking(errorObservable);
startRuntimeErrorTracking(errorObservable);
filteredErrorsObservable = filterErrors(configuration, errorObservable);

@@ -28,0 +26,0 @@ }

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

export { DEFAULT_CONFIGURATION, Configuration, UserConfiguration, isIntakeRequest } from './configuration';
export { DEFAULT_CONFIGURATION, Configuration, UserConfiguration, isIntakeRequest, mustUseSecureCookie, } from './configuration';
export { ErrorMessage, ErrorContext, HttpContext, ErrorOrigin, ErrorObservable } from './errorCollection';

@@ -3,0 +3,0 @@ export { BuildEnv, BuildMode, Datacenter, makeStub, makeGlobal, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './init';

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

export { DEFAULT_CONFIGURATION, isIntakeRequest } from './configuration';
export { DEFAULT_CONFIGURATION, isIntakeRequest, mustUseSecureCookie, } from './configuration';
export { ErrorOrigin } from './errorCollection';

@@ -3,0 +3,0 @@ export { BuildMode, Datacenter, makeStub, makeGlobal, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './init';

@@ -27,3 +27,3 @@ import { UserConfiguration } from './configuration';

};
export declare function checkCookiesAuthorized(): boolean;
export declare function checkCookiesAuthorized(useSecureCookie: boolean): boolean;
export declare function checkIsNotLocalFile(): boolean;

@@ -7,2 +7,3 @@ var _a;

import { setDebugMode, startInternalMonitoring } from './internalMonitoring';
import { Observable } from './observable';
export function makeStub(methodName) {

@@ -41,3 +42,5 @@ console.warn("'" + methodName + "' not yet available, please call '.init()' first.");

var internalMonitoring = startInternalMonitoring(configuration);
var errorObservable = startErrorCollection(configuration);
var errorObservable = configuration.isCollectingError
? startErrorCollection(configuration)
: new Observable();
return {

@@ -49,4 +52,4 @@ configuration: configuration,

}
export function checkCookiesAuthorized() {
if (!areCookiesAuthorized()) {
export function checkCookiesAuthorized(useSecureCookie) {
if (!areCookiesAuthorized(useSecureCookie)) {
console.warn('Cookies are not authorized, we will not send any data.');

@@ -53,0 +56,0 @@ return false;

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

import { CookieCache } from './cookie';
import { CookieCache, CookieOptions } from './cookie';
import { Observable } from './observable';

@@ -21,3 +21,3 @@ export declare const SESSION_COOKIE_NAME = "_dd_s";

*/
export declare function startSessionManagement<TrackingType extends string>(productKey: string, computeSessionState: (rawTrackingType?: string) => {
export declare function startSessionManagement<TrackingType extends string>(options: CookieOptions, productKey: string, computeSessionState: (rawTrackingType?: string) => {
trackingType: TrackingType;

@@ -24,0 +24,0 @@ isTracked: boolean;

@@ -13,4 +13,4 @@ import { cacheCookieAccess, COOKIE_ACCESS_DELAY } from './cookie';

*/
export function startSessionManagement(productKey, computeSessionState) {
var sessionCookie = cacheCookieAccess(SESSION_COOKIE_NAME);
export function startSessionManagement(options, productKey, computeSessionState) {
var sessionCookie = cacheCookieAccess(SESSION_COOKIE_NAME, options);
tryOldCookiesMigration(sessionCookie);

@@ -17,0 +17,0 @@ var renewObservable = new Observable();

@@ -14,3 +14,4 @@ export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

TOUCH_START = "touchstart",
VISIBILITY_CHANGE = "visibilitychange"
VISIBILITY_CHANGE = "visibilitychange",
DOM_CONTENT_LOADED = "DOMContentLoaded"
}

@@ -17,0 +18,0 @@ export declare enum ResourceKind {

@@ -16,2 +16,3 @@ import { __assign, __spreadArrays } from "tslib";

DOM_EVENT["VISIBILITY_CHANGE"] = "visibilitychange";
DOM_EVENT["DOM_CONTENT_LOADED"] = "DOMContentLoaded";
})(DOM_EVENT || (DOM_EVENT = {}));

@@ -18,0 +19,0 @@ export var ResourceKind;

{
"name": "@datadog/browser-core",
"version": "1.18.1",
"version": "1.19.0",
"license": "Apache-2.0",

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

},
"gitHead": "bfb9ba782580bd09434d645f651f4fcce9978f72"
"gitHead": "abc4a0266e51c70c1642b755448d2b46946e53a3"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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