@eventuras/fides-auth 0.3.0 → 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 CHANGED
@@ -231,15 +231,22 @@ import {
231
231
 
232
232
  ### Pluggable Logging (`/logger`)
233
233
 
234
- The library uses console logging by default. Plug in your preferred logger at startup:
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 pino
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
@@ -667,7 +667,7 @@ async function ht(e, t = oe) {
667
667
  return n;
668
668
  }
669
669
  var H = Symbol(), gt = Symbol(), U, _t;
670
- (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (_t = "openid-client/v6.8.2", U = { "user-agent": _t });
670
+ (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (_t = "openid-client/v6.8.3", U = { "user-agent": _t });
671
671
  var W = (e) => vt.get(e), vt, yt;
672
672
  function bt(e) {
673
673
  return e === void 0 ? (yt ||= /* @__PURE__ */ new WeakMap(), (e, t, n, r) => {
package/dist/logger.d.ts CHANGED
@@ -1,14 +1,17 @@
1
1
  /**
2
2
  * Pluggable logger for fides-auth.
3
3
  *
4
- * By default, uses a console-based logger. Users can provide their own
5
- * implementation (pino, winston, etc.) via `configureLogger()`.
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
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;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,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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
- var e = class {
3
- prefix;
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.prefix = `[${e}]${t && Object.keys(t).length > 0 ? ` ${JSON.stringify(t)}` : ""}`;
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
- typeof e == "string" ? console.debug(this.prefix, e) : t ? console.debug(this.prefix, t, e) : e && console.debug(this.prefix, e);
53
+ this.write("debug", "debug", e, t);
9
54
  }
10
55
  info(e, t) {
11
- typeof e == "string" ? console.info(this.prefix, e) : t ? console.info(this.prefix, t, e) : e && console.info(this.prefix, e);
56
+ this.write("info", "info", e, t);
12
57
  }
13
58
  warn(e, t) {
14
- typeof e == "string" ? console.warn(this.prefix, e) : t ? console.warn(this.prefix, t, e) : e && console.warn(this.prefix, e);
59
+ this.write("warn", "warn", e, t);
15
60
  }
16
61
  error(e, t) {
17
- typeof e == "string" ? console.error(this.prefix, e) : t ? console.error(this.prefix, t, e) : e && console.error(this.prefix, e);
62
+ this.write("error", "error", e, t);
18
63
  }
19
- }, t = { create({ namespace: t, context: n }) {
20
- return new e(t, n);
21
- } }, n = 0;
22
- function r(e) {
23
- t = e, n++;
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 i(e) {
26
- let r = null, i = -1;
27
- function a() {
28
- return (r === null || i !== n) && (r = t.create(e), i = n), r;
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
- a().debug(e, t);
77
+ r().debug(e, t);
33
78
  },
34
79
  info(e, t) {
35
- a().info(e, t);
80
+ r().info(e, t);
36
81
  },
37
82
  warn(e, t) {
38
- a().warn(e, t);
83
+ r().warn(e, t);
39
84
  },
40
85
  error(e, t) {
41
- a().error(e, t);
86
+ r().error(e, t);
42
87
  }
43
88
  };
44
89
  }
45
90
  //#endregion
46
- export { r as configureLogger, i as createLogger };
91
+ export { o as configureLogger, s as createLogger };
package/dist/oauth.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createLogger as e } from "./logger.js";
2
2
  import { t } from "./decode_jwt-1J26fl4I.js";
3
- import { a as n, c as r, i, n as a, o, r as s, s as c, t as l } from "./build-CNL3v39v.js";
3
+ import { a as n, c as r, i, n as a, o, r as s, s as c, t as l } from "./build-BnXr85C9.js";
4
4
  //#region src/oauth.ts
5
5
  var u = e({ namespace: "fides-auth:oauth" }), d = "openid profile email offline_access";
6
6
  async function f(e, t) {
@@ -1,5 +1,5 @@
1
1
  import { createLogger as e } from "../../logger.js";
2
- import { a as t, c as n, n as r, t as i } from "../../build-CNL3v39v.js";
2
+ import { a as t, c as n, n as r, t as i } from "../../build-BnXr85C9.js";
3
3
  import { buildAuthorizationUrl as a, buildPKCEOptions as o } from "../../oauth.js";
4
4
  //#region src/providers/vipps/types.ts
5
5
  var s = {
@@ -1,5 +1,5 @@
1
1
  import { createLogger as e } from "./logger.js";
2
- import { a as t, r as n, t as r } from "./build-CNL3v39v.js";
2
+ import { a as t, r as n, t as r } from "./build-BnXr85C9.js";
3
3
  //#region src/silent-login.ts
4
4
  var i = e({ namespace: "fides-auth:silent-login" });
5
5
  async function a(e, a = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventuras/fides-auth",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Framework-agnostic OAuth/OIDC authentication library with PKCE, session management, and pluggable logging",
5
5
  "keywords": [
6
6
  "oauth",
@@ -79,23 +79,24 @@
79
79
  "LICENSE",
80
80
  "README.md"
81
81
  ],
82
- "scripts": {
83
- "build": "vite build",
84
- "dev": "vite build --watch",
85
- "test": "vitest run",
86
- "test:watch": "vitest"
87
- },
88
82
  "dependencies": {
89
83
  "jose": "6.2.2",
90
- "openid-client": "^6.8.2"
84
+ "openid-client": "^6.8.3"
91
85
  },
92
86
  "devDependencies": {
93
- "@eventuras/typescript-config": "workspace:*",
94
- "@eventuras/vite-config": "workspace:*",
95
- "vite": "^8.0.3",
96
- "vitest": "^4.1.2"
87
+ "@types/node": "^25.6.0",
88
+ "vite": "^8.0.8",
89
+ "vitest": "^4.1.4",
90
+ "@eventuras/typescript-config": "1.0.0",
91
+ "@eventuras/vite-config": "0.2.1"
97
92
  },
98
93
  "engines": {
99
94
  "node": ">=18"
95
+ },
96
+ "scripts": {
97
+ "build": "vite build",
98
+ "dev": "vite build --watch",
99
+ "test": "vitest run",
100
+ "test:watch": "vitest"
100
101
  }
101
- }
102
+ }