Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ULID support #499

Merged
merged 25 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,270 changes: 3,127 additions & 3,143 deletions docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_2.0/api_spec.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
"successCallback": {
"method": "put",
"path": "/participants/{Type}/{ID}/{SubId}",
"pathPattern": "/participants/{$request.params.Type}/{$request.params.ID}",
"pathPattern": "/participants/{$request.params.Type}/{$request.params.ID}/{$request.params.SubId}",
"headerOverride": {
"FSPIOP-Source": "{$config.FSPID}",
"FSPIOP-Destination": "{$request.headers.fspiop-source}",
Expand All @@ -368,7 +368,7 @@
"errorCallback": {
"method": "put",
"path": "/participants/{Type}/{ID}/{SubId}/error",
"pathPattern": "/participants/{$request.params.Type}/{$request.params.ID}/error",
"pathPattern": "/participants/{$request.params.Type}/{$request.params.ID}/{$request.params.SubId}/error",
"headerOverride": {
"FSPIOP-Source": "{$config.FSPID}",
"FSPIOP-Destination": "{$request.headers.fspiop-source}",
Expand All @@ -382,7 +382,7 @@
"successCallback": {
"method": "put",
"path": "/participants/{Type}/{ID}/{SubId}",
"pathPattern": "/participants/{$request.params.Type}/{$request.params.ID}",
"pathPattern": "/participants/{$request.params.Type}/{$request.params.ID}/{$request.params.SubId}",
"headerOverride": {
"FSPIOP-Source": "{$config.FSPID}",
"FSPIOP-Destination": "{$request.headers.fspiop-source}",
Expand All @@ -393,7 +393,7 @@
"errorCallback": {
"method": "put",
"path": "/participants/{Type}/{ID}/{SubId}/error",
"pathPattern": "/participants/{$request.params.Type}/{$request.params.ID}/error",
"pathPattern": "/participants/{$request.params.Type}/{$request.params.ID}/{$request.params.SubId}/error",
"headerOverride": {
"FSPIOP-Source": "{$config.FSPID}",
"FSPIOP-Destination": "{$request.headers.fspiop-source}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"FSPIOP-Source": "{$inputs.TrsPayerFspId}"
},
"body": {
"quoteId": "{$function.generic.generateUUID}",
"quoteId": "{$function.generic.generateID}",
"transactionId": "{$inputs.transactionId}",
"payer": {
"partyIdInfo": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ components:
title: CorrelationId
type: string
pattern: >-
^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
description: >-
Identifier that correlates all messages of the same sequence. The API
data type UUID (Universally Unique Identifier) is a JSON String in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ components:
bulkQuoteId:
description: A Mojaloop API bulk quote identifier (UUID).
pattern: >-
^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
type: string
bulkQuoteRequest:
description: A request for a bulk quote.
Expand Down Expand Up @@ -736,7 +736,7 @@ components:
bulkTransferId:
description: A Mojaloop API transfer identifier (UUID).
pattern: >-
^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
type: string
bulkTransferRequest:
properties:
Expand Down Expand Up @@ -1214,7 +1214,7 @@ components:
quoteId:
description: A Mojaloop API quote identifier (UUID).
pattern: >-
^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
type: string
quoteRequest:
description: A request for a quote for transfer from the DFSP backend.
Expand Down Expand Up @@ -1324,7 +1324,7 @@ components:
ID of the transaction, the ID is decided by the Payer FSP during the
creation of the quote.
pattern: >-
^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
type: string
transactionRequest:
description: A request for a pull based transfer.
Expand Down Expand Up @@ -1371,7 +1371,7 @@ components:
transactionRequestId:
description: A Mojaloop API transaction request identifier (UUID).
pattern: >-
^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
type: string
transactionRequestResponse:
description: A response to a request for a quote.
Expand Down Expand Up @@ -1470,7 +1470,7 @@ components:
transferId:
description: A Mojaloop API transfer identifier (UUID).
pattern: >-
^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
type: string
transferParty:
properties:
Expand Down Expand Up @@ -1621,7 +1621,7 @@ components:
title: CorrelationId
type: string
pattern: >-
^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
description: >-
Identifier that correlates all messages of the same sequence. The API
data type UUID (Universally Unique Identifier) is a JSON String in
Expand Down
10 changes: 5 additions & 5 deletions modules/api-svc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-scheme-adapter-api-svc",
"version": "20.8.0-snapshot.16",
"version": "20.8.0-snapshot.18",
"description": "An adapter for connecting to Mojaloop API enabled switches.",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand All @@ -21,7 +21,7 @@
"start:debug": "node --inspect=0.0.0.0:9229 src/index.js",
"build": "yarn run build:openapi",
"build:openapi": "yarn run build:openapi:inbound",
"build:openapi:inbound": "openapi bundle --output src/InboundServer/api.yaml --ext yaml ./node_modules/@mojaloop/api-snippets/fspiop/v2_0/openapi3/openapi.yaml",
"build:openapi:inbound": "openapi bundle --output src/InboundServer/api.yaml --ext yaml ../../node_modules/@mojaloop/api-snippets/fspiop/v2_0/openapi3/openapi.yaml",
"clean:dist": "rm -Rf dist",
"lint": "eslint ./src/",
"lint:fix": "eslint ./src/ --fix",
Expand Down Expand Up @@ -63,11 +63,11 @@
},
"dependencies": {
"@koa/cors": "^5.0.0",
"@mojaloop/api-snippets": "17.6.1",
"@mojaloop/api-snippets": "17.7.0",
"@mojaloop/central-services-error-handling": "^13.0.1",
"@mojaloop/central-services-logger": "^11.5.1",
"@mojaloop/central-services-metrics": "^12.0.8",
"@mojaloop/central-services-shared": "18.8.0",
"@mojaloop/central-services-shared": "18.9.0",
"@mojaloop/event-sdk": "^14.1.1",
"@mojaloop/sdk-scheme-adapter-private-shared-lib": "workspace:^",
"@mojaloop/sdk-standard-components": "18.4.1",
Expand Down Expand Up @@ -109,7 +109,7 @@
"nock": "^13.5.5",
"npm-check-updates": "^16.7.10",
"openapi-response-validator": "^12.1.3",
"openapi-typescript": "^7.4.0",
"openapi-typescript": "^7.4.1",
"redis-mock": "^0.56.3",
"replace": "^1.2.2",
"standard-version": "^9.5.0",
Expand Down
26 changes: 17 additions & 9 deletions modules/api-svc/src/InboundServer/api.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
openapi: 3.0.2
info:
version: '2.0'
version: 2.0-draft
title: Open API for FSP Interoperability (FSPIOP)
description: >-
Based on [API Definition updated on 2020-05-19 Version
Revision date: 2023-11-23 Based on [API Definition updated on 2020-05-19
Version
1.1](https://github.com/mojaloop/mojaloop-specification/blob/main/documents/v1.1-document-set/API%20Definition_v1.1.pdf).

This is implementation friendly version of the API definition.

It includes the below definitions needed for third-party functionality. -
AuthenticationType
- U2F enum
- AuthenticationValue
- oneOf is changed to anyOf
- new element is added U2FPinValue
- New element U2FPIN

**Note:** The API supports a maximum size of 65536 bytes (64 Kilobytes) in
the HTTP header.
Expand Down Expand Up @@ -2810,14 +2820,12 @@ components:
title: CorrelationId
type: string
pattern: >-
^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$|^[0-9A-HJKMNP-TV-Z]{26}$
description: >-
Identifier that correlates all messages of the same sequence. The API
data type UUID (Universally Unique Identifier) is a JSON String in
canonical format, conforming to [RFC
4122](https://tools.ietf.org/html/rfc4122), that is restricted by a
regular expression for interoperability reasons. A UUID is always 36
characters long, 32 hexadecimal symbols and 4 dashes (‘-‘).
Identifier that correlates all messages of the same sequence. The
supported identifiers formats are for lowercase
[UUID](https://datatracker.ietf.org/doc/html/rfc9562) and uppercase
[ULID](https://github.com/ulid/spec)
example: b51ec534-ee48-4575-b6a9-ead2955b8069
PartyIdType:
title: PartyIdType
Expand Down
2 changes: 1 addition & 1 deletion modules/api-svc/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = {
mgmtAPIWsUrl: env.get('MGMT_API_WS_URL').default('127.0.0.1').asString(),
mgmtAPIWsPort: env.get('MGMT_API_WS_PORT').default('4005').asPortNumber()
},
idGenerator: env.get('ID_GENERATOR').default('{"type":"uuid","version":4}').asJsonObject(),
idGenerator: env.get('ID_GENERATOR').default('{"type":"ulid"}').asJsonObject(),
logLevel: env.get('LOG_LEVEL').default('info').asEnum(['trace', 'debug', 'info', 'warn', 'error', 'fatal']),
inbound: {
port: env.get('INBOUND_LISTEN_PORT').default('4000').asPortNumber(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class OutboundRequestToPayModel {
jwsSignPutParties: config.jwsSignPutParties,
jwsSigningKey: config.jwsSigningKey,
wso2: config.wso2,
resourceVersions: config.resourceVersions,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class OutboundRequestToPayTransferModel {
jwsSignPutParties: config.jwsSignPutParties,
jwsSigningKey: config.jwsSigningKey,
wso2: config.wso2,
resourceVersions: config.resourceVersions,
});

this._ilp = new Ilp({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const components = jest.requireActual('@mojaloop/central-services-shared');

let id = 0;

components.Util.id = () => () => `00000000-0000-1000-8000-${(++id).toString().padStart(12, '0')}`;
components.Util.id = () => () => (++id).toString().padStart(26, '0');
components.Util.id.__reset = () => { id = 0; };

module.exports = components;
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jest.unmock('@mojaloop/central-services-shared');
jest.unmock('javascript-state-machine');
// Tests can timeout in a CI pipeline so giving it leeway
jest.setTimeout(50000);
const randomUUID = require('@mojaloop/central-services-shared').Util.id({version: 4});
const randomUUID = require('@mojaloop/central-services-shared').Util.id({type: 'ulid'});

const MANAGEMENT_MOCK_SERVER_URL = 'http://localhost:5005';
const fs = require('fs');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const axios = require('axios');
const uuid = require('@mojaloop/central-services-shared').Util.id({version: 4});
const uuid = require('@mojaloop/central-services-shared').Util.id({type: 'ulid'});
const env = require('../../testEnv');
const quotesPostRequest = require('./data/quotesPostRequest.json');
const { SDKStateEnum } = require('../../../../src/lib/model/common');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const axios = require('axios');
const uuid = require('@mojaloop/central-services-shared').Util.id({version: 4});
const uuid = require('@mojaloop/central-services-shared').Util.id({type: 'ulid'});
const env = require('../../testEnv');
const transfersPostRequest = require('./data/transfersPostRequest.json');
const { SDKStateEnum } = require('../../../../src/lib/model/common');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
}
},
"modelId": "00000000-0000-1000-8000-000000000001",
"modelId": "00000000000000000000000001",
"response": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"lastError": {
"httpStatusCode": 504
},
"modelId": "00000000-0000-1000-8000-000000000001",
"modelId": "00000000000000000000000001",
"response": []
},
"message": "Timeout waiting for response to account creation request 00000000-0000-1000-8000-000000000002",
"message": "Timeout waiting for response to account creation request 00000000000000000000000002",
"statusCode": "504"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"currentState": "COMPLETED",
"modelId": "00000000-0000-1000-8000-000000000001",
"modelId": "00000000000000000000000001",
"postAccountsResponse": {
"body": {
"currency": "USD",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"currentState": "COMPLETED",
"modelId": "00000000-0000-1000-8000-000000000001",
"modelId": "00000000000000000000000001",
"postAccountsResponse": {
"body": {
"partyList": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"currentState": "COMPLETED",
"modelId": "00000000-0000-1000-8000-000000000001",
"modelId": "00000000000000000000000001",
"postAccountsResponse": {
"body": {
"currency": "USD",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"transferState": "COMMITTED"
}
},
"transferId": "00000000-0000-1000-8000-000000000001"
"transferId": "00000000000000000000000001"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
}
}
},
"transferId": "00000000-0000-1000-8000-000000000001"
"transferId": "00000000000000000000000001"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"partyIdentifier": "123456789"
}
},
"quoteId": "00000000-0000-1000-8000-000000000002",
"transactionId": "00000000-0000-1000-8000-000000000001",
"quoteId": "00000000000000000000000002",
"transactionId": "00000000000000000000000001",
"transactionType": {
"initiator": "PAYER",
"initiatorType": "CONSUMER",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"ilpPacket": "AQAAAAAAACasIWcuc2UubW9iaWxlbW9uZXkubXNpc2RuLjEyMzQ1Njc4OYIEIXsNCiAgICAidHJhbnNhY3Rpb25JZCI6ICI4NWZlYWMyZi0zOWIyLTQ5MWItODE3ZS00YTAzMjAzZDRmMTQiLA0KICAgICJxdW90ZUlkIjogIjdjMjNlODBjLWQwNzgtNDA3Ny04MjYzLTJjMDQ3ODc2ZmNmNiIsDQogICAgInBheWVlIjogew0KICAgICAgICAicGFydHlJZEluZm8iOiB7DQogICAgICAgICAgICAicGFydHlJZFR5cGUiOiAiTVNJU0ROIiwNCiAgICAgICAgICAgICJwYXJ0eUlkZW50aWZpZXIiOiAiMTIzNDU2Nzg5IiwNCiAgICAgICAgICAgICJmc3BJZCI6ICJNb2JpbGVNb25leSINCiAgICAgICAgfSwNCiAgICAgICAgInBlcnNvbmFsSW5mbyI6IHsNCiAgICAgICAgICAgICJjb21wbGV4TmFtZSI6IHsNCiAgICAgICAgICAgICAgICAiZmlyc3ROYW1lIjogIkhlbnJpayIsDQogICAgICAgICAgICAgICAgImxhc3ROYW1lIjogIkthcmxzc29uIg0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAgfSwNCiAgICAicGF5ZXIiOiB7DQogICAgICAgICJwZXJzb25hbEluZm8iOiB7DQogICAgICAgICAgICAiY29tcGxleE5hbWUiOiB7DQogICAgICAgICAgICAgICAgImZpcnN0TmFtZSI6ICJNYXRzIiwNCiAgICAgICAgICAgICAgICAibGFzdE5hbWUiOiAiSGFnbWFuIg0KICAgICAgICAgICAgfQ0KICAgICAgICB9LA0KICAgICAgICAicGFydHlJZEluZm8iOiB7DQogICAgICAgICAgICAicGFydHlJZFR5cGUiOiAiSUJBTiIsDQogICAgICAgICAgICAicGFydHlJZGVudGlmaWVyIjogIlNFNDU1MDAwMDAwMDA1ODM5ODI1NzQ2NiIsDQogICAgICAgICAgICAiZnNwSWQiOiAiQmFua05yT25lIg0KICAgICAgICB9DQogICAgfSwNCiAgICAiYW1vdW50Ijogew0KICAgICAgICAiYW1vdW50IjogIjEwMCIsDQogICAgICAgICJjdXJyZW5jeSI6ICJVU0QiDQogICAgfSwNCiAgICAidHJhbnNhY3Rpb25UeXBlIjogew0KICAgICAgICAic2NlbmFyaW8iOiAiVFJBTlNGRVIiLA0KICAgICAgICAiaW5pdGlhdG9yIjogIlBBWUVSIiwNCiAgICAgICAgImluaXRpYXRvclR5cGUiOiAiQ09OU1VNRVIiDQogICAgfSwNCiAgICAibm90ZSI6ICJGcm9tIE1hdHMiDQp9DQo==",
"payeeFsp": "sim",
"payerFsp": "mojaloop-sdk",
"transferId": "00000000-0000-1000-8000-000000000001"
"transferId": "00000000000000000000000001"
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"transferId": "00000000-0000-1000-8000-000000000001",
"transferId": "00000000000000000000000001",
"transferRequestExtensions": [
{
"key": "treqkey1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"message": "Timeout resolving payee for transfer 00000000-0000-1000-8000-000000000001",
"message": "Timeout resolving payee for transfer 00000000000000000000000001",
"statusCode": "504",
"transferState": {
"amount": "100",
Expand Down Expand Up @@ -34,7 +34,7 @@
},
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"transferId": "00000000-0000-1000-8000-000000000001",
"transferId": "00000000000000000000000001",
"transferRequestExtensions": [
{
"key": "treqkey1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"homeTransactionId": "123ABC",
"note": "test payment",
"quoteId": "00000000-0000-1000-8000-000000000002",
"quoteId": "00000000000000000000000002",
"quoteRequestExtensions": [
{
"key": "qreqkey1",
Expand Down Expand Up @@ -115,7 +115,7 @@
},
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"transferId": "00000000-0000-1000-8000-000000000001",
"transferId": "00000000000000000000000001",
"transferRequestExtensions": [
{
"key": "treqkey1",
Expand Down
2 changes: 1 addition & 1 deletion modules/api-svc/test/unit/api/transfers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function createGetTransfersTester({ reqInbound, reqOutbound, apiSpecsOutbound })
* @return {Promise<any>}
*/
return async (putBodyFn, responseCode, responseBody) => {
const TRANSFER_ID = '00000000-0000-1000-8000-000000000001';
const TRANSFER_ID = '00000000000000000000000001';
const endpoint = new URL(`http://${defaultConfig.peerEndpoint}`).host;
const switchEndpoint = `http://${endpoint}`;

Expand Down
Loading