@ti-engine/core 1.0.7 → 1.0.11

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 ADDED
@@ -0,0 +1,7 @@
1
+ ##Version 1.0.11
2
+ * feat(message exchange): implement message tampering and insertion protection
3
+ * feat(config): provide option to turn on/off the message tampering and insertion protection
4
+ * feat(config): provide option to turn on/off message tracing
5
+ * feat: upgrade all used packages to their latest versions
6
+ * refactor(config)!: rename all environment variables that set configuration settings to match their related setting
7
+ * docs: add a change log
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
  Flexible framework for the creation of microservices with [node.js](https://nodejs.org/).
3
3
 
4
4
  ## introduction
5
- The **ti-engine** is an open source, free to use - both for personal and commercial projects - framework for the creation of microservice-based solutions using **node.js**. The general architectural concept of the framework is based on a standard messenger system that allows certain customization but also provides predictability and traceability of its behavior.
5
+ The **ti-engine** is an open source, free to use - both for personal and commercial projects - framework for the creation of microservice-based solutions using **node.js**. The architectural concept of the framework is based on a standard _messaging system_ that allows for certain customization but also provides predictability and traceability of its behavior.
6
6
 
7
- Being a messenger system, the **ti-engine** relies on a message broker for the actual exchange of messages between microservice instances. The default implementation of the framework uses [Redis](https://redis.io/) cache, however, you could create your own implementation using something like [Rabbit MQ](https://www.rabbitmq.com/). See the [advanced topics](#advanced-topics) section of this documentation for guides on how to do this.
7
+ Being a messaging system, the **ti-engine** relies on a message broker for the actual exchange of messages between microservice instances. The default implementation of the framework uses [Redis](https://redis.io/) cache, however, you could create your own implementation using something like [Rabbit MQ](https://www.rabbitmq.com/). See the [advanced topics](#advanced-topics) section of this documentation for guides on how to do this.
8
8
 
9
9
  Please be aware, that this framework is under active development and will expand in the near future. Also, this documentation is still in the process of being created and refined. Make sure to keep an eye on the changes in case you want to use it in the meantime.
10
10
 
@@ -40,7 +40,7 @@ Once you have everything else ready, you should download the **ti-engine** teste
40
40
  `[path to your project]/node_modules/@ti-engine/tester`
41
41
  2. Execute the following command `node ../core/bin/start-instance.js`
42
42
  3. If everything was done properly, you should see the following output:
43
- ```shell
43
+ ```text
44
44
  [timestamp]: [instance-id] - notice - Starting new instance of type 'tester-service' with instance ID '[instance-id]'.
45
45
  [timestamp]: [instance-id] - info - Starting service registration process. There is NO default service handler provided.
46
46
  [timestamp]: [instance-id] - info - Registration of defined services completed with 2 successful out of 2 total.
@@ -64,7 +64,7 @@ At the start of the output log you can see a NOTICE that tells you a couple of i
64
64
  Following that come a couple of INFO lines that inform you about the microservice interface state. The framework starts with the process of registration of _business services_ within the service domain of the microservice `tester-service` and successfully adds 2 such services. The necessary information for this is read from a JSON config file included in the package. We'll get into more details on what this all means in the section [creating a microservice](#creating-a-microservice).
65
65
 
66
66
  Once the initialization sequence has completed the framework informs you that the microservice instance has started successfully. If the framework encountered an error during initialization instead, you would see something like this:
67
- ```shell
67
+ ```text
68
68
  [timestamp]: [instance-id] - notice - Starting new instance of type 'tester-service' with instance ID '[instance-id]'.
69
69
  [timestamp]: [instance-id] - alert - Error detected in the instance startup script!
70
70
  ```
@@ -73,14 +73,14 @@ The following 5 lines inform you about the successful connection to Redis. The d
73
73
  Finally, you should see a couple of execution statements with their results in JSON format.
74
74
 
75
75
  You can now kill the node process which should show you the following two lines:
76
- ```shell
76
+ ```text
77
77
  [timestamp]: [instance-id] - notice - SIGINT event detected in main instance process.
78
78
  [timestamp]: [instance-id] - notice - Instance '[instance-id]' shut down successfully.
79
79
  ```
80
80
  The framework will always try to capture the shut-down event and log it. This should work even in container environment, but it might depend on your setup whether the last two entries will reach the logging system or not.
81
81
 
82
82
  The tester module gets its starting configuration from an `.env` file included in the package. If you open it, this is what you'll see:
83
- ```shell
83
+ ```text
84
84
  TI_INSTANCE_CLASS=tester-service.js
85
85
  TI_INSTANCE_CONFIG=tester-service.json
86
86
  TI_INSTANCE_NAME=tester-service
@@ -91,6 +91,38 @@ The first variable `TI_INSTANCE_CLASS` is mandatory for every microservice you c
91
91
  Before moving on, also take a good look at the file `bin/start-instance.js`. It should give you an idea on how to the process of starting and stopping a microservice operates. In most cases this file should be sufficient as a starting script for your **ti-engine** based microservice applications. You can, of course, create your own starting script, but then you'll have to consider all necessary steps to properly handle the microservice instance.
92
92
 
93
93
  ## architecture
94
+ The architectural approach for the **ti-engine** is done in _tiers_ with lower tiers being unaware of the tiers above them. The framework prefers a high level of abstraction in all its tiers and provides many options for customization and extension. While the language is JavaScript, the structuring of the framework follows the OOP principles, and you will find a lot of abstract classes and methods that require you to implement them. These are always marked with the `@abstract` annotation but if you happen to miss one, the framework will raise an exception when you try to use it in your solution.
95
+
96
+ There are three general tiers in the **ti-engine**:
97
+ 1. message exchange
98
+ 2. service domains
99
+ 3. solution implementation
100
+
101
+ See the following sections for more information on each of them.
102
+
103
+ ### tier 1 - message exchange
104
+ This is the lowest framework tier, unless we count the actual data objects processed by the framework. As you already know, the foundational **ti-engine** concept is that of a messaging system. Therefore, the first tier provides an abstraction over a chosen message broker (Redis by default). That abstraction makes it easy to switch between message brokers whenever you want to without having to change anything above tier 1. It also provides several added bonuses that can accelerate your work - message encryption, message tracing, message observers, and others. More details about each of these features will be covered in section [using the framework](#using-the-framework).
105
+
106
+ Another important aspect for you to remember is that the message exchange is entirely _asynchronous_. This helps reduce system load and optimizes the usage of the available resources. Even so each node.js process can handle a limited amount of load. Therefore, you should plan for running multiple identical senders and receives in order to scale your solution. But more on that later.
107
+
108
+ For now, take a look at the following diagram:
109
+
110
+ ![Message Exchange](https://github.com/Belleal/ti-engine/blob/master/core/docs/diagram1.png)
111
+
112
+ It shows the standard flow of a message exchange between one sender and _n_ identical message receivers. The sender splits each message into an _envelope_ and a _payload_, then stores the payload in the shared cache and enqueues the envelope in the requests (destination) queue. Receivers can subscribe to that queue in order to fetch enqueued messages and process their contents. During the fetch sequence a receiver assembles the full message by getting the payload from the storage. This process is depicted by the blue flow lines.
113
+
114
+ After the processing is done the message payload is modified and the receiver sends the message back to the original sender using the same mechanism. It again splits the message into an envelope and a payload, stores the payload in the storage and enqueues the envelope in the sender response (source) queue. The sender will then assemble the message back and process the contained results. This process is depicted by the red flow lines.
115
+
116
+ In this scenario the framework utilizes _Redis lists_ as queues for the message envelopes and _Redis hash_ as message payload storage. Other message brokers might utilize a slightly different approach, but they should still adhere to the same logical flow.
117
+
118
+ ### tier 2 - service domains
119
+ This tier focuses on hosting and executing the _business logic_ of your application. It's comprised of _business services_ that process input data and return the result of the processing as output data. The business services are grouped in _service domains_, which are in turn hosted inside stateless _microservices_ also named _service instances_. There are two types of service instances in **ti-engine**:
120
+ * Service consumers - these are service instances, that can call business services in any available service domain.
121
+ * Service providers - these are service instances, that host and run a set of business services in a particular service domain. Every service provider is also a service consumer.
122
+
123
+ The various service instances in a solution represent a network of interconnected service domains that contain the business logic of your application. All business services exchange data via _service calls_ using abstract _service addresses_. These service calls are transported from one address in the network to another via the underlying message exchange tier. This, however, is completely transparent to the service instances. In essence, tier 2 does not care about the actual data transportation method or protocol. You could in fact change completely the tier 1 approach without having to modify anything in your business logic and business flow.
124
+
125
+ ### tier 3 - solution implementation
94
126
  Under development...
95
127
 
96
128
  ## creating a microservice
package/bin/settings.json CHANGED
@@ -20,6 +20,8 @@
20
20
  "messageExchange": {
21
21
  "messageQueuePrefix": "ti:messages:",
22
22
  "messageStore": "ti:messages:store",
23
+ "securityHashEnabled": true,
24
+ "securityHashKey": "23e7bdc7-a793-41f9-856e-6760332f0c73",
23
25
  "traceLogEnabled": true
24
26
  },
25
27
  "serviceConfig": {
@@ -23,10 +23,9 @@ class DefaultMessageReceiver extends MessageReceiver {
23
23
  * @constructor
24
24
  * @param {string} identifier An identifier for this message handler. Should be unique in the context of the message exchange.
25
25
  * @param {string} receiveQueue The queue from which the messages will be received.
26
- * @param {string} [processingQueue=undefined] The queue in which the messages will be put for processing (if necessary).
27
26
  */
28
- constructor( identifier, receiveQueue, processingQueue = undefined ) {
29
- super( identifier, receiveQueue, processingQueue );
27
+ constructor( identifier, receiveQueue ) {
28
+ super( identifier, receiveQueue );
30
29
  }
31
30
 
32
31
  /**
@@ -75,7 +74,7 @@ class DefaultMessageReceiver extends MessageReceiver {
75
74
  onReceive() {
76
75
  return new Promise( ( resolve, reject ) => {
77
76
  this.#memoryCache.receiveMessage( this.receiveQueue ).then( ( lightweightMessage ) => {
78
- return this.#memoryCache.retrieveMessagePayload( lightweightMessage, config.getSetting( config.setting.MESSAGE_EXCHANGE_STORE ) );
77
+ return this.#memoryCache.retrieveMessagePayload( lightweightMessage, config.getSetting( config.setting.MESSAGE_EXCHANGE_MESSAGE_STORE ) );
79
78
  } ).then( ( message ) => {
80
79
  resolve( message );
81
80
  } ).catch( ( error ) => {
@@ -42,7 +42,7 @@ class DefaultMessageSender extends MessageSender {
42
42
  */
43
43
  onSend( message, queue ) {
44
44
  return new Promise( ( resolve, reject ) => {
45
- this.#memoryCache.storeMessagePayload( message.payload, config.getSetting( config.setting.MESSAGE_EXCHANGE_STORE ) ).then( ( storeID ) => {
45
+ this.#memoryCache.storeMessagePayload( message.payload, config.getSetting( config.setting.MESSAGE_EXCHANGE_MESSAGE_STORE ) ).then( ( storeID ) => {
46
46
  let lightweightMessage = _.cloneDeep( message );
47
47
  lightweightMessage.payload = storeID;
48
48
  return this.#memoryCache.sendMessage( lightweightMessage, queue );
@@ -25,8 +25,9 @@ const messageTracer = require( "#message-tracer" );
25
25
  * @property {string} chainID Unique identifier of the message chain if the message is part of one.
26
26
  * @property {number} chainLevel The node level of this message in the message chain tree.
27
27
  * @property {MessageDestination} destination The destination of the message.
28
+ * @property {string} [hash] Security hash for the message if the mechanism is enabled.
28
29
  * @property {string} messageID Unique message identifier.
29
- * @property {Object|string|undefined} payload The message contents to be processed in destination. If string, it is ID of the payload in the memory cache instead.
30
+ * @property {Object|string|undefined} payload The message contents to be processed in destination. If string it is ID of the payload in the memory cache instead.
30
31
  * Note that if this is not an Object or a string, there is no guarantee that it will be delivered in the same/proper format!
31
32
  * @property {MessageSource} source The source of the message.
32
33
  */
@@ -5,8 +5,11 @@
5
5
 
6
6
  const ConnectionObserver = require( "#connection-observer" );
7
7
  const _ = require( "lodash" );
8
+ const blake2 = require( "blake2" );
8
9
  const exceptions = require( "#exceptions" );
9
10
  const logger = require( "#logger" );
11
+ const tools = require( "#tools" );
12
+ const config = require( "#config" );
10
13
 
11
14
  /**
12
15
  * An abstract class that defines a basic message handler behavior.
@@ -98,6 +101,21 @@ class MessageHandler extends ConnectionObserver {
98
101
  return Promise.reject( exceptions.raise( exceptions.exceptionCode.E_GEN_ABSTRACT_METHOD_CALL, { name: this.constructor.name + "." + this.disable.name } ) );
99
102
  }
100
103
 
104
+ /**
105
+ * Used to create a security hash from the message.
106
+ *
107
+ * @method
108
+ * @param {Message} message
109
+ * @returns {string}
110
+ * @public
111
+ */
112
+ createMessageHash( message ) {
113
+ let transformed = tools.decomposeJSON( tools.decycle( message ) );
114
+ let hash = blake2.createKeyedHash( "blake2b", Buffer.from( config.getSetting( config.setting.MESSAGE_EXCHANGE_SECURITY_HASH_KEY ) ) );
115
+ hash.update( Buffer.from( transformed ) );
116
+ return hash.digest( "hex" );
117
+ }
118
+
101
119
  /**
102
120
  * Used to register a new {@link MessageObserver} for events related to the messages passing through this handler.
103
121
  *
@@ -6,6 +6,7 @@
6
6
  const MessageHandler = require( "#message-handler" );
7
7
  const logger = require( "#logger" );
8
8
  const exceptions = require( "#exceptions" );
9
+ const config = require( "#config" );
9
10
 
10
11
  /**
11
12
  * An abstract class that defines a basic message receiver behavior.
@@ -84,6 +85,8 @@ class MessageReceiver extends MessageHandler {
84
85
  */
85
86
  receive() {
86
87
  this.onReceive().then( ( message ) => {
88
+ return this.#postReceive( message );
89
+ } ).then( ( message ) => {
87
90
  this.onMessage( message );
88
91
  } ).catch( ( error ) => {
89
92
  logger.log( `Error while trying to receive the next pending message from memory cache in receiver '${ this.connectionIdentifier }'! Resuming operation...`, logger.logSeverity.ERROR, error );
@@ -108,6 +111,37 @@ class MessageReceiver extends MessageHandler {
108
111
  return Promise.reject( exceptions.raise( exceptions.exceptionCode.E_GEN_ABSTRACT_METHOD_CALL, { name: this.constructor.name + "." + this.onReceive.name } ) );
109
112
  }
110
113
 
114
+ /* Private interface */
115
+
116
+ /**
117
+ * Used to process the received message before providing it to any {@link MessageObserver}.
118
+ *
119
+ * @method
120
+ * @param {Message} message
121
+ * @returns {Promise<Message>}
122
+ * @private
123
+ */
124
+ #postReceive( message ) {
125
+ return new Promise( ( resolve, reject ) => {
126
+ if ( config.getSetting( config.setting.MESSAGE_EXCHANGE_SECURITY_HASH_ENABLED ) === true ) {
127
+ let receivedHash = message.hash;
128
+ delete message.hash;
129
+ let currentHash = this.createMessageHash( message );
130
+ if ( receivedHash && receivedHash === currentHash ) {
131
+ resolve( message );
132
+ } else {
133
+ reject( exceptions.raise( exceptions.exceptionCode.E_SEC_MESSAGE_TAMPERING_DETECTED, {
134
+ messageID: message.messageID,
135
+ receivedHash: receivedHash,
136
+ currentHash: currentHash
137
+ } ) );
138
+ }
139
+ } else {
140
+ resolve( message );
141
+ }
142
+ } );
143
+ }
144
+
111
145
  }
112
146
 
113
147
  module.exports = MessageReceiver;
@@ -5,6 +5,7 @@
5
5
 
6
6
  const MessageHandler = require( "#message-handler" );
7
7
  const exceptions = require( "#exceptions" );
8
+ const config = require( "#config" );
8
9
 
9
10
  /**
10
11
  * An abstract class that defines a basic message sender behavior.
@@ -70,7 +71,7 @@ class MessageSender extends MessageHandler {
70
71
  */
71
72
  send( message, queue ) {
72
73
  return new Promise( ( resolve, reject ) => {
73
- this.#preSend().then( () => {
74
+ this.#preSend( message ).then( ( message ) => {
74
75
  return this.onSend( message, queue );
75
76
  } ).then( () => {
76
77
  return this.#postSend();
@@ -106,12 +107,17 @@ class MessageSender extends MessageHandler {
106
107
  * Used to do pre-send verifications and checks.
107
108
  *
108
109
  * @method
109
- * @returns {Promise}
110
+ * @param {Message} message
111
+ * @returns {Promise<Message>}
110
112
  * @private
111
113
  */
112
- #preSend() {
114
+ #preSend( message ) {
113
115
  if ( this.isAvailable === true ) {
114
- return Promise.resolve();
116
+ if ( config.getSetting( config.setting.MESSAGE_EXCHANGE_SECURITY_HASH_ENABLED ) === true ) {
117
+ message.hash = this.createMessageHash( message );
118
+ }
119
+
120
+ return Promise.resolve( message );
115
121
  } else {
116
122
  return Promise.reject( exceptions.raise( exceptions.exceptionCode.E_COM_MESSAGE_SENDER_UNAVAILABLE ) );
117
123
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ti-engine/core",
3
- "version": "1.0.7",
3
+ "version": "1.0.11",
4
4
  "description": "The ti-engine is an open source, free to use - both for personal and commercial projects - framework for the creation of microservice-based solutions using node.js.",
5
5
  "author": "Boris Kostadinov <kostadinov.boris@gmail.com>",
6
6
  "license": "ISC",
@@ -41,12 +41,12 @@
41
41
  "#tools": "./utils/tools.js"
42
42
  },
43
43
  "dependencies": {
44
- "blake2": "^4.0.2",
45
- "dotenv": "^10.0.0",
44
+ "blake2": "^4.1.0",
45
+ "dotenv": "^14.1.0",
46
46
  "fs-extra": "^10.0.0",
47
47
  "lodash": "^4.17.21",
48
- "node-schedule": "^2.0.0",
49
- "ioredis": "^4.28.1"
48
+ "node-schedule": "^2.1.0",
49
+ "ioredis": "^4.28.3"
50
50
  },
51
51
  "optionalDependencies": {
52
52
  "@google-cloud/error-reporting": "^2.0.4"
package/utils/config.js CHANGED
@@ -20,13 +20,16 @@ const tools = require( "#tools" );
20
20
  * @property {EnvironmentVariable} env.TI_INSTANCE_CONFIG
21
21
  * @property {EnvironmentVariable} env.TI_INSTANCE_ID
22
22
  * @property {EnvironmentVariable} env.TI_INSTANCE_NAME
23
- * @property {EnvironmentVariable} env.TI_LOG_CONSOLE_ENABLED
24
- * @property {EnvironmentVariable} env.TI_LOG_MIN_LEVEL
25
- * @property {EnvironmentVariable} env.TI_LOG_USED_JSON
23
+ * @property {EnvironmentVariable} env.TI_AUDITING_LOG_CONSOLE_ENABLED
24
+ * @property {EnvironmentVariable} env.TI_AUDITING_LOG_MIN_LEVEL
25
+ * @property {EnvironmentVariable} env.TI_AUDITING_LOG_USES_JSON
26
26
  * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_AUTH_KEY
27
- * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_DB
28
- * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_HOST
29
- * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_PORT
27
+ * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_REDIS_DB
28
+ * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_REDIS_HOST
29
+ * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_REDIS_PORT
30
+ * @property {EnvironmentVariable} env.TI_MESSAGE_EXCHANGE_SECURITY_HASH_ENABLED
31
+ * @property {EnvironmentVariable} env.TI_MESSAGE_EXCHANGE_SECURITY_HASH_KEY
32
+ * @property {EnvironmentVariable} env.TI_MESSAGE_EXCHANGE_TRACE_LOG_ENABLED
30
33
  * @property {EnvironmentVariable} env.TI_OPERATION_MODE
31
34
  */
32
35
 
@@ -70,6 +73,8 @@ const tools = require( "#tools" );
70
73
  * @typedef {Object} SettingsMessageExchange
71
74
  * @property {string} messageQueuePrefix
72
75
  * @property {string} messageStore
76
+ * @property {boolean} securityHashEnabled
77
+ * @property {string} securityHashKey
73
78
  * @property {boolean} traceLogEnabled
74
79
  */
75
80
 
@@ -100,7 +105,9 @@ let settingsEnum = tools.enum( {
100
105
  MEMORY_CACHE_REDIS_HOST: [ "memoryCache.redisHost", "redisHost", "" ],
101
106
  MEMORY_CACHE_REDIS_PORT: [ "memoryCache.redisPort", "redisPort", "" ],
102
107
  MESSAGE_EXCHANGE_QUEUE_PREFIX: [ "messageExchange.messageQueuePrefix", "messageQueuePrefix", "" ],
103
- MESSAGE_EXCHANGE_STORE: [ "messageExchange.messageStore", "messageStore", "" ],
108
+ MESSAGE_EXCHANGE_MESSAGE_STORE: [ "messageExchange.messageStore", "messageStore", "" ],
109
+ MESSAGE_EXCHANGE_SECURITY_HASH_ENABLED: [ "messageExchange.securityHashEnabled", "securityHashEnabled", "" ],
110
+ MESSAGE_EXCHANGE_SECURITY_HASH_KEY: [ "messageExchange.securityHashKey", "securityHashKey", "" ],
104
111
  MESSAGE_EXCHANGE_TRACE_LOG_ENABLED: [ "messageExchange.traceLogEnabled", "traceLogEnabled", "" ],
105
112
  SERVICE_EXECUTION_TIMEOUT: [ "serviceConfig.executionTimeout", "executionTimeout", "" ],
106
113
  SERVICE_HEALTH_CHECK_ADDRESS: [ "serviceConfig.healthCheckAddress", "healthCheckAddress", "" ],
@@ -120,18 +127,23 @@ const settings = require( "#settings" );
120
127
 
121
128
  // override remaining settings with ENV variables (if provided):
122
129
  if ( settings.auditing ) {
123
- settings.auditing.logMinLevel = ( process.env.TI_LOG_MIN_LEVEL !== undefined ) ? process.env.TI_LOG_MIN_LEVEL : settings.auditing.logMinLevel;
124
- settings.auditing.logConsoleEnabled = ( process.env.TI_LOG_CONSOLE_ENABLED !== undefined ) ? tools.toBool( process.env.TI_LOG_CONSOLE_ENABLED ) : settings.auditing.logConsoleEnabled;
125
- settings.auditing.logUsesJSON = ( process.env.TI_LOG_USED_JSON !== undefined ) ? tools.toBool( process.env.TI_LOG_USED_JSON ) : settings.auditing.logUsesJSON;
130
+ settings.auditing.logMinLevel = ( process.env.TI_AUDITING_LOG_MIN_LEVEL !== undefined ) ? process.env.TI_AUDITING_LOG_MIN_LEVEL : settings.auditing.logMinLevel;
131
+ settings.auditing.logConsoleEnabled = ( process.env.TI_AUDITING_LOG_CONSOLE_ENABLED !== undefined ) ? tools.toBool( process.env.TI_AUDITING_LOG_CONSOLE_ENABLED ) : settings.auditing.logConsoleEnabled;
132
+ settings.auditing.logUsesJSON = ( process.env.TI_AUDITING_LOG_USES_JSON !== undefined ) ? tools.toBool( process.env.TI_AUDITING_LOG_USES_JSON ) : settings.auditing.logUsesJSON;
126
133
  }
127
134
  if ( settings.memoryCache ) {
128
135
  settings.memoryCache.authKey = ( process.env.TI_MEMORY_CACHE_AUTH_KEY !== undefined ) ? process.env.TI_MEMORY_CACHE_AUTH_KEY : settings.memoryCache.authKey;
129
- settings.memoryCache.redisDB = ( process.env.TI_MEMORY_CACHE_DB !== undefined ) ? process.env.TI_MEMORY_CACHE_DB : settings.memoryCache.redisDB;
130
- settings.memoryCache.redisHost = ( process.env.TI_MEMORY_CACHE_HOST !== undefined ) ? process.env.TI_MEMORY_CACHE_HOST : settings.memoryCache.redisHost;
131
- settings.memoryCache.redisPort = ( process.env.TI_MEMORY_CACHE_PORT !== undefined ) ? process.env.TI_MEMORY_CACHE_PORT : settings.memoryCache.redisPort;
136
+ settings.memoryCache.redisDB = ( process.env.TI_MEMORY_CACHE_REDIS_DB !== undefined ) ? process.env.TI_MEMORY_CACHE_REDIS_DB : settings.memoryCache.redisDB;
137
+ settings.memoryCache.redisHost = ( process.env.TI_MEMORY_CACHE_REDIS_HOST !== undefined ) ? process.env.TI_MEMORY_CACHE_REDIS_HOST : settings.memoryCache.redisHost;
138
+ settings.memoryCache.redisPort = ( process.env.TI_MEMORY_CACHE_REDIS_PORT !== undefined ) ? process.env.TI_MEMORY_CACHE_REDIS_PORT : settings.memoryCache.redisPort;
139
+ }
140
+ if ( settings.messageExchange ) {
141
+ settings.messageExchange.securityHashEnabled = ( process.env.TI_MESSAGE_EXCHANGE_SECURITY_HASH_ENABLED !== undefined ) ? tools.toBool( process.env.TI_MESSAGE_EXCHANGE_SECURITY_HASH_ENABLED ) : settings.messageExchange.securityHashEnabled;
142
+ settings.messageExchange.securityHashKey = ( process.env.TI_MESSAGE_EXCHANGE_SECURITY_HASH_KEY !== undefined ) ? process.env.TI_MESSAGE_EXCHANGE_SECURITY_HASH_KEY : settings.messageExchange.securityHashKey;
143
+ settings.messageExchange.traceLogEnabled = ( process.env.TI_MESSAGE_EXCHANGE_TRACE_LOG_ENABLED !== undefined ) ? tools.toBool( process.env.TI_MESSAGE_EXCHANGE_TRACE_LOG_ENABLED ) : settings.messageExchange.traceLogEnabled;
132
144
  }
133
145
 
134
- // make sure GCloud is enabled before trying to setup it:
146
+ // make sure GCloud is enabled before trying to set it up:
135
147
  if ( process.env.TI_GCLOUD_ENABLED === true && settings.gcloudIntegration ) {
136
148
  settings.gcloudIntegration.apiKey = ( process.env.TI_GCLOUD_API_KEY !== undefined ) ? process.env.TI_GCLOUD_API_KEY : settings.gcloudIntegration.apiKey;
137
149
  settings.gcloudIntegration.projectID = ( process.env.TI_GCLOUD_PROJECT_ID !== undefined ) ? process.env.TI_GCLOUD_PROJECT_ID : settings.gcloudIntegration.projectID;
@@ -25,6 +25,7 @@ let exceptionCodeEnum = tools.enum( {
25
25
  E_SEC_INVALID_AUTH_TOKEN: [ 2000, "invalid auth token", "Invalid authorization token provided." ],
26
26
  E_SEC_INVALID_EXPIRED_SESSION: [ 2001, "invalid or expired session", "Invalid or expired session encountered." ],
27
27
  E_SEC_UNAUTHORIZED_ACCESS: [ 2002, "unauthorized access", "Attempt for unauthorized access detected." ],
28
+ E_SEC_MESSAGE_TAMPERING_DETECTED: [ 2003, "message tampering detected", "The system detected tampering with the message received via message exchange." ],
28
29
  /** Cross-Application Communication exceptions - codes under 3xxx */
29
30
  E_COM_GENERAL_ERROR: [ 3000, "general communication error", "General error during cross-application communication." ],
30
31
  E_COM_MESSAGE_SENDER_UNAVAILABLE: [ 3001, "message sender unavailable", "The message sender instance is currently unavailable." ],
package/utils/tools.js CHANGED
@@ -35,7 +35,7 @@ module.exports.getUUID = () => {
35
35
  *
36
36
  * @method
37
37
  * @param {Object} seed
38
- * @returns {TiEnum}
38
+ * @returns {Object}
39
39
  * @public
40
40
  */
41
41
  module.exports.enum = ( seed ) => {