@skillswaveca/nova-shared-libraries 3.10.0 → 3.11.1

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.
@@ -1,31 +1,31 @@
1
1
  export const packageInfo = [
2
2
  {
3
3
  "name": "@skillswaveca/nova-utils",
4
- "version": "3.9.2",
4
+ "version": "3.11.0",
5
5
  "description": "A collection of random utils used in nova repos",
6
6
  "docsPath": "./nova-utils/index.html"
7
7
  },
8
8
  {
9
9
  "name": "nova-router",
10
- "version": "2.0.0",
10
+ "version": "3.11.0",
11
11
  "description": "An extended Koa router that enables better validation",
12
12
  "docsPath": "./nova-router/index.html"
13
13
  },
14
14
  {
15
15
  "name": "@skillswaveca/nova-model",
16
- "version": "3.9.2",
16
+ "version": "3.11.0",
17
17
  "description": "Nova model stuff",
18
18
  "docsPath": "./nova-model/index.html"
19
19
  },
20
20
  {
21
21
  "name": "@skillswaveca/nova-middleware",
22
- "version": "3.9.2",
22
+ "version": "3.11.0",
23
23
  "description": "A collection of middleware used by nova projects",
24
24
  "docsPath": "./nova-middleware/index.html"
25
25
  },
26
26
  {
27
27
  "name": "@skillswaveca/nova-drivers",
28
- "version": "3.9.2",
28
+ "version": "3.11.0",
29
29
  "description": "Some helper drivers for AWS services",
30
30
  "docsPath": "./drivers/index.html"
31
31
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "@skillswaveca/nova-shared-libraries",
4
4
  "description": "A monorepo of shared libraries for Nova projects.",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.10.0",
6
+ "version": "3.11.1",
7
7
  "main": "index.js",
8
8
  "license": "MIT",
9
9
  "keywords": [],
@@ -3,7 +3,7 @@
3
3
  "name": "@skillswaveca/nova-drivers",
4
4
  "description": "Some helper drivers for AWS services",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.10.0",
6
+ "version": "3.11.1",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -3,7 +3,7 @@
3
3
  "name": "@skillswaveca/nova-middleware",
4
4
  "description": "A collection of middleware used by nova projects",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.10.0",
6
+ "version": "3.11.1",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -18,13 +18,19 @@ const _verifyToken = async(authHeader, jwksUrl, audience, issuer) => {
18
18
 
19
19
  // Verify the token
20
20
  jwt.verify(token, pem, { algorithms: ['RS256'], audience, issuer });
21
+ return jwt.decode(token);
21
22
  };
22
23
 
23
24
  /**
24
25
  * Koa middleware for OAuth token verification
25
- * @param audience
26
- * @param issuer
27
- * @param jwksUrl
26
+ *
27
+ * Adds the decoded JWT to the context state. (i.e context.state.decodedJWT)
28
+ *
29
+ * @param {Object} options - The options object.
30
+ * @param {string} options.audience - The audience of the token.
31
+ * @param {string} options.issuer - The issuer of the token.
32
+ * @param {string} options.jwksUrl - The URL to the JWKS endpoint.
33
+ *
28
34
  * @returns {(function(*, *): Promise<void>)|*}
29
35
  */
30
36
  export const oauthMiddleware = ({ audience, issuer, jwksUrl }) => {
@@ -32,7 +38,8 @@ export const oauthMiddleware = ({ audience, issuer, jwksUrl }) => {
32
38
  const authHeader = ctx.headers.authorization || '';
33
39
 
34
40
  try {
35
- await _verifyToken(authHeader, jwksUrl, audience, issuer);
41
+ ctx.state.decodedJWT = await _verifyToken(authHeader, jwksUrl, audience, issuer);
42
+ ctx.state.scopes = ctx.state?.decodedJWT?.scope?.split(' ') || [];
36
43
  } catch (error) {
37
44
  ctx.status = 401;
38
45
  ctx.body = { message: 'Invalid or expired token', error: error.message };
@@ -3,7 +3,7 @@
3
3
  "name": "@skillswaveca/nova-model",
4
4
  "description": "Nova model stuff",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.10.0",
6
+ "version": "3.11.1",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -3,7 +3,7 @@
3
3
  "name": "nova-router",
4
4
  "description": "An extended Koa router that enables better validation",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.10.0",
6
+ "version": "3.11.1",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",
@@ -3,7 +3,7 @@
3
3
  "name": "@skillswaveca/nova-utils",
4
4
  "description": "A collection of random utils used in nova repos",
5
5
  "repository": "https://github.com/SkillsWave/nova-shared-libraries",
6
- "version": "3.10.0",
6
+ "version": "3.11.1",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "pre-release": "pnpm run create-index",