Skip to content

Country constants

Importable from x511/countries. Country codes are ISO 3166-1 alpha-3 strings.

ts
import {
  ALL_COUNTRIES,
  EU_COUNTRIES,
  EEA_COUNTRIES,
  SCHENGEN_COUNTRIES,
  ASEAN_COUNTRIES,
  MERCOSUR_COUNTRIES,
  AMERICAS_COUNTRIES,
  isSelfCountryAllowed,
} from 'x511/countries'
import type { X511Country } from 'x511/countries'

ALL_COUNTRIES

ts
const ALL_COUNTRIES: readonly string[]

The full list of 249 ISO 3166-1 alpha-3 codes recognised by X511. Used as the source of truth for the X511Country type.

Pre-defined groups

ConstantMembers
EU_COUNTRIESThe 27 EU member states.
EEA_COUNTRIESEU + Iceland (ISL), Liechtenstein (LIE), Norway (NOR).
SCHENGEN_COUNTRIESThe 29 Schengen Area members.
ASEAN_COUNTRIESThe 10 ASEAN members (BRN, KHM, IDN, LAO, MYS, MMR, PHL, SGP, THA, VNM).
MERCOSUR_COUNTRIESMercosur full + associate members (ARG, BOL, BRA, CHL, COL, ECU, GUY, PRY, PER, SUR, URY, VEN).
AMERICAS_COUNTRIES34 sovereign states across North, Central, and South America plus the Caribbean.

Use them anywhere a CountryFilter is accepted:

ts
import { x511, self } from 'x511/hono'
import { EU_COUNTRIES } from 'x511/countries'

const { verify, verified } = x511({
  domain: 'https://your-app.example.com',
  disclosures: {
    minAge: 18,
    nationality: { included: EU_COUNTRIES },
  },
  mode: { type: 'session', ttl: 1800 },
  providers: [self({ scope: 'your-app' })],
})

X511Country

ts
type X511Country = (typeof ALL_COUNTRIES)[number]

A literal-string union of every code in ALL_COUNTRIES. Use it when you build your own arrays:

ts
import type { X511Country } from 'x511/countries'

const allowed: X511Country[] = ['HUN', 'POL', 'SVK', 'CZE']

CountryFilter

ts
type CountryFilter =
  | { included: X511Country[]; excluded?: never }
  | { excluded: X511Country[]; included?: never }

Filters appear inside disclosures.nationality and disclosures.issuingState. The two halves are mutually exclusive — x511() throws if both (or neither) are present.

ts
disclosures: {
  minAge: 18,
  issuingState: { excluded: ['PRK', 'IRN'] },
}

isSelfCountryAllowed()

ts
function isSelfCountryAllowed(disclosed: string, filter: CountryFilter): boolean

Used internally by the self provider when checking the nationality and issuingState it received from @selfxyz/core. Self emits country values using ICAO machine-readable codes (e.g. D<< for Germany), and this helper normalizes them back to ISO alpha-3 before matching against the configured filter.

You normally do not need to call it directly; expose it only if you write a custom provider that consumes Self attestation output.