@animo-id/expo-mdoc-data-transfer 0.0.1-alpha.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/.github/workflows/ci.yaml +86 -0
  2. package/LICENSE +201 -0
  3. package/README.md +35 -0
  4. package/android/build.gradle +57 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/java/id/animo/mdocdatatransfer/MdocDataTransfer.kt +88 -0
  7. package/android/src/main/java/id/animo/mdocdatatransfer/MdocDataTransferEvent.kt +6 -0
  8. package/android/src/main/java/id/animo/mdocdatatransfer/MdocDataTransferException.kt +5 -0
  9. package/android/src/main/java/id/animo/mdocdatatransfer/MdocDataTransferManager.kt +35 -0
  10. package/android/src/main/java/id/animo/mdocdatatransfer/MdocDataTransferModule.kt +59 -0
  11. package/android/src/main/java/id/animo/mdocdatatransfer/NfcEngagementServiceImpl.kt +8 -0
  12. package/app.plugin.js +1 -0
  13. package/build/MdocDataTransfer.d.ts +14 -0
  14. package/build/MdocDataTransfer.d.ts.map +1 -0
  15. package/build/MdocDataTransfer.js +41 -0
  16. package/build/MdocDataTransfer.js.map +1 -0
  17. package/build/MdocDataTransferEvent.d.ts +9 -0
  18. package/build/MdocDataTransferEvent.d.ts.map +1 -0
  19. package/build/MdocDataTransferEvent.js +6 -0
  20. package/build/MdocDataTransferEvent.js.map +1 -0
  21. package/build/MdocDataTransferModule.d.ts +10 -0
  22. package/build/MdocDataTransferModule.d.ts.map +1 -0
  23. package/build/MdocDataTransferModule.js +4 -0
  24. package/build/MdocDataTransferModule.js.map +1 -0
  25. package/build/index.d.ts +2 -0
  26. package/build/index.d.ts.map +1 -0
  27. package/build/index.js +2 -0
  28. package/build/index.js.map +1 -0
  29. package/expo-module.config.json +9 -0
  30. package/ios/MdocDataTransfer.podspec +27 -0
  31. package/ios/MdocDataTransferModule.swift +44 -0
  32. package/ios/MdocDataTransferView.swift +7 -0
  33. package/package.json +46 -0
  34. package/plugin/build/index.d.ts +3 -0
  35. package/plugin/build/index.js +8 -0
  36. package/plugin/build/withAndroid.d.ts +2 -0
  37. package/plugin/build/withAndroid.js +77 -0
@@ -0,0 +1,86 @@
1
+ name: Pipeline
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ pull_request:
9
+
10
+ workflow_dispatch:
11
+ inputs:
12
+ release-type:
13
+ description: "Type of release (major, minor, patch, alpha)"
14
+ required: true
15
+ default: alpha
16
+ type: choice
17
+ options:
18
+ - major
19
+ - minor
20
+ - patch
21
+ - alpha
22
+
23
+ jobs:
24
+ continuous-integration:
25
+ name: "Continuous Integration"
26
+ runs-on: ubuntu-latest
27
+
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+
31
+ - uses: pnpm/action-setup@v4
32
+ with:
33
+ version: 9
34
+
35
+ - name: Install dependencies
36
+ run: pnpm install
37
+
38
+ - name: Style
39
+ run: pnpm style:check
40
+
41
+ - name: Build
42
+ run: pnpm build
43
+
44
+ - name: Check types
45
+ run: pnpm types:check
46
+
47
+ continuous-deployment:
48
+ if: github.event_name == 'workflow_dispatch'
49
+
50
+ name: 'Continuous Deployment'
51
+ runs-on: ubuntu-latest
52
+ needs: ['continuous-integration']
53
+
54
+ steps:
55
+ - uses: actions/checkout@v4
56
+ with:
57
+ fetch-depth: 0
58
+
59
+ - uses: pnpm/action-setup@v4
60
+ with:
61
+ version: 9
62
+
63
+ - name: Install dependencies
64
+ run: pnpm install
65
+
66
+ - name: Build
67
+ run: pnpm build
68
+
69
+ - name: Set git configuration
70
+ run: |
71
+ git config user.name "Animo Solutions"
72
+ git config user.email "development@animo.id"
73
+
74
+ - name: Publish
75
+ id: publish
76
+ env:
77
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
78
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79
+ run: |
80
+ npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
81
+
82
+ if [ ${{ inputs.release-type }} == 'alpha' ]; then
83
+ pnpm release --preRelease=alpha
84
+ else
85
+ pnpm release -i=${{ inputs.release-type }}
86
+ fi
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2023-present Animo Solutions
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @animo-id/mdoc-data-transfer
2
+
3
+ mdoc data transfer module
4
+
5
+ # API documentation
6
+
7
+ - [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/@animo-id/expo-mdoc-data-transfer.md)
8
+ - [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/@animo-id/expo-mdoc-data-transfer/)
9
+
10
+ # Installation in managed Expo projects
11
+
12
+ For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
13
+
14
+ # Installation in bare React Native projects
15
+
16
+ For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
17
+
18
+ ### Add the package to your npm dependencies
19
+
20
+ ```
21
+ npm install @animo-id/expo-mdoc-data-transfer
22
+ ```
23
+
24
+ ### Configure for iOS
25
+
26
+ Run `npx pod-install` after installing the npm package.
27
+
28
+
29
+ ### Configure for Android
30
+
31
+
32
+
33
+ # Contributing
34
+
35
+ Contributions are very welcome! Please refer to guidelines described in the [contributing guide]( https://github.com/expo/expo#contributing).
@@ -0,0 +1,57 @@
1
+ apply plugin: 'com.android.library'
2
+
3
+ group = 'id.animo.mdocdatatransfer'
4
+ version = '0.1.0'
5
+
6
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
+ apply from: expoModulesCorePlugin
8
+ applyKotlinExpoModulesCorePlugin()
9
+ useCoreDependencies()
10
+ useExpoPublishing()
11
+
12
+ // If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
13
+ // The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
14
+ // Most of the time, you may like to manage the Android SDK versions yourself.
15
+ def useManagedAndroidSdkVersions = false
16
+ if (useManagedAndroidSdkVersions) {
17
+ useDefaultAndroidSdkVersions()
18
+ } else {
19
+ buildscript {
20
+ // Simple helper that allows the root project to override versions declared by this library.
21
+ ext.safeExtGet = { prop, fallback ->
22
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
23
+ }
24
+ }
25
+ project.android {
26
+ compileSdkVersion safeExtGet("compileSdkVersion", 34)
27
+ defaultConfig {
28
+ minSdkVersion safeExtGet("minSdkVersion", 26)
29
+ targetSdkVersion safeExtGet("targetSdkVersion", 34)
30
+ }
31
+ }
32
+ }
33
+
34
+ android {
35
+ namespace "id.animo.mdocdatatransfer"
36
+ defaultConfig {
37
+ versionCode 1
38
+ versionName "0.1.0"
39
+ }
40
+ lintOptions {
41
+ abortOnError false
42
+ }
43
+ }
44
+
45
+
46
+ dependencies {
47
+ implementation("eu.europa.ec.eudi:eudi-lib-android-iso18013-data-transfer:0.3.0-SNAPSHOT") {
48
+ exclude group: 'org.bouncycastle'
49
+ exclude module: 'bcprov-jdk18on'
50
+ }
51
+ implementation("org.bouncycastle:bcprov-jdk18on") {
52
+ version {
53
+ strictly '1.72'
54
+ }
55
+ }
56
+ implementation "androidx.biometric:biometric-ktx:1.2.0-alpha05"
57
+ }
@@ -0,0 +1 @@
1
+ <manifest></manifest>
@@ -0,0 +1,88 @@
1
+ package id.animo.mdocdatatransfer
2
+
3
+ import android.app.Activity
4
+ import android.content.Context
5
+ import android.util.Log
6
+ import androidx.activity.ComponentActivity
7
+ import eu.europa.ec.eudi.iso18013.transfer.TransferEvent
8
+ import eu.europa.ec.eudi.iso18013.transfer.engagement.NfcEngagementService
9
+ import eu.europa.ec.eudi.iso18013.transfer.response.DeviceRequest
10
+
11
+ class MdocDataTransfer(
12
+ context: Context,
13
+ private val currentActivity: Activity,
14
+ sendEvent: (name: String, body: Map<String, Any?>?) -> Unit
15
+ ) {
16
+ companion object {
17
+ private val TAG = Companion::class.java.simpleName
18
+ }
19
+
20
+ init {
21
+ MdocDataTransferManager.init(context)
22
+
23
+ val transferEventListener = TransferEvent.Listener { event ->
24
+ when (event) {
25
+ is TransferEvent.QrEngagementReady -> {
26
+ Log.d(TAG, ":::mdoc-data-transfer::: TransferEvent.QrEngagementReady")
27
+ onQrEngagementReady?.let { it(event.qrCode.content) }
28
+ }
29
+
30
+ is TransferEvent.Connecting -> {
31
+ Log.d(TAG, ":::mdoc-data-transfer::: TransferEvent.Connecting")
32
+ }
33
+
34
+ is TransferEvent.Connected -> {
35
+ Log.d(TAG, ":::mdoc-data-transfer::: TransferEvent.Connected")
36
+ }
37
+
38
+ is TransferEvent.Disconnected -> {
39
+ Log.d(TAG, ":::mdoc-data-transfer::: TransferEvent.Disconnected")
40
+ }
41
+
42
+ is TransferEvent.Error -> {
43
+ Log.d(TAG, ":::mdoc-data-transfer::: TransferEvent.Error")
44
+ }
45
+
46
+ is TransferEvent.Redirect -> {
47
+ Log.d(TAG, ":::mdoc-data-transfer::: TransferEvent.Redirect")
48
+ }
49
+
50
+ is TransferEvent.RequestReceived -> {
51
+ Log.d(TAG, ":::mdoc-data-transfer::: TransferEvent.RequestReceived")
52
+ when (val request = event.request) {
53
+ is DeviceRequest -> {
54
+ sendEvent(
55
+ MdocDataTransferEvent.ON_REQUEST_RECEIVED,
56
+ mapOf(("deviceRequest" to request.deviceRequestBytes.asList()))
57
+ )
58
+ }
59
+ }
60
+ }
61
+
62
+ is TransferEvent.ResponseSent -> {
63
+ Log.d(TAG, ":::mdoc-data-transfer::: TransferEvent.ResponseSent")
64
+ sendEvent(
65
+ MdocDataTransferEvent.ON_RESPONSE_SENT,
66
+ null
67
+ )
68
+ }
69
+ }
70
+ }
71
+
72
+ MdocDataTransferManager.transferManager.value.addTransferEventListener(transferEventListener)
73
+ }
74
+
75
+ var onQrEngagementReady: ((qrCode: String) -> Unit)? = null
76
+
77
+ fun startQrEngagement() {
78
+ MdocDataTransferManager.transferManager.value.startQrEngagement()
79
+ }
80
+
81
+ fun respond(deviceResponse: ByteArray) {
82
+ MdocDataTransferManager.transferManager.value.sendResponse(deviceResponse)
83
+ }
84
+
85
+ fun shutdown() {
86
+ NfcEngagementService.disable(currentActivity as ComponentActivity)
87
+ }
88
+ }
@@ -0,0 +1,6 @@
1
+ package id.animo.mdocdatatransfer
2
+
3
+ object MdocDataTransferEvent {
4
+ const val ON_REQUEST_RECEIVED = "onRequestReceived"
5
+ const val ON_RESPONSE_SENT = "onResponseSent"
6
+ }
@@ -0,0 +1,5 @@
1
+ package id.animo.mdocdatatransfer
2
+
3
+ class MdocDataTransferException {
4
+ class NotInitialized : Exception("MdocDataTransfer class was not initialized")
5
+ }
@@ -0,0 +1,35 @@
1
+ package id.animo.mdocdatatransfer
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import android.util.Log
6
+ import eu.europa.ec.eudi.iso18013.transfer.DocumentsResolver
7
+ import eu.europa.ec.eudi.iso18013.transfer.TransferManager
8
+ import eu.europa.ec.eudi.iso18013.transfer.response.ResponseGenerator
9
+ import eu.europa.ec.eudi.iso18013.transfer.retrieval.BleRetrievalMethod
10
+
11
+ @SuppressLint("StaticFieldLeak")
12
+ object MdocDataTransferManager {
13
+ @Volatile
14
+ private lateinit var context: Context
15
+
16
+ fun init(context: Context) {
17
+ this.context = context
18
+ }
19
+
20
+ val transferManager = lazy {
21
+ TransferManager.Builder(context).apply {
22
+ retrievalMethods = listOf(
23
+ BleRetrievalMethod(
24
+ peripheralServerMode = true,
25
+ centralClientMode = true,
26
+ clearBleCache = true
27
+ )
28
+ )
29
+ responseGenerator = ResponseGenerator.Builder(context)
30
+ .apply {
31
+ documentsResolver = DocumentsResolver { listOf() }
32
+ }.build()
33
+ }.build()
34
+ }
35
+ }
@@ -0,0 +1,59 @@
1
+ package id.animo.mdocdatatransfer
2
+
3
+ import expo.modules.kotlin.Promise
4
+ import expo.modules.kotlin.exception.Exceptions
5
+ import expo.modules.kotlin.modules.Module
6
+ import expo.modules.kotlin.modules.ModuleDefinition
7
+ import org.bouncycastle.jce.provider.BouncyCastleProvider
8
+ import java.security.Security
9
+
10
+ class MdocDataTransferModule : Module() {
11
+ override fun definition() = ModuleDefinition {
12
+ var mDocDataTransfer: MdocDataTransfer? = null
13
+
14
+ Name("MdocDataTransfer")
15
+
16
+ Events(
17
+ MdocDataTransferEvent.ON_REQUEST_RECEIVED,
18
+ MdocDataTransferEvent.ON_RESPONSE_SENT
19
+ )
20
+
21
+ Function("initialize") {
22
+ // We have to re-set the Bouncy Castle provider, otherwise the EUDI library cannot find it correctly
23
+ Security.removeProvider("BC")
24
+ Security.addProvider(BouncyCastleProvider())
25
+ mDocDataTransfer = MdocDataTransfer(
26
+ appContext.reactContext ?: throw Exceptions.ReactContextLost(),
27
+ appContext.currentActivity ?: throw Exceptions.MissingActivity()
28
+ ) { name: String, body: Map<String, Any?>? ->
29
+ sendEvent(
30
+ name,
31
+ body ?: mapOf()
32
+ )
33
+ }
34
+
35
+ return@Function null
36
+ }
37
+
38
+
39
+ AsyncFunction("startQrEngagement") { promise: Promise ->
40
+ mDocDataTransfer?.apply {
41
+ onQrEngagementReady = { qrCode ->
42
+ promise.resolve(qrCode)
43
+ onQrEngagementReady = null
44
+ }
45
+ startQrEngagement()
46
+ } ?: throw MdocDataTransferException.NotInitialized()
47
+ }
48
+
49
+ Function("sendDeviceResponse") { deviceResponse: ByteArray ->
50
+ (mDocDataTransfer ?: throw MdocDataTransferException.NotInitialized()).respond(
51
+ deviceResponse
52
+ )
53
+ }
54
+
55
+ Function("shutdown") {
56
+ (mDocDataTransfer ?: throw MdocDataTransferException.NotInitialized()).shutdown()
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,8 @@
1
+ package id.animo.mdocdatatransfer
2
+
3
+ import eu.europa.ec.eudi.iso18013.transfer.TransferManager
4
+ import eu.europa.ec.eudi.iso18013.transfer.engagement.NfcEngagementService
5
+
6
+ class NfcEngagementServiceImpl : NfcEngagementService() {
7
+ override val transferManager: TransferManager get() = MdocDataTransferManager.transferManager.value
8
+ }
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build/index.js')
@@ -0,0 +1,14 @@
1
+ export declare const mdocDataTransfer: {
2
+ instance: () => MdocDataTransfer;
3
+ };
4
+ declare class MdocDataTransfer {
5
+ static initialize(): MdocDataTransfer;
6
+ startQrEngagement(): Promise<string>;
7
+ private onDeviceRequest;
8
+ private onResponseSent;
9
+ waitForDeviceRequest(): Promise<Uint8Array>;
10
+ sendDeviceResponse(deviceResponse: Uint8Array): Promise<void>;
11
+ shutdown(): void;
12
+ }
13
+ export {};
14
+ //# sourceMappingURL=MdocDataTransfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdocDataTransfer.d.ts","sourceRoot":"","sources":["../src/MdocDataTransfer.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,gBAAgB;;CAK5B,CAAA;AAED,cAAM,gBAAgB;WACN,UAAU;IAMX,iBAAiB;IAI9B,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,cAAc;IAIT,oBAAoB;IAIpB,kBAAkB,CAAC,cAAc,EAAE,UAAU;IAMnD,QAAQ;CAIhB"}
@@ -0,0 +1,41 @@
1
+ import { MdocDataTransferEvent, } from './MdocDataTransferEvent';
2
+ import { mDocNativeModule, mDocNativeModuleEventEmitter } from './MdocDataTransferModule';
3
+ let instance = undefined;
4
+ export const mdocDataTransfer = {
5
+ instance: () => {
6
+ if (instance)
7
+ return instance;
8
+ return MdocDataTransfer.initialize();
9
+ },
10
+ };
11
+ class MdocDataTransfer {
12
+ static initialize() {
13
+ mDocNativeModule.initialize();
14
+ instance = new MdocDataTransfer();
15
+ return instance;
16
+ }
17
+ async startQrEngagement() {
18
+ return await mDocNativeModule.startQrEngagement();
19
+ }
20
+ onDeviceRequest(cb) {
21
+ return mDocNativeModuleEventEmitter.addListener(MdocDataTransferEvent.OnRequestReceived, (payload) => cb({
22
+ deviceRequest: new Uint8Array(payload.deviceRequest),
23
+ }));
24
+ }
25
+ onResponseSent(cb) {
26
+ return mDocNativeModuleEventEmitter.addListener(MdocDataTransferEvent.OnRequestReceived, cb);
27
+ }
28
+ async waitForDeviceRequest() {
29
+ return (await new Promise(this.onDeviceRequest)).deviceRequest;
30
+ }
31
+ async sendDeviceResponse(deviceResponse) {
32
+ const p = new Promise(this.onResponseSent);
33
+ mDocNativeModule.sendDeviceResponse(deviceResponse);
34
+ await p;
35
+ }
36
+ shutdown() {
37
+ mDocNativeModule.shutdown();
38
+ instance = undefined;
39
+ }
40
+ }
41
+ //# sourceMappingURL=MdocDataTransfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdocDataTransfer.js","sourceRoot":"","sources":["../src/MdocDataTransfer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAGtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA;AAEzF,IAAI,QAAQ,GAAiC,SAAS,CAAA;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,GAAG,EAAE;QACb,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAA;QAC7B,OAAO,gBAAgB,CAAC,UAAU,EAAE,CAAA;IACtC,CAAC;CACF,CAAA;AAED,MAAM,gBAAgB;IACb,MAAM,CAAC,UAAU;QACtB,gBAAgB,CAAC,UAAU,EAAE,CAAA;QAC7B,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAA;QACjC,OAAO,QAAQ,CAAA;IACjB,CAAC;IAEM,KAAK,CAAC,iBAAiB;QAC5B,OAAO,MAAM,gBAAgB,CAAC,iBAAiB,EAAE,CAAA;IACnD,CAAC;IAEO,eAAe,CAAC,EAAgF;QACtG,OAAO,4BAA4B,CAAC,WAAW,CAC7C,qBAAqB,CAAC,iBAAiB,EACvC,CAAC,OAAO,EAAE,EAAE,CACV,EAAE,CAAC;YACD,aAAa,EAAE,IAAI,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC;SACrD,CAAC,CACL,CAAA;IACH,CAAC;IAEO,cAAc,CAAC,EAA4D;QACjF,OAAO,4BAA4B,CAAC,WAAW,CAAwB,qBAAqB,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAA;IACrH,CAAC;IAEM,KAAK,CAAC,oBAAoB;QAC/B,OAAO,CAAC,MAAM,IAAI,OAAO,CAA4C,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAA;IAC3G,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,cAA0B;QACxD,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QAC1C,gBAAgB,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAA;QACnD,MAAM,CAAC,CAAA;IACT,CAAC;IAEM,QAAQ;QACb,gBAAgB,CAAC,QAAQ,EAAE,CAAA;QAC3B,QAAQ,GAAG,SAAS,CAAA;IACtB,CAAC;CACF","sourcesContent":["import {\n MdocDataTransferEvent,\n type OnRequestReceivedEventPayload,\n type OnResponseSendPayload,\n} from './MdocDataTransferEvent'\nimport { mDocNativeModule, mDocNativeModuleEventEmitter } from './MdocDataTransferModule'\n\nlet instance: MdocDataTransfer | undefined = undefined\nexport const mdocDataTransfer = {\n instance: () => {\n if (instance) return instance\n return MdocDataTransfer.initialize()\n },\n}\n\nclass MdocDataTransfer {\n public static initialize() {\n mDocNativeModule.initialize()\n instance = new MdocDataTransfer()\n return instance\n }\n\n public async startQrEngagement() {\n return await mDocNativeModule.startQrEngagement()\n }\n\n private onDeviceRequest(cb: (payload: OnRequestReceivedEventPayload<Uint8Array>) => Promise<void> | void) {\n return mDocNativeModuleEventEmitter.addListener<OnRequestReceivedEventPayload>(\n MdocDataTransferEvent.OnRequestReceived,\n (payload) =>\n cb({\n deviceRequest: new Uint8Array(payload.deviceRequest),\n })\n )\n }\n\n private onResponseSent(cb: (payload: OnResponseSendPayload) => Promise<void> | void) {\n return mDocNativeModuleEventEmitter.addListener<OnResponseSendPayload>(MdocDataTransferEvent.OnRequestReceived, cb)\n }\n\n public async waitForDeviceRequest() {\n return (await new Promise<OnRequestReceivedEventPayload<Uint8Array>>(this.onDeviceRequest)).deviceRequest\n }\n\n public async sendDeviceResponse(deviceResponse: Uint8Array) {\n const p = new Promise(this.onResponseSent)\n mDocNativeModule.sendDeviceResponse(deviceResponse)\n await p\n }\n\n public shutdown() {\n mDocNativeModule.shutdown()\n instance = undefined\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export declare enum MdocDataTransferEvent {
2
+ OnRequestReceived = "onRequestReceived",
3
+ OnResponseSent = "onResponseSent"
4
+ }
5
+ export type OnResponseSendPayload = null;
6
+ export type OnRequestReceivedEventPayload<T = Array<number>> = {
7
+ deviceRequest: T;
8
+ };
9
+ //# sourceMappingURL=MdocDataTransferEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdocDataTransferEvent.d.ts","sourceRoot":"","sources":["../src/MdocDataTransferEvent.ts"],"names":[],"mappings":"AAAA,oBAAY,qBAAqB;IAC/B,iBAAiB,sBAAsB;IACvC,cAAc,mBAAmB;CAClC;AAED,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAA;AAExC,MAAM,MAAM,6BAA6B,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI;IAC7D,aAAa,EAAE,CAAC,CAAA;CACjB,CAAA"}
@@ -0,0 +1,6 @@
1
+ export var MdocDataTransferEvent;
2
+ (function (MdocDataTransferEvent) {
3
+ MdocDataTransferEvent["OnRequestReceived"] = "onRequestReceived";
4
+ MdocDataTransferEvent["OnResponseSent"] = "onResponseSent";
5
+ })(MdocDataTransferEvent || (MdocDataTransferEvent = {}));
6
+ //# sourceMappingURL=MdocDataTransferEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdocDataTransferEvent.js","sourceRoot":"","sources":["../src/MdocDataTransferEvent.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,gEAAuC,CAAA;IACvC,0DAAiC,CAAA;AACnC,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC","sourcesContent":["export enum MdocDataTransferEvent {\n OnRequestReceived = 'onRequestReceived',\n OnResponseSent = 'onResponseSent',\n}\n\nexport type OnResponseSendPayload = null\n\nexport type OnRequestReceivedEventPayload<T = Array<number>> = {\n deviceRequest: T\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { EventEmitter } from 'expo-modules-core';
2
+ export type MdocNativeModule = {
3
+ initialize: () => void;
4
+ startQrEngagement: () => Promise<string>;
5
+ sendDeviceResponse: (devceResponse: Uint8Array) => void;
6
+ shutdown: () => void;
7
+ };
8
+ export declare const mDocNativeModule: MdocNativeModule;
9
+ export declare const mDocNativeModuleEventEmitter: EventEmitter;
10
+ //# sourceMappingURL=MdocDataTransferModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdocDataTransferModule.d.ts","sourceRoot":"","sources":["../src/MdocDataTransferModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,mBAAmB,CAAA;AAGrE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,IAAI,CAAA;IACtB,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACxC,kBAAkB,EAAE,CAAC,aAAa,EAAE,UAAU,KAAK,IAAI,CAAA;IACvD,QAAQ,EAAE,MAAM,IAAI,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,gBAAgB,kBAA4D,CAAA;AACzF,eAAO,MAAM,4BAA4B,cAAgE,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { EventEmitter, requireNativeModule } from 'expo-modules-core';
2
+ export const mDocNativeModule = requireNativeModule('MdocDataTransfer');
3
+ export const mDocNativeModuleEventEmitter = new EventEmitter(mDocNativeModule);
4
+ //# sourceMappingURL=MdocDataTransferModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdocDataTransferModule.js","sourceRoot":"","sources":["../src/MdocDataTransferModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAUrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAmB,kBAAkB,CAAC,CAAA;AACzF,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,YAAY,CAAC,gBAA2C,CAAC,CAAA","sourcesContent":["import { EventEmitter, requireNativeModule } from 'expo-modules-core'\nimport type { NativeModule } from 'react-native'\n\nexport type MdocNativeModule = {\n initialize: () => void\n startQrEngagement: () => Promise<string>\n sendDeviceResponse: (devceResponse: Uint8Array) => void\n shutdown: () => void\n}\n\nexport const mDocNativeModule = requireNativeModule<MdocNativeModule>('MdocDataTransfer')\nexport const mDocNativeModuleEventEmitter = new EventEmitter(mDocNativeModule as unknown as NativeModule)\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './MdocDataTransfer';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
package/build/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './MdocDataTransfer';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA","sourcesContent":["export * from './MdocDataTransfer'\n"]}
@@ -0,0 +1,9 @@
1
+ {
2
+ "platforms": ["ios", "android"],
3
+ "ios": {
4
+ "modules": ["MdocDataTransferModule"]
5
+ },
6
+ "android": {
7
+ "modules": ["id.animo.mdocdatatransfer.MdocDataTransferModule"]
8
+ }
9
+ }
@@ -0,0 +1,27 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'MdocDataTransfer'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.description = package['description']
10
+ s.license = package['license']
11
+ s.author = package['author']
12
+ s.homepage = package['homepage']
13
+ s.platforms = { :ios => '13.4', :tvos => '13.4' }
14
+ s.swift_version = '5.4'
15
+ s.source = { git: 'https://github.com/animo/expo-mdoc-data-transfer' }
16
+ s.static_framework = true
17
+
18
+ s.dependency 'ExpoModulesCore'
19
+
20
+ # Swift/Objective-C compatibility
21
+ s.pod_target_xcconfig = {
22
+ 'DEFINES_MODULE' => 'YES',
23
+ 'SWIFT_COMPILATION_MODE' => 'wholemodule'
24
+ }
25
+
26
+ s.source_files = "**/*.{h,m,swift}"
27
+ end
@@ -0,0 +1,44 @@
1
+ import ExpoModulesCore
2
+
3
+ public class MdocDataTransferModule: Module {
4
+ // Each module class must implement the definition function. The definition consists of components
5
+ // that describes the module's functionality and behavior.
6
+ // See https://docs.expo.dev/modules/module-api for more details about available components.
7
+ public func definition() -> ModuleDefinition {
8
+ // Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
9
+ // Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
10
+ // The module will be accessible from `requireNativeModule('MdocDataTransfer')` in JavaScript.
11
+ Name("MdocDataTransfer")
12
+
13
+ // Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
14
+ Constants([
15
+ "PI": Double.pi
16
+ ])
17
+
18
+ // Defines event names that the module can send to JavaScript.
19
+ Events("onChange")
20
+
21
+ // Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
22
+ Function("hello") {
23
+ return "Hello world! 👋"
24
+ }
25
+
26
+ // Defines a JavaScript function that always returns a Promise and whose native code
27
+ // is by default dispatched on the different thread than the JavaScript runtime runs on.
28
+ AsyncFunction("setValueAsync") { (value: String) in
29
+ // Send an event to JavaScript.
30
+ self.sendEvent("onChange", [
31
+ "value": value
32
+ ])
33
+ }
34
+
35
+ // Enables the module to be used as a native view. Definition components that are accepted as part of the
36
+ // view definition: Prop, Events.
37
+ View(MdocDataTransferView.self) {
38
+ // Defines a setter for the `name` prop.
39
+ Prop("name") { (view: MdocDataTransferView, prop: String) in
40
+ print(prop)
41
+ }
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,7 @@
1
+ import ExpoModulesCore
2
+
3
+ // This view will be used as a native component. Make sure to inherit from `ExpoView`
4
+ // to apply the proper styling (e.g. border radius and shadows).
5
+ class MdocDataTransferView: ExpoView {
6
+
7
+ }
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@animo-id/expo-mdoc-data-transfer",
3
+ "version": "0.0.1-alpha.0",
4
+ "description": "Expo mdoc data transfer module",
5
+ "main": "build/index.js",
6
+ "types": "build/index.d.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "scripts": {
11
+ "build": "EXPO_NONINTERACTIVE=1 expo-module build && EXPO_NONINTERACTIVE=1 expo-module build plugin",
12
+ "style:check": "biome check --unsafe",
13
+ "style:fix": "pnpm style:check --write",
14
+ "types:check": "EXPO_NONINTERACTIVE=1 expo-module typecheck && EXPO_NONINTERACTIVE=1 expo-module plugin typecheck",
15
+ "release": "release-it"
16
+ },
17
+ "keywords": [
18
+ "react-native",
19
+ "expo",
20
+ "@animo-id/expo-mdoc-data-transfer",
21
+ "MdocDataTransfer"
22
+ ],
23
+ "repository": "https://github.com/animo/expo-mdoc-data-transfer",
24
+ "bugs": {
25
+ "url": "https://github.com/animo/expo-mdoc-data-transfer/issues"
26
+ },
27
+ "author": "Animo Solutions <development@animo.id> (https://github.com/animo)",
28
+ "license": "Apache-2.0",
29
+ "homepage": "https://github.com/animo/expo-mdoc-data-transfer#readme",
30
+ "devDependencies": {
31
+ "@biomejs/biome": "1.9.3",
32
+ "@types/react": "~18.2.79",
33
+ "expo-module-scripts": "3.5.2",
34
+ "expo-modules-core": "~1.12.25",
35
+ "release-it": "^17.4.1",
36
+ "typescript": "~5.3.3"
37
+ },
38
+ "peerDependencies": {
39
+ "expo": "*",
40
+ "react": "*",
41
+ "react-native": "*"
42
+ },
43
+ "dependencies": {
44
+ "@expo/config-plugins": "^8.0.10"
45
+ }
46
+ }
@@ -0,0 +1,3 @@
1
+ import { type ConfigPlugin } from '@expo/config-plugins';
2
+ declare const _default: ConfigPlugin<void>;
3
+ export default _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_plugins_1 = require("@expo/config-plugins");
4
+ const withAndroid_1 = require("./withAndroid");
5
+ const withMdocTransportSdk = (config) => {
6
+ return (0, config_plugins_1.withPlugins)(config, [withAndroid_1.withAndroid]);
7
+ };
8
+ exports.default = (0, config_plugins_1.createRunOncePlugin)(withMdocTransportSdk, '@animo-id/expo-mdoc-data-transfer');
@@ -0,0 +1,2 @@
1
+ import type { ConfigPlugin } from '@expo/config-plugins';
2
+ export declare const withAndroid: ConfigPlugin;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withAndroid = void 0;
4
+ const config_plugins_1 = require("@expo/config-plugins");
5
+ const permissions = [
6
+ 'android.permission.INTERNET',
7
+ 'android.permission.BLUETOOTH',
8
+ 'android.permission.BLUETOOTH_ADMIN',
9
+ 'android.permission.BLUETOOTH_SCAN',
10
+ 'android.permission.BLUETOOTH_ADVERTISE',
11
+ 'android.permission.BLUETOOTH_CONNECT',
12
+ 'android.permission.ACCESS_BACKGROUND_LOCATION',
13
+ 'android.permission.ACCESS_FINE_LOCATION',
14
+ 'android.permission.ACCESS_COARSE_LOCATION',
15
+ ];
16
+ // TODO: make it possible to optionally enable NFC
17
+ const withAndroidNfcProperties = (expoConfig) => (0, config_plugins_1.withAndroidManifest)(expoConfig, (c) => {
18
+ const androidManifest = c.modResults.manifest;
19
+ if (!androidManifest['uses-permission']?.some((p) => p.$['android:name'] === 'android.permission.NFC')) {
20
+ androidManifest['uses-permission']?.push({
21
+ $: {
22
+ 'android:name': 'android.permission.NFC',
23
+ },
24
+ });
25
+ }
26
+ for (const app of androidManifest.application ?? []) {
27
+ if (app.service?.some((s) => s.$['android:name'] === 'id.animo.mdocdatatransfer.NfcEngagementServiceImpl'))
28
+ continue;
29
+ app.service ??= [];
30
+ app.service.push({
31
+ $: {
32
+ 'android:exported': 'true',
33
+ 'android:name': 'id.animo.mdocdatatransfer.NfcEngagementServiceImpl',
34
+ 'android:permission': 'android.permission.BIND_NFC_SERVICE',
35
+ },
36
+ 'intent-filter': [
37
+ {
38
+ action: [
39
+ {
40
+ $: {
41
+ 'android:name': 'android.nfc.action.NDEF_DISCOVERED',
42
+ },
43
+ },
44
+ {
45
+ $: {
46
+ 'android:name': 'android.nfc.cardemulation.action.HOST_APDU_SERVICE',
47
+ },
48
+ },
49
+ ],
50
+ },
51
+ ],
52
+ // @ts-ignore
53
+ 'meta-data': {
54
+ $: {
55
+ 'android:name': 'android.nfc.cardemulation.host_apdu_service',
56
+ 'android:resource': '@xml/nfc_engagement_apdu_service',
57
+ },
58
+ },
59
+ });
60
+ }
61
+ return c;
62
+ });
63
+ const withAndroidPermissions = (expoConfig) => (0, config_plugins_1.withAndroidManifest)(expoConfig, (c) => {
64
+ const androidManifest = c.modResults.manifest;
65
+ for (const permission of permissions) {
66
+ if (androidManifest['uses-permission']?.some((p) => p.$['android:name'] === permission))
67
+ continue;
68
+ androidManifest['uses-permission']?.push({
69
+ $: {
70
+ 'android:name': permission,
71
+ },
72
+ });
73
+ }
74
+ return c;
75
+ });
76
+ const withAndroid = (config) => (0, config_plugins_1.withPlugins)(config, [withAndroidNfcProperties, withAndroidPermissions]);
77
+ exports.withAndroid = withAndroid;