Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A utility library for returning country data, ISO info and states/provinces within them.
A Node.js module for returning data about countries, ISO info and states/provinces within them.
npm install countryjs
To run in-browser, you'll need the bulkify
transform for browserify
, as it pairs with bulk-require
, to staticly resolve each country JSON.
npm install bulkify
var bulkify = require('bulkify')
var bundle = browserify({
entries: [...],
})
.transform(bulkify, {
global: true
})
To access one of the country properties available, you'll need to use one of the API methods listed below and pass a country in either way:
country.population('US', 'ISO2')
or country.area('JP')
(defaults)country.capital('GBR', 'ISO3)
country.wiki('france', 'name')
. The matching is case-insensitive, against the native name, alternative spellings and available transalations..info()
Returns all available information for a specified country.
var country = require('countryjs');
country.info('US', 'ISO2'); // 'ISO2', 'ISO3', 'name'
country.info('US'); // Defaults to ISO2
// returns object,
// {
// "name": "United States",
// "altSpellings": ["US", "USA", "United States of America"],
// "area": 9629091,
// "borders": ["CAN", "MEX"],
// "callingCodes": ["1"],
// "capital": "Washington D.C.",
// "currencies": ["USD", "USN", "USS"],
// "demonym": "American",
// "flag": "", // Flag API is incomplete
// "geoJSON": {} //GeoJSON data,
// "ISO": {
// "alpha2": "US",
// "alpha3": "USA"
// },
// "languages": ["en"],
// "latlng": [38, -97],
// "nativeName": "United States",
// "population": 319259000,
// "provinces": [], // State/Province list
// "region": "Americas",
// "subregion": "Northern America",
// "timezones": [], // TimeZone list
// "tld": [".us"],
// "translations": {
// "de": "Vereinigte Staaten von Amerika",
// "es": "Estados Unidos",
// "fr": "États-Unis",
// "ja": "アメリカ合衆国",
// "it": "Stati Uniti D'America"
// },
// "wiki": "http://en.wikipedia.org/wiki/united_states_of_america"
// }
.states()
Returns all states/provinces for a specified country.
var country = require('countryjs');
country.states('USA', 'ISO3'); // 'ISO2', 'ISO3', 'name'
country.states('US'); // Defaults to ISO2
// returns array of states / provinces,
// [
// "Alabama",
// ...
// ]
.provinces()
Alias of .states()
.name()
Returns name for a specified country
var country = require('countryjs');
country.name('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.name('US') // Defaults to 'ISO2'
// returns string
// "United States"
.altSpellings()
Returns alternate spellings for the name of a specified country
var country = require('countryjs');
country.altSpellings('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.altSpellings('US') // Defaults to 'ISO2'
// returns array of strings, alternate names
// ["US", "USA", "United States of America"]
.area()
Returns area (km²) for a specified country
var country = require('countryjs');
country.area('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.area('US') // Defaults to 'ISO2'
// returns number of square kilometer area
// 9629091
.borders()
Returns bordering countries (ISO3) for a specified country
var country = require('countryjs');
country.borders('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.borders('US') // Defaults to 'ISO2'
// returns array of strings, ISO3 codes of countries that border the given country
// ["CAN", "MEX"]
.callingCodes()
Returns international calling codes for a specified country
var country = require('countryjs');
country.callingCodes('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.callingCodes('US') // Defaults to 'ISO2'
// returns array of calling code strings
// ["1"]
.capital()
Returns capital city for a specified country
var country = require('countryjs');
country.capital('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.capital('US') // Defaults to 'ISO2'
// returns string
// "Washington D.C."
.currencies()
Returns official currencies for a specified country
var country = require('countryjs');
country.currencies('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.currencies('US') // Defaults to 'ISO2'
// returns array of strings, currencies
// ["USD", "USN", "USS"]
.demonym()
Returns the demonyms for a specified country
var country = require('countryjs');
country.demonym('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.demonym('US') // Defaults to 'ISO2'
// returns string, name of residents
// "American"
.flag() - INCOMPLETE
Returns SVG link of the official flag for a specified country
var country = require('countryjs');
country.flag('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.flag('US') // Defaults to 'ISO2'
// returns string URL of CC licensed svg flag
.geoJSON()
Returns geoJSON for a specified country
var country = require('countryjs');
country.geoJSON('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.geoJSON('US') // Defaults to 'ISO2'
// returns object of GeoJSON data
.ISOcodes()
Returns ISO codes for a specified country
var country = require('countryjs');
country.ISOcodes('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.ISOcodes('US') // Defaults to 'ISO2'
// returns object of ISO codes
// {
// "alpha2": "US",
// "alpha3": "USA"
// }
.languages()
Returns official languages for a specified country
var country = require('countryjs');
country.languages('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.languages('US') // Defaults to 'ISO2'
// returns array of language codes
// ["en"]
.latlng()
Returns approx latitude and longitude for a specified country
var country = require('countryjs');
country.latlng('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.latlng('US') // Defaults to 'ISO2'
// returns array, approx latitude and longitude for country
// [38, -97]
.nativeName()
Returns the name of the country in its native tongue
var country = require('countryjs');
country.nativeName('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.nativeName('US') // Defaults to 'ISO2'
// returns string, name of country in native language
// "United States"
.population()
Returns approximate population for a specified country
var country = require('countryjs');
country.population('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.population('US') // Defaults to 'ISO2'
// returns number, approx population
// 319259000
.region()
Returns general region for a specified country
var country = require('countryjs');
country.region('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.region('US') // Defaults to 'ISO2'
// returns string
// "Americas"
.subregion()
Returns a more specific region for a specified country
var country = require('countryjs');
country.subregion('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.subregion('US') // Defaults to 'ISO2'
// returns string
// "Northern America"
.timezones()
Returns all timezones for a specified country
var country = require('countryjs');
country.timezones('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.timezones('US') // Defaults to 'ISO2'
// returns array of timezones
.tld()
Returns official top level domains for a specified country
var country = require('countryjs');
country.tld('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.tld('US') // Defaults to 'ISO2'
// returns array of top level domains specific to the country
// [".us"]
.translations()
Returns translations for a specified country name in popular languages
var country = require('countryjs');
country.translations('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.translations('US') // Defaults to 'ISO2'
// returns object of translations of country name in major languages
// {
// "de": "Vereinigte Staaten von Amerika",
// "es": "Estados Unidos",
// "fr": "États-Unis",
// "ja": "アメリカ合衆国",
// "it": "Stati Uniti D'America"
// }
.wiki()
Returns link to wikipedia page for a specified country
var country = require('countryjs');
country.wiki('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.wiki('US') // Defaults to 'ISO2'
// returns string URL of wikipedia article on country
// "http://en.wikipedia.org/wiki/united_states_of_america"
.all()
Returns array of objects containing all available data for all countries. This will be super big. Not recommended.
var country = require('countryjs');
country.all();
// returns array of objects,
// [{
// "name": "United States",
// "altSpellings": ["US", "USA", "United States of America"],
// "area": 9629091,
// "borders": ["CAN", "MEX"],
// "callingCodes": ["1"],
// "capital": "Washington D.C.",
// "currencies": ["USD", "USN", "USS"],
// "demonym": "American",
// "flag": "", // Flag API is incomplete
// "geoJSON": {} //GeoJSON data,
// "ISO": {
// "alpha2": "US",
// "alpha3": "USA"
// },
// "languages": ["en"],
// "latlng": [38, -97],
// "nativeName": "United States",
// "population": 319259000,
// "provinces": [], // State/Province list
// "region": "Americas",
// "subregion": "Northern America",
// "timezones": [], // TimeZone list
// "tld": [".us"],
// "translations": {
// "de": "Vereinigte Staaten von Amerika",
// "es": "Estados Unidos",
// "fr": "États-Unis",
// "ja": "アメリカ合衆国",
// "it": "Stati Uniti D'America"
// },
// "wiki": "http://en.wikipedia.org/wiki/united_states_of_america"
// }...]
Special thanks to johan for his work on johan/world.geo.json, who made the geojson portion of this build possible.
This project adheres to Javascript Standard style
To contribute code to this module, please follow this workflow:
npm install --dev
test/
folder, and run:npm test
This will check do the following:
test/
coverage/lcov-report/index.html
Please note that if your code updates do not pass JS Standard style, mocha tests and code coverage, your PR may be rejected and you'll need to fix any issues listed in it.
All notable changes to this project will be documented in this file.
This project adheres to Semantic Versioning and Keep A Changelog.
bulk-require
to depsglob
dep (replaced by bulk-require
)package.json
and README
)mocha.opts
.DS_STORE
to .gitignore
test
scriptThis is being maintained in the contributor's free time, and as such, may contain minor errors in regards to some countries. Most of the information included in this library is what is listed on Wikipedia. If there is an error, please let me know and I will do my best to correct it.
Copyright (c) 2015, Trent Oswald trentoswald@therebelrobot.com
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
FAQs
A utility library for returning country data, ISO info and states/provinces within them.
The npm package countryjs receives a total of 4,446 weekly downloads. As such, countryjs popularity was classified as popular.
We found that countryjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.