@doordeck/headless-react-native-sdk 0.86.0 → 1.0.7
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 +15 -23
- package/android/build.gradle +7 -7
- package/android/generated/jni/CMakeLists.txt +1 -9
- package/android/generated/jni/react/renderer/components/RNHeadlessReactNativeSdkSpec/RNHeadlessReactNativeSdkSpecJSI.h +66 -108
- package/android/gradle.properties +4 -4
- package/android/src/main/java/com/doordeck/headlessreactnativesdk/HeadlessReactNativeSdkModule.kt +25 -23
- package/android/src/main/java/com/doordeck/headlessreactnativesdk/HeadlessReactNativeSdkPackage.kt +5 -6
- package/ios/HeadlessReactNativeSdk.h +1 -1
- package/ios/HeadlessReactNativeSdkImpl.swift +103 -77
- package/ios/generated/{RNHeadlessReactNativeSdkSpecJSI.h → ReactCodegen/RNHeadlessReactNativeSdkSpecJSI.h} +66 -108
- package/lib/commonjs/NativeHeadlessReactNativeSdk.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/module/NativeHeadlessReactNativeSdk.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeHeadlessReactNativeSdk.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeHeadlessReactNativeSdk.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +32 -52
- package/src/NativeHeadlessReactNativeSdk.ts +8 -8
- package/src/index.tsx +13 -8
- package/android/generated/jni/react/renderer/components/RNHeadlessReactNativeSdkSpec/RNHeadlessReactNativeSdkSpecJSI-generated.cpp +0 -68
- package/ios/generated/RNHeadlessReactNativeSdkSpecJSI-generated.cpp +0 -68
- /package/ios/generated/{RNHeadlessReactNativeSdkSpec → ReactCodegen/RNHeadlessReactNativeSdkSpec}/RNHeadlessReactNativeSdkSpec-generated.mm +0 -0
- /package/ios/generated/{RNHeadlessReactNativeSdkSpec → ReactCodegen/RNHeadlessReactNativeSdkSpec}/RNHeadlessReactNativeSdkSpec.h +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
|
|
3
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
4
|
|
|
6
5
|
Pod::Spec.new do |s|
|
|
7
6
|
s.name = "HeadlessReactNativeSdk"
|
|
@@ -18,27 +17,20 @@ Pod::Spec.new do |s|
|
|
|
18
17
|
s.private_header_files = "ios/**/*.h"
|
|
19
18
|
s.preserve_paths = "ios/**/*.{h,m,mm,swift}"
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
# The native Doordeck SDK is distributed as a Swift Package (a binary xcframework),
|
|
21
|
+
# not as a CocoaPods pod. Wire it in via React Native's built-in SPM support
|
|
22
|
+
# (spm_dependency, available on RN >= 0.76). The SPM product/module is "DoordeckSDK",
|
|
23
|
+
# so `import DoordeckSDK` in the Swift bridge continues to work unchanged.
|
|
24
|
+
spm_dependency(s,
|
|
25
|
+
url: 'https://github.com/doordeck/doordeck-headless-sdk-spm.git',
|
|
26
|
+
requirement: { kind: 'exactVersion', version: '1.128.0' },
|
|
27
|
+
products: ['DoordeckSDK']
|
|
28
|
+
)
|
|
23
29
|
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#
|
|
29
|
-
|
|
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
|
|
30
|
+
# Install all React Native dependencies (React-Core, RCT-Folly, RCTRequired,
|
|
31
|
+
# RCTTypeSafety, ReactCommon, codegen, New Architecture flags, etc.) via the
|
|
32
|
+
# official helper. This resolves the correct spec sources for the installed RN
|
|
33
|
+
# version — replacing the hand-maintained dependency list, which broke on RN
|
|
34
|
+
# 0.86 (`Unable to find a specification for RCT-Folly`).
|
|
35
|
+
install_modules_dependencies(s)
|
|
44
36
|
end
|
package/android/build.gradle
CHANGED
|
@@ -9,7 +9,7 @@ buildscript {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
dependencies {
|
|
12
|
-
classpath "com.android.tools.build:gradle:8.
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.13.2"
|
|
13
13
|
// noinspection DifferentKotlinGradleVersion
|
|
14
14
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
15
|
}
|
|
@@ -51,11 +51,11 @@ android {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
compileSdk getExtOrIntegerDefault("compileSdkVersion")
|
|
55
55
|
|
|
56
56
|
defaultConfig {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
minSdk getExtOrIntegerDefault("minSdkVersion")
|
|
58
|
+
targetSdk getExtOrIntegerDefault("targetSdkVersion")
|
|
59
59
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -69,8 +69,8 @@ android {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
disable "GradleCompatible"
|
|
72
|
+
lint {
|
|
73
|
+
disable += "GradleCompatible"
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
compileOptions {
|
|
@@ -98,7 +98,7 @@ repositories {
|
|
|
98
98
|
|
|
99
99
|
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
100
100
|
|
|
101
|
-
def doordeckSdkVersion = "0.
|
|
101
|
+
def doordeckSdkVersion = "0.185.0"
|
|
102
102
|
|
|
103
103
|
dependencies {
|
|
104
104
|
implementation "com.facebook.react:react-android"
|
|
@@ -25,12 +25,4 @@ target_link_libraries(
|
|
|
25
25
|
reactnative
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
react_codegen_RNHeadlessReactNativeSdkSpec
|
|
30
|
-
PRIVATE
|
|
31
|
-
-DLOG_TAG=\"ReactNative\"
|
|
32
|
-
-fexceptions
|
|
33
|
-
-frtti
|
|
34
|
-
-std=c++20
|
|
35
|
-
-Wall
|
|
36
|
-
)
|
|
28
|
+
target_compile_reactnative_options(react_codegen_RNHeadlessReactNativeSdkSpec PRIVATE)
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
namespace facebook::react {
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
#pragma mark - NativeHeadlessReactNativeSdkAssistedRegisterEphemeralKeyResponse
|
|
20
19
|
|
|
21
20
|
template <typename P0>
|
|
@@ -61,8 +60,8 @@ struct NativeHeadlessReactNativeSdkAssistedRegisterEphemeralKeyResponseBridging
|
|
|
61
60
|
|
|
62
61
|
template <typename P0, typename P1, typename P2>
|
|
63
62
|
struct NativeHeadlessReactNativeSdkTileLocksResponse {
|
|
64
|
-
P0 siteId;
|
|
65
|
-
P1 tileId;
|
|
63
|
+
P0 siteId{};
|
|
64
|
+
P1 tileId{};
|
|
66
65
|
P2 deviceIds;
|
|
67
66
|
bool operator==(const NativeHeadlessReactNativeSdkTileLocksResponse &other) const {
|
|
68
67
|
return siteId == other.siteId && tileId == other.tileId && deviceIds == other.deviceIds;
|
|
@@ -88,11 +87,9 @@ struct NativeHeadlessReactNativeSdkTileLocksResponseBridging {
|
|
|
88
87
|
static jsi::String siteIdToJs(jsi::Runtime &rt, decltype(types.siteId) value) {
|
|
89
88
|
return bridging::toJs(rt, value);
|
|
90
89
|
}
|
|
91
|
-
|
|
92
90
|
static jsi::String tileIdToJs(jsi::Runtime &rt, decltype(types.tileId) value) {
|
|
93
91
|
return bridging::toJs(rt, value);
|
|
94
92
|
}
|
|
95
|
-
|
|
96
93
|
static jsi::Array deviceIdsToJs(jsi::Runtime &rt, decltype(types.deviceIds) value) {
|
|
97
94
|
return bridging::toJs(rt, value);
|
|
98
95
|
}
|
|
@@ -116,12 +113,12 @@ struct NativeHeadlessReactNativeSdkTileLocksResponseBridging {
|
|
|
116
113
|
|
|
117
114
|
template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
|
|
118
115
|
struct NativeHeadlessReactNativeSdkUserDetailsResponse {
|
|
119
|
-
P0 userId;
|
|
120
|
-
P1 publicKey;
|
|
121
|
-
P2 email;
|
|
122
|
-
P3 displayName;
|
|
123
|
-
P4 emailVerified;
|
|
124
|
-
P5 certificateChainAboutToExpire;
|
|
116
|
+
P0 userId{};
|
|
117
|
+
P1 publicKey{};
|
|
118
|
+
P2 email{};
|
|
119
|
+
P3 displayName{};
|
|
120
|
+
P4 emailVerified{};
|
|
121
|
+
P5 certificateChainAboutToExpire{};
|
|
125
122
|
P6 tokenAboutToExpire;
|
|
126
123
|
bool operator==(const NativeHeadlessReactNativeSdkUserDetailsResponse &other) const {
|
|
127
124
|
return userId == other.userId && publicKey == other.publicKey && email == other.email && displayName == other.displayName && emailVerified == other.emailVerified && certificateChainAboutToExpire == other.certificateChainAboutToExpire && tokenAboutToExpire == other.tokenAboutToExpire;
|
|
@@ -151,27 +148,21 @@ struct NativeHeadlessReactNativeSdkUserDetailsResponseBridging {
|
|
|
151
148
|
static jsi::String userIdToJs(jsi::Runtime &rt, decltype(types.userId) value) {
|
|
152
149
|
return bridging::toJs(rt, value);
|
|
153
150
|
}
|
|
154
|
-
|
|
155
151
|
static jsi::String publicKeyToJs(jsi::Runtime &rt, decltype(types.publicKey) value) {
|
|
156
152
|
return bridging::toJs(rt, value);
|
|
157
153
|
}
|
|
158
|
-
|
|
159
154
|
static jsi::String emailToJs(jsi::Runtime &rt, decltype(types.email) value) {
|
|
160
155
|
return bridging::toJs(rt, value);
|
|
161
156
|
}
|
|
162
|
-
|
|
163
157
|
static jsi::String displayNameToJs(jsi::Runtime &rt, decltype(types.displayName) value) {
|
|
164
158
|
return bridging::toJs(rt, value);
|
|
165
159
|
}
|
|
166
|
-
|
|
167
160
|
static bool emailVerifiedToJs(jsi::Runtime &rt, decltype(types.emailVerified) value) {
|
|
168
161
|
return bridging::toJs(rt, value);
|
|
169
162
|
}
|
|
170
|
-
|
|
171
163
|
static bool certificateChainAboutToExpireToJs(jsi::Runtime &rt, decltype(types.certificateChainAboutToExpire) value) {
|
|
172
164
|
return bridging::toJs(rt, value);
|
|
173
165
|
}
|
|
174
|
-
|
|
175
166
|
static bool tokenAboutToExpireToJs(jsi::Runtime &rt, decltype(types.tokenAboutToExpire) value) {
|
|
176
167
|
return bridging::toJs(rt, value);
|
|
177
168
|
}
|
|
@@ -197,111 +188,78 @@ struct NativeHeadlessReactNativeSdkUserDetailsResponseBridging {
|
|
|
197
188
|
}
|
|
198
189
|
};
|
|
199
190
|
|
|
200
|
-
class JSI_EXPORT NativeHeadlessReactNativeSdkCxxSpecJSI : public TurboModule {
|
|
201
|
-
protected:
|
|
202
|
-
NativeHeadlessReactNativeSdkCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
203
|
-
|
|
204
|
-
public:
|
|
205
|
-
virtual jsi::Value login(jsi::Runtime &rt, jsi::String email, jsi::String password) = 0;
|
|
206
|
-
virtual jsi::Value setAuthToken(jsi::Runtime &rt, jsi::String authToken) = 0;
|
|
207
|
-
virtual jsi::Value getUserDetails(jsi::Runtime &rt) = 0;
|
|
208
|
-
virtual jsi::Value verify(jsi::Runtime &rt, jsi::String code) = 0;
|
|
209
|
-
virtual jsi::Value logout(jsi::Runtime &rt) = 0;
|
|
210
|
-
virtual jsi::Value getLocksBelongingToTile(jsi::Runtime &rt, jsi::String tileId) = 0;
|
|
211
|
-
virtual jsi::Value unlockDevice(jsi::Runtime &rt, jsi::String lockId) = 0;
|
|
212
|
-
|
|
213
|
-
};
|
|
214
191
|
|
|
215
192
|
template <typename T>
|
|
216
193
|
class JSI_EXPORT NativeHeadlessReactNativeSdkCxxSpec : public TurboModule {
|
|
217
194
|
public:
|
|
218
|
-
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
219
|
-
return delegate_.create(rt, propName);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
223
|
-
return delegate_.getPropertyNames(runtime);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
195
|
static constexpr std::string_view kModuleName = "HeadlessReactNativeSdk";
|
|
227
196
|
|
|
228
197
|
protected:
|
|
229
|
-
NativeHeadlessReactNativeSdkCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
198
|
+
NativeHeadlessReactNativeSdkCxxSpec(std::shared_ptr<CallInvoker> jsInvoker) : TurboModule(std::string{NativeHeadlessReactNativeSdkCxxSpec::kModuleName}, jsInvoker) {
|
|
199
|
+
methodMap_["login"] = MethodMetadata {.argCount = 2, .invoker = __login};
|
|
200
|
+
methodMap_["setAuthToken"] = MethodMetadata {.argCount = 1, .invoker = __setAuthToken};
|
|
201
|
+
methodMap_["getUserDetails"] = MethodMetadata {.argCount = 0, .invoker = __getUserDetails};
|
|
202
|
+
methodMap_["verify"] = MethodMetadata {.argCount = 1, .invoker = __verify};
|
|
203
|
+
methodMap_["logout"] = MethodMetadata {.argCount = 0, .invoker = __logout};
|
|
204
|
+
methodMap_["getLocksBelongingToTile"] = MethodMetadata {.argCount = 1, .invoker = __getLocksBelongingToTile};
|
|
205
|
+
methodMap_["unlockDevice"] = MethodMetadata {.argCount = 1, .invoker = __unlockDevice};
|
|
206
|
+
}
|
|
207
|
+
|
|
234
208
|
private:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
static_assert(
|
|
244
|
-
bridging::getParameterCount(&T::login) == 3,
|
|
245
|
-
"Expected login(...) to have 3 parameters");
|
|
246
|
-
|
|
247
|
-
return bridging::callFromJs<jsi::Value>(
|
|
248
|
-
rt, &T::login, jsInvoker_, instance_, std::move(email), std::move(password));
|
|
249
|
-
}
|
|
250
|
-
jsi::Value setAuthToken(jsi::Runtime &rt, jsi::String authToken) override {
|
|
251
|
-
static_assert(
|
|
252
|
-
bridging::getParameterCount(&T::setAuthToken) == 2,
|
|
253
|
-
"Expected setAuthToken(...) to have 2 parameters");
|
|
254
|
-
|
|
255
|
-
return bridging::callFromJs<jsi::Value>(
|
|
256
|
-
rt, &T::setAuthToken, jsInvoker_, instance_, std::move(authToken));
|
|
257
|
-
}
|
|
258
|
-
jsi::Value getUserDetails(jsi::Runtime &rt) override {
|
|
259
|
-
static_assert(
|
|
260
|
-
bridging::getParameterCount(&T::getUserDetails) == 1,
|
|
261
|
-
"Expected getUserDetails(...) to have 1 parameters");
|
|
262
|
-
|
|
263
|
-
return bridging::callFromJs<jsi::Value>(
|
|
264
|
-
rt, &T::getUserDetails, jsInvoker_, instance_);
|
|
265
|
-
}
|
|
266
|
-
jsi::Value verify(jsi::Runtime &rt, jsi::String code) override {
|
|
267
|
-
static_assert(
|
|
268
|
-
bridging::getParameterCount(&T::verify) == 2,
|
|
269
|
-
"Expected verify(...) to have 2 parameters");
|
|
209
|
+
static jsi::Value __login(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
210
|
+
static_assert(
|
|
211
|
+
bridging::getParameterCount(&T::login) == 3,
|
|
212
|
+
"Expected login(...) to have 3 parameters");
|
|
213
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::login, static_cast<NativeHeadlessReactNativeSdkCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
214
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
215
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt));
|
|
216
|
+
}
|
|
270
217
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
218
|
+
static jsi::Value __setAuthToken(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
219
|
+
static_assert(
|
|
220
|
+
bridging::getParameterCount(&T::setAuthToken) == 2,
|
|
221
|
+
"Expected setAuthToken(...) to have 2 parameters");
|
|
222
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::setAuthToken, static_cast<NativeHeadlessReactNativeSdkCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
223
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt));
|
|
224
|
+
}
|
|
278
225
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
"Expected getLocksBelongingToTile(...) to have 2 parameters");
|
|
226
|
+
static jsi::Value __getUserDetails(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
|
|
227
|
+
static_assert(
|
|
228
|
+
bridging::getParameterCount(&T::getUserDetails) == 1,
|
|
229
|
+
"Expected getUserDetails(...) to have 1 parameters");
|
|
230
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::getUserDetails, static_cast<NativeHeadlessReactNativeSdkCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
|
|
231
|
+
}
|
|
286
232
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
233
|
+
static jsi::Value __verify(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
234
|
+
static_assert(
|
|
235
|
+
bridging::getParameterCount(&T::verify) == 2,
|
|
236
|
+
"Expected verify(...) to have 2 parameters");
|
|
237
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::verify, static_cast<NativeHeadlessReactNativeSdkCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
238
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt));
|
|
239
|
+
}
|
|
294
240
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
241
|
+
static jsi::Value __logout(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
|
|
242
|
+
static_assert(
|
|
243
|
+
bridging::getParameterCount(&T::logout) == 1,
|
|
244
|
+
"Expected logout(...) to have 1 parameters");
|
|
245
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::logout, static_cast<NativeHeadlessReactNativeSdkCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
|
|
246
|
+
}
|
|
298
247
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
248
|
+
static jsi::Value __getLocksBelongingToTile(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
249
|
+
static_assert(
|
|
250
|
+
bridging::getParameterCount(&T::getLocksBelongingToTile) == 2,
|
|
251
|
+
"Expected getLocksBelongingToTile(...) to have 2 parameters");
|
|
252
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::getLocksBelongingToTile, static_cast<NativeHeadlessReactNativeSdkCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
253
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt));
|
|
254
|
+
}
|
|
303
255
|
|
|
304
|
-
|
|
256
|
+
static jsi::Value __unlockDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
257
|
+
static_assert(
|
|
258
|
+
bridging::getParameterCount(&T::unlockDevice) == 2,
|
|
259
|
+
"Expected unlockDevice(...) to have 2 parameters");
|
|
260
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::unlockDevice, static_cast<NativeHeadlessReactNativeSdkCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
261
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt));
|
|
262
|
+
}
|
|
305
263
|
};
|
|
306
264
|
|
|
307
265
|
} // namespace facebook::react
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
HeadlessReactNativeSdk_kotlinVersion=2.
|
|
2
|
-
HeadlessReactNativeSdk_minSdkVersion=
|
|
3
|
-
HeadlessReactNativeSdk_targetSdkVersion=
|
|
4
|
-
HeadlessReactNativeSdk_compileSdkVersion=
|
|
1
|
+
HeadlessReactNativeSdk_kotlinVersion=2.1.20
|
|
2
|
+
HeadlessReactNativeSdk_minSdkVersion=30
|
|
3
|
+
HeadlessReactNativeSdk_targetSdkVersion=36
|
|
4
|
+
HeadlessReactNativeSdk_compileSdkVersion=36
|
|
5
5
|
HeadlessReactNativeSdk_ndkVersion=27.1.12297006
|
package/android/src/main/java/com/doordeck/headlessreactnativesdk/HeadlessReactNativeSdkModule.kt
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.doordeck.headlessreactnativesdk
|
|
2
2
|
|
|
3
3
|
import com.doordeck.multiplatform.sdk.Doordeck
|
|
4
|
-
import com.doordeck.multiplatform.sdk.exceptions.SdkException
|
|
5
4
|
import com.doordeck.multiplatform.sdk.model.data.LockOperations
|
|
6
5
|
import com.doordeck.multiplatform.sdk.model.responses.AssistedRegisterEphemeralKeyResponse
|
|
7
6
|
import com.doordeck.multiplatform.sdk.model.responses.TileLocksResponse
|
|
@@ -10,10 +9,8 @@ import com.facebook.react.bridge.Arguments
|
|
|
10
9
|
import com.facebook.react.bridge.Promise
|
|
11
10
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
11
|
import com.facebook.react.module.annotations.ReactModule
|
|
13
|
-
import java.
|
|
14
|
-
import java.
|
|
15
|
-
import java.security.spec.PKCS8EncodedKeySpec
|
|
16
|
-
import kotlin.time.Duration.Companion.days
|
|
12
|
+
import java.util.Base64
|
|
13
|
+
import java.util.UUID
|
|
17
14
|
|
|
18
15
|
@ReactModule(name = HeadlessReactNativeSdkModule.NAME)
|
|
19
16
|
class HeadlessReactNativeSdkModule(
|
|
@@ -79,15 +76,22 @@ class HeadlessReactNativeSdkModule(
|
|
|
79
76
|
* User operations
|
|
80
77
|
*/
|
|
81
78
|
override fun getUserDetails(promise: Promise) {
|
|
79
|
+
val contextManager = doordeckSdk.contextManager()
|
|
80
|
+
|
|
82
81
|
doordeckSdk.account().getUserDetailsAsync()
|
|
83
|
-
.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
tokenAboutToExpire
|
|
88
|
-
|
|
82
|
+
.thenCompose { response ->
|
|
83
|
+
// The cloud-auth-token expiry check is now asynchronous; chain it and
|
|
84
|
+
// build the response once it resolves.
|
|
85
|
+
contextManager.isCloudAuthTokenInvalidOrExpiredAsync(false)
|
|
86
|
+
.thenApply { tokenAboutToExpire ->
|
|
87
|
+
promise.resolve(response.toNativeMap(
|
|
88
|
+
userId = contextManager.getUserId()?.toString(),
|
|
89
|
+
certificateChainAboutToExpire = contextManager.isCertificateChainInvalidOrExpired(),
|
|
90
|
+
tokenAboutToExpire = tokenAboutToExpire,
|
|
91
|
+
))
|
|
92
|
+
}
|
|
89
93
|
}
|
|
90
|
-
.exceptionally {
|
|
94
|
+
.exceptionally { error ->
|
|
91
95
|
promise.reject("USER_DETAILS_ERROR", error)
|
|
92
96
|
}
|
|
93
97
|
}
|
|
@@ -97,7 +101,7 @@ class HeadlessReactNativeSdkModule(
|
|
|
97
101
|
*/
|
|
98
102
|
|
|
99
103
|
override fun getLocksBelongingToTile(tileId: String, promise: Promise) {
|
|
100
|
-
doordeckSdk.tiles().getLocksBelongingToTileAsync(tileId)
|
|
104
|
+
doordeckSdk.tiles().getLocksBelongingToTileAsync(UUID.fromString(tileId))
|
|
101
105
|
.thenApply { response ->
|
|
102
106
|
promise.resolve(response.toNativeMap())
|
|
103
107
|
}
|
|
@@ -110,7 +114,7 @@ class HeadlessReactNativeSdkModule(
|
|
|
110
114
|
doordeckSdk.lockOperations().unlockAsync(
|
|
111
115
|
LockOperations.UnlockOperation(
|
|
112
116
|
LockOperations.BaseOperation(
|
|
113
|
-
lockId = lockId,
|
|
117
|
+
lockId = UUID.fromString(lockId),
|
|
114
118
|
)
|
|
115
119
|
)
|
|
116
120
|
)
|
|
@@ -130,10 +134,7 @@ class HeadlessReactNativeSdkModule(
|
|
|
130
134
|
private fun setKeyPairIfNeeded() {
|
|
131
135
|
if (!doordeckSdk.contextManager().isKeyPairValid()) {
|
|
132
136
|
val newKeyPair = doordeckSdk.crypto().generateKeyPair()
|
|
133
|
-
doordeckSdk.contextManager().setKeyPair(
|
|
134
|
-
publicKey = newKeyPair.public,
|
|
135
|
-
privateKey = newKeyPair.private,
|
|
136
|
-
)
|
|
137
|
+
doordeckSdk.contextManager().setKeyPair(newKeyPair)
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -152,10 +153,10 @@ class HeadlessReactNativeSdkModule(
|
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
private fun TileLocksResponse.toNativeMap() = Arguments.createMap().apply {
|
|
155
|
-
putString("siteId", siteId)
|
|
156
|
-
putString("tileId", tileId)
|
|
156
|
+
putString("siteId", siteId.toString())
|
|
157
|
+
putString("tileId", tileId.toString())
|
|
157
158
|
putArray("deviceIds", Arguments.createArray().apply {
|
|
158
|
-
deviceIds.forEach { pushString(it) }
|
|
159
|
+
deviceIds.forEach { pushString(it.toString()) }
|
|
159
160
|
})
|
|
160
161
|
}
|
|
161
162
|
|
|
@@ -167,10 +168,11 @@ class HeadlessReactNativeSdkModule(
|
|
|
167
168
|
putString("userId", userId)
|
|
168
169
|
putBoolean("certificateChainAboutToExpire", certificateChainAboutToExpire)
|
|
169
170
|
putBoolean("tokenAboutToExpire", tokenAboutToExpire)
|
|
170
|
-
|
|
171
|
+
// The SDK now returns a java.security.PublicKey; expose its X.509 (SPKI)
|
|
172
|
+
// form as a base64 string to preserve the `publicKey: string` JS contract.
|
|
173
|
+
putString("publicKey", Base64.getEncoder().encodeToString(publicKey.encoded))
|
|
171
174
|
putString("email", email)
|
|
172
175
|
putString("displayName", displayName)
|
|
173
176
|
putBoolean("emailVerified", emailVerified)
|
|
174
177
|
}
|
|
175
178
|
}
|
|
176
|
-
|
package/android/src/main/java/com/doordeck/headlessreactnativesdk/HeadlessReactNativeSdkPackage.kt
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package com.doordeck.headlessreactnativesdk
|
|
2
2
|
|
|
3
|
-
import com.doordeck.multiplatform.sdk.ApplicationContext
|
|
4
3
|
import com.doordeck.multiplatform.sdk.KDoordeckFactory
|
|
5
4
|
import com.doordeck.multiplatform.sdk.config.SdkConfig
|
|
6
5
|
import com.facebook.react.BaseReactPackage
|
|
@@ -13,13 +12,13 @@ import java.util.HashMap
|
|
|
13
12
|
class HeadlessReactNativeSdkPackage : BaseReactPackage() {
|
|
14
13
|
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
15
14
|
return if (name == HeadlessReactNativeSdkModule.NAME) {
|
|
15
|
+
// The Android application context is supplied automatically by the SDK's
|
|
16
|
+
// bundled DoordeckContextProvider (a ContentProvider auto-registered in the
|
|
17
|
+
// AAR manifest), so the bridge no longer sets it explicitly. initialize() is
|
|
18
|
+
// now a suspend fun; use the blocking CompletableFuture variant here.
|
|
16
19
|
HeadlessReactNativeSdkModule(
|
|
17
20
|
reactContext = reactContext,
|
|
18
|
-
doordeckSdk = KDoordeckFactory.
|
|
19
|
-
SdkConfig.Builder()
|
|
20
|
-
.setApplicationContext(ApplicationContext.apply { set(reactContext.applicationContext)})
|
|
21
|
-
.build()
|
|
22
|
-
)
|
|
21
|
+
doordeckSdk = KDoordeckFactory.initializeAsync(SdkConfig.Builder().build()).get()
|
|
23
22
|
)
|
|
24
23
|
} else {
|
|
25
24
|
null
|