@itentialopensource/adapter-utils 5.9.1 → 5.9.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/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ## 5.9.2 [10-07-2024]
3
+
4
+ * add token logs
5
+
6
+ See merge request itentialopensource/adapter-utils!306
7
+
8
+ ---
9
+
2
10
  ## 5.9.1 [09-26-2024]
3
11
 
4
12
  * Update refresh token logic
@@ -1309,7 +1309,7 @@ async function getToken(reqPath, options, tokenSchema, bodyString, callPropertie
1309
1309
 
1310
1310
  // process primary token from header
1311
1311
  if (tokenSchema.responseSchema && tokenSchema.responseSchema.properties && tokenSchema.responseSchema.properties.token
1312
- && tokenSchema.responseSchema.properties.token.placement && tokenSchema.responseSchema.properties.token.placement.toUpperCase() === 'HEADER') {
1312
+ && tokenSchema.responseSchema.properties.token.placement && tokenSchema.responseSchema.properties.token.placement.toUpperCase() === 'HEADER') {
1313
1313
  if (!tokenSchema.responseSchema.properties.token.external_name) {
1314
1314
  const errorObj = transUtilInst.formatErrorObject(origin, 'Unable To Get Primary Token', ['Primary Token', result.code], null, null, null);
1315
1315
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
@@ -1317,6 +1317,7 @@ async function getToken(reqPath, options, tokenSchema, bodyString, callPropertie
1317
1317
  }
1318
1318
 
1319
1319
  const exName = tokenSchema.responseSchema.properties.token.external_name.toLowerCase();
1320
+ log.debug(`Attempting to get primary token from Header ${exName}`);
1320
1321
  const headKeys = Object.keys(result.headers);
1321
1322
  let fullToken = null;
1322
1323
  let setCookie = null;
@@ -1397,6 +1398,7 @@ async function getToken(reqPath, options, tokenSchema, bodyString, callPropertie
1397
1398
  }
1398
1399
 
1399
1400
  const exName = tokenSchema.responseSchema.properties.tokenp2.external_name.toLowerCase();
1401
+ log.debug(`Attempting to get second token from Header ${exName}`);
1400
1402
  const headKeys = Object.keys(result.headers);
1401
1403
  let fullToken = null;
1402
1404
  let setCookie = null;
@@ -1470,6 +1472,8 @@ async function getToken(reqPath, options, tokenSchema, bodyString, callPropertie
1470
1472
  // process the body
1471
1473
  // if response is just a string
1472
1474
  if (Object.hasOwnProperty.call(tokenSchema, 'responseDatatype') && tokenSchema.responseDatatype.toUpperCase() === 'PLAIN') {
1475
+ log.debug('Attempting to get tokens from text body repsonse');
1476
+
1473
1477
  if (tokenSchema.responseSchema && tokenSchema.responseSchema.properties && tokenSchema.responseSchema.properties.token
1474
1478
  && tokenSchema.responseSchema.properties.token.placement && tokenSchema.responseSchema.properties.token.placement.toUpperCase() === 'BODY') {
1475
1479
  currResult.token = result.response;
@@ -1493,6 +1497,8 @@ async function getToken(reqPath, options, tokenSchema, bodyString, callPropertie
1493
1497
  return resolve(currResult);
1494
1498
  }
1495
1499
  if (Object.hasOwnProperty.call(tokenSchema, 'responseDatatype') && tokenSchema.responseDatatype.toUpperCase() === 'XML') {
1500
+ log.debug('Attempting to get tokens from XML body repsonse');
1501
+
1496
1502
  if (tokenSchema.responseSchema && tokenSchema.responseSchema.properties && tokenSchema.responseSchema.properties.token
1497
1503
  && tokenSchema.responseSchema.properties.token.placement && tokenSchema.responseSchema.properties.token.placement.toUpperCase() === 'BODY') {
1498
1504
  currResult.token = result.response;
@@ -1510,6 +1516,8 @@ async function getToken(reqPath, options, tokenSchema, bodyString, callPropertie
1510
1516
  let tempResult = null;
1511
1517
  if (result.response) {
1512
1518
  if (Object.hasOwnProperty.call(tokenSchema, 'responseDatatype') && tokenSchema.responseDatatype.toUpperCase() === 'XML2JSON') {
1519
+ log.debug('Attempting to get tokens from XML2JSON repsonse');
1520
+
1513
1521
  try {
1514
1522
  const parser = new xml2js.Parser({ explicitArray: false, attrkey: '_attr' });
1515
1523
  parser.parseString(result.response, (error, presult) => {
@@ -1532,9 +1540,11 @@ async function getToken(reqPath, options, tokenSchema, bodyString, callPropertie
1532
1540
  }
1533
1541
  }
1534
1542
  if (Object.hasOwnProperty.call(tokenSchema, 'responseDatatype') && tokenSchema.responseDatatype.toUpperCase() === 'URLENCODE') {
1543
+ log.debug('Attempting to get tokens from URLENCODE repsonse');
1535
1544
  tempResult = querystring.parse(result.response.trim());
1536
1545
  } else {
1537
1546
  try {
1547
+ log.debug('Parsing JSON response');
1538
1548
  tempResult = JSON.parse(result.response.trim());
1539
1549
  } catch (exc) {
1540
1550
  log.warn(exc);
@@ -1572,7 +1582,9 @@ async function getToken(reqPath, options, tokenSchema, bodyString, callPropertie
1572
1582
  }
1573
1583
 
1574
1584
  // return the token from the token schema
1585
+ log.debug(`About to Translate Token Response: ${JSON.stringify(propUtilInst.scrubSensitiveInfo(tempResult))}`);
1575
1586
  let translated = transUtilInst.mapFromOutboundEntity(tempResult, tokenSchema.responseSchema);
1587
+ log.debug(`Translated response ${JSON.stringify(propUtilInst.scrubSensitiveInfo(translated))}`);
1576
1588
 
1577
1589
  // if what we got back is an array, just return the first element
1578
1590
  // should only have one token!!!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "5.9.1",
3
+ "version": "5.9.2",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",
@@ -29,7 +29,7 @@
29
29
  "async-lock": "^1.4.0",
30
30
  "aws-sdk": "^2.1665.0",
31
31
  "aws4": "^1.9.1",
32
- "cookie": "^0.5.0",
32
+ "cookie": "^0.7.1",
33
33
  "crypto-js": "^4.1.1",
34
34
  "ejs": "^3.1.10",
35
35
  "form-data": "^4.0.0",
Binary file