@flink-app/oidc-plugin 0.14.3 → 2.0.0-alpha.100

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +485 -0
  2. package/README.md +23 -2
  3. package/dist/OidcPlugin.d.ts +1 -1
  4. package/dist/OidcPlugin.d.ts.map +1 -1
  5. package/dist/OidcPlugin.js +32 -18
  6. package/dist/OidcPluginOptions.d.ts +75 -8
  7. package/dist/OidcPluginOptions.d.ts.map +1 -1
  8. package/dist/OidcProviderConfig.d.ts +21 -1
  9. package/dist/OidcProviderConfig.d.ts.map +1 -1
  10. package/dist/handlers/CallbackOidc.d.ts.map +1 -1
  11. package/dist/handlers/CallbackOidc.js +50 -5
  12. package/dist/handlers/InitiateOidc.d.ts.map +1 -1
  13. package/dist/handlers/InitiateOidc.js +14 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/log.d.ts +27 -0
  17. package/dist/log.d.ts.map +1 -0
  18. package/dist/log.js +37 -0
  19. package/dist/providers/OidcProvider.d.ts +1 -1
  20. package/dist/providers/OidcProvider.d.ts.map +1 -1
  21. package/dist/providers/OidcProvider.js +46 -5
  22. package/dist/providers/ProviderRegistry.d.ts +2 -1
  23. package/dist/providers/ProviderRegistry.d.ts.map +1 -1
  24. package/dist/providers/ProviderRegistry.js +10 -2
  25. package/dist/schemas/CallbackRequest.d.ts +3 -6
  26. package/dist/schemas/CallbackRequest.d.ts.map +1 -1
  27. package/dist/schemas/InitiateRequest.d.ts +3 -6
  28. package/dist/schemas/InitiateRequest.d.ts.map +1 -1
  29. package/dist/schemas/OidcSession.d.ts +5 -0
  30. package/dist/schemas/OidcSession.d.ts.map +1 -1
  31. package/dist/utils/response-utils.d.ts +16 -5
  32. package/dist/utils/response-utils.d.ts.map +1 -1
  33. package/dist/utils/response-utils.js +31 -10
  34. package/examples/multi-provider.ts +1 -1
  35. package/package.json +8 -11
  36. package/spec/helpers/test-helpers.ts +14 -0
  37. package/spec/plugin/OidcPlugin.spec.ts +104 -3
  38. package/spec/providers/ProviderRegistry.spec.ts +8 -7
  39. package/spec/utils/response-utils.spec.ts +85 -0
  40. package/src/OidcPlugin.ts +54 -21
  41. package/src/OidcPluginOptions.ts +84 -9
  42. package/src/OidcProviderConfig.ts +23 -1
  43. package/src/handlers/CallbackOidc.ts +66 -5
  44. package/src/handlers/InitiateOidc.ts +19 -1
  45. package/src/index.ts +1 -1
  46. package/src/log.ts +33 -0
  47. package/src/providers/OidcProvider.ts +60 -7
  48. package/src/providers/ProviderRegistry.ts +22 -3
  49. package/src/schemas/CallbackRequest.ts +4 -6
  50. package/src/schemas/InitiateRequest.ts +3 -6
  51. package/src/schemas/OidcSession.ts +6 -0
  52. package/src/utils/response-utils.ts +53 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,490 @@
1
1
  # @flink-app/oidc-plugin
2
2
 
3
+ ## 2.0.0-alpha.100
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [6e8166a]
8
+ - @flink-app/flink@2.0.0-alpha.100
9
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.100
10
+
11
+ ## 2.0.0-alpha.99
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [ed9cd2c]
16
+ - @flink-app/flink@2.0.0-alpha.99
17
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.99
18
+
19
+ ## 2.0.0-alpha.98
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [2f4a132]
24
+ - @flink-app/flink@2.0.0-alpha.98
25
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.98
26
+
27
+ ## 2.0.0-alpha.97
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [eed6bc1]
32
+ - @flink-app/flink@2.0.0-alpha.97
33
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.97
34
+
35
+ ## 2.0.0-alpha.96
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies
40
+ - Updated dependencies [e431237]
41
+ - @flink-app/flink@2.0.0-alpha.96
42
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.96
43
+
44
+ ## 2.0.0-alpha.95
45
+
46
+ ### Patch Changes
47
+
48
+ - @flink-app/flink@2.0.0-alpha.95
49
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.95
50
+
51
+ ## 2.0.0-alpha.94
52
+
53
+ ### Patch Changes
54
+
55
+ - @flink-app/flink@2.0.0-alpha.94
56
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.94
57
+
58
+ ## 2.0.0-alpha.93
59
+
60
+ ### Patch Changes
61
+
62
+ - @flink-app/flink@2.0.0-alpha.93
63
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.93
64
+
65
+ ## 2.0.0-alpha.92
66
+
67
+ ### Patch Changes
68
+
69
+ - Updated dependencies [8d23d56]
70
+ - @flink-app/flink@2.0.0-alpha.92
71
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.92
72
+
73
+ ## 2.0.0-alpha.91
74
+
75
+ ### Minor Changes
76
+
77
+ - 1bdbc82: feat(oidc-plugin): add per-provider `useUserInfoEndpoint` config flag (default `true`) to disable UserInfo calls for IdPs where the endpoint is unreliable or redundant with ID token claims
78
+
79
+ ### Patch Changes
80
+
81
+ - @flink-app/flink@2.0.0-alpha.91
82
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.91
83
+
84
+ ## 2.0.0-alpha.90
85
+
86
+ ### Patch Changes
87
+
88
+ - e18a37b: Add raw IdP response trace logs and prune redundant debug logs
89
+ - Updated dependencies [0d84b5f]
90
+ - @flink-app/flink@2.0.0-alpha.90
91
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.90
92
+
93
+ ## 2.0.0-alpha.89
94
+
95
+ ### Patch Changes
96
+
97
+ - Fix OIDC trace logs
98
+ - @flink-app/flink@2.0.0-alpha.89
99
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.89
100
+
101
+ ## 2.0.0-alpha.88
102
+
103
+ ### Patch Changes
104
+
105
+ - 5f3919e: fix(oidc-plugin): use discovered userinfo endpoint in buildProfile when no manual endpoint is configured
106
+ - @flink-app/flink@2.0.0-alpha.88
107
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.88
108
+
109
+ ## 2.0.0-alpha.87
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies
114
+ - @flink-app/flink@2.0.0-alpha.87
115
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.87
116
+
117
+ ## 2.0.0-alpha.86
118
+
119
+ ### Patch Changes
120
+
121
+ - 4219f07: Add `tokenDelivery` option to control how the JWT is attached to the post-callback redirect URL. Defaults to `"fragment"` (unchanged — `#token=...` is still appended for browser flows where URL fragments are not sent to the server). Set to `"query"` for native mobile flows where iOS `ASWebAuthenticationSession` strips fragments from custom-scheme callbacks, or pass a function `({ redirectUrl, provider, metadata }) => "fragment" | "query"` to decide per-request when one app serves both web and native clients. The plugin makes no scheme-based assumptions — policy lives in the host app.
122
+ - @flink-app/flink@2.0.0-alpha.86
123
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.86
124
+
125
+ ## 2.0.0-alpha.85
126
+
127
+ ### Patch Changes
128
+
129
+ - Updated dependencies [179c085]
130
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.85
131
+ - @flink-app/flink@2.0.0-alpha.85
132
+
133
+ ## 2.0.0-alpha.84
134
+
135
+ ### Patch Changes
136
+
137
+ - @flink-app/flink@2.0.0-alpha.84
138
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.84
139
+
140
+ ## 2.0.0-alpha.83
141
+
142
+ ### Patch Changes
143
+
144
+ - Updated dependencies
145
+ - @flink-app/flink@2.0.0-alpha.83
146
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.83
147
+
148
+ ## 2.0.0-alpha.82
149
+
150
+ ### Patch Changes
151
+
152
+ - Add metadata passthrough support. Any query parameters prefixed with `meta.` on the initiate endpoint (e.g. `?meta.intent=admin&meta.source=mobile`) are collected, stripped of the prefix, stored in the session, and delivered to both `onAuthSuccess` and `onAuthError` callbacks as `metadata: Record<string, string>`. Empty object when no meta params are provided.
153
+ - @flink-app/flink@2.0.0-alpha.82
154
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.82
155
+
156
+ ## 2.0.0-alpha.81
157
+
158
+ ### Patch Changes
159
+
160
+ - @flink-app/flink@2.0.0-alpha.81
161
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.81
162
+
163
+ ## 2.0.0-alpha.80
164
+
165
+ ### Patch Changes
166
+
167
+ - Add flink.oidc named logger with debug instrumentation across init, provider resolution, and auth flow
168
+ - @flink-app/flink@2.0.0-alpha.80
169
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.80
170
+
171
+ ## 2.0.0-alpha.79
172
+
173
+ ### Patch Changes
174
+
175
+ - Expose redirectUri from session in onAuthSuccess and onAuthError callbacks, enabling multi-client redirect decisions
176
+ - @flink-app/flink@2.0.0-alpha.79
177
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.79
178
+
179
+ ## 2.0.0-alpha.78
180
+
181
+ ### Patch Changes
182
+
183
+ - Fix optional chaining on providers in handlers after making providers optional
184
+ - @flink-app/flink@2.0.0-alpha.78
185
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.78
186
+
187
+ ## 2.0.0-alpha.77
188
+
189
+ ### Minor Changes
190
+
191
+ - Make providers optional when providerLoader is configured, add TCtx generic for typed ctx in providerLoader and onAuthSuccess callbacks
192
+
193
+ ### Patch Changes
194
+
195
+ - @flink-app/flink@2.0.0-alpha.77
196
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.77
197
+
198
+ ## 2.0.0-alpha.76
199
+
200
+ ### Patch Changes
201
+
202
+ - Updated dependencies
203
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.76
204
+ - @flink-app/flink@2.0.0-alpha.76
205
+
206
+ ## 2.0.0-alpha.75
207
+
208
+ ### Patch Changes
209
+
210
+ - @flink-app/flink@2.0.0-alpha.75
211
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.75
212
+
213
+ ## 2.0.0-alpha.74
214
+
215
+ ### Patch Changes
216
+
217
+ - Updated dependencies
218
+ - Updated dependencies
219
+ - @flink-app/flink@2.0.0-alpha.74
220
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.74
221
+
222
+ ## 2.0.0-alpha.73
223
+
224
+ ### Patch Changes
225
+
226
+ - Updated dependencies
227
+ - @flink-app/flink@2.0.0-alpha.73
228
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.73
229
+
230
+ ## 2.0.0-alpha.72
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies
235
+ - @flink-app/flink@2.0.0-alpha.72
236
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.72
237
+
238
+ ## 2.0.0-alpha.71
239
+
240
+ ### Patch Changes
241
+
242
+ - @flink-app/flink@2.0.0-alpha.71
243
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.71
244
+
245
+ ## 2.0.0-alpha.70
246
+
247
+ ### Patch Changes
248
+
249
+ - @flink-app/flink@2.0.0-alpha.70
250
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.70
251
+
252
+ ## 2.0.0-alpha.69
253
+
254
+ ### Minor Changes
255
+
256
+ - feat(oidc-plugin): support public clients with PKCE-only authentication (no client secret)
257
+
258
+ `clientSecret` is now optional in `OidcProviderConfig`. When omitted, the plugin configures `openid-client` with `token_endpoint_auth_method: "none"` for public client flows. Added `tokenEndpointAuthMethod` option for explicit control. Encryption key derivation skips providers without a secret, and `storeTokens: true` requires an explicit `encryptionKey` when no provider has a client secret.
259
+
260
+ ### Patch Changes
261
+
262
+ - @flink-app/flink@2.0.0-alpha.69
263
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.69
264
+
265
+ ## 2.0.0-alpha.68
266
+
267
+ ### Patch Changes
268
+
269
+ - @flink-app/flink@2.0.0-alpha.68
270
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.68
271
+
272
+ ## 2.0.0-alpha.67
273
+
274
+ ### Patch Changes
275
+
276
+ - Updated dependencies [418cb54]
277
+ - Updated dependencies [70d574c]
278
+ - @flink-app/flink@2.0.0-alpha.67
279
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.67
280
+
281
+ ## 2.0.0-alpha.66
282
+
283
+ ### Patch Changes
284
+
285
+ - Updated dependencies [5593d26]
286
+ - @flink-app/flink@2.0.0-alpha.66
287
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.66
288
+
289
+ ## 2.0.0-alpha.65
290
+
291
+ ### Patch Changes
292
+
293
+ - @flink-app/flink@2.0.0-alpha.65
294
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.65
295
+
296
+ ## 2.0.0-alpha.64
297
+
298
+ ### Patch Changes
299
+
300
+ - Updated dependencies [95b99ee]
301
+ - @flink-app/flink@2.0.0-alpha.64
302
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.64
303
+
304
+ ## 2.0.0-alpha.63
305
+
306
+ ### Patch Changes
307
+
308
+ - Updated dependencies [810df2c]
309
+ - Updated dependencies [8dd0752]
310
+ - @flink-app/flink@2.0.0-alpha.63
311
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.63
312
+
313
+ ## 2.0.0-alpha.62
314
+
315
+ ### Patch Changes
316
+
317
+ - Updated dependencies
318
+ - @flink-app/flink@2.0.0-alpha.62
319
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.62
320
+
321
+ ## 2.0.0-alpha.61
322
+
323
+ ### Patch Changes
324
+
325
+ - @flink-app/flink@2.0.0-alpha.61
326
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.61
327
+
328
+ ## 2.0.0-alpha.60
329
+
330
+ ### Patch Changes
331
+
332
+ - @flink-app/flink@2.0.0-alpha.60
333
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.60
334
+
335
+ ## 2.0.0-alpha.59
336
+
337
+ ### Patch Changes
338
+
339
+ - Updated dependencies [dbc2119]
340
+ - @flink-app/flink@2.0.0-alpha.59
341
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.59
342
+
343
+ ## 2.0.0-alpha.58
344
+
345
+ ### Patch Changes
346
+
347
+ - Updated dependencies
348
+ - @flink-app/flink@2.0.0-alpha.58
349
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.58
350
+
351
+ ## 2.0.0-alpha.57
352
+
353
+ ### Patch Changes
354
+
355
+ - Updated dependencies [ef7f495]
356
+ - Updated dependencies [2d53aa4]
357
+ - Updated dependencies [b3cc5d1]
358
+ - Updated dependencies [d377fac]
359
+ - Updated dependencies [4ad44c0]
360
+ - Updated dependencies [90f80c7]
361
+ - Updated dependencies [f0887e7]
362
+ - Updated dependencies [68c46d3]
363
+ - Updated dependencies [4ad44c0]
364
+ - Updated dependencies
365
+ - @flink-app/flink@2.0.0-alpha.57
366
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.57
367
+
368
+ ## 2.0.0-alpha.56
369
+
370
+ ### Patch Changes
371
+
372
+ - Zod 3.x compat
373
+ - Updated dependencies
374
+ - Updated dependencies [0203256]
375
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.56
376
+ - @flink-app/flink@2.0.0-alpha.56
377
+
378
+ ## 2.0.0-alpha.55
379
+
380
+ ### Patch Changes
381
+
382
+ - Updated dependencies [3267206]
383
+ - Updated dependencies [497b7c2]
384
+ - Updated dependencies [3267206]
385
+ - @flink-app/flink@2.0.0-alpha.55
386
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.55
387
+
388
+ ## 2.0.0-alpha.53
389
+
390
+ ### Patch Changes
391
+
392
+ - Updated dependencies [669c806]
393
+ - @flink-app/flink@2.0.0-alpha.53
394
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.53
395
+
396
+ ## 2.0.0-alpha.52
397
+
398
+ ### Patch Changes
399
+
400
+ - Updated dependencies [fe9f8f2]
401
+ - @flink-app/flink@2.0.0-alpha.52
402
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.52
403
+
404
+ ## 2.0.0-alpha.51
405
+
406
+ ### Patch Changes
407
+
408
+ - fix: add peerDependencies to all plugins and adapters
409
+
410
+ **Breaking Change Prevention:**
411
+
412
+ - Added "@flink-app/flink": ">=2.0.0-alpha.0" as peerDependency to all plugins
413
+ - Fixed oidc-plugin peerDependencies from "workspace:\*" to proper version ranges
414
+ - Fixed oauth-plugin to include @flink-app/flink peerDependency
415
+
416
+ **JWT Auth Plugin Interface Fix:**
417
+
418
+ - Removed redundant createToken declaration from JwtAuthPlugin interface
419
+ - The method is already inherited from FlinkAuthPlugin, this fixes TypeScript type checking issues
420
+
421
+ **Why this matters:**
422
+
423
+ - Ensures only one version of @flink-app/flink exists in node_modules
424
+ - Prevents type conflicts when TypeScript resolves interfaces across packages
425
+ - Follows standard plugin architecture best practices (same pattern as React, Webpack, etc.)
426
+ - Package managers now warn if incompatible versions are installed
427
+
428
+ - Updated dependencies
429
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.51
430
+ - @flink-app/flink@2.0.0-alpha.51
431
+
432
+ ## 2.0.0-alpha.50
433
+
434
+ ### Patch Changes
435
+
436
+ - Updated dependencies
437
+ - @flink-app/flink@2.0.0-alpha.50
438
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.50
439
+
440
+ ## 2.0.0-alpha.49
441
+
442
+ ### Patch Changes
443
+
444
+ - Typescript include fix
445
+ - Updated dependencies
446
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.49
447
+ - @flink-app/flink@2.0.0-alpha.49
448
+
449
+ ## 2.0.0-alpha.48
450
+
451
+ ### Patch Changes
452
+
453
+ - Updated dependencies
454
+ - @flink-app/jwt-auth-plugin@2.0.0-alpha.48
455
+ - @flink-app/flink@2.0.0-alpha.48
456
+
457
+ ## 1.0.0
458
+
459
+ ### Minor Changes
460
+
461
+ - Align minor version, from now all packages in monorepo will have same version
462
+
463
+ ### Patch Changes
464
+
465
+ - ee21c29: Normalize query parameters to predictable string types
466
+
467
+ Query parameters are now automatically normalized to `string | string[]` types before reaching handlers:
468
+
469
+ - Single values: converted to strings (e.g., `?page=1` → `{ page: "1" }`)
470
+ - Repeated parameters: converted to string arrays (e.g., `?tag=a&tag=b` → `{ tag: ["a", "b"] }`)
471
+ - All types (numbers, booleans, etc.) from Express parser are converted to strings
472
+
473
+ **Breaking Change (Minor):**
474
+
475
+ - `Query` type changed from `{ [x: string]: string | string[] | undefined }` to `Record<string, string | string[]>`
476
+ - `Params` type changed from `Request["params"]` to explicit `Record<string, string>`
477
+ - Removed `undefined` from query/param types since normalization ensures values are never undefined
478
+ - Updated OAuth and OIDC plugin query type definitions to satisfy new Query constraint
479
+
480
+ This ensures predictable query and path parameter handling regardless of Express parser configuration. Handlers can reliably parse string values as needed using `Number()`, `parseInt()`, boolean comparisons, etc.
481
+
482
+ - Updated dependencies
483
+ - Updated dependencies [ee21c29]
484
+ - Updated dependencies [5c2ff97]
485
+ - @flink-app/flink@1.0.0
486
+ - @flink-app/jwt-auth-plugin@1.0.0
487
+
3
488
  ## 0.14.3
4
489
 
5
490
  ### Patch Changes
package/README.md CHANGED
@@ -203,6 +203,26 @@ await app.start();
203
203
  }
204
204
  ```
205
205
 
206
+ #### Disabling the UserInfo endpoint
207
+
208
+ By default, the plugin calls the UserInfo endpoint after token exchange to
209
+ enrich the profile with additional claims. Some IdPs either don't expose
210
+ extra claims beyond the ID token or return unreliable 5xx errors from
211
+ UserInfo. In those cases, set `useUserInfoEndpoint: false` on the provider
212
+ config to skip the UserInfo call entirely and build profiles from ID token
213
+ claims only:
214
+
215
+ ```typescript
216
+ {
217
+ issuer: "https://idp.acme.com",
218
+ clientId: "your-client-id",
219
+ clientSecret: "your-client-secret",
220
+ callbackUrl: "https://myapp.com/oidc/acme/callback",
221
+ discoveryUrl: "https://idp.acme.com/.well-known/openid-configuration",
222
+ useUserInfoEndpoint: false, // skip UserInfo; use ID token claims only
223
+ }
224
+ ```
225
+
206
226
  ### Callback Functions
207
227
 
208
228
  #### onAuthSuccess
@@ -500,7 +520,7 @@ onAuthSuccess: async ({ profile, claims }, ctx) => {
500
520
  subject: claims.sub,
501
521
  provider: "acme",
502
522
  });
503
- await ctx.repos.userRepo.updateOne(user._id, {
523
+ await ctx.repos.userRepo.updateById(user._id, {
504
524
  oidcConnections: user.oidcConnections,
505
525
  });
506
526
  } else {
@@ -552,7 +572,7 @@ onAuthSuccess: async ({ profile, claims }, ctx) => {
552
572
  });
553
573
  } else {
554
574
  // Update roles on each login
555
- await ctx.repos.userRepo.updateOne(user._id, { roles });
575
+ await ctx.repos.userRepo.updateById(user._id, { roles });
556
576
  }
557
577
 
558
578
  const token = await ctx.plugins.jwtAuth.createToken({ userId: user._id }, roles);
@@ -619,6 +639,7 @@ interface OidcProviderConfigDB {
619
639
  authorizationEndpoint?: string;
620
640
  tokenEndpoint?: string;
621
641
  userinfoEndpoint?: string;
642
+ useUserInfoEndpoint?: boolean; // default true
622
643
  jwksUri?: string;
623
644
  scope: string[];
624
645
  createdAt: Date;
@@ -73,5 +73,5 @@ import { OidcPluginOptions } from "./OidcPluginOptions";
73
73
  * });
74
74
  * ```
75
75
  */
76
- export declare function oidcPlugin(options: OidcPluginOptions): FlinkPlugin;
76
+ export declare function oidcPlugin<TCtx = any>(options: OidcPluginOptions<TCtx>): FlinkPlugin;
77
77
  //# sourceMappingURL=OidcPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OidcPlugin.d.ts","sourceRoot":"","sources":["../src/OidcPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAO,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAWxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,CA2MlE"}
1
+ {"version":3,"file":"OidcPlugin.d.ts","sourceRoot":"","sources":["../src/OidcPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAO,MAAM,kBAAkB,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAWxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,wBAAgB,UAAU,CAAC,IAAI,GAAG,GAAG,EAAE,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC,GAAG,WAAW,CA2OpF"}
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.oidcPlugin = oidcPlugin;
30
30
  const flink_1 = require("@flink-app/flink");
31
+ const log_1 = require("./log");
31
32
  const OidcSessionRepo_1 = __importDefault(require("./repos/OidcSessionRepo"));
32
33
  const OidcConnectionRepo_1 = __importDefault(require("./repos/OidcConnectionRepo"));
33
34
  const encryption_utils_1 = require("./utils/encryption-utils");
@@ -109,13 +110,14 @@ const CallbackOidc = __importStar(require("./handlers/CallbackOidc"));
109
110
  */
110
111
  function oidcPlugin(options) {
111
112
  // Validation
112
- if (!options.providers || Object.keys(options.providers).length === 0) {
113
- throw new Error("OIDC Plugin: At least one provider must be configured");
113
+ const providers = options.providers || {};
114
+ if (Object.keys(providers).length === 0 && !options.providerLoader) {
115
+ throw new Error("OIDC Plugin: At least one provider must be configured, or providerLoader must be provided");
114
116
  }
115
117
  // Validate provider configurations
116
- const configuredProviders = Object.keys(options.providers);
118
+ const configuredProviders = Object.keys(providers);
117
119
  for (const providerName of configuredProviders) {
118
- const providerConfig = options.providers[providerName];
120
+ const providerConfig = providers[providerName];
119
121
  if (!providerConfig)
120
122
  continue;
121
123
  if (!providerConfig.issuer) {
@@ -124,9 +126,6 @@ function oidcPlugin(options) {
124
126
  if (!providerConfig.clientId) {
125
127
  throw new Error(`OIDC Plugin: ${providerName} clientId is required`);
126
128
  }
127
- if (!providerConfig.clientSecret) {
128
- throw new Error(`OIDC Plugin: ${providerName} clientSecret is required`);
129
- }
130
129
  if (!providerConfig.callbackUrl) {
131
130
  throw new Error(`OIDC Plugin: ${providerName} callbackUrl is required`);
132
131
  }
@@ -137,6 +136,7 @@ function oidcPlugin(options) {
137
136
  `(authorizationEndpoint, tokenEndpoint, jwksUri)`);
138
137
  }
139
138
  }
139
+ log_1.oidcLog.debug(`Provider "${providerName}" config:`, `issuer=${providerConfig.issuer}`, `clientId=${providerConfig.clientId}`, `clientSecret=${(0, log_1.maskSecret)(providerConfig.clientSecret)}`, `callbackUrl=${providerConfig.callbackUrl}`, providerConfig.discoveryUrl ? `discoveryUrl=${providerConfig.discoveryUrl}` : `authorizationEndpoint=${providerConfig.authorizationEndpoint} tokenEndpoint=${providerConfig.tokenEndpoint}`, `scope=${(providerConfig.scope || ["openid", "email", "profile"]).join(" ")}`, providerConfig.tokenEndpointAuthMethod ? `authMethod=${providerConfig.tokenEndpointAuthMethod}` : "");
140
140
  }
141
141
  if (!options.onAuthSuccess) {
142
142
  throw new Error("OIDC Plugin: onAuthSuccess callback is required");
@@ -144,19 +144,32 @@ function oidcPlugin(options) {
144
144
  // Determine encryption key
145
145
  let encryptionKey = options.encryptionKey;
146
146
  if (!encryptionKey) {
147
- // Derive from first configured provider's client secret
148
- const firstProvider = configuredProviders[0];
149
- const firstProviderConfig = options.providers[firstProvider];
150
- if (firstProviderConfig) {
151
- encryptionKey = firstProviderConfig.clientSecret;
147
+ // Derive from the first configured provider that has a client secret
148
+ const providerWithSecret = configuredProviders.find((name) => providers[name]?.clientSecret);
149
+ if (providerWithSecret) {
150
+ encryptionKey = providers[providerWithSecret].clientSecret;
152
151
  flink_1.log.warn("OIDC Plugin: No encryption key provided, deriving from client secret. " + "For better security, provide a dedicated encryptionKey in options.");
152
+ log_1.oidcLog.debug(`Encryption key derived from provider "${providerWithSecret}" clientSecret`);
153
153
  }
154
154
  }
155
- if (!encryptionKey || encryptionKey.length < 32) {
156
- throw new Error("OIDC Plugin: Encryption key must be at least 32 characters");
155
+ else {
156
+ log_1.oidcLog.debug(`Encryption key: ${(0, log_1.maskSecret)(encryptionKey)} (explicit)`);
157
+ }
158
+ // Encryption key is required when storing tokens
159
+ if (options.storeTokens) {
160
+ if (!encryptionKey || encryptionKey.length < 32) {
161
+ throw new Error("OIDC Plugin: Encryption key must be at least 32 characters. " +
162
+ "Provide an explicit encryptionKey when using storeTokens with public clients (no clientSecret).");
163
+ }
164
+ (0, encryption_utils_1.validateEncryptionSecret)(encryptionKey);
165
+ }
166
+ else if (encryptionKey) {
167
+ // Validate if provided, even when not storing tokens (used for getConnection/getConnections)
168
+ if (encryptionKey.length < 32) {
169
+ throw new Error("OIDC Plugin: Encryption key must be at least 32 characters");
170
+ }
171
+ (0, encryption_utils_1.validateEncryptionSecret)(encryptionKey);
157
172
  }
158
- // Validate encryption key
159
- (0, encryption_utils_1.validateEncryptionSecret)(encryptionKey);
160
173
  let flinkApp;
161
174
  let sessionRepo;
162
175
  let connectionRepo;
@@ -174,6 +187,7 @@ function oidcPlugin(options) {
174
187
  // Initialize repositories
175
188
  const sessionsCollectionName = options.sessionsCollectionName || "oidc_sessions";
176
189
  const connectionsCollectionName = options.connectionsCollectionName || "oidc_connections";
190
+ log_1.oidcLog.debug(`Init: sessionsCollection=${sessionsCollectionName}`, `connectionsCollection=${connectionsCollectionName}`, `storeTokens=${!!options.storeTokens}`, `sessionTTL=${options.sessionTTL ?? 600}s`, `registerRoutes=${options.registerRoutes !== false}`, configuredProviders.length > 0 ? `staticProviders=[${configuredProviders.join(", ")}]` : "staticProviders=[] (dynamic only)", options.providerLoader ? "providerLoader=yes" : "providerLoader=no");
177
191
  sessionRepo = new OidcSessionRepo_1.default(sessionsCollectionName, db);
178
192
  connectionRepo = new OidcConnectionRepo_1.default(connectionsCollectionName, db);
179
193
  flinkApp.addRepo("oidcSessionRepo", sessionRepo);
@@ -183,7 +197,7 @@ function oidcPlugin(options) {
183
197
  await db.collection(sessionsCollectionName).createIndex({ createdAt: 1 }, { expireAfterSeconds: sessionTTL });
184
198
  flink_1.log.info(`OIDC Plugin: Created TTL index on ${sessionsCollectionName} with ${sessionTTL}s expiration`);
185
199
  // Initialize provider registry
186
- providerRegistry = new ProviderRegistry_1.ProviderRegistry(options.providers, options.providerLoader);
200
+ providerRegistry = new ProviderRegistry_1.ProviderRegistry(providers, options.providerLoader, flinkApp.ctx);
187
201
  // Store provider registry in app context for handlers to access
188
202
  flinkApp.ctx.oidcProviderRegistry = providerRegistry;
189
203
  // Register OIDC handlers
@@ -192,7 +206,7 @@ function oidcPlugin(options) {
192
206
  flinkApp.addHandler(InitiateOidc);
193
207
  flinkApp.addHandler(CallbackOidc);
194
208
  }
195
- flink_1.log.info(`OIDC Plugin initialized with providers: ${configuredProviders.join(", ")}`);
209
+ flink_1.log.info(`OIDC Plugin initialized${configuredProviders.length > 0 ? ` with providers: ${configuredProviders.join(", ")}` : " with dynamic provider loader"}`);
196
210
  }
197
211
  catch (error) {
198
212
  flink_1.log.error("Failed to initialize OIDC Plugin:", error);