@muze-nl/metro-oidc 0.5.0 → 0.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muze-nl/metro-oidc",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "oidc client middleware for @muze-nl/metro",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -50,6 +50,6 @@
50
50
  "dependencies": {
51
51
  "@muze-nl/assert": "^0.4.2",
52
52
  "@muze-nl/metro": "^0.6.9",
53
- "@muze-nl/metro-oauth2": "^0.7.0"
53
+ "@muze-nl/metro-oauth2": "^0.7.1"
54
54
  }
55
55
  }
@@ -53,12 +53,19 @@ export default async function register(options)
53
53
  })
54
54
 
55
55
  const defaultOptions = {
56
- client: metro.client().with(throwermw()).with(jsonmw())
56
+ client: metro.client().with(throwermw()).with(jsonmw()),
57
+ client_info: {
58
+ redirect_uris: [ globalThis.document?.location.href ]
59
+ }
57
60
  }
58
61
 
59
62
  options = Object.assign({}, defaultOptions, options)
60
-
61
-
63
+ if (!options.client_info) {
64
+ options.client_info = {}
65
+ }
66
+ if (!options.client_info.redirect_uris) {
67
+ options.client_info.redirect_uris = [ globalThis.document?.location.href ]
68
+ }
62
69
  let response = await options.client
63
70
  .post(options.registration_endpoint, {
64
71
  body: options.client_info
package/src/oidcmw.mjs CHANGED
@@ -36,7 +36,7 @@ export default function oidcmw(options={}) {
36
36
  if (!options.openid_configuration && options.store.has('openid_configuration')) {
37
37
  options.openid_configuration = options.store.get('openid_configuration')
38
38
  }
39
- if (!options.client_info.client_id && options.store.has('client_info')) {
39
+ if (!options.client_info?.client_id && options.store.has('client_info')) {
40
40
  options.client_info = options.store.get('client_info')
41
41
  }
42
42
 
@@ -62,7 +62,6 @@ export default function oidcmw(options={}) {
62
62
  }
63
63
 
64
64
  if (!options.client_info?.client_id) {
65
- assert(options.client_info?.client_name, Required())
66
65
  if (!options.openid_configuration.registration_endpoint) {
67
66
  throw metro.metroError('metro.oidcmw: Error: issuer '+options.issuer+' does not support dynamic client registration, but you haven\'t specified a client_id')
68
67
  }
@@ -84,8 +83,8 @@ export default function oidcmw(options={}) {
84
83
  force_authorization: true,
85
84
  authorize_callback: options.authorize_callback,
86
85
  oauth2_configuration: {
87
- client_id: options.client_info.client_id,
88
- client_secret: options.client_info.client_secret,
86
+ client_id: options.client_info?.client_id,
87
+ client_secret: options.client_info?.client_secret,
89
88
  grant_type: 'authorization_code',
90
89
  response_type: 'code',
91
90
  response_mode: 'query',