@mojaloop/sdk-scheme-adapter 11.18.11 → 12.0.1

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/.nvmrc CHANGED
@@ -1 +1 @@
1
- v14.15
1
+ v16.14
package/.versionrc CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "header": "# Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)",
2
3
  "types": [
3
4
  {"type": "feat", "section": "Features"},
4
5
  {"type": "fix", "section": "Bug Fixes"},
package/CHANGELOG.md CHANGED
@@ -1,6 +1,28 @@
1
- # Changelog
1
+ # Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
2
+ ### [12.0.1](https://github.com/mojaloop/sdk-scheme-adapter/compare/v12.0.0...v12.0.1) (2022-04-19)
2
3
 
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### Bug Fixes
6
+
7
+ * remove outdated koa2-oauth-server and bump to node 16 ([#302](https://github.com/mojaloop/sdk-scheme-adapter/issues/302)) ([9c1ae18](https://github.com/mojaloop/sdk-scheme-adapter/commit/9c1ae18375f033fe59c219fa7cc970bd4d0c72f2))
8
+
9
+ ## [12.0.0](https://github.com/mojaloop/sdk-scheme-adapter/compare/v11.18.12...v12.0.0) (2022-03-18)
10
+
11
+
12
+ ### ⚠ BREAKING CHANGES
13
+
14
+ * update typescript interfaces using latest api-snippets (#297)
15
+
16
+ ### Refactors
17
+
18
+ * update typescript interfaces using latest api-snippets ([#297](https://github.com/mojaloop/sdk-scheme-adapter/issues/297)) ([9a72083](https://github.com/mojaloop/sdk-scheme-adapter/commit/9a7208372976297a307a57478fb339b4ebbdc790))
19
+
20
+ ### [11.18.12](https://github.com/mojaloop/sdk-scheme-adapter/compare/v11.18.11...v11.18.12) (2022-02-15)
21
+
22
+
23
+ ### Chore
24
+
25
+ * add config option for mismatch id's ([#291](https://github.com/mojaloop/sdk-scheme-adapter/issues/291)) ([8e9717a](https://github.com/mojaloop/sdk-scheme-adapter/commit/8e9717a02c6d19f93b78f5b293917050be0ade84))
4
26
 
5
27
  ### [11.18.11](https://github.com/mojaloop/sdk-scheme-adapter/compare/v11.18.9...v11.18.11) (2021-11-25)
6
28
 
@@ -10,11 +10,13 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const http = require('http');
14
- const Koa = require('koa');
15
- const koaBody = require('koa-body');
16
- const OAuthServer = require('koa2-oauth-server');
13
+ const { assert } = require('assert');
14
+ const express = require('express');
15
+ const bodyParser = require('body-parser');
16
+ const OAuth2Server = require('oauth2-server');
17
17
  const { InMemoryCache } = require('./model');
18
+ const {Request, Response} = require('oauth2-server');
19
+ const UnauthorizedRequestError = require('oauth2-server/lib/errors/unauthorized-request-error');
18
20
 
19
21
  class OAuthTestServer {
20
22
  /**
@@ -29,36 +31,95 @@ class OAuthTestServer {
29
31
  this._api = null;
30
32
  this._port = port;
31
33
  this._logger = logger;
32
- this._api = OAuthTestServer._SetupApi({ clientKey, clientSecret });
33
- this._server = http.createServer(this._api.callback());
34
+ this._clientKey = clientKey;
35
+ this._clientSecret = clientSecret;
34
36
  }
35
37
 
36
38
  async start() {
37
- if (this._server.listening) {
39
+ if (this._app) {
38
40
  return;
39
41
  }
40
- await new Promise((resolve) => this._server.listen(this._port, resolve));
42
+ this._app = express();
43
+
44
+ this._oauth = new OAuth2Server({
45
+ model: new InMemoryCache({ clientKey: this._clientKey, clientSecret:this._clientSecret }),
46
+ accessTokenLifetime: 60 * 60,
47
+ allowBearerTokensInQueryString: true,
48
+ });
49
+
50
+ this._app.use(bodyParser.urlencoded({ extended: false }));
51
+ this._app.use(bodyParser.json());
52
+ this._app.use(this.tokenMiddleware());
53
+
54
+
55
+ await new Promise((resolve) => this._app.listen(this._port, resolve));
41
56
  this._logger.push({ port: this._port }).log('Serving OAuth2 Test Server');
42
57
  }
43
58
 
44
59
  async stop() {
45
- await new Promise(resolve => this._server.close(resolve));
60
+ if (!this._app) {
61
+ return;
62
+ }
63
+ await new Promise(resolve => this._app.close(resolve));
64
+ this._app = null;
46
65
  this._logger.log('OAuth2 Test Server shut down complete');
47
66
  }
48
67
 
49
- static _SetupApi({ clientKey, clientSecret }) {
50
- const result = new Koa();
68
+ async reconfigure({ port, clientKey, clientSecret, logger }) {
69
+ assert(port === this._port, 'Cannot reconfigure running port');
70
+ return () => {
71
+ this._port = port;
72
+ this._logger = logger;
73
+ this.stop().then(() => this.start());
74
+ this._api = OAuthTestServer._SetupApi({ clientKey, clientSecret });
75
+ this._logger.log('restarted');
76
+ };
77
+ }
51
78
 
52
- result.oauth = new OAuthServer({
53
- model: new InMemoryCache({ clientKey, clientSecret }),
54
- accessTokenLifetime: 60 * 60,
55
- allowBearerTokensInQueryString: true,
56
- });
79
+ handleResponse(req, res, response) {
80
+ if (response.status === 302) {
81
+ const location = response.headers.location;
82
+ delete response.headers.location;
83
+ res.set(response.headers);
84
+ res.redirect(location);
85
+ } else {
86
+ res.set(response.headers);
87
+ res.status(response.status).send(response.body);
88
+ }
89
+ }
90
+
91
+ handleError(e, req, res, response) {
92
+ if (response) {
93
+ res.set(response.headers);
94
+ }
95
+
96
+ res.status(e.code);
97
+
98
+ if (e instanceof UnauthorizedRequestError) {
99
+ return res.send();
100
+ }
101
+
102
+ res.send({ error: e.name, error_description: e.message });
103
+ }
104
+
105
+ tokenMiddleware(options) {
106
+ return async (req, res, next) => {
107
+ const request = new Request(req);
108
+ const response = new Response(res);
109
+
110
+ let token;
111
+
112
+ try {
113
+ token = await this._oauth.token(request, response, options);
114
+ res.locals.oauth = {token};
115
+ } catch (e) {
116
+ await this.handleError(e, req, res, response, next);
117
+ return;
118
+ }
57
119
 
58
- result.use(koaBody());
59
- result.use(result.oauth.token());
120
+ await this.handleResponse(req, res, response);
60
121
 
61
- return result;
122
+ };
62
123
  }
63
124
  }
64
125
 
@@ -83,9 +83,6 @@ export declare namespace Schemas {
83
83
  type accountsCreationState = components['schemas']['accountsCreationState'];
84
84
  type accountsResponse = components['schemas']['accountsResponse'];
85
85
  type errorAccountsResponse = components['schemas']['errorAccountsResponse'];
86
- type AccountAddress = components['schemas']['AccountAddress'];
87
- type Account = components['schemas']['Account'];
88
- type AccountList = components['schemas']['AccountList'];
89
86
  type PartyIdInfo = components['schemas']['PartyIdInfo'];
90
87
  type PartyName = components['schemas']['PartyName'];
91
88
  type PartyComplexName = components['schemas']['PartyComplexName'];
@@ -101,17 +98,4 @@ export declare namespace Schemas {
101
98
  type simpleTransfersPostRequest = components['schemas']['simpleTransfersPostRequest'];
102
99
  type simpleTransfersPostResponse = components['schemas']['simpleTransfersPostResponse'];
103
100
  type errorSimpleTransfersResponse = components['schemas']['errorSimpleTransfersResponse'];
104
- type AuthorizationChannelType = components['schemas']['AuthorizationChannelType'];
105
- type Integer = components['schemas']['Integer'];
106
- type AuthorizationsPostRequest = components['schemas']['AuthorizationsPostRequest'];
107
- type authorizationsPostRequest = components['schemas']['authorizationsPostRequest'];
108
- type OtpValue = components['schemas']['OtpValue'];
109
- type QRCODE = components['schemas']['QRCODE'];
110
- type U2FPIN = components['schemas']['U2FPIN'];
111
- type U2FPinValue = components['schemas']['U2FPinValue'];
112
- type AuthenticationValue = components['schemas']['AuthenticationValue'];
113
- type AuthenticationInfo = components['schemas']['AuthenticationInfo'];
114
- type AuthorizationResponseType = components['schemas']['AuthorizationResponseType'];
115
- type authorizationsPostResponse = components['schemas']['authorizationsPostResponse'];
116
- type errorAuthorizationsResponse = components['schemas']['errorAuthorizationsResponse'];
117
- }
101
+ }
@@ -7,7 +7,7 @@ items:
7
7
  properties:
8
8
  idType:
9
9
  $ref: >-
10
- ../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/PartyIdType.yaml
10
+ ../../../../node_modules/@mojaloop/api-snippets/thirdparty/v1_0/openapi3/components/schemas/PartyIdType.yaml
11
11
  idValue:
12
12
  $ref: >-
13
13
  ../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/PartyIdentifier.yaml
@@ -8,7 +8,7 @@ items:
8
8
  properties:
9
9
  idType:
10
10
  $ref: >-
11
- ../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/PartyIdType.yaml
11
+ ../../../../node_modules/@mojaloop/api-snippets/thirdparty/v1_0/openapi3/components/schemas/PartyIdType.yaml
12
12
  idValue:
13
13
  $ref: >-
14
14
  ../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/PartyIdentifier.yaml
@@ -4,10 +4,10 @@
4
4
  properties:
5
5
  party:
6
6
  $ref: >-
7
- ../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/Party.yaml
7
+ ../../../../node_modules/@mojaloop/api-snippets/thirdparty/v1_0/openapi3/components/schemas/Party.yaml
8
8
  description: Information regarding the requested Party.
9
9
  currentState:
10
10
  $ref: ../schemas/async2SyncCurrentState.yaml
11
11
  required:
12
12
  - party
13
- - currentState
13
+ - currentState
@@ -1,13 +1,13 @@
1
1
  title: QuotesPostRequest
2
2
  type: object
3
3
  properties:
4
- fspId:
4
+ fspId:
5
5
  title: destination DFSP requested to calculate the quote
6
6
  $ref: >-
7
7
  ../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/FspId.yaml
8
8
  quotesPostRequest:
9
9
  $ref: >-
10
- ../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/QuotesPostRequest.yaml
11
- required:
10
+ ../../../../node_modules/@mojaloop/api-snippets/thirdparty/v1_0/openapi3/components/schemas/QuotesPostRequest.yaml
11
+ required:
12
12
  - fspId
13
13
  - quotesPostRequest
@@ -8,7 +8,7 @@ properties:
8
8
  ../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/TransactionInitiatorType.yaml
9
9
  idType:
10
10
  $ref: >-
11
- ../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/PartyIdType.yaml
11
+ ../../../../node_modules/@mojaloop/api-snippets/thirdparty/v1_0/openapi3/components/schemas/PartyIdType.yaml
12
12
  idValue:
13
13
  $ref: >-
14
14
  ../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/PartyIdentifier.yaml
@@ -140,80 +140,280 @@
140
140
  "expiresAt": 1637308004771
141
141
  },
142
142
  "1004946|@mojaloop/event-sdk>@grpc/proto-loader>yargs>string-width>strip-ansi>ansi-regex": {
143
- "decision": "postpone",
144
- "madeAt": 1637774978679
143
+ "decision": "ignore",
144
+ "madeAt": 1644879175753,
145
+ "expiresAt": 1647471172307
145
146
  },
146
147
  "1004946|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>string-width>strip-ansi>ansi-regex": {
147
- "decision": "postpone",
148
- "madeAt": 1637774978679
148
+ "decision": "ignore",
149
+ "madeAt": 1644879175753,
150
+ "expiresAt": 1647471172307
149
151
  },
150
152
  "1004946|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
151
- "decision": "postpone",
152
- "madeAt": 1637774978679
153
+ "decision": "ignore",
154
+ "madeAt": 1644879175753,
155
+ "expiresAt": 1647471172307
153
156
  },
154
157
  "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
155
- "decision": "postpone",
156
- "madeAt": 1637774978679
158
+ "decision": "ignore",
159
+ "madeAt": 1644879175753,
160
+ "expiresAt": 1647471172307
157
161
  },
158
162
  "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
159
- "decision": "postpone",
160
- "madeAt": 1637774978679
163
+ "decision": "ignore",
164
+ "madeAt": 1644879175754,
165
+ "expiresAt": 1647471172307
161
166
  },
162
167
  "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>string-width>strip-ansi>ansi-regex": {
163
- "decision": "postpone",
164
- "madeAt": 1637774978679
168
+ "decision": "ignore",
169
+ "madeAt": 1644879175754,
170
+ "expiresAt": 1647471172307
165
171
  },
166
172
  "1004946|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
167
- "decision": "postpone",
168
- "madeAt": 1637774978679
173
+ "decision": "ignore",
174
+ "madeAt": 1644879175754,
175
+ "expiresAt": 1647471172307
169
176
  },
170
177
  "1004946|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
171
- "decision": "postpone",
172
- "madeAt": 1637774978679
178
+ "decision": "ignore",
179
+ "madeAt": 1644879175754,
180
+ "expiresAt": 1647471172307
173
181
  },
174
182
  "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
175
- "decision": "postpone",
176
- "madeAt": 1637774978679
183
+ "decision": "ignore",
184
+ "madeAt": 1644879175754,
185
+ "expiresAt": 1647471172307
177
186
  },
178
187
  "1004946|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
179
- "decision": "postpone",
180
- "madeAt": 1637774978679
188
+ "decision": "ignore",
189
+ "madeAt": 1644879175754,
190
+ "expiresAt": 1647471172307
181
191
  },
182
192
  "1004946|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>strip-ansi>ansi-regex": {
183
- "decision": "postpone",
184
- "madeAt": 1637774978679
193
+ "decision": "ignore",
194
+ "madeAt": 1644879175754,
195
+ "expiresAt": 1647471172307
185
196
  },
186
197
  "1004854|@mojaloop/central-services-shared>widdershins>openapi-sampler>json-pointer": {
187
- "decision": "postpone",
188
- "madeAt": 1637774979253
198
+ "decision": "ignore",
199
+ "madeAt": 1644879153322,
200
+ "expiresAt": 1647471110577
189
201
  },
190
202
  "1004869|@mojaloop/central-services-shared>widdershins>swagger2openapi>better-ajv-errors>jsonpointer": {
191
- "decision": "postpone",
192
- "madeAt": 1637774979672
203
+ "decision": "ignore",
204
+ "madeAt": 1644879154472,
205
+ "expiresAt": 1647471110577
193
206
  },
194
207
  "1004869|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>better-ajv-errors>jsonpointer": {
195
- "decision": "postpone",
196
- "madeAt": 1637774979672
208
+ "decision": "ignore",
209
+ "madeAt": 1644879154472,
210
+ "expiresAt": 1647471110577
197
211
  },
198
212
  "1004946|@mojaloop/central-services-shared>widdershins>yargs>string-width>strip-ansi>ansi-regex": {
199
- "decision": "postpone",
200
- "madeAt": 1637774980265
213
+ "decision": "ignore",
214
+ "madeAt": 1644879155619,
215
+ "expiresAt": 1647471110577
201
216
  },
202
217
  "1004946|@mojaloop/central-services-shared>widdershins>yargs>cliui>string-width>strip-ansi>ansi-regex": {
203
- "decision": "postpone",
204
- "madeAt": 1637774980265
218
+ "decision": "ignore",
219
+ "madeAt": 1644879155619,
220
+ "expiresAt": 1647471110577
205
221
  },
206
222
  "1005383|@mojaloop/central-services-shared>shins>sanitize-html": {
207
- "decision": "postpone",
208
- "madeAt": 1637774980738
223
+ "decision": "ignore",
224
+ "madeAt": 1644879156746,
225
+ "expiresAt": 1647471110577
209
226
  },
210
227
  "1005384|@mojaloop/central-services-shared>shins>sanitize-html": {
211
- "decision": "postpone",
212
- "madeAt": 1637774980738
228
+ "decision": "ignore",
229
+ "madeAt": 1644879156746,
230
+ "expiresAt": 1647471110577
213
231
  },
214
232
  "1005534|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
215
- "decision": "postpone",
216
- "madeAt": 1637774981266
233
+ "decision": "ignore",
234
+ "madeAt": 1644879157837,
235
+ "expiresAt": 1647471110577
236
+ },
237
+ "1006865|axios>follow-redirects": {
238
+ "decision": "fix",
239
+ "madeAt": 1644879138577
240
+ },
241
+ "1006865|@mojaloop/central-services-shared>axios>follow-redirects": {
242
+ "decision": "fix",
243
+ "madeAt": 1644879138577
244
+ },
245
+ "1007023|axios>follow-redirects": {
246
+ "decision": "fix",
247
+ "madeAt": 1644879138577
248
+ },
249
+ "1007023|@mojaloop/central-services-shared>axios>follow-redirects": {
250
+ "decision": "fix",
251
+ "madeAt": 1644879138577
252
+ },
253
+ "1006899|@mojaloop/central-services-shared>widdershins>node-fetch": {
254
+ "decision": "fix",
255
+ "madeAt": 1644879149946
256
+ },
257
+ "1006899|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>node-fetch": {
258
+ "decision": "fix",
259
+ "madeAt": 1644879149946
260
+ },
261
+ "1006846|@mojaloop/central-services-shared>shins>sanitize-html>postcss": {
262
+ "decision": "ignore",
263
+ "madeAt": 1644879158938,
264
+ "expiresAt": 1647471110577
265
+ },
266
+ "1006886|@mojaloop/central-services-shared>shins>markdown-it": {
267
+ "decision": "ignore",
268
+ "madeAt": 1644879160175,
269
+ "expiresAt": 1647471110577
270
+ },
271
+ "1007017|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>ajv": {
272
+ "decision": "ignore",
273
+ "madeAt": 1644879161354,
274
+ "expiresAt": 1647471110577
275
+ },
276
+ "1064587|@mojaloop/central-services-shared>widdershins>urijs": {
277
+ "decision": "fix",
278
+ "madeAt": 1647565572809
279
+ },
280
+ "1064606|@mojaloop/central-services-shared>widdershins>urijs": {
281
+ "decision": "fix",
282
+ "madeAt": 1647565572809
283
+ },
284
+ "1067233|@mojaloop/central-services-shared>widdershins>urijs": {
285
+ "decision": "fix",
286
+ "madeAt": 1647565572809
287
+ },
288
+ "1064843|@mojaloop/event-sdk>@grpc/proto-loader>yargs>string-width>strip-ansi>ansi-regex": {
289
+ "decision": "ignore",
290
+ "madeAt": 1647565608486,
291
+ "expiresAt": 1650157604921
292
+ },
293
+ "1064843|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>string-width>strip-ansi>ansi-regex": {
294
+ "decision": "ignore",
295
+ "madeAt": 1647565608486,
296
+ "expiresAt": 1650157604921
297
+ },
298
+ "1064843|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
299
+ "decision": "ignore",
300
+ "madeAt": 1647565608486,
301
+ "expiresAt": 1650157604921
302
+ },
303
+ "1064843|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
304
+ "decision": "ignore",
305
+ "madeAt": 1647565608486,
306
+ "expiresAt": 1650157604921
307
+ },
308
+ "1064843|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>string-width>strip-ansi>ansi-regex": {
309
+ "decision": "ignore",
310
+ "madeAt": 1647565608486,
311
+ "expiresAt": 1650157604921
312
+ },
313
+ "1064843|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>string-width>strip-ansi>ansi-regex": {
314
+ "decision": "ignore",
315
+ "madeAt": 1647565608486,
316
+ "expiresAt": 1650157604921
317
+ },
318
+ "1064843|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
319
+ "decision": "ignore",
320
+ "madeAt": 1647565608486,
321
+ "expiresAt": 1650157604921
322
+ },
323
+ "1064843|@mojaloop/central-services-shared>widdershins>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
324
+ "decision": "ignore",
325
+ "madeAt": 1647565608486,
326
+ "expiresAt": 1650157604921
327
+ },
328
+ "1064843|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
329
+ "decision": "ignore",
330
+ "madeAt": 1647565608486,
331
+ "expiresAt": 1650157604921
332
+ },
333
+ "1064843|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>oas-resolver>yargs>cliui>wrap-ansi>strip-ansi>ansi-regex": {
334
+ "decision": "ignore",
335
+ "madeAt": 1647565608487,
336
+ "expiresAt": 1650157604921
337
+ },
338
+ "1064843|@mojaloop/event-sdk>@grpc/proto-loader>yargs>cliui>strip-ansi>ansi-regex": {
339
+ "decision": "ignore",
340
+ "madeAt": 1647565608487,
341
+ "expiresAt": 1650157604921
342
+ },
343
+ "1064661|@mojaloop/central-services-shared>shins>markdown-it": {
344
+ "decision": "ignore",
345
+ "madeAt": 1647565592292,
346
+ "expiresAt": 1650157555692
347
+ },
348
+ "1064744|@mojaloop/central-services-shared>widdershins>openapi-sampler>json-pointer": {
349
+ "decision": "ignore",
350
+ "madeAt": 1647565593879,
351
+ "expiresAt": 1650157555692
352
+ },
353
+ "1064761|@mojaloop/central-services-shared>widdershins>swagger2openapi>better-ajv-errors>jsonpointer": {
354
+ "decision": "ignore",
355
+ "madeAt": 1647565594838,
356
+ "expiresAt": 1650157555692
357
+ },
358
+ "1064761|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>better-ajv-errors>jsonpointer": {
359
+ "decision": "ignore",
360
+ "madeAt": 1647565594838,
361
+ "expiresAt": 1650157555692
362
+ },
363
+ "1064843|@mojaloop/central-services-shared>widdershins>yargs>string-width>strip-ansi>ansi-regex": {
364
+ "decision": "ignore",
365
+ "madeAt": 1647565599016,
366
+ "expiresAt": 1650157555692
367
+ },
368
+ "1064843|@mojaloop/central-services-shared>widdershins>yargs>cliui>string-width>strip-ansi>ansi-regex": {
369
+ "decision": "ignore",
370
+ "madeAt": 1647565599016,
371
+ "expiresAt": 1650157555692
372
+ },
373
+ "1065159|@mojaloop/central-services-shared>widdershins>swagger2openapi>oas-validator>ajv": {
374
+ "decision": "ignore",
375
+ "madeAt": 1647565600359,
376
+ "expiresAt": 1650157555692
377
+ },
378
+ "1065367|@mojaloop/central-services-shared>shins>sanitize-html": {
379
+ "decision": "ignore",
380
+ "madeAt": 1647565601450,
381
+ "expiresAt": 1650157555692
382
+ },
383
+ "1065368|@mojaloop/central-services-shared>shins>sanitize-html": {
384
+ "decision": "ignore",
385
+ "madeAt": 1647565601450,
386
+ "expiresAt": 1650157555692
387
+ },
388
+ "1065523|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
389
+ "decision": "ignore",
390
+ "madeAt": 1647565602524,
391
+ "expiresAt": 1650157555692
392
+ },
393
+ "1069972|@mojaloop/central-services-shared>@mojaloop/event-sdk>moment": {
394
+ "decision": "ignore",
395
+ "madeAt": 1649898254012,
396
+ "expiresAt": 1652490250295
397
+ },
398
+ "1069972|@mojaloop/event-sdk>moment": {
399
+ "decision": "ignore",
400
+ "madeAt": 1649898254012,
401
+ "expiresAt": 1652490250295
402
+ },
403
+ "1067456|@mojaloop/central-services-shared>widdershins>markdown-it": {
404
+ "decision": "ignore",
405
+ "madeAt": 1649898255401,
406
+ "expiresAt": 1652490250295
407
+ },
408
+ "1068310|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
409
+ "decision": "ignore",
410
+ "madeAt": 1649898256486,
411
+ "expiresAt": 1652490250295
412
+ },
413
+ "1067946|ajv": {
414
+ "decision": "ignore",
415
+ "madeAt": 1649898257344,
416
+ "expiresAt": 1652490250295
217
417
  }
218
418
  },
219
419
  "rules": {},
package/config.js CHANGED
@@ -154,5 +154,10 @@ module.exports = {
154
154
  proxyConfig: env.get('PROXY_CONFIG_PATH').asYamlConfig(),
155
155
  reserveNotification: env.get('RESERVE_NOTIFICATION').default('false').asBool(),
156
156
  // resourceVersions config should be string in format: "resouceOneName=1.0,resourceTwoName=1.1"
157
- resourceVersions: env.get('RESOURCE_VERSIONS').default('').asResourceVersions()
157
+ resourceVersions: env.get('RESOURCE_VERSIONS').default('').asResourceVersions(),
158
+
159
+ // in 3PPI DFSP's generate their own `transferId` which is associated with
160
+ // a transactionRequestId. this option decodes the ilp packet for
161
+ // the `transactionId` to retrieve the quote from cache
162
+ allowDifferentTransferTransactionId: env.get('ALLOW_DIFFERENT_TRANSFER_TRANSACTION_ID').default('false').asBool(),
158
163
  };
@@ -34,6 +34,7 @@ class InboundTransfersModel {
34
34
  this._rejectTransfersOnExpiredQuotes = config.rejectTransfersOnExpiredQuotes;
35
35
  this._allowTransferWithoutQuote = config.allowTransferWithoutQuote;
36
36
  this._reserveNotification = config.reserveNotification;
37
+ this._allowDifferentTransferTransactionId = config.allowDifferentTransferTransactionId;
37
38
 
38
39
  this._mojaloopRequests = new MojaloopRequests({
39
40
  logger: this._logger,
@@ -175,7 +176,7 @@ class InboundTransfersModel {
175
176
  response.expiration = new Date(expiration).toISOString();
176
177
  }
177
178
 
178
- // project our internal quote reponse into mojaloop quote response form
179
+ // project our internal quote response into mojaloop quote response form
179
180
  const mojaloopResponse = shared.internalQuoteResponseToMojaloop(response);
180
181
 
181
182
  // create our ILP packet and condition and tag them on to our internal quote response
@@ -193,7 +194,7 @@ class InboundTransfersModel {
193
194
  fulfilment: fulfilment
194
195
  });
195
196
 
196
- // now store the quoteRespnse data against the quoteId in our cache to be sent as a response to GET /quotes/{ID}
197
+ // now store the quoteResponse data against the quoteId in our cache to be sent as a response to GET /quotes/{ID}
197
198
  await this._cache.set(`quoteResponse_${quoteRequest.quoteId}`, mojaloopResponse);
198
199
 
199
200
  // make a callback to the source fsp with the quote response
@@ -209,21 +210,21 @@ class InboundTransfersModel {
209
210
  }
210
211
 
211
212
  /**
212
- * This is executed as when GET /quotes/{ID} request is made to get the response of a previous POST /quotes request.
213
+ * This is executed as when GET /quotes/{ID} request is made to get the response of a previous POST /quotes request.
213
214
  * Gets the quoteResponse from the cache and makes a callback to the originator with result
214
215
  */
215
216
  async getQuoteRequest(quoteId, sourceFspId) {
216
217
  try {
217
218
  // Get the quoteRespnse data for the quoteId from the cache to be sent as a response to GET /quotes/{ID}
218
219
  const quoteResponse = await this._cache.get(`quoteResponse_${quoteId}`);
219
-
220
+
220
221
  // If no quoteResponse is found in the cache, make an error callback to the source fsp
221
222
  if (!quoteResponse) {
222
223
  const err = new Error('Quote Id not found');
223
224
  const mojaloopError = await this._handleError(err, Errors.MojaloopApiErrorCodes.QUOTE_ID_NOT_FOUND);
224
225
  this._logger.push({ mojaloopError }).log(`Sending error response to ${sourceFspId}`);
225
226
  return await this._mojaloopRequests.putQuotesError(quoteId,
226
- mojaloopError, sourceFspId);
227
+ mojaloopError, sourceFspId);
227
228
  }
228
229
  // Make a PUT /quotes/{ID} callback to the source fsp with the quote response
229
230
  return this._mojaloopRequests.putQuotes(quoteId, quoteResponse, sourceFspId);
@@ -270,14 +271,20 @@ class InboundTransfersModel {
270
271
 
271
272
 
272
273
  /**
273
- * Validates an incoming transfer prepare request and makes a callback to the originator with
274
+ * Validates an incoming transfer prepare request and makes a callback to the originator with
274
275
  * the result
275
276
  */
276
277
  async prepareTransfer(prepareRequest, sourceFspId) {
277
278
  try {
278
-
279
279
  // retrieve our quote data
280
- const quote = await this._cache.get(`quote_${prepareRequest.transferId}`);
280
+ let quote;
281
+
282
+ if (this._allowDifferentTransferTransactionId) {
283
+ const transactionId = this._ilp.getTransactionObject(prepareRequest.ilpPacket).transactionId;
284
+ quote = await this._cache.get(`quote_${transactionId}`);
285
+ } else {
286
+ quote = await this._cache.get(`quote_${prepareRequest.transferId}`);
287
+ }
281
288
 
282
289
  if(!quote) {
283
290
  // Check whether to allow transfers without a previous quote.
@@ -703,7 +710,7 @@ class InboundTransfersModel {
703
710
  }
704
711
 
705
712
  /**
706
- * Forwards Switch notification for fulfiled transfer to the DFSP backend, when acting as a payee
713
+ * Forwards Switch notification for fulfiled transfer to the DFSP backend, when acting as a payee
707
714
  */
708
715
  async sendNotificationToPayee(body, transferId) {
709
716
  try {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@mojaloop/sdk-scheme-adapter",
3
- "version": "11.18.11",
3
+ "version": "12.0.1",
4
4
  "description": "An adapter for connecting to Mojaloop API enabled switches.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "engines": {
8
- "node": ">=14.15"
8
+ "node": "=16.x"
9
9
  },
10
10
  "scripts": {
11
11
  "audit:resolve": "SHELL=sh resolve-audit --production",
@@ -57,19 +57,20 @@
57
57
  "@mojaloop/central-services-metrics": "11.0.0",
58
58
  "@mojaloop/central-services-shared": "14.0.0",
59
59
  "@mojaloop/event-sdk": "10.7.1",
60
- "@mojaloop/sdk-standard-components": "15.13.0",
60
+ "@mojaloop/sdk-standard-components": "^16.0.0",
61
61
  "ajv": "8.6.3",
62
62
  "ajv-keywords": "5.0.0",
63
63
  "axios": "^0.21.4",
64
64
  "co-body": "^6.1.0",
65
65
  "dotenv": "^10.0.0",
66
66
  "env-var": "^7.0.1",
67
+ "express": "^4.17.2",
67
68
  "javascript-state-machine": "^3.1.0",
68
69
  "js-yaml": "^4.1.0",
69
70
  "json-schema-ref-parser": "^9.0.9",
70
71
  "koa": "^2.13.1",
71
72
  "koa-body": "^4.2.0",
72
- "koa2-oauth-server": "^1.0.0",
73
+ "oauth2-server": "^4.0.0-dev.2",
73
74
  "openapi-jsonschema-parameters": "^9.3.0",
74
75
  "promise-timeout": "^1.3.0",
75
76
  "redis": "^3.1.2",
@@ -79,7 +80,7 @@
79
80
  "devDependencies": {
80
81
  "@babel/core": "^7.15.5",
81
82
  "@babel/preset-env": "^7.15.6",
82
- "@mojaloop/api-snippets": "^13.0.3",
83
+ "@mojaloop/api-snippets": "^13.0.9",
83
84
  "@redocly/openapi-cli": "^1.0.0-beta.59",
84
85
  "@types/jest": "^27.0.1",
85
86
  "babel-jest": "^27.2.0",
@@ -90,7 +91,7 @@
90
91
  "jest": "^27.2.0",
91
92
  "jest-junit": "^12.2.0",
92
93
  "nock": "^13.1.3",
93
- "npm-audit-resolver": "^2.3.1",
94
+ "npm-audit-resolver": "^3.0.0-0",
94
95
  "npm-check-updates": "^11.8.5",
95
96
  "openapi-response-validator": "^9.3.0",
96
97
  "openapi-typescript": "^4.0.2",
@@ -376,7 +376,7 @@ describe('Inbound Server', () => {
376
376
 
377
377
  afterEach(async () => {
378
378
  await svr.stop();
379
- fs.rmdirSync(keysDir, { recursive: true });
379
+ fs.rmSync(keysDir, { recursive: true });
380
380
  });
381
381
 
382
382
  it('updates server configuration when a new JWS verification key '
@@ -33,7 +33,7 @@ describe('config', () => {
33
33
 
34
34
  afterEach(() => {
35
35
  process.env = { ...env };
36
- fs.rmdirSync(certDir, { recursive: true });
36
+ fs.rmSync(certDir, { recursive: true });
37
37
  jest.resetModules();
38
38
  });
39
39
 
@@ -21,6 +21,7 @@ const mockTxnReqquestsArguments = require('./data/mockTxnRequestsArguments');
21
21
  const { MojaloopRequests, Ilp, Logger } = require('@mojaloop/sdk-standard-components');
22
22
  const { BackendRequests, HTTPResponseError } = require('../../../../lib/model/lib/requests');
23
23
  const Cache = require('../../../../lib/cache');
24
+ const shared = require('../../../../lib/model/lib/shared');
24
25
 
25
26
  const getTransfersBackendResponse = require('./data/getTransfersBackendResponse');
26
27
  const getTransfersMojaloopResponse = require('./data/getTransfersMojaloopResponse');
@@ -232,9 +233,9 @@ describe('inboundModel', () => {
232
233
 
233
234
  test('calls `mojaloopRequests.putAuthorizations` with the expected arguments.', async () => {
234
235
  await model.getAuthorizations('123456', mockTxnReqArgs.fspId);
235
-
236
+
236
237
  expect(MojaloopRequests.__putAuthorizations).toHaveBeenCalledTimes(1);
237
-
238
+
238
239
  });
239
240
 
240
241
 
@@ -406,6 +407,43 @@ describe('inboundModel', () => {
406
407
  expect(BackendRequests.__postTransfers).toHaveBeenCalledTimes(1);
407
408
  expect(MojaloopRequests.__putTransfers).toHaveBeenCalledTimes(1);
408
409
  });
410
+
411
+ test('allow different transfer and transaction id', async () => {
412
+ const transactionId = 'mockTransactionId';
413
+ const TRANSFER_ID = 'transfer-id';
414
+ shared.mojaloopPrepareToInternalTransfer = jest.fn().mockReturnValueOnce({});
415
+
416
+ cache.set(`quote_${transactionId}`, {
417
+ fulfilment: '',
418
+ mojaloopResponse: {
419
+ response: ''
420
+ }
421
+ });
422
+
423
+ const args = {
424
+ transferId: TRANSFER_ID,
425
+ amount: {
426
+ currency: 'USD',
427
+ amount: 20.13
428
+ },
429
+ ilpPacket: 'mockIlpPacket',
430
+ condition: 'mockGeneratedCondition'
431
+ };
432
+
433
+ const model = new Model({
434
+ ...config,
435
+ cache,
436
+ logger,
437
+ allowDifferentTransferTransactionId: true,
438
+ checkIlp: false,
439
+ });
440
+
441
+ await model.prepareTransfer(args, mockArgs.fspId);
442
+
443
+ expect(MojaloopRequests.__putTransfersError).toHaveBeenCalledTimes(0);
444
+ expect(BackendRequests.__postTransfers).toHaveBeenCalledTimes(1);
445
+ expect(MojaloopRequests.__putTransfers).toHaveBeenCalledTimes(1);
446
+ });
409
447
  });
410
448
 
411
449
  describe('prepareBulkTransfer:', () => {
@@ -574,7 +612,7 @@ describe('inboundModel', () => {
574
612
  }
575
613
  ]
576
614
  };
577
-
615
+
578
616
  const model = new Model({
579
617
  ...config,
580
618
  cache,
@@ -595,7 +633,7 @@ describe('inboundModel', () => {
595
633
  const transferId = '1234';
596
634
  let cache;
597
635
 
598
- beforeEach(async () => {
636
+ beforeEach(async () => {
599
637
  cache = new Cache({
600
638
  host: 'dummycachehost',
601
639
  port: 1234,