@posthog/core
Advanced tools
| /** | ||
| * Converts an arbitrary value, sanitizing `toJSON` results when available. | ||
| * The limits keep pathological values from causing unbounded recursion or traversal. | ||
| */ | ||
| export declare function toJsonSafeValue(value: unknown): unknown; | ||
| //# sourceMappingURL=json-utils.d.ts.map |
| {"version":3,"file":"json-utils.d.ts","sourceRoot":"","sources":["../../src/utils/json-utils.ts"],"names":[],"mappings":"AAoCA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA2GvD"} |
| "use strict"; | ||
| var __webpack_require__ = {}; | ||
| (()=>{ | ||
| __webpack_require__.d = (exports1, definition)=>{ | ||
| for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { | ||
| enumerable: true, | ||
| get: definition[key] | ||
| }); | ||
| }; | ||
| })(); | ||
| (()=>{ | ||
| __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); | ||
| })(); | ||
| (()=>{ | ||
| __webpack_require__.r = (exports1)=>{ | ||
| if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { | ||
| value: 'Module' | ||
| }); | ||
| Object.defineProperty(exports1, '__esModule', { | ||
| value: true | ||
| }); | ||
| }; | ||
| })(); | ||
| var __webpack_exports__ = {}; | ||
| __webpack_require__.r(__webpack_exports__); | ||
| __webpack_require__.d(__webpack_exports__, { | ||
| toJsonSafeValue: ()=>toJsonSafeValue | ||
| }); | ||
| const MAX_JSON_SAFE_VALUE_DEPTH = 20; | ||
| const MAX_JSON_SAFE_VALUE_ITEMS = 1000; | ||
| const MAX_JSON_SAFE_VALUE_NODES = 10000; | ||
| const CIRCULAR_VALUE = '[Circular]'; | ||
| const TRUNCATED_VALUE = '[Truncated]'; | ||
| const UNSERIALIZABLE_VALUE = '[Unserializable]'; | ||
| const FUNCTION_VALUE = '[Function]'; | ||
| const dateGetTime = Date.prototype.getTime; | ||
| const dateToISOString = Date.prototype.toISOString; | ||
| const propertyIsEnumerable = Object.prototype.propertyIsEnumerable; | ||
| function sanitizeString(value) { | ||
| let output = ''; | ||
| for(let index = 0; index < value.length; index++){ | ||
| const codeUnit = value.charCodeAt(index); | ||
| if (codeUnit >= 0xd800 && codeUnit <= 0xdbff) { | ||
| const nextCodeUnit = value.charCodeAt(index + 1); | ||
| if (nextCodeUnit >= 0xdc00 && nextCodeUnit <= 0xdfff) { | ||
| output += value[index] + value[index + 1]; | ||
| index++; | ||
| } else output += '\ufffd'; | ||
| } else output += codeUnit >= 0xdc00 && codeUnit <= 0xdfff ? '\ufffd' : value[index]; | ||
| } | ||
| return output; | ||
| } | ||
| function toJsonSafeValue(value) { | ||
| const state = { | ||
| ancestors: new WeakSet(), | ||
| remainingNodes: MAX_JSON_SAFE_VALUE_NODES | ||
| }; | ||
| const convert = (current, depth)=>{ | ||
| if (state.remainingNodes <= 0) return TRUNCATED_VALUE; | ||
| state.remainingNodes--; | ||
| try { | ||
| if (null == current || 'boolean' == typeof current) return current; | ||
| if ('string' == typeof current) return sanitizeString(current); | ||
| if ('number' == typeof current) return Number.isFinite(current) ? current : null; | ||
| if ('bigint' == typeof current) return current.toString(); | ||
| if ('function' == typeof current) return FUNCTION_VALUE; | ||
| if ('symbol' == typeof current) return current.description ? `Symbol(${current.description})` : 'Symbol()'; | ||
| if (depth >= MAX_JSON_SAFE_VALUE_DEPTH) return TRUNCATED_VALUE; | ||
| if (state.ancestors.has(current)) return CIRCULAR_VALUE; | ||
| state.ancestors.add(current); | ||
| try { | ||
| if (current instanceof Date) return Number.isFinite(dateGetTime.call(current)) ? dateToISOString.call(current) : null; | ||
| let hasToJSONResult = false; | ||
| let toJSONResult; | ||
| try { | ||
| const toJSON = current.toJSON; | ||
| if ('function' == typeof toJSON) { | ||
| toJSONResult = toJSON.call(current); | ||
| hasToJSONResult = true; | ||
| } | ||
| } catch { | ||
| hasToJSONResult = false; | ||
| } | ||
| if (hasToJSONResult) return convert(toJSONResult, depth + 1); | ||
| if (Array.isArray(current)) { | ||
| const itemCount = Math.min(current.length, MAX_JSON_SAFE_VALUE_ITEMS); | ||
| const output = []; | ||
| let index = 0; | ||
| for(; index < itemCount && state.remainingNodes > 0; index++)output.push(convert(current[index], depth + 1)); | ||
| if (current.length > index) output.push(TRUNCATED_VALUE); | ||
| return output; | ||
| } | ||
| const output = {}; | ||
| let itemCount = 0; | ||
| let truncated = false; | ||
| for(const key in current){ | ||
| if (!propertyIsEnumerable.call(current, key)) break; | ||
| if (itemCount >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) { | ||
| truncated = true; | ||
| break; | ||
| } | ||
| const converted = convert(current[key], depth + 1); | ||
| Object.defineProperty(output, key, { | ||
| value: converted, | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true | ||
| }); | ||
| itemCount++; | ||
| } | ||
| if (truncated) output[TRUNCATED_VALUE] = 'Additional properties omitted'; | ||
| return output; | ||
| } finally{ | ||
| state.ancestors.delete(current); | ||
| } | ||
| } catch { | ||
| return UNSERIALIZABLE_VALUE; | ||
| } | ||
| }; | ||
| return convert(value, 0); | ||
| } | ||
| exports.toJsonSafeValue = __webpack_exports__.toJsonSafeValue; | ||
| for(var __webpack_i__ in __webpack_exports__)if (-1 === [ | ||
| "toJsonSafeValue" | ||
| ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__]; | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); |
| const MAX_JSON_SAFE_VALUE_DEPTH = 20; | ||
| const MAX_JSON_SAFE_VALUE_ITEMS = 1000; | ||
| const MAX_JSON_SAFE_VALUE_NODES = 10000; | ||
| const CIRCULAR_VALUE = '[Circular]'; | ||
| const TRUNCATED_VALUE = '[Truncated]'; | ||
| const UNSERIALIZABLE_VALUE = '[Unserializable]'; | ||
| const FUNCTION_VALUE = '[Function]'; | ||
| const dateGetTime = Date.prototype.getTime; | ||
| const dateToISOString = Date.prototype.toISOString; | ||
| const propertyIsEnumerable = Object.prototype.propertyIsEnumerable; | ||
| function sanitizeString(value) { | ||
| let output = ''; | ||
| for(let index = 0; index < value.length; index++){ | ||
| const codeUnit = value.charCodeAt(index); | ||
| if (codeUnit >= 0xd800 && codeUnit <= 0xdbff) { | ||
| const nextCodeUnit = value.charCodeAt(index + 1); | ||
| if (nextCodeUnit >= 0xdc00 && nextCodeUnit <= 0xdfff) { | ||
| output += value[index] + value[index + 1]; | ||
| index++; | ||
| } else output += '\ufffd'; | ||
| } else output += codeUnit >= 0xdc00 && codeUnit <= 0xdfff ? '\ufffd' : value[index]; | ||
| } | ||
| return output; | ||
| } | ||
| function toJsonSafeValue(value) { | ||
| const state = { | ||
| ancestors: new WeakSet(), | ||
| remainingNodes: MAX_JSON_SAFE_VALUE_NODES | ||
| }; | ||
| const convert = (current, depth)=>{ | ||
| if (state.remainingNodes <= 0) return TRUNCATED_VALUE; | ||
| state.remainingNodes--; | ||
| try { | ||
| if (null == current || 'boolean' == typeof current) return current; | ||
| if ('string' == typeof current) return sanitizeString(current); | ||
| if ('number' == typeof current) return Number.isFinite(current) ? current : null; | ||
| if ('bigint' == typeof current) return current.toString(); | ||
| if ('function' == typeof current) return FUNCTION_VALUE; | ||
| if ('symbol' == typeof current) return current.description ? `Symbol(${current.description})` : 'Symbol()'; | ||
| if (depth >= MAX_JSON_SAFE_VALUE_DEPTH) return TRUNCATED_VALUE; | ||
| if (state.ancestors.has(current)) return CIRCULAR_VALUE; | ||
| state.ancestors.add(current); | ||
| try { | ||
| if (current instanceof Date) return Number.isFinite(dateGetTime.call(current)) ? dateToISOString.call(current) : null; | ||
| let hasToJSONResult = false; | ||
| let toJSONResult; | ||
| try { | ||
| const toJSON = current.toJSON; | ||
| if ('function' == typeof toJSON) { | ||
| toJSONResult = toJSON.call(current); | ||
| hasToJSONResult = true; | ||
| } | ||
| } catch { | ||
| hasToJSONResult = false; | ||
| } | ||
| if (hasToJSONResult) return convert(toJSONResult, depth + 1); | ||
| if (Array.isArray(current)) { | ||
| const itemCount = Math.min(current.length, MAX_JSON_SAFE_VALUE_ITEMS); | ||
| const output = []; | ||
| let index = 0; | ||
| for(; index < itemCount && state.remainingNodes > 0; index++)output.push(convert(current[index], depth + 1)); | ||
| if (current.length > index) output.push(TRUNCATED_VALUE); | ||
| return output; | ||
| } | ||
| const output = {}; | ||
| let itemCount = 0; | ||
| let truncated = false; | ||
| for(const key in current){ | ||
| if (!propertyIsEnumerable.call(current, key)) break; | ||
| if (itemCount >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) { | ||
| truncated = true; | ||
| break; | ||
| } | ||
| const converted = convert(current[key], depth + 1); | ||
| Object.defineProperty(output, key, { | ||
| value: converted, | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true | ||
| }); | ||
| itemCount++; | ||
| } | ||
| if (truncated) output[TRUNCATED_VALUE] = 'Additional properties omitted'; | ||
| return output; | ||
| } finally{ | ||
| state.ancestors.delete(current); | ||
| } | ||
| } catch { | ||
| return UNSERIALIZABLE_VALUE; | ||
| } | ||
| }; | ||
| return convert(value, 0); | ||
| } | ||
| export { toJsonSafeValue }; |
| import { toJsonSafeValue } from './json-utils' | ||
| describe('toJsonSafeValue', () => { | ||
| it('converts circular and unsupported values while preserving shared references', () => { | ||
| const shared = { id: 1 } | ||
| const value: Record<string, unknown> = { | ||
| count: BigInt(42), | ||
| callback: () => undefined, | ||
| symbol: Symbol('test'), | ||
| invalidNumber: Number.NaN, | ||
| loneSurrogate: '\ud800', | ||
| validSurrogatePair: '😀', | ||
| first: shared, | ||
| second: shared, | ||
| } | ||
| value.self = value | ||
| expect(toJsonSafeValue(value)).toEqual({ | ||
| count: '42', | ||
| callback: '[Function]', | ||
| symbol: 'Symbol(test)', | ||
| invalidNumber: null, | ||
| loneSurrogate: '�', | ||
| validSurrogatePair: '😀', | ||
| first: { id: 1 }, | ||
| second: { id: 1 }, | ||
| self: '[Circular]', | ||
| }) | ||
| }) | ||
| it('sanitizes toJSON results and falls back when toJSON throws', () => { | ||
| const serializableToJSON = jest.fn(() => ({ count: BigInt(2) })) | ||
| const serializable = Object.create({ toJSON: serializableToJSON }) | ||
| const throwingToJSON = jest.fn(() => { | ||
| throw new Error('cannot serialize') | ||
| }) | ||
| const selfReturningValue: { toJSON: () => unknown } = { | ||
| toJSON: () => selfReturningValue, | ||
| } | ||
| const getTimeOverride = jest.fn(() => 0) | ||
| const toISOStringOverride = jest.fn(() => BigInt(2)) | ||
| const date = new Date('2025-01-02T03:04:05.000Z') | ||
| Object.defineProperties(date, { | ||
| getTime: { value: getTimeOverride }, | ||
| toISOString: { value: toISOStringOverride }, | ||
| }) | ||
| expect( | ||
| toJsonSafeValue({ | ||
| serializable, | ||
| throwing: { value: 'kept', toJSON: throwingToJSON }, | ||
| selfReturningValue, | ||
| date, | ||
| }) | ||
| ).toEqual({ | ||
| serializable: { count: '2' }, | ||
| throwing: { value: 'kept', toJSON: '[Function]' }, | ||
| selfReturningValue: '[Circular]', | ||
| date: '2025-01-02T03:04:05.000Z', | ||
| }) | ||
| expect(serializableToJSON).toHaveBeenCalledTimes(1) | ||
| expect(throwingToJSON).toHaveBeenCalledTimes(1) | ||
| expect(getTimeOverride).not.toHaveBeenCalled() | ||
| expect(toISOStringOverride).not.toHaveBeenCalled() | ||
| }) | ||
| it('stops before traversing inherited enumerable properties', () => { | ||
| const prototype = Object.fromEntries(Array.from({ length: 2_000 }, (_, index) => [`key-${index}`, index])) | ||
| const target = Object.assign(Object.create(prototype), { own: 'kept' }) | ||
| const getOwnPropertyDescriptor = jest.fn((object: object, key: string | symbol) => | ||
| Object.getOwnPropertyDescriptor(object, key) | ||
| ) | ||
| const value = new Proxy(target, { getOwnPropertyDescriptor }) | ||
| expect(toJsonSafeValue(value)).toEqual({ own: 'kept' }) | ||
| expect(getOwnPropertyDescriptor.mock.calls.length).toBeLessThan(10) | ||
| }) | ||
| it('returns a fallback for values that throw during traversal', () => { | ||
| const value = new Proxy( | ||
| {}, | ||
| { | ||
| ownKeys() { | ||
| throw new Error('cannot inspect') | ||
| }, | ||
| } | ||
| ) | ||
| expect(toJsonSafeValue(value)).toBe('[Unserializable]') | ||
| }) | ||
| it('bounds deeply nested, oversized, and node-heavy values', () => { | ||
| const deepValue: Record<string, unknown> = {} | ||
| let cursor = deepValue | ||
| for (let depth = 0; depth < 100; depth++) { | ||
| const child: Record<string, unknown> = {} | ||
| cursor.child = child | ||
| cursor = child | ||
| } | ||
| const oversizedArray = Array.from({ length: 2_000 }, (_, index) => index) | ||
| const oversizedObject = Object.fromEntries(Array.from({ length: 2_000 }, (_, index) => [`key-${index}`, index])) | ||
| const nodeHeavyValue = Array.from({ length: 1_000 }, () => Array.from({ length: 20 }, () => true)) | ||
| expect(JSON.stringify(toJsonSafeValue(deepValue))).toContain('[Truncated]') | ||
| expect(toJsonSafeValue(oversizedArray)).toEqual([...oversizedArray.slice(0, 1_000), '[Truncated]']) | ||
| const safeObject = toJsonSafeValue(oversizedObject) as Record<string, unknown> | ||
| expect(Object.keys(safeObject)).toHaveLength(1_001) | ||
| expect(safeObject['[Truncated]']).toBe('Additional properties omitted') | ||
| const safeNodeHeavyValue = toJsonSafeValue(nodeHeavyValue) as unknown[] | ||
| expect(safeNodeHeavyValue).toHaveLength(478) | ||
| expect(safeNodeHeavyValue.at(-1)).toBe('[Truncated]') | ||
| }) | ||
| }) |
| const MAX_JSON_SAFE_VALUE_DEPTH = 20 | ||
| const MAX_JSON_SAFE_VALUE_ITEMS = 1_000 | ||
| const MAX_JSON_SAFE_VALUE_NODES = 10_000 | ||
| const CIRCULAR_VALUE = '[Circular]' | ||
| const TRUNCATED_VALUE = '[Truncated]' | ||
| const UNSERIALIZABLE_VALUE = '[Unserializable]' | ||
| const FUNCTION_VALUE = '[Function]' | ||
| const dateGetTime = Date.prototype.getTime | ||
| const dateToISOString = Date.prototype.toISOString | ||
| const propertyIsEnumerable = Object.prototype.propertyIsEnumerable | ||
| interface JsonSafeValueConversionState { | ||
| ancestors: WeakSet<object> | ||
| remainingNodes: number | ||
| } | ||
| function sanitizeString(value: string): string { | ||
| let output = '' | ||
| for (let index = 0; index < value.length; index++) { | ||
| const codeUnit = value.charCodeAt(index) | ||
| if (codeUnit >= 0xd800 && codeUnit <= 0xdbff) { | ||
| const nextCodeUnit = value.charCodeAt(index + 1) | ||
| if (nextCodeUnit >= 0xdc00 && nextCodeUnit <= 0xdfff) { | ||
| output += value[index] + value[index + 1] | ||
| index++ | ||
| } else { | ||
| output += '\ufffd' | ||
| } | ||
| } else { | ||
| output += codeUnit >= 0xdc00 && codeUnit <= 0xdfff ? '\ufffd' : value[index] | ||
| } | ||
| } | ||
| return output | ||
| } | ||
| /** | ||
| * Converts an arbitrary value, sanitizing `toJSON` results when available. | ||
| * The limits keep pathological values from causing unbounded recursion or traversal. | ||
| */ | ||
| export function toJsonSafeValue(value: unknown): unknown { | ||
| const state: JsonSafeValueConversionState = { | ||
| ancestors: new WeakSet(), | ||
| remainingNodes: MAX_JSON_SAFE_VALUE_NODES, | ||
| } | ||
| const convert = (current: unknown, depth: number): unknown => { | ||
| if (state.remainingNodes <= 0) { | ||
| return TRUNCATED_VALUE | ||
| } | ||
| state.remainingNodes-- | ||
| try { | ||
| if (current === null || current === undefined || typeof current === 'boolean') { | ||
| return current | ||
| } | ||
| if (typeof current === 'string') { | ||
| return sanitizeString(current) | ||
| } | ||
| if (typeof current === 'number') { | ||
| return Number.isFinite(current) ? current : null | ||
| } | ||
| if (typeof current === 'bigint') { | ||
| return current.toString() | ||
| } | ||
| if (typeof current === 'function') { | ||
| return FUNCTION_VALUE | ||
| } | ||
| if (typeof current === 'symbol') { | ||
| return current.description ? `Symbol(${current.description})` : 'Symbol()' | ||
| } | ||
| if (depth >= MAX_JSON_SAFE_VALUE_DEPTH) { | ||
| return TRUNCATED_VALUE | ||
| } | ||
| if (state.ancestors.has(current)) { | ||
| return CIRCULAR_VALUE | ||
| } | ||
| state.ancestors.add(current) | ||
| try { | ||
| if (current instanceof Date) { | ||
| return Number.isFinite(dateGetTime.call(current)) ? dateToISOString.call(current) : null | ||
| } | ||
| let hasToJSONResult = false | ||
| let toJSONResult: unknown | ||
| try { | ||
| const toJSON = (current as { toJSON?: unknown }).toJSON | ||
| if (typeof toJSON === 'function') { | ||
| toJSONResult = toJSON.call(current) | ||
| hasToJSONResult = true | ||
| } | ||
| } catch { | ||
| hasToJSONResult = false | ||
| } | ||
| if (hasToJSONResult) { | ||
| return convert(toJSONResult, depth + 1) | ||
| } | ||
| if (Array.isArray(current)) { | ||
| const itemCount = Math.min(current.length, MAX_JSON_SAFE_VALUE_ITEMS) | ||
| const output: unknown[] = [] | ||
| let index = 0 | ||
| for (; index < itemCount && state.remainingNodes > 0; index++) { | ||
| output.push(convert(current[index], depth + 1)) | ||
| } | ||
| if (current.length > index) { | ||
| output.push(TRUNCATED_VALUE) | ||
| } | ||
| return output | ||
| } | ||
| const output: Record<string, unknown> = {} | ||
| let itemCount = 0 | ||
| let truncated = false | ||
| for (const key in current) { | ||
| // for...in visits own enumerable keys before walking the prototype chain. | ||
| if (!propertyIsEnumerable.call(current, key)) { | ||
| break | ||
| } | ||
| if (itemCount >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) { | ||
| truncated = true | ||
| break | ||
| } | ||
| const converted = convert((current as Record<string, unknown>)[key], depth + 1) | ||
| Object.defineProperty(output, key, { | ||
| value: converted, | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| }) | ||
| itemCount++ | ||
| } | ||
| if (truncated) { | ||
| output[TRUNCATED_VALUE] = 'Additional properties omitted' | ||
| } | ||
| return output | ||
| } finally { | ||
| state.ancestors.delete(current) | ||
| } | ||
| } catch { | ||
| return UNSERIALIZABLE_VALUE | ||
| } | ||
| } | ||
| return convert(value, 0) | ||
| } |
@@ -5,2 +5,3 @@ import { FetchLike } from '../types'; | ||
| export * from './bucketed-rate-limiter'; | ||
| export * from './json-utils'; | ||
| export * from './number-utils'; | ||
@@ -7,0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AM,SAAS,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAEtD,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,KAEzC,CAAA;AAED,wBAAgB,QAAQ,IAAI,SAAS,GAAG,SAAS,CAEhD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC1C,OAAO,CAAC,CAAC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,EAAE,CAAC,CAStF"} |
+45
-18
@@ -12,2 +12,5 @@ "use strict"; | ||
| }, | ||
| "./json-utils": function(module) { | ||
| module.exports = require("./json-utils.js"); | ||
| }, | ||
| "./logger": function(module) { | ||
@@ -165,5 +168,5 @@ module.exports = require("./logger.js"); | ||
| __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__); | ||
| var _number_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./number-utils"); | ||
| var _json_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./json-utils"); | ||
| var __WEBPACK_REEXPORT_OBJECT__ = {}; | ||
| for(var __WEBPACK_IMPORT_KEY__ in _number_utils__WEBPACK_IMPORTED_MODULE_3__)if ([ | ||
| for(var __WEBPACK_IMPORT_KEY__ in _json_utils__WEBPACK_IMPORTED_MODULE_3__)if ([ | ||
| "removeTrailingSlash", | ||
@@ -187,8 +190,8 @@ "isValidUUID", | ||
| ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) { | ||
| return _number_utils__WEBPACK_IMPORTED_MODULE_3__[key]; | ||
| return _json_utils__WEBPACK_IMPORTED_MODULE_3__[key]; | ||
| }).bind(0, __WEBPACK_IMPORT_KEY__); | ||
| __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__); | ||
| var _string_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./string-utils"); | ||
| var _number_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./number-utils"); | ||
| var __WEBPACK_REEXPORT_OBJECT__ = {}; | ||
| for(var __WEBPACK_IMPORT_KEY__ in _string_utils__WEBPACK_IMPORTED_MODULE_4__)if ([ | ||
| for(var __WEBPACK_IMPORT_KEY__ in _number_utils__WEBPACK_IMPORTED_MODULE_4__)if ([ | ||
| "removeTrailingSlash", | ||
@@ -212,8 +215,8 @@ "isValidUUID", | ||
| ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) { | ||
| return _string_utils__WEBPACK_IMPORTED_MODULE_4__[key]; | ||
| return _number_utils__WEBPACK_IMPORTED_MODULE_4__[key]; | ||
| }).bind(0, __WEBPACK_IMPORT_KEY__); | ||
| __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__); | ||
| var _type_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./type-utils"); | ||
| var _string_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./string-utils"); | ||
| var __WEBPACK_REEXPORT_OBJECT__ = {}; | ||
| for(var __WEBPACK_IMPORT_KEY__ in _type_utils__WEBPACK_IMPORTED_MODULE_5__)if ([ | ||
| for(var __WEBPACK_IMPORT_KEY__ in _string_utils__WEBPACK_IMPORTED_MODULE_5__)if ([ | ||
| "removeTrailingSlash", | ||
@@ -237,8 +240,8 @@ "isValidUUID", | ||
| ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) { | ||
| return _type_utils__WEBPACK_IMPORTED_MODULE_5__[key]; | ||
| return _string_utils__WEBPACK_IMPORTED_MODULE_5__[key]; | ||
| }).bind(0, __WEBPACK_IMPORT_KEY__); | ||
| __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__); | ||
| var _promise_queue__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./promise-queue"); | ||
| var _type_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./type-utils"); | ||
| var __WEBPACK_REEXPORT_OBJECT__ = {}; | ||
| for(var __WEBPACK_IMPORT_KEY__ in _promise_queue__WEBPACK_IMPORTED_MODULE_6__)if ([ | ||
| for(var __WEBPACK_IMPORT_KEY__ in _type_utils__WEBPACK_IMPORTED_MODULE_6__)if ([ | ||
| "removeTrailingSlash", | ||
@@ -262,8 +265,8 @@ "isValidUUID", | ||
| ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) { | ||
| return _promise_queue__WEBPACK_IMPORTED_MODULE_6__[key]; | ||
| return _type_utils__WEBPACK_IMPORTED_MODULE_6__[key]; | ||
| }).bind(0, __WEBPACK_IMPORT_KEY__); | ||
| __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__); | ||
| var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("./logger"); | ||
| var _promise_queue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("./promise-queue"); | ||
| var __WEBPACK_REEXPORT_OBJECT__ = {}; | ||
| for(var __WEBPACK_IMPORT_KEY__ in _logger__WEBPACK_IMPORTED_MODULE_7__)if ([ | ||
| for(var __WEBPACK_IMPORT_KEY__ in _promise_queue__WEBPACK_IMPORTED_MODULE_7__)if ([ | ||
| "removeTrailingSlash", | ||
@@ -287,8 +290,8 @@ "isValidUUID", | ||
| ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) { | ||
| return _logger__WEBPACK_IMPORTED_MODULE_7__[key]; | ||
| return _promise_queue__WEBPACK_IMPORTED_MODULE_7__[key]; | ||
| }).bind(0, __WEBPACK_IMPORT_KEY__); | ||
| __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__); | ||
| var _user_agent_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__("./user-agent-utils"); | ||
| var _logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__("./logger"); | ||
| var __WEBPACK_REEXPORT_OBJECT__ = {}; | ||
| for(var __WEBPACK_IMPORT_KEY__ in _user_agent_utils__WEBPACK_IMPORTED_MODULE_8__)if ([ | ||
| for(var __WEBPACK_IMPORT_KEY__ in _logger__WEBPACK_IMPORTED_MODULE_8__)if ([ | ||
| "removeTrailingSlash", | ||
@@ -312,5 +315,29 @@ "isValidUUID", | ||
| ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) { | ||
| return _user_agent_utils__WEBPACK_IMPORTED_MODULE_8__[key]; | ||
| return _logger__WEBPACK_IMPORTED_MODULE_8__[key]; | ||
| }).bind(0, __WEBPACK_IMPORT_KEY__); | ||
| __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__); | ||
| var _user_agent_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__("./user-agent-utils"); | ||
| var __WEBPACK_REEXPORT_OBJECT__ = {}; | ||
| for(var __WEBPACK_IMPORT_KEY__ in _user_agent_utils__WEBPACK_IMPORTED_MODULE_9__)if ([ | ||
| "removeTrailingSlash", | ||
| "isValidUUID", | ||
| "currentISOTime", | ||
| "isError", | ||
| "safeSetTimeout", | ||
| "UUID_REGEX", | ||
| "assert", | ||
| "allSettled", | ||
| "retriable", | ||
| "default", | ||
| "stripUrlHash", | ||
| "STRING_FORMAT", | ||
| "currentTimestamp", | ||
| "raceWithTimeout", | ||
| "getFetch", | ||
| "getEventUuid", | ||
| "isPromise" | ||
| ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) { | ||
| return _user_agent_utils__WEBPACK_IMPORTED_MODULE_9__[key]; | ||
| }).bind(0, __WEBPACK_IMPORT_KEY__); | ||
| __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__); | ||
| const STRING_FORMAT = 'utf8'; | ||
@@ -317,0 +344,0 @@ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; |
| export * from "./bot-detection.mjs"; | ||
| export * from "./browser-utils.mjs"; | ||
| export * from "./bucketed-rate-limiter.mjs"; | ||
| export * from "./json-utils.mjs"; | ||
| export * from "./number-utils.mjs"; | ||
@@ -5,0 +6,0 @@ export * from "./string-utils.mjs"; |
+1
-1
| { | ||
| "name": "@posthog/core", | ||
| "version": "1.46.5", | ||
| "version": "1.46.6", | ||
| "bugs": { | ||
@@ -5,0 +5,0 @@ "url": "https://github.com/PostHog/posthog-js/issues" |
@@ -6,2 +6,3 @@ import { FetchLike } from '../types' | ||
| export * from './bucketed-rate-limiter' | ||
| export * from './json-utils' | ||
| export * from './number-utils' | ||
@@ -8,0 +9,0 @@ export * from './string-utils' |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1330725
1.53%334
1.83%30799
1.64%