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/merge mowali branch #1

Merged
merged 193 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
902319b
Issue934-FixSetEnvVarRCAsBooleanInsteadOfString (#81)
gibaros Nov 8, 2019
79d8126
bugfix/1066 Remove Put Accept Header (#86)
ggrg Nov 19, 2019
3fcd9c7
More unit tests and some code cleanup (#87)
Nov 20, 2019
6241ba5
Bump npm-check-updates from 3.2.1 to 3.2.2 (#88)
dependabot-preview[bot] Nov 25, 2019
f2f17a5
Bump eslint from 6.6.0 to 6.7.1 (#89)
dependabot-preview[bot] Nov 25, 2019
a8c21c9
bugfix/1079 Extensions Longer Than 128 Chars (#90)
ggrg Nov 27, 2019
8025f5f
Dissasociated unit tests from the actual contents of file `config/rul…
Nov 29, 2019
8261ee3
bugfix/1085 Quote to Inactive Fsp (#91)
ggrg Dec 2, 2019
3b04304
mowdev-3411
Dec 5, 2019
b36efd3
added more rules
Dec 5, 2019
c2b9016
Feature/846 async logging (#100)
lewisdaly Dec 5, 2019
50564a1
Feature/update json rules engine (#101)
partiallyordered Dec 5, 2019
ada4adb
Feature/test fx rules (#102)
partiallyordered Dec 5, 2019
6567058
Feature/846 async logging (#100)
lewisdaly Dec 5, 2019
03fc69d
Feature/update json rules engine (#101)
partiallyordered Dec 5, 2019
78bdc53
Feature/test fx rules (#102)
partiallyordered Dec 5, 2019
71dff00
added more rules and tests
Dec 6, 2019
7a5cb58
test discard
Dec 6, 2019
6b058cc
test discard
Dec 6, 2019
1dd36cb
test discard
Dec 6, 2019
7af1891
updated dependencies (#105)
vgenev Dec 11, 2019
28549b8
stripe off accept header for PUT requests
Dec 12, 2019
621ff7c
added package-lock.json
Dec 12, 2019
61c4dd0
Merge branch 'master' into feature/mowdev-3411
shashi165 Dec 12, 2019
8c1a145
Feature/1003 add container scans (#103)
lewisdaly Dec 12, 2019
396a996
Feature/1047 improve test coverage (#108)
lewisdaly Dec 17, 2019
e27d8dc
added more rules
Dec 18, 2019
72e1dac
Merge remote-tracking branch 'origin/feature/mowdev-3411' into featur…
Dec 18, 2019
da91411
fixed the package.json version
Dec 19, 2019
b6b3890
fixed version number
Dec 19, 2019
4e4db82
fixed the Object.assign
Dec 19, 2019
578f61a
removed rules.json
Dec 19, 2019
026bbf5
update package-lock.json
Dec 19, 2019
200d721
Merge branch 'master' into feature/mowdev-3411
shashi165 Dec 19, 2019
3a87289
Attempt cache refresh
KamuelaFranco Jan 6, 2020
cbb418f
Replace audit:check with audit
KamuelaFranco Jan 6, 2020
2c5d6f6
Debug with verbose audit
KamuelaFranco Jan 6, 2020
1be3256
Skip vulnerability check because of network errors
KamuelaFranco Jan 6, 2020
736f5b3
Skip vuln check step
KamuelaFranco Jan 6, 2020
693f3ae
downgrade helm version
Jan 6, 2020
19f7359
#1147 - Update dependencies (#118)
oderayi Jan 7, 2020
58a285b
temp logging
Jan 8, 2020
99ceeb5
renamed switchEndpoint to a better name
Jan 8, 2020
745d45f
removed config from dockerfile
shashi165 Jan 9, 2020
4d8730d
Fix for #1169 - GET /quotes for malformed ID error response is 1001 i…
oderayi Jan 15, 2020
f6e8f6c
Added synchronous responses for rules engine invalid quote errors (#127)
partiallyordered Jan 16, 2020
53f4907
added error code
shashi165 Jan 16, 2020
06eaf8c
added swagger changes
shashi165 Jan 16, 2020
cbf535f
Bugfix/1172empty quote values (#128)
ndonnan Jan 17, 2020
55504e6
Upgrading version to v8.8.0-snapshot (#129)
Jan 17, 2020
b78a016
Feature/1157 anchore report summary (#132)
lewisdaly Jan 20, 2020
856a215
Update dependencies (#133)
oderayi Jan 22, 2020
5f1dc1b
added error handling when there are no active accounts
shashi165 Jan 22, 2020
b1f7e1c
added error handling when there are no active accounts
shashi165 Jan 22, 2020
85f748d
added error handling when there are no active accounts
shashi165 Jan 22, 2020
5cb6955
893-UpdateRegexToValidateIncomingErrorCodeAtEndpointCallbackAndUpdate…
gibaros Jan 24, 2020
b0e3047
fixed error responses sync and async
shashi165 Jan 24, 2020
9767ad7
fixed the rounting problem with forex quotes
shashi165 Jan 26, 2020
1d814b3
fixed the rounting problem with forex quotes
shashi165 Jan 26, 2020
ec8ce82
fixed the rounting problem with forex quotes
shashi165 Jan 26, 2020
c876ec3
removed fspiop-uri header
shashi165 Jan 27, 2020
24b82fb
removed fspiop-signature header
shashi165 Jan 27, 2020
6ff4541
added one more error code to sync errors
shashi165 Jan 27, 2020
9641b2f
added more error handling
shashi165 Jan 29, 2020
a3131ad
Merged from master
partiallyordered Feb 10, 2020
a93c8b9
Fix for #1173 - GET /quotes for unknown quote ID error response is 10…
oderayi Feb 10, 2020
148a14d
Upgrade to Node 12.16.0 LTS version (#150)
oderayi Feb 17, 2020
7a8bbda
Added updated Mojaloop license (#151)
lewisdaly Feb 19, 2020
1fda789
Added updated Mojaloop license (#152)
lewisdaly Feb 19, 2020
e156cab
Hotfix: Fix startup failure error (#153)
oderayi Feb 20, 2020
e8b6d7c
Fix/1107 circleci deploy (#154)
lewisdaly Feb 25, 2020
92d2d2a
Fixed /quote/\{id\}/error destination (#156)
partiallyordered Mar 2, 2020
63b2757
Updated package version (#157)
partiallyordered Mar 2, 2020
ab806e0
Merged from master
partiallyordered Mar 2, 2020
99a2226
Updated package version
partiallyordered Mar 2, 2020
28d90b0
Updated dependencies (#158)
rmothilal Mar 2, 2020
3f47b36
Feature/updating dependencies (#159)
rmothilal Mar 3, 2020
202a5e2
#1178: Bug fixes for POST /quotes with unknown destination FSP (#160)
oderayi Mar 3, 2020
304bf1a
Hotfix: Revert #1178 changes (#161)
oderayi Mar 5, 2020
1859796
Bugfix/restore handle quote error headers (#168)
Mar 17, 2020
50858fe
Do not modify headers in case they are only being relayed to another …
Mar 18, 2020
76e654a
Do not delete `FSPIOP-Signature` header unless if `modifyHeaders` is …
Mar 18, 2020
9667b52
Store extensionLists for quote requests and responses. (#184)
bushjames Apr 9, 2020
4f21650
Feature/otc 218 enhance post quote partyIdInfo with extension list (#…
lazolalucas Apr 9, 2020
eb99692
Add custom mojaloop policy for evaluating anchore-cli scans (#192)
lewisdaly Apr 16, 2020
52a60f7
Update dependencies (#200)
oderayi Apr 30, 2020
b96cd31
Hotfix for docker image to support async logging (#202)
mdebarros May 6, 2020
c9cde80
Merged `master` into this branch.
May 11, 2020
ffe191a
added JWS support for switch generated msg (#203)
shashi165 May 19, 2020
de7996b
merge master
May 19, 2020
464b4da
fixed the bug with createQuoteExtensions
May 20, 2020
e25fe98
Fixed the arguments passed to `createQuoteExtensions`. (#213)
May 21, 2020
5a49911
fixed issue with createQuoteExtension
May 21, 2020
1e1cd38
Fixed issue with `createQuoteExtension` (#214)
May 22, 2020
8c735ae
Revert change of the error message as it breaks tests.
May 22, 2020
a544b1a
Updated versions for error-handler, etc... (#218)
aenns May 26, 2020
ea50235
Change CI/CD notifications to their own slack channel, bump package t…
lewisdaly May 27, 2020
79ca56f
Fix DB transaction leaks. Update unit tests (#220)
oderayi Jun 1, 2020
88a8c05
Feature/validation for name place accents (#221)
rmothilal Jun 15, 2020
64a519e
Updated python in Circle CI (#222)
rmothilal Jun 15, 2020
84bdcf0
Updated dependencies and version for issue: https://github.com/mojalo…
aenns Jun 17, 2020
05b7dfc
Aligned an error message with the master branch to match Postman test…
Jun 25, 2020
39121ef
Fixed some npm vulnerabilities and skipped the rest.
Jun 25, 2020
1261ad1
Updated circle CI config according to master branch.
Jun 25, 2020
2669bdd
Removed `quoteId` from error log message as it causes error due its e…
Jun 30, 2020
be43446
Removed `quoteId` from error log message as it causes error due its e…
Jun 30, 2020
4303335
fixed error message
Jun 30, 2020
c62a229
Bugfix/1385 fix post quotes header (#225)
rmothilal Jun 30, 2020
294e090
fix error message (#226)
shashi165 Jun 30, 2020
c4945b0
Bugfix/fix participant lookup to use currency (#227)
rmothilal Jul 2, 2020
63b4a36
Bugfix/fix participant lookup to use currency (#228)
rmothilal Jul 2, 2020
5442493
Bugfix/fix participant lookup to use currency (#230)
rmothilal Jul 2, 2020
9b87b67
Bugfix/fix participant lookup to use currency (#231)
rmothilal Jul 2, 2020
55cc399
Feature/1468 support for bulk quotes post passthrough (#233)
rmothilal Jul 16, 2020
66f2a0b
#1484: Update FSPIOP API version (#235)
oderayi Aug 10, 2020
c9e8b7b
Add ISO test currencies (XTS, XXX) (#238)
bushjames Aug 27, 2020
78179bf
added test currencies
shashi165 Aug 28, 2020
b10cfdb
resolve audit issues
shashi165 Aug 28, 2020
c7a99bf
fix audit issues
shashi165 Aug 28, 2020
d4685b0
fix audit issues
shashi165 Aug 28, 2020
4db9a82
Convert handlers to async, update deps, and bump version (#239)
oderayi Sep 8, 2020
7021d02
Feature/#1615 content headers (#240)
vgenev Sep 9, 2020
5c4a6db
fixed resource api version to be changed only if message originates f…
vgenev Sep 21, 2020
81eaf70
updated dependencies and removed old audit records (#243)
rmothilal Oct 2, 2020
8bbf5d2
Updated to cater for spans finishing early (#244)
rmothilal Oct 6, 2020
9ac9910
fixes (#245)
rmothilal Oct 6, 2020
d37de6b
#1456: Feature/docker config fixes (#247)
oderayi Nov 18, 2020
0ffc8ed
validate dfsps in payload for simple routing mode (#248)
shashi165 Nov 19, 2020
55b1fd4
#1875: Replace wildcard routes with explicit routes. (#249)
oderayi Nov 27, 2020
ef6da1e
chore: update license file (#251)
lewisdaly Dec 9, 2020
0bbf228
#1885: Add API documentation library (#250)
oderayi Dec 9, 2020
3444c2a
[Security] Bump node-notifier from 8.0.0 to 8.0.1 (#252)
dependabot-preview[bot] Dec 29, 2020
e235f6a
[Security] Bump axios from 0.21.0 to 0.21.1 (#255)
dependabot-preview[bot] Jan 19, 2021
399a442
[Security] Bump urijs from 1.19.2 to 1.19.5 (#254)
dependabot-preview[bot] Jan 19, 2021
6d3f56c
feat(ci/cd): add pr title check (#256)
lewisdaly Feb 5, 2021
2b2ef17
chore: adding codeowners file (#257)
elnyry-sam-k Feb 9, 2021
52846d9
chore: maintenance upgrades, audit check resolve update (#258)
elnyry-sam-k Feb 9, 2021
8143b30
fix(headers)!: made fspiop-destination header mandatory (#259)
shashi165 Feb 17, 2021
4fabb3a
[Security] Bump urijs from 1.19.5 to 1.19.6 (#260)
dependabot-preview[bot] Apr 7, 2021
6ad7250
fix(security): Bump y18n from 3.2.1 to 3.2.2 (#261)
dependabot-preview[bot] Apr 13, 2021
45792af
fix(security): Bump djv from 2.1.2 to 2.1.4 (#263)
dependabot[bot] May 3, 2021
d0fc967
fix: #2103 fix subid functionality in POST quotes request (#264)
vijayg10 May 4, 2021
b435764
feat(#2119): fixes for updated for AJV error objects change (#265)
mdebarros May 6, 2021
157493f
fix(#2182): regex validations against swagger interface spec no longe…
mdebarros May 12, 2021
12ecdb6
fix: helm release v12.1.0 (#269)
mdebarros Jun 1, 2021
b6c4ca9
[Security] Bump hosted-git-info from 2.8.8 to 2.8.9 (#266)
dependabot-preview[bot] Jun 2, 2021
b86b3ed
chore: helm release v12.1.0 (#270)
mdebarros Jun 2, 2021
c96fb58
fix(mojaloop/project#2246): updated dependency version (#272)
JohannWNel Jun 11, 2021
65075f1
fix(#2358): firstname, middlename and lastname regex not supporting m…
mdebarros Aug 11, 2021
0bf7cad
chore(#864): change instanbul to nyc for coverage on all projects (#279)
mdebarros Aug 19, 2021
b0c2cdc
fix(mojaloop/#2439): quoting-service-model.validatequoterequest-doesn…
mdebarros Sep 1, 2021
9ee10d7
fix: updated circleci config to use the SHA1 hash of the last commit …
mdebarros Sep 1, 2021
0cdf026
chore(release): 12.0.8 [skip ci]
Sep 1, 2021
3e6ac84
fix: circleci slack webhook typo fix (#282)
mdebarros Sep 1, 2021
44908b1
chore(release): 12.0.9 [skip ci]
Sep 1, 2021
3f1ad76
chore: updated readme with automated-releases, potential-problems and…
mdebarros Sep 1, 2021
0255b2f
chore(release): 12.0.10 [skip ci]
Sep 1, 2021
94191ac
WIP
shashi165 Sep 28, 2021
ee4f419
WIP
shashi165 Sep 28, 2021
dcdafd1
WIP
shashi165 Sep 28, 2021
520646e
WIP
shashi165 Sep 28, 2021
a622f8f
WIP
shashi165 Sep 28, 2021
df6d07e
WIP
shashi165 Sep 28, 2021
688f8c6
WIP
shashi165 Sep 28, 2021
3d30128
WIP
shashi165 Sep 28, 2021
6341d1e
WIP
shashi165 Sep 28, 2021
555b294
WIP
shashi165 Sep 29, 2021
f710217
WIP
shashi165 Sep 29, 2021
41932a1
WIP
shashi165 Sep 29, 2021
a481ee1
WIP
shashi165 Sep 29, 2021
57f6ef3
WIP
shashi165 Sep 29, 2021
8577e2d
WIP
shashi165 Sep 29, 2021
2740e7e
WIP
shashi165 Sep 29, 2021
0d0941b
WIP
shashi165 Sep 29, 2021
3d97c09
WIP
shashi165 Sep 29, 2021
13d1aba
WIP
shashi165 Sep 29, 2021
e8e70b4
WIP
shashi165 Sep 29, 2021
6cdc5b4
Fixed the tests
shashi165 Sep 30, 2021
fcec97c
changed the way we add headers
shashi165 Oct 1, 2021
50ad88d
refactoring
shashi165 Oct 1, 2021
132d458
refactoring
shashi165 Oct 1, 2021
26af659
removed the hardcoded headers
shashi165 Oct 4, 2021
4443563
removed the hardcoded headers
shashi165 Oct 4, 2021
690d727
updated README
shashi165 Oct 4, 2021
f957580
fixed swagger
shashi165 Oct 5, 2021
cc42204
revert sync changes
shashi165 Oct 11, 2021
7d5d13d
revert sync changes
shashi165 Oct 11, 2021
dacc612
revert sync changes
shashi165 Oct 11, 2021
d6f7786
revert sync changes
shashi165 Oct 11, 2021
b5bcb32
revert sync changes
shashi165 Oct 11, 2021
049a4b9
revert sync changes
shashi165 Oct 13, 2021
171a454
revert sync changes
shashi165 Oct 13, 2021
6b157b9
Merge branch 'master' into feat/merge-mowali-branch
shashi165 Oct 13, 2021
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
569 changes: 266 additions & 303 deletions .circleci/config.yml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ typings/

# MacOs
.[Dd][Ss]_[Ss]tore
.notes.md

# https://devspace.sh/
devspace*
.devspace/**.*
5 changes: 5 additions & 0 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"reject": [
"json-rules-engine"
]
}
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

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.

### [12.0.10](https://github.com/mojaloop/quoting-service/compare/v12.0.9...v12.0.10) (2021-09-01)

### [12.0.9](https://github.com/mojaloop/quoting-service/compare/v12.0.8...v12.0.9) (2021-09-01)


### Bug Fixes

* circleci slack webhook typo fix ([#282](https://github.com/mojaloop/quoting-service/issues/282)) ([3e6ac84](https://github.com/mojaloop/quoting-service/commit/3e6ac841727ffc5c133fee35387e4781c8253779))

### [12.0.8](https://github.com/mojaloop/quoting-service/compare/v12.0.7...v12.0.8) (2021-09-01)


### Bug Fixes

* **mojaloop/#2439:** quoting-service-model.validatequoterequest-doesnt-perform-correct-validation ([#280](https://github.com/mojaloop/quoting-service/issues/280)) ([b0c2cdc](https://github.com/mojaloop/quoting-service/commit/b0c2cdc42422ecf604a58d48e9e5e9c2402d4341)), closes [mojaloop/#2439](https://github.com/mojaloop/quoting-service/issues/2439) [mojaloop/#2439](https://github.com/mojaloop/quoting-service/issues/2439)
* updated circleci config to use the SHA1 hash of the last commit of the current build ([#281](https://github.com/mojaloop/quoting-service/issues/281)) ([9ee10d7](https://github.com/mojaloop/quoting-service/commit/9ee10d72b5941b973e15e97633835aa6d34d20eb))
38 changes: 38 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.

## These owners will be the default owners for everything in
## the repo. Unless a later match takes precedence,
## @global-owner1 and @global-owner2 will be requested for
## review when someone opens a pull request.
#* @global-owner1 @global-owner2
* @vgenev @mdebarros @elnyry-sam-k @lewisdaly @oderayi @shashi165 @vijayg10 @eoln @bushjames

## Order is important; the last matching pattern takes the most
## precedence. When someone opens a pull request that only
## modifies JS files, only @js-owner and not the global
## owner(s) will be requested for a review.
# *.js @js-owner

## You can also use email addresses if you prefer. They'll be
## used to look up users just like we do for commit author
## emails.
#*.go docs@example.com

# In this example, @doctocat owns any files in the build/logs
# directory at the root of the repository and any of its
# subdirectories.
# /build/logs/ @doctocat

## The `docs/*` pattern will match files like
## `docs/getting-started.md` but not further nested files like
## `docs/build-app/troubleshooting.md`.
# docs/* docs@example.com

## In this example, @octocat owns any file in an apps directory
## anywhere in your repository.
#apps/ @octocat

## In this example, @doctocat owns any file in the `/docs`
## directory in the root of your repository.
#/docs/ @doctocat
21 changes: 19 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM node:10.15.3-alpine
FROM node:12.16.1-alpine as builder

WORKDIR /opt/quoting-service

RUN apk add --no-cache -t build-dependencies git make gcc g++ python libtool autoconf automake \
Expand All @@ -8,12 +9,28 @@ RUN apk add --no-cache -t build-dependencies git make gcc g++ python libtool aut

COPY package.json package-lock.json* /opt/quoting-service/

RUN npm install --production
RUN npm install

RUN apk del build-dependencies

COPY config /opt/quoting-service/config
COPY src /opt/quoting-service/src

FROM node:12.16.1-alpine

WORKDIR /opt/quoting-service

# Create empty log file & link stdout to the application log file
RUN mkdir ./logs && touch ./logs/combined.log
# Links combined to stdout
RUN ln -sf /dev/stdout ./logs/combined.log

# Create a non-root user: ml-user
RUN adduser -D ml-user
USER ml-user

COPY --chown=ml-user --from=builder /opt/quoting-service .
RUN npm prune --production

EXPOSE 3002
CMD ["npm", "run", "start"]
10 changes: 10 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# LICENSE

Copyright © 2020 Mojaloop Foundation

The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0
(the "License") and you may not use these files except in compliance with the [License](http://www.apache.org/licenses/LICENSE-2.0).

You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the [License](http://www.apache.org/licenses/LICENSE-2.0).
190 changes: 179 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,211 @@
# Quoting Service

[![Git Commit](https://img.shields.io/github/last-commit/mojaloop/quoting-service.svg?style=flat)](https://github.com/mojaloop/quoting-service/commits/master)
[![Git Releases](https://img.shields.io/github/release/mojaloop/quoting-service.svg?style=flat)](https://github.com/mojaloop/quoting-service/releases)
[![Docker pulls](https://img.shields.io/docker/pulls/mojaloop/quoting-service.svg?style=flat)](https://hub.docker.com/r/mojaloop/quoting-service)
[![CircleCI](https://circleci.com/gh/mojaloop/quoting-service.svg?style=svg)](https://circleci.com/gh/mojaloop/quoting-service)
[![CircleCI](https://circleci.com/gh/mojaloop/quoting-service.svg?style=svg)](https://app.circleci.com/pipelines/github/mojaloop/quoting-service)

The Quoting Service was donated by the Mowali project working in collaboration with Orange and MTN. The original author of this service is James Bush (james.bush@modusbox.com).

The Quoting Service was donated by the Mowali project working in collaboration with Orange and MTN.
The Quoting service is now part of the Mojaloop project and deployment.

The service provided by the API resource /quotes is calculation of possible fees and FSP commission involved in performing an interoperable financial transaction.
The service provided by the API resource /quotes is calculation of possible fees and FSP commission involved in performing an interoperable financial transaction.
Both the Payer and Payee FSP should calculate their part of the quote to be able to get a total view of all the fees and FSP commission involved in the transaction.

### Contents:
## Contents

- [Services Sequence overview](#services-sequence-overview)
- [Local Deployment](#local-deployment)
- [Quoting Service](#quoting-service)
- [Contents](#contents)
- [Services Sequence overview](#services-sequence-overview)
- [Running Locally](#running-locally)
- [Auditing Dependencies](#auditing-dependencies)
- [Container Scans](#container-scans)
- [Automated Releases](#automated-releases)
- [Potential problems](#potential-problems)
- [Additional Notes](#additional-notes)

## Services Sequence overview

![Quoting Service Sequence diagram](diagrams/quotingServiceSequences.svg)

* [Quoting Service Sequence diagram](diagrams/quotingServiceSequences.puml)
> [Quoting Service Sequence diagram](diagrams/quotingServiceSequences.puml)

## Local Deployment
## Running Locally

Please follow the instruction in [Onboarding Document](onboarding.md) to setup and run the service locally.

## Auditing Dependencies

We use `npm-audit-resolver` along with `npm audit` to check dependencies for vulnerabilities, and keep track of resolved dependencies with an `audit-resolv.json` file.
We use `npm-audit-resolver` along with `npm audit` to check dependencies for node vulnerabilities, and keep track of resolved dependencies with an `audit-resolve.json` file.

To start a new resolution process, run:

```bash
npm run audit:resolve
```

You can then check to see if the CI will pass based on the current dependencies with:

```bash
npm run audit:check
```

And commit the changed `audit-resolv.json` to ensure that CircleCI will build correctly.
test
And commit the changed `audit-resolve.json` to ensure that CircleCI will build correctly.

## Container Scans

As part of our CI/CD process, we use anchore-cli to scan our built docker container for vulnerabilities upon release.

If you find your release builds are failing, refer to the [container scanning](https://github.com/mojaloop/ci-config#container-scanning) in our shared Mojaloop CI config repo. There is a good chance you simply need to update the `mojaloop-policy-generator.js` file and re-run the circleci workflow.

For more information on anchore and anchore-cli, refer to:

- [Anchore CLI](https://github.com/anchore/anchore-cli)
- [Circle Orb Registry](https://circleci.com/orbs/registry/orb/anchore/anchore-engine)

## Automated Releases

As part of our CI/CD process, we use a combination of CircleCI, standard-version
npm package and github-release CircleCI orb to automatically trigger our releases
and image builds. This process essentially mimics a manual tag and release.

On a merge to master, CircleCI is configured to use the mojaloopci github account
to push the latest generated CHANGELOG and package version number.

Once those changes are pushed, CircleCI will pull the updated master, tag and
push a release triggering another subsequent build that also publishes a docker image.

### Potential problems

- There is a case where the merge to master workflow will resolve successfully, triggering
a release. Then that tagged release workflow subsequently failing due to the image scan,
audit check, vulnerability check or other "live" checks.

This will leave master without an associated published build. Fixes that require
a new merge will essentially cause a skip in version number or require a clean up
of the master branch to the commit before the CHANGELOG and bump.

This may be resolved by relying solely on the previous checks of the
merge to master workflow to assume that our tagged release is of sound quality.
We are still mulling over this solution since catching bugs/vulnerabilities/etc earlier
is a boon.

- It is unknown if a race condition might occur with multiple merges with master in
quick succession, but this is a suspected edge case.


## How to use quoting-service JSON rules
### About rules.json
The rules.json file acts as a rules engine and enables you to define arbitrary rules that will accept or reject quotes. A rule is defined as an object with a title, a conditions object, and an event object. A rule specifies that if certain conditions are met, then the specified event will be generated.

The rules engine used by the quoting-service is an off-the-shelf rules engine, called json-rules-engine. For detailed information on how to write rules, see the [json-rules-engine documentation](https://github.com/CacheControl/json-rules-engine/blob/master/docs/rules.md). This page only focuses on those details that are relevant for adding support for new currencies.

### Conditions
Conditions are a combination of facts, paths, operators, and values.

Each rule's conditions must have either an all or an any operator at its root, containing an array of conditions. The all operator specifies that all conditions must be met for the rule to be applied. The any operator only requires one condition to be met for the rule to be applied.

Operators within the individual conditions can take the following values:

- `equal:` fact must equal value (string or numeric value)
- `notEqual:` fact must not equal value (string or numeric value)
- `in:` fact must be included in value (an array)
- `notIn:` fact must not be included in value (an array)
- `contains:` fact (an array) must include value
- `doesNotContain:` fact (an array) must not include value

### Events
Event objects must have a type property, and an optional params property. There are two types of events:

- `INTERCEPT_QUOTE`: Used for redirecting quote requests.
- `INVALID_QUOTE_REQUEST`: Used for validation rules. You do not have to use this type of event when adding support for new currencies.

### Configuration – an example
```
[
{
"title": "This is UGX -> ZMW transfer rule",
"conditions": {
"all": [
{
"fact": "headers",
"path": "$.fspiop-source",
"operator": "notIn",
"value":[
"DFSPUGX",
"DFSPZMW"
]
},
{
"fact": "payer",
"path": "$.accounts[?(@.ledgerAccountType == 'POSITION' && @.isActive == 1)].currency",
"operator": "equal",
"value": "UGX"
},
{
"fact": "payee",
"path": "$.accounts[?(@.ledgerAccountType == 'POSITION' && @.isActive == 1)].currency",
"operator": "equal",
"value": "ZMW"
}
]
},
"event":{
"type": "INTERCEPT_QUOTE",
"params":{
"rerouteToFsp": "DFSPUGX",
"additionalHeaders": {
"x-fspiop-sourcecurrency": "UGX",
"x-fspiop-destinationcurrency": "ZMW"
}
}
}
},
{
"title": "Payee fsp should have only one active account",
"conditions": {
"all": [
{
"any": [
{
"fact": "payload",
"path": "$.amount.currency",
"operator": "notIn",
"value": {
"fact": "payer",
"path": "$.accounts[?(@.ledgerAccountType == \"POSITION\" && @.isActive == 1)].currency"
}
},
{
"fact": "payload",
"path": "$.amount.currency",
"operator": "notIn",
"value": {
"fact": "payee",
"path": "$.accounts[?(@.ledgerAccountType == \"POSITION\" && @.isActive == 1)].currency"
}
}
]
},
{
"fact": "payee",
"path": "$.accounts[?(@.ledgerAccountType == \"POSITION\" && @.isActive == 1)]",
"operator": "isArray",
"value": true
}
]
},
"event": {
"type": "INVALID_QUOTE_REQUEST",
"params": {
"FSPIOPError": "PAYEE_ERROR",
"message": "Payee FSP has more than 1 active currency account. Switch does not support more than 1 active currency account for Forex Requests"
}
}
}
]

```
## Additional Notes

N/A
Loading