@icedevml/react-native-host-card-emulation 0.2.1 → 0.2.2

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
@@ -11,7 +11,92 @@ Host Card Emulation Module for React Native on iOS and Android platforms.
11
11
  > [!NOTE]
12
12
  > Kindly please reference this project in your README if you are willing to create a derivative library.
13
13
 
14
+ ## Prerequisites
15
+ ### iOS
16
+ 1. Ensure that you are enrolled as organization (not individual) in Apple Developer Program, and that you are established in the European Economic Area (EEA).
17
+ 2. Ensure that you meet other [non-technical requirements imposed by Apple](https://developer.apple.com/support/hce-transactions-in-apps/#requirements-and-availability).
18
+ 3. Find out the Bundle ID of your existing application or [register a new Bundle ID](https://developer.apple.com/account/resources/identifiers/bundleId/add/bundle).
19
+ 4. [Request the HCE Entitlement](https://developer.apple.com/contact/request/hce-entitlement/) for your application's bundle ID.
20
+ 5. Wait until the entitlement is approved by Apple.
21
+
22
+ ### Android
23
+ *(no prerequisite steps are required for Android)*
24
+
25
+ ## Installation
26
+ Install `@icedevml/react-native-host-card-emulation` package within your React Native project. Then, follow the subsections below for each platform that you need to support.
27
+
28
+ ### iOS
29
+ 1. Make sure to set up a proper signing team and bundle identifier in "Signing & Capabilities" configuration section of your project.
30
+ 2. Add Host Card Emulation (HCE) entitlement with desired AIDs. This could be done either through XCode (by clicking "+ Capability") or within the entitlements XML file directly. Example:
31
+ ```xml
32
+ <?xml version="1.0" encoding="UTF-8"?>
33
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
34
+ <plist version="1.0">
35
+ <dict>
36
+ <key>com.apple.developer.nfc.hce</key>
37
+ <true/>
38
+ <key>com.apple.developer.nfc.hce.iso7816.select-identifier-prefixes</key>
39
+ <array>
40
+ <string>F001020304</string>
41
+ <string>F00102030405</string>
42
+ <string>F0010203040506</string>
43
+ </array>
44
+ </dict>
45
+ </plist>
46
+ ```
47
+ Replace `F001020304`, `F00102030405`, `F0010203040506` with the ISO7816 AIDs that you want to support.
48
+ 3. In the `ios/` app's subdirectory, run `bundle install && bundle exec pod install`.
49
+
50
+ ### Android
51
+ 1. In `android/app/src/main/AndroidManifest.xml` add:
52
+ ```diff
53
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
54
+ ...
55
+
56
+ + <uses-permission android:name="android.permission.NFC" />
57
+ + <uses-feature android:name="android.hardware.nfc.hce" android:required="true" />
58
+
59
+ ...
60
+
61
+ <application
62
+ ...
63
+ >
64
+
65
+ ...
66
+
67
+ + <service
68
+ + android:name="com.itsecrnd.rtnhceandroid.HCEService"
69
+ + android:exported="true"
70
+ + android:enabled="true"
71
+ + android:permission="android.permission.BIND_NFC_SERVICE" >
72
+ + <intent-filter>
73
+ + <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
74
+ + <category android:name="android.intent.category.DEFAULT"/>
75
+ + </intent-filter>
76
+ +
77
+ + <meta-data
78
+ + android:name="android.nfc.cardemulation.host_apdu_service"
79
+ + android:resource="@xml/aid_list" />
80
+ + </service>
81
+ </application>
82
+ </manifest>
83
+ ```
84
+ 2. Create file `android/app/src/main/res/xml/aid_list.xml`:
85
+ ```xml
86
+ <host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
87
+ android:description="@string/app_name"
88
+ android:requireDeviceUnlock="false">
89
+ <aid-group android:category="other"
90
+ android:description="@string/app_name">
91
+ <aid-filter android:name="F001020304" />
92
+ <aid-filter android:name="F00102030405" />
93
+ <aid-filter android:name="F0010203040506" />
94
+ </aid-group>
95
+ </host-apdu-service>
96
+ ```
97
+ Replace `F001020304`, `F00102030405`, `F0010203040506` with the ISO7816 AIDs that you want to support.
98
+
14
99
  ## API Specification & Demo App
15
100
 
16
- * [module API (declarations)](https://github.com/icedevml/react-native-host-card-emulation/blob/master/packages/react-native-hce-module/js/NativeHCEModule.ts)
17
- * [demo app's code (example usage)](https://github.com/icedevml/react-native-host-card-emulation/blob/master/packages/demo-hce-module-ios-app/App.tsx)
101
+ * [module API (declarations)](https://github.com/icedevml/react-native-host-card-emulation/blob/master/packages/native-hce-module/js/NativeHCEModule.ts)
102
+ * [demo app's code (example usage)](https://github.com/icedevml/react-native-host-card-emulation/blob/master/packages/demo-hce-module-app/App.tsx)
@@ -1,11 +1,11 @@
1
1
  import type {TurboModule, CodegenTypes} from 'react-native';
2
2
  import {TurboModuleRegistry} from 'react-native';
3
3
 
4
- export type HCEModuleIOSEventType = 'sessionStarted' | 'readerDetected' | 'readerDeselected' | 'received' | 'sessionInvalidated';
5
- export type HCEModuleIOSStopReason = 'success' | 'failure';
4
+ export type HCEModuleEventType = 'sessionStarted' | 'readerDetected' | 'readerDeselected' | 'received' | 'sessionInvalidated';
5
+ export type HCEModuleStopReason = 'success' | 'failure';
6
6
 
7
- export type HCEModuleIOSEvent = {
8
- type: HCEModuleIOSEventType
7
+ export type HCEModuleEvent = {
8
+ type: HCEModuleEventType
9
9
  arg: string | null,
10
10
  }
11
11
 
@@ -21,11 +21,11 @@ export interface Spec extends TurboModule {
21
21
  isSessionRunning(): boolean;
22
22
 
23
23
  startHCE(): Promise<void>;
24
- stopHCE(status: HCEModuleIOSStopReason): Promise<void>;
24
+ stopHCE(status: HCEModuleStopReason): Promise<void>;
25
25
  respondAPDU(rapdu: string): Promise<void>;
26
26
  isHCERunning(): Promise<boolean>;
27
27
 
28
- readonly onEvent: CodegenTypes.EventEmitter<HCEModuleIOSEvent>;
28
+ readonly onEvent: CodegenTypes.EventEmitter<HCEModuleEvent>;
29
29
  }
30
30
 
31
31
  export default TurboModuleRegistry.getEnforcing<Spec>(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icedevml/react-native-host-card-emulation",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Host Card Emulation (HCE) React Native Turbo Module for iOS and Android platforms.",
5
5
  "react-native": "js/index",
6
6
  "source": "js/index",