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

Fix bug in check for EU country set #444

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
4 changes: 4 additions & 0 deletions packages/browser-wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- A button in settings that opens the wallet in fullscreen mode in a tab.

### Fixed

- An issue where some proof requests for nationality or country of residence would be misintrepreted as asking whether in the EU or not.

## 1.4.2

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export type SecretStatement = Exclude<AtomicStatement, RevealStatement>;
export const getYearFromDateString = (ds: string): number => Number(ds.substring(0, 4));
const formatDateString = (ds: string): string => `${ds.substring(0, 4)}-${ds.substring(4, 6)}-${ds.substring(6)}`;

const isEuCountrySet = (countries: string[]) =>
countries.length === EU_MEMBERS.length && countries.every((n) => EU_MEMBERS.includes(n));
export const isEuCountrySet = (countries: string[]) =>
countries.length === EU_MEMBERS.length && EU_MEMBERS.every((euCountry) => countries.includes(euCountry));

const getTextForSet =
<T extends (...args: any) => any>(t: T, statement: MembershipStatement | NonMembershipStatement) =>
Expand Down
16 changes: 16 additions & 0 deletions packages/browser-wallet/test/id-proof-util.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { EU_MEMBERS } from '@concordium/web-sdk';
import { isEuCountrySet } from '../src/popup/pages/IdProofRequest/DisplayStatement/utils';

test('not eu country set if only one country in set', () => {
const countries = 'DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK,DK'.split(',');

const isEu = isEuCountrySet(countries);

expect(isEu).toBeFalsy();
});

test('eu country set returns true when checking if eu country set', () => {
const isEu = isEuCountrySet(EU_MEMBERS);

expect(isEu).toBeTruthy();
});
Loading