diff --git a/app/src/components/Disclosures.tsx b/app/src/components/Disclosures.tsx index 0d7c53a6c..c0d1e03b6 100644 --- a/app/src/components/Disclosures.tsx +++ b/app/src/components/Disclosures.tsx @@ -57,7 +57,7 @@ export default function Disclosures({ disclosures }: DisclosureProps) { break; case 'excludedCountries': text = `I am not a citizen of the following countries: ${countriesToSentence( - disclosures.excludedCountries || [], + disclosures.excludedCountries as Country3LetterCode[] || [], )}`; break; case 'minimumAge': diff --git a/common/src/constants/countries.ts b/common/src/constants/countries.ts new file mode 100644 index 000000000..c8bed6663 --- /dev/null +++ b/common/src/constants/countries.ts @@ -0,0 +1,516 @@ +export const commonNames = { + AFG: 'Afghanistan', + ALA: 'Aland Islands', + ALB: 'Albania', + DZA: 'Algeria', + ASM: 'American Samoa', + AND: 'Andorra', + AGO: 'Angola', + AIA: 'Anguilla', + ATA: 'Antarctica', + ATG: 'Antigua and Barbuda', + ARG: 'Argentina', + ARM: 'Armenia', + ABW: 'Aruba', + AUS: 'Australia', + AUT: 'Austria', + AZE: 'Azerbaijan', + BHS: 'Bahamas', + BHR: 'Bahrain', + BGD: 'Bangladesh', + BRB: 'Barbados', + BLR: 'Belarus', + BEL: 'Belgium', + BLZ: 'Belize', + BEN: 'Benin', + BMU: 'Bermuda', + BTN: 'Bhutan', + BOL: 'Bolivia', + BES: 'Bonaire, Sint Eustatius and Saba', + BIH: 'Bosnia and Herzegovina', + BWA: 'Botswana', + BVT: 'Bouvet Island', + BRA: 'Brazil', + IOT: 'British Indian Ocean Territory', + BRN: 'Brunei Darussalam', + BGR: 'Bulgaria', + BFA: 'Burkina Faso', + BDI: 'Burundi', + CPV: 'Cape Verde', + KHM: 'Cambodia', + CMR: 'Cameroon', + CAN: 'Canada', + CYM: 'Cayman Islands', + CAF: 'Central African Republic', + TCD: 'Chad', + CHL: 'Chile', + CHN: 'China', + CXR: 'Christmas Island', + CCK: 'Cocos Islands', + COL: 'Colombia', + COM: 'Comoros', + COG: 'Congo', + COD: 'Congo, Democratic Republic of the', + COK: 'Cook Islands', + CRI: 'Costa Rica', + CIV: 'Ivory Coast', + HRV: 'Croatia', + CUB: 'Cuba', + CUW: 'Curacao', + CYP: 'Cyprus', + CZE: 'Czechia', + DNK: 'Denmark', + DJI: 'Djibouti', + DMA: 'Dominica', + DOM: 'Dominican Republic', + ECU: 'Ecuador', + EGY: 'Egypt', + SLV: 'El Salvador', + GNQ: 'Equatorial Guinea', + ERI: 'Eritrea', + EST: 'Estonia', + SWZ: 'Eswatini', + ETH: 'Ethiopia', + FLK: 'Falkland Islands', + FRO: 'Faroe Islands', + FJI: 'Fiji', + FIN: 'Finland', + FRA: 'France', + GUF: 'French Guiana', + PYF: 'French Polynesia', + ATF: 'French Southern Territories', + GAB: 'Gabon', + GMB: 'Gambia', + GEO: 'Georgia', + DEU: 'Germany', + "D<<": 'Germany', // Bundesrepublik Deutschland uses this in passports instead of DEU + GHA: 'Ghana', + GIB: 'Gibraltar', + GRC: 'Greece', + GRL: 'Greenland', + GRD: 'Grenada', + GLP: 'Guadeloupe', + GUM: 'Guam', + GTM: 'Guatemala', + GGY: 'Guernsey', + GIN: 'Guinea', + GNB: 'Guinea-Bissau', + GUY: 'Guyana', + HTI: 'Haiti', + HMD: 'Heard Island and McDonald Islands', + VAT: 'Vatican City', + HND: 'Honduras', + HKG: 'Hong Kong', + HUN: 'Hungary', + ISL: 'Iceland', + IND: 'India', + IDN: 'Indonesia', + IRN: 'Iran', + IRQ: 'Iraq', + IRL: 'Ireland', + IMN: 'Isle of Man', + ISR: 'Israel', + ITA: 'Italy', + JAM: 'Jamaica', + JPN: 'Japan', + JEY: 'Jersey', + JOR: 'Jordan', + KAZ: 'Kazakhstan', + KEN: 'Kenya', + KIR: 'Kiribati', + PRK: 'North Korea', + KOR: 'South Korea', + KWT: 'Kuwait', + KGZ: 'Kyrgyzstan', + LAO: 'Laos', + LVA: 'Latvia', + LBN: 'Lebanon', + LSO: 'Lesotho', + LBR: 'Liberia', + LBY: 'Libya', + LIE: 'Liechtenstein', + LTU: 'Lithuania', + LUX: 'Luxembourg', + MAC: 'Macao', + MDG: 'Madagascar', + MWI: 'Malawi', + MYS: 'Malaysia', + MDV: 'Maldives', + MLI: 'Mali', + MLT: 'Malta', + MHL: 'Marshall Islands', + MTQ: 'Martinique', + MRT: 'Mauritania', + MUS: 'Mauritius', + MYT: 'Mayotte', + MEX: 'Mexico', + FSM: 'Micronesia', + MDA: 'Moldova', + MCO: 'Monaco', + MNG: 'Mongolia', + MNE: 'Montenegro', + MSR: 'Montserrat', + MAR: 'Morocco', + MOZ: 'Mozambique', + MMR: 'Myanmar', + NAM: 'Namibia', + NRU: 'Nauru', + NPL: 'Nepal', + NLD: 'Netherlands', + NCL: 'New Caledonia', + NZL: 'New Zealand', + NIC: 'Nicaragua', + NER: 'Niger', + NGA: 'Nigeria', + NIU: 'Niue', + NFK: 'Norfolk Island', + MKD: 'North Macedonia', + MNP: 'Northern Mariana Islands', + NOR: 'Norway', + OMN: 'Oman', + PAK: 'Pakistan', + PLW: 'Palau', + PSE: 'Palestine, State of', + PAN: 'Panama', + PNG: 'Papua New Guinea', + PRY: 'Paraguay', + PER: 'Peru', + PHL: 'Philippines', + PCN: 'Pitcairn', + POL: 'Poland', + PRT: 'Portugal', + PRI: 'Puerto Rico', + QAT: 'Qatar', + REU: 'Reunion', + ROU: 'Romania', + RUS: 'Russian Federation', + RWA: 'Rwanda', + BLM: 'Saint Barthelemy', + SHN: 'Saint Helena, Ascension and Tristan da Cunha', + KNA: 'Saint Kitts and Nevis', + LCA: 'Saint Lucia', + MAF: 'Saint Martin (French part)', + SPM: 'Saint Pierre and Miquelon', + VCT: 'Saint Vincent and the Grenadines', + WSM: 'Samoa', + SMR: 'San Marino', + STP: 'Sao Tome and Principe', + SAU: 'Saudi Arabia', + SEN: 'Senegal', + SRB: 'Serbia', + SYC: 'Seychelles', + SLE: 'Sierra Leone', + SGP: 'Singapore', + SXM: 'Sint Maarten (Dutch part)', + SVK: 'Slovakia', + SVN: 'Slovenia', + SLB: 'Solomon Islands', + SOM: 'Somalia', + ZAF: 'South Africa', + SGS: 'South Georgia and the South Sandwich Islands', + SSD: 'South Sudan', + ESP: 'Spain', + LKA: 'Sri Lanka', + SDN: 'Sudan', + SUR: 'Suriname', + SJM: 'Svalbard and Jan Mayen', + SWE: 'Sweden', + CHE: 'Switzerland', + SYR: 'Syrian Arab Republic', + TWN: 'Taiwan, Province of China', + TJK: 'Tajikistan', + TZA: 'Tanzania, United Republic of', + THA: 'Thailand', + TLS: 'Timor-Leste', + TGO: 'Togo', + TKL: 'Tokelau', + TON: 'Tonga', + TTO: 'Trinidad and Tobago', + TUN: 'Tunisia', + TUR: 'Turkey', + TKM: 'Turkmenistan', + TCA: 'Turks and Caicos Islands', + TUV: 'Tuvalu', + UGA: 'Uganda', + UKR: 'Ukraine', + ARE: 'United Arab Emirates', + GBR: 'United Kingdom of Great Britain and Northern Ireland', + USA: 'United States of America', + UMI: 'United States Minor Outlying Islands', + URY: 'Uruguay', + UZB: 'Uzbekistan', + VUT: 'Vanuatu', + VEN: 'Venezuela (Bolivarian Republic of)', + VNM: 'Viet Nam', + VGB: 'Virgin Islands (British)', + VIR: 'Virgin Islands (U.S.)', + WLF: 'Wallis and Futuna', + ESH: 'Western Sahara', + YEM: 'Yemen', + ZMB: 'Zambia', + ZWE: 'Zimbabwe', + EUE: 'European Union', + UNO: 'United Nations', + XCE: 'Council of Europe', + XPO: 'International Criminal Police Organization', + XOM: 'Sovereign Military Order of Malta', +}; + +export const countries = { + AFGHANISTAN: 'AFG', + ALAND_ISLANDS: 'ALA', + ALBANIA: 'ALB', + ALGERIA: 'DZA', + AMERICAN_SAMOA: 'ASM', + ANDORRA: 'AND', + ANGOLA: 'AGO', + ANGUILLA: 'AIA', + ANTARCTICA: 'ATA', + ANTIGUA_AND_BARBUDA: 'ATG', + ARGENTINA: 'ARG', + ARMENIA: 'ARM', + ARUBA: 'ABW', + AUSTRALIA: 'AUS', + AUSTRIA: 'AUT', + AZERBAIJAN: 'AZE', + BAHAMAS: 'BHS', + BAHRAIN: 'BHR', + BANGLADESH: 'BGD', + BARBADOS: 'BRB', + BELARUS: 'BLR', + BELGIUM: 'BEL', + BELIZE: 'BLZ', + BENIN: 'BEN', + BERMUDA: 'BMU', + BHUTAN: 'BTN', + BOLIVIA: 'BOL', + BONAIRE_SINT_EUSTATIUS_AND_SABA: 'BES', + BOSNIA_AND_HERZEGOVINA: 'BIH', + BOTSWANA: 'BWA', + BOUVET_ISLAND: 'BVT', + BRAZIL: 'BRA', + BRITISH_INDIAN_OCEAN_TERRITORY: 'IOT', + BRUNEI: 'BRN', + BULGARIA: 'BGR', + BURKINA_FASO: 'BFA', + BURUNDI: 'BDI', + CAPE_VERDE: 'CPV', + CAMBODIA: 'KHM', + CAMEROON: 'CMR', + CANADA: 'CAN', + CAYMAN_ISLANDS: 'CYM', + CENTRAL_AFRICAN_REPUBLIC: 'CAF', + CHAD: 'TCD', + CHILE: 'CHL', + CHINA: 'CHN', + CHRISTMAS_ISLAND: 'CXR', + COCOS_ISLANDS: 'CCK', + COLOMBIA: 'COL', + COMOROS: 'COM', + CONGO: 'COG', + DR_CONGO: 'COD', + COOK_ISLANDS: 'COK', + COSTA_RICA: 'CRI', + IVORY_COAST: 'CIV', + CROATIA: 'HRV', + CUBA: 'CUB', + CURACAO: 'CUW', + CYPRUS: 'CYP', + CZECH_REPUBLIC: 'CZE', + DENMARK: 'DNK', + DJIBOUTI: 'DJI', + DOMINICA: 'DMA', + DOMINICAN_REPUBLIC: 'DOM', + ECUADOR: 'ECU', + EGYPT: 'EGY', + EL_SALVADOR: 'SLV', + EQUATORIAL_GUINEA: 'GNQ', + ERITREA: 'ERI', + ESTONIA: 'EST', + ESWATINI: 'SWZ', + ETHIOPIA: 'ETH', + FALKLAND_ISLANDS: 'FLK', + FAROE_ISLANDS: 'FRO', + FIJI: 'FJI', + FINLAND: 'FIN', + FRANCE: 'FRA', + FRENCH_GUIANA: 'GUF', + FRENCH_POLYNESIA: 'PYF', + FRENCH_SOUTHERN_TERRITORIES: 'ATF', + GABON: 'GAB', + GAMBIA: 'GMB', + GEORGIA: 'GEO', + GERMANY: 'D<<', + GHANA: 'GHA', + GIBRALTAR: 'GIB', + GREECE: 'GRC', + GREENLAND: 'GRL', + GRENADA: 'GRD', + GUADELOUPE: 'GLP', + GUAM: 'GUM', + GUATEMALA: 'GTM', + GUERNSEY: 'GGY', + GUINEA: 'GIN', + GUINEA_BISSAU: 'GNB', + GUYANA: 'GUY', + HAITI: 'HTI', + HEARD_ISLAND_AND_MCDONALD_ISLANDS: 'HMD', + VATICAN_CITY: 'VAT', + HONDURAS: 'HND', + HONG_KONG: 'HKG', + HUNGARY: 'HUN', + ICELAND: 'ISL', + INDIA: 'IND', + INDONESIA: 'IDN', + IRAN: 'IRN', + IRAQ: 'IRQ', + IRELAND: 'IRL', + ISLE_OF_MAN: 'IMN', + ISRAEL: 'ISR', + ITALY: 'ITA', + JAMAICA: 'JAM', + JAPAN: 'JPN', + JERSEY: 'JEY', + JORDAN: 'JOR', + KAZAKHSTAN: 'KAZ', + KENYA: 'KEN', + KIRIBATI: 'KIR', + NORTH_KOREA: 'PRK', + SOUTH_KOREA: 'KOR', + KUWAIT: 'KWT', + KYRGYZSTAN: 'KGZ', + LAOS: 'LAO', + LATVIA: 'LVA', + LEBANON: 'LBN', + LESOTHO: 'LSO', + LIBERIA: 'LBR', + LIBYA: 'LBY', + LIECHTENSTEIN: 'LIE', + LITHUANIA: 'LTU', + LUXEMBOURG: 'LUX', + MACAO: 'MAC', + MADAGASCAR: 'MDG', + MALAWI: 'MWI', + MALAYSIA: 'MYS', + MALDIVES: 'MDV', + MALI: 'MLI', + MALTA: 'MLT', + MARSHALL_ISLANDS: 'MHL', + MARTINIQUE: 'MTQ', + MAURITANIA: 'MRT', + MAURITIUS: 'MUS', + MAYOTTE: 'MYT', + MEXICO: 'MEX', + MICRONESIA: 'FSM', + MOLDOVA: 'MDA', + MONACO: 'MCO', + MONGOLIA: 'MNG', + MONTENEGRO: 'MNE', + MONTSERRAT: 'MSR', + MOROCCO: 'MAR', + MOZAMBIQUE: 'MOZ', + MYANMAR: 'MMR', + NAMIBIA: 'NAM', + NAURU: 'NRU', + NEPAL: 'NPL', + NETHERLANDS: 'NLD', + NEW_CALEDONIA: 'NCL', + NEW_ZEALAND: 'NZL', + NICARAGUA: 'NIC', + NIGER: 'NER', + NIGERIA: 'NGA', + NIUE: 'NIU', + NORFOLK_ISLAND: 'NFK', + NORTH_MACEDONIA: 'MKD', + NORTHERN_MARIANA_ISLANDS: 'MNP', + NORWAY: 'NOR', + OMAN: 'OMN', + PAKISTAN: 'PAK', + PALAU: 'PLW', + PALESTINE: 'PSE', + PANAMA: 'PAN', + PAPUA_NEW_GUINEA: 'PNG', + PARAGUAY: 'PRY', + PERU: 'PER', + PHILIPPINES: 'PHL', + PITCAIRN: 'PCN', + POLAND: 'POL', + PORTUGAL: 'PRT', + PUERTO_RICO: 'PRI', + QATAR: 'QAT', + REUNION: 'REU', + ROMANIA: 'ROU', + RUSSIA: 'RUS', + RWANDA: 'RWA', + SAINT_BARTHELEMY: 'BLM', + SAINT_HELENA_ASCENSION_AND_TRISTAN_DA_CUNHA: 'SHN', + SAINT_KITTS_AND_NEVIS: 'KNA', + SAINT_LUCIA: 'LCA', + SAINT_MARTIN: 'MAF', + SAINT_PIERRE_AND_MIQUELON: 'SPM', + SAINT_VINCENT_AND_THE_GRENADINES: 'VCT', + SAMOA: 'WSM', + SAN_MARINO: 'SMR', + SAO_TOME_AND_PRINCIPE: 'STP', + SAUDI_ARABIA: 'SAU', + SENEGAL: 'SEN', + SERBIA: 'SRB', + SEYCHELLES: 'SYC', + SIERRA_LEONE: 'SLE', + SINGAPORE: 'SGP', + SINT_MAARTEN: 'SXM', + SLOVAKIA: 'SVK', + SLOVENIA: 'SVN', + SOLOMON_ISLANDS: 'SLB', + SOMALIA: 'SOM', + SOUTH_AFRICA: 'ZAF', + SOUTH_GEORGIA_AND_THE_SOUTH_SANDWICH_ISLANDS: 'SGS', + SOUTH_SUDAN: 'SSD', + SPAIN: 'ESP', + SRI_LANKA: 'LKA', + SUDAN: 'SDN', + SURINAME: 'SUR', + SVALBARD_AND_JAN_MAYEN: 'SJM', + SWEDEN: 'SWE', + SWITZERLAND: 'CHE', + SYRIAN_ARAB_REPUBLIC: 'SYR', + TAIWAN: 'TWN', + TAJIKISTAN: 'TJK', + TANZANIA: 'TZA', + THAILAND: 'THA', + TIMOR_LESTE: 'TLS', + TOGO: 'TGO', + TOKELAU: 'TKL', + TONGA: 'TON', + TRINIDAD_AND_TOBAGO: 'TTO', + TUNISIA: 'TUN', + TURKEY: 'TUR', + TURKMENISTAN: 'TKM', + TURKS_AND_CAICOS_ISLANDS: 'TCA', + TUVALU: 'TUV', + UGANDA: 'UGA', + UKRAINE: 'UKR', + UNITED_ARAB_EMIRATES: 'ARE', + UNITED_KINGDOM: 'GBR', + UNITED_STATES: 'USA', + UNITED_STATES_MINOR_OUTLYING_ISLANDS: 'UMI', + URUGUAY: 'URY', + UZBEKISTAN: 'UZB', + VANUATU: 'VUT', + VENEZUELA: 'VEN', + VIET_NAM: 'VNM', + VIRGIN_ISLANDS_BRITISH: 'VGB', + VIRGIN_ISLANDS_US: 'VIR', + WALLIS_AND_FUTUNA: 'WLF', + WESTERN_SAHARA: 'ESH', + YEMEN: 'YEM', + ZAMBIA: 'ZMB', + ZIMBABWE: 'ZWE', + EUROPEAN_UNION: 'EUE', + UNITED_NATIONS: 'UNO', + COUNCIL_OF_EUROPE: 'XCE', + INTERPOL: "XPO", + SMOM: "XOM", +}; + +export type Country3LetterCode = typeof countries[keyof typeof countries]; diff --git a/common/src/utils/appType.ts b/common/src/utils/appType.ts index fc2171011..fc75f5afc 100644 --- a/common/src/utils/appType.ts +++ b/common/src/utils/appType.ts @@ -4,8 +4,8 @@ export type Mode = 'register' | 'dsc' | 'vc_and_disclose'; export type EndpointType = 'https' | 'celo' | 'staging_celo' | 'staging_https'; import { v4 } from 'uuid'; -import { Country3LetterCode, REDIRECT_URL } from "../constants/constants"; - +import { REDIRECT_URL } from "../constants/constants"; +import { Country3LetterCode } from "../constants/countries"; export interface SelfApp { appName: string; logoBase64: string; diff --git a/sdk/core/index.ts b/sdk/core/index.ts index 4eb29d8a5..2a44ed9b6 100644 --- a/sdk/core/index.ts +++ b/sdk/core/index.ts @@ -2,5 +2,5 @@ import { SelfBackendVerifier } from './src/SelfBackendVerifier'; import { getUserIdentifier } from './src/utils/utils'; import { countryCodes } from '../../common/src/constants/constants'; import { SelfApp, getUniversalLink } from '../../common/src/utils/appType'; - -export { SelfBackendVerifier, getUserIdentifier, countryCodes, SelfApp, getUniversalLink }; +import { countries } from '../../common/src/constants/countries'; +export { SelfBackendVerifier, getUserIdentifier, countryCodes, SelfApp, getUniversalLink, countries }; diff --git a/sdk/core/package.json b/sdk/core/package.json index c66a1cc07..2860749bc 100644 --- a/sdk/core/package.json +++ b/sdk/core/package.json @@ -1,6 +1,6 @@ { "name": "@selfxyz/core", - "version": "0.0.12", + "version": "0.0.13", "repository": { "type": "git", "url": "https://github.com/selfxyz/self" diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 6b17b229d..a9864a4d3 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -3,16 +3,11 @@ import { verifyAllAbi } from './abi/VerifyAll'; import { REGISTRY_ADDRESS, VERIFYALL_ADDRESS, REGISTRY_ADDRESS_STAGING, VERIFYALL_ADDRESS_STAGING } from './constants/contractAddresses'; import { ethers } from 'ethers'; import { PublicSignals } from 'snarkjs'; -import { - countryCodes, - getCountryCode, -} from '../../../common/src/constants/constants'; import type { SelfVerificationResult } from '../../../common/src/utils/selfAttestation'; import { castToScope, castToUserIdentifier, UserIdType } from '../../../common/src/utils/circuits/uuid'; import { CIRCUIT_CONSTANTS, revealedDataTypes } from '../../../common/src/constants/constants'; import { packForbiddenCountriesList } from '../../../common/src/utils/contracts/formatCallData'; - -type CountryCode = (typeof countryCodes)[keyof typeof countryCodes]; +import { Country3LetterCode, commonNames } from '../../../common/src/constants/countries'; export class SelfBackendVerifier { protected scope: string; @@ -25,10 +20,10 @@ export class SelfBackendVerifier { protected nationality: { enabled: boolean; - value: CountryCode; + value: Country3LetterCode; } = { enabled: false, - value: '' as CountryCode, + value: '' as Country3LetterCode, }; protected minimumAge: { enabled: boolean; value: string } = { enabled: false, @@ -36,7 +31,7 @@ export class SelfBackendVerifier { }; protected excludedCountries: { enabled: boolean; - value: CountryCode[]; + value: Country3LetterCode[]; } = { enabled: false, value: [], @@ -66,10 +61,7 @@ export class SelfBackendVerifier { } public async verify(proof: any, publicSignals: PublicSignals): Promise { - const excludedCountryCodes = this.excludedCountries.value.map((country) => - getCountryCode(country) - ); - const forbiddenCountriesListPacked = packForbiddenCountriesList(excludedCountryCodes); + const forbiddenCountriesListPacked = packForbiddenCountriesList(this.excludedCountries.value); const isValidScope = this.scope === @@ -159,8 +151,7 @@ export class SelfBackendVerifier { let isValidNationality = true; if (this.nationality.enabled) { const nationality = result[0][revealedDataTypes.nationality]; - const countryCode = countryCodes[nationality as keyof typeof countryCodes]; - isValidNationality = countryCode === this.nationality.value; + isValidNationality = nationality === this.nationality.value; } const credentialSubject = { @@ -215,12 +206,12 @@ export class SelfBackendVerifier { return this; } - setNationality(country: CountryCode): this { + setNationality(country: Country3LetterCode): this { this.nationality = { enabled: true, value: country }; return this; } - excludeCountries(...countries: CountryCode[]): this { + excludeCountries(...countries: Country3LetterCode[]): this { if (countries.length > 40) { throw new Error('Number of excluded countries cannot exceed 40'); } @@ -242,4 +233,4 @@ export class SelfBackendVerifier { this.nameAndYobOfac = true; return this; } -} +} \ No newline at end of file diff --git a/sdk/core/src/index.ts b/sdk/core/src/index.ts new file mode 100644 index 000000000..27e68c7f7 --- /dev/null +++ b/sdk/core/src/index.ts @@ -0,0 +1 @@ +export { SelfBackendVerifier } from './SelfBackendVerifier'; \ No newline at end of file diff --git a/sdk/qrcode/index.ts b/sdk/qrcode/index.ts index 8e1908906..c932b1383 100644 --- a/sdk/qrcode/index.ts +++ b/sdk/qrcode/index.ts @@ -1,7 +1,8 @@ import SelfQRcodeWrapper, { SelfQRcode, SelfApp, SelfAppBuilder } from './SelfQRcode'; import { WebAppInfo } from './utils/websocket'; +import { countries } from '../../common/src/constants/countries'; export default SelfQRcodeWrapper; -export { SelfQRcode, SelfApp, SelfAppBuilder }; +export { SelfQRcode, SelfApp, SelfAppBuilder, countries }; export type { WebAppInfo }; diff --git a/sdk/qrcode/package.json b/sdk/qrcode/package.json index 95deba17c..d5ffd2452 100644 --- a/sdk/qrcode/package.json +++ b/sdk/qrcode/package.json @@ -1,6 +1,6 @@ { "name": "@selfxyz/qrcode", - "version": "0.0.13", + "version": "0.0.14", "repository": { "type": "git", "url": "https://github.com/selfxyz/self" diff --git a/sdk/tests/web-app/src/app/api/verify/route.ts b/sdk/tests/web-app/src/app/api/verify/route.ts index 2424858ed..bd9e7c5fc 100644 --- a/sdk/tests/web-app/src/app/api/verify/route.ts +++ b/sdk/tests/web-app/src/app/api/verify/route.ts @@ -1,5 +1,7 @@ import { SelfBackendVerifier } from '../../../../../../core'; import { NextResponse } from 'next/server'; +import { countries } from '../../../../../../../common/src/constants/countries'; +import { count } from 'console'; export async function POST(request: Request) { try { @@ -18,7 +20,15 @@ export async function POST(request: Request) { "self-workshop", 'uuid', true - ).setMinimumAge(20); + ) + .setMinimumAge(20) + .excludeCountries( + countries.RUSSIA, + countries.CHINA, + countries.NORTH_KOREA, + countries.IRAN + ) + .setNationality(countries.UNITED_STATES); const result = await configuredVerifier.verify(proof, publicSignals); console.log("Verification result:", result); diff --git a/sdk/tests/web-app/src/app/page.tsx b/sdk/tests/web-app/src/app/page.tsx index 7be1c990c..34a95d4ba 100644 --- a/sdk/tests/web-app/src/app/page.tsx +++ b/sdk/tests/web-app/src/app/page.tsx @@ -2,6 +2,7 @@ import { SelfAppBuilder } from '../../../../qrcode/SelfQRcode'; import SelfQRcodeWrapper from '../../../../qrcode/SelfQRcode'; +import { countries } from '../../../../../common/src/constants/countries'; import { v4 } from 'uuid'; export default function Home() { @@ -10,10 +11,17 @@ export default function Home() { const selfApp = new SelfAppBuilder({ appName: "Self Workshop", scope: "self-workshop", - endpoint: "https://b950-194-230-144-192.ngrok-free.app/api/verify", + endpoint: "https://a1d5-133-3-201-47.ngrok-free.app/api/verify", logoBase64: "https://pluspng.com/img-png/images-owls-png-hd-owl-free-download-png-png-image-485.png", userId, disclosures: { + nationality: true, + excludedCountries: [ + countries.RUSSIA, + countries.CHINA, + countries.NORTH_KOREA, + countries.IRAN + ], minimumAge: 20, ofac: true, }