@posthog/core 1.69.1 → 1.69.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/featureFlagUtils.d.ts.map +1 -1
- package/dist/featureFlagUtils.js +2 -1
- package/dist/featureFlagUtils.mjs +2 -1
- package/dist/gzip.d.ts +2 -0
- package/dist/gzip.d.ts.map +1 -1
- package/dist/gzip.js +17 -1
- package/dist/gzip.mjs +15 -2
- package/package.json +2 -2
- package/src/featureFlagUtils.ts +3 -0
- package/src/gzip.ts +21 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"featureFlagUtils.d.ts","sourceRoot":"","sources":["../src/featureFlagUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAEhB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EAEtB,mBAAmB,EACnB,2BAA2B,EAC5B,MAAM,SAAS,CAAA;AAEhB,eAAO,MAAM,sBAAsB,kBAE7B,mBAAmB,CAAC,sBAAsB,EAAE,OAAO,CAAC,GACpD,mBAAmB,CAAC,sBAAsB,EAAE,cAAc,GAAG,qBAAqB,CAAC,KACtF,2BAgCF,CAAA;AAqBD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,UAAW,oBAAoB,CAAC,OAAO,CAAC,KAAG,oBAAoB,CAAC,cAAc,CAMhH,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,UACxB,oBAAoB,CAAC,OAAO,CAAC,KACnC,oBAAoB,CAAC,qBAAqB,CAa5C,CAAA;AAED,eAAO,MAAM,mBAAmB,WAAY,iBAAiB,GAAG,SAAS,KAAG,gBAAgB,GAAG,SAE9F,CAAA;AAED,eAAO,MAAM,YAAY,aAAc,GAAG,KAAG,GAU5C,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,uCAAuC,iBACpC,sBAAsB,CAAC,cAAc,CAAC,uBAC/B,sBAA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AAM,EAAE,GAAG,CAAC,kBAChB,SAAS,MAAM,EAAE,KAC/B,MAAM,CAAC,MAAM,EAAE,GAAG,CAUpB,CAAA"}
|
package/dist/featureFlagUtils.js
CHANGED
|
@@ -188,7 +188,8 @@ const MINIMAL_FLAG_CALLED_EVENT_PROPERTIES = [
|
|
|
188
188
|
'$lib',
|
|
189
189
|
'$lib_version',
|
|
190
190
|
'$device_id',
|
|
191
|
-
'$is_server'
|
|
191
|
+
'$is_server',
|
|
192
|
+
'$release_id'
|
|
192
193
|
];
|
|
193
194
|
const minimizeFlagCalledEventProperties = (properties, transportKeys = [])=>{
|
|
194
195
|
const minimal = {};
|
|
@@ -159,7 +159,8 @@ const MINIMAL_FLAG_CALLED_EVENT_PROPERTIES = [
|
|
|
159
159
|
'$lib',
|
|
160
160
|
'$lib_version',
|
|
161
161
|
'$device_id',
|
|
162
|
-
'$is_server'
|
|
162
|
+
'$is_server',
|
|
163
|
+
'$release_id'
|
|
163
164
|
];
|
|
164
165
|
const minimizeFlagCalledEventProperties = (properties, transportKeys = [])=>{
|
|
165
166
|
const minimal = {};
|
package/dist/gzip.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export declare const isGzipData: (body: unknown) => boolean;
|
|
|
7
7
|
export declare const isGzipRequest: (compression?: unknown, urlCompression?: unknown) => boolean;
|
|
8
8
|
export declare const isNativeAsyncGzipReadError: (error: unknown) => boolean;
|
|
9
9
|
export declare const isNativeAsyncGzipError: (error: unknown) => boolean;
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare const __resetNativeGzipTrustForTests: () => void;
|
|
10
12
|
export type GzipCompressOptions = {
|
|
11
13
|
/**
|
|
12
14
|
* By default this helper swallows compression errors and returns null.
|
package/dist/gzip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gzip.d.ts","sourceRoot":"","sources":["../src/gzip.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAOzC;AAWD,eAAO,MAAM,UAAU,SAAU,OAAO,KAAG,OAU1C,CAAA;AAED,eAAO,MAAM,aAAa,iBAAkB,OAAO,mBAAmB,OAAO,KAAG,OAE/E,CAAA;AAED,eAAO,MAAM,0BAA0B,UAAW,OAAO,KAAG,OAQ3D,CAAA;AAED,eAAO,MAAM,sBAAsB,UAAW,OAAO,KAAG,OAQvD,CAAA;
|
|
1
|
+
{"version":3,"file":"gzip.d.ts","sourceRoot":"","sources":["../src/gzip.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAOzC;AAWD,eAAO,MAAM,UAAU,SAAU,OAAO,KAAG,OAU1C,CAAA;AAED,eAAO,MAAM,aAAa,iBAAkB,OAAO,mBAAmB,OAAO,KAAG,OAE/E,CAAA;AAED,eAAO,MAAM,0BAA0B,UAAW,OAAO,KAAG,OAQ3D,CAAA;AAED,eAAO,MAAM,sBAAsB,UAAW,OAAO,KAAG,OAQvD,CAAA;AA0CD,gBAAgB;AAChB,eAAO,MAAM,8BAA8B,QAAO,IAGjD,CAAA;AA2BD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,UAAO,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAgCrH"}
|
package/dist/gzip.js
CHANGED
|
@@ -28,6 +28,7 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
__resetNativeGzipTrustForTests: ()=>__resetNativeGzipTrustForTests,
|
|
31
32
|
gzipCompress: ()=>gzipCompress,
|
|
32
33
|
isGzipData: ()=>isGzipData,
|
|
33
34
|
isGzipRequest: ()=>isGzipRequest,
|
|
@@ -81,14 +82,27 @@ const crc32 = (bytes)=>{
|
|
|
81
82
|
const throwNativeGzipValidationError = (reason)=>{
|
|
82
83
|
throw (0, index_js_namespaceObject.createNamedError)(NATIVE_GZIP_VALIDATION_ERROR, `Native gzip produced invalid output: ${reason}`);
|
|
83
84
|
};
|
|
85
|
+
const CRC_VALIDATED_COMPRESSIONS_BEFORE_TRUST = 3;
|
|
86
|
+
let crcValidatedCompressions = 0;
|
|
87
|
+
let crcMismatchSeen = false;
|
|
88
|
+
const __resetNativeGzipTrustForTests = ()=>{
|
|
89
|
+
crcValidatedCompressions = 0;
|
|
90
|
+
crcMismatchSeen = false;
|
|
91
|
+
};
|
|
84
92
|
const validateNativeGzip = async (compressed, inputBytes)=>{
|
|
85
93
|
if (compressed.size < 18) throwNativeGzipValidationError('too-short');
|
|
86
94
|
const header = new Uint8Array(await compressed.slice(0, 10).arrayBuffer());
|
|
87
95
|
if (!hasGzipMagic(header) || header[2] !== GZIP_DEFLATE_METHOD) throwNativeGzipValidationError('invalid-header');
|
|
88
96
|
const trailer = new DataView(await compressed.slice(compressed.size - 8).arrayBuffer());
|
|
89
|
-
if (trailer.getUint32(0, true) !== crc32(inputBytes)) throwNativeGzipValidationError('invalid-crc');
|
|
90
97
|
const inputSize = inputBytes.length >>> 0;
|
|
91
98
|
if (trailer.getUint32(4, true) !== inputSize) throwNativeGzipValidationError('invalid-size');
|
|
99
|
+
if (crcMismatchSeen || crcValidatedCompressions < CRC_VALIDATED_COMPRESSIONS_BEFORE_TRUST) {
|
|
100
|
+
if (trailer.getUint32(0, true) !== crc32(inputBytes)) {
|
|
101
|
+
crcMismatchSeen = true;
|
|
102
|
+
throwNativeGzipValidationError('invalid-crc');
|
|
103
|
+
}
|
|
104
|
+
crcValidatedCompressions++;
|
|
105
|
+
}
|
|
92
106
|
};
|
|
93
107
|
async function gzipCompress(input, isDebug = true, options) {
|
|
94
108
|
try {
|
|
@@ -114,6 +128,7 @@ async function gzipCompress(input, isDebug = true, options) {
|
|
|
114
128
|
return null;
|
|
115
129
|
}
|
|
116
130
|
}
|
|
131
|
+
exports.__resetNativeGzipTrustForTests = __webpack_exports__.__resetNativeGzipTrustForTests;
|
|
117
132
|
exports.gzipCompress = __webpack_exports__.gzipCompress;
|
|
118
133
|
exports.isGzipData = __webpack_exports__.isGzipData;
|
|
119
134
|
exports.isGzipRequest = __webpack_exports__.isGzipRequest;
|
|
@@ -121,6 +136,7 @@ exports.isGzipSupported = __webpack_exports__.isGzipSupported;
|
|
|
121
136
|
exports.isNativeAsyncGzipError = __webpack_exports__.isNativeAsyncGzipError;
|
|
122
137
|
exports.isNativeAsyncGzipReadError = __webpack_exports__.isNativeAsyncGzipReadError;
|
|
123
138
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
139
|
+
"__resetNativeGzipTrustForTests",
|
|
124
140
|
"gzipCompress",
|
|
125
141
|
"isGzipData",
|
|
126
142
|
"isGzipRequest",
|
package/dist/gzip.mjs
CHANGED
|
@@ -44,14 +44,27 @@ const crc32 = (bytes)=>{
|
|
|
44
44
|
const throwNativeGzipValidationError = (reason)=>{
|
|
45
45
|
throw createNamedError(NATIVE_GZIP_VALIDATION_ERROR, `Native gzip produced invalid output: ${reason}`);
|
|
46
46
|
};
|
|
47
|
+
const CRC_VALIDATED_COMPRESSIONS_BEFORE_TRUST = 3;
|
|
48
|
+
let crcValidatedCompressions = 0;
|
|
49
|
+
let crcMismatchSeen = false;
|
|
50
|
+
const __resetNativeGzipTrustForTests = ()=>{
|
|
51
|
+
crcValidatedCompressions = 0;
|
|
52
|
+
crcMismatchSeen = false;
|
|
53
|
+
};
|
|
47
54
|
const validateNativeGzip = async (compressed, inputBytes)=>{
|
|
48
55
|
if (compressed.size < 18) throwNativeGzipValidationError('too-short');
|
|
49
56
|
const header = new Uint8Array(await compressed.slice(0, 10).arrayBuffer());
|
|
50
57
|
if (!hasGzipMagic(header) || header[2] !== GZIP_DEFLATE_METHOD) throwNativeGzipValidationError('invalid-header');
|
|
51
58
|
const trailer = new DataView(await compressed.slice(compressed.size - 8).arrayBuffer());
|
|
52
|
-
if (trailer.getUint32(0, true) !== crc32(inputBytes)) throwNativeGzipValidationError('invalid-crc');
|
|
53
59
|
const inputSize = inputBytes.length >>> 0;
|
|
54
60
|
if (trailer.getUint32(4, true) !== inputSize) throwNativeGzipValidationError('invalid-size');
|
|
61
|
+
if (crcMismatchSeen || crcValidatedCompressions < CRC_VALIDATED_COMPRESSIONS_BEFORE_TRUST) {
|
|
62
|
+
if (trailer.getUint32(0, true) !== crc32(inputBytes)) {
|
|
63
|
+
crcMismatchSeen = true;
|
|
64
|
+
throwNativeGzipValidationError('invalid-crc');
|
|
65
|
+
}
|
|
66
|
+
crcValidatedCompressions++;
|
|
67
|
+
}
|
|
55
68
|
};
|
|
56
69
|
async function gzipCompress(input, isDebug = true, options) {
|
|
57
70
|
try {
|
|
@@ -77,4 +90,4 @@ async function gzipCompress(input, isDebug = true, options) {
|
|
|
77
90
|
return null;
|
|
78
91
|
}
|
|
79
92
|
}
|
|
80
|
-
export { gzipCompress, isGzipData, isGzipRequest, isGzipSupported, isNativeAsyncGzipError, isNativeAsyncGzipReadError };
|
|
93
|
+
export { __resetNativeGzipTrustForTests, gzipCompress, isGzipData, isGzipRequest, isGzipSupported, isNativeAsyncGzipError, isNativeAsyncGzipReadError };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/core",
|
|
3
|
-
"version": "1.69.
|
|
3
|
+
"version": "1.69.3",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@posthog/types": "^1.
|
|
75
|
+
"@posthog/types": "^1.428.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@rslib/core": "0.23.2",
|
package/src/featureFlagUtils.ts
CHANGED
|
@@ -258,6 +258,9 @@ export const MINIMAL_FLAG_CALLED_EVENT_PROPERTIES: readonly string[] = [
|
|
|
258
258
|
'$lib_version',
|
|
259
259
|
'$device_id',
|
|
260
260
|
'$is_server',
|
|
261
|
+
// A release id is static and low-cardinality for the lifetime of a process, so a minimized
|
|
262
|
+
// event keeps the release the read happened on. Inert on SDKs that never stamp it.
|
|
263
|
+
'$release_id',
|
|
261
264
|
]
|
|
262
265
|
|
|
263
266
|
/**
|
package/src/gzip.ts
CHANGED
|
@@ -92,6 +92,19 @@ const throwNativeGzipValidationError = (reason: NativeGzipValidationReason): nev
|
|
|
92
92
|
throw createNamedError(NATIVE_GZIP_VALIDATION_ERROR, `Native gzip produced invalid output: ${reason}`)
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// The CRC pass is linear JS over the whole input on the main thread, so once native gzip has
|
|
96
|
+
// proven itself in this runtime we keep only the cheap header and size checks, unless it has
|
|
97
|
+
// ever produced a bad CRC.
|
|
98
|
+
const CRC_VALIDATED_COMPRESSIONS_BEFORE_TRUST = 3
|
|
99
|
+
let crcValidatedCompressions = 0
|
|
100
|
+
let crcMismatchSeen = false
|
|
101
|
+
|
|
102
|
+
/** @internal */
|
|
103
|
+
export const __resetNativeGzipTrustForTests = (): void => {
|
|
104
|
+
crcValidatedCompressions = 0
|
|
105
|
+
crcMismatchSeen = false
|
|
106
|
+
}
|
|
107
|
+
|
|
95
108
|
const validateNativeGzip = async (compressed: Blob, inputBytes: Uint8Array): Promise<void> => {
|
|
96
109
|
if (compressed.size < 18) {
|
|
97
110
|
throwNativeGzipValidationError('too-short')
|
|
@@ -103,14 +116,18 @@ const validateNativeGzip = async (compressed: Blob, inputBytes: Uint8Array): Pro
|
|
|
103
116
|
}
|
|
104
117
|
|
|
105
118
|
const trailer = new DataView(await compressed.slice(compressed.size - 8).arrayBuffer())
|
|
106
|
-
if (trailer.getUint32(0, true) !== crc32(inputBytes)) {
|
|
107
|
-
throwNativeGzipValidationError('invalid-crc')
|
|
108
|
-
}
|
|
109
|
-
|
|
110
119
|
const inputSize = inputBytes.length >>> 0
|
|
111
120
|
if (trailer.getUint32(4, true) !== inputSize) {
|
|
112
121
|
throwNativeGzipValidationError('invalid-size')
|
|
113
122
|
}
|
|
123
|
+
|
|
124
|
+
if (crcMismatchSeen || crcValidatedCompressions < CRC_VALIDATED_COMPRESSIONS_BEFORE_TRUST) {
|
|
125
|
+
if (trailer.getUint32(0, true) !== crc32(inputBytes)) {
|
|
126
|
+
crcMismatchSeen = true
|
|
127
|
+
throwNativeGzipValidationError('invalid-crc')
|
|
128
|
+
}
|
|
129
|
+
crcValidatedCompressions++
|
|
130
|
+
}
|
|
114
131
|
}
|
|
115
132
|
|
|
116
133
|
export type GzipCompressOptions = {
|