@posthog/core
Advanced tools
+2
-0
@@ -6,2 +6,4 @@ /** | ||
| export declare function isGzipSupported(): boolean; | ||
| export declare const isGzipData: (body: unknown) => boolean; | ||
| export declare const isGzipRequest: (compression?: unknown, urlCompression?: unknown) => boolean; | ||
| export declare const isNativeAsyncGzipReadError: (error: unknown) => boolean; | ||
@@ -8,0 +10,0 @@ export declare const isNativeAsyncGzipError: (error: unknown) => boolean; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"gzip.d.ts","sourceRoot":"","sources":["../src/gzip.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAOzC;AAID,eAAO,MAAM,0BAA0B,GAAI,OAAO,OAAO,KAAG,OAQ3D,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,KAAG,OAQvD,CAAA;AA0DD,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"} | ||
| {"version":3,"file":"gzip.d.ts","sourceRoot":"","sources":["../src/gzip.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAOzC;AAWD,eAAO,MAAM,UAAU,GAAI,MAAM,OAAO,KAAG,OAU1C,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,cAAc,OAAO,EAAE,iBAAiB,OAAO,KAAG,OAE/E,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAI,OAAO,OAAO,KAAG,OAQ3D,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,KAAG,OAQvD,CAAA;AA0DD,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"} |
+21
-4
@@ -27,7 +27,10 @@ "use strict"; | ||
| __webpack_require__.d(__webpack_exports__, { | ||
| isNativeAsyncGzipError: ()=>isNativeAsyncGzipError, | ||
| isNativeAsyncGzipReadError: ()=>isNativeAsyncGzipReadError, | ||
| isGzipRequest: ()=>isGzipRequest, | ||
| isGzipSupported: ()=>isGzipSupported, | ||
| gzipCompress: ()=>gzipCompress, | ||
| isGzipSupported: ()=>isGzipSupported, | ||
| isNativeAsyncGzipError: ()=>isNativeAsyncGzipError, | ||
| isNativeAsyncGzipReadError: ()=>isNativeAsyncGzipReadError | ||
| isGzipData: ()=>isGzipData | ||
| }); | ||
| const external_types_js_namespaceObject = require("./types.js"); | ||
| function isGzipSupported() { | ||
@@ -37,2 +40,12 @@ return 'CompressionStream' in globalThis && 'TextEncoder' in globalThis && 'Response' in globalThis && 'function' == typeof Response.prototype.blob; | ||
| const NATIVE_GZIP_VALIDATION_ERROR = 'NativeGzipValidationError'; | ||
| const GZIP_MAGIC_FIRST_BYTE = 0x1f; | ||
| const GZIP_MAGIC_SECOND_BYTE = 0x8b; | ||
| const GZIP_DEFLATE_METHOD = 0x08; | ||
| const hasGzipMagic = (bytes)=>bytes.length >= 2 && bytes[0] === GZIP_MAGIC_FIRST_BYTE && bytes[1] === GZIP_MAGIC_SECOND_BYTE; | ||
| const isGzipData = (body)=>{ | ||
| if (body instanceof ArrayBuffer) return hasGzipMagic(new Uint8Array(body)); | ||
| if (ArrayBuffer.isView(body)) return hasGzipMagic(new Uint8Array(body.buffer, body.byteOffset, body.byteLength)); | ||
| return false; | ||
| }; | ||
| const isGzipRequest = (compression, urlCompression)=>compression === external_types_js_namespaceObject.Compression.GZipJS || urlCompression === external_types_js_namespaceObject.Compression.GZipJS || 'gzip' === urlCompression; | ||
| const isNativeAsyncGzipReadError = (error)=>{ | ||
@@ -73,3 +86,3 @@ if (!error || 'object' != typeof error) return false; | ||
| const header = new Uint8Array(await compressed.slice(0, 10).arrayBuffer()); | ||
| if (0x1f !== header[0] || 0x8b !== header[1] || 0x08 !== header[2]) throwNativeGzipValidationError('invalid-header'); | ||
| if (!hasGzipMagic(header) || header[2] !== GZIP_DEFLATE_METHOD) throwNativeGzipValidationError('invalid-header'); | ||
| const trailer = new DataView(await compressed.slice(compressed.size - 8).arrayBuffer()); | ||
@@ -105,2 +118,4 @@ if (trailer.getUint32(0, true) !== crc32(inputBytes)) throwNativeGzipValidationError('invalid-crc'); | ||
| exports.gzipCompress = __webpack_exports__.gzipCompress; | ||
| exports.isGzipData = __webpack_exports__.isGzipData; | ||
| exports.isGzipRequest = __webpack_exports__.isGzipRequest; | ||
| exports.isGzipSupported = __webpack_exports__.isGzipSupported; | ||
@@ -111,2 +126,4 @@ exports.isNativeAsyncGzipError = __webpack_exports__.isNativeAsyncGzipError; | ||
| "gzipCompress", | ||
| "isGzipData", | ||
| "isGzipRequest", | ||
| "isGzipSupported", | ||
@@ -113,0 +130,0 @@ "isNativeAsyncGzipError", |
+13
-2
@@ -0,1 +1,2 @@ | ||
| import { Compression } from "./types.mjs"; | ||
| function isGzipSupported() { | ||
@@ -5,2 +6,12 @@ return 'CompressionStream' in globalThis && 'TextEncoder' in globalThis && 'Response' in globalThis && 'function' == typeof Response.prototype.blob; | ||
| const NATIVE_GZIP_VALIDATION_ERROR = 'NativeGzipValidationError'; | ||
| const GZIP_MAGIC_FIRST_BYTE = 0x1f; | ||
| const GZIP_MAGIC_SECOND_BYTE = 0x8b; | ||
| const GZIP_DEFLATE_METHOD = 0x08; | ||
| const hasGzipMagic = (bytes)=>bytes.length >= 2 && bytes[0] === GZIP_MAGIC_FIRST_BYTE && bytes[1] === GZIP_MAGIC_SECOND_BYTE; | ||
| const isGzipData = (body)=>{ | ||
| if (body instanceof ArrayBuffer) return hasGzipMagic(new Uint8Array(body)); | ||
| if (ArrayBuffer.isView(body)) return hasGzipMagic(new Uint8Array(body.buffer, body.byteOffset, body.byteLength)); | ||
| return false; | ||
| }; | ||
| const isGzipRequest = (compression, urlCompression)=>compression === Compression.GZipJS || urlCompression === Compression.GZipJS || 'gzip' === urlCompression; | ||
| const isNativeAsyncGzipReadError = (error)=>{ | ||
@@ -41,3 +52,3 @@ if (!error || 'object' != typeof error) return false; | ||
| const header = new Uint8Array(await compressed.slice(0, 10).arrayBuffer()); | ||
| if (0x1f !== header[0] || 0x8b !== header[1] || 0x08 !== header[2]) throwNativeGzipValidationError('invalid-header'); | ||
| if (!hasGzipMagic(header) || header[2] !== GZIP_DEFLATE_METHOD) throwNativeGzipValidationError('invalid-header'); | ||
| const trailer = new DataView(await compressed.slice(compressed.size - 8).arrayBuffer()); | ||
@@ -72,2 +83,2 @@ if (trailer.getUint32(0, true) !== crc32(inputBytes)) throwNativeGzipValidationError('invalid-crc'); | ||
| } | ||
| export { gzipCompress, isGzipSupported, isNativeAsyncGzipError, isNativeAsyncGzipReadError }; | ||
| export { gzipCompress, isGzipData, isGzipRequest, isGzipSupported, isNativeAsyncGzipError, isNativeAsyncGzipReadError }; |
+1
-1
| export { getFeatureFlagValue } from './featureFlagUtils'; | ||
| export { gzipCompress, isNativeAsyncGzipError, isNativeAsyncGzipReadError } from './gzip'; | ||
| export { gzipCompress, isGzipData, isGzipRequest, isNativeAsyncGzipError, isNativeAsyncGzipReadError } from './gzip'; | ||
| export * from './utils'; | ||
@@ -4,0 +4,0 @@ export * as ErrorTracking from './error-tracking'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,0BAA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EAChB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,cAAc,CAAA;AAIrB,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACzG,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA"} |
+30
-12
@@ -98,2 +98,4 @@ "use strict"; | ||
| gzipCompress: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.gzipCompress, | ||
| isGzipData: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.isGzipData, | ||
| isGzipRequest: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.isGzipRequest, | ||
| isNativeAsyncGzipError: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.isNativeAsyncGzipError, | ||
@@ -116,8 +118,10 @@ isNativeAsyncGzipReadError: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.isNativeAsyncGzipReadError, | ||
| "getFeatureFlagValue", | ||
| "isGzipRequest", | ||
| "gzipCompress", | ||
| "uuidv7", | ||
| "ErrorTracking", | ||
| "getValidationError", | ||
| "ErrorTracking", | ||
| "gzipCompress", | ||
| "default", | ||
| "getRequirementsHint", | ||
| "isGzipData", | ||
| "getOtlpSeverityNumber", | ||
@@ -145,8 +149,10 @@ "getLengthFromRules", | ||
| "getFeatureFlagValue", | ||
| "isGzipRequest", | ||
| "gzipCompress", | ||
| "uuidv7", | ||
| "ErrorTracking", | ||
| "getValidationError", | ||
| "ErrorTracking", | ||
| "gzipCompress", | ||
| "default", | ||
| "getRequirementsHint", | ||
| "isGzipData", | ||
| "getOtlpSeverityNumber", | ||
@@ -170,8 +176,10 @@ "getLengthFromRules", | ||
| "getFeatureFlagValue", | ||
| "isGzipRequest", | ||
| "gzipCompress", | ||
| "uuidv7", | ||
| "ErrorTracking", | ||
| "getValidationError", | ||
| "ErrorTracking", | ||
| "gzipCompress", | ||
| "default", | ||
| "getRequirementsHint", | ||
| "isGzipData", | ||
| "getOtlpSeverityNumber", | ||
@@ -195,8 +203,10 @@ "getLengthFromRules", | ||
| "getFeatureFlagValue", | ||
| "isGzipRequest", | ||
| "gzipCompress", | ||
| "uuidv7", | ||
| "ErrorTracking", | ||
| "getValidationError", | ||
| "ErrorTracking", | ||
| "gzipCompress", | ||
| "default", | ||
| "getRequirementsHint", | ||
| "isGzipData", | ||
| "getOtlpSeverityNumber", | ||
@@ -220,8 +230,10 @@ "getLengthFromRules", | ||
| "getFeatureFlagValue", | ||
| "isGzipRequest", | ||
| "gzipCompress", | ||
| "uuidv7", | ||
| "ErrorTracking", | ||
| "getValidationError", | ||
| "ErrorTracking", | ||
| "gzipCompress", | ||
| "default", | ||
| "getRequirementsHint", | ||
| "isGzipData", | ||
| "getOtlpSeverityNumber", | ||
@@ -245,8 +257,10 @@ "getLengthFromRules", | ||
| "getFeatureFlagValue", | ||
| "isGzipRequest", | ||
| "gzipCompress", | ||
| "uuidv7", | ||
| "ErrorTracking", | ||
| "getValidationError", | ||
| "ErrorTracking", | ||
| "gzipCompress", | ||
| "default", | ||
| "getRequirementsHint", | ||
| "isGzipData", | ||
| "getOtlpSeverityNumber", | ||
@@ -274,2 +288,4 @@ "getLengthFromRules", | ||
| exports.gzipCompress = __webpack_exports__.gzipCompress; | ||
| exports.isGzipData = __webpack_exports__.isGzipData; | ||
| exports.isGzipRequest = __webpack_exports__.isGzipRequest; | ||
| exports.isNativeAsyncGzipError = __webpack_exports__.isNativeAsyncGzipError; | ||
@@ -292,2 +308,4 @@ exports.isNativeAsyncGzipReadError = __webpack_exports__.isNativeAsyncGzipReadError; | ||
| "gzipCompress", | ||
| "isGzipData", | ||
| "isGzipRequest", | ||
| "isNativeAsyncGzipError", | ||
@@ -294,0 +312,0 @@ "isNativeAsyncGzipReadError", |
+2
-2
| import { getFeatureFlagValue } from "./featureFlagUtils.mjs"; | ||
| import { gzipCompress, isNativeAsyncGzipError, isNativeAsyncGzipReadError } from "./gzip.mjs"; | ||
| import { gzipCompress, isGzipData, isGzipRequest, isNativeAsyncGzipError, isNativeAsyncGzipReadError } from "./gzip.mjs"; | ||
| import { buildOtlpLogRecord, buildOtlpLogsPayload, getOtlpSeverityNumber, getOtlpSeverityText, toOtlpAnyValue, toOtlpKeyValueList } from "./logs/logs-utils.mjs"; | ||
@@ -14,2 +14,2 @@ import { PostHogLogs } from "./logs/index.mjs"; | ||
| import * as __WEBPACK_EXTERNAL_MODULE__error_tracking_index_mjs_b3406d6f__ from "./error-tracking/index.mjs"; | ||
| export { __WEBPACK_EXTERNAL_MODULE__error_tracking_index_mjs_b3406d6f__ as ErrorTracking, PostHogLogs, buildOtlpLogRecord, buildOtlpLogsPayload, getFeatureFlagValue, getLengthFromRules, getOtlpSeverityNumber, getOtlpSeverityText, getRequirementsHint, getValidationError, gzipCompress, isNativeAsyncGzipError, isNativeAsyncGzipReadError, toOtlpAnyValue, toOtlpKeyValueList, uuidv7 }; | ||
| export { __WEBPACK_EXTERNAL_MODULE__error_tracking_index_mjs_b3406d6f__ as ErrorTracking, PostHogLogs, buildOtlpLogRecord, buildOtlpLogsPayload, getFeatureFlagValue, getLengthFromRules, getOtlpSeverityNumber, getOtlpSeverityText, getRequirementsHint, getValidationError, gzipCompress, isGzipData, isGzipRequest, isNativeAsyncGzipError, isNativeAsyncGzipReadError, toOtlpAnyValue, toOtlpKeyValueList, uuidv7 }; |
+2
-2
| { | ||
| "name": "@posthog/core", | ||
| "version": "1.29.0", | ||
| "version": "1.29.1", | ||
| "license": "MIT", | ||
@@ -70,3 +70,3 @@ "main": "dist/index.js", | ||
| "dependencies": { | ||
| "@posthog/types": "1.373.3" | ||
| "@posthog/types": "1.373.4" | ||
| }, | ||
@@ -73,0 +73,0 @@ "devDependencies": { |
+26
-1
@@ -0,1 +1,3 @@ | ||
| import { Compression } from './types' | ||
| /** | ||
@@ -15,3 +17,26 @@ * Older browsers and some runtimes don't support this yet | ||
| const NATIVE_GZIP_VALIDATION_ERROR = 'NativeGzipValidationError' | ||
| const GZIP_MAGIC_FIRST_BYTE = 0x1f | ||
| const GZIP_MAGIC_SECOND_BYTE = 0x8b | ||
| const GZIP_DEFLATE_METHOD = 0x08 | ||
| const hasGzipMagic = (bytes: Uint8Array): boolean => { | ||
| return bytes.length >= 2 && bytes[0] === GZIP_MAGIC_FIRST_BYTE && bytes[1] === GZIP_MAGIC_SECOND_BYTE | ||
| } | ||
| export const isGzipData = (body: unknown): boolean => { | ||
| if (body instanceof ArrayBuffer) { | ||
| return hasGzipMagic(new Uint8Array(body)) | ||
| } | ||
| if (ArrayBuffer.isView(body)) { | ||
| return hasGzipMagic(new Uint8Array(body.buffer, body.byteOffset, body.byteLength)) | ||
| } | ||
| return false | ||
| } | ||
| export const isGzipRequest = (compression?: unknown, urlCompression?: unknown): boolean => { | ||
| return compression === Compression.GZipJS || urlCompression === Compression.GZipJS || urlCompression === 'gzip' | ||
| } | ||
| export const isNativeAsyncGzipReadError = (error: unknown): boolean => { | ||
@@ -78,3 +103,3 @@ if (!error || typeof error !== 'object') { | ||
| const header = new Uint8Array(await compressed.slice(0, 10).arrayBuffer()) | ||
| if (header[0] !== 0x1f || header[1] !== 0x8b || header[2] !== 0x08) { | ||
| if (!hasGzipMagic(header) || header[2] !== GZIP_DEFLATE_METHOD) { | ||
| throwNativeGzipValidationError('invalid-header') | ||
@@ -81,0 +106,0 @@ } |
+1
-1
| export { getFeatureFlagValue } from './featureFlagUtils' | ||
| export { gzipCompress, isNativeAsyncGzipError, isNativeAsyncGzipReadError } from './gzip' | ||
| export { gzipCompress, isGzipData, isGzipRequest, isNativeAsyncGzipError, isNativeAsyncGzipReadError } from './gzip' | ||
| export * from './utils' | ||
@@ -4,0 +4,0 @@ export * as ErrorTracking from './error-tracking' |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1041265
0.34%24511
0.27%+ Added
- Removed
Updated