@eventuras/fides-auth 0.3.1 → 0.5.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
@@ -5,6 +5,7 @@ Framework-agnostic OAuth 2.0 / OpenID Connect library with PKCE, encrypted sessi
5
5
  ## Features
6
6
 
7
7
  - **OAuth 2.0 + OIDC** — Authorization Code with PKCE, token refresh, client credentials
8
+ - **Pushed Authorization Requests** — Opt-in RFC 9126 support (`usePar`) when the provider advertises it
8
9
  - **Dual environment** — Node.js (`openid-client`) and browser (Web Crypto) entry points
9
10
  - **Encrypted sessions** — AES-256-GCM encrypted JWTs for secure session storage
10
11
  - **Rate limiting** — Generic token-bucket algorithm, ready for login protection
@@ -123,6 +124,8 @@ Full OIDC flows using `openid-client`:
123
124
  import {
124
125
  buildPKCEOptions,
125
126
  buildAuthorizationUrl,
127
+ buildAuthorizationUrlWithPAR,
128
+ discoverAndBuildAuthorizationUrl,
126
129
  exchangeAuthorizationCode,
127
130
  refreshAccessToken,
128
131
  extractUserFromTokens,
@@ -133,6 +136,43 @@ import {
133
136
  } from "@eventuras/fides-auth/oauth";
134
137
  ```
135
138
 
139
+ #### Pushed Authorization Requests (PAR, RFC 9126)
140
+
141
+ Opt in by setting `usePar: true` on your `OAuthConfig`. The convenience
142
+ helper `discoverAndBuildAuthorizationUrl` then posts the authorization
143
+ parameters to the provider's PAR endpoint and returns a URL containing
144
+ only `client_id` and `request_uri`:
145
+
146
+ ```typescript
147
+ const oauthConfig = {
148
+ issuer: "https://auth.example.com",
149
+ clientId: "your-client-id",
150
+ clientSecret: "your-client-secret",
151
+ redirect_uri: "https://app.example.com/callback",
152
+ scope: "openid profile email offline_access",
153
+ usePar: true,
154
+ };
155
+
156
+ const pkce = await buildPKCEOptions(oauthConfig);
157
+ const authUrl = await discoverAndBuildAuthorizationUrl(oauthConfig, pkce);
158
+ // redirect user to authUrl
159
+ ```
160
+
161
+ Behaviour:
162
+
163
+ - `usePar: true` + provider advertises `pushed_authorization_request_endpoint` → uses PAR.
164
+ - `usePar: true` + provider does **not** advertise PAR → throws.
165
+ - `usePar` unset/false + provider advertises PAR → standard flow, with a
166
+ one-line `info` log noting that PAR is available but not enabled.
167
+ - `usePar` unset/false + no PAR endpoint → standard flow, no advisory.
168
+
169
+ If you already have a discovered `Configuration` you can call the
170
+ low-level wrapper directly:
171
+
172
+ ```typescript
173
+ const authUrl = await buildAuthorizationUrlWithPAR(config, pkce);
174
+ ```
175
+
136
176
  ### OAuth — Browser (`/oauth-browser`)
137
177
 
138
178
  Lightweight browser-only flows using Web Crypto:
@@ -231,15 +271,22 @@ import {
231
271
 
232
272
  ### Pluggable Logging (`/logger`)
233
273
 
234
- The library uses console logging by default. Plug in your preferred logger at startup:
274
+ 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
275
 
236
276
  ```typescript
237
277
  import { configureLogger } from "@eventuras/fides-auth/logger";
238
278
 
239
- // Example: plug in pino
279
+ // Example: plug in @eventuras/logger
280
+ import { Logger } from "@eventuras/logger";
281
+ configureLogger({
282
+ create(options) {
283
+ return Logger.create(options);
284
+ },
285
+ });
286
+
287
+ // Or plug in pino directly
240
288
  import pino from "pino";
241
289
  const pinoInstance = pino();
242
-
243
290
  configureLogger({
244
291
  create({ namespace, context }) {
245
292
  return pinoInstance.child({ namespace, ...context });
@@ -249,6 +296,12 @@ configureLogger({
249
296
 
250
297
  Any object implementing `{ debug, info, warn, error }` works — pino, winston, bunyan, or your own.
251
298
 
299
+ The default JSONL output looks like:
300
+
301
+ ```json
302
+ {"level":"info","time":"2026-04-15T19:40:57.300Z","namespace":"fides-auth:oauth","msg":"PKCE parameters generated"}
303
+ ```
304
+
252
305
  ### Vipps Login Provider (`/providers/vipps`)
253
306
 
254
307
  ```typescript