@animo-id/expo-mdoc-data-transfer 0.1.0 → 0.1.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/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
export declare const withAndroid: ConfigPlugin;
|
|
@@ -2,30 +2,98 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withAndroid = void 0;
|
|
4
4
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
const withAndroidExcludeMetaInf = (expoConfig) => (0, config_plugins_1.withAppBuildGradle)(expoConfig, (c) => {
|
|
17
|
-
if (c.modResults.contents.includes('resources.excludes.add("META-INF/versions/9/OSGI-INF/MANIFEST.MF")'))
|
|
18
|
-
return c;
|
|
19
|
-
c.modResults.contents += `packaging { resources.excludes.add("META-INF/versions/9/OSGI-INF/MANIFEST.MF") }`;
|
|
20
|
-
return c;
|
|
5
|
+
const withBleAndroidManifest = (config) => (0, config_plugins_1.withAndroidManifest)(config, (config) => {
|
|
6
|
+
config.modResults = addLocationPermissionToManifest(config.modResults);
|
|
7
|
+
config.modResults = addScanAndAdvertisePermissionToManifest(config.modResults);
|
|
8
|
+
config.modResults = addConnectPermissionToManifest(config.modResults);
|
|
9
|
+
config.modResults = addLegacyBlePermissionToManifest(config.modResults);
|
|
10
|
+
return config;
|
|
21
11
|
});
|
|
12
|
+
function addLocationPermissionToManifest(androidManifest) {
|
|
13
|
+
if (!Array.isArray(androidManifest.manifest['uses-permission-sdk-23'])) {
|
|
14
|
+
androidManifest.manifest['uses-permission-sdk-23'] = [];
|
|
15
|
+
}
|
|
16
|
+
if (!androidManifest.manifest['uses-permission-sdk-23'].find((item) => item.$['android:name'] === 'android.permission.ACCESS_COARSE_LOCATION')) {
|
|
17
|
+
androidManifest.manifest['uses-permission-sdk-23'].push({
|
|
18
|
+
$: {
|
|
19
|
+
'android:name': 'android.permission.ACCESS_COARSE_LOCATION',
|
|
20
|
+
'android:maxSdkVersion': '30',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (!androidManifest.manifest['uses-permission-sdk-23'].find((item) => item.$['android:name'] === 'android.permission.ACCESS_FINE_LOCATION')) {
|
|
25
|
+
androidManifest.manifest['uses-permission-sdk-23'].push({
|
|
26
|
+
$: {
|
|
27
|
+
'android:name': 'android.permission.ACCESS_FINE_LOCATION',
|
|
28
|
+
'android:maxSdkVersion': '30',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return androidManifest;
|
|
33
|
+
}
|
|
34
|
+
function addLegacyBlePermissionToManifest(androidManifest) {
|
|
35
|
+
if (!Array.isArray(androidManifest.manifest['uses-permission'])) {
|
|
36
|
+
androidManifest.manifest['uses-permission'] = [];
|
|
37
|
+
}
|
|
38
|
+
if (!androidManifest.manifest['uses-permission'].find((item) => item.$['android:name'] === 'android.permission.BLUETOOTH')) {
|
|
39
|
+
config_plugins_1.AndroidConfig.Manifest.ensureToolsAvailable(androidManifest);
|
|
40
|
+
androidManifest.manifest['uses-permission']?.push({
|
|
41
|
+
$: {
|
|
42
|
+
'android:name': 'android.permission.BLUETOOTH',
|
|
43
|
+
'android:maxSdkVersion': '30',
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
androidManifest.manifest['uses-permission']?.push({
|
|
47
|
+
$: {
|
|
48
|
+
'android:name': 'android.permission.BLUETOOTH_ADMIN',
|
|
49
|
+
'android:maxSdkVersion': '30',
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return androidManifest;
|
|
54
|
+
}
|
|
55
|
+
function addScanAndAdvertisePermissionToManifest(androidManifest) {
|
|
56
|
+
if (!Array.isArray(androidManifest.manifest['uses-permission'])) {
|
|
57
|
+
androidManifest.manifest['uses-permission'] = [];
|
|
58
|
+
}
|
|
59
|
+
if (!androidManifest.manifest['uses-permission'].find((item) => item.$['android:name'] === 'android.permission.BLUETOOTH_SCAN')) {
|
|
60
|
+
config_plugins_1.AndroidConfig.Manifest.ensureToolsAvailable(androidManifest);
|
|
61
|
+
androidManifest.manifest['uses-permission']?.push({
|
|
62
|
+
$: {
|
|
63
|
+
'android:name': 'android.permission.BLUETOOTH_SCAN',
|
|
64
|
+
'android:usesPermissionFlags': 'neverForLocation',
|
|
65
|
+
'tools:targetApi': '31',
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
androidManifest.manifest['uses-permission']?.push({
|
|
69
|
+
$: {
|
|
70
|
+
'android:name': 'android.permission.BLUETOOTH_ADVERTISE',
|
|
71
|
+
'tools:targetApi': '31',
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return androidManifest;
|
|
76
|
+
}
|
|
77
|
+
function addConnectPermissionToManifest(androidManifest) {
|
|
78
|
+
if (!Array.isArray(androidManifest.manifest['uses-permission'])) {
|
|
79
|
+
androidManifest.manifest['uses-permission'] = [];
|
|
80
|
+
}
|
|
81
|
+
if (!androidManifest.manifest['uses-permission'].find((item) => item.$['android:name'] === 'android.permission.BLUETOOTH_CONNECT')) {
|
|
82
|
+
config_plugins_1.AndroidConfig.Manifest.ensureToolsAvailable(androidManifest);
|
|
83
|
+
androidManifest.manifest['uses-permission']?.push({
|
|
84
|
+
$: {
|
|
85
|
+
'android:name': 'android.permission.BLUETOOTH_CONNECT',
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return androidManifest;
|
|
90
|
+
}
|
|
22
91
|
const withAndroidExcludeBcProv = (expoConfig) => (0, config_plugins_1.withAppBuildGradle)(expoConfig, (c) => {
|
|
23
92
|
if (c.modResults.contents.includes("all*.exclude module: 'bcprov-jdk15to18'"))
|
|
24
93
|
return c;
|
|
25
94
|
c.modResults.contents += `android { configurations { all*.exclude module: 'bcprov-jdk15to18' } }`;
|
|
26
95
|
return c;
|
|
27
96
|
});
|
|
28
|
-
// TODO: make it possible to optionally enable NFC
|
|
29
97
|
const withAndroidNfcProperties = (expoConfig) => (0, config_plugins_1.withAndroidManifest)(expoConfig, (c) => {
|
|
30
98
|
const androidManifest = c.modResults.manifest;
|
|
31
99
|
if (!androidManifest['uses-permission']?.some((p) => p.$['android:name'] === 'android.permission.NFC')) {
|
|
@@ -72,23 +140,10 @@ const withAndroidNfcProperties = (expoConfig) => (0, config_plugins_1.withAndroi
|
|
|
72
140
|
}
|
|
73
141
|
return c;
|
|
74
142
|
});
|
|
75
|
-
const withAndroidPermissions = (expoConfig) => (0, config_plugins_1.withAndroidManifest)(expoConfig, (c) => {
|
|
76
|
-
const androidManifest = c.modResults.manifest;
|
|
77
|
-
for (const permission of permissions) {
|
|
78
|
-
if (androidManifest['uses-permission']?.some((p) => p.$['android:name'] === permission))
|
|
79
|
-
continue;
|
|
80
|
-
androidManifest['uses-permission']?.push({
|
|
81
|
-
$: {
|
|
82
|
-
'android:name': permission,
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return c;
|
|
87
|
-
});
|
|
88
143
|
const withAndroid = (config) => (0, config_plugins_1.withPlugins)(config, [
|
|
89
|
-
|
|
144
|
+
(c) => config_plugins_1.AndroidConfig.Permissions.withPermissions(c, ['android.permission.BLUETOOTH_CONNECT']),
|
|
145
|
+
withBleAndroidManifest,
|
|
90
146
|
withAndroidExcludeBcProv,
|
|
91
147
|
withAndroidNfcProperties,
|
|
92
|
-
withAndroidPermissions,
|
|
93
148
|
]);
|
|
94
149
|
exports.withAndroid = withAndroid;
|
package/plugin/build/withIos.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withIos = void 0;
|
|
4
4
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
-
const
|
|
5
|
+
const BLUETOOTH_ALWAYS = 'Allow $(PRODUCT_NAME) to connect to bluetooth devices for data sharing';
|
|
6
|
+
const withIosBuildStatic = (expoConfig, props) => (0, config_plugins_1.withPodfile)(expoConfig, (c) => {
|
|
6
7
|
if (!props.ios?.buildStatic)
|
|
7
8
|
return c;
|
|
8
9
|
const staticLibraries = `mdoc_data_transfer_static_libraries=[${props.ios.buildStatic.map((i) => `"${i}"`).join(', ')}]`;
|
|
@@ -27,18 +28,17 @@ end
|
|
|
27
28
|
`;
|
|
28
29
|
return c;
|
|
29
30
|
});
|
|
30
|
-
const
|
|
31
|
-
return (0, config_plugins_1.withInfoPlist)(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
c.ios.infoPlist.NSBluetoothAlwaysUsageDescription = usageDescription;
|
|
31
|
+
const withBluetoothPermissions = (c, { bluetoothAlwaysPermission } = {}) => {
|
|
32
|
+
return (0, config_plugins_1.withInfoPlist)(c, (config) => {
|
|
33
|
+
if (bluetoothAlwaysPermission !== false) {
|
|
34
|
+
config.modResults.NSBluetoothAlwaysUsageDescription =
|
|
35
|
+
bluetoothAlwaysPermission || config.modResults.NSBluetoothAlwaysUsageDescription || BLUETOOTH_ALWAYS;
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return config;
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
const withIos = (config, props) => (0, config_plugins_1.withPlugins)(config, [
|
|
41
|
-
[
|
|
42
|
-
[
|
|
41
|
+
[withBluetoothPermissions, props],
|
|
42
|
+
[withIosBuildStatic, props],
|
|
43
43
|
]);
|
|
44
44
|
exports.withIos = withIos;
|