@glassops/scribe 1.0.1 → 1.0.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.
@@ -4,7 +4,7 @@
4
4
  |* provided LoggerScope. This is the only step containing
5
5
  |* side-effects in Scribe's initialization flow.
6
6
  \* -------------------------------------------------------------------------- */
7
- import type { LoggerScope } from "./types.js";
7
+ import type { LoggerScope } from './types.js';
8
8
  /**
9
9
  * Resolves and creates the directory where log files will be written.
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"create-directory.d.ts","sourceRoot":"","sources":["../src/create-directory.ts"],"names":[],"mappings":"AAAA;;;;;gFAKgF;AAWhF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM9C;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,OAAO,WAAW,WAoBjE,CAAC"}
1
+ {"version":3,"file":"create-directory.d.ts","sourceRoot":"","sources":["../src/create-directory.ts"],"names":[],"mappings":"AAAA;;;;;gFAKgF;AAWhF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM9C;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,OAAO,WAAW,WA2BjE,CAAC"}
@@ -7,9 +7,9 @@
7
7
  /* --------------------------------------------------------------------------
8
8
  |* NPM Dependencies
9
9
  \* -------------------------------------------------------------------------- */
10
- import fs from "fs";
11
- import path from "path";
12
- import { safe } from "./utilities.js";
10
+ import fs from 'fs';
11
+ import path from 'path';
12
+ import { safe } from './utilities.js';
13
13
  /* -------------------------------------------------------------------------- *\
14
14
  |* Create Directory
15
15
  \* -------------------------------------------------------------------------- */
@@ -25,14 +25,18 @@ import { safe } from "./utilities.js";
25
25
  */
26
26
  export const createDirectory = (target, scope) => {
27
27
  if (!target)
28
- throw new Error("Invalid log directory");
28
+ throw new Error('Invalid log directory');
29
29
  const { tenant, environment, service } = scope;
30
30
  if (!tenant || !environment) {
31
- throw new Error("LoggerScope must include tenant and environment");
31
+ throw new Error('LoggerScope must include tenant and environment');
32
32
  }
33
- const directory = service
34
- ? path.join(target, safe(service), safe(tenant))
35
- : path.join(target, safe(tenant), safe(environment));
33
+ const base = path.resolve(target);
34
+ const segmentA = service ? safe(service) : safe(tenant);
35
+ const segmentB = service ? safe(tenant) : safe(environment);
36
+ if (!segmentA || !segmentB) {
37
+ throw new Error('Invalid directory segment after sanitization');
38
+ }
39
+ const directory = path.join(base, segmentA, segmentB);
36
40
  try {
37
41
  fs.mkdirSync(directory, { recursive: true });
38
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"create-directory.js","sourceRoot":"","sources":["../src/create-directory.ts"],"names":[],"mappings":"AAAA;;;;;gFAKgF;AAEhF;;gFAEgF;AAChF,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAMxB,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC;;gFAEgF;AAChF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAE,KAAkB,EAAE,EAAE;IAClE,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAEtD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAE/C,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,SAAS,GAAG,OAAO;QACrB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,E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AI,CAAC,QAAQ,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEtD,IAAI,CAAC;QACD,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACL,MAAM,IAAI,KAAK,CAAC,mCAAmC,SAAS,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
- import winston from "winston";
2
- import type { LoggerOptions, LoggerScope } from "./types.js";
1
+ import winston from 'winston';
2
+ import type { LoggerOptions, LoggerScope } from './types.js';
3
3
  /**
4
4
  * Creates a fully configured Winston logger with:
5
5
  *
@@ -14,7 +14,7 @@ import type { LoggerOptions, LoggerScope } from "./types.js";
14
14
  * `logError`, `logIncident`, etc.), a Morgan-compatible HTTP stream, and a
15
15
  * `scope()` method for deriving new loggers with extended metadata.
16
16
  */
17
- export declare const createLogger: (directory: string, scope: LoggerScope, options: LoggerOptions) => {
17
+ export declare const createLogger: (targetDirectory: string, scope: LoggerScope, options: LoggerOptions) => {
18
18
  logError: (error: string | Error, context?: Record<string, unknown>) => void;
19
19
  logWarn: (message: string, context?: Record<string, unknown>) => void;
20
20
  logInfo: (message: string, context?: Record<string, unknown>) => void;
@@ -24,7 +24,8 @@ export declare const createLogger: (directory: string, scope: LoggerScope, optio
24
24
  createLoggerStream: () => {
25
25
  write: (message: string) => void;
26
26
  };
27
- scope: (partial: Partial<LoggerScope>) => /*elided*/ any;
27
+ scope: (partial: Partial<LoggerScope>) => Promise<void>;
28
+ close: () => Promise<void>;
28
29
  logger: winston.Logger;
29
30
  };
30
31
  //# sourceMappingURL=create-logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-logger.d.ts","sourceRoot":"","sources":["../src/create-logger.ts"],"names":[],"mappings":"AAUA,OAAO,OAAO,MAAM,SAAS,CAAC;AAO9B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAY,MAAM,YAAY,CAAC;AAmCvE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GACrB,WAAW,MAAM,EACjB,OAAO,WAAW,EAClB,SAAS,aAAa;sBAkJP,MAAM,GAAG,KAAK,YACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;uBAGjB,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;uBAGxC,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;wBAGvC,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;2BAGrC,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;yBAG1C,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;yBAIxC,MAAM;;qBAaV,OAAO,CAAC,WAAW,CAAC;;CAK5C,CAAC"}
1
+ {"version":3,"file":"create-logger.d.ts","sourceRoot":"","sources":["../src/create-logger.ts"],"names":[],"mappings":"AAUA,OAAO,OAAO,MAAM,SAAS,CAAC;AAO9B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAY,MAAM,YAAY,CAAC;AAoCvE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GACrB,iBAAiB,MAAM,EACvB,OAAO,WAAW,EAClB,SAAS,aAAa;sBAwKA,MAAM,GAAG,KAAK,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;uBAG/C,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;uBAGxC,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;wBAGvC,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;2BAGrC,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;yBAG1C,MAAM,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;yBAIxC,MAAM;;qBA1CK,OAAO,CAAC,WAAW,CAAC;;;CAsD3D,CAAC"}
@@ -1,7 +1,8 @@
1
- import DailyRotateFile from "winston-daily-rotate-file";
2
- import winston from "winston";
1
+ import DailyRotateFile from 'winston-daily-rotate-file';
2
+ import winston from 'winston';
3
3
  const { combine, timestamp, errors, colorize, json } = winston.format;
4
- import { redact, stripAnsi } from "./utilities.js";
4
+ import { redact, stripAnsi } from './utilities.js';
5
+ import { createDirectory } from './create-directory.js';
5
6
  /* -------------------------------------------------------------------------- *\
6
7
  |* Initialize Variables
7
8
  \* -------------------------------------------------------------------------- */
@@ -21,13 +22,13 @@ const customLevels = Object.freeze({
21
22
  debug: 6,
22
23
  });
23
24
  const customColors = Object.freeze({
24
- critical: "magenta",
25
- error: "red",
26
- warn: "yellow",
27
- info: "green",
28
- http: "blue",
29
- change: "cyan",
30
- debug: "gray",
25
+ critical: 'magenta',
26
+ error: 'red',
27
+ warn: 'yellow',
28
+ info: 'green',
29
+ http: 'blue',
30
+ change: 'cyan',
31
+ debug: 'gray',
31
32
  });
32
33
  winston.addColors(customColors);
33
34
  /* -------------------------------------------------------------------------- *\
@@ -47,84 +48,84 @@ winston.addColors(customColors);
47
48
  * `logError`, `logIncident`, etc.), a Morgan-compatible HTTP stream, and a
48
49
  * `scope()` method for deriving new loggers with extended metadata.
49
50
  */
50
- export const createLogger = (directory, scope, options) => {
51
- const { tenant, service, environment, user, correlationId, requestId } = scope;
51
+ export const createLogger = (targetDirectory, scope, options) => {
52
+ let currentScope = { ...scope };
53
+ let currentDirectory = createDirectory(targetDirectory, currentScope);
54
+ let closed = false;
52
55
  const sensitiveKeys = [
53
- "password",
54
- "token",
55
- "secret",
56
- "authorization",
56
+ 'password',
57
+ 'token',
58
+ 'secret',
59
+ 'authorization',
57
60
  ...(options.sensitiveKeys ?? []),
58
61
  ];
59
- const retention = options.retention ?? "14d";
60
- const transports = [];
61
- if (!options.disableFileTransports) {
62
- transports.push(new DailyRotateFile({
63
- dirname: directory,
64
- filename: options.requestLog,
65
- datePattern: "YYYY-MM-DD",
66
- level: "http",
67
- zippedArchive: true,
68
- maxFiles: retention,
69
- format: combine(winston.format((log) => log.level === "http" ? log : false)(), timestamp(), json()),
70
- }));
71
- transports.push(new DailyRotateFile({
72
- dirname: directory,
73
- filename: options.appLog,
74
- datePattern: "YYYY-MM-DD",
75
- level: options.level,
76
- zippedArchive: true,
77
- maxFiles: retention,
78
- format: combine(errors({ stack: environment !== "production" }), timestamp(), json()),
79
- }));
80
- if (options.incidentLog) {
62
+ const retention = options.retention ?? '14d';
63
+ const buildTransports = (dir) => {
64
+ const transports = [];
65
+ if (!options.disableFileTransports) {
81
66
  transports.push(new DailyRotateFile({
82
- dirname: directory,
83
- filename: options.incidentLog,
84
- datePattern: "YYYY-MM-DD",
85
- level: "critical",
67
+ dirname: dir,
68
+ filename: options.requestLog,
69
+ datePattern: 'YYYY-MM-DD',
70
+ level: 'http',
86
71
  zippedArchive: true,
87
72
  maxFiles: retention,
88
- format: combine(winston.format((log) => log.level === "critical" ? log : false)(), timestamp(), json()),
73
+ format: combine(winston.format((log) => (log.level === 'http' ? log : false))(), timestamp(), json()),
89
74
  }));
90
- }
91
- if (options.changeLog) {
92
75
  transports.push(new DailyRotateFile({
93
- dirname: directory,
94
- filename: options.changeLog,
95
- datePattern: "YYYY-MM-DD",
96
- level: "change",
76
+ dirname: dir,
77
+ filename: options.appLog,
78
+ datePattern: 'YYYY-MM-DD',
79
+ level: options.level,
97
80
  zippedArchive: true,
98
81
  maxFiles: retention,
99
- format: combine(winston.format((log) => log.level === "change" ? log : false)(), timestamp(), json()),
82
+ format: combine(errors({ stack: scope.environment !== 'production' }), timestamp(), json()),
83
+ }));
84
+ if (options.incidentLog) {
85
+ transports.push(new DailyRotateFile({
86
+ dirname: dir,
87
+ filename: options.incidentLog,
88
+ datePattern: 'YYYY-MM-DD',
89
+ level: 'critical',
90
+ zippedArchive: true,
91
+ maxFiles: retention,
92
+ format: combine(winston.format((log) => (log.level === 'critical' ? log : false))(), timestamp(), json()),
93
+ }));
94
+ }
95
+ if (options.changeLog) {
96
+ transports.push(new DailyRotateFile({
97
+ dirname: dir,
98
+ filename: options.changeLog,
99
+ datePattern: 'YYYY-MM-DD',
100
+ level: 'change',
101
+ zippedArchive: true,
102
+ maxFiles: retention,
103
+ format: combine(winston.format((log) => (log.level === 'change' ? log : false))(), timestamp(), json()),
104
+ }));
105
+ }
106
+ }
107
+ if (options.logToConsole) {
108
+ transports.push(new winston.transports.Console({
109
+ format: combine(colorize(), timestamp()),
100
110
  }));
101
111
  }
102
- }
103
- if (options.logToConsole) {
104
- transports.push(new winston.transports.Console({
105
- format: combine(colorize(), timestamp()),
106
- }));
107
- }
108
- if (options.extraTransports?.length) {
109
- transports.push(...options.extraTransports);
110
- }
112
+ if (options.extraTransports?.length) {
113
+ transports.push(...options.extraTransports);
114
+ }
115
+ return transports;
116
+ };
111
117
  const loggerInstance = winston.createLogger({
112
118
  levels: customLevels,
113
119
  level: options.level,
114
- transports,
120
+ transports: buildTransports(currentDirectory),
115
121
  defaultMeta: {
116
- tenant,
117
- service,
118
- environment,
119
- user,
120
- correlationId,
121
- requestId,
122
+ ...currentScope,
122
123
  pid: process.pid,
123
124
  },
124
125
  });
125
126
  const log = (level, message, context = {}) => {
126
127
  const safeContext = redact(context, sensitiveKeys);
127
- const includeStack = environment !== "production";
128
+ const includeStack = currentScope.environment !== 'production';
128
129
  loggerInstance.log(level, message instanceof Error
129
130
  ? {
130
131
  message: message.message,
@@ -133,27 +134,47 @@ export const createLogger = (directory, scope, options) => {
133
134
  }
134
135
  : { message, ...safeContext });
135
136
  };
137
+ const close = async () => {
138
+ if (closed)
139
+ return;
140
+ closed = true;
141
+ await Promise.all(loggerInstance.transports.map((t) => new Promise((resolve) => {
142
+ t.on('finish', resolve);
143
+ t.end();
144
+ })));
145
+ loggerInstance.clear();
146
+ };
147
+ const scopeRebind = async (partial) => {
148
+ const newScope = { ...currentScope, ...partial };
149
+ const newDirectory = createDirectory(targetDirectory, newScope);
150
+ if (newDirectory !== currentDirectory) {
151
+ await close();
152
+ closed = false;
153
+ const newTransports = buildTransports(newDirectory);
154
+ newTransports.forEach((t) => loggerInstance.add(t));
155
+ currentDirectory = newDirectory;
156
+ }
157
+ currentScope = newScope;
158
+ loggerInstance.defaultMeta = { ...currentScope, pid: process.pid };
159
+ };
160
+ /* ----------------------------------------------------------------------
161
+ |* Return Public API
162
+ ---------------------------------------------------------------------- */
136
163
  return {
137
- logError: (error, context = {}) => log("error", error, context),
138
- logWarn: (message, context = {}) => log("warn", message, context),
139
- logInfo: (message, context = {}) => log("info", message, context),
140
- logDebug: (message, context = {}) => log("debug", message, context),
141
- logIncident: (message, context = {}) => log("critical", message, { category: "incident", ...context }),
142
- logChange: (message, context = {}) => log("change", message, { category: "change", ...context }),
164
+ logError: (error, context = {}) => log('error', error, context),
165
+ logWarn: (message, context = {}) => log('warn', message, context),
166
+ logInfo: (message, context = {}) => log('info', message, context),
167
+ logDebug: (message, context = {}) => log('debug', message, context),
168
+ logIncident: (message, context = {}) => log('critical', message, { category: 'incident', ...context }),
169
+ logChange: (message, context = {}) => log('change', message, { category: 'change', ...context }),
143
170
  createLoggerStream: () => ({
144
171
  write: (message) => {
145
- const clean = stripAnsi(message).replace(/\n$/, "");
146
- log("http", clean, {
147
- source: "morgan",
148
- service,
149
- tenant,
150
- environment,
151
- correlationId,
152
- requestId,
153
- });
172
+ const clean = stripAnsi(message).replace(/\n$/, '');
173
+ log('http', clean, { source: 'morgan', ...currentScope });
154
174
  },
155
175
  }),
156
- scope: (partial) => createLogger(directory, { ...scope, ...partial }, options),
176
+ scope: scopeRebind,
177
+ close,
157
178
  logger: loggerInstance,
158
179
  };
159
180
  };
@@ -1 +1 @@
1
- {"version":3,"file":"create-logger.js","sourceRoot":"","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EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;YAC9D,CAAC;SACJ,CAAC;QAEF,KAAK,EAAE,WAAW;QAElB,KAAK;QAEL,MAAM,EAAE,cAAc;KACzB,CAAC;AACN,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /** ------------------------------------------------------------------------
2
2
  |* @package @glassops/scribe
3
- |* @version 1.0.0
3
+ |* @version 1.0.2
4
4
  |* @see https://www.jane-io.com
5
5
  |* @license Apache-2.0
6
6
  |* -------------------------------------------------------------------------
@@ -13,16 +13,16 @@
13
13
  /**
14
14
  * Public authoring contracts for configuring logger scope and behavior.
15
15
  */
16
- export type { LoggerScope, LoggerOptions, LogLevel } from "./types.js";
16
+ export type { LoggerScope, LoggerOptions, LogLevel } from './types.js';
17
17
  /**
18
18
  * Pure, deterministic entrypoints for initializing the log directory and
19
19
  * constructing a scoped logger instance. These are the primary runtime APIs.
20
20
  */
21
- export { createDirectory } from "./create-directory.js";
22
- export { createLogger } from "./create-logger.js";
21
+ export { createDirectory } from './create-directory.js';
22
+ export { createLogger } from './create-logger.js';
23
23
  /**
24
24
  * Internal helpers exposed for advanced use cases. These functions are pure
25
25
  * and side‑effect‑free, but not required for normal operation.
26
26
  */
27
- export { redact, safe, stripAnsi } from "./utilities.js";
27
+ export { redact, safe, stripAnsi } from './utilities.js';
28
28
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /** ------------------------------------------------------------------------
2
2
  |* @package @glassops/scribe
3
- |* @version 1.0.0
3
+ |* @version 1.0.2
4
4
  |* @see https://www.jane-io.com
5
5
  |* @license Apache-2.0
6
6
  |* -------------------------------------------------------------------------
@@ -17,8 +17,8 @@
17
17
  * Pure, deterministic entrypoints for initializing the log directory and
18
18
  * constructing a scoped logger instance. These are the primary runtime APIs.
19
19
  */
20
- export { createDirectory } from "./create-directory.js";
21
- export { createLogger } from "./create-logger.js";
20
+ export { createDirectory } from './create-directory.js';
21
+ export { createLogger } from './create-logger.js';
22
22
  /* --------------------------------------------------------------------------
23
23
  |* Utilities
24
24
  \* -------------------------------------------------------------------------- */
@@ -26,5 +26,5 @@ export { createLogger } from "./create-logger.js";
26
26
  * Internal helpers exposed for advanced use cases. These functions are pure
27
27
  * and side‑effect‑free, but not required for normal operation.
28
28
  */
29
- export { redact, safe, stripAnsi } from "./utilities.js";
29
+ export { redact, safe, stripAnsi } from './utilities.js';
30
30
  //# sourceMappingURL=index.js.map
@@ -23,13 +23,5 @@ export declare const safe: (value: string) => string;
23
23
  * control characters.
24
24
  */
25
25
  export declare const stripAnsi: (log: string) => string;
26
- /**
27
- * Recursively removes sensitive fields from an input object. Supports nested
28
- * objects, arrays, and circular references. Sensitive keys are replaced with
29
- * "[REDACTED]". Buffers are replaced with "[Binary]" to avoid dumping raw
30
- * binary data into logs. All other values are preserved as‑is.
31
- *
32
- * This function never mutates the input and guarantees deterministic output.
33
- */
34
- export declare const redact: (input: unknown, sensitiveKeys: string[], seen?: WeakSet<object>) => unknown;
26
+ export declare const redact: (value: unknown, sensitiveKeys: string[], depth?: number, seen?: WeakSet<object>) => unknown;
35
27
  //# sourceMappingURL=utilities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;gFAUgF;AAChF;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,WACqB,CAAC;AAKxD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,WAEY,CAAC;AAKlD;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GACf,OAAO,OAAO,EACd,eAAe,MAAM,EAAE,EACvB,sBAAoB,KACrB,OA2BF,CAAC"}
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;gFAUgF;AAChF;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,WAajC,CAAC;AAKF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,WAEY,CAAC;AAiBlD,eAAO,MAAM,MAAM,GACf,OAAO,OAAO,EACd,eAAe,MAAM,EAAE,EACvB,cAAS,EACT,sBAA4B,KAC7B,OA4CF,CAAC"}
package/dist/utilities.js CHANGED
@@ -15,7 +15,18 @@
15
15
  * deterministic, cross‑platform directory names and prevents path traversal
16
16
  * or invalid characters from entering the log directory grammar.
17
17
  */
18
- export const safe = (value) => value.toLowerCase().replace(/[^a-zA-Z0-9-_]/g, "-");
18
+ export const safe = (value) => {
19
+ const result = value
20
+ .toLowerCase()
21
+ .replace(/[^a-zA-Z0-9-_]/g, '-')
22
+ .trim()
23
+ .replace(/-+/g, '-')
24
+ .replace(/^-|-$/g, '');
25
+ if (!result) {
26
+ throw new Error('Invalid directory segment');
27
+ }
28
+ return result;
29
+ };
19
30
  /* -------------------------------------------------------------------------- *\
20
31
  |* Strip ANSI
21
32
  \* -------------------------------------------------------------------------- */
@@ -27,7 +38,7 @@ export const safe = (value) => value.toLowerCase().replace(/[^a-zA-Z0-9-_]/g, "-
27
38
  */
28
39
  export const stripAnsi = (log) =>
29
40
  // eslint-disable-next-line no-control-regex
30
- log.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "");
41
+ log.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, '');
31
42
  /* -------------------------------------------------------------------------- *\
32
43
  |* Redact
33
44
  \* -------------------------------------------------------------------------- */
@@ -39,29 +50,44 @@ log.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "");
39
50
  *
40
51
  * This function never mutates the input and guarantees deterministic output.
41
52
  */
42
- export const redact = (input, sensitiveKeys, seen = new WeakSet()) => {
43
- if (Array.isArray(input)) {
44
- return input.map((value) => redact(value, sensitiveKeys, seen));
53
+ const MAX_DEPTH = 6;
54
+ const MAX_KEYS = 100;
55
+ const MAX_STRING_LENGTH = 10_000;
56
+ export const redact = (value, sensitiveKeys, depth = 0, seen = new WeakSet()) => {
57
+ if (value === null || value === undefined) {
58
+ return value;
59
+ }
60
+ if (typeof value === 'object') {
61
+ if (seen.has(value)) {
62
+ return '[Circular]';
63
+ }
64
+ seen.add(value);
65
+ }
66
+ if (depth > MAX_DEPTH) {
67
+ return '[MaxDepthExceeded]';
45
68
  }
46
- if (input && typeof input === "object") {
47
- if (seen.has(input))
48
- return "[Circular]";
49
- seen.add(input);
50
- const clone = {};
51
- for (const [key, value] of Object.entries(input)) {
52
- const normalized = sensitiveKeys.map((k) => k.toLowerCase());
53
- if (normalized.includes(key.toLowerCase())) {
54
- clone[key] = "[REDACTED]";
55
- }
56
- else if (value instanceof Buffer) {
57
- clone[key] = "[Binary]";
58
- }
59
- else {
60
- clone[key] = redact(value, sensitiveKeys, seen);
61
- }
69
+ if (typeof value === 'string') {
70
+ return value.length > MAX_STRING_LENGTH
71
+ ? value.slice(0, MAX_STRING_LENGTH) + '...[Truncated]'
72
+ : value;
73
+ }
74
+ if (typeof value !== 'object') {
75
+ return value;
76
+ }
77
+ if (Array.isArray(value)) {
78
+ return value.slice(0, MAX_KEYS).map((item) => redact(item, sensitiveKeys, depth + 1, seen));
79
+ }
80
+ const output = {};
81
+ const entries = Object.entries(value).slice(0, MAX_KEYS);
82
+ const normalizedKeys = new Set(sensitiveKeys.map((k) => k.toLowerCase()));
83
+ for (const [key, val] of entries) {
84
+ if (normalizedKeys.has(key.toLowerCase())) {
85
+ output[key] = '[REDACTED]';
86
+ }
87
+ else {
88
+ output[key] = redact(val, sensitiveKeys, depth + 1, seen);
62
89
  }
63
- return clone;
64
90
  }
65
- return input;
91
+ return output;
66
92
  };
67
93
  //# sourceMappingURL=utilities.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;gFAUgF;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AE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAE1E,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC;QAC/B,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;YACxC,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC;QAC/B,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;QAC9D,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glassops/scribe",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Deterministic, multi-tenant logging subsystem for GlassOps services.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "GlassOps Limited",