@mojaloop/sdk-scheme-adapter 11.18.6 → 11.18.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 +23 -0
- package/InboundServer/api.yaml +2 -0
- package/InboundServer/handlers.js +0 -38
- package/InboundServer/middlewares.js +1 -1
- package/OutboundServer/api.yaml +23 -270
- package/OutboundServer/api_interfaces/openapi.d.ts +10 -127
- package/OutboundServer/api_template/openapi.yaml +0 -3
- package/OutboundServer/handlers.js +2 -40
- package/audit-resolve.json +174 -6
- package/lib/cache.js +23 -7
- package/lib/model/OutboundBulkQuotesModel.js +1 -0
- package/lib/model/OutboundBulkTransfersModel.js +1 -0
- package/lib/model/OutboundTransfersModel.js +1 -0
- package/lib/model/index.js +1 -3
- package/package.json +15 -15
- package/test/__mocks__/@mojaloop/sdk-standard-components.js +0 -2
- package/test/config/integration.env +0 -3
- package/test/unit/inboundApi/handlers.test.js +0 -46
- package/test/unit/outboundApi/handlers.test.js +1 -100
- package/OutboundServer/api_template/components/responses/authorizationPostSuccess.yaml +0 -5
- package/OutboundServer/api_template/components/responses/authorizationsServerError.yaml +0 -5
- package/OutboundServer/api_template/components/schemas/authorizationsPostRequest.yaml +0 -15
- package/OutboundServer/api_template/components/schemas/authorizationsPostResponse.yaml +0 -19
- package/OutboundServer/api_template/components/schemas/errorAuthorizationsResponse.yaml +0 -3
- package/OutboundServer/api_template/paths/authorizations.yaml +0 -19
- package/lib/model/AuthorizationsModel.js +0 -86
- package/test/integration/lib/Outbound/authorizations.test.js +0 -58
- package/test/integration/lib/Outbound/data/authorizationsPostRequest.json +0 -43
- package/test/unit/lib/model/AuthorizationsModel.test.js +0 -460
- package/test/unit/lib/model/data/putAuthorizationsResponse.json +0 -10
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
title: AuthorizationsPostResponse
|
|
2
|
-
description: POST /authorizations response object
|
|
3
|
-
type: object
|
|
4
|
-
properties:
|
|
5
|
-
authorizations:
|
|
6
|
-
type: object
|
|
7
|
-
properties:
|
|
8
|
-
authenticationInfo:
|
|
9
|
-
$ref: '../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/AuthenticationInfo.yaml'
|
|
10
|
-
responseType:
|
|
11
|
-
$ref: '../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/AuthorizationResponseType.yaml'
|
|
12
|
-
required:
|
|
13
|
-
- responseType
|
|
14
|
-
currentState:
|
|
15
|
-
$ref: ../schemas/async2SyncCurrentState.yaml
|
|
16
|
-
required:
|
|
17
|
-
- authorizations
|
|
18
|
-
- currentState
|
|
19
|
-
additionalProperties: false
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
post:
|
|
2
|
-
description: The HTTP request `POST /authorizations` is used to request the Payer to enter the applicable credentials in the PISP system.
|
|
3
|
-
summary: Authorizations endpoint
|
|
4
|
-
operationId: AuthorizationsPost
|
|
5
|
-
tags:
|
|
6
|
-
- authorizations
|
|
7
|
-
requestBody:
|
|
8
|
-
description: Perform authorization
|
|
9
|
-
required: true
|
|
10
|
-
content:
|
|
11
|
-
application/json:
|
|
12
|
-
schema:
|
|
13
|
-
$ref: '../components/schemas/authorizationsPostRequest.yaml'
|
|
14
|
-
responses:
|
|
15
|
-
200:
|
|
16
|
-
$ref: '../components/responses/authorizationPostSuccess.yaml'
|
|
17
|
-
500:
|
|
18
|
-
$ref: '../components/responses/authorizationsServerError.yaml'
|
|
19
|
-
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**************************************************************************
|
|
2
|
-
* (C) Copyright ModusBox Inc. 2020 - All rights reserved. *
|
|
3
|
-
* *
|
|
4
|
-
* This file is made available under the terms of the license agreement *
|
|
5
|
-
* specified in the corresponding source code repository. *
|
|
6
|
-
* *
|
|
7
|
-
* ORIGINAL AUTHOR: *
|
|
8
|
-
* Sridhar Voruganti - sridhar.voruganti@modusbox.com *
|
|
9
|
-
**************************************************************************/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const Async2SyncModel = require('./Async2SyncModel');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// delegated methods for AuthorizationsModel
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @name channelName
|
|
20
|
-
* @description generates the pub/sub channel name
|
|
21
|
-
* @param {object} - args
|
|
22
|
-
* @param {string} args.transactionRequestId - the transactionRequestId
|
|
23
|
-
* @param {string} [args.fspId] - ignored if passed - the destination fsp id
|
|
24
|
-
* @param {string} [args.authorization] - ignored if passed - the authorization payload
|
|
25
|
-
* @returns {string} - the pub/sub channel name
|
|
26
|
-
*/
|
|
27
|
-
function channelName ({ transactionRequestId /* ,fspId, authorization - are not used here */ }) {
|
|
28
|
-
const tokens = ['authorizations', transactionRequestId];
|
|
29
|
-
return tokens.map(x => `${x}`).join('-');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @name requestAction
|
|
34
|
-
* @description invokes the call to switch
|
|
35
|
-
* @param {object} requests - MojaloopRequests instance
|
|
36
|
-
* @param {array} args - the arguments passed as object to `run` method
|
|
37
|
-
* @param {string} [args.transactionRequestId] - the transactionRequestId
|
|
38
|
-
* @param {string} args.fspId - the destination fsp id
|
|
39
|
-
* @param {string} args.authorization - the authorization
|
|
40
|
-
*/
|
|
41
|
-
function requestAction (requests, { /* transactionRequestId, not used here */ fspId, authorization }) {
|
|
42
|
-
if (!fspId) {
|
|
43
|
-
throw new Error('AuthorizationsModel args requires \'fspId\' to be nonempty string');
|
|
44
|
-
}
|
|
45
|
-
return requests.postAuthorizations(authorization, fspId);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @name argsValidationMethod
|
|
50
|
-
* @description makes validation of args object, invoked in `run, triggerDeferredJob, generateKey` methods to ensure everything is going well
|
|
51
|
-
* @param {array} args - the arguments passed as object to `run` method
|
|
52
|
-
* @param {string} args.transactionRequestId - the transactionRequestId
|
|
53
|
-
* @param {string} args.fspId - the destination fsp id
|
|
54
|
-
* @param {string} [args.authorization] - ignored if passed - the authorization payload
|
|
55
|
-
*/
|
|
56
|
-
function argsValidation ({ transactionRequestId, fspId /* ,authorization not used here */ }) {
|
|
57
|
-
if (!(transactionRequestId && typeof (transactionRequestId) === 'string' && transactionRequestId.length > 0)) {
|
|
58
|
-
throw new Error('AuthorizationsModel args requires \'transactionRequestId\' is nonempty string and mandatory property');
|
|
59
|
-
}
|
|
60
|
-
if (fspId && !(typeof (fspId) === 'string' && fspId.length > 0)) {
|
|
61
|
-
throw new Error('AuthorizationsModel args requires \'fspId\' to be nonempty string');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @name reformatMessage
|
|
67
|
-
* @description reformats message received from PUB/SUB channel, it is optional method, if not specified identify function is used by default
|
|
68
|
-
* @param {object} message - message received
|
|
69
|
-
* @returns {object} - reformatted message
|
|
70
|
-
*/
|
|
71
|
-
function reformatMessage (message) {
|
|
72
|
-
return {
|
|
73
|
-
authorizations: { ...message }
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// generate model
|
|
78
|
-
const AuthorizationsModel = Async2SyncModel.generate({
|
|
79
|
-
modelName: 'AuthorizationsModel',
|
|
80
|
-
channelNameMethod: channelName,
|
|
81
|
-
requestActionMethod: requestAction,
|
|
82
|
-
argsValidationMethod: argsValidation,
|
|
83
|
-
reformatMessageMethod: reformatMessage
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
module.exports = AuthorizationsModel;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
const { uuid } = require('uuidv4');
|
|
5
|
-
const env = require('../../testEnv');
|
|
6
|
-
const authorizationsPostRequest = require('./data/authorizationsPostRequest.json');
|
|
7
|
-
|
|
8
|
-
jest.dontMock('redis');
|
|
9
|
-
|
|
10
|
-
describe('/authorizations', () => {
|
|
11
|
-
|
|
12
|
-
test('post - happy flow', async () => {
|
|
13
|
-
const postAuthorizationsURI = `${env.OutboundHostURI}/authorizations`;
|
|
14
|
-
const transactionRequestId = uuid();
|
|
15
|
-
const res = await axios({
|
|
16
|
-
method: 'POST',
|
|
17
|
-
url: postAuthorizationsURI,
|
|
18
|
-
data: {
|
|
19
|
-
fspId: 'switch',
|
|
20
|
-
authorizationsPostRequest: {
|
|
21
|
-
...authorizationsPostRequest,
|
|
22
|
-
transactionRequestId
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
headers: {
|
|
26
|
-
'access-control-allow-origin': '*'
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
expect(res.status).toEqual(200);
|
|
31
|
-
expect(res.data.currentState).toEqual('COMPLETED');
|
|
32
|
-
expect(typeof res.data).toEqual('object');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('post - timeout', (done) => {
|
|
36
|
-
const postAuthorizationsURI = `${env.OutboundHostURI}/authorizations`;
|
|
37
|
-
const transactionRequestId = uuid();
|
|
38
|
-
axios({
|
|
39
|
-
method: 'POST',
|
|
40
|
-
url: postAuthorizationsURI,
|
|
41
|
-
data: {
|
|
42
|
-
fspId: 'timeout-fsp-id',
|
|
43
|
-
authorizationsPostRequest: {
|
|
44
|
-
...authorizationsPostRequest,
|
|
45
|
-
transactionRequestId
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
headers: {
|
|
49
|
-
'access-control-allow-origin': '*'
|
|
50
|
-
}
|
|
51
|
-
}).catch(err => {
|
|
52
|
-
expect(err.response.status).toEqual(500);
|
|
53
|
-
expect(err.response.data.message).toEqual('Timeout');
|
|
54
|
-
done();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"authenticationType": "U2F",
|
|
3
|
-
"retriesLeft": 1,
|
|
4
|
-
"amount": {
|
|
5
|
-
"currency": "USD",
|
|
6
|
-
"amount": "100"
|
|
7
|
-
},
|
|
8
|
-
"transactionId": "2f169631-ef99-4cb1-96dc-91e8fc08f539",
|
|
9
|
-
"transactionRequestId": "02e28448-3c05-4059-b5f7-d518d0a2d8ea",
|
|
10
|
-
"quote": {
|
|
11
|
-
"transferAmount": {
|
|
12
|
-
"currency": "USD",
|
|
13
|
-
"amount": "100"
|
|
14
|
-
},
|
|
15
|
-
"payeeReceiveAmount": {
|
|
16
|
-
"currency": "USD",
|
|
17
|
-
"amount": "99"
|
|
18
|
-
},
|
|
19
|
-
"payeeFspFee": {
|
|
20
|
-
"currency": "USD",
|
|
21
|
-
"amount": "1"
|
|
22
|
-
},
|
|
23
|
-
"payeeFspCommission": {
|
|
24
|
-
"currency": "USD",
|
|
25
|
-
"amount": "0"
|
|
26
|
-
},
|
|
27
|
-
"expiration": "2020-05-17T15:28:54.250Z",
|
|
28
|
-
"geoCode": {
|
|
29
|
-
"latitude": "+45.4215",
|
|
30
|
-
"longitude": "+75.6972"
|
|
31
|
-
},
|
|
32
|
-
"ilpPacket": "AQAAAAAAACasIWcuc2UubW9iaWxlbW9uZXkubXNpc2RuLjEyMzQ1Njc4OYIEIXsNCiAgICAidHJhbnNhY3Rpb25JZCI6ICI4NWZlYWMyZi0zOWIyLTQ5MWItODE3ZS00YTAzMjAzZDRmMTQiLA0KICAgICJxdW90ZUlkIjogIjdjMjNlODBjLWQwNzgtNDA3Ny04MjYzLTJjMDQ3ODc2ZmNmNiIsDQogICAgInBheWVlIjogew0KICAgICAgICAicGFydHlJZEluZm8iOiB7DQogICAgICAgICAgICAicGFydHlJZFR5cGUiOiAiTVNJU0ROIiwNCiAgICAgICAgICAgICJwYXJ0eUlkZW50aWZpZXIiOiAiMTIzNDU2Nzg5IiwNCiAgICAgICAgICAgICJmc3BJZCI6ICJNb2JpbGVNb25leSINCiAgICAgICAgfSwNCiAgICAgICAgInBlcnNvbmFsSW5mbyI6IHsNCiAgICAgICAgICAgICJjb21wbGV4TmFtZSI6IHsNCiAgICAgICAgICAgICAgICAiZmlyc3ROYW1lIjogIkhlbnJpayIsDQogICAgICAgICAgICAgICAgImxhc3ROYW1lIjogIkthcmxzc29uIg0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAgfSwNCiAgICAicGF5ZXIiOiB7DQogICAgICAgICJwZXJzb25hbEluZm8iOiB7DQogICAgICAgICAgICAiY29tcGxleE5hbWUiOiB7DQogICAgICAgICAgICAgICAgImZpcnN0TmFtZSI6ICJNYXRzIiwNCiAgICAgICAgICAgICAgICAibGFzdE5hbWUiOiAiSGFnbWFuIg0KICAgICAgICAgICAgfQ0KICAgICAgICB9LA0KICAgICAgICAicGFydHlJZEluZm8iOiB7DQogICAgICAgICAgICAicGFydHlJZFR5cGUiOiAiSUJBTiIsDQogICAgICAgICAgICAicGFydHlJZGVudGlmaWVyIjogIlNFNDU1MDAwMDAwMDA1ODM5ODI1NzQ2NiIsDQogICAgICAgICAgICAiZnNwSWQiOiAiQmFua05yT25lIg0KICAgICAgICB9DQogICAgfSwNCiAgICAiYW1vdW50Ijogew0KICAgICAgICAiYW1vdW50IjogIjEwMCIsDQogICAgICAgICJjdXJyZW5jeSI6ICJVU0QiDQogICAgfSwNCiAgICAidHJhbnNhY3Rpb25UeXBlIjogew0KICAgICAgICAic2NlbmFyaW8iOiAiVFJBTlNGRVIiLA0KICAgICAgICAiaW5pdGlhdG9yIjogIlBBWUVSIiwNCiAgICAgICAgImluaXRpYXRvclR5cGUiOiAiQ09OU1VNRVIiDQogICAgfSwNCiAgICAibm90ZSI6ICJGcm9tIE1hdHMiDQp9DQo\u003d\u003d",
|
|
33
|
-
"condition": "f5sqb7tBTWPd5Y8BDFdMm9BJR_MNI4isf8p8n4D5pHA",
|
|
34
|
-
"extensionList": {
|
|
35
|
-
"extension": [
|
|
36
|
-
{
|
|
37
|
-
"key": "errorDescription1",
|
|
38
|
-
"value": "This is a more detailed error description"
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|