@ledgerhq/device-transport-kit-react-native-hid 0.0.0-develop-20250415001140
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/LICENSE.MD +202 -0
- package/README.md +84 -0
- package/android/build.gradle +101 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/android/gradle.properties +1 -0
- package/android/gradlew +252 -0
- package/android/gradlew.bat +94 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/kotlin/com/ledger/androidtransporthid/BridgeEvents.kt +42 -0
- package/android/src/main/kotlin/com/ledger/androidtransporthid/TransportHidModule.kt +241 -0
- package/android/src/main/kotlin/com/ledger/androidtransporthid/TransportHidPackage.kt +25 -0
- package/android/src/main/kotlin/com/ledger/androidtransporthid/bridge/serialization.kt +124 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/AndroidUsbTransport.kt +16 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/DefaultAndroidUsbTransport.kt +298 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/UsbPermissionRequester.kt +18 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/connection/AndroidUsbApduSender.kt +133 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/controller/UsbAttachedReceiverController.kt +59 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/controller/UsbDetachedReceiverController.kt +58 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/controller/UsbPermissionReceiver.kt +92 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/model/LedgerUsbDevice.kt +16 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/model/ProductId.kt +11 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/model/UsbPermissionEvent.kt +14 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/model/UsbState.kt +16 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/model/VendorId.kt +11 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/utils/UsbDeviceMapper.kt +46 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/utils/UsbMapper.kt +56 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMainInternal/transport/UsbConst.android.kt +8 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMainInternal/transport/deviceconnection/DeviceApduSender.kt +13 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMainInternal/transport/deviceconnection/DeviceConnection.kt +95 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMainInternal/transport/deviceconnection/DeviceConnectionStateMachine.kt +314 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/apdu/Apdu.kt +44 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/apdu/ApduBuilder.kt +88 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/apdu/ApduParser.kt +37 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/apdu/ApduUtils.kt +37 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/apdu/SendApduResult.kt +47 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/connection/ConnectedDevice.kt +25 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/connection/ConnectionResult.kt +45 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/device/BleInformation.kt +8 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/device/LedgerDevice.kt +89 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/device/UsbInfo.kt +7 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/disconnection/DisconnectionResult.kt +10 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/discovery/ConnectivityType.kt +10 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/discovery/DiscoveryDevice.kt +18 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/discovery/DiscoveryResult.kt +28 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/utils/ByteArrayExtension.kt +116 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/utils/StringExtension.kt +21 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/connection/InternalConnectedDevice.kt +13 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/connection/InternalConnectionResult.kt +41 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/coroutine/SDKScope.kt +25 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/coroutine/SDKScopeHandler.kt +18 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/event/SdkEventDispatcher.kt +19 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/service/logger/DisableLoggerService.kt +12 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/service/logger/LogInfo.kt +52 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/service/logger/LogLevel.kt +13 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/service/logger/LoggerService.kt +10 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/Transport.kt +21 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/TransportEvent.kt +18 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/framer/FramerService.kt +210 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/framer/FramerUtils.kt +35 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/framer/model/ApduConst.kt +9 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/framer/model/ApduFrame.kt +66 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/framer/model/ApduFramerHeader.kt +74 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/framer/model/FramerConst.kt +14 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/utils/ByteExtension.kt +21 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/utils/InternalByteArrayExtension.kt +18 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/utils/Controller.kt +12 -0
- package/android/src/test/kotlin/com/ledger/devicesdk/shared/androidMainInternal/transport/deviceconnection/DeviceConnectionStateMachineTest.kt +713 -0
- package/android/src/test/kotlin/com/ledger/devicesdk/shared/androidMainInternal/transport/deviceconnection/DeviceConnectionTest.kt +218 -0
- package/lib/cjs/api/RNHidTransportFactory.js +2 -0
- package/lib/cjs/api/RNHidTransportFactory.js.map +7 -0
- package/lib/cjs/api/bridge/DefaultNativeModuleWrapper.js +2 -0
- package/lib/cjs/api/bridge/DefaultNativeModuleWrapper.js.map +7 -0
- package/lib/cjs/api/bridge/NativeTransportModule.js +2 -0
- package/lib/cjs/api/bridge/NativeTransportModule.js.map +7 -0
- package/lib/cjs/api/bridge/StubNativeModuleWrapper.js +2 -0
- package/lib/cjs/api/bridge/StubNativeModuleWrapper.js.map +7 -0
- package/lib/cjs/api/bridge/mapper.js +2 -0
- package/lib/cjs/api/bridge/mapper.js.map +7 -0
- package/lib/cjs/api/bridge/mapper.test.js +2 -0
- package/lib/cjs/api/bridge/mapper.test.js.map +7 -0
- package/lib/cjs/api/bridge/types.js +2 -0
- package/lib/cjs/api/bridge/types.js.map +7 -0
- package/lib/cjs/api/helpers/base64Utils.js +2 -0
- package/lib/cjs/api/helpers/base64Utils.js.map +7 -0
- package/lib/cjs/api/helpers/base64Utils.test.js +2 -0
- package/lib/cjs/api/helpers/base64Utils.test.js.map +7 -0
- package/lib/cjs/api/helpers/getObservableOfArraysNewItems.js +2 -0
- package/lib/cjs/api/helpers/getObservableOfArraysNewItems.js.map +7 -0
- package/lib/cjs/api/helpers/getObservableOfArraysNewItems.test.js +2 -0
- package/lib/cjs/api/helpers/getObservableOfArraysNewItems.test.js.map +7 -0
- package/lib/cjs/api/transport/Errors.js +2 -0
- package/lib/cjs/api/transport/Errors.js.map +7 -0
- package/lib/cjs/api/transport/NativeModuleWrapper.js +2 -0
- package/lib/cjs/api/transport/NativeModuleWrapper.js.map +7 -0
- package/lib/cjs/api/transport/RNHidTransport.js +2 -0
- package/lib/cjs/api/transport/RNHidTransport.js.map +7 -0
- package/lib/cjs/api/transport/RNHidTransport.test.js +2 -0
- package/lib/cjs/api/transport/RNHidTransport.test.js.map +7 -0
- package/lib/cjs/api/transport/rnHidTransportIdentifier.js +2 -0
- package/lib/cjs/api/transport/rnHidTransportIdentifier.js.map +7 -0
- package/lib/cjs/api/transport/types.js +2 -0
- package/lib/cjs/api/transport/types.js.map +7 -0
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +7 -0
- package/lib/cjs/package.json +61 -0
- package/lib/esm/api/RNHidTransportFactory.js +2 -0
- package/lib/esm/api/RNHidTransportFactory.js.map +7 -0
- package/lib/esm/api/bridge/DefaultNativeModuleWrapper.js +2 -0
- package/lib/esm/api/bridge/DefaultNativeModuleWrapper.js.map +7 -0
- package/lib/esm/api/bridge/NativeTransportModule.js +2 -0
- package/lib/esm/api/bridge/NativeTransportModule.js.map +7 -0
- package/lib/esm/api/bridge/StubNativeModuleWrapper.js +2 -0
- package/lib/esm/api/bridge/StubNativeModuleWrapper.js.map +7 -0
- package/lib/esm/api/bridge/mapper.js +2 -0
- package/lib/esm/api/bridge/mapper.js.map +7 -0
- package/lib/esm/api/bridge/mapper.test.js +2 -0
- package/lib/esm/api/bridge/mapper.test.js.map +7 -0
- package/lib/esm/api/bridge/types.js +2 -0
- package/lib/esm/api/bridge/types.js.map +7 -0
- package/lib/esm/api/helpers/base64Utils.js +2 -0
- package/lib/esm/api/helpers/base64Utils.js.map +7 -0
- package/lib/esm/api/helpers/base64Utils.test.js +2 -0
- package/lib/esm/api/helpers/base64Utils.test.js.map +7 -0
- package/lib/esm/api/helpers/getObservableOfArraysNewItems.js +2 -0
- package/lib/esm/api/helpers/getObservableOfArraysNewItems.js.map +7 -0
- package/lib/esm/api/helpers/getObservableOfArraysNewItems.test.js +2 -0
- package/lib/esm/api/helpers/getObservableOfArraysNewItems.test.js.map +7 -0
- package/lib/esm/api/transport/Errors.js +2 -0
- package/lib/esm/api/transport/Errors.js.map +7 -0
- package/lib/esm/api/transport/NativeModuleWrapper.js +1 -0
- package/lib/esm/api/transport/NativeModuleWrapper.js.map +7 -0
- package/lib/esm/api/transport/RNHidTransport.js +2 -0
- package/lib/esm/api/transport/RNHidTransport.js.map +7 -0
- package/lib/esm/api/transport/RNHidTransport.test.js +2 -0
- package/lib/esm/api/transport/RNHidTransport.test.js.map +7 -0
- package/lib/esm/api/transport/rnHidTransportIdentifier.js +2 -0
- package/lib/esm/api/transport/rnHidTransportIdentifier.js.map +7 -0
- package/lib/esm/api/transport/types.js +1 -0
- package/lib/esm/api/transport/types.js.map +7 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +7 -0
- package/lib/esm/package.json +61 -0
- package/lib/types/api/RNHidTransportFactory.d.ts +3 -0
- package/lib/types/api/RNHidTransportFactory.d.ts.map +1 -0
- package/lib/types/api/bridge/DefaultNativeModuleWrapper.d.ts +22 -0
- package/lib/types/api/bridge/DefaultNativeModuleWrapper.d.ts.map +1 -0
- package/lib/types/api/bridge/NativeTransportModule.d.ts +3 -0
- package/lib/types/api/bridge/NativeTransportModule.d.ts.map +1 -0
- package/lib/types/api/bridge/StubNativeModuleWrapper.d.ts +15 -0
- package/lib/types/api/bridge/StubNativeModuleWrapper.d.ts.map +1 -0
- package/lib/types/api/bridge/mapper.d.ts +10 -0
- package/lib/types/api/bridge/mapper.d.ts.map +1 -0
- package/lib/types/api/bridge/mapper.test.d.ts +2 -0
- package/lib/types/api/bridge/mapper.test.d.ts.map +1 -0
- package/lib/types/api/bridge/types.d.ts +61 -0
- package/lib/types/api/bridge/types.d.ts.map +1 -0
- package/lib/types/api/helpers/base64Utils.d.ts +13 -0
- package/lib/types/api/helpers/base64Utils.d.ts.map +1 -0
- package/lib/types/api/helpers/base64Utils.test.d.ts +2 -0
- package/lib/types/api/helpers/base64Utils.test.d.ts.map +1 -0
- package/lib/types/api/helpers/getObservableOfArraysNewItems.d.ts +15 -0
- package/lib/types/api/helpers/getObservableOfArraysNewItems.d.ts.map +1 -0
- package/lib/types/api/helpers/getObservableOfArraysNewItems.test.d.ts +2 -0
- package/lib/types/api/helpers/getObservableOfArraysNewItems.test.d.ts.map +1 -0
- package/lib/types/api/transport/Errors.d.ts +7 -0
- package/lib/types/api/transport/Errors.d.ts.map +1 -0
- package/lib/types/api/transport/NativeModuleWrapper.d.ts +23 -0
- package/lib/types/api/transport/NativeModuleWrapper.d.ts.map +1 -0
- package/lib/types/api/transport/RNHidTransport.d.ts +23 -0
- package/lib/types/api/transport/RNHidTransport.d.ts.map +1 -0
- package/lib/types/api/transport/RNHidTransport.test.d.ts +2 -0
- package/lib/types/api/transport/RNHidTransport.test.d.ts.map +1 -0
- package/lib/types/api/transport/rnHidTransportIdentifier.d.ts +2 -0
- package/lib/types/api/transport/rnHidTransportIdentifier.d.ts.map +1 -0
- package/lib/types/api/transport/types.d.ts +12 -0
- package/lib/types/api/transport/types.d.ts.map +1 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -0
- package/package.json +60 -0
package/LICENSE.MD
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2024-present Ledger
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Device Transport Kit React Native HID
|
|
2
|
+
|
|
3
|
+
> [!CAUTION]
|
|
4
|
+
> This is still under development and we are free to make new interfaces which may lead to breaking changes.
|
|
5
|
+
|
|
6
|
+
- [Device Transport Kit React Native HID](#device-transport-kit-react-native-hid)
|
|
7
|
+
- [Description](#description)
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Usage](#usage)
|
|
10
|
+
- [Compatibility](#compatibility)
|
|
11
|
+
- [Pre-requisites](#pre-requisites)
|
|
12
|
+
- [AndroidManifest.xml](#androidmanifestxml)
|
|
13
|
+
- [Main Features](#main-features)
|
|
14
|
+
- [How To](#how-to)
|
|
15
|
+
|
|
16
|
+
## Description
|
|
17
|
+
|
|
18
|
+
This transport is used to interact with a Ledger device through the React Native HID (usb) implementation by the Device Management Kit.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
To install the core package, run the following command:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm install @ledgerhq/device-transport-kit-react-native-hid
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Compatibility
|
|
31
|
+
|
|
32
|
+
This library works in React Native projects.
|
|
33
|
+
|
|
34
|
+
The transport itself is only compatible with Android devices but there is no additional configuration needed for other platforms, the Device Management Kit will simply not use that transport.
|
|
35
|
+
|
|
36
|
+
### Pre-requisites
|
|
37
|
+
|
|
38
|
+
To use this transport, ensure you have the Device Management Kit installed in your project.
|
|
39
|
+
|
|
40
|
+
#### AndroidManifest.xml
|
|
41
|
+
|
|
42
|
+
Add the following to your `AndroidManifest.xml` file in your `<activity>`:
|
|
43
|
+
|
|
44
|
+
```xml
|
|
45
|
+
<intent-filter>
|
|
46
|
+
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
|
47
|
+
</intent-filter>
|
|
48
|
+
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/usb_device_filter" />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
And in your app's config in the resources folder, add a new file `app/src/main/res/xml/usb_device_filter.xml` with the following content:
|
|
52
|
+
|
|
53
|
+
```xml
|
|
54
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
55
|
+
<resources>
|
|
56
|
+
<usb-device vendor-id="11415" />
|
|
57
|
+
</resources>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This will allow your app to detect when a Ledger device is connected to the phone.
|
|
61
|
+
|
|
62
|
+
### Main Features
|
|
63
|
+
|
|
64
|
+
- Exposing a transport factory to be injected into the DeviceManagementKit
|
|
65
|
+
- Exposing the transport directly for a custom configuration
|
|
66
|
+
|
|
67
|
+
### How To
|
|
68
|
+
|
|
69
|
+
To use the transport, you need to inject it in the DeviceManagementKitBuilder before the build. This will allow the Device Management Kit to find and interact with USB devices.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { DeviceManagementKitBuilder } from "@ledgerhq/device-management-kit";
|
|
73
|
+
import {
|
|
74
|
+
RNHidTransportFactory,
|
|
75
|
+
RNHidTransport,
|
|
76
|
+
} from "@ledgerhq/device-transport-kit-react-native-hid";
|
|
77
|
+
|
|
78
|
+
// Easy setup with the factory
|
|
79
|
+
const dmk = new DeviceManagementKitBuilder()
|
|
80
|
+
.addTransport(RNHidTransportFactory)
|
|
81
|
+
.build();
|
|
82
|
+
|
|
83
|
+
// You can then make use of the Device Management Kit
|
|
84
|
+
```
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext {
|
|
3
|
+
// Kotlin and JVM Versions
|
|
4
|
+
kotlin_version = '2.0.20'
|
|
5
|
+
coroutines_version = '1.7.3'
|
|
6
|
+
jvmTargetVersion = "17"
|
|
7
|
+
|
|
8
|
+
// Libraries Versions
|
|
9
|
+
androidCoreKtx_version = '1.13.1'
|
|
10
|
+
kotlin_stdlib_version = kotlin_version
|
|
11
|
+
kotlin_coroutines_version = coroutines_version
|
|
12
|
+
kotlinx_datetime_version = '0.6.1'
|
|
13
|
+
mockk_version = '1.13.5'
|
|
14
|
+
kotlin_junit_test_version = kotlin_version
|
|
15
|
+
kotlin_coroutines_test_version = coroutines_version
|
|
16
|
+
timber_version = '5.0.1'
|
|
17
|
+
buffer_version = '1.4.2'
|
|
18
|
+
}
|
|
19
|
+
repositories {
|
|
20
|
+
mavenCentral()
|
|
21
|
+
google()
|
|
22
|
+
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
dependencies {
|
|
26
|
+
// Android Gradle Plugin
|
|
27
|
+
classpath "com.android.tools.build:gradle:8.3.2"
|
|
28
|
+
|
|
29
|
+
// Kotlin Gradle Plugin
|
|
30
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
allprojects {
|
|
35
|
+
repositories {
|
|
36
|
+
mavenCentral()
|
|
37
|
+
google()
|
|
38
|
+
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
|
39
|
+
maven {
|
|
40
|
+
// React Native Android binaries
|
|
41
|
+
url "$rootDir/../node_modules/react-native/android"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
apply plugin: 'com.android.library'
|
|
47
|
+
apply plugin: 'org.jetbrains.kotlin.android'
|
|
48
|
+
|
|
49
|
+
def safeExtGet(prop, fallback) {
|
|
50
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
android {
|
|
54
|
+
namespace "com.ledger.androidtransporthid"
|
|
55
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 34)
|
|
56
|
+
|
|
57
|
+
defaultConfig {
|
|
58
|
+
minSdkVersion safeExtGet("minSdkVersion", 30)
|
|
59
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
|
60
|
+
versionCode 1
|
|
61
|
+
versionName "1.0"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
compileOptions {
|
|
65
|
+
// Use JavaVersion enums for compatibility
|
|
66
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
67
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
kotlinOptions {
|
|
71
|
+
jvmTarget = jvmTargetVersion
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
lintOptions {
|
|
75
|
+
abortOnError false
|
|
76
|
+
warning 'InvalidPackage'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
repositories {
|
|
81
|
+
mavenCentral()
|
|
82
|
+
google()
|
|
83
|
+
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
|
84
|
+
maven {
|
|
85
|
+
// React Native Android binaries
|
|
86
|
+
url "$rootDir/../node_modules/react-native/android"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
dependencies {
|
|
91
|
+
implementation 'com.facebook.react:react-native:+'
|
|
92
|
+
implementation "androidx.core:core-ktx:$androidCoreKtx_version"
|
|
93
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_stdlib_version"
|
|
94
|
+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
|
95
|
+
implementation "org.jetbrains.kotlinx:kotlinx-datetime:$kotlinx_datetime_version"
|
|
96
|
+
implementation "com.jakewharton.timber:timber:$timber_version"
|
|
97
|
+
implementation "com.ditchoom:buffer:$buffer_version"
|
|
98
|
+
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
|
|
99
|
+
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlin_coroutines_test_version"
|
|
100
|
+
testImplementation "junit:junit:4.13.2"
|
|
101
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
android.useAndroidX=true
|
package/android/gradlew
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Copyright © 2015-2021 the original authors.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
##############################################################################
|
|
22
|
+
#
|
|
23
|
+
# Gradle start up script for POSIX generated by Gradle.
|
|
24
|
+
#
|
|
25
|
+
# Important for running:
|
|
26
|
+
#
|
|
27
|
+
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
28
|
+
# noncompliant, but you have some other compliant shell such as ksh or
|
|
29
|
+
# bash, then to run this script, type that shell name before the whole
|
|
30
|
+
# command line, like:
|
|
31
|
+
#
|
|
32
|
+
# ksh Gradle
|
|
33
|
+
#
|
|
34
|
+
# Busybox and similar reduced shells will NOT work, because this script
|
|
35
|
+
# requires all of these POSIX shell features:
|
|
36
|
+
# * functions;
|
|
37
|
+
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
38
|
+
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
39
|
+
# * compound commands having a testable exit status, especially «case»;
|
|
40
|
+
# * various built-in commands including «command», «set», and «ulimit».
|
|
41
|
+
#
|
|
42
|
+
# Important for patching:
|
|
43
|
+
#
|
|
44
|
+
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
45
|
+
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
46
|
+
#
|
|
47
|
+
# The "traditional" practice of packing multiple parameters into a
|
|
48
|
+
# space-separated string is a well documented source of bugs and security
|
|
49
|
+
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
50
|
+
# options in "$@", and eventually passing that to Java.
|
|
51
|
+
#
|
|
52
|
+
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
53
|
+
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
54
|
+
# see the in-line comments for details.
|
|
55
|
+
#
|
|
56
|
+
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
57
|
+
# Darwin, MinGW, and NonStop.
|
|
58
|
+
#
|
|
59
|
+
# (3) This script is generated from the Groovy template
|
|
60
|
+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
61
|
+
# within the Gradle project.
|
|
62
|
+
#
|
|
63
|
+
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
64
|
+
#
|
|
65
|
+
##############################################################################
|
|
66
|
+
|
|
67
|
+
# Attempt to set APP_HOME
|
|
68
|
+
|
|
69
|
+
# Resolve links: $0 may be a link
|
|
70
|
+
app_path=$0
|
|
71
|
+
|
|
72
|
+
# Need this for daisy-chained symlinks.
|
|
73
|
+
while
|
|
74
|
+
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
75
|
+
[ -h "$app_path" ]
|
|
76
|
+
do
|
|
77
|
+
ls=$( ls -ld "$app_path" )
|
|
78
|
+
link=${ls#*' -> '}
|
|
79
|
+
case $link in #(
|
|
80
|
+
/*) app_path=$link ;; #(
|
|
81
|
+
*) app_path=$APP_HOME$link ;;
|
|
82
|
+
esac
|
|
83
|
+
done
|
|
84
|
+
|
|
85
|
+
# This is normally unused
|
|
86
|
+
# shellcheck disable=SC2034
|
|
87
|
+
APP_BASE_NAME=${0##*/}
|
|
88
|
+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
89
|
+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
|
90
|
+
' "$PWD" ) || exit
|
|
91
|
+
|
|
92
|
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
93
|
+
MAX_FD=maximum
|
|
94
|
+
|
|
95
|
+
warn () {
|
|
96
|
+
echo "$*"
|
|
97
|
+
} >&2
|
|
98
|
+
|
|
99
|
+
die () {
|
|
100
|
+
echo
|
|
101
|
+
echo "$*"
|
|
102
|
+
echo
|
|
103
|
+
exit 1
|
|
104
|
+
} >&2
|
|
105
|
+
|
|
106
|
+
# OS specific support (must be 'true' or 'false').
|
|
107
|
+
cygwin=false
|
|
108
|
+
msys=false
|
|
109
|
+
darwin=false
|
|
110
|
+
nonstop=false
|
|
111
|
+
case "$( uname )" in #(
|
|
112
|
+
CYGWIN* ) cygwin=true ;; #(
|
|
113
|
+
Darwin* ) darwin=true ;; #(
|
|
114
|
+
MSYS* | MINGW* ) msys=true ;; #(
|
|
115
|
+
NONSTOP* ) nonstop=true ;;
|
|
116
|
+
esac
|
|
117
|
+
|
|
118
|
+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# Determine the Java command to use to start the JVM.
|
|
122
|
+
if [ -n "$JAVA_HOME" ] ; then
|
|
123
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
124
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
|
125
|
+
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
126
|
+
else
|
|
127
|
+
JAVACMD=$JAVA_HOME/bin/java
|
|
128
|
+
fi
|
|
129
|
+
if [ ! -x "$JAVACMD" ] ; then
|
|
130
|
+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
131
|
+
|
|
132
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
133
|
+
location of your Java installation."
|
|
134
|
+
fi
|
|
135
|
+
else
|
|
136
|
+
JAVACMD=java
|
|
137
|
+
if ! command -v java >/dev/null 2>&1
|
|
138
|
+
then
|
|
139
|
+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
140
|
+
|
|
141
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
142
|
+
location of your Java installation."
|
|
143
|
+
fi
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
# Increase the maximum file descriptors if we can.
|
|
147
|
+
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
148
|
+
case $MAX_FD in #(
|
|
149
|
+
max*)
|
|
150
|
+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
151
|
+
# shellcheck disable=SC2039,SC3045
|
|
152
|
+
MAX_FD=$( ulimit -H -n ) ||
|
|
153
|
+
warn "Could not query maximum file descriptor limit"
|
|
154
|
+
esac
|
|
155
|
+
case $MAX_FD in #(
|
|
156
|
+
'' | soft) :;; #(
|
|
157
|
+
*)
|
|
158
|
+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
159
|
+
# shellcheck disable=SC2039,SC3045
|
|
160
|
+
ulimit -n "$MAX_FD" ||
|
|
161
|
+
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
162
|
+
esac
|
|
163
|
+
fi
|
|
164
|
+
|
|
165
|
+
# Collect all arguments for the java command, stacking in reverse order:
|
|
166
|
+
# * args from the command line
|
|
167
|
+
# * the main class name
|
|
168
|
+
# * -classpath
|
|
169
|
+
# * -D...appname settings
|
|
170
|
+
# * --module-path (only if needed)
|
|
171
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
172
|
+
|
|
173
|
+
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
174
|
+
if "$cygwin" || "$msys" ; then
|
|
175
|
+
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
176
|
+
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
177
|
+
|
|
178
|
+
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
179
|
+
|
|
180
|
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
181
|
+
for arg do
|
|
182
|
+
if
|
|
183
|
+
case $arg in #(
|
|
184
|
+
-*) false ;; # don't mess with options #(
|
|
185
|
+
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
186
|
+
[ -e "$t" ] ;; #(
|
|
187
|
+
*) false ;;
|
|
188
|
+
esac
|
|
189
|
+
then
|
|
190
|
+
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
191
|
+
fi
|
|
192
|
+
# Roll the args list around exactly as many times as the number of
|
|
193
|
+
# args, so each arg winds up back in the position where it started, but
|
|
194
|
+
# possibly modified.
|
|
195
|
+
#
|
|
196
|
+
# NB: a `for` loop captures its iteration list before it begins, so
|
|
197
|
+
# changing the positional parameters here affects neither the number of
|
|
198
|
+
# iterations, nor the values presented in `arg`.
|
|
199
|
+
shift # remove old arg
|
|
200
|
+
set -- "$@" "$arg" # push replacement arg
|
|
201
|
+
done
|
|
202
|
+
fi
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
206
|
+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
207
|
+
|
|
208
|
+
# Collect all arguments for the java command:
|
|
209
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
210
|
+
# and any embedded shellness will be escaped.
|
|
211
|
+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
212
|
+
# treated as '${Hostname}' itself on the command line.
|
|
213
|
+
|
|
214
|
+
set -- \
|
|
215
|
+
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
216
|
+
-classpath "$CLASSPATH" \
|
|
217
|
+
org.gradle.wrapper.GradleWrapperMain \
|
|
218
|
+
"$@"
|
|
219
|
+
|
|
220
|
+
# Stop when "xargs" is not available.
|
|
221
|
+
if ! command -v xargs >/dev/null 2>&1
|
|
222
|
+
then
|
|
223
|
+
die "xargs is not available"
|
|
224
|
+
fi
|
|
225
|
+
|
|
226
|
+
# Use "xargs" to parse quoted args.
|
|
227
|
+
#
|
|
228
|
+
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
229
|
+
#
|
|
230
|
+
# In Bash we could simply go:
|
|
231
|
+
#
|
|
232
|
+
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
233
|
+
# set -- "${ARGS[@]}" "$@"
|
|
234
|
+
#
|
|
235
|
+
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
236
|
+
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
237
|
+
# character that might be a shell metacharacter, then use eval to reverse
|
|
238
|
+
# that process (while maintaining the separation between arguments), and wrap
|
|
239
|
+
# the whole thing up as a single "set" statement.
|
|
240
|
+
#
|
|
241
|
+
# This will of course break if any of these variables contains a newline or
|
|
242
|
+
# an unmatched quote.
|
|
243
|
+
#
|
|
244
|
+
|
|
245
|
+
eval "set -- $(
|
|
246
|
+
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
247
|
+
xargs -n1 |
|
|
248
|
+
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
249
|
+
tr '\n' ' '
|
|
250
|
+
)" '"$@"'
|
|
251
|
+
|
|
252
|
+
exec "$JAVACMD" "$@"
|