@pagopa/io-react-native-iso18013 0.6.0 → 0.8.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.
Files changed (37) hide show
  1. package/IoReactNativeIso18013.podspec +1 -1
  2. package/README.md +1 -1
  3. package/android/build.gradle +3 -2
  4. package/android/src/main/AndroidManifest.xml +17 -0
  5. package/android/src/main/AndroidManifestNew.xml +17 -0
  6. package/android/src/main/java/com/ioreactnativeiso18013/Enums.kt +42 -0
  7. package/android/src/main/java/com/ioreactnativeiso18013/IoNfcEngagementService.kt +17 -0
  8. package/android/src/main/java/com/ioreactnativeiso18013/IoReactNativeIso18013Module.kt +329 -137
  9. package/android/src/main/res/values/strings.xml +5 -0
  10. package/android/src/main/res/xml/nfc_engagement_apdu_service.xml +9 -0
  11. package/android/src/test/java/com/ioreactnativeiso18013/IoReactNativeIso18013Test.kt +11 -13
  12. package/ios/IoReactNativeIso18013.mm +8 -9
  13. package/ios/IoReactNativeIso18013.swift +264 -191
  14. package/lib/module/cbor/cbor/README.md +2 -1
  15. package/lib/module/cbor/cose/README.md +6 -4
  16. package/lib/module/iso18013/iso18013-5/README.md +161 -41
  17. package/lib/module/iso18013/iso18013-5/error.js +1 -3
  18. package/lib/module/iso18013/iso18013-5/error.js.map +1 -1
  19. package/lib/module/iso18013/iso18013-5/index.js +1 -1
  20. package/lib/module/iso18013/iso18013-5/index.js.map +1 -1
  21. package/lib/module/iso18013/iso18013-5/proximity.js +29 -19
  22. package/lib/module/iso18013/iso18013-5/proximity.js.map +1 -1
  23. package/lib/module/iso18013/iso18013-7/README.md +1 -1
  24. package/lib/typescript/src/iso18013/iso18013-5/error.d.ts +4 -4
  25. package/lib/typescript/src/iso18013/iso18013-5/error.d.ts.map +1 -1
  26. package/lib/typescript/src/iso18013/iso18013-5/index.d.ts +1 -1
  27. package/lib/typescript/src/iso18013/iso18013-5/index.d.ts.map +1 -1
  28. package/lib/typescript/src/iso18013/iso18013-5/proximity.d.ts +32 -13
  29. package/lib/typescript/src/iso18013/iso18013-5/proximity.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/src/cbor/cbor/README.md +2 -1
  32. package/src/cbor/cose/README.md +6 -4
  33. package/src/iso18013/iso18013-5/README.md +161 -41
  34. package/src/iso18013/iso18013-5/error.ts +0 -2
  35. package/src/iso18013/iso18013-5/index.ts +3 -2
  36. package/src/iso18013/iso18013-5/proximity.ts +52 -23
  37. package/src/iso18013/iso18013-7/README.md +1 -1
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
 
18
18
  # Module dependencies
19
19
  s.dependency "IOWalletCBOR", "0.2.1"
20
- s.dependency "IOWalletProximity", "1.3.0"
20
+ s.dependency "IOWalletProximity", "1.4.1"
21
21
 
22
22
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
23
23
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
package/README.md CHANGED
@@ -13,7 +13,7 @@ npm install @pagopa/io-react-native-iso18013
13
13
  This library includes two native modules for both iOS and Android:
14
14
 
15
15
  - [IoReactNativeIso18013](src/iso18013/iso18013-5/proximity.ts) for ISO 18013-5 and ISO 18013-7 implementations;
16
- - [IoReactNativeCbor](src/cbor/cbor.ts) for CBOR and COSE implementations.
16
+ - [IoReactNativeCbor](src/cbor/index.ts) for CBOR and COSE implementations.
17
17
 
18
18
  On the javascript side, the library exposes the following modules:
19
19
 
@@ -83,7 +83,8 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
83
83
  dependencies {
84
84
  implementation "com.facebook.react:react-android"
85
85
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
86
- implementation "it.pagopa.io.wallet.proximity:proximity:2.2.0"
87
- implementation "it.pagopa.io.wallet.cbor:cbor:1.3.0"
86
+ implementation "it.pagopa.io.wallet.proximity:proximity:2.4.1"
87
+ implementation "it.pagopa.io.wallet.cbor:cbor:1.4.1"
88
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
88
89
  testImplementation('junit:junit:4.13.2')
89
90
  }
@@ -1,3 +1,20 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
2
  package="com.ioreactnativeiso18013">
3
+ <uses-permission android:name="android.permission.NFC" />
4
+ <uses-feature android:name="android.hardware.nfc.hce" android:required="false" />
5
+
6
+ <application>
7
+ <service
8
+ android:name="com.ioreactnativeiso18013.IoNfcEngagementService"
9
+ android:exported="true"
10
+ android:permission="android.permission.BIND_NFC_SERVICE">
11
+ <intent-filter>
12
+ <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
13
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
14
+ </intent-filter>
15
+ <meta-data
16
+ android:name="android.nfc.cardemulation.host_apdu_service"
17
+ android:resource="@xml/nfc_engagement_apdu_service" />
18
+ </service>
19
+ </application>
3
20
  </manifest>
@@ -1,2 +1,19 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.NFC" />
3
+ <uses-feature android:name="android.hardware.nfc.hce" android:required="false" />
4
+
5
+ <application>
6
+ <service
7
+ android:name="com.ioreactnativeiso18013.IoNfcEngagementService"
8
+ android:exported="true"
9
+ android:permission="android.permission.BIND_NFC_SERVICE">
10
+ <intent-filter>
11
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
12
+ <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
13
+ </intent-filter>
14
+ <meta-data
15
+ android:name="android.nfc.cardemulation.host_apdu_service"
16
+ android:resource="@xml/nfc_engagement_apdu_service" />
17
+ </service>
18
+ </application>
2
19
  </manifest>
@@ -0,0 +1,42 @@
1
+ package com.ioreactnativeiso18013
2
+
3
+ import com.facebook.react.bridge.ReadableArray
4
+
5
+ internal enum class EngagementMode(val bridgeValue: String) {
6
+ QR_CODE("qrcode"),
7
+ NFC("nfc");
8
+
9
+ companion object {
10
+ fun fromBridgeValue(value: String): EngagementMode =
11
+ entries.firstOrNull { it.bridgeValue == value.lowercase() }
12
+ ?: throw IllegalArgumentException("Invalid retrieval method: '$value'. Expected 'ble' or 'nfc'.")
13
+ }
14
+ }
15
+
16
+ internal fun parseEngagementModes(engagementModes: ReadableArray): List<EngagementMode> {
17
+ if (engagementModes.size() == 0) return listOf(EngagementMode.QR_CODE)
18
+ return (0 until engagementModes.size()).map { index ->
19
+ val method = engagementModes.getString(index)
20
+ ?: throw IllegalArgumentException("Engagement mode at index $index is null")
21
+ EngagementMode.fromBridgeValue(method)
22
+ }
23
+ }
24
+ internal enum class RetrievalMethod(val bridgeValue: String) {
25
+ BLE("ble"),
26
+ NFC("nfc");
27
+
28
+ companion object {
29
+ fun fromBridgeValue(value: String): RetrievalMethod =
30
+ entries.firstOrNull { it.bridgeValue == value.lowercase() }
31
+ ?: throw IllegalArgumentException("Invalid retrieval method: '$value'. Expected 'ble' or 'nfc'.")
32
+ }
33
+ }
34
+
35
+ internal fun parseRetrievalMethods(retrievalMethods: ReadableArray): List<RetrievalMethod> {
36
+ if (retrievalMethods.size() == 0) return listOf(RetrievalMethod.BLE)
37
+ return (0 until retrievalMethods.size()).map { index ->
38
+ val method = retrievalMethods.getString(index)
39
+ ?: throw IllegalArgumentException("Retrieval method at index $index is null")
40
+ RetrievalMethod.fromBridgeValue(method)
41
+ }
42
+ }
@@ -0,0 +1,17 @@
1
+ package com.ioreactnativeiso18013
2
+
3
+ import it.pagopa.io.wallet.proximity.nfc.NfcEngagementService
4
+
5
+ /**
6
+ * Concrete subclass of [NfcEngagementService] (which itself extends [android.nfc.cardemulation.HostApduService]).
7
+ *
8
+ * This class intentionally lives in its own file and contains no logic.
9
+ * Android components declared in AndroidManifest.xml must be top-level, named classes so the
10
+ * system can instantiate them by their fully-qualified name via reflection. Registering an
11
+ * anonymous object or an inner class in the manifest is not supported.
12
+ *
13
+ * All NFC engagement logic is handled by the library's [NfcEngagementService] base class and
14
+ * events are surfaced through [it.pagopa.io.wallet.proximity.nfc.NfcEngagementEventBus].
15
+ * See [IoReactNativeIso18013Module.setupNfcHandler] for the event handling.
16
+ */
17
+ class IoNfcEngagementService : NfcEngagementService()