@mojaloop/sdk-scheme-adapter 12.2.0 → 12.2.3

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/.env.example CHANGED
@@ -141,7 +141,7 @@ ALLOW_TRANSFER_WITHOUT_QUOTE=false
141
141
  # To enable request for notification on fulfiled transfer
142
142
  RESERVE_NOTIFICATION=true
143
143
 
144
- # resources API versions should be string in format: "resouceOneName=1.0,resourceTwoName=1.1"
144
+ # resources API versions should be string in format: "resourceOneName=1.0,resourceTwoName=1.1"
145
145
  RESOURCE_VERSIONS="transfers=1.1,participants=1.1"
146
146
 
147
147
  # Management API websocket connection settings.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,25 @@
1
1
  # Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
2
+ ### [12.2.3](https://github.com/mojaloop/sdk-scheme-adapter/compare/v12.2.2...v12.2.3) (2022-04-26)
3
+
4
+
5
+ ### Refactors
6
+
7
+ * change config structure and remove unused code ([#311](https://github.com/mojaloop/sdk-scheme-adapter/issues/311)) ([c2e69e7](https://github.com/mojaloop/sdk-scheme-adapter/commit/c2e69e751daf7ad74ae213e8987946fdb84dd427))
8
+
9
+ ### [12.2.2](https://github.com/mojaloop/sdk-scheme-adapter/compare/v12.2.1...v12.2.2) (2022-04-22)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * make management url config option optional ([#310](https://github.com/mojaloop/sdk-scheme-adapter/issues/310)) ([93c4048](https://github.com/mojaloop/sdk-scheme-adapter/commit/93c4048d5a604be81ce90365ff3f9cd42b531fef))
15
+
16
+ ### [12.2.1](https://github.com/mojaloop/sdk-scheme-adapter/compare/v12.2.0...v12.2.1) (2022-04-21)
17
+
18
+
19
+ ### Chore
20
+
21
+ * **deps:** bump validator from 13.6.0 to 13.7.0 ([#309](https://github.com/mojaloop/sdk-scheme-adapter/issues/309)) ([3800820](https://github.com/mojaloop/sdk-scheme-adapter/commit/3800820b095fa86147189e836817c49b380b6814))
22
+
2
23
  ## [12.2.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v12.1.0...v12.2.0) (2022-04-21)
3
24
 
4
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/sdk-scheme-adapter",
3
- "version": "12.2.0",
3
+ "version": "12.2.3",
4
4
  "description": "An adapter for connecting to Mojaloop API enabled switches.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -78,6 +78,7 @@
78
78
  "oauth2-server": "^4.0.0-dev.2",
79
79
  "openapi-jsonschema-parameters": "^9.3.0",
80
80
  "promise-timeout": "^1.3.0",
81
+ "random-word-slugs": "^0.1.6",
81
82
  "redis": "^3.1.2",
82
83
  "uuidv4": "^6.2.12",
83
84
  "ws": "^7.5.5"
@@ -25,8 +25,7 @@
25
25
  const assert = require('assert').strict;
26
26
  const ws = require('ws');
27
27
  const jsonPatch = require('fast-json-patch');
28
- const randomPhrase = require('~/lib/randomphrase');
29
-
28
+ const { generateSlug } = require('random-word-slugs');
30
29
 
31
30
  /**************************************************************************
32
31
  * The message protocol messages, verbs, and errors
@@ -75,7 +74,7 @@ const deserialise = (msg) => {
75
74
  });
76
75
  };
77
76
 
78
- const buildMsg = (verb, msg, data, id = randomPhrase()) => serialise({
77
+ const buildMsg = (verb, msg, data, id = generateSlug(4)) => serialise({
79
78
  verb,
80
79
  msg,
81
80
  data,
@@ -26,8 +26,8 @@ const assert = require('assert').strict;
26
26
 
27
27
  const ws = require('ws');
28
28
  const jsonPatch = require('fast-json-patch');
29
+ const { generateSlug } = require('random-word-slugs');
29
30
 
30
- const randomPhrase = require('~/lib/randomphrase');
31
31
 
32
32
  /**************************************************************************
33
33
  * The message protocol messages, verbs, and errors
@@ -76,7 +76,7 @@ const deserialise = (msg) => {
76
76
  });
77
77
  };
78
78
 
79
- const buildMsg = (verb, msg, data, id = randomPhrase()) => serialise({
79
+ const buildMsg = (verb, msg, data, id = generateSlug(4)) => serialise({
80
80
  verb,
81
81
  msg,
82
82
  data,
@@ -35,7 +35,7 @@ class InboundApi extends EventEmitter {
35
35
  auth: new WSO2Auth({
36
36
  ...conf.wso2.auth,
37
37
  logger,
38
- tlsCreds: conf.mutualTLS.outboundRequests.enabled && conf.mutualTLS.outboundRequests.creds,
38
+ tlsCreds: conf.inbound.tls.mutualTLS.enabled && conf.inbound.tls.creds,
39
39
  }),
40
40
  retryWso2AuthFailureTimes: conf.wso2.requestAuthFailureRetryTimes,
41
41
  };
@@ -160,8 +160,8 @@ class InboundServer extends EventEmitter {
160
160
  this.emit('error', ...args);
161
161
  });
162
162
  this._server = this._createServer(
163
- conf.mutualTLS.inboundRequests.enabled,
164
- conf.mutualTLS.inboundRequests.creds,
163
+ conf.inbound.tls.mutualTLS.enabled,
164
+ conf.inbound.tls.creds,
165
165
  this._api.callback()
166
166
  );
167
167
  }
@@ -172,8 +172,8 @@ class InboundServer extends EventEmitter {
172
172
  const apiSpecs = yaml.load(fs.readFileSync(specPath));
173
173
  await this._validator.initialise(apiSpecs);
174
174
  await this._api.start();
175
- await new Promise((resolve) => this._server.listen(this._conf.inboundServerPort, resolve));
176
- this._logger.log(`Serving inbound API on port ${this._conf.inboundServerPort}`);
175
+ await new Promise((resolve) => this._server.listen(this._conf.inbound.port, resolve));
176
+ this._logger.log(`Serving outbound API on port ${this._conf.inbound.port}`);
177
177
  }
178
178
 
179
179
  async stop() {
@@ -194,7 +194,7 @@ class InboundServer extends EventEmitter {
194
194
  // are subclasses of net.Server. This wasn't considered as a requirement at the time of
195
195
  // writing.
196
196
  assert(
197
- this._conf.mutualTLS.inboundRequests.enabled === conf.mutualTLS.inboundRequests.enabled,
197
+ this._conf.inbound.tls.mutualTLS.enabled === conf.inbound.tls.mutualTLS.enabled,
198
198
  'Cannot live-restart an HTTPS server as HTTP or vice versa',
199
199
  );
200
200
  const newApi = new InboundApi(conf, logger, cache, this._validator);
@@ -207,7 +207,7 @@ class InboundServer extends EventEmitter {
207
207
  conf.inbound.tls.creds,
208
208
  this._conf.inbound.tls.creds
209
209
  );
210
- if (this._conf.mutualTLS.inboundRequests.enabled && tlsCredsChanged) {
210
+ if (this._conf.inbound.tls.mutualTLS.enabled && tlsCredsChanged) {
211
211
  this._server.setSecureContext(conf.inbound.tls.creds);
212
212
  }
213
213
  this._server.removeAllListeners('request');
@@ -10,7 +10,7 @@
10
10
 
11
11
  const coBody = require('co-body');
12
12
 
13
- const randomPhrase = require('../lib/randomphrase');
13
+ const { generateSlug } = require('random-word-slugs');
14
14
  const { Jws, Errors } = require('@mojaloop/sdk-standard-components');
15
15
  const {
16
16
  parseAcceptHeader,
@@ -157,7 +157,7 @@ const cacheRequest = (cache) => async (ctx, next) => {
157
157
  * @return {Function}
158
158
  */
159
159
  const createRequestIdGenerator = () => async (ctx, next) => {
160
- ctx.request.id = randomPhrase();
160
+ ctx.request.id = generateSlug(4);
161
161
  await next();
162
162
  };
163
163
 
@@ -39,7 +39,7 @@ class OutboundApi extends EventEmitter {
39
39
  auth: new WSO2Auth({
40
40
  ...this._conf.wso2.auth,
41
41
  logger: this._logger,
42
- tlsCreds: this._conf.mutualTLS.outboundRequests.enabled && this._conf.mutualTLS.outboundRequests.creds,
42
+ tlsCreds: this._conf.outbound.tls.mutualTLS.enabled && this._conf.outbound.tls.creds,
43
43
  }),
44
44
  retryWso2AuthFailureTimes: conf.wso2.requestAuthFailureRetryTimes,
45
45
  };
@@ -67,7 +67,7 @@ class OutboundApi extends EventEmitter {
67
67
  proxyConfig: conf.proxyConfig,
68
68
  logger: this._logger,
69
69
  wso2Auth: this._wso2.auth,
70
- tls: conf.mutualTLS.outboundRequests,
70
+ tls: conf.outbound.tls,
71
71
  }));
72
72
  }
73
73
 
@@ -111,14 +111,11 @@ class OutboundServer extends EventEmitter {
111
111
 
112
112
  async start() {
113
113
  await this._api.start();
114
-
115
114
  const specPath = path.join(__dirname, 'api.yaml');
116
115
  const apiSpecs = yaml.load(fs.readFileSync(specPath));
117
116
  await this._validator.initialise(apiSpecs);
118
-
119
- await new Promise((resolve) => this._server.listen(this._conf.outboundServerPort, resolve));
120
-
121
- this._logger.log(`Serving outbound API on port ${this._conf.outboundServerPort}`);
117
+ await new Promise((resolve) => this._server.listen(this._conf.outbound.port, resolve));
118
+ this._logger.log(`Serving outbound API on port ${this._conf.outbound.port}`);
122
119
  }
123
120
 
124
121
  async stop() {
package/src/config.js CHANGED
@@ -22,8 +22,8 @@ function getFileContent (path) {
22
22
  }
23
23
 
24
24
  /**
25
- * Gets Resources versions from enviromental variable RESOURCES_VERSIONS
26
- * should be string in format: "resouceOneName=1.0,resourceTwoName=1.1"
25
+ * Gets Resources versions from environmental variable RESOURCES_VERSIONS
26
+ * should be string in format: "resourceOneName=1.0,resourceTwoName=1.1"
27
27
  */
28
28
  function getVersionFromConfig (resourceString) {
29
29
  const resourceVersionMap = {};
@@ -44,7 +44,7 @@ function parseResourceVersions (resourceString) {
44
44
  const resourceFormatRegex = /(([A-Za-z])\w*)=([0-9]+).([0-9]+)([^;:|],*)/g;
45
45
  const noSpResources = resourceString.replace(/\s/g,'');
46
46
  if (!resourceFormatRegex.test(noSpResources)) {
47
- throw new Error('Resource versions format should be in format: "resouceOneName=1.0,resourceTwoName=1.1"');
47
+ throw new Error('Resource versions format should be in format: "resourceOneName=1.0,resourceTwoName=1.1"');
48
48
  }
49
49
  return getVersionFromConfig(noSpResources);
50
50
  }
@@ -59,20 +59,28 @@ const env = from(process.env, {
59
59
  module.exports = {
60
60
  __parseResourceVersion: parseResourceVersions,
61
61
  control: {
62
- mgmtAPIWsUrl: env.get('MGMT_API_WS_URL').required().asString(),
62
+ mgmtAPIWsUrl: env.get('MGMT_API_WS_URL').default('127.0.0.1').asString(),
63
63
  mgmtAPIWsPort: env.get('MGMT_API_WS_PORT').default('4005').asPortNumber()
64
64
  },
65
- mutualTLS: {
66
- inboundRequests: {
67
- enabled: env.get('INBOUND_MUTUAL_TLS_ENABLED').default('false').asBool(),
65
+ inbound: {
66
+ port: env.get('INBOUND_LISTEN_PORT').default('4000').asPortNumber(),
67
+ tls: {
68
+ mutualTLS: {
69
+ enabled: env.get('INBOUND_MUTUAL_TLS_ENABLED').default('false').asBool(),
70
+ },
68
71
  creds: {
69
72
  ca: env.get('IN_CA_CERT_PATH').asFileListContent(),
70
73
  cert: env.get('IN_SERVER_CERT_PATH').asFileContent(),
71
74
  key: env.get('IN_SERVER_KEY_PATH').asFileContent(),
72
75
  },
73
76
  },
74
- outboundRequests: {
75
- enabled: env.get('OUTBOUND_MUTUAL_TLS_ENABLED').default('false').asBool(),
77
+ },
78
+ outbound: {
79
+ port: env.get('OUTBOUND_LISTEN_PORT').default('4001').asPortNumber(),
80
+ tls: {
81
+ mutualTLS: {
82
+ enabled: env.get('OUTBOUND_MUTUAL_TLS_ENABLED').default('false').asBool(),
83
+ },
76
84
  creds: {
77
85
  ca: env.get('OUT_CA_CERT_PATH').asFileListContent(),
78
86
  cert: env.get('OUT_CLIENT_CERT_PATH').asFileContent(),
@@ -80,9 +88,9 @@ module.exports = {
80
88
  },
81
89
  },
82
90
  },
83
- inboundServerPort: env.get('INBOUND_LISTEN_PORT').default('4000').asPortNumber(),
84
- outboundServerPort: env.get('OUTBOUND_LISTEN_PORT').default('4001').asPortNumber(),
85
- testServerPort: env.get('TEST_LISTEN_PORT').default('4002').asPortNumber(),
91
+ test: {
92
+ port: env.get('TEST_LISTEN_PORT').default('4002').asPortNumber(),
93
+ },
86
94
  peerEndpoint: env.get('PEER_ENDPOINT').required().asString(),
87
95
  alsEndpoint: env.get('ALS_ENDPOINT').asString(),
88
96
  quotesEndpoint: env.get('QUOTES_ENDPOINT').asString(),
@@ -97,6 +105,9 @@ module.exports = {
97
105
  checkIlp: env.get('CHECK_ILP').default('true').asBool(),
98
106
  expirySeconds: env.get('EXPIRY_SECONDS').default('60').asIntPositive(),
99
107
 
108
+ multiplePartiesResponse: env.get('MULTIPLE_PARTIES_RESPONSE').default('false').asBool(),
109
+ multiplePartiesResponseSeconds: env.get('MULTIPLE_PARTIES_RESPONSE_SECONDS').default('30').asIntPositive(),
110
+
100
111
  autoAcceptQuotes: env.get('AUTO_ACCEPT_QUOTES').default('true').asBool(),
101
112
  autoAcceptParty: env.get('AUTO_ACCEPT_PARTY').default('true').asBool(),
102
113
  autoAcceptR2PBusinessQuotes: env.get('AUTO_ACCEPT_R2P_BUSINESS_QUOTES').default('false').asBool(),
@@ -157,13 +168,19 @@ module.exports = {
157
168
 
158
169
  proxyConfig: env.get('PROXY_CONFIG_PATH').asYamlConfig(),
159
170
  reserveNotification: env.get('RESERVE_NOTIFICATION').default('false').asBool(),
160
- // resourceVersions config should be string in format: "resouceOneName=1.0,resourceTwoName=1.1"
171
+ sendFinalNotificationIfRequested: env.get('SEND_FINAL_NOTIFICATION_IF_REQUESTED').default('false').asBool(),
172
+
173
+ // resourceVersions config should be string in format: "resourceOneName=1.0,resourceTwoName=1.1"
161
174
  resourceVersions: env.get('RESOURCE_VERSIONS').default('').asResourceVersions(),
162
175
 
176
+ metrics: {
177
+ port: env.get('METRICS_SERVER_LISTEN_PORT').default('4004').asPortNumber()
178
+ },
179
+
163
180
  // in 3PPI DFSP's generate their own `transferId` which is associated with
164
181
  // a transactionRequestId. this option decodes the ilp packet for
165
182
  // the `transactionId` to retrieve the quote from cache
166
183
  allowDifferentTransferTransactionId: env.get('ALLOW_DIFFERENT_TRANSFER_TRANSACTION_ID').default('false').asBool(),
167
184
 
168
- pm4mlEnabled: env.get('PM4ML_ENABLED').default('false').asBool(),
185
+ pm4mlEnabled: env.get('PM4ML_ENABLED').default('false').asBool()
169
186
  };
package/src/index.js CHANGED
@@ -25,7 +25,6 @@ const InboundServerMiddleware = require('./InboundServer/middlewares.js');
25
25
  const OutboundServerMiddleware = require('./OutboundServer/middlewares.js');
26
26
  const Router = require('./lib/router');
27
27
  const Validate = require('./lib/validate');
28
- const RandomPhrase = require('./lib/randomphrase');
29
28
  const Cache = require('./lib/cache');
30
29
  const { Logger } = require('@mojaloop/sdk-standard-components');
31
30
 
@@ -142,7 +141,6 @@ module.exports = {
142
141
  Cache,
143
142
  InboundServerMiddleware,
144
143
  OutboundServerMiddleware,
145
- RandomPhrase,
146
144
  Router,
147
145
  Server,
148
146
  Validate,
@@ -36,7 +36,10 @@ class AccountsModel {
36
36
  logger: this._logger,
37
37
  peerEndpoint: config.alsEndpoint,
38
38
  dfspId: config.dfspId,
39
- tls: config.tls,
39
+ tls: {
40
+ enabled: config.outbound.tls.mutualTLS.enabled,
41
+ creds: config.outbound.tls.creds,
42
+ },
40
43
  jwsSign: config.jwsSign,
41
44
  jwsSigningKey: config.jwsSigningKey,
42
45
  wso2: config.wso2,
@@ -228,7 +228,10 @@ function generate({
228
228
  transfersEndpoint: config.transfersEndpoint,
229
229
  transactionRequestsEndpoint: config.transactionRequestsEndpoint,
230
230
  dfspId: config.dfspId,
231
- tls: config.tls,
231
+ tls: {
232
+ enabled: config.outbound.tls.mutualTLS.enabled,
233
+ creds: config.outbound.tls.creds,
234
+ },
232
235
  jwsSign: config.jwsSign,
233
236
  jwsSignPutParties: config.jwsSignPutParties,
234
237
  jwsSigningKey: config.jwsSigningKey,
@@ -46,7 +46,10 @@ class InboundTransfersModel {
46
46
  transactionRequestsEndpoint: config.transactionRequestsEndpoint,
47
47
  bulkQuotesEndpoint: config.bulkQuotesEndpoint,
48
48
  dfspId: config.dfspId,
49
- tls: config.tls,
49
+ tls: {
50
+ enabled: config.outbound.tls.mutualTLS.enabled,
51
+ creds: config.outbound.tls.creds,
52
+ },
50
53
  jwsSign: config.jwsSign,
51
54
  jwsSigningKey: config.jwsSigningKey,
52
55
  wso2: config.wso2,
@@ -40,7 +40,10 @@ class OutboundBulkQuotesModel {
40
40
  peerEndpoint: config.peerEndpoint,
41
41
  bulkQuotesEndpoint: config.bulkQuotesEndpoint,
42
42
  dfspId: config.dfspId,
43
- tls: config.tls,
43
+ tls: {
44
+ enabled: config.outbound.tls.mutualTLS.enabled,
45
+ creds: config.outbound.tls.creds,
46
+ },
44
47
  jwsSign: config.jwsSign,
45
48
  jwsSigningKey: config.jwsSigningKey,
46
49
  wso2: config.wso2,
@@ -38,7 +38,10 @@ class OutboundBulkTransfersModel {
38
38
  peerEndpoint: config.peerEndpoint,
39
39
  bulkTransfersEndpoint: config.bulkTransfersEndpoint,
40
40
  dfspId: config.dfspId,
41
- tls: config.tls,
41
+ tls: {
42
+ enabled: config.outbound.tls.mutualTLS.enabled,
43
+ creds: config.outbound.tls.creds,
44
+ },
42
45
  jwsSign: config.jwsSign,
43
46
  jwsSignPutParties: config.jwsSignPutParties,
44
47
  jwsSigningKey: config.jwsSigningKey,
@@ -39,7 +39,10 @@ class OutboundRequestToPayModel {
39
39
  peerEndpoint: config.peerEndpoint,
40
40
  alsEndpoint: config.alsEndpoint,
41
41
  dfspId: config.dfspId,
42
- tls: config.tls,
42
+ tls: {
43
+ enabled: config.outbound.tls.mutualTLS.enabled,
44
+ creds: config.outbound.tls.creds,
45
+ },
43
46
  jwsSign: config.jwsSign,
44
47
  jwsSignPutParties: config.jwsSignPutParties,
45
48
  jwsSigningKey: config.jwsSigningKey,
@@ -52,7 +52,10 @@ class OutboundRequestToPayTransferModel {
52
52
  authorizationsEndpoint: config.authorizationsEndpoint,
53
53
  transfersEndpoint: config.transfersEndpoint,
54
54
  dfspId: config.dfspId,
55
- tls: config.tls,
55
+ tls: {
56
+ enabled: config.outbound.tls.mutualTLS.enabled,
57
+ creds: config.outbound.tls.creds,
58
+ },
56
59
  jwsSign: config.jwsSign,
57
60
  jwsSignPutParties: config.jwsSignPutParties,
58
61
  jwsSigningKey: config.jwsSigningKey,
@@ -51,7 +51,10 @@ class OutboundTransfersModel {
51
51
  transfersEndpoint: config.transfersEndpoint,
52
52
  transactionRequestsEndpoint: config.transactionRequestsEndpoint,
53
53
  dfspId: config.dfspId,
54
- tls: config.tls,
54
+ tls: {
55
+ enabled: config.outbound.tls.mutualTLS.enabled,
56
+ creds: config.outbound.tls.creds,
57
+ },
55
58
  jwsSign: config.jwsSign,
56
59
  jwsSignPutParties: config.jwsSignPutParties,
57
60
  jwsSigningKey: config.jwsSigningKey,
@@ -35,8 +35,10 @@ class ProxyModel {
35
35
  this._requests = new MojaloopRequests({
36
36
  logger: this._logger,
37
37
  peerEndpoint: config.peerEndpoint,
38
- dfspId: config.dfspId,
39
- tls: config.tls,
38
+ tls: {
39
+ enabled: config.outbound.tls.mutualTLS.enabled,
40
+ creds: config.outbound.tls.creds,
41
+ },
40
42
  jwsSign: config.jwsSign,
41
43
  jwsSigningKey: config.jwsSigningKey,
42
44
  wso2Auth: config.wso2Auth
@@ -24,7 +24,7 @@ const { Errors } = require('@mojaloop/sdk-standard-components');
24
24
  const Ajv = require('ajv');
25
25
  const ajv = new Ajv({ allErrors: true, coerceTypes: true, strict: false });
26
26
 
27
- const httpMethods = ['get', 'head', 'post', 'put', 'delete', 'connnect', 'options', 'trace', 'patch'];
27
+ const httpMethods = ['get', 'head', 'post', 'put', 'delete', 'connect', 'options', 'trace', 'patch'];
28
28
 
29
29
  // Create a json schema in the format we've chosen to use
30
30
  const createSchema = (pathValue, methodValue) => {
@@ -186,7 +186,7 @@ class Validator {
186
186
 
187
187
  if(firstError.keyword === 'required') {
188
188
  // this is a missing required property; there is a specific mojaloop api spec error code for this
189
- err = new Errors.MojaloopFSPIOPError(firstError, util.format('Request failed validation',
189
+ err = new Errors.MojaloopFSPIOPError(firstError, util.format('Request failed validation',
190
190
  validationResult), null, Errors.MojaloopApiErrorCodes.MISSING_ELEMENT);
191
191
 
192
192
  // overwrite the defaul error message with something more useful
@@ -132,6 +132,11 @@ TRANSFERS_ENDPOINT=ml-testing-toolkit:5000
132
132
  # The fulfilment will be generated from the provided ILP packet, and must hash to the provided condition.
133
133
  ALLOW_TRANSFER_WITHOUT_QUOTE=false
134
134
 
135
+ # To enable request for notification on fulfiled transfer
136
+ RESERVE_NOTIFICATION=true
137
+ # resources API versions should be string in format: "resourceOneName=1.0,resourceTwoName=1.1"
138
+ RESOURCE_VERSIONS="transfers=1.1,participants=1.1"
139
+
135
140
  # Management API websocket connection settings.
136
141
  # The Management API uses this for exchanging connector management messages.
137
142
  MGMT_API_WS_URL=127.0.0.1
@@ -11,7 +11,7 @@
11
11
 
12
12
  const ws = require('ws');
13
13
  const jsonPatch = require('fast-json-patch');
14
- const randomPhrase = require('~/lib/randomphrase');
14
+ const { generateSlug } = require('random-word-slugs');
15
15
  const { getInternalEventEmitter, INTERNAL_EVENTS } = require('./events');
16
16
 
17
17
  const ControlServerEventEmitter = getInternalEventEmitter();
@@ -58,7 +58,7 @@ const deserialise = (msg) => {
58
58
  };
59
59
 
60
60
 
61
- const buildMsg = (verb, msg, data, id = randomPhrase()) => serialise({
61
+ const buildMsg = (verb, msg, data, id = generateSlug(4)) => serialise({
62
62
  verb,
63
63
  msg,
64
64
  data,
@@ -197,7 +197,7 @@ class Server extends ws.Server {
197
197
  * @param {object} params Updated configuration
198
198
  */
199
199
  async broadcastConfigChange(updatedConfig) {
200
- const updateConfMsg = build.CONFIGURATION.PATCH({}, updatedConfig, randomPhrase());
200
+ const updateConfMsg = build.CONFIGURATION.PATCH({}, updatedConfig, generateSlug(4));
201
201
  const errorLogger = (socket, message) => (err) =>
202
202
  this._logger
203
203
  .push({ message, ip: this._clientData.get(socket).ip, err })
@@ -334,7 +334,7 @@ describe('Inbound Server', () => {
334
334
  });
335
335
 
336
336
  async function testTlsServer(enableTls) {
337
- defConfig.mutualTLS.inboundRequests.enabled = enableTls;
337
+ defConfig.inbound.tls.mutualTLS.enabled = enableTls;
338
338
  const logger = new Logger.Logger({ stringify: () => '' });
339
339
  const cache = new Cache({ ...defConfig.cacheConfig, logger: logger.push({ component: 'cache' }) });
340
340
  const server = new InboundServer(defConfig, logger, cache);
@@ -68,7 +68,7 @@ describe('config', () => {
68
68
  fs.writeFileSync(cert, certContent);
69
69
  process.env.IN_SERVER_CERT_PATH = cert;
70
70
  const config = require('~/config');
71
- const content = config.mutualTLS.inboundRequests.creds.cert.toString();
71
+ const content = config.inbound.tls.creds.cert.toString();
72
72
  expect(content).toBe(certContent);
73
73
  });
74
74
 
@@ -84,7 +84,7 @@ describe('config', () => {
84
84
  certs.forEach((cert, index) => fs.writeFileSync(cert, certContent[index]));
85
85
  process.env.IN_CA_CERT_PATH = certs.join(',');
86
86
  const config = require('~/config');
87
- const content = config.mutualTLS.inboundRequests.creds.ca.map(ca => ca.toString());
87
+ const content = config.inbound.tls.creds.ca.map(ca => ca.toString());
88
88
  expect(content).toStrictEqual(certContent);
89
89
  });
90
90
 
@@ -114,7 +114,7 @@ describe('config', () => {
114
114
 
115
115
  it('should throw an err if the resource string is not correctly formed', () => {
116
116
  const parseResourceVersion = require('~/config').__parseResourceVersion;
117
- expect(() => parseResourceVersion('resourceOneName=1.0;resourceTwoName=1.1')).toThrowError(new Error('Resource versions format should be in format: "resouceOneName=1.0,resourceTwoName=1.1"'));
117
+ expect(() => parseResourceVersion('resourceOneName=1.0;resourceTwoName=1.1')).toThrowError(new Error('Resource versions format should be in format: "resourceOneName=1.0,resourceTwoName=1.1"'));
118
118
  });
119
119
 
120
120
  });
@@ -1,15 +1,28 @@
1
1
  {
2
- "mutualTLS": {
3
- "inboundRequests": {
4
- "enabled": false,
2
+ "control": {},
3
+ "test": {
4
+ "tls": {
5
+ "mutualTLS": { "enabled": false },
5
6
  "creds": {
6
7
  "ca": null,
7
8
  "cert": null,
8
9
  "key": null
9
10
  }
10
- },
11
- "outboundRequests": {
12
- "enabled": false,
11
+ }
12
+ },
13
+ "inbound": {
14
+ "tls": {
15
+ "mutualTLS": { "enabled": false },
16
+ "creds": {
17
+ "ca": null,
18
+ "cert": null,
19
+ "key": null
20
+ }
21
+ }
22
+ },
23
+ "outbound": {
24
+ "tls": {
25
+ "mutualTLS": { "enabled": false },
13
26
  "creds": {
14
27
  "ca": null,
15
28
  "cert": null,
@@ -54,5 +67,8 @@
54
67
  "rejectExpiredQuoteResponses": false,
55
68
  "rejectExpiredTransferFulfils": false,
56
69
  "rejectTransfersOnExpiredQuotes": false,
57
- "logIndent": 2
70
+ "logIndent": 2,
71
+ "metrics": {
72
+ "port": 4004
73
+ }
58
74
  }
@@ -50,7 +50,6 @@ describe('index.js', () => {
50
50
  expect(typeof(index.OutboundServerMiddleware)).toBe('object');
51
51
  expect(typeof(index.Router)).toBe('function');
52
52
  expect(typeof(index.Validate)).toBe('function');
53
- expect(typeof(index.RandomPhrase)).toBe('function');
54
53
  expect(typeof(index.Cache)).toBe('function');
55
54
  });
56
55
  });
@@ -849,7 +849,7 @@ describe('outboundModel', () => {
849
849
 
850
850
 
851
851
  async function testTlsServer(enableTls) {
852
- config.tls.enabled = enableTls;
852
+ config.outbound.tls.mutualTLS.enabled = enableTls;
853
853
 
854
854
  new Model({
855
855
  cache,
@@ -1,14 +1,26 @@
1
1
  {
2
- "tls": {
3
- "enabled": false,
4
- "creds": {
5
- "ca": null,
6
- "cert": null,
7
- "key": null
2
+ "inbound": {
3
+ "port": 4000,
4
+ "tls": {
5
+ "mutualTLS": { "enabled": false },
6
+ "creds": {
7
+ "ca": null,
8
+ "cert": null,
9
+ "key": null
10
+ }
8
11
  }
9
12
  },
10
- "inboundServerPort": 4000,
11
- "outboundServerPort": 4001,
13
+ "outbound": {
14
+ "port": 4001,
15
+ "tls": {
16
+ "mutualTLS": { "enabled": false },
17
+ "creds": {
18
+ "ca": null,
19
+ "cert": null,
20
+ "key": null
21
+ }
22
+ }
23
+ },
12
24
  "peerEndpoint": "172.17.0.2:3001",
13
25
  "backendEndpoint": "172.17.0.2:3001",
14
26
  "alsEndpoint": "127.0.0.1:6500",
@@ -43,5 +55,8 @@
43
55
  "rejectExpiredQuoteResponses": false,
44
56
  "rejectExpiredTransferFulfils": false,
45
57
  "rejectTransfersOnExpiredQuotes": false,
46
- "logIndent": 2
58
+ "logIndent": 2,
59
+ "metrics": {
60
+ "port": 4004
61
+ }
47
62
  }
@@ -1,12 +0,0 @@
1
- class ApiServer {
2
- constructor(conf) {
3
- this.conf = conf;
4
- this.api = null;
5
- this.server = null;
6
- this.logger = null;
7
- }
8
-
9
-
10
- }
11
-
12
- module.exports = ApiServer;