1.16.4-4 • Published 4 years ago

mojaloop-fxp-scheme-adapter v1.16.4-4

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
4 years ago

Mojaloop FXP Scheme Adapter

Mojaloop FXP Scheme Adapter implements the Mojaloop API quotes and transfers operations to provide Foreign Exchange quotes and transaction handling. It uses the Mojaloop FXP Server that provides the exchange rate conversion for quotes and transfers.

The following diagram shows how FXP would be deployed in a Mojaloop instance

npm.io.

Configuration

Mojaloop FXP Scheme Adapter uses a set of environment variables. Several variables are passed on to the mojaloop-sdk-scheme-adapter used as a library.

The repo includes a sample env file that can be used as a base.

ENV varDescription
INBOUND_LISTEN_PORTPort number that the inbound (Mojaloop API) HTTP server will listen on
PEER_ENDPOINTMojaloop Switch inbound endpoint (host:port)
BACKEND_ENDPOINTMojaloop FXP Server inbound endpoint (host:port)
WS02_BEARER_TOKENStatic token to be used on the communication with the mojaloop hub

| OAuth2 data used to obtain WSO2 bearer token |OAUTH_TOKEN_ENDPOINT| See Mojaloop Scheme Adapter SDK |OAUTH_CLIENT_KEY| See Mojaloop Scheme Adapter SDK |OAUTH_CLIENT_SECRET| See Mojaloop Scheme Adapter SDK |OAUTH_REFRESH_SECONDS| See Mojaloop Scheme Adapter SDK | TLS Configuration |MUTUAL_TLS_ENABLED|Enable mutual TLS authentication on the inboud API |IN_CA_CERT_PATH|Location of the CA cert required for TLS |IN_SERVER_CERT_PATH|Location of the Server cert required for TLS |IN_SERVER_KEY_PATH|Location of the Key cert required for TLS | JWS Configuration |VALIDATE_INBOUND_JWS|Enable verification or incoming JWS signatures. Note that signatures will be required on incoming messages and will be validated against a public key. If enabled, remember to add the other DFSP's keys at JWS_VERIFICATION_KEYS_DIRECTORY |JWS_VERIFICATION_KEYS_DIRECTORY|Contains the DFSP's public keys. Each file must be named as the DFSP and have the .pem extension ( as in DFSP1.pem) |JWS_SIGN|Enables JWS signing of outgoing requests. If true, you must also define JWS_SIGNING_KEY_PATH |JWS_SIGNING_KEY_PATH|Path to JWS signing key (private key) in PEM format | ILP Configuration |CHECK_ILP|set to true to validate ILP, otherwise false to ignore ILP |ILP_SECRET|Secret used for generation and verification of secure ILP | Cache Configuration |CACHE_HOST|Redis cache host |CACHE_PORT|Redis cache port | Timeouts |SECOND_STAGE_QUOTE_RESPONSE_TIMEOUT|Time in milliseconds to wait for a response to a second stage quote before timing out |REJECT_TRANSFERS_ON_EXPIRED_QUOTES| See Mojaloop Scheme Adaptet SDK | Database configuration | Database used to store the domain events |DATABASE_HOST|mysql host |DATABASE_PORT|mysql port |DATABASE_USER|user |DATABASE_PASSWORD|password |DATABASE_SCHEMA|schema |DB_RETRIES| Number of times the service should attempt to connect to the database |DB_CONNECTION_RETRY_WAIT_MILLISECONDS| Pause between DB connection retries |RUN_DB_SCHEMA_CREATION|boolean. If true, it will create the initial database schema on startup, without any data. To create initial data, go to the Initial data configuration section below |RUN_DB_SEED| Run knex seed process, inserting in the database all the data in the seeds folder |RUN_CHECK_DB_UTC|boolean. If true, it will check that the DB is in UTC (must be) |INTERNAL VARIABLES (safe defaults): |FXP_MODE_ENABLED|SDK works as a FXP server front end ( true ). Must be true |LOG_INDENT|The number of space characters by which to indent pretty-printed logs. If set to zero, log events will each be printed on a single line |PEER_ROUTING_CONFIG|JSON file path with the peer routing ( dfsp -> endpoint ). If null, this feature is not enabled and all request will be sent to the PEER_ENDPOINT |FORWARD_PUT_QUOTES_TO_BACKEND|Forward put /quotes/{id} calls to backend. Usually set to true when used as a passthrough or Hub emulator while testing an integration |FORWARD_PUT_TRANSFERS_TO_BACKEND|Forward put /transfers/{id} calls to backend. Usually set to true when used as a passthrough or Hub emulator while testing an integration |FXP_LEDGERS_API_PORT| Port number where it runs the ledgers api server | Initial data configuration |RUN_DATA_CONFIGURATION| Set RUN_DATA_CONFIGURATION = TRUE to execute the initial data configuration process. Preferably, it should be changed to FALSE after the first deployment or in case we don't want to insert new data. If it is still TRUE, the process will continue to run succesfully but will try to insert the previous data configurations again, logging ignored errors. For more instructions about the process, see initial_data_configuration.md |DATA_CONFIGURATION_FILE| If RUN_DATA_CONFIGURATION = TRUE, set this variable with the location of the file containing the initial data configuration of currencies to be enable, monetary zones and vdfsp. More instructions about the process and the file schema specification in initial_data_configuration.md |DFSP_ID_PATTERN| If RUN_DATA_CONFIGURATION = TRUE, set this variable with a regular expression pattern for valid VDFSP names. Examples: if DFSP_ID_PATTERN=^DFSPA-Z{3}$ then DFSPEUR is valid. If DFSP_ID_PATTERN=^DFSP-A-Z{3}$, then DFSP-EUR is valid. Warning: If using docker compose, see (https://docs.docker.com/compose/compose-file/#variable-substitution) |CURRENCY_CODES| Contains the information of ISO 4217 Currency Codes | Email configuration |SMTP_HOST| Smtp server to send email |SMTP_PORT| Smtp port to send email |MAIL_SENDER_USER|Email user account used to send email notifications |MAIL_SENDER_PASS| Password for the MAIL_SENDER_USER account | Transfer configuration |MAIL_RECEIVER_USER_TRANSFER|Email user that will receive the notification |TRANSFER_B_SENT_WAIT_MILLISECONDS| Time in milliseconds to wait before calling the hub to get the new status of the transfer B sent, |TRANSFER_B_IDLE_WAIT_MILLISECONDS| Time in milliseconds to wait before calling the hub to get the new status of the transfer B idle, |TRANSFER_B_IDLE_MAX_RETRIES| Maximum number of retries for getting the transfer B status

Running a local dev instance

While developing we'd like to run the FXP SDK and the FXP server not in a container, but locally or even with a debugger attached from VSCode. We need to run a local redis instance, and the two node processes. In the following example we have a directory where we have cloned both https://github.com/modusintegration/mojaloop-fxp and https://github.com/modusintegration/mojaloop-fxp-scheme-adapter repos under the same directory.

Redis

This command runs a redis instance and exports its port

cd mojaloop-fxp/docker
./run-redis.sh

FXP SDK

The Mojaloop FXP Scheme Adapter uses https://www.npmjs.com/package/dotenv to load the env variables so there are several options to configure the environment, as explained on the package's web page. The easiest way is to copy the base file src/local.env to .env and edit as needed.

cd mojaloop-fxp-scheme-adapter
# Run on first run only
npm start
#  or run this last one via vscode debugger