Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@pagopa/react-native-cie

pagopa10.8kMIT1.4.3TypeScript support: included

CIE (Carta di Identità Elettronica) module for react native.

cie, react-native

readme


IO - The public services app

Italiano

Questo repository contiene il porting per React Native (eseguito dal team di IO) dell'SDK sviluppato da IPZS (disponibile qui)

Installazione

Per utilizzare la libreria nel tuo progetto:

npm install @pagopa/react-native-cie --save

La login con CIE può essere effettuata esclusivamente tramite tecnologia NFC (tecnologia di tipo Hardware).
Su iOS, il codice che implementa la tecnologia non è disponibile sul simulatore, rendendo impossibile la build.

Per superare il problema, è necessario rinominare la cartella ios in .ios. In questo modo, React Native non ha visibilità del codice iOS e la build va a buon fine.

Per facilitare questo passaggio e abilitare la compilazione della libreria (lanciando la build da un device reale), è stato definito il comando:

mv node_modules/@pagopa/react-native-cie/.ios node_modules/@pagopa/react-native-cie/ios
mv node_modules/@pagopa/react-native-cie/.react-native-cie.podspec node_modules/@pagopa/react-native-cie/react-native-cie.podspec
cd ios
pod install

Per effettuare l'operazione inversa, invece:

mv node_modules/@pagopa/react-native-cie/ios node_modules/@pagopa/react-native-cie/.ios
mv node_modules/@pagopa/react-native-cie/react-native-cie.podspec node_modules/@pagopa/react-native-cie/.react-native-cie.podspec
cd ios
rm -rf Pods
pod install

Compatibilità

Non tutti i device sono compatibili con la login tramite CIE. La libreria espone dei metodi per sapere se il dispositivo è compatibile oppure no

Android

Su Android, è necessario verificare la presenza dell'NFC, oltre che della versione minima dell'API (>= 23).
Recentemente, è stato scoperto che alcuni vendors disabilitano la funzionalità software extended APDU, rendendo impossibile la lettura/scrittura tramite NFC.
Purtroppo, non è possibile determinare a priori questa possibilità, ma può essere gestito l'errore ritornato dall'SDK in fase di lettura.

iOS

Su iOS, la tecnologia NFC è presente su tutti i device con iOS >= 13.

Utilizzo

Per effettuare l'autenticazione tramite CIE, sono necessari tre componenti:

  • un URI di Autenticazione;
  • il PIN della CIE;
  • la carta da leggere;

Il recupero di queste tre componenti non dipendono dall'SDK.
Per utilizzare l'SDK, è necessario importarlo

import cieManager from "@pagopa/react-native-cie";

Una volta importato, è possibile accedere a tutti i suoi metodi.

API

Di seguito sono elencate alcune delle funzionalità presenti.
E' possibile trovare qui tutte le altre.

Function Return Descrizione
hasApiLevelSupport() Promise<boolean> (Android) Verifica se l'OS supporta l'autenticazione con CIE
hasNFCFeature() Promise<boolean> Verifica se il device ha l'NFC
setPin(pin: string) Promise<void> Set del PIN della CIE
setAuthenticationUrl(url: string) Promise<void> Set dell'Url di Autenticazione
start(alertMessagesConfig?: Partial<Record<iOSAlertMessageKeys, string>>) Promise<void> Avvia l'utilizzo dell'SDK
startListeningNFC() Promise<void> (Android) Avvia la lettura dell'NFC
stopListeningNFC() Promise<void> (Android) Stoppa la lettura dell'NFC
openNFCSettings() Promise<void> (Android) Apre le impostazioni dell'OS per l'NFC
onEvent(callback: (event: Event) => void) void Callback eseguita ad ogni evento di lettura/scrittura
onError(callback: (error: Error) => void) void Callback eseguita ad ogni errore di lettura/scrittura
onSuccess(callback: (url: string) => void) void Callback eseguita in caso di success

Possibili eventi

Durante la lettura dell'NFC, i possibili errori sono i seguenti

Error code Descrizione
ON_TAG_DISCOVERED_NOT_CIE (Android) La carta letta non è una CIE
TAG_ERROR_NFC_NOT_SUPPORTED (iOS) La carta letta non è una CIE
ON_TAG_DISCOVERED E' stato riconosciuto un tag
ON_TAG_LOST Tag rimosso / allontanato
ON_CARD_PIN_LOCKED (Android) Troppi inserimenti errati del PIN. La Card CIE è bloccata
PIN Locked (iOS) Troppi inserimenti errati del PIN. La Card CIE è bloccata
ON_PIN_ERROR Pin errato. L'evento restituisce anche il numero di tentativi rimasti
PIN_INPUT_ERROR Il PIN ha un formato errato (8 cifre numeriche)
CERTIFICATE_EXPIRED La CIE è scaduta
CERTIFICATE_REVOKED La CIE è stata revocata
AUTHENTICATION_ERROR Errore di autenticazione con il server del Ministero
ON_NO_INTERNET_CONNECTION Nessuna connesione ad Internet
STOP_NFC_ERROR Errore durante lo stop della lettura NFC
START_NFC_ERROR Errore durante lo start della lettura NFC
EXTENDED_APDU_NOT_SUPPORTED Il dispositivo non supporta una caratteristica della lettura della CIE
Transmission Error (iOS) Errore durante la trasmissione NFC

English

This repository contains the React Native library for CIE integration, written by IO

Installation

To use the library in your project

npm install @pagopa/react-native-cie --save

The login with CIE works only with NFC (hardware tecnology).
On iOS, the code that implements this tecnology isn't available on simulator, so it's not possible to build the project.

To solve this issue, you can rename the ios folder into .ios. After that, ReactNative has no more visibility on the iOS part and the build goes well.

If you want, you can use these commands to enable o disable the compiling phase.

Enable

mv node_modules/@pagopa/react-native-cie/.ios node_modules/@pagopa/react-native-cie/ios
mv node_modules/@pagopa/react-native-cie/.react-native-cie.podspec node_modules/@pagopa/react-native-cie/react-native-cie.podspec
cd ios
pod install

Disable

mv node_modules/@pagopa/react-native-cie/ios node_modules/@pagopa/react-native-cie/.ios
mv node_modules/@pagopa/react-native-cie/react-native-cie.podspec node_modules/@pagopa/react-native-cie/.react-native-cie.podspec
cd ios
rm -rf Pods
pod install

Compatibility

Note that not all the devices can allow the CIE login. This library provides you the methods to check that.

Android

On Android, is mandatory to check if the device has the NFC feature and the minimum version for the API (>= 23).
Recently, it was discovered a new issue. Some vendors are disabling a feature called software extended APDU. This feature disable the writing/reading through the NFC.
Unfortunately, it's not possible to determinate this possibility at beginning, but it's possible to handle the error returned by the SDK while reading the CIE.

iOS

On iOS, the NFC feature is available on all the device with iOS >=13.

Usage

To provide the CIE authentication, 3 components are required:

  • Authentication URI;
  • CIE pin;
  • the physical CIE to read;

It's up to you to get this components.
To use the library, just import it!

import cieManager from "@pagopa/react-native-cie";

Now you have access to all the methods.

API

A summary of some functionalities are written below, but you can find more here.

Function Return Desciption
hasApiLevelSupport() Promise<boolean> (Android) Check if OS has the minimum Api version
hasNFCFeature() Promise<boolean> Check if the device has the NFC
setPin(pin: string) Promise<void> Set the pin of the CIE
setAuthenticationUrl(url: string) Promise<void> Set the Authentication Url
setCutomIdpUrl(url: string?) <void> Set a Custom IdP Url
enableLog(isEnabled: boolean) <void> Enable the sdk logs
start(alertMessagesConfig?: Partial<Record<iOSAlertMessageKeys, string>>) Promise<void> Start the SDK
startListeningNFC() Promise<void> (Android) Start the reading from the NFC
stopListeningNFC() Promise<void> (Android) Stop the reading from the NFC
openNFCSettings() Promise<void> (Android) Open the OS Settings for the NFC
onEvent(callback: (event: Event) => void) void Callback after any events of reading/writing
onError(callback: (error: Error) => void) void Callback after any errors of reading/writing
onSuccess(callback: (url: string) => void) void Success Callback

Handle errors

You can handle the errors that happens while reading the NFC.

Error code Description
ON_TAG_DISCOVERED_NOT_CIE (Android) The card is not a CIE
TAG_ERROR_NFC_NOT_SUPPORTED (iOS) The card is not a CIE
ON_TAG_DISCOVERED A tag is discovered.
ON_TAG_LOST A tag is lost
ON_CARD_PIN_LOCKED (Android) The CIE is locked because of too many insert of wrong PIN
PIN Locked (iOS) The CIE is locked because of too many insert of wrong PIN
ON_PIN_ERROR Wrong PIN. The error returns also the remaining attempts number
PIN_INPUT_ERROR Wrong format for the PIN. It must be 8 numeric characters
CERTIFICATE_EXPIRED Expired CIE
CERTIFICATE_REVOKED Revoked CIE
AUTHENTICATION_ERROR Authentication error during the communication with Government server
ON_NO_INTERNET_CONNECTION No Internet connection
STOP_NFC_ERROR Error while stopping the NFC reading
START_NFC_ERROR Error while starting the NFC reading
EXTENDED_APDU_NOT_SUPPORTED The device cannot read the CIE
Transmission Error (iOS) Generic Error

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

v1.4.3

  • fix: [IOPID-2404] javax.net.ssl.SSLHandshakeException on different SDK provider #57

v1.4.2

13 January 2025

  • [IOAPPX-454] Use kotlin and okhttp version from the root project #54
  • chore: release 1.4.2 84ea230

v1.4.1

10 January 2025

  • chore: [IOAPPX-461] Add release-it and npm GA workflow #55
  • chore: release 1.4.1 af0f6c7

v1.4.0

11 November 2024

v1.4.0-RELEASE

11 November 2024

  • [#IOPLT-764] chore: removes kotlin-android-extensions due to compatibility with rn 0.75 #53
  • Bump version to 1.4.0 [skip ci] ec2cc84

v1.3.0

14 June 2024

v1.3.0-RELEASE

14 June 2024

  • chore: bump compile SDK version for android #52
  • Bump version to 1.3.0 [skip ci] 15fbcb1

v1.2.1

4 April 2024

v1.2.1-RELEASE

4 April 2024

  • [IOPID-1714] handle malformed response on iOS #51
  • Bump version to 1.2.1 [skip ci] 4ba5833
  • Create CODEOWNERS 50018c4

v1.2.0

28 July 2023

v1.2.0-RELEASE

28 July 2023

  • [IOPID-542, IOPID-543] Switch for IPZS UAT #50
  • Bump version to 1.2.0 [skip ci] a3c759c

v1.1.5

13 February 2023

v1.1.5-RELEASE

13 February 2023

  • Fix reading of new CIE on Android #48
  • Bump version to 1.1.5 [skip ci] 7f813a3

v1.1.4

15 April 2022

v1.1.4-RELEASE

15 April 2022

v1.1.3

1 October 2021

v1.1.3-RELEASE

1 October 2021

  • Support alert messages customization [ios] #38
  • Bump version to 1.1.3 [skip ci] 36185a4

v1.1.2

22 September 2021

v1.1.2-RELEASE

22 September 2021

  • Bump version to 1.1.2 [skip ci] ea83b16
  • fix: Add missing import 901c139

v1.1.1

22 September 2021

v1.1.1-RELEASE

22 September 2021

  • [IA-222] An unhandled exception causes crash #37
  • Bump version to 1.1.1 [skip ci] a56a043

v1.1.0

20 September 2021

v1.1.0-RELEASE

20 September 2021

  • Fix isIosDeviceCompatible condition #36
  • Bump version to 1.1.0 [skip ci] cd15d67
  • Delete .node-version 295c3cb

v1.0.7

21 July 2021

v1.0.7-RELEASE

21 July 2021

  • Bump version to 1.0.7 [skip ci] 499763f
  • restore test library 61148fd

v1.0.6

21 July 2021

v1.0.6-RELEASE

21 July 2021

  • restore libraries version be0fdb5
  • Bump version to 1.0.6 [skip ci] 17533e5

v1.0.5

21 July 2021

v1.0.5-RELEASE

21 July 2021

  • Update pipelines with new template and variables #35
  • Update from main repo #34
  • Bump version to 1.0.5 [skip ci] 6355f96

v1.0.4

30 March 2021

v1.0.4-RELEASE

30 March 2021

  • [iOS] Close NFC dialog when card is successfully read #32 25b6bb8
  • Bump version to 1.0.4 [skip ci] 24d42ab
  • restore version 96f5a26

v1.0.3

1 February 2021

v1.0.3-RELEASE

1 February 2021

  • fix: [#176614756] Fix package file list #31
  • Bump version to 1.0.3 [skip ci] 302abc2

v1.0.2

26 January 2021

v1.0.2-RELEASE

26 January 2021

  • Bump version to 1.0.2 [skip ci] c5c45b3
  • add missing files to deployed bundle 5a6162b

v1.0.1

26 January 2021

v1.0.1-RELEASE

26 January 2021

v1.0.0

26 January 2021

v1.0.0-RELEASE

26 January 2021

  • add declaration file to package.json #26
  • [#176614756] Remove github registry #28
  • Add danger #30
  • add danger #29
  • [#176013578] added code-review and deploy pipeline #27
  • Bump version to 1.0.0 [skip ci] e612ada
  • update 0.3.3 4e2b2ed
  • update ios framework (handle blocked card error code) 829a917

0.3.1

21 October 2020

0.3.0

19 October 2020

  • Add new errors event #25
  • Added the ability to open CieID #23
  • Add android 10 support #22
  • [#170150939] now nfc feature/enabled can be asked with context #21
  • fix native event creation #20
  • Add files via upload #19
  • Update README.md #18
  • [#169430153,#169410028,#169404707] fixes and improvements #17
  • [#169129603] fix bug on cie attempts null check #16
  • added method launchCieID #15
  • Merge branch 'ipzs-rebase' of https://github.com/teamdigitale/io-cie-android-sdk into ipzs-rebase #13
  • [#169129603] add api level check method #14
  • [#169059802] Add CIE pin setter #12
  • [#168485185] Add openNFCSettings bridge method #8
  • [#168485266] Complete React Native Bridge #9
  • [#168954275] increase timeout to 10 seconds #11
  • [#168485266] Removed 'any' and typed enums #7
  • [#167568466] Add react native bridge #6
  • set isoDep timeout from default (300ms) to 2s #5
  • ios production (min iOS 10) 85c102e
  • ios cie dev/production configuration 6f9c4a6
  • integrate ios support fef3803