@defra/lis-hubs-infra-access 0.3.0-lreg-177.alpha.1 → 0.3.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/auth/oidc.js +9 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/lis-hubs-infra-access",
3
- "version": "0.3.0-lreg-177.alpha.1",
3
+ "version": "0.3.0",
4
4
  "description": "Shared hub access and capability resolution for the livestock platform.",
5
5
  "main": "src/index.js",
6
6
  "repository": {
package/src/auth/oidc.js CHANGED
@@ -99,6 +99,14 @@ function createCodeExchanger({
99
99
  }
100
100
  }
101
101
 
102
+ function resolveScope(configuredScope) {
103
+ const requestedScopes = (configuredScope ?? 'openid').split(' ')
104
+
105
+ return requestedScopes.includes('openid')
106
+ ? requestedScopes.join(' ')
107
+ : ['openid', ...requestedScopes].join(' ')
108
+ }
109
+
102
110
  function addAuthorizationParameters(
103
111
  authorizationUrl,
104
112
  { providerConfig, redirectUri, authFlow }
@@ -106,7 +114,7 @@ function addAuthorizationParameters(
106
114
  const parameters = {
107
115
  client_id: providerConfig.clientId,
108
116
  response_type: 'code',
109
- scope: providerConfig.scope ?? 'openid',
117
+ scope: resolveScope(providerConfig.scope),
110
118
  redirect_uri: redirectUri,
111
119
  state: authFlow.state,
112
120
  nonce: authFlow.nonce,