@ktuban/safe-json-loader 1.1.1 → 1.1.2
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/cjs/logger.js.map +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/types/logger.d.ts +3 -2
- package/dist/types/types.d.ts +3 -14
- package/package.json +2 -2
package/dist/cjs/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";AAAA,YAAY;;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";AAAA,YAAY;;AAmDZ,oCAYC;AAQD,kBAQC;AA7ED,iEAA6E;AAM7E;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,oCAAgB,CAAC,WAAW,EAAE,CAAC;AAExD;;;GAGG;AACH,MAAM,cAAc,GAAmB;IACrC,KAAK,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,IAAW,CAAC;IACtE,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAW,CAAC;IACpE,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAW,CAAC;IACpE,KAAK,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,IAAW,CAAC;CACvE,CAAC;AAEF;;GAEG;AACH,MAAM,eAAe,GAAkC;IACrD,QAAQ,EAAE,GAAG;IACb,aAAa,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,QAAQ;IACzC,YAAY,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,EAAI,OAAO;IACxC,aAAa,EAAE,IAAI;IACnB,cAAc,EAAE,CAAC;IACjB,oBAAoB,EAAE,IAAI;IAC1B,YAAY,EAAE,EAAE;IAChB,MAAM,EAAE,cAAc;IACtB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,YAAY,CAC1B,IAA4B;IAE5B,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC;IAEtD,OAAO;QACL,GAAG,eAAe;QAClB,GAAG,IAAI;QACP,MAAM;QACN,YAAY,EAAE,IAAI,EAAE,YAAY,IAAI,eAAe,CAAC,YAAY;QAChE,aAAa,EAAE,IAAI,EAAE,aAAa,IAAI,eAAe,CAAC,aAAa;KACpE,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,GAAG,CACjB,OAAsC,EACtC,KAA2B,EAC3B,OAAe,EACf,IAAc;IAEd,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,EAAE;QAAE,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/esm/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EAAkB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAM7E;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,WAAW,EAAE,CAAC;AAExD;;;GAGG;AACH,MAAM,cAAc,GAAmB;IACrC,KAAK,EAAE,CAAC,OAAO,EAAE,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f,IAAc;IAEd,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,EAAE;QAAE,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/types/logger.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { LoggerContract } from "@ktuban/structured-logger";
|
|
2
|
+
import type { ResolvedSafeJsonLoaderOptions, SafeJsonLoaderOptions } from "./types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Merge user‑provided options with defaults.
|
|
4
5
|
*
|
|
@@ -12,4 +13,4 @@ export declare function mergeOptions(opts?: SafeJsonLoaderOptions): ResolvedSafe
|
|
|
12
13
|
* This is intentionally minimal and tolerant:
|
|
13
14
|
* - If a given level is not implemented by the logger, it is silently skipped.
|
|
14
15
|
*/
|
|
15
|
-
export declare function log(options: ResolvedSafeJsonLoaderOptions, level: keyof
|
|
16
|
+
export declare function log(options: ResolvedSafeJsonLoaderOptions, level: keyof LoggerContract, message: string, meta?: unknown): void;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PathLike } from "fs";
|
|
2
2
|
import type { URL } from "url";
|
|
3
|
+
import { LoggerContract } from "@ktuban/structured-logger";
|
|
3
4
|
/** JSON primitive types. */
|
|
4
5
|
export type JsonPrimitive = string | number | boolean | null;
|
|
5
6
|
/** JSON object type. */
|
|
@@ -22,18 +23,6 @@ export interface LoadedJsonFile {
|
|
|
22
23
|
/** Original source (absolute path or URL). */
|
|
23
24
|
__source: string;
|
|
24
25
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Minimal logger interface used by the loader.
|
|
27
|
-
*
|
|
28
|
-
* This keeps the loader decoupled from any specific logging framework.
|
|
29
|
-
* Callers can pass console, pino, winston, @ktuban/structured-logger, etc.
|
|
30
|
-
*/
|
|
31
|
-
export interface Logger {
|
|
32
|
-
debug?: (message: string, meta?: unknown) => void;
|
|
33
|
-
info?: (message: string, meta?: unknown) => void;
|
|
34
|
-
warn?: (message: string, meta?: unknown) => void;
|
|
35
|
-
error?: (message: string, meta?: unknown) => void;
|
|
36
|
-
}
|
|
37
26
|
/**
|
|
38
27
|
* Options for safe JSON loading.
|
|
39
28
|
*/
|
|
@@ -80,7 +69,7 @@ export interface SafeJsonLoaderOptions {
|
|
|
80
69
|
* Optional logger implementation.
|
|
81
70
|
* If omitted, a default adapter to @ktuban/structured-logger is used.
|
|
82
71
|
*/
|
|
83
|
-
logger?:
|
|
72
|
+
logger?: LoggerContract;
|
|
84
73
|
/**
|
|
85
74
|
* Optional hook invoked after each file is successfully loaded and sanitized.
|
|
86
75
|
*/
|
|
@@ -104,7 +93,7 @@ export interface ResolvedSafeJsonLoaderOptions extends SafeJsonLoaderOptions {
|
|
|
104
93
|
maxConcurrency: number;
|
|
105
94
|
looseJsonContentType: boolean;
|
|
106
95
|
maxJsonDepth: number;
|
|
107
|
-
logger:
|
|
96
|
+
logger: LoggerContract;
|
|
108
97
|
onFileLoaded: (file: LoadedJsonFile) => void;
|
|
109
98
|
onFileSkipped: (info: {
|
|
110
99
|
source: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ktuban/safe-json-loader",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "A security‑hardened JSON loader with prototype‑pollution protection, depth limits, safe parsing, and optional validation layers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"json",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"start": "node ./dist/esm/index.js"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@ktuban/structured-logger": "^1.
|
|
66
|
+
"@ktuban/structured-logger": "^1.1.0",
|
|
67
67
|
"node-fetch": "^3.3.2",
|
|
68
68
|
"safe-json-stringify": "^1.2.0"
|
|
69
69
|
},
|