@itentialopensource/adapter-utils 5.10.8 → 5.10.10

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.
@@ -8,7 +8,7 @@
8
8
 
9
9
  const aws4 = require('aws4');
10
10
  const AWS = require('aws-sdk');
11
- const querystring = require('querystring');
11
+ const querystring = require('node:querystring');
12
12
 
13
13
  /*
14
14
  * INTERNAL FUNCTION: update device broker properties from service instance config and adapter sample properties
@@ -249,6 +249,21 @@ class AuthenticationHandler {
249
249
  return callback(authOpts.headers);
250
250
  }
251
251
 
252
+ const myDate = new Date().getTime();
253
+ const mySess = `${this.myid}-${myDate}`;
254
+
255
+ /* ADAPTER PROPERTIES AUTHENTICATION WITH GLOBAL ROLE */
256
+ // This will use the adapter role via the credentials provided to sign the call. If there is a global role for it to assume.
257
+ // it will use AWS Environment variables (access and secret key are null) to sign the call.
258
+ if (this.allProps.authentication.aws_access_key && this.allProps.authentication.aws_secret_key && this.allProps.authentication.aws_iam_role) {
259
+ log.info('Using Adapter PROPERTIES for AWS Authentication to assume a global role');
260
+ const parmas = {
261
+ RoleArn: this.allProps.authentication.aws_iam_role,
262
+ RoleSessionName: mySess
263
+ };
264
+ return this.assumeAWSSTSRole(null, null, null, options, parmas, true, callback);
265
+ }
266
+
252
267
  /* ROLE NAME AUTHENTICATION */
253
268
  // Different scenarios to discuss here
254
269
  // 1. IAM to internal AWS Server - either Task Role (roleName) or Adapter Role (aws_iam_role)
@@ -268,8 +283,6 @@ class AuthenticationHandler {
268
283
 
269
284
  // set up data for first assume role call
270
285
  const stsrole = new AWS.STS();
271
- const myDate = new Date().getTime();
272
- const mySess = `${this.myid}-${myDate}`;
273
286
  const stsData = {
274
287
  RoleArn: myRole,
275
288
  RoleSessionName: mySess,
@@ -27,7 +27,7 @@ const http = require('http');
27
27
  const cookieHandler = require('cookie');
28
28
  const jsonQuery = require('json-query');
29
29
  const xml2js = require('xml2js');
30
- const querystring = require('querystring');
30
+ const querystring = require('node:querystring');
31
31
  const { HttpsProxyAgent } = require('https-proxy-agent');
32
32
  const { SocksProxyAgent } = require('socks-proxy-agent');
33
33
  const AsyncLockCl = require('async-lock');
@@ -1153,7 +1153,7 @@ class AdapterPropertyUtil {
1153
1153
  }
1154
1154
 
1155
1155
  // This is the array of sensitive keys
1156
- let sensList = ['authorization', 'x-auth-token', 'x-csrf-token', 'x-amz-security-token', 'x-aws-ec2-metadata-token', 'cookie', 'set-cookie', 'token', 'tokenp2', 'user', 'username', 'passwd', 'password', 'api-key', 'client-id', 'client-secret', 'client_id', 'client_secret', 'session', 'session-id', 'jsessionid'];
1156
+ let sensList = ['authorization', 'x-auth-token', 'x-csrf-token', 'x-amz-security-token', 'x-aws-ec2-metadata-token', 'cookie', 'set-cookie', 'token', 'tokenp2', 'user', 'username', 'passwd', 'password', 'api-key', 'client-id', 'client-secret', 'client_id', 'client_secret', 'session', 'session-id', 'jsessionid', 'sessionToken', 'accessKeyId', 'secretAccessKey'];
1157
1157
 
1158
1158
  // add any additional items to scrub
1159
1159
  if (addItems && Array.isArray(addItems) && addItems.length > 0) {
@@ -4,7 +4,7 @@
4
4
  /* global log */
5
5
 
6
6
  /* NodeJS internal utilities */
7
- const querystring = require('querystring');
7
+ const querystring = require('node:querystring');
8
8
  const jsonQuery = require('json-query');
9
9
  const jsonxml = require('jsontoxml');
10
10
  const xml2js = require('xml2js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "5.10.8",
3
+ "version": "5.10.10",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",
@@ -8,14 +8,13 @@
8
8
  "lint:errors": "eslint --quiet . --ext .json --ext .js",
9
9
  "test:unit": "mocha test/unit/lib/requestHandlerTest.js --LOG=error && mocha test/unit/lib/restHandlerTest.js --LOG=error && mocha test/unit/lib/propertyUtilTest.js --LOG=error && mocha test/unit/lib/translatorUtilTest.js --LOG=error && mocha test/unit/lib/dbUtilTest.js --LOG=error",
10
10
  "test:integration": "mocha test/integration/lib/requestHandlerTest.js --LOG=error && mocha test/integration/lib/restHandlerTest.js --LOG=error && mocha test/integration/lib/restHandlerMfaTest.js --LOG=error",
11
- "test:cover": "nyc --reporter html --reporter text mocha --recursive --reporter dot test/*",
12
11
  "test": "npm run test:unit && npm run test:integration",
13
12
  "deploy": "npm publish --registry=https://registry.npmjs.org --access=public",
14
13
  "build": "npm run deploy"
15
14
  },
16
15
  "license": "Apache-2.0",
17
16
  "engines": {
18
- "node": ">= 8.0.0",
17
+ "node": ">= 14.0.0",
19
18
  "npm": ">= 6.0.0"
20
19
  },
21
20
  "repository": {
@@ -25,7 +24,7 @@
25
24
  "author": "Itential",
26
25
  "homepage": "https://gitlab.com/itentialopensource/adapter-utils#readme",
27
26
  "dependencies": {
28
- "ajv": "^8.12.0",
27
+ "ajv": "^8.17.1",
29
28
  "async-lock": "^1.4.0",
30
29
  "aws-sdk": "^2.1665.0",
31
30
  "aws4": "^1.9.1",
@@ -33,13 +32,12 @@
33
32
  "crypto-js": "^4.1.1",
34
33
  "ejs": "^3.1.10",
35
34
  "form-data": "^4.0.0",
36
- "fs-extra": "^11.1.1",
35
+ "fs-extra": "^11.2.0",
37
36
  "https-proxy-agent": "^7.0.0",
38
37
  "json-query": "^2.2.2",
39
38
  "jsontoxml": "^1.0.1",
40
39
  "jsonwebtoken": "^9.0.1",
41
40
  "mongodb": "^3.7.4",
42
- "querystring": "^0.2.0",
43
41
  "readline-sync": "^1.4.10",
44
42
  "socks-proxy-agent": "^8.0.1",
45
43
  "uuid": "^9.0.0",
@@ -51,13 +49,12 @@
51
49
  "eslint-config-airbnb-base": "^15.0.0",
52
50
  "eslint-plugin-import": "^2.27.5",
53
51
  "eslint-plugin-json": "^3.1.0",
54
- "mocha": "^10.2.0",
52
+ "mocha": "^10.7.3",
55
53
  "nock": "^13.3.1",
56
- "nyc": "^15.1.0",
57
54
  "strip-ansi": "^7.1.0",
58
55
  "strip-ansi-cli": "^3.0.2",
59
56
  "testdouble": "^3.18.0",
60
- "winston": "^3.9.0"
57
+ "winston": "^3.14.2"
61
58
  },
62
59
  "private": false
63
60
  }