@animo-id/expo-mdoc-data-transfer 0.0.1-alpha.1 → 0.0.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/.github/workflows/ci.yaml +12 -12
- package/MdocDataTransfer.podspec +35 -0
- package/README.md +11 -5
- package/android/src/main/java/id/animo/mdocdatatransfer/MdocDataTransferModule.kt +1 -0
- package/app.plugin.js +1 -1
- package/build/MdocDataTransfer.d.ts +1 -1
- package/build/MdocDataTransfer.d.ts.map +1 -1
- package/build/MdocDataTransfer.js +3 -3
- package/build/MdocDataTransfer.js.map +1 -1
- package/build/MdocDataTransferModule.d.ts +1 -7
- package/build/MdocDataTransferModule.d.ts.map +1 -1
- package/build/MdocDataTransferModule.js +4 -2
- package/build/MdocDataTransferModule.js.map +1 -1
- package/build/NativeMdocDataTransfer.d.ts +16 -0
- package/build/NativeMdocDataTransfer.d.ts.map +1 -0
- package/build/NativeMdocDataTransfer.js +9 -0
- package/build/NativeMdocDataTransfer.js.map +1 -0
- package/expo-module.config.json +2 -4
- package/ios/MdocDataTransfer.h +12 -0
- package/ios/MdocDataTransfer.mm +41 -0
- package/ios/MdocDataTransferImpl.swift +22 -0
- package/package.json +13 -7
- package/plugin/build/index.d.ts +6 -1
- package/plugin/build/index.js +3 -4
- package/plugin/build/withIos.d.ts +3 -0
- package/plugin/build/withIos.js +31 -0
- package/src/MdocDataTransfer.ts +55 -0
- package/src/MdocDataTransferEvent.ts +10 -0
- package/src/MdocDataTransferModule.ts +6 -0
- package/src/NativeMdocDataTransfer.ts +25 -0
- package/src/index.ts +1 -0
- package/ios/MdocDataTransfer.podspec +0 -27
- package/ios/MdocDataTransferModule.swift +0 -44
- package/ios/MdocDataTransferView.swift +0 -7
|
@@ -28,21 +28,21 @@ jobs:
|
|
|
28
28
|
steps:
|
|
29
29
|
- uses: actions/checkout@v4
|
|
30
30
|
|
|
31
|
-
- uses:
|
|
31
|
+
- uses: actions/setup-node@v4
|
|
32
32
|
with:
|
|
33
|
-
version:
|
|
33
|
+
node-version: '18'
|
|
34
34
|
|
|
35
35
|
- name: Install dependencies
|
|
36
|
-
run:
|
|
36
|
+
run: npm install
|
|
37
37
|
|
|
38
38
|
- name: Style
|
|
39
|
-
run:
|
|
39
|
+
run: npm run style:check
|
|
40
40
|
|
|
41
41
|
- name: Build
|
|
42
|
-
run:
|
|
42
|
+
run: npm run build
|
|
43
43
|
|
|
44
44
|
- name: Check types
|
|
45
|
-
run:
|
|
45
|
+
run: npm run types:check
|
|
46
46
|
|
|
47
47
|
continuous-deployment:
|
|
48
48
|
if: github.event_name == 'workflow_dispatch'
|
|
@@ -56,15 +56,15 @@ jobs:
|
|
|
56
56
|
with:
|
|
57
57
|
fetch-depth: 0
|
|
58
58
|
|
|
59
|
-
- uses:
|
|
59
|
+
- uses: actions/setup-node@v4
|
|
60
60
|
with:
|
|
61
|
-
|
|
61
|
+
node-version: '18'
|
|
62
62
|
|
|
63
63
|
- name: Install dependencies
|
|
64
|
-
run:
|
|
64
|
+
run: npm install
|
|
65
65
|
|
|
66
66
|
- name: Build
|
|
67
|
-
run:
|
|
67
|
+
run: npm run build
|
|
68
68
|
|
|
69
69
|
- name: Set git configuration
|
|
70
70
|
run: |
|
|
@@ -80,7 +80,7 @@ jobs:
|
|
|
80
80
|
npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
|
|
81
81
|
|
|
82
82
|
if [ ${{ inputs.release-type }} == 'alpha' ]; then
|
|
83
|
-
|
|
83
|
+
npm run release --preRelease=alpha
|
|
84
84
|
else
|
|
85
|
-
|
|
85
|
+
npm run release -i=${{ inputs.release-type }}
|
|
86
86
|
fi
|
|
@@ -0,0 +1,35 @@
|
|
|
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 => '14.0' }
|
|
14
|
+
s.swift_version = '5.4'
|
|
15
|
+
s.source = { git: 'https://github.com/animo/mdoc-data-transfer' }
|
|
16
|
+
|
|
17
|
+
s.pod_target_xcconfig = {
|
|
18
|
+
'DEFINES_MODULE' => 'YES',
|
|
19
|
+
'SWIFT_COMPILATION_MODE' => 'wholemodule'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
23
|
+
install_modules_dependencies(s)
|
|
24
|
+
|
|
25
|
+
if defined?(:spm_dependency)
|
|
26
|
+
spm_dependency(s,
|
|
27
|
+
url: 'https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-data-transfer.git',
|
|
28
|
+
requirement: {kind: 'upToNextMajorVersion', minimumVersion: '0.3.3'},
|
|
29
|
+
products: ['MdocDataTransfer18013']
|
|
30
|
+
)
|
|
31
|
+
else
|
|
32
|
+
raise "Please upgrade React Native to >=0.75.0 to use SPM dependencies."
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
package/README.md
CHANGED
|
@@ -11,6 +11,15 @@ mdoc data transfer module
|
|
|
11
11
|
|
|
12
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
13
|
|
|
14
|
+
TODO: plugin config for iOS and android:
|
|
15
|
+
|
|
16
|
+
- iOS
|
|
17
|
+
- add `expo-build-properties` with `ios.useFrameworks: "dynamic"`
|
|
18
|
+
- the library works with both new and old arch, but is most efficient on new arch
|
|
19
|
+
- to enable new arch add `expo-build-properties` with `newArchEnabled: true`
|
|
20
|
+
- Android
|
|
21
|
+
- @berend?
|
|
22
|
+
|
|
14
23
|
# Installation in bare React Native projects
|
|
15
24
|
|
|
16
25
|
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.
|
|
@@ -23,13 +32,10 @@ npm install @animo-id/expo-mdoc-data-transfer
|
|
|
23
32
|
|
|
24
33
|
### Configure for iOS
|
|
25
34
|
|
|
26
|
-
Run `npx pod-install` after installing the npm package.
|
|
27
|
-
|
|
35
|
+
Run `USE_FRAMEWORKS=dynamic npx pod-install` after installing the npm package.
|
|
28
36
|
|
|
29
37
|
### Configure for Android
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
33
39
|
# Contributing
|
|
34
40
|
|
|
35
|
-
Contributions are very welcome! Please refer to guidelines described in the [contributing guide](
|
|
41
|
+
Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).
|
|
@@ -22,6 +22,7 @@ class MdocDataTransferModule : Module() {
|
|
|
22
22
|
// We have to re-set the Bouncy Castle provider, otherwise the EUDI library cannot find it correctly
|
|
23
23
|
Security.removeProvider("BC")
|
|
24
24
|
Security.addProvider(BouncyCastleProvider())
|
|
25
|
+
|
|
25
26
|
mDocDataTransfer = MdocDataTransfer(
|
|
26
27
|
appContext.reactContext ?: throw Exceptions.ReactContextLost(),
|
|
27
28
|
appContext.currentActivity ?: throw Exceptions.MissingActivity()
|
package/app.plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./plugin/build
|
|
1
|
+
module.exports = require('./plugin/build')
|
|
@@ -8,7 +8,7 @@ declare class MdocDataTransfer {
|
|
|
8
8
|
private onResponseSent;
|
|
9
9
|
waitForDeviceRequest(): Promise<Uint8Array>;
|
|
10
10
|
sendDeviceResponse(deviceResponse: Uint8Array): Promise<void>;
|
|
11
|
-
shutdown(): void
|
|
11
|
+
shutdown(): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=MdocDataTransfer.d.ts.map
|
|
@@ -1 +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;
|
|
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;IAM7C,QAAQ;CAItB"}
|
|
@@ -30,11 +30,11 @@ class MdocDataTransfer {
|
|
|
30
30
|
}
|
|
31
31
|
async sendDeviceResponse(deviceResponse) {
|
|
32
32
|
const p = new Promise(this.onResponseSent);
|
|
33
|
-
mDocNativeModule.sendDeviceResponse(deviceResponse);
|
|
33
|
+
await mDocNativeModule.sendDeviceResponse(deviceResponse);
|
|
34
34
|
await p;
|
|
35
35
|
}
|
|
36
|
-
shutdown() {
|
|
37
|
-
mDocNativeModule.shutdown();
|
|
36
|
+
async shutdown() {
|
|
37
|
+
await mDocNativeModule.shutdown();
|
|
38
38
|
instance = undefined;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MdocDataTransfer.js","sourceRoot":"","sources":["../src/MdocDataTransfer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAGtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,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CAAA;QAC1C,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAA;QACzD,MAAM,CAAC,CAAA;IACT,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,MAAM,gBAAgB,CAAC,QAAQ,EAAE,CAAA;QACjC,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 await mDocNativeModule.sendDeviceResponse(deviceResponse)\n await p\n }\n\n public async shutdown() {\n await mDocNativeModule.shutdown()\n instance = undefined\n }\n}\n"]}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { EventEmitter } from 'expo-modules-core';
|
|
2
|
-
export
|
|
3
|
-
initialize: () => void;
|
|
4
|
-
startQrEngagement: () => Promise<string>;
|
|
5
|
-
sendDeviceResponse: (devceResponse: Uint8Array) => void;
|
|
6
|
-
shutdown: () => void;
|
|
7
|
-
};
|
|
8
|
-
export declare const mDocNativeModule: MdocNativeModule;
|
|
2
|
+
export declare const mDocNativeModule: import("./NativeMdocDataTransfer").MdocNativeModule;
|
|
9
3
|
export declare const mDocNativeModuleEventEmitter: EventEmitter;
|
|
10
4
|
//# sourceMappingURL=MdocDataTransferModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MdocDataTransferModule.d.ts","sourceRoot":"","sources":["../src/MdocDataTransferModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"MdocDataTransferModule.d.ts","sourceRoot":"","sources":["../src/MdocDataTransferModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIhD,eAAO,MAAM,gBAAgB,qDAAqE,CAAA;AAClG,eAAO,MAAM,4BAA4B,cAAgE,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { EventEmitter
|
|
2
|
-
|
|
1
|
+
import { EventEmitter } from 'expo-modules-core';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import { requireExpoModule, requireTurboModule } from './NativeMdocDataTransfer';
|
|
4
|
+
export const mDocNativeModule = Platform.OS === 'ios' ? requireTurboModule() : requireExpoModule();
|
|
3
5
|
export const mDocNativeModuleEventEmitter = new EventEmitter(mDocNativeModule);
|
|
4
6
|
//# sourceMappingURL=MdocDataTransferModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MdocDataTransferModule.js","sourceRoot":"","sources":["../src/MdocDataTransferModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"MdocDataTransferModule.js","sourceRoot":"","sources":["../src/MdocDataTransferModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAqB,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAEhF,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAA;AAClG,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,YAAY,CAAC,gBAA2C,CAAC,CAAA","sourcesContent":["import { EventEmitter } from 'expo-modules-core'\nimport { type NativeModule, Platform } from 'react-native'\nimport { requireExpoModule, requireTurboModule } from './NativeMdocDataTransfer'\n\nexport const mDocNativeModule = Platform.OS === 'ios' ? requireTurboModule() : requireExpoModule()\nexport const mDocNativeModuleEventEmitter = new EventEmitter(mDocNativeModule as unknown as NativeModule)\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
export type MdocNativeModule = {
|
|
3
|
+
initialize: () => void;
|
|
4
|
+
startQrEngagement: () => Promise<string>;
|
|
5
|
+
sendDeviceResponse: (devceResponse: Uint8Array) => void;
|
|
6
|
+
shutdown: () => void;
|
|
7
|
+
};
|
|
8
|
+
export interface Spec extends TurboModule {
|
|
9
|
+
initialize: () => void;
|
|
10
|
+
startQrEngagement: () => Promise<string>;
|
|
11
|
+
sendDeviceResponse: (devceResponse: Uint8Array) => void;
|
|
12
|
+
shutdown: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function requireTurboModule(): Spec;
|
|
15
|
+
export declare function requireExpoModule(): MdocNativeModule;
|
|
16
|
+
//# sourceMappingURL=NativeMdocDataTransfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeMdocDataTransfer.d.ts","sourceRoot":"","sources":["../src/NativeMdocDataTransfer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAG/C,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,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,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;AAED,wBAAgB,kBAAkB,SAEjC;AAED,wBAAgB,iBAAiB,qBAEhC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { requireNativeModule } from 'expo-modules-core';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
export function requireTurboModule() {
|
|
4
|
+
return TurboModuleRegistry.getEnforcing('MdocDataTransfer');
|
|
5
|
+
}
|
|
6
|
+
export function requireExpoModule() {
|
|
7
|
+
return requireNativeModule('MdocDataTransfer');
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=NativeMdocDataTransfer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeMdocDataTransfer.js","sourceRoot":"","sources":["../src/NativeMdocDataTransfer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAgBlD,MAAM,UAAU,kBAAkB;IAChC,OAAO,mBAAmB,CAAC,YAAY,CAAO,kBAAkB,CAAC,CAAA;AACnE,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,mBAAmB,CAAmB,kBAAkB,CAAC,CAAA;AAClE,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core'\nimport type { TurboModule } from 'react-native'\nimport { TurboModuleRegistry } 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 interface Spec extends TurboModule {\n initialize: () => void\n startQrEngagement: () => Promise<string>\n sendDeviceResponse: (devceResponse: Uint8Array) => void\n shutdown: () => void\n}\n\nexport function requireTurboModule() {\n return TurboModuleRegistry.getEnforcing<Spec>('MdocDataTransfer')\n}\n\nexport function requireExpoModule() {\n return requireNativeModule<MdocNativeModule>('MdocDataTransfer')\n}\n"]}
|
package/expo-module.config.json
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
3
|
+
#import "RNMdocDataTransferSpec.h"
|
|
4
|
+
|
|
5
|
+
@interface MdocDataTransfer : NSObject <NativeMdocDataTransferSpec>
|
|
6
|
+
#else
|
|
7
|
+
#import <React/RCTBridgeModule.h>
|
|
8
|
+
|
|
9
|
+
@interface MdocDataTransfer : NSObject <RCTBridgeModule>
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
@end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#import "MdocDataTransfer.h"
|
|
2
|
+
#import "MdocDataTransfer/MdocDataTransfer-Swift.h"
|
|
3
|
+
|
|
4
|
+
static MdocDataTransferImpl *mdoc_data_transfer = [MdocDataTransferImpl new];
|
|
5
|
+
|
|
6
|
+
// NOTE: to make this library compatible with both the new AND old architecture
|
|
7
|
+
// we define all methods twice.
|
|
8
|
+
|
|
9
|
+
@implementation MdocDataTransfer
|
|
10
|
+
RCT_EXPORT_MODULE()
|
|
11
|
+
|
|
12
|
+
// New architecture methods
|
|
13
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
14
|
+
- (NSString *)hello {
|
|
15
|
+
return [mdoc_data_transfer doSomethingWithMdoc];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
19
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
20
|
+
{
|
|
21
|
+
return std::make_shared<facebook::react::NativeMdocDataTransferSpecJSI>(params);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Old architecture methods
|
|
25
|
+
#else
|
|
26
|
+
|
|
27
|
+
// For old architecture we need to use async methods
|
|
28
|
+
RCT_EXPORT_METHOD(hello:(RCTPromiseResolveBlock)resolve
|
|
29
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
30
|
+
{
|
|
31
|
+
NSString *message = [mdoc_data_transfer doSomethingWithMdoc];
|
|
32
|
+
resolve(message);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, hello)
|
|
36
|
+
//{
|
|
37
|
+
// return [mdoc_data_transfer doSomethingWithMdoc];
|
|
38
|
+
//}
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
@end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MdocDataTransferImpl.swift
|
|
3
|
+
// MdocDataTransfer
|
|
4
|
+
//
|
|
5
|
+
// Created by Timo Glastra on 01/11/2024.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import MdocDataTransfer18013
|
|
10
|
+
|
|
11
|
+
@objc(MdocDataTransferImpl)
|
|
12
|
+
public class MdocDataTransferImpl: NSObject {
|
|
13
|
+
@objc public func doSomethingWithMdoc() -> String {
|
|
14
|
+
let bleServerTransfer = try? MdocGattServer(parameters: [
|
|
15
|
+
InitializeKeys.document_json_data.rawValue: [Data(name: "sample_data")],
|
|
16
|
+
InitializeKeys.trusted_certificates.rawValue: [Data(name: "scytales_root_ca.der")]
|
|
17
|
+
])
|
|
18
|
+
|
|
19
|
+
return "Called the mdoc library"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animo-id/expo-mdoc-data-transfer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Expo mdoc data transfer module",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "EXPO_NONINTERACTIVE=1 expo-module build && EXPO_NONINTERACTIVE=1 expo-module build plugin",
|
|
12
12
|
"style:check": "biome check --unsafe",
|
|
13
|
-
"style:fix": "
|
|
13
|
+
"style:fix": "npm run style:check -- --write",
|
|
14
14
|
"types:check": "EXPO_NONINTERACTIVE=1 expo-module typecheck && EXPO_NONINTERACTIVE=1 expo-module plugin typecheck",
|
|
15
15
|
"release": "release-it"
|
|
16
16
|
},
|
|
@@ -29,18 +29,24 @@
|
|
|
29
29
|
"homepage": "https://github.com/animo/expo-mdoc-data-transfer#readme",
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@biomejs/biome": "1.9.3",
|
|
32
|
+
"@types/node": "^22.8.1",
|
|
32
33
|
"@types/react": "~18.2.79",
|
|
33
34
|
"expo-module-scripts": "3.5.2",
|
|
34
|
-
"expo-modules-core": "~1.12.
|
|
35
|
+
"expo-modules-core": "~1.12.26",
|
|
35
36
|
"release-it": "^17.4.1",
|
|
36
37
|
"typescript": "~5.3.3"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
|
-
"expo": "
|
|
40
|
-
"react": "*"
|
|
41
|
-
"react-native": "*"
|
|
40
|
+
"expo": ">= 51",
|
|
41
|
+
"react": "*"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@expo/config-plugins": "^8.0.10"
|
|
44
|
+
"@expo/config-plugins": "^8.0.10",
|
|
45
|
+
"react-native": ">= 0.75"
|
|
46
|
+
},
|
|
47
|
+
"codegenConfig": {
|
|
48
|
+
"name": "RNMdocDataTransferSpec",
|
|
49
|
+
"type": "modules",
|
|
50
|
+
"jsSrcsDir": "src"
|
|
45
51
|
}
|
|
46
52
|
}
|
package/plugin/build/index.d.ts
CHANGED
package/plugin/build/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
4
|
const withAndroid_1 = require("./withAndroid");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.default = (0, config_plugins_1.createRunOncePlugin)(withMdocTransportSdk, '@animo-id/expo-mdoc-data-transfer');
|
|
5
|
+
const withIos_1 = require("./withIos");
|
|
6
|
+
const withMdocDataTransfer = (config, props) => (0, config_plugins_1.withPlugins)(config, [withAndroid_1.withAndroid, (0, withIos_1.withIos)(props)]);
|
|
7
|
+
exports.default = (0, config_plugins_1.createRunOncePlugin)(withMdocDataTransfer, '@animo-id/mdoc-data-transfer');
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withIos = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
const withIosPodfile = (props) => (expoConfig) => (0, config_plugins_1.withPodfile)(expoConfig, (c) => {
|
|
6
|
+
if (!props.ios?.buildStatic)
|
|
7
|
+
return c;
|
|
8
|
+
const staticLibraries = `mdoc_data_transfer_static_libraries=[${props.ios.buildStatic.map((i) => `"${i}"`).join(', ')}]`;
|
|
9
|
+
if (c.modResults.contents.includes('mdoc_data_transfer_static_libraries')) {
|
|
10
|
+
c.modResults.contents = c.modResults.contents.replace(/mdoc_data_transfer_static_libraries=.*/, staticLibraries);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
c.modResults.contents += staticLibraries;
|
|
14
|
+
}
|
|
15
|
+
if (c.modResults.contents.includes('Pod::BuildType.static_library'))
|
|
16
|
+
return c;
|
|
17
|
+
c.modResults.contents += `
|
|
18
|
+
pre_install do |installer|
|
|
19
|
+
installer.pod_targets.each do |pod|
|
|
20
|
+
if mdoc_data_transfer_static_libraries.include?(pod.name)
|
|
21
|
+
def pod.build_type;
|
|
22
|
+
Pod::BuildType.static_library
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
`;
|
|
28
|
+
return c;
|
|
29
|
+
});
|
|
30
|
+
const withIos = (props) => (config) => (0, config_plugins_1.withPlugins)(config, [withIosPodfile(props)]);
|
|
31
|
+
exports.withIos = withIos;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MdocDataTransferEvent,
|
|
3
|
+
type OnRequestReceivedEventPayload,
|
|
4
|
+
type OnResponseSendPayload,
|
|
5
|
+
} from './MdocDataTransferEvent'
|
|
6
|
+
import { mDocNativeModule, mDocNativeModuleEventEmitter } from './MdocDataTransferModule'
|
|
7
|
+
|
|
8
|
+
let instance: MdocDataTransfer | undefined = undefined
|
|
9
|
+
export const mdocDataTransfer = {
|
|
10
|
+
instance: () => {
|
|
11
|
+
if (instance) return instance
|
|
12
|
+
return MdocDataTransfer.initialize()
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class MdocDataTransfer {
|
|
17
|
+
public static initialize() {
|
|
18
|
+
mDocNativeModule.initialize()
|
|
19
|
+
instance = new MdocDataTransfer()
|
|
20
|
+
return instance
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async startQrEngagement() {
|
|
24
|
+
return await mDocNativeModule.startQrEngagement()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private onDeviceRequest(cb: (payload: OnRequestReceivedEventPayload<Uint8Array>) => Promise<void> | void) {
|
|
28
|
+
return mDocNativeModuleEventEmitter.addListener<OnRequestReceivedEventPayload>(
|
|
29
|
+
MdocDataTransferEvent.OnRequestReceived,
|
|
30
|
+
(payload) =>
|
|
31
|
+
cb({
|
|
32
|
+
deviceRequest: new Uint8Array(payload.deviceRequest),
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private onResponseSent(cb: (payload: OnResponseSendPayload) => Promise<void> | void) {
|
|
38
|
+
return mDocNativeModuleEventEmitter.addListener<OnResponseSendPayload>(MdocDataTransferEvent.OnRequestReceived, cb)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public async waitForDeviceRequest() {
|
|
42
|
+
return (await new Promise<OnRequestReceivedEventPayload<Uint8Array>>(this.onDeviceRequest)).deviceRequest
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async sendDeviceResponse(deviceResponse: Uint8Array) {
|
|
46
|
+
const p = new Promise(this.onResponseSent)
|
|
47
|
+
await mDocNativeModule.sendDeviceResponse(deviceResponse)
|
|
48
|
+
await p
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public async shutdown() {
|
|
52
|
+
await mDocNativeModule.shutdown()
|
|
53
|
+
instance = undefined
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EventEmitter } from 'expo-modules-core'
|
|
2
|
+
import { type NativeModule, Platform } from 'react-native'
|
|
3
|
+
import { requireExpoModule, requireTurboModule } from './NativeMdocDataTransfer'
|
|
4
|
+
|
|
5
|
+
export const mDocNativeModule = Platform.OS === 'ios' ? requireTurboModule() : requireExpoModule()
|
|
6
|
+
export const mDocNativeModuleEventEmitter = new EventEmitter(mDocNativeModule as unknown as NativeModule)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { requireNativeModule } from 'expo-modules-core'
|
|
2
|
+
import type { TurboModule } from 'react-native'
|
|
3
|
+
import { TurboModuleRegistry } from 'react-native'
|
|
4
|
+
|
|
5
|
+
export type MdocNativeModule = {
|
|
6
|
+
initialize: () => void
|
|
7
|
+
startQrEngagement: () => Promise<string>
|
|
8
|
+
sendDeviceResponse: (devceResponse: Uint8Array) => void
|
|
9
|
+
shutdown: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Spec extends TurboModule {
|
|
13
|
+
initialize: () => void
|
|
14
|
+
startQrEngagement: () => Promise<string>
|
|
15
|
+
sendDeviceResponse: (devceResponse: Uint8Array) => void
|
|
16
|
+
shutdown: () => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function requireTurboModule() {
|
|
20
|
+
return TurboModuleRegistry.getEnforcing<Spec>('MdocDataTransfer')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function requireExpoModule() {
|
|
24
|
+
return requireNativeModule<MdocNativeModule>('MdocDataTransfer')
|
|
25
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MdocDataTransfer'
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
}
|