@pagopa/io-react-native-cie 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -97,21 +97,21 @@ To run the example app, follow the instructions in [example/README.md](./example
97
97
 
98
98
  List of available functions
99
99
 
100
- | Function | Return | Descrizione |
101
- | :---------------------------------------------------------------------------- | :----------------- | :------------------------------------------------------------ |
102
- | `hasNFCFeature()` | `Promise<boolean>` | (Android) Checks if the device supports NFC feature |
103
- | `isNfcEnabled()` | `Promise<boolean>` | (Android) Checks if the NFC is currently enabled |
104
- | `isCieAuthenticationSupported()` | `Promise<boolean>` | (Android) Checks if the device supports CIE autentication |
105
- | `openNfcSettings()` | `Promise<void>` | (Android) Opens NFC system settings page |
106
- | `addListener(event: CieEvent, listener: CieEventHandlers)` | `() => void` | Adds a NFC event listener and returns a function to unsubscribe from the event |
107
- | `removeListener(event: CieEvent)` | `void` | Removes all listeners for the specified event |
108
- | `removeAllListeners()` | `void` | Removes all registered listeners |
109
- | `setCustomIdpUrl(url: string)` | `void` | Updates IDP url |
110
- | `setAlertMessage(key: AlertMessageKey, value: string)` | `void` | (iOS) Updates iOS NFC modal alert message |
111
- | `setCurrentAlertMessage(value: string)` | `void` | (iOS) Updates currently displayed iOS NFC modal alert message |
112
- | `startReadingAttributes(timeout: number)` | `Promise<void` | Start the CIE attributes reading process |
113
- | `startReading(pin: string, authenticationUrl: string, timeout: number)` | `Promise<void` | Start the CIE reading process fro authentication |
114
- | `stopReading()` | `Promise<void` | (Android) Stops all reading process |
100
+ | Function | Return | Description |
101
+ | :---------------------------------------------------------------------- | :----------------- | :----------------------------------------------------------------------------- |
102
+ | `hasNFCFeature()` | `Promise<boolean>` | (Android) Checks if the device supports NFC feature |
103
+ | `isNfcEnabled()` | `Promise<boolean>` | (Android) Checks if the NFC is currently enabled |
104
+ | `isCieAuthenticationSupported()` | `Promise<boolean>` | (Android) Checks if the device supports CIE autentication |
105
+ | `openNfcSettings()` | `Promise<void>` | (Android) Opens NFC system settings page |
106
+ | `addListener(event: CieEvent, listener: CieEventHandlers)` | `() => void` | Adds a NFC event listener and returns a function to unsubscribe from the event |
107
+ | `removeListener(event: CieEvent)` | `void` | Removes all listeners for the specified event |
108
+ | `removeAllListeners()` | `void` | Removes all registered listeners |
109
+ | `setCustomIdpUrl(url?: string)` | `void` | Updates IDP url, if `undefined` will use the default IDP url |
110
+ | `setAlertMessage(key: AlertMessageKey, value: string)` | `void` | (iOS) Updates iOS NFC modal alert message |
111
+ | `setCurrentAlertMessage(value: string)` | `void` | (iOS) Updates currently displayed iOS NFC modal alert message |
112
+ | `startReadingAttributes(timeout: number)` | `Promise<void` | Start the CIE attributes reading process |
113
+ | `startReading(pin: string, authenticationUrl: string, timeout: number)` | `Promise<void` | Start the CIE reading process fro authentication |
114
+ | `stopReading()` | `Promise<void` | (Android) Stops all reading process |
115
115
 
116
116
  ## Usage
117
117
 
@@ -200,7 +200,7 @@ class IoReactNativeCieModule(reactContext: ReactApplicationContext) :
200
200
  .emit(EventType.ERROR.value, WritableNativeMap().apply {
201
201
  putString("name", mapNfcError(error).name)
202
202
  error.msg?.let { putString("msg", it) }
203
- error.numberOfAttempts?.let { putInt("attempts", it) }
203
+ error.numberOfAttempts?.let { putInt("attemptsLeft", it) }
204
204
  })
205
205
 
206
206
  }
@@ -161,8 +161,8 @@ class IoReactNativeCie: RCTEventEmitter {
161
161
  }
162
162
  case .errorBuildingApdu, .responseError:
163
163
  payload = [ "name": ErrorType.APDU_ERROR.rawValue, "message": error.description ]
164
- case .wrongPin(let attempts):
165
- payload = [ "name":ErrorType.WRONG_PIN.rawValue, "message": error.description, "attempts": attempts ]
164
+ case .wrongPin(let attemptsLeft):
165
+ payload = [ "name":ErrorType.WRONG_PIN.rawValue, "message": error.description, "attemptsLeft": attemptsLeft ]
166
166
  case .cardBlocked:
167
167
  payload = [ "name": ErrorType.CARD_BLOCKED.rawValue, "message": error.description ]
168
168
  case .sslError:
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
 
3
- import { NativeEventEmitter, NativeModules } from 'react-native';
3
+ import { NativeEventEmitter } from 'react-native';
4
4
  import { IoReactNativeCie } from "../native.js";
5
+ import { getDefaultIdpUrl } from "./utils.js";
5
6
  const DEFAULT_TIMEOUT = 10000;
6
- const eventEmitter = new NativeEventEmitter(NativeModules.IoReactNativeCie);
7
+ const eventEmitter = new NativeEventEmitter(IoReactNativeCie);
7
8
 
8
9
  /**
9
10
  * Adds a listener for a specific CIE event.
@@ -50,17 +51,18 @@ const removeAllListeners = () => {
50
51
 
51
52
  /**
52
53
  * Sets a custom Identity Provider (IDP) URL for authentication.
53
- * If not set, will be used the default IDP URL:
54
- * https://idserver.servizicie.interno.gov.it/idp/
54
+ * If not set or set to undefined, will be used the default IDP URL:
55
+ * - iOS: https://idserver.servizicie.interno.gov.it/idp/Authn/SSL/Login2?
56
+ * - Android: https://idserver.servizicie.interno.gov.it/idp/
55
57
  *
56
- * @param url - The custom IDP URL to use
58
+ * @param url - The custom IDP URL to use or undefined to use the default IDP URL
57
59
  * @example
58
60
  * ```typescript
59
61
  * CieManager.setCustomIdpUrl('https://custom.idp.com/auth');
60
62
  * ```
61
63
  */
62
64
  const setCustomIdpUrl = url => {
63
- return IoReactNativeCie.setCustomIdpUrl(url);
65
+ return IoReactNativeCie.setCustomIdpUrl(url ?? getDefaultIdpUrl());
64
66
  };
65
67
 
66
68
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","IoReactNativeCie","DEFAULT_TIMEOUT","eventEmitter","addListener","event","listener","subscription","remove","removeListener","removeAllListeners","setCustomIdpUrl","url","setAlertMessage","key","value","setCurrentAlertMessage","startReadingAttributes","timeout","startReading","pin","authenticationUrl","stopReading"],"sourceRoot":"../../../src","sources":["manager/index.ts"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,SAASC,gBAAgB,QAAQ,cAAW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Od,gBAAgB,CAACe,sBAAsB,CAACD,KAAK,CAAC;AACvD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,sBAAsB,GAAG,MAAAA,CAC7BC,OAAe,GAAGhB,eAAe,KACf;EAClB,OAAOD,gBAAgB,CAACgB,sBAAsB,CAACC,OAAO,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAG,MAAAA,CACnBC,GAAW,EACXC,iBAAyB,EACzBH,OAAe,GAAGhB,eAAe,KACf;EAClB,OAAOD,gBAAgB,CAACkB,YAAY,CAACC,GAAG,EAAEC,iBAAiB,EAAEH,OAAO,CAAC;AACvE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,WAAW,GAAG,MAAAA,CAAA,KAA2B;EAC7C,OAAOrB,gBAAgB,CAACqB,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,SACElB,WAAW,EACXK,cAAc,EACdC,kBAAkB,EAClBC,eAAe,EACfM,sBAAsB,EACtBE,YAAY,EACZG,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["NativeEventEmitter","IoReactNativeCie","getDefaultIdpUrl","DEFAULT_TIMEOUT","eventEmitter","addListener","event","listener","subscription","remove","removeListener","removeAllListeners","setCustomIdpUrl","url","setAlertMessage","key","value","setCurrentAlertMessage","startReadingAttributes","timeout","startReading","pin","authenticationUrl","stopReading"],"sourceRoot":"../../../src","sources":["manager/index.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,SAASC,gBAAgB,QAAQ,cAAW;AAE5C,SAASC,gBAAgB,QAAQ,YAAS;AAE1C,MAAMC,eAAe,GAAG,KAAK;AAE7B,MAAMC,YAAY,GAAG,IAAIJ,kBAAkB,CAACC,gBAAgB,CAAC;;AAE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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,sBAAsB,GAAG,MAAAA,CAC7BC,OAAe,GAAGhB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACiB,sBAAsB,CAACC,OAAO,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAG,MAAAA,CACnBC,GAAW,EACXC,iBAAyB,EACzBH,OAAe,GAAGhB,eAAe,KACf;EAClB,OAAOF,gBAAgB,CAACmB,YAAY,CAACC,GAAG,EAAEC,iBAAiB,EAAEH,OAAO,CAAC;AACvE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,WAAW,GAAG,MAAAA,CAAA,KAA2B;EAC7C,OAAOtB,gBAAgB,CAACsB,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,SACElB,WAAW,EACXK,cAAc,EACdC,kBAAkB,EAClBC,eAAe,EACfM,sBAAsB,EACtBE,YAAY,EACZG,WAAW","ignoreList":[]}
@@ -22,15 +22,16 @@ export const NfcEvent = z.object({
22
22
  export const NfcErrorName = z.enum(['NOT_A_CIE', 'TAG_LOST', 'CANCELLED_BY_USER', 'APDU_ERROR', 'WRONG_PIN', 'CARD_BLOCKED', 'NO_INTERNET_CONNECTION', 'CERTIFICATE_EXPIRED', 'CERTIFICATE_REVOKED', 'AUTHENTICATION_ERROR', 'GENERIC_ERROR']);
23
23
  /**
24
24
  * Represent an NFC error emitted during the CIE reading process
25
- * It contains the name of the error, the message and the number of attempts
26
25
  */
27
26
  export const NfcError = z.union([z.object({
28
- name: NfcErrorName,
27
+ name: NfcErrorName.exclude(['WRONG_PIN']),
29
28
  message: z.string().optional()
30
- }), z.object({
31
- name: z.literal(NfcErrorName.enum.WRONG_PIN),
29
+ }),
30
+ // WRONG_PIN error also contains the number of attempts left
31
+ z.object({
32
+ name: NfcErrorName.extract(['WRONG_PIN']),
32
33
  message: z.string().optional(),
33
- attempts: z.number()
34
+ attemptsLeft: z.number()
34
35
  })]);
35
36
  /**
36
37
  * Represent the CIE attributes containing the CIE type
@@ -1 +1 @@
1
- {"version":3,"names":["z","AlertMessageKey","enum","NfcEvent","object","name","string","progress","coerce","number","NfcErrorName","NfcError","union","message","optional","literal","WRONG_PIN","attempts","CieAttributes","type","base64"],"sourceRoot":"../../../src","sources":["manager/types.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGD,CAAC,CAACE,IAAI,CAAC,CACpC,qBAAqB,EACrB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,CACf,CAAC;AAIF;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGH,CAAC,CAACI,MAAM,CAAC;EAC/BC,IAAI,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBC,QAAQ,EAAEP,CAAC,CAACQ,MAAM,CAACC,MAAM,CAAC;AAC5B,CAAC,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGV,CAAC,CAACE,IAAI,CAAC,CACjC,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,CAChB,CAAC;AAIF;AACA;AACA;AACA;AACA,OAAO,MAAMS,QAAQ,GAAGX,CAAC,CAACY,KAAK,CAAC,CAC9BZ,CAAC,CAACI,MAAM,CAAC;EACPC,IAAI,EAAEK,YAAY;EAClBG,OAAO,EAAEb,CAAC,CAACM,MAAM,CAAC,CAAC,CAACQ,QAAQ,CAAC;AAC/B,CAAC,CAAC,EACFd,CAAC,CAACI,MAAM,CAAC;EACPC,IAAI,EAAEL,CAAC,CAACe,OAAO,CAACL,YAAY,CAACR,IAAI,CAACc,SAAS,CAAC;EAC5CH,OAAO,EAAEb,CAAC,CAACM,MAAM,CAAC,CAAC,CAACQ,QAAQ,CAAC,CAAC;EAC9BG,QAAQ,EAAEjB,CAAC,CAACS,MAAM,CAAC;AACrB,CAAC,CAAC,CACH,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMS,aAAa,GAAGlB,CAAC,CAACI,MAAM,CAAC;EACpCe,IAAI,EAAEnB,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBc,MAAM,EAAEpB,CAAC,CAACM,MAAM,CAAC;AACnB,CAAC,CAAC;;AAIF;AACA;AACA;;AAQA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["z","AlertMessageKey","enum","NfcEvent","object","name","string","progress","coerce","number","NfcErrorName","NfcError","union","exclude","message","optional","extract","attemptsLeft","CieAttributes","type","base64"],"sourceRoot":"../../../src","sources":["manager/types.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;;AAEvB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGD,CAAC,CAACE,IAAI,CAAC,CACpC,qBAAqB,EACrB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,CACf,CAAC;AAIF;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGH,CAAC,CAACI,MAAM,CAAC;EAC/BC,IAAI,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBC,QAAQ,EAAEP,CAAC,CAACQ,MAAM,CAACC,MAAM,CAAC;AAC5B,CAAC,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGV,CAAC,CAACE,IAAI,CAAC,CACjC,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,CAChB,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMS,QAAQ,GAAGX,CAAC,CAACY,KAAK,CAAC,CAC9BZ,CAAC,CAACI,MAAM,CAAC;EACPC,IAAI,EAAEK,YAAY,CAACG,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;EACzCC,OAAO,EAAEd,CAAC,CAACM,MAAM,CAAC,CAAC,CAACS,QAAQ,CAAC;AAC/B,CAAC,CAAC;AACF;AACAf,CAAC,CAACI,MAAM,CAAC;EACPC,IAAI,EAAEK,YAAY,CAACM,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;EACzCF,OAAO,EAAEd,CAAC,CAACM,MAAM,CAAC,CAAC,CAACS,QAAQ,CAAC,CAAC;EAC9BE,YAAY,EAAEjB,CAAC,CAACS,MAAM,CAAC;AACzB,CAAC,CAAC,CACH,CAAC;AAIF;AACA;AACA;AACA,OAAO,MAAMS,aAAa,GAAGlB,CAAC,CAACI,MAAM,CAAC;EACpCe,IAAI,EAAEnB,CAAC,CAACM,MAAM,CAAC,CAAC;EAChBc,MAAM,EAAEpB,CAAC,CAACM,MAAM,CAAC;AACnB,CAAC,CAAC;;AAIF;AACA;AACA;;AAQA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ import { Platform } from 'react-native';
4
+ export const BASE_IDP_URL = 'https://idserver.servizicie.interno.gov.it/idp/';
5
+ export const getDefaultIdpUrl = () => Platform.select({
6
+ ios: `${BASE_IDP_URL}Authn/SSL/Login2?`,
7
+ android: BASE_IDP_URL
8
+ });
9
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","BASE_IDP_URL","getDefaultIdpUrl","select","ios","android"],"sourceRoot":"../../../src","sources":["manager/utils.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,YAAY,GAAG,iDAAiD;AAE7E,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAC9BF,QAAQ,CAACG,MAAM,CAAC;EACdC,GAAG,EAAE,GAAGH,YAAY,mBAAmB;EACvCI,OAAO,EAAEJ;AACX,CAAC,CAAC","ignoreList":[]}
@@ -31,16 +31,17 @@ declare const removeListener: (event: CieEvent) => void;
31
31
  declare const removeAllListeners: () => void;
32
32
  /**
33
33
  * Sets a custom Identity Provider (IDP) URL for authentication.
34
- * If not set, will be used the default IDP URL:
35
- * https://idserver.servizicie.interno.gov.it/idp/
34
+ * If not set or set to undefined, will be used the default IDP URL:
35
+ * - iOS: https://idserver.servizicie.interno.gov.it/idp/Authn/SSL/Login2?
36
+ * - Android: https://idserver.servizicie.interno.gov.it/idp/
36
37
  *
37
- * @param url - The custom IDP URL to use
38
+ * @param url - The custom IDP URL to use or undefined to use the default IDP URL
38
39
  * @example
39
40
  * ```typescript
40
41
  * CieManager.setCustomIdpUrl('https://custom.idp.com/auth');
41
42
  * ```
42
43
  */
43
- declare const setCustomIdpUrl: (url: string) => any;
44
+ declare const setCustomIdpUrl: (url: string | undefined) => any;
44
45
  /**
45
46
  * Sets an alert message for the CIE reading process.
46
47
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/manager/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAMhF;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,WAAW,GAAI,CAAC,SAAS,QAAQ,EACrC,OAAO,CAAC,EACR,UAAU,gBAAgB,CAAC,CAAC,CAAC,eAI9B,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,cAAc,GAAI,OAAO,QAAQ,SAEtC,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,YAKvB,CAAC;AAEF;;;;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G;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,eAAe,EAAE,OAAO,MAAM,QAElE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,QAEnD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,sBAAsB,GAC1B,UAAS,MAAwB,KAChC,OAAO,CAAC,IAAI,CAEd,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,YAAY,GAChB,KAAK,MAAM,EACX,mBAAmB,MAAM,EACzB,UAAS,MAAwB,KAChC,OAAO,CAAC,IAAI,CAEd,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,WAAW,QAAa,OAAO,CAAC,IAAI,CAEzC,CAAC;AAEF,OAAO,EACL,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,WAAW,GACZ,CAAC"}
@@ -28,28 +28,27 @@ export declare const NfcErrorName: z.ZodEnum<["NOT_A_CIE", "TAG_LOST", "CANCELLE
28
28
  export type NfcErrorName = z.infer<typeof NfcErrorName>;
29
29
  /**
30
30
  * Represent an NFC error emitted during the CIE reading process
31
- * It contains the name of the error, the message and the number of attempts
32
31
  */
33
32
  export declare const NfcError: z.ZodUnion<[z.ZodObject<{
34
- name: z.ZodEnum<["NOT_A_CIE", "TAG_LOST", "CANCELLED_BY_USER", "APDU_ERROR", "WRONG_PIN", "CARD_BLOCKED", "NO_INTERNET_CONNECTION", "CERTIFICATE_EXPIRED", "CERTIFICATE_REVOKED", "AUTHENTICATION_ERROR", "GENERIC_ERROR"]>;
33
+ name: z.ZodEnum<["NOT_A_CIE", "TAG_LOST", "CANCELLED_BY_USER", "APDU_ERROR", "CARD_BLOCKED", "NO_INTERNET_CONNECTION", "CERTIFICATE_EXPIRED", "CERTIFICATE_REVOKED", "AUTHENTICATION_ERROR", "GENERIC_ERROR"]>;
35
34
  message: z.ZodOptional<z.ZodString>;
36
35
  }, "strip", z.ZodTypeAny, {
37
- name: "NOT_A_CIE" | "TAG_LOST" | "CANCELLED_BY_USER" | "APDU_ERROR" | "WRONG_PIN" | "CARD_BLOCKED" | "NO_INTERNET_CONNECTION" | "CERTIFICATE_EXPIRED" | "CERTIFICATE_REVOKED" | "AUTHENTICATION_ERROR" | "GENERIC_ERROR";
36
+ name: "NOT_A_CIE" | "TAG_LOST" | "CANCELLED_BY_USER" | "APDU_ERROR" | "CARD_BLOCKED" | "NO_INTERNET_CONNECTION" | "CERTIFICATE_EXPIRED" | "CERTIFICATE_REVOKED" | "AUTHENTICATION_ERROR" | "GENERIC_ERROR";
38
37
  message?: string | undefined;
39
38
  }, {
40
- name: "NOT_A_CIE" | "TAG_LOST" | "CANCELLED_BY_USER" | "APDU_ERROR" | "WRONG_PIN" | "CARD_BLOCKED" | "NO_INTERNET_CONNECTION" | "CERTIFICATE_EXPIRED" | "CERTIFICATE_REVOKED" | "AUTHENTICATION_ERROR" | "GENERIC_ERROR";
39
+ name: "NOT_A_CIE" | "TAG_LOST" | "CANCELLED_BY_USER" | "APDU_ERROR" | "CARD_BLOCKED" | "NO_INTERNET_CONNECTION" | "CERTIFICATE_EXPIRED" | "CERTIFICATE_REVOKED" | "AUTHENTICATION_ERROR" | "GENERIC_ERROR";
41
40
  message?: string | undefined;
42
41
  }>, z.ZodObject<{
43
- name: z.ZodLiteral<"WRONG_PIN">;
42
+ name: z.ZodEnum<["WRONG_PIN"]>;
44
43
  message: z.ZodOptional<z.ZodString>;
45
- attempts: z.ZodNumber;
44
+ attemptsLeft: z.ZodNumber;
46
45
  }, "strip", z.ZodTypeAny, {
47
46
  name: "WRONG_PIN";
48
- attempts: number;
47
+ attemptsLeft: number;
49
48
  message?: string | undefined;
50
49
  }, {
51
50
  name: "WRONG_PIN";
52
- attempts: number;
51
+ attemptsLeft: number;
53
52
  message?: string | undefined;
54
53
  }>]>;
55
54
  export type NfcError = z.infer<typeof NfcError>;
@@ -1 +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const getDefaultIdpUrl: () => string | undefined;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/manager/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,oDAAoD,CAAC;AAE9E,eAAO,MAAM,gBAAgB,0BAIzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/io-react-native-cie",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Native support for CIE",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
@@ -1,10 +1,11 @@
1
- import { NativeEventEmitter, NativeModules } from 'react-native';
1
+ import { NativeEventEmitter } from 'react-native';
2
2
  import { IoReactNativeCie } from '../native';
3
3
  import { AlertMessageKey, type CieEvent, type CieEventHandlers } from './types';
4
+ import { getDefaultIdpUrl } from './utils';
4
5
 
5
6
  const DEFAULT_TIMEOUT = 10000;
6
7
 
7
- const eventEmitter = new NativeEventEmitter(NativeModules.IoReactNativeCie);
8
+ const eventEmitter = new NativeEventEmitter(IoReactNativeCie);
8
9
 
9
10
  /**
10
11
  * Adds a listener for a specific CIE event.
@@ -54,17 +55,18 @@ const removeAllListeners = () => {
54
55
 
55
56
  /**
56
57
  * Sets a custom Identity Provider (IDP) URL for authentication.
57
- * If not set, will be used the default IDP URL:
58
- * https://idserver.servizicie.interno.gov.it/idp/
58
+ * If not set or set to undefined, will be used the default IDP URL:
59
+ * - iOS: https://idserver.servizicie.interno.gov.it/idp/Authn/SSL/Login2?
60
+ * - Android: https://idserver.servizicie.interno.gov.it/idp/
59
61
  *
60
- * @param url - The custom IDP URL to use
62
+ * @param url - The custom IDP URL to use or undefined to use the default IDP URL
61
63
  * @example
62
64
  * ```typescript
63
65
  * CieManager.setCustomIdpUrl('https://custom.idp.com/auth');
64
66
  * ```
65
67
  */
66
- const setCustomIdpUrl = (url: string) => {
67
- return IoReactNativeCie.setCustomIdpUrl(url);
68
+ const setCustomIdpUrl = (url: string | undefined) => {
69
+ return IoReactNativeCie.setCustomIdpUrl(url ?? getDefaultIdpUrl());
68
70
  };
69
71
 
70
72
  /**
@@ -52,17 +52,17 @@ export type NfcErrorName = z.infer<typeof NfcErrorName>;
52
52
 
53
53
  /**
54
54
  * Represent an NFC error emitted during the CIE reading process
55
- * It contains the name of the error, the message and the number of attempts
56
55
  */
57
56
  export const NfcError = z.union([
58
57
  z.object({
59
- name: NfcErrorName,
58
+ name: NfcErrorName.exclude(['WRONG_PIN']),
60
59
  message: z.string().optional(),
61
60
  }),
61
+ // WRONG_PIN error also contains the number of attempts left
62
62
  z.object({
63
- name: z.literal(NfcErrorName.enum.WRONG_PIN),
63
+ name: NfcErrorName.extract(['WRONG_PIN']),
64
64
  message: z.string().optional(),
65
- attempts: z.number(),
65
+ attemptsLeft: z.number(),
66
66
  }),
67
67
  ]);
68
68
 
@@ -0,0 +1,9 @@
1
+ import { Platform } from 'react-native';
2
+
3
+ export const BASE_IDP_URL = 'https://idserver.servizicie.interno.gov.it/idp/';
4
+
5
+ export const getDefaultIdpUrl = () =>
6
+ Platform.select({
7
+ ios: `${BASE_IDP_URL}Authn/SSL/Login2?`,
8
+ android: BASE_IDP_URL,
9
+ });