|
| 1 | +export type ParseOptions = { |
| 2 | + /** |
| 3 | + * What to do when a `__proto__` key is found. |
| 4 | + * - `'error'` - throw a `SyntaxError` when a `__proto__` key is found. This is the default value. |
| 5 | + * - `'remove'` - deletes any `__proto__` keys from the result object. |
| 6 | + * - `'ignore'` - skips all validation (same as calling `JSON.parse()` directly). |
| 7 | + */ |
| 8 | + protoAction?: 'error' | 'remove' | 'ignore', |
| 9 | + /** |
| 10 | + * What to do when a `constructor` key is found. |
| 11 | + * - `'error'` - throw a `SyntaxError` when a `constructor.prototype` key is found. This is the default value. |
| 12 | + * - `'remove'` - deletes any `constructor` keys from the result object. |
| 13 | + * - `'ignore'` - skips all validation (same as calling `JSON.parse()` directly). |
| 14 | + */ |
| 15 | + constructorAction?: 'error' | 'remove' | 'ignore', |
| 16 | +} |
| 17 | + |
| 18 | +export type ScanOptions = { |
| 19 | + /** |
| 20 | + * What to do when a `__proto__` key is found. |
| 21 | + * - `'error'` - throw a `SyntaxError` when a `__proto__` key is found. This is the default value. |
| 22 | + * - `'remove'` - deletes any `__proto__` keys from the input `obj`. |
| 23 | + */ |
| 24 | + protoAction?: 'error' | 'remove', |
| 25 | + /** |
| 26 | + * What to do when a `constructor` key is found. |
| 27 | + * - `'error'` - throw a `SyntaxError` when a `constructor.prototype` key is found. This is the default value. |
| 28 | + * - `'remove'` - deletes any `constructor` keys from the input `obj`. |
| 29 | + */ |
| 30 | + constructorAction?: 'error' | 'remove', |
| 31 | +} |
| 32 | + |
| 33 | +type Reviver = (this: any, key: string, value: any) => any |
| 34 | + |
| 35 | +/** |
| 36 | + * Parses a given JSON-formatted text into an object. |
| 37 | + * |
| 38 | + * @param text The JSON text string. |
| 39 | + * @param reviver The `JSON.parse()` optional `reviver` argument. |
| 40 | + * @param options Optional configuration object. |
| 41 | + * @returns The parsed object. |
| 42 | + */ |
| 43 | +export function parse(text: string | Buffer, reviver?: Reviver | null, options?: ParseOptions): any |
| 44 | + |
| 45 | +/** |
| 46 | + * Parses a given JSON-formatted text into an object. |
| 47 | + * |
| 48 | + * @param text The JSON text string. |
| 49 | + * @param reviver The `JSON.parse()` optional `reviver` argument. |
| 50 | + * @returns The parsed object, or `null` if there was an error or if the JSON contained possibly insecure properties. |
| 51 | + */ |
| 52 | +export function safeParse(text: string | Buffer, reviver?: Reviver | null): any |
| 53 | + |
| 54 | +/** |
| 55 | + * Scans a given object for prototype properties. |
| 56 | + * |
| 57 | + * @param obj The object being scanned. |
| 58 | + * @param options Optional configuration object. |
| 59 | + */ |
| 60 | +export function scan(obj: any, options?: ScanOptions): void |
0 commit comments