@kronos-integration/service 15.0.2 → 15.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/service",
3
- "version": "15.0.2",
3
+ "version": "15.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
package/src/service.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { defaultLogLevels, LogLevelMixin, makeLogEvent } from "loglevel-mixin";
2
2
  import { prepareActions, StateTransitionMixin } from "statetransition-mixin";
3
3
  import {
4
+ attributeIterator,
4
5
  prepareAttributesDefinitions,
5
6
  getAttributes,
6
7
  setAttributes,
@@ -430,14 +431,31 @@ export class Service extends EndpointsMixin(
430
431
  }
431
432
 
432
433
  /**
433
- *
434
- * @param {string} key
434
+ *
435
+ * @param {string} key
435
436
  * @returns {Promise<string|Uint8Array>}
436
437
  */
437
438
  async getCredential(key) {
438
439
  return this.owner.getCredential(this.name + "." + key, "utf8");
439
440
  }
440
441
 
442
+ /**
443
+ * Retrieve all credential attribute values.
444
+ * @returns {Promise<Object>}
445
+ */
446
+ async getCredentials(filter = (name, attribute) => attribute.credential) {
447
+ const credentials = {};
448
+ for (const [path, attribute] of attributeIterator(
449
+ this.attributes,
450
+ filter
451
+ )) {
452
+ const name = path.join(".");
453
+ credentials[name] = await this.getCredential(name);
454
+ }
455
+
456
+ return credentials;
457
+ }
458
+
441
459
  /**
442
460
  * Adds service name to the log event.
443
461
  * @param {string} level the log level
@@ -146,6 +146,11 @@ export class Service extends Service_base {
146
146
  * @returns {Promise<string|Uint8Array>}
147
147
  */
148
148
  getCredential(key: string): Promise<string | Uint8Array>;
149
+ /**
150
+ * Retrieve all credential attribute values.
151
+ * @returns {Promise<Object>}
152
+ */
153
+ getCredentials(filter?: (name: any, attribute: any) => any): Promise<any>;
149
154
  /**
150
155
  * Adds service name to the log event.
151
156
  * @param {string} level the log level