@eventuras/fides-auth 0.3.1 → 0.4.0
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/README.md +16 -3
- package/dist/logger.d.ts +6 -3
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +66 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -231,15 +231,22 @@ import {
|
|
|
231
231
|
|
|
232
232
|
### Pluggable Logging (`/logger`)
|
|
233
233
|
|
|
234
|
-
The library
|
|
234
|
+
The library writes newline-delimited JSON to `console.<level>` by default — interoperable with Loki, Grafana, Datadog, and other log shippers without any setup. Plug in a richer logger at startup if you want OpenTelemetry, redaction, or shared formatting with the rest of your app:
|
|
235
235
|
|
|
236
236
|
```typescript
|
|
237
237
|
import { configureLogger } from "@eventuras/fides-auth/logger";
|
|
238
238
|
|
|
239
|
-
// Example: plug in
|
|
239
|
+
// Example: plug in @eventuras/logger
|
|
240
|
+
import { Logger } from "@eventuras/logger";
|
|
241
|
+
configureLogger({
|
|
242
|
+
create(options) {
|
|
243
|
+
return Logger.create(options);
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// Or plug in pino directly
|
|
240
248
|
import pino from "pino";
|
|
241
249
|
const pinoInstance = pino();
|
|
242
|
-
|
|
243
250
|
configureLogger({
|
|
244
251
|
create({ namespace, context }) {
|
|
245
252
|
return pinoInstance.child({ namespace, ...context });
|
|
@@ -249,6 +256,12 @@ configureLogger({
|
|
|
249
256
|
|
|
250
257
|
Any object implementing `{ debug, info, warn, error }` works — pino, winston, bunyan, or your own.
|
|
251
258
|
|
|
259
|
+
The default JSONL output looks like:
|
|
260
|
+
|
|
261
|
+
```json
|
|
262
|
+
{"level":"info","time":"2026-04-15T19:40:57.300Z","namespace":"fides-auth:oauth","msg":"PKCE parameters generated"}
|
|
263
|
+
```
|
|
264
|
+
|
|
252
265
|
### Vipps Login Provider (`/providers/vipps`)
|
|
253
266
|
|
|
254
267
|
```typescript
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pluggable logger for fides-auth.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* The default writes newline-delimited JSON to `console.<level>` so output
|
|
5
|
+
* is interoperable with Loki / Grafana / Datadog out of the box, even when
|
|
6
|
+
* the consumer hasn't wired in a structured logger. Users can plug their
|
|
7
|
+
* own backend (pino, winston, @eventuras/logger, ...) via `configureLogger()`.
|
|
6
8
|
*
|
|
7
9
|
* @example
|
|
8
|
-
* // Use default console logger (no setup needed)
|
|
10
|
+
* // Use default JSONL console logger (no setup needed)
|
|
9
11
|
* import { createLogger } from '@eventuras/fides-auth/logger';
|
|
10
12
|
* const logger = createLogger({ namespace: 'my-app:auth' });
|
|
11
13
|
* logger.info('Authentication successful');
|
|
14
|
+
* // → {"level":"info","time":"…","namespace":"my-app:auth","msg":"Authentication successful"}
|
|
12
15
|
*
|
|
13
16
|
* @example
|
|
14
17
|
* // Plug in pino
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnE,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClE,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpE;AAED,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,gGAAgG;AAChG,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAAC;CAClD;AAkID;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAGjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAkBrE"}
|
package/dist/logger.js
CHANGED
|
@@ -1,46 +1,91 @@
|
|
|
1
1
|
//#region src/logger.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
function e(e) {
|
|
3
|
+
return e instanceof Error ? {
|
|
4
|
+
name: e.name,
|
|
5
|
+
message: e.message,
|
|
6
|
+
stack: e.stack
|
|
7
|
+
} : e;
|
|
8
|
+
}
|
|
9
|
+
var t = new Set([
|
|
10
|
+
"level",
|
|
11
|
+
"time",
|
|
12
|
+
"namespace"
|
|
13
|
+
]);
|
|
14
|
+
function n(t) {
|
|
15
|
+
let n = /* @__PURE__ */ new WeakSet();
|
|
16
|
+
try {
|
|
17
|
+
return JSON.stringify(t, (t, r) => {
|
|
18
|
+
if (r instanceof Error) return e(r);
|
|
19
|
+
if (typeof r == "bigint") return r.toString();
|
|
20
|
+
if (typeof r == "object" && r) {
|
|
21
|
+
if (n.has(r)) return "[Circular]";
|
|
22
|
+
n.add(r);
|
|
23
|
+
}
|
|
24
|
+
return r;
|
|
25
|
+
});
|
|
26
|
+
} catch {
|
|
27
|
+
return JSON.stringify({
|
|
28
|
+
level: t.level,
|
|
29
|
+
time: t.time,
|
|
30
|
+
namespace: t.namespace,
|
|
31
|
+
msg: typeof t.msg == "string" ? t.msg : "[unserializable log entry]",
|
|
32
|
+
_serializeError: !0
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var r = class {
|
|
4
37
|
constructor(e, t) {
|
|
5
|
-
this.
|
|
38
|
+
this.namespace = e, this.context = t;
|
|
39
|
+
}
|
|
40
|
+
write(r, i, a, o) {
|
|
41
|
+
if (a === void 0 && o === void 0) return;
|
|
42
|
+
let s = {
|
|
43
|
+
level: i,
|
|
44
|
+
time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
45
|
+
namespace: this.namespace
|
|
46
|
+
};
|
|
47
|
+
if (this.context) for (let [e, n] of Object.entries(this.context)) t.has(e) || (s[e] = n);
|
|
48
|
+
if (typeof a == "string") s.msg = a;
|
|
49
|
+
else if (o !== void 0 && (s.msg = o), a) for (let [e, n] of Object.entries(a)) t.has(e) || (s[e] = n);
|
|
50
|
+
s.error !== void 0 && (s.error = e(s.error)), console[r](n(s));
|
|
6
51
|
}
|
|
7
52
|
debug(e, t) {
|
|
8
|
-
|
|
53
|
+
this.write("debug", "debug", e, t);
|
|
9
54
|
}
|
|
10
55
|
info(e, t) {
|
|
11
|
-
|
|
56
|
+
this.write("info", "info", e, t);
|
|
12
57
|
}
|
|
13
58
|
warn(e, t) {
|
|
14
|
-
|
|
59
|
+
this.write("warn", "warn", e, t);
|
|
15
60
|
}
|
|
16
61
|
error(e, t) {
|
|
17
|
-
|
|
62
|
+
this.write("error", "error", e, t);
|
|
18
63
|
}
|
|
19
|
-
},
|
|
20
|
-
return new e
|
|
21
|
-
} },
|
|
22
|
-
function
|
|
23
|
-
|
|
64
|
+
}, i = { create({ namespace: e, context: t }) {
|
|
65
|
+
return new r(e, t);
|
|
66
|
+
} }, a = 0;
|
|
67
|
+
function o(e) {
|
|
68
|
+
i = e, a++;
|
|
24
69
|
}
|
|
25
|
-
function
|
|
26
|
-
let
|
|
27
|
-
function
|
|
28
|
-
return (
|
|
70
|
+
function s(e) {
|
|
71
|
+
let t = null, n = -1;
|
|
72
|
+
function r() {
|
|
73
|
+
return (t === null || n !== a) && (t = i.create(e), n = a), t;
|
|
29
74
|
}
|
|
30
75
|
return {
|
|
31
76
|
debug(e, t) {
|
|
32
|
-
|
|
77
|
+
r().debug(e, t);
|
|
33
78
|
},
|
|
34
79
|
info(e, t) {
|
|
35
|
-
|
|
80
|
+
r().info(e, t);
|
|
36
81
|
},
|
|
37
82
|
warn(e, t) {
|
|
38
|
-
|
|
83
|
+
r().warn(e, t);
|
|
39
84
|
},
|
|
40
85
|
error(e, t) {
|
|
41
|
-
|
|
86
|
+
r().error(e, t);
|
|
42
87
|
}
|
|
43
88
|
};
|
|
44
89
|
}
|
|
45
90
|
//#endregion
|
|
46
|
-
export {
|
|
91
|
+
export { o as configureLogger, s as createLogger };
|