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

posthog-js

Package Overview
Dependencies
Maintainers
1
Versions
764
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

posthog-js - npm Package Compare versions

Comparing version

to
1.144.0

dist/lib/src/extensions/replay/external/denylist.d.ts

4

dist/lib/src/extensions/replay/config.d.ts
import { NetworkRecordOptions, PostHogConfig } from '../../types';
export declare const defaultNetworkOptions: NetworkRecordOptions;
export declare const defaultNetworkOptions: Required<NetworkRecordOptions>;
/**

@@ -9,2 +9,2 @@ * whether a maskRequestFn is provided or not,

*/
export declare const buildNetworkRequestOptions: (instanceConfig: PostHogConfig, remoteNetworkOptions: Pick<NetworkRecordOptions, 'recordHeaders' | 'recordBody' | 'recordPerformance'>) => NetworkRecordOptions;
export declare const buildNetworkRequestOptions: (instanceConfig: PostHogConfig, remoteNetworkOptions: Pick<NetworkRecordOptions, 'recordHeaders' | 'recordBody' | 'recordPerformance' | 'payloadHostDenyList'>) => NetworkRecordOptions;

@@ -381,2 +381,10 @@ import type { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';

payloadSizeLimitBytes: number;
/**
* some domains we should never record the payload
* for example other companies session replay ingestion payloads aren't super useful but are gigantic
* if this isn't provided we use a default list
* if this is provided - we add the provided list to the default list
* i.e. we never record the payloads on the default deny list
*/
payloadHostDenyList?: string[];
};

@@ -383,0 +391,0 @@ /** @deprecated - use CapturedNetworkRequest instead */

{
"name": "posthog-js",
"version": "1.143.0",
"version": "1.144.0",
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",

@@ -5,0 +5,0 @@ "repository": "https://github.com/PostHog/posthog-js",

@@ -67,3 +67,3 @@ var __assign = (this && this.__assign) || function () {

import { getRecordConsolePlugin } from 'rrweb/es/rrweb/packages/rrweb/src/plugins/console/record';
import { isArray, isBoolean, isDocument, isFormData, isNull, isNullish, isObject, isString, isUndefined, } from '../utils/type-utils';
import { isArray, isBoolean, isDocument, isFormData, isNull, isNullish, isObject, isString } from '../utils/type-utils';
import { logger } from '../utils/logger';

@@ -74,2 +74,3 @@ import { window } from '../utils/globals';

import { patch } from '../extensions/replay/rrweb-plugins/patch';
import { isHostOnDenyList } from '../extensions/replay/external/denylist';
var isNavigationTiming = function (entry) {

@@ -143,3 +144,4 @@ return entry.entryType === 'navigation';

}
function shouldRecordBody(type, recordBody, headers) {
function shouldRecordBody(_a) {
var type = _a.type, recordBody = _a.recordBody, headers = _a.headers;
function matchesContentType(contentTypes) {

@@ -196,6 +198,11 @@ var contentTypeHeader = Object.keys(headers).find(function (key) { return key.toLowerCase() === 'content-type'; });

*/
function _tryReadXHRBody(body) {
function _tryReadXHRBody(_a) {
var body = _a.body, options = _a.options, url = _a.url;
if (isNullish(body)) {
return null;
}
var _b = isHostOnDenyList(url, options), hostname = _b.hostname, isHostDenied = _b.isHostDenied;
if (isHostDenied) {
return hostname + ' is in deny list';
}
if (isString(body)) {

@@ -255,9 +262,9 @@ return body;

xhr.send = function (body) {
if (shouldRecordBody('request', options.recordBody, requestHeaders)) {
if (isUndefined(body) || isNull(body)) {
networkRequest.requestBody = null;
}
else {
networkRequest.requestBody = _tryReadXHRBody(body);
}
if (shouldRecordBody({
type: 'request',
headers: requestHeaders,
url: url,
recordBody: options.recordBody,
})) {
networkRequest.requestBody = _tryReadXHRBody({ body: body, options: options, url: url });
}

@@ -286,10 +293,9 @@ after = win.performance.now();

}
if (shouldRecordBody('response', options.recordBody, responseHeaders)) {
if (isNullish(xhr.response)) {
networkRequest.responseBody = null;
}
else {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
networkRequest.responseBody = _tryReadXHRBody(xhr.response);
}
if (shouldRecordBody({
type: 'response',
headers: responseHeaders,
url: url,
recordBody: options.recordBody,
})) {
networkRequest.responseBody = _tryReadXHRBody({ body: xhr.response, options: options, url: url });
}

@@ -366,4 +372,5 @@ getRequestPerformanceEntry(win, 'xmlhttprequest', req.url, after, before)

var contentTypePrefixDenyList = ['video/', 'audio/'];
function _checkForCannotReadResponseBody(r) {
var _a;
function _checkForCannotReadResponseBody(_a) {
var _b;
var r = _a.r, options = _a.options, url = _a.url;
if (r.headers.get('Transfer-Encoding') === 'chunked') {

@@ -374,3 +381,3 @@ return 'Chunked Transfer-Encoding is not supported';

// but return the header value with the casing that was supplied
var contentType = (_a = r.headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
var contentType = (_b = r.headers.get('Content-Type')) === null || _b === void 0 ? void 0 : _b.toLowerCase();
var contentTypeIsDenied = contentTypePrefixDenyList.some(function (prefix) { return contentType === null || contentType === void 0 ? void 0 : contentType.startsWith(prefix); });

@@ -380,2 +387,6 @@ if (contentType && contentTypeIsDenied) {

}
var _c = isHostOnDenyList(url, options), hostname = _c.hostname, isHostDenied = _c.isHostDenied;
if (isHostDenied) {
return hostname + ' is in deny list';
}
return null;

@@ -394,7 +405,21 @@ }

}
function _tryReadResponseBody(r) {
function _tryReadRequestBody(_a) {
var r = _a.r, options = _a.options, url = _a.url;
return __awaiter(this, void 0, void 0, function () {
var _b, hostname, isHostDenied;
return __generator(this, function (_c) {
_b = isHostOnDenyList(url, options), hostname = _b.hostname, isHostDenied = _b.isHostDenied;
if (isHostDenied) {
return [2 /*return*/, Promise.resolve(hostname + ' is in deny list')];
}
return [2 /*return*/, _tryReadBody(r)];
});
});
}
function _tryReadResponseBody(_a) {
var r = _a.r, options = _a.options, url = _a.url;
return __awaiter(this, void 0, void 0, function () {
var cannotReadBodyReason;
return __generator(this, function (_a) {
cannotReadBodyReason = _checkForCannotReadResponseBody(r);
return __generator(this, function (_b) {
cannotReadBodyReason = _checkForCannotReadResponseBody({ r: r, options: options, url: url });
if (!isNull(cannotReadBodyReason)) {

@@ -436,5 +461,10 @@ return [2 /*return*/, Promise.resolve(cannotReadBodyReason)];

}
if (!shouldRecordBody('request', options.recordBody, requestHeaders_1)) return [3 /*break*/, 3];
if (!shouldRecordBody({
type: 'request',
headers: requestHeaders_1,
url: url,
recordBody: options.recordBody,
})) return [3 /*break*/, 3];
_a = networkRequest;
return [4 /*yield*/, _tryReadBody(req)];
return [4 /*yield*/, _tryReadRequestBody({ r: req, options: options, url: url })];
case 2:

@@ -456,5 +486,10 @@ _a.requestBody = _c.sent();

}
if (!shouldRecordBody('response', options.recordBody, responseHeaders_1)) return [3 /*break*/, 6];
if (!shouldRecordBody({
type: 'response',
headers: responseHeaders_1,
url: url,
recordBody: options.recordBody,
})) return [3 /*break*/, 6];
_b = networkRequest;
return [4 /*yield*/, _tryReadResponseBody(res)];
return [4 /*yield*/, _tryReadResponseBody({ r: res, options: options, url: url })];
case 5:

@@ -461,0 +496,0 @@ _b.responseBody = _c.sent();

import { NetworkRecordOptions, PostHogConfig } from '../../types';
export declare const defaultNetworkOptions: NetworkRecordOptions;
export declare const defaultNetworkOptions: Required<NetworkRecordOptions>;
/**

@@ -9,2 +9,2 @@ * whether a maskRequestFn is provided or not,

*/
export declare const buildNetworkRequestOptions: (instanceConfig: PostHogConfig, remoteNetworkOptions: Pick<NetworkRecordOptions, 'recordHeaders' | 'recordBody' | 'recordPerformance'>) => NetworkRecordOptions;
export declare const buildNetworkRequestOptions: (instanceConfig: PostHogConfig, remoteNetworkOptions: Pick<NetworkRecordOptions, 'recordHeaders' | 'recordBody' | 'recordPerformance' | 'payloadHostDenyList'>) => NetworkRecordOptions;

@@ -83,2 +83,3 @@ var __assign = (this && this.__assign) || function () {

payloadSizeLimitBytes: 1000000,
payloadHostDenyList: ['.lr-ingest.io', '.ingest.sentry.io'],
};

@@ -199,2 +200,3 @@ var HEADER_DENY_LIST = [

performanceEntryTypeToObserve: __spreadArray([], __read(defaultNetworkOptions.performanceEntryTypeToObserve), false),
payloadHostDenyList: __spreadArray(__spreadArray([], __read((remoteNetworkOptions.payloadHostDenyList || [])), false), __read(defaultNetworkOptions.payloadHostDenyList), false),
};

@@ -201,0 +203,0 @@ // client can always disable despite remote options

@@ -381,2 +381,10 @@ import type { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';

payloadSizeLimitBytes: number;
/**
* some domains we should never record the payload
* for example other companies session replay ingestion payloads aren't super useful but are gigantic
* if this isn't provided we use a default list
* if this is provided - we add the provided list to the default list
* i.e. we never record the payloads on the default deny list
*/
payloadHostDenyList?: string[];
};

@@ -383,0 +391,0 @@ /** @deprecated - use CapturedNetworkRequest instead */

{
"name": "posthog-js",
"version": "1.143.0",
"version": "1.144.0",
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",

@@ -5,0 +5,0 @@ "repository": "https://github.com/PostHog/posthog-js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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