@skillswaveca/nova-shared-libraries 3.13.0 → 3.15.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/docs-base/package-info.js +5 -5
- package/package.json +1 -1
- package/packages/drivers/package.json +1 -1
- package/packages/drivers/src/oauth.js +20 -0
- package/packages/drivers/src/wave.js +28 -5
- package/packages/nova-middleware/package.json +1 -1
- package/packages/nova-model/package.json +1 -1
- package/packages/nova-router/package.json +1 -1
- package/packages/nova-utils/package.json +1 -1
- package/packages/nova-utils/src/config.js +1 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
export const packageInfo = [
|
|
2
2
|
{
|
|
3
3
|
"name": "@skillswaveca/nova-utils",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.14.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": "3.
|
|
10
|
+
"version": "3.14.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.
|
|
16
|
+
"version": "3.14.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.
|
|
22
|
+
"version": "3.14.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.
|
|
28
|
+
"version": "3.14.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.
|
|
6
|
+
"version": "3.15.0",
|
|
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.
|
|
6
|
+
"version": "3.15.0",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"pre-release": "pnpm run create-index",
|
|
@@ -147,4 +147,24 @@ export class OAuthDriver extends HttpDriver {
|
|
|
147
147
|
this.clientCredentialsInstance = new ClientCredentials(this.clientConfig);
|
|
148
148
|
return this.clientCredentialsInstance;
|
|
149
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Retrieves the health of the service protected by OAuth.
|
|
153
|
+
*
|
|
154
|
+
* @returns {Promise<{message, status: string}|*|{message: string, status: string}>}
|
|
155
|
+
*/
|
|
156
|
+
async health() {
|
|
157
|
+
const response = await super.get('/health');
|
|
158
|
+
const { success, body, error, statusCode } = response;
|
|
159
|
+
if(success) {
|
|
160
|
+
return body;
|
|
161
|
+
} else {
|
|
162
|
+
if(statusCode === 404) {
|
|
163
|
+
return { status: 'unknown', message: 'No health check endpoint found' };
|
|
164
|
+
} else {
|
|
165
|
+
return { status: 'error', message: error };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
}
|
|
150
170
|
}
|
|
@@ -80,24 +80,47 @@ export class WaveDriver extends OAuthDriver {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Gets a tenant SSO objects from the Wave platform
|
|
85
|
+
*
|
|
86
|
+
* @param tenantId the guid of the tenant
|
|
87
|
+
* @returns {Promise<*>} the tenant object
|
|
88
|
+
*/
|
|
89
|
+
async getTenantSSO(tenantId) {
|
|
90
|
+
const url = `/api/v2/tenants/${tenantId}/sso`;
|
|
91
|
+
|
|
92
|
+
this.log.debug({ tenantId, url }, 'Getting tenant SSO from Wave');
|
|
93
|
+
const response = await this.get(url, {});
|
|
94
|
+
|
|
95
|
+
const { success, body, error } = response;
|
|
96
|
+
|
|
97
|
+
if (response.success) {
|
|
98
|
+
this.log.info({ 'response': { success, body } }, 'Tenant SSO retrieved from wave');
|
|
99
|
+
return body;
|
|
100
|
+
} else {
|
|
101
|
+
this.log.error({ 'response': { success, error } }, 'Failed to retrieve tenant SSO from wave');
|
|
102
|
+
throw new Error(`Failed to retrieve tenant SSO from Wave: ${error}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
83
106
|
/**
|
|
84
107
|
* Gets all tenants from the Wave platform
|
|
85
108
|
*
|
|
86
109
|
* @returns {*}
|
|
87
110
|
*/
|
|
88
|
-
getAllTenants() {
|
|
111
|
+
async getAllTenants() {
|
|
89
112
|
const url = '/api/v2/tenants';
|
|
90
113
|
this.log.debug({ url }, 'Getting all tenants from Wave');
|
|
91
|
-
const response = this.get(url, {});
|
|
114
|
+
const response = await this.get(url, {});
|
|
92
115
|
|
|
93
|
-
const { success, body, error } = response;
|
|
116
|
+
const { success, body, error, statusCode } = response;
|
|
94
117
|
|
|
95
118
|
if (response.success) {
|
|
96
119
|
this.log.info({ 'response': { success, body } }, 'Tenants retrieved from wave');
|
|
97
120
|
return body;
|
|
98
121
|
} else {
|
|
99
|
-
this.log.error({ 'response': { success, error } }, 'Failed to retrieve tenants from wave');
|
|
100
|
-
throw new Error(`Failed to retrieve tenants from Wave: ${error}`);
|
|
122
|
+
this.log.error({ 'response': { success, error, statusCode } }, 'Failed to retrieve tenants from wave');
|
|
123
|
+
throw new Error(`Failed to retrieve tenants from Wave: ${error}, statusCode: ${statusCode}`);
|
|
101
124
|
}
|
|
102
125
|
}
|
|
103
126
|
|
|
@@ -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.
|
|
6
|
+
"version": "3.15.0",
|
|
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-model",
|
|
4
4
|
"description": "Nova model stuff",
|
|
5
5
|
"repository": "https://github.com/SkillsWave/nova-shared-libraries",
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.15.0",
|
|
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.
|
|
6
|
+
"version": "3.15.0",
|
|
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.
|
|
6
|
+
"version": "3.15.0",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"pre-release": "pnpm run create-index",
|
|
@@ -125,7 +125,7 @@ export const getOauthDriverConfig = driverName => {
|
|
|
125
125
|
return disabledConfig;
|
|
126
126
|
}
|
|
127
127
|
// Check for essential configuration components
|
|
128
|
-
const requiredFields = ['enabled', '
|
|
128
|
+
const requiredFields = ['enabled', 'audience', 'clientId', 'clientSecretName', 'tokenHost', 'tokenPath'];
|
|
129
129
|
const missingFields = requiredFields.filter(field => typeof driverConfig[field] === 'undefined' && typeof authConfig[field] === 'undefined');
|
|
130
130
|
|
|
131
131
|
if (missingFields.length > 0) {
|