@doordeck/headless-react-native-sdk 0.83.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.
- package/HeadlessReactNativeSdk.podspec +44 -0
- package/LICENSE +174 -0
- package/README.md +113 -0
- package/android/build.gradle +118 -0
- package/android/generated/java/com/doordeck/headlessreactnativesdk/NativeHeadlessReactNativeSdkSpec.java +62 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNHeadlessReactNativeSdkSpec-generated.cpp +68 -0
- package/android/generated/jni/RNHeadlessReactNativeSdkSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNHeadlessReactNativeSdkSpec/RNHeadlessReactNativeSdkSpecJSI-generated.cpp +68 -0
- package/android/generated/jni/react/renderer/components/RNHeadlessReactNativeSdkSpec/RNHeadlessReactNativeSdkSpecJSI.h +307 -0
- package/android/gradle.properties +5 -0
- package/android/settings.gradle.kts +16 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/doordeck/headlessreactnativesdk/HeadlessReactNativeSdkModule.kt +176 -0
- package/android/src/main/java/com/doordeck/headlessreactnativesdk/HeadlessReactNativeSdkPackage.kt +43 -0
- package/ios/HeadlessReactNativeSdk.h +6 -0
- package/ios/HeadlessReactNativeSdk.mm +54 -0
- package/ios/HeadlessReactNativeSdkImpl.swift +210 -0
- package/ios/generated/RNHeadlessReactNativeSdkSpec/RNHeadlessReactNativeSdkSpec-generated.mm +81 -0
- package/ios/generated/RNHeadlessReactNativeSdkSpec/RNHeadlessReactNativeSdkSpec.h +81 -0
- package/ios/generated/RNHeadlessReactNativeSdkSpecJSI-generated.cpp +68 -0
- package/ios/generated/RNHeadlessReactNativeSdkSpecJSI.h +307 -0
- package/lib/commonjs/NativeHeadlessReactNativeSdk.js +9 -0
- package/lib/commonjs/NativeHeadlessReactNativeSdk.js.map +1 -0
- package/lib/commonjs/index.js +36 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/NativeHeadlessReactNativeSdk.js +5 -0
- package/lib/module/NativeHeadlessReactNativeSdk.js.map +1 -0
- package/lib/module/index.js +25 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeHeadlessReactNativeSdk.d.ts +72 -0
- package/lib/typescript/commonjs/src/NativeHeadlessReactNativeSdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +9 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeHeadlessReactNativeSdk.d.ts +72 -0
- package/lib/typescript/module/src/NativeHeadlessReactNativeSdk.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +9 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +203 -0
- package/react-native.config.js +12 -0
- package/src/NativeHeadlessReactNativeSdk.ts +87 -0
- package/src/index.tsx +35 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "HeadlessReactNativeSdk"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
|
|
14
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
15
|
+
s.source = { :git => "https://github.com/doordeck/doordeck-headless-sdk-react-native.git", :tag => "#{s.version}" }
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
18
|
+
s.private_header_files = "ios/**/*.h"
|
|
19
|
+
s.preserve_paths = "ios/**/*.{h,m,mm,swift}"
|
|
20
|
+
|
|
21
|
+
doordeck_sdk_version = '0.83.0'
|
|
22
|
+
s.dependency "DoordeckSDK", "~> #{doordeck_sdk_version}"
|
|
23
|
+
|
|
24
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
25
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
26
|
+
s.dependency "React-Core"
|
|
27
|
+
|
|
28
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
29
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
30
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
31
|
+
s.pod_target_xcconfig = {
|
|
32
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
33
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1",
|
|
34
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
35
|
+
}
|
|
36
|
+
s.dependency "React-Codegen"
|
|
37
|
+
s.dependency "RCT-Folly"
|
|
38
|
+
s.dependency "RCTRequired"
|
|
39
|
+
s.dependency "RCTTypeSafety"
|
|
40
|
+
# There is a bug importing <ReactCommon/RCTTurboModule.h>
|
|
41
|
+
# s.dependency "ReactCommon/turbomodule/core"
|
|
42
|
+
s.dependency "React"
|
|
43
|
+
end
|
|
44
|
+
end
|
package/LICENSE
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# @doordeck/headless-react-native-sdk
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
The `@doordeck/headless-react-native-sdk` is a lightweight React Native SDK built on top of the Doordeck SDK. This SDK provides a minimal interface for authentication and lock management, focusing on user-facing operations. It enables React Native applications to authenticate users, manage authentication tokens, retrieve lock details, and unlock devices via Doordeck's platform.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
To install the SDK, ensure you have React Native set up in your project, then add the necessary dependencies:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @doordeck/headless-react-native-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or using yarn:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
yarn add @doordeck/headless-react-native-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Importing the SDK
|
|
22
|
+
|
|
23
|
+
Import every single method according to your usage
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
import { login } from '@doordeck/headless-react-native-sdk';
|
|
27
|
+
// ...
|
|
28
|
+
import { logout } from '@doordeck/headless-react-native-sdk';
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Authentication Methods
|
|
32
|
+
|
|
33
|
+
#### `login(email: string, password: string): Promise<AssistedRegisterEphemeralKeyResponse>`
|
|
34
|
+
Logs the user in with their email and password.
|
|
35
|
+
|
|
36
|
+
> **Note:** If login is performed without verification within the same session, authentication will only persist in runtime memory and will be lost when the app restarts.
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
import { login } from '@doordeck/headless-react-native-sdk';
|
|
40
|
+
|
|
41
|
+
login("user@example.com", "password123")
|
|
42
|
+
.then(response => console.log("Login successful", response))
|
|
43
|
+
.catch(error => console.error("Login failed", error));
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### `setAuthToken(authToken: string): Promise<AssistedRegisterEphemeralKeyResponse>`
|
|
47
|
+
Sets an authentication token manually.
|
|
48
|
+
|
|
49
|
+
> **Note:** Like login, authentication without verification will only persist in runtime memory and will be lost after the app restarts.
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
import { setAuthToken } from '@doordeck/headless-react-native-sdk';
|
|
53
|
+
|
|
54
|
+
setAuthToken("your-auth-token")
|
|
55
|
+
.then(response => console.log("Token set successfully", response))
|
|
56
|
+
.catch(error => console.error("Error setting token", error));
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### `verify(code: string): Promise<void>`
|
|
60
|
+
Verifies an ephemeral key registration with a verification code. Upon successful verification, the user ID and authentication context are saved in persistent storage.
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
import { verify } from '@doordeck/headless-react-native-sdk';
|
|
64
|
+
|
|
65
|
+
verify("123456")
|
|
66
|
+
.then(() => console.log("Verification successful"))
|
|
67
|
+
.catch(error => console.error("Verification failed", error));
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### `logout(): Promise<void>`
|
|
71
|
+
Logs out the current user and clears the stored authentication context, including removing the persistent user ID.
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
import { logout } from '@doordeck/headless-react-native-sdk';
|
|
75
|
+
|
|
76
|
+
logout()
|
|
77
|
+
.then(() => console.log("Logged out"))
|
|
78
|
+
.catch(error => console.error("Logout failed", error));
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Device and Tile Operations
|
|
82
|
+
|
|
83
|
+
#### `getLocksBelongingToTile(tileId: string): Promise<TileLocksResponse>`
|
|
84
|
+
Retrieves a list of locks associated with a specific tile.
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
import { getLocksBelongingToTile } from '@doordeck/headless-react-native-sdk';
|
|
88
|
+
|
|
89
|
+
getLocksBelongingToTile("tile-uuid")
|
|
90
|
+
.then(response => console.log("Locks: ", response))
|
|
91
|
+
.catch(error => console.error("Failed to get locks", error));
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### `unlockDevice(lockId: string): Promise<void>`
|
|
95
|
+
Unlocks a device given its lock ID.
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
import { unlockDevice } from '@doordeck/headless-react-native-sdk';
|
|
99
|
+
|
|
100
|
+
unlockDevice("lock-uuid")
|
|
101
|
+
.then(() => console.log("Device unlocked"))
|
|
102
|
+
.catch(error => console.error("Unlock failed", error));
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Error Handling
|
|
106
|
+
Each method returns a `Promise`. If an error occurs, the `catch` block will handle the failure, returning an error object containing an error code and message.
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
This SDK follows the Doordeck licensing agreement. Ensure compliance with Doordeck's API usage policies before integrating this SDK into your project.
|
|
110
|
+
|
|
111
|
+
## Support
|
|
112
|
+
For additional support, refer to the [Doordeck Developer Documentation](https://developer.doordeck.com/docs/#introduction).
|
|
113
|
+
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['HeadlessReactNativeSdk_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def isNewArchitectureEnabled() {
|
|
20
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
apply plugin: "com.android.library"
|
|
24
|
+
apply plugin: "kotlin-android"
|
|
25
|
+
|
|
26
|
+
if (isNewArchitectureEnabled()) {
|
|
27
|
+
apply plugin: "com.facebook.react"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
def getExtOrIntegerDefault(name) {
|
|
31
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["HeadlessReactNativeSdk_" + name]).toInteger()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def supportsNamespace() {
|
|
35
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
36
|
+
def major = parsed[0].toInteger()
|
|
37
|
+
def minor = parsed[1].toInteger()
|
|
38
|
+
|
|
39
|
+
// Namespace support was added in 7.3.0
|
|
40
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
android {
|
|
44
|
+
if (supportsNamespace()) {
|
|
45
|
+
namespace "com.doordeck.headlessreactnativesdk"
|
|
46
|
+
|
|
47
|
+
sourceSets {
|
|
48
|
+
main {
|
|
49
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
55
|
+
|
|
56
|
+
defaultConfig {
|
|
57
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
58
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
59
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
buildFeatures {
|
|
63
|
+
buildConfig true
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
buildTypes {
|
|
67
|
+
release {
|
|
68
|
+
minifyEnabled false
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
lintOptions {
|
|
73
|
+
disable "GradleCompatible"
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
compileOptions {
|
|
77
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
78
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
sourceSets {
|
|
82
|
+
main {
|
|
83
|
+
if (isNewArchitectureEnabled()) {
|
|
84
|
+
java.srcDirs += [
|
|
85
|
+
"generated/java",
|
|
86
|
+
"generated/jni"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
repositories {
|
|
94
|
+
mavenCentral()
|
|
95
|
+
google()
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
100
|
+
|
|
101
|
+
def doordeckSdkVersion = "0.83.0"
|
|
102
|
+
|
|
103
|
+
dependencies {
|
|
104
|
+
implementation "com.facebook.react:react-android"
|
|
105
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
106
|
+
implementation "com.doordeck.headless.sdk:doordeck-sdk-android:$doordeckSdkVersion"
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (isNewArchitectureEnabled()) {
|
|
110
|
+
react {
|
|
111
|
+
jsRootDir = file("../src/")
|
|
112
|
+
libraryName = "HeadlessReactNativeSdk"
|
|
113
|
+
codegenJavaPackageName = "com.doordeck.headlessreactnativesdk"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package com.doordeck.headlessreactnativesdk;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.Promise;
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
20
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
21
|
+
import javax.annotation.Nonnull;
|
|
22
|
+
|
|
23
|
+
public abstract class NativeHeadlessReactNativeSdkSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
24
|
+
public static final String NAME = "HeadlessReactNativeSdk";
|
|
25
|
+
|
|
26
|
+
public NativeHeadlessReactNativeSdkSpec(ReactApplicationContext reactContext) {
|
|
27
|
+
super(reactContext);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public @Nonnull String getName() {
|
|
32
|
+
return NAME;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@ReactMethod
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
public abstract void login(String email, String password, Promise promise);
|
|
38
|
+
|
|
39
|
+
@ReactMethod
|
|
40
|
+
@DoNotStrip
|
|
41
|
+
public abstract void setAuthToken(String authToken, Promise promise);
|
|
42
|
+
|
|
43
|
+
@ReactMethod
|
|
44
|
+
@DoNotStrip
|
|
45
|
+
public abstract void getUserDetails(Promise promise);
|
|
46
|
+
|
|
47
|
+
@ReactMethod
|
|
48
|
+
@DoNotStrip
|
|
49
|
+
public abstract void verify(String code, Promise promise);
|
|
50
|
+
|
|
51
|
+
@ReactMethod
|
|
52
|
+
@DoNotStrip
|
|
53
|
+
public abstract void logout(Promise promise);
|
|
54
|
+
|
|
55
|
+
@ReactMethod
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
public abstract void getLocksBelongingToTile(String tileId, Promise promise);
|
|
58
|
+
|
|
59
|
+
@ReactMethod
|
|
60
|
+
@DoNotStrip
|
|
61
|
+
public abstract void unlockDevice(String lockId, Promise promise);
|
|
62
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
cmake_minimum_required(VERSION 3.13)
|
|
7
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
8
|
+
|
|
9
|
+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNHeadlessReactNativeSdkSpec/*.cpp)
|
|
10
|
+
|
|
11
|
+
add_library(
|
|
12
|
+
react_codegen_RNHeadlessReactNativeSdkSpec
|
|
13
|
+
OBJECT
|
|
14
|
+
${react_codegen_SRCS}
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
target_include_directories(react_codegen_RNHeadlessReactNativeSdkSpec PUBLIC . react/renderer/components/RNHeadlessReactNativeSdkSpec)
|
|
18
|
+
|
|
19
|
+
target_link_libraries(
|
|
20
|
+
react_codegen_RNHeadlessReactNativeSdkSpec
|
|
21
|
+
fbjni
|
|
22
|
+
jsi
|
|
23
|
+
# We need to link different libraries based on whether we are building rncore or not, that's necessary
|
|
24
|
+
# because we want to break a circular dependency between react_codegen_rncore and reactnative
|
|
25
|
+
reactnative
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
target_compile_options(
|
|
29
|
+
react_codegen_RNHeadlessReactNativeSdkSpec
|
|
30
|
+
PRIVATE
|
|
31
|
+
-DLOG_TAG=\"ReactNative\"
|
|
32
|
+
-fexceptions
|
|
33
|
+
-frtti
|
|
34
|
+
-std=c++20
|
|
35
|
+
-Wall
|
|
36
|
+
)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "RNHeadlessReactNativeSdkSpec.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
static facebook::jsi::Value __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_login(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
16
|
+
static jmethodID cachedMethodId = nullptr;
|
|
17
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "login", "(Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static facebook::jsi::Value __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_setAuthToken(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
|
+
static jmethodID cachedMethodId = nullptr;
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "setAuthToken", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static facebook::jsi::Value __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_getUserDetails(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
26
|
+
static jmethodID cachedMethodId = nullptr;
|
|
27
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getUserDetails", "(Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static facebook::jsi::Value __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_verify(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
31
|
+
static jmethodID cachedMethodId = nullptr;
|
|
32
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "verify", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static facebook::jsi::Value __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_logout(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
36
|
+
static jmethodID cachedMethodId = nullptr;
|
|
37
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "logout", "(Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static facebook::jsi::Value __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_getLocksBelongingToTile(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
41
|
+
static jmethodID cachedMethodId = nullptr;
|
|
42
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getLocksBelongingToTile", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static facebook::jsi::Value __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_unlockDevice(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
46
|
+
static jmethodID cachedMethodId = nullptr;
|
|
47
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "unlockDevice", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
NativeHeadlessReactNativeSdkSpecJSI::NativeHeadlessReactNativeSdkSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
51
|
+
: JavaTurboModule(params) {
|
|
52
|
+
methodMap_["login"] = MethodMetadata {2, __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_login};
|
|
53
|
+
methodMap_["setAuthToken"] = MethodMetadata {1, __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_setAuthToken};
|
|
54
|
+
methodMap_["getUserDetails"] = MethodMetadata {0, __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_getUserDetails};
|
|
55
|
+
methodMap_["verify"] = MethodMetadata {1, __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_verify};
|
|
56
|
+
methodMap_["logout"] = MethodMetadata {0, __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_logout};
|
|
57
|
+
methodMap_["getLocksBelongingToTile"] = MethodMetadata {1, __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_getLocksBelongingToTile};
|
|
58
|
+
methodMap_["unlockDevice"] = MethodMetadata {1, __hostFunction_NativeHeadlessReactNativeSdkSpecJSI_unlockDevice};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
std::shared_ptr<TurboModule> RNHeadlessReactNativeSdkSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
|
62
|
+
if (moduleName == "HeadlessReactNativeSdk") {
|
|
63
|
+
return std::make_shared<NativeHeadlessReactNativeSdkSpecJSI>(params);
|
|
64
|
+
}
|
|
65
|
+
return nullptr;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
14
|
+
#include <ReactCommon/TurboModule.h>
|
|
15
|
+
#include <jsi/jsi.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JNI C++ class for module 'NativeHeadlessReactNativeSdk'
|
|
21
|
+
*/
|
|
22
|
+
class JSI_EXPORT NativeHeadlessReactNativeSdkSpecJSI : public JavaTurboModule {
|
|
23
|
+
public:
|
|
24
|
+
NativeHeadlessReactNativeSdkSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
JSI_EXPORT
|
|
29
|
+
std::shared_ptr<TurboModule> RNHeadlessReactNativeSdkSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
|
|
30
|
+
|
|
31
|
+
} // namespace facebook::react
|