Skip to content

Commit

Permalink
feat(pisp-transaction): handle outbound put authorization (#119)
Browse files Browse the repository at this point in the history
* feat(outbound): update sync authorization response

* feat(outbound): update sync authorization response

* feat: replace outdated putAuthorizations with putThirdpartyRequestsAuthorizations call

* fix: pispTransaction model tests for new auth payloads

* fix: pispTransaction model tests for new auth payloads

* fix: pispTransaction model tests for new auth payloads

* fix(ci): run integration tests inband to help reduce flakyness

* fix(integration): update ttk interface

* fix(integration): update ttk interface
  • Loading branch information
Lewis Daly authored Aug 31, 2021
1 parent fbbc209 commit 7d6e6d8
Show file tree
Hide file tree
Showing 15 changed files with 707 additions and 359 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"fspid": "{$request.headers.fspiop-source}",
"successCallback": {
"method": "post",
"path": "/authorizations",
"pathPattern": "/authorizations",
"path": "/thirdpartyRequests/authorizations",
"pathPattern": "/thirdpartyRequests/authorizations",
"headerOverride": {
"FSPIOP-Source": "{$config.FSPID}",
"FSPIOP-Destination": "{$request.headers.fspiop-source}",
Expand All @@ -15,8 +15,8 @@
},
"errorCallback": {
"method": "post",
"path": "/authorizations",
"pathPattern": "/authorizations",
"path": "/thirdpartyRequests/authorizations",
"pathPattern": "/thirdpartyRequests/authorizations",
"headerOverride": {
"FSPIOP-Source": "{$config.FSPID}",
"FSPIOP-Destination": "{$request.headers.fspiop-source}",
Expand Down Expand Up @@ -80,7 +80,7 @@
}
}
},
"/authorizations/{ID}": {
"/thirdpartyRequests/authorizations/{ID}": {
"put": {
"fspid": "{$request.headers.fspiop-source}",
"successCallback": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,12 @@ paths:
$ref: '../../../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/paths/participants_Type_ID.yaml'
/participants/{Type}/{ID}/error:
$ref: '../../../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/paths/participants_Type_ID_error.yaml'
/thirdpartyRequests/authorizations:
$ref: '../../../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/paths/thirdpartyRequests_authorizations.yaml'
/thirdpartyRequests/authorizations/{ID}:
$ref: '../../../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/paths/thirdpartyRequests_authorizations_ID.yaml'
/thirdpartyRequests/authorizations/{ID}/error:
$ref: '../../../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/paths/thirdpartyRequests_authorizations_ID_error.yaml'

components:
schemas:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
},
"event": {
"method": "post",
"path": "/authorizations",
"path": "/thirdpartyRequests/authorizations",
"params": {
"headers": {
"Accept": "application/vnd.interoperability.authorizations+json;version=1.0",
Expand All @@ -134,47 +134,39 @@
"FSPIOP-Source": "DFSPA"
},
"body": {
"authenticationType": "U2F",
"retriesLeft": "1",
"amount": {
"currency": "USD",
"amount": "124.45"
"authorizationRequestId": "5f8ee7f9-290f-4e03-ae1c-1e81ecf398df",
"transactionRequestId": "b51ec534-ee48-4575-b6a9-ead2955b8069",
"challenge": "<base64 encoded binary - the encoded challenge>",
"transferAmount": {
"amount": "100",
"currency": "USD"
},
"transactionId": "2f169631-ef99-4cb1-96dc-91e8fc08f539",
"transactionRequestId": "{$request.body.transactionRequestId}",
"quote": {
"transferAmount": {
"currency": "USD",
"amount": "124.45"
},
"payeeReceiveAmount": {
"currency": "USD",
"amount": "123.45"
},
"payeeFspFee": {
"currency": "USD",
"amount": "1"
},
"payeeFspCommission": {
"currency": "USD",
"amount": "0"
},
"expiration": "2020-08-24T08:38:08.699-04:00",
"geoCode": {
"latitude": "+45.4215",
"longitude": "+75.6972"
},
"ilpPacket": "AYIBgQAAAAAAAASwNGxldmVsb25lLmRmc3AxLm1lci45T2RTOF81MDdqUUZ",
"condition": "f5sqb7tBTWPd5Y8BDFdMm9BJR_MNI4isf8p8n4D5pHA",
"extensionList": {
"extension": [
{
"key": "errorDescription",
"value": "This is a more detailed error description"
}
]
"payeeReceiveAmount": {
"amount": "99",
"currency": "USD"
},
"fees": {
"amount": "1",
"currency": "USD"
},
"payee": {
"partyIdInfo": {
"partyIdType": "MSISDN",
"partyIdentifier": "+4412345678",
"fspId": "dfspb"
}
}
},
"payer": {
"partyIdType": "THIRD_PARTY_LINK",
"partyIdentifier": "qwerty-123456",
"fspId": "dfspa"
},
"transactionType": {
"scenario": "TRANSFER",
"initiator": "PAYER",
"initiatorType": "CONSUMER"
},
"expiration": "2020-06-15T12:00:00.000Z"
},
"scripts": {
"exec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
{
"ruleId": 4,
"priority": 1,
"description": "put /authorizations/{ID}",
"description": "put /thirdpartyRequests/authorizations/{ID}",
"apiVersion": {
"minorVersion": 1,
"majorVersion": 0,
Expand All @@ -158,7 +158,7 @@
{
"fact": "operationPath",
"operator": "equal",
"value": "/authorizations/{ID}"
"value": "/thirdpartyRequests/authorizations/{ID}"
},
{
"fact": "method",
Expand All @@ -178,9 +178,7 @@
"",
"const userConfig = JSON.parse(pm.globals.get('userConfig'))",
"const curDate = (new Date()).toUTCString();",
"const transactionRequestId = pm.request.url.path[1]",
"console.log('transactionRequestId:'+transactionRequestId)",
"const url = 'http://inbound-thirdparty-scheme-adapter:4005/thirdpartyRequests/transactions/' + transactionRequestId",
"const url = 'http://inbound-thirdparty-scheme-adapter:4005/thirdpartyRequests/transactions/b51ec534-ee48-4575-b6a9-ead2955b8069'",
"console.log('url:'+ url)",
"const patchThirdpartyRequestIDTransactionReq = {",
" url,",
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"test:bdd": "jest --config './jest.bdd.config.js' --runInBand --testMatch '**/test/step-definitions/**/*.step.ts'",
"test:coverage": "jest --coverage --testMatch '**/test/unit/**/*.(test|spec).ts'",
"test:coverage-check": "jest -w 1 --coverage --testMatch '**/test/unit/**/*.(test|spec).ts'",
"test:integration": "jest --config './jest.integration.config.js' --testMatch '**/test/integration/**/*.(test|spec).ts'",
"test:integration": "jest --config './jest.integration.config.js' --testMatch '**/test/integration/**/*.(test|spec).ts' --runInBand",
"test:unit": "jest -w 1 --coverageThreshold='{}' --testMatch '**/test/unit/**/*.(test|spec).ts'",
"updates:check": "npm-check-updates",
"updates:update": "npm-check-updates -u && npm install",
Expand Down Expand Up @@ -93,7 +93,7 @@
"@mojaloop/central-services-health": "^13.0.0",
"@mojaloop/central-services-shared": "^13.0.5",
"@mojaloop/sdk-scheme-adapter": "^11.16.2",
"@mojaloop/sdk-standard-components": "^15.11.0",
"@mojaloop/sdk-standard-components": "^15.13.0",
"@types/axios": "^0.14.0",
"@types/convict": "^5.2.2",
"@types/crypto-js": "^4.0.1",
Expand Down
144 changes: 44 additions & 100 deletions src/interface/api-outbound.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1462,69 +1462,41 @@ components:
oneOf:
- $ref: '#/components/schemas/ThirdpartyTransactionIDInitiateResponseError'
- $ref: '#/components/schemas/ThirdpartyTransactionIDInitiateResponseSuccess'
AuthenticationType:
title: AuthenticationType
SignedPayloadTypeGeneric:
title: SignedPayloadTypeGeneric
type: string
enum:
- OTP
- QRCODE
- U2F
description: |-
Below are the allowed values for the enumeration AuthenticationType.
- OTP - One-time password generated by the Payer FSP.
- QRCODE - QR code used as One Time Password.
- U2F - U2F is a new addition isolated to Thirdparty stream.
OtpValue:
title: OtpValue
- GENERIC
description: Describes a challenge that has been signed with a private key
BinaryString:
type: string
pattern: '^\d{3,10}$'
pattern: '^[A-Za-z0-9-_]+[=]{0,2}$'
description: >-
The API data type OtpValue is a JSON String of 3 to 10 characters,
consisting of digits only. Negative numbers are not allowed. One or more
leading zeros are allowed.
QRCODE:
title: QRCODE
type: string
minLength: 1
maxLength: 64
description: QR code used as a One Time Password.
U2FPIN:
title: U2FPIN
type: string
pattern: '^\S{1,64}$'
minLength: 1
maxLength: 64
description: >
U2F challenge-response, where payer FSP verifies if the response
provided by end-user device matches the previously registered key.
Integer:
title: Integer
type: string
pattern: '^[1-9]\d*$'
description: >-
The API data type Integer is a JSON String consisting of digits only.
Negative numbers and leading zeroes are not allowed. The data type is
always limited to a specific number of digits.
U2FPinValue:
title: U2FPinValue
The API data type BinaryString is a JSON String. The string is a
base64url encoding of a string of raw bytes, where padding (character
‘=’) is added at the end of the data if needed to ensure that the string
is a multiple of 4 characters. The length restriction indicates the
allowed number of characters.
ThirdpartyRequestsAuthorizationsIDPutResponseGeneric:
title: ThirdpartyRequestsAuthorizationsIDPutResponseGeneric
type: object
description: >
U2F challenge-response, where payer FSP verifies if the response
provided by end-user device matches the previously registered key.
description: >-
The object sent in the PUT /thirdpartyRequests/authorizations/{ID}
callback.
properties:
pinValue:
allOf:
- $ref: '#/components/schemas/U2FPIN'
description: U2F challenge-response.
counter:
allOf:
- $ref: '#/components/schemas/Integer'
description: >-
Sequential counter used for cloning detection. Present only for U2F
authentication.
signedPayloadType:
$ref: '#/components/schemas/SignedPayloadTypeGeneric'
signedPayload:
$ref: '#/components/schemas/BinaryString'
required:
- pinValue
- counter
- signedPayloadType
- authenticationValue
SignedPayloadTypeFIDO:
title: SignedPayloadTypeFIDO
type: string
enum:
- FIDO
description: Describes a challenge that has been signed with FIDO Attestation flows
FIDOPublicKeyCredentialAssertion:
title: FIDOPublicKeyCredentialAssertion
type: object
Expand Down Expand Up @@ -1596,58 +1568,30 @@ components:
- response
- type
additionalProperties: false
AuthenticationValue:
title: AuthenticationValue
anyOf:
- $ref: '#/components/schemas/OtpValue'
- $ref: '#/components/schemas/QRCODE'
- $ref: '#/components/schemas/U2FPinValue'
- $ref: '#/components/schemas/FIDOPublicKeyCredentialAssertion'
description: >-
Contains the authentication value. The format depends on the
authentication type used in the AuthenticationInfo complex type.
AuthenticationInfo:
title: AuthenticationInfo
type: object
description: Data model for the complex type AuthenticationInfo.
properties:
authentication:
$ref: '#/components/schemas/AuthenticationType'
authenticationValue:
$ref: '#/components/schemas/AuthenticationValue'
required:
- authentication
- authenticationValue
AuthorizationResponse:
title: AuthorizationResponse
type: string
enum:
- ENTERED
- REJECTED
- RESEND
description: |-
Below are the allowed values for the enumeration.
- ENTERED - Consumer entered the authentication value.
- REJECTED - Consumer rejected the transaction.
- RESEND - Consumer requested to resend the authentication value.
example: ENTERED
AuthorizationsIDPutResponse:
title: AuthorizationsIDPutResponse
ThirdpartyRequestsAuthorizationsIDPutResponseFIDO:
title: ThirdpartyRequestsAuthorizationsIDPutResponseFIDO
type: object
description: 'The object sent in the PUT /authorizations/{ID} callback.'
description: >-
The object sent in the PUT /thirdpartyRequests/authorizations/{ID}
callback.
properties:
authenticationInfo:
$ref: '#/components/schemas/AuthenticationInfo'
responseType:
$ref: '#/components/schemas/AuthorizationResponse'
signedPayloadType:
$ref: '#/components/schemas/SignedPayloadTypeFIDO'
signedPayload:
$ref: '#/components/schemas/FIDOPublicKeyCredentialAssertion'
required:
- responseType
- signedPayloadType
- signedPayload
ThirdpartyTransactionIDApproveRequest:
title: ThirdpartyTransactionIDApproveRequest
type: object
properties:
authorizationResponse:
$ref: '#/components/schemas/AuthorizationsIDPutResponse'
oneOf:
- $ref: >-
#/components/schemas/ThirdpartyRequestsAuthorizationsIDPutResponseGeneric
- $ref: >-
#/components/schemas/ThirdpartyRequestsAuthorizationsIDPutResponseFIDO
required:
- authorizationResponse
ThirdpartyTransactionIDApproveState:
Expand Down
11 changes: 0 additions & 11 deletions src/interface/outbound/api_interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,10 @@ export namespace Schemas {
export type ExtensionList = components['schemas']['ExtensionList']
export type ErrorInformation = components['schemas']['ErrorInformation']
export type ErrorInformationResponse = components['schemas']['ErrorInformationResponse']
export type AuthenticationType = components['schemas']['AuthenticationType']
export type Integer = components['schemas']['Integer']
export type Currency = components['schemas']['Currency']
export type Amount = components['schemas']['Amount']
export type Money = components['schemas']['Money']
export type CorrelationId = components['schemas']['CorrelationId']
export type DateTime = components['schemas']['DateTime']
export type OtpValue = components['schemas']['OtpValue']
export type QRCODE = components['schemas']['QRCODE']
export type U2FPIN = components['schemas']['U2FPIN']
export type U2FPinValue = components['schemas']['U2FPinValue']
export type AuthenticationValue = components['schemas']['AuthenticationValue']
export type AuthenticationInfo = components['schemas']['AuthenticationInfo']
export type AuthorizationResponse = components['schemas']['AuthorizationResponse']
export type PartyIdType = components['schemas']['PartyIdType']
export type PartyIdentifier = components['schemas']['PartyIdentifier']
export type PartySubIdOrType = components['schemas']['PartySubIdOrType']
Expand Down Expand Up @@ -64,7 +54,6 @@ export namespace Schemas {
export type ThirdpartyRequestsAuthorizationsPostRequest = components['schemas']['ThirdpartyRequestsAuthorizationsPostRequest']
export type ThirdpartyTransactionIDInitiateResponseSuccess = components['schemas']['ThirdpartyTransactionIDInitiateResponseSuccess']
export type ThirdpartyTransactionIDInitiateResponse = components['schemas']['ThirdpartyTransactionIDInitiateResponse']
export type AuthorizationsIDPutResponse = components['schemas']['AuthorizationsIDPutResponse']
export type ThirdpartyTransactionIDApproveRequest = components['schemas']['ThirdpartyTransactionIDApproveRequest']
export type ThirdpartyTransactionIDApproveState = components['schemas']['ThirdpartyTransactionIDApproveState']
export type ThirdpartyTransactionIDApproveResponseError = components['schemas']['ThirdpartyTransactionIDApproveResponseError']
Expand Down
Loading

0 comments on commit 7d6e6d8

Please sign in to comment.