All Projects → reducktion → socrates

reducktion / socrates

Licence: MIT license
PHP package to Validate and Extract information from National Identification Numbers.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to socrates

php-currency-api
Standardized wrapper for popular currency rate APIs. Currently supports FixerIO, CurrencyLayer, Open Exchange Rates and Exchange Rates API.
Stars: ✭ 17 (-63.04%)
Mutual labels:  composer-package, php-package
ERC-1484
ERC-1484 Reference Implementation
Stars: ✭ 28 (-39.13%)
Mutual labels:  identity
Nager.Country
Worldwide Country Informations (ISO-3166-1 Alpha2, ISO-3166-1 Alpha3, ISO 639-1)
Stars: ✭ 68 (+47.83%)
Mutual labels:  countries
active-directory-android
An android app that uses Azure AD and the ADAL library for authenticating the user and calling a web API using OAuth 2.0 access tokens.
Stars: ✭ 33 (-28.26%)
Mutual labels:  identity
APICorePayLots
Web API designed in Asp.NET Core 3.1, using Dapper and Entity Framework Core, Repository Pattern, Identity
Stars: ✭ 13 (-71.74%)
Mutual labels:  identity
poa-popa
DApp for proof of physical address (PoPA) attestation for validators of POA Network
Stars: ✭ 22 (-52.17%)
Mutual labels:  identity
easydock
Dockerize your PHP apps ;)
Stars: ✭ 52 (+13.04%)
Mutual labels:  composer-package
blockstack.js-old
The Blockstack JS library for identity and authentication
Stars: ✭ 20 (-56.52%)
Mutual labels:  identity
ID-Card-Passport-Recognition-SDK-Android
On-Device ID Card & Passport & Driver License Recognition SDK for Android
Stars: ✭ 223 (+384.78%)
Mutual labels:  identity
facematch
Facematch is a tool to verifies if two photos contain the same person.
Stars: ✭ 62 (+34.78%)
Mutual labels:  identity
Authentication
Authentication examples for AspNetCore 3.1
Stars: ✭ 37 (-19.57%)
Mutual labels:  identity
npm-civic-sip-api
Node.js client library for the Civic Secure Identity Platform (SIP).
Stars: ✭ 25 (-45.65%)
Mutual labels:  identity
php-typography
A PHP library for improving your web typography.
Stars: ✭ 63 (+36.96%)
Mutual labels:  composer-package
netlify-gated-sites
How to create Single Sign On flows with role based access controls & functions
Stars: ✭ 21 (-54.35%)
Mutual labels:  identity
Convenience
.NET Core 5/Angular11/NG-ZORRO 权限管理系统 工作流系统
Stars: ✭ 74 (+60.87%)
Mutual labels:  identity
WeIdentity
基于区块链的符合W3C DID和Verifiable Credential规范的分布式身份解决方案
Stars: ✭ 1,063 (+2210.87%)
Mutual labels:  identity
identityazuretable
This project provides a high performance cloud solution for ASP.NET Identity Core using Azure Table storage replacing the Entity Framework / MSSQL provider.
Stars: ✭ 97 (+110.87%)
Mutual labels:  identity
cogito
Cogito Identity Management https://cogito.mobi
Stars: ✭ 14 (-69.57%)
Mutual labels:  identity
database-of-embassies
Database of embassies and consulates. Download as CSV, no registration, public domain. Powered by Wikidata.
Stars: ✭ 33 (-28.26%)
Mutual labels:  countries
opus
No description or website provided.
Stars: ✭ 22 (-52.17%)
Mutual labels:  identity

Socrates logo

Usage example

Badge Total Downloads Latest Version License StyleCI Contributors


Introduction

I am a Citizen of the World, and my Nationality is Goodwill.

Socrates is a PHP Package that allows you to validate and retrieve personal data from National Identification Numbers. Most countries in Europe are supported as well as some North and South American ones, with the goal to support as many countries in the world as possible.

Some countries also encode personal information of the citizen, such as gender or the place of birth. This package allows you to extract that information in a consistent way.

This package can be useful for many things such as validating a user's ID for finance related applications or verifying a user's age without asking for it explicitly. We recommend you review your country's data processing and protection laws before storing any information.

Ports of this package to other languages are currently in progress. Check further below for which ones are currently available.

PHP Version

PHP 8.1 is the minimum required version. If you are using an older version you should pull in the 1.3.0 version of this package. We highly recommend you upgrade though!

Installation

composer require reducktion/socrates

Usage

Socrates provides two methods: validateId and getCitizenDataFromId. Both receive an ID and the country code as a backed enum with the ISO 3166-2 format as the first and second parameters respectively. Simply instantiate the class and call the method you wish:

use Reducktion\Socrates\Socrates;
use Reducktion\Socrates\Constants\Country;

$socrates = new Socrates();
$socrates->validateId('14349483 0 ZV3', Country::Portugal);

validateId

This method will return true or false. In case the ID has a wrong character length an InvalidLengthException will be thrown.

if ($socrates->validateId('719102091', Country::Netherlands)) {
    echo 'Valid ID.';
} else {
    echo 'Invalid ID.';
}

getCitizenDataFromId

This method will return an instance of Citizen.
If the ID is invalid, an InvalidIdException will be thrown.
If the country does not support data extraction, an UnsupportedOperationException will be thrown.

$citizen = $socrates->getCitizenDataFromId('3860123012', Country::Estonia);

The Citizen class stores the extracted citizen data in a consistent format across all countries.
It exposes the getGender(), getDateOfBirth(), getAge() and getPlaceOfBirth() methods.

getGender will return an instance of the Gender enum.
getPlaceOfBirth will return a city or region name as a string.
getAge() returns the age of the citizen as an int.
getDateOfBirth() returns a DateTime instance.

Using the example above, Estonia only encodes the date of birth and gender of the citizen in their ID. So the above methods will return:

echo $citizen->getGender(); // 'Gender::Male'
echo $citizen->getDateOfBirth(); // DateTime instance with the date '1986-01-23'
echo $citizen->getAge(); // (The current age as a number)
echo $citizen->getPlaceOfBirth(); // null - Estonia does not encode place of birth on its ID numbers

Supported and Unsupported Countries

Here you can see the full list of supported countries and whether they support data extraction.

Four european countries are currently unsupported: Austria 🇦🇹, Belarus 🇧🇾, Cyprus 🇨🇾 and Luxembourg 🇱🇺. A number of countries in the Americas are also unsupported. This is because we could not find a reliable source for the algorithm, if at all. Help would be appreciated to get these countries supported.

Testing

composer test

Ports

This package is also available for the following languages:

Rust
Java

Contributing

Did you find a problem in any of the algorithms? Do you know how to implement a country which we have missed? Are there any improvements that you think should be made to the codebase? Any help is appreciated! Take a look at our contributing guidelines.

Code of Conduct

Our CoC is based on Ruby's. Check out our code of conduct.

License

The MIT License (MIT). Please see License File for more information.

Credits

Socrates was made with 💖 by Alexandre Olival and João Cruz. We are Reducktion. We hope to make someone's life easier after all the hard work compiling, researching, reverse-engineering and agonizing over ID validation algorithms - many of which were very obscure and hard to find.

Special Thanks

A big thanks goes to these people who helped us either test with real life IDs or guide us in finding the algorithm for their countries:

  • Alexandra from 🇷🇴
  • Berilay from 🇹🇷
  • Christian from 🇨🇭
  • Domynikas from 🇱🇹
  • Jeppe from 🇩🇰
  • Jeremy from 🇫🇷
  • Lisa from 🇬🇷
  • Miguel from 🇪🇸

and Nair from 🇵🇹 for the package name.

Contributors

Thanks goes to these wonderful people (emoji key):


SLourenco

🐛 📖 💻

Flávio Heleno

💻 📖

Yves Bos

📖 💻 🐛

bofalke

💻 📖

Rodolpho Lima

💻 📖

tiagomichaelsousa

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].