@itentialopensource/adapter-gcp_compute 1.5.1 → 1.5.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
+ ## 1.5.2 [09-18-2023]
3
+
4
+ * Patch/adapt 2852
5
+
6
+ See merge request itentialopensource/adapters/cloud/adapter-gcp_compute!12
7
+
8
+ ---
9
+
2
10
  ## 1.5.1 [09-11-2023]
3
11
 
4
12
  * more migration & metadata changes
package/adapter.js CHANGED
@@ -134,7 +134,8 @@ class GcpCompute extends AdapterBaseCl {
134
134
  'refreshAuthorizationHeader',
135
135
  'refreshAuthorizationAndIdentifyRequest',
136
136
  'getToken',
137
- 'generateKeyObjFromProps'
137
+ 'generateKeyObjFromProps',
138
+ 'refreshAuthorizationBroker'
138
139
  ];
139
140
  if (!inIgnore && Array.isArray(inIgnore)) {
140
141
  myIgnore = inIgnore;
@@ -442,7 +443,7 @@ class GcpCompute extends AdapterBaseCl {
442
443
  log.trace(origin);
443
444
 
444
445
  try {
445
- return super.hasEntities(entityType, entityList, callback);
446
+ return this.refreshAuthorizationBroker().then(() => super.hasEntities(entityType, entityList, callback));
446
447
  } catch (err) {
447
448
  log.error(`${origin}: ${err}`);
448
449
  return callback(null, err);
@@ -464,7 +465,7 @@ class GcpCompute extends AdapterBaseCl {
464
465
  log.trace(origin);
465
466
 
466
467
  try {
467
- return super.getDevice(deviceName, callback);
468
+ return this.refreshAuthorizationBroker().then(() => super.getDevice(deviceName, callback));
468
469
  } catch (err) {
469
470
  log.error(`${origin}: ${err}`);
470
471
  return callback(null, err);
@@ -484,9 +485,8 @@ class GcpCompute extends AdapterBaseCl {
484
485
  const meth = 'adapter-getDevicesFiltered';
485
486
  const origin = `${this.id}-${meth}`;
486
487
  log.trace(origin);
487
-
488
488
  try {
489
- return super.getDevicesFiltered(options, callback);
489
+ return this.refreshAuthorizationBroker().then(() => super.getDevicesFiltered(options, callback));
490
490
  } catch (err) {
491
491
  log.error(`${origin}: ${err}`);
492
492
  return callback(null, err);
@@ -508,7 +508,7 @@ class GcpCompute extends AdapterBaseCl {
508
508
  log.trace(origin);
509
509
 
510
510
  try {
511
- return super.isAlive(deviceName, callback);
511
+ return this.refreshAuthorizationBroker().then(() => super.isAlive(deviceName, callback));
512
512
  } catch (err) {
513
513
  log.error(`${origin}: ${err}`);
514
514
  return callback(null, err);
@@ -531,7 +531,7 @@ class GcpCompute extends AdapterBaseCl {
531
531
  log.trace(origin);
532
532
 
533
533
  try {
534
- return super.getConfig(deviceName, format, callback);
534
+ return this.refreshAuthorizationBroker().then(() => super.getConfig(deviceName, format, callback));
535
535
  } catch (err) {
536
536
  log.error(`${origin}: ${err}`);
537
537
  return callback(null, err);
@@ -552,7 +552,7 @@ class GcpCompute extends AdapterBaseCl {
552
552
  log.trace(origin);
553
553
 
554
554
  try {
555
- return super.iapGetDeviceCount(callback);
555
+ return this.refreshAuthorizationBroker().then(() => super.iapGetDeviceCount(callback));
556
556
  } catch (err) {
557
557
  log.error(`${origin}: ${err}`);
558
558
  return callback(null, err);
@@ -845,6 +845,19 @@ class GcpCompute extends AdapterBaseCl {
845
845
  }
846
846
  }
847
847
 
848
+ async refreshAuthorizationBroker() {
849
+ const meth = 'adapter-refreshAuthorizationBroker';
850
+ const origin = `${this.id}-${meth}`;
851
+ try {
852
+ const token = await this.gtoken.getToken();
853
+ this.refreshAuthorizationHeader(token);
854
+ } catch (ex) {
855
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
856
+ log.error(`${origin}: ${errorObj.IAPerror.displayString} ${ex.message}`);
857
+ throw new Error(errorObj);
858
+ }
859
+ }
860
+
848
861
  /**
849
862
  * configureGtoken accepts the options for the gtoken library documented in the website below,
850
863
  * plus keyFileContents in order to facilitate convenient retrieval from Hashicorp Vault
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-gcp_compute",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "This adapter integrates with system described as: computeEngineApi.",
5
5
  "main": "adapter.js",
6
6
  "systemName": "Google Cloud Platform Compute",
Binary file