From b52f9d699cb8700530ea82c74d6ea82b5100fd29 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Tue, 24 Oct 2023 17:46:32 +0530 Subject: [PATCH 1/3] v0.4.17 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0bb7d66..e594f37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@autonolas/frontend-library", - "version": "0.4.16", + "version": "0.4.17", "description": "Codebase to common style, components, settings, etc.", "main": "dist/index.js", "types": "dist/index.d.ts", From 98e756fcdd6b8662d579df62a6db7b8790011eac Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Tue, 24 Oct 2023 19:00:49 +0530 Subject: [PATCH 2/3] update functions --- HISTORY.md | 4 ++ SECURITY.md | 2 +- src/components/product/components.tsx | 16 +++++++ src/components/product/index.ts | 1 + .../prohibitedCountriesAndAddresses/index.tsx | 42 +++---------------- .../prohibitedCountriesAndAddresses.ts | 23 ++++++++++ 6 files changed, 50 insertions(+), 38 deletions(-) create mode 100644 src/components/product/components.tsx create mode 100644 src/functions/prohibitedCountriesAndAddresses/prohibitedCountriesAndAddresses.ts diff --git a/HISTORY.md b/HISTORY.md index 5768988..8adc2fc 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -148,3 +148,7 @@ ## 0.4.16 - Functions to prohibit user from prohibited countries & addresses + +## 0.4.17 +- Update the functions to prohibit user from prohibited countries & addresses +- Export the JSON files for prohibited countries & addresses diff --git a/SECURITY.md b/SECURITY.md index e766322..3a795f6 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -8,7 +8,7 @@ The following table shows which versions of `autonolas-frontend-library` are cur | Version | Supported | | --------- | ------------------ | -| `0.4.16` | :white_check_mark: | +| `0.4.17` | :white_check_mark: | ## Reporting a Vulnerability diff --git a/src/components/product/components.tsx b/src/components/product/components.tsx new file mode 100644 index 0000000..ec34fa9 --- /dev/null +++ b/src/components/product/components.tsx @@ -0,0 +1,16 @@ +// list of tiny reusable components + +import React from 'react'; + +export const CannotConnectAddressOfacError = () => ( + <> + Cannot connect – address is on  + + OFAC SDN list + + +); diff --git a/src/components/product/index.ts b/src/components/product/index.ts index b2d87cb..ce0e02e 100644 --- a/src/components/product/index.ts +++ b/src/components/product/index.ts @@ -4,3 +4,4 @@ export * from './Footer'; export * from './ServiceStatusInfo'; export * from './Loader'; export * from './GlobalStyles'; +export * from './components'; \ No newline at end of file diff --git a/src/functions/prohibitedCountriesAndAddresses/index.tsx b/src/functions/prohibitedCountriesAndAddresses/index.tsx index 406ec5f..9a50f15 100644 --- a/src/functions/prohibitedCountriesAndAddresses/index.tsx +++ b/src/functions/prohibitedCountriesAndAddresses/index.tsx @@ -1,40 +1,8 @@ -import React from 'react'; -import { toLower } from 'lodash'; import prohibitedAddresses from './prohibited-addresses.json'; import prohibitedCountries from './prohibited-countries.json'; -import { notifyError } from '../functions'; -/** - * Check if the address is prohibited - */ -export const isAddressProhibited = (address: string | null) => { - if (!address) return false; - - const addresses = prohibitedAddresses.map((e) => toLower(e)); - return addresses.includes(toLower(address)); -}; - -/** - * Check if the country is prohibited - */ -export const isCountryProhibited = (country: string | null) => { - if (!country) return false; - - const prohibitedCountriesCode = Object.values(prohibitedCountries); - return prohibitedCountriesCode.includes(country); -}; - -export const notifyProhibitedAddressError = () => { - return notifyError( - <> - Cannot connect – address is on  - - OFAC SDN list - - , - ); -}; +export { + isAddressProhibited, + isCountryProhibited, +} from './prohibitedCountriesAndAddresses'; +export { prohibitedAddresses, prohibitedCountries }; diff --git a/src/functions/prohibitedCountriesAndAddresses/prohibitedCountriesAndAddresses.ts b/src/functions/prohibitedCountriesAndAddresses/prohibitedCountriesAndAddresses.ts new file mode 100644 index 0000000..13d8598 --- /dev/null +++ b/src/functions/prohibitedCountriesAndAddresses/prohibitedCountriesAndAddresses.ts @@ -0,0 +1,23 @@ +import { toLower } from 'lodash'; +import prohibitedAddresses from './prohibited-addresses.json'; +import prohibitedCountries from './prohibited-countries.json'; + +/** + * Check if the address is prohibited + */ +export const isAddressProhibited = (address: string | null) => { + if (!address) return false; + + const addresses = prohibitedAddresses.map((e) => toLower(e)); + return addresses.includes(toLower(address)); +}; + +/** + * Check if the country is prohibited + */ +export const isCountryProhibited = (country: string | null) => { + if (!country) return false; + + const prohibitedCountriesCode = Object.values(prohibitedCountries); + return prohibitedCountriesCode.includes(country); +}; From 83ced5c9f305872248ffba332ac1d388c0607fd2 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Tue, 24 Oct 2023 19:02:07 +0530 Subject: [PATCH 3/3] tiny --- src/components/product/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/product/index.ts b/src/components/product/index.ts index ce0e02e..9f2500c 100644 --- a/src/components/product/index.ts +++ b/src/components/product/index.ts @@ -4,4 +4,4 @@ export * from './Footer'; export * from './ServiceStatusInfo'; export * from './Loader'; export * from './GlobalStyles'; -export * from './components'; \ No newline at end of file +export * from './components';