@reclaimprotocol/inapp-rn-sdk 0.1.7 → 0.2.1
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/InappRnSdk.podspec +1 -1
- package/README.md +10 -6
- package/android/build.gradle +3 -3
- package/android/generated/java/com/reclaimprotocol/inapp_rn_sdk/NativeInappRnSdkSpec.java +16 -0
- package/android/generated/jni/RNInappRnSdkSpec-generated.cpp +14 -0
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI-generated.cpp +15 -0
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI.h +192 -20
- package/android/src/main/java/com/reclaimprotocol/inapp_rn_sdk/InappRnSdkModule.kt +99 -20
- package/ios/InappRnSdk.mm +35 -8
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec-generated.mm +24 -0
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec.h +18 -6
- package/ios/generated/RNInappRnSdkSpecJSI-generated.cpp +15 -0
- package/ios/generated/RNInappRnSdkSpecJSI.h +192 -20
- package/ios/inapp_rn_sdk/Api.swift +73 -7
- package/lib/commonjs/ReclaimVerificationPlatformChannel.js +120 -36
- package/lib/commonjs/ReclaimVerificationPlatformChannel.js.map +1 -1
- package/lib/commonjs/index.js +11 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeInappRnSdk.js +1 -0
- package/lib/commonjs/specs/NativeInappRnSdk.js.map +1 -1
- package/lib/module/ReclaimVerificationPlatformChannel.js +117 -34
- package/lib/module/ReclaimVerificationPlatformChannel.js.map +1 -1
- package/lib/module/index.js +7 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeInappRnSdk.js +2 -0
- package/lib/module/specs/NativeInappRnSdk.js.map +1 -1
- package/lib/typescript/commonjs/src/ReclaimVerificationPlatformChannel.d.ts +29 -4
- package/lib/typescript/commonjs/src/ReclaimVerificationPlatformChannel.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +4 -3
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts +22 -4
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts.map +1 -1
- package/lib/typescript/module/src/ReclaimVerificationPlatformChannel.d.ts +29 -4
- package/lib/typescript/module/src/ReclaimVerificationPlatformChannel.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +4 -3
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts +22 -4
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ReclaimVerificationPlatformChannel.ts +149 -41
- package/src/index.ts +8 -4
- package/src/specs/NativeInappRnSdk.ts +32 -6
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package com.reclaimprotocol.inapp_rn_sdk
|
|
2
2
|
|
|
3
|
-
import java.util.UUID
|
|
4
3
|
import android.util.Log
|
|
5
4
|
import com.facebook.react.bridge.Arguments
|
|
6
5
|
import com.facebook.react.bridge.Promise
|
|
@@ -12,6 +11,7 @@ import com.facebook.react.module.annotations.ReactModule
|
|
|
12
11
|
import org.reclaimprotocol.inapp_sdk.ReclaimOverrides
|
|
13
12
|
import org.reclaimprotocol.inapp_sdk.ReclaimSessionStatus
|
|
14
13
|
import org.reclaimprotocol.inapp_sdk.ReclaimVerification
|
|
14
|
+
import java.util.UUID
|
|
15
15
|
|
|
16
16
|
@ReactModule(name = InappRnSdkModule.NAME)
|
|
17
17
|
class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
@@ -39,7 +39,10 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
39
39
|
userInfoMap.putString("errorType", errorType)
|
|
40
40
|
userInfoMap.putString("sessionId", exception.sessionId)
|
|
41
41
|
userInfoMap.putBoolean("didSubmitManualVerification", exception.didSubmitManualVerification)
|
|
42
|
-
userInfoMap.putString(
|
|
42
|
+
userInfoMap.putString(
|
|
43
|
+
"reason",
|
|
44
|
+
if (exception is ReclaimVerification.ReclaimVerificationException.Failed) exception.reason else null
|
|
45
|
+
)
|
|
43
46
|
promise?.reject("VERIFICATION_ERROR", "Verification Error", exception, userInfoMap)
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -68,12 +71,12 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
68
71
|
}
|
|
69
72
|
val handler = ReclaimVerificationResultHandlerImpl(promise)
|
|
70
73
|
reactContext.runOnUiQueueThread {
|
|
71
|
-
val appId =getString(request,"appId")
|
|
72
|
-
val secret = getString(request,"secret")
|
|
74
|
+
val appId = getString(request, "appId")
|
|
75
|
+
val secret = getString(request, "secret")
|
|
73
76
|
val verificationRequest: ReclaimVerification.Request
|
|
74
77
|
val session = request.getMap("session")
|
|
75
78
|
val parametersRN = request.getMap("parameters")?.toHashMap()
|
|
76
|
-
val parameters =
|
|
79
|
+
val parameters = mutableMapOf<String, String>()
|
|
77
80
|
if (parametersRN != null) {
|
|
78
81
|
for (key in parametersRN.keys) {
|
|
79
82
|
val value = parametersRN[key]
|
|
@@ -82,7 +85,6 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
|
-
val hideLanding = getBoolean(request, "hideLanding")
|
|
86
88
|
val autoSubmit = getBoolean(request, "autoSubmit")
|
|
87
89
|
val acceptAiProviders = getBoolean(request, "acceptAiProviders")
|
|
88
90
|
val webhookUrl = getString(request, "webhookUrl")
|
|
@@ -97,7 +99,6 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
97
99
|
signature = getString(session, "signature") ?: "",
|
|
98
100
|
),
|
|
99
101
|
parameters = parameters,
|
|
100
|
-
hideLanding = hideLanding ?: true,
|
|
101
102
|
autoSubmit = autoSubmit ?: false,
|
|
102
103
|
acceptAiProviders = acceptAiProviders ?: false,
|
|
103
104
|
webhookUrl = webhookUrl,
|
|
@@ -114,16 +115,13 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
114
115
|
signature = getString(session, "signature") ?: "",
|
|
115
116
|
),
|
|
116
117
|
parameters = parameters,
|
|
117
|
-
hideLanding = hideLanding ?: true,
|
|
118
118
|
autoSubmit = autoSubmit ?: false,
|
|
119
119
|
acceptAiProviders = acceptAiProviders ?: false,
|
|
120
120
|
webhookUrl = webhookUrl,
|
|
121
121
|
)
|
|
122
122
|
}
|
|
123
123
|
ReclaimVerification.startVerification(
|
|
124
|
-
context = reactContext.applicationContext,
|
|
125
|
-
request = verificationRequest,
|
|
126
|
-
handler = handler
|
|
124
|
+
context = reactContext.applicationContext, request = verificationRequest, handler = handler
|
|
127
125
|
)
|
|
128
126
|
}
|
|
129
127
|
}
|
|
@@ -151,11 +149,24 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
151
149
|
logConsumer = getMap(overrides, "logConsumer"),
|
|
152
150
|
sessionManagement = getMap(overrides, "sessionManagement"),
|
|
153
151
|
appInfo = getMap(overrides, "appInfo"),
|
|
152
|
+
capabilityAccessToken = getString(overrides, "capabilityAccessToken"),
|
|
154
153
|
promise,
|
|
155
154
|
)
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
|
|
157
|
+
override fun clearAllOverrides(promise: Promise?) {
|
|
158
|
+
reactContext.runOnUiQueueThread {
|
|
159
|
+
ReclaimVerification.clearAllOverrides(
|
|
160
|
+
context = reactContext.applicationContext,
|
|
161
|
+
) { result ->
|
|
162
|
+
result.onSuccess {
|
|
163
|
+
promise?.resolve(null)
|
|
164
|
+
}.onFailure { error ->
|
|
165
|
+
onPlatformException(promise, error)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
159
170
|
|
|
160
171
|
private fun setOverrides(
|
|
161
172
|
provider: ReadableMap?,
|
|
@@ -163,24 +174,49 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
163
174
|
logConsumer: ReadableMap?,
|
|
164
175
|
sessionManagement: ReadableMap?,
|
|
165
176
|
appInfo: ReadableMap?,
|
|
177
|
+
capabilityAccessToken: String?,
|
|
166
178
|
promise: Promise?
|
|
167
179
|
) {
|
|
168
180
|
reactContext.runOnUiQueueThread {
|
|
169
181
|
ReclaimVerification.setOverrides(
|
|
170
182
|
context = reactContext.applicationContext,
|
|
171
183
|
provider = if (provider == null) null else (
|
|
172
|
-
if (
|
|
184
|
+
if (hasValue(provider, "jsonString"))
|
|
173
185
|
ReclaimOverrides.ProviderInformation.FromJsonString(
|
|
174
186
|
requireString(
|
|
175
187
|
provider, "jsonString"
|
|
176
188
|
)
|
|
177
189
|
)
|
|
178
|
-
else
|
|
190
|
+
else if (hasValue(provider, "url"))
|
|
179
191
|
ReclaimOverrides.ProviderInformation.FromUrl(
|
|
180
192
|
requireString(
|
|
181
193
|
provider, "url"
|
|
182
194
|
)
|
|
183
195
|
)
|
|
196
|
+
else if (getBoolean(provider, "canFetchProviderInformationFromHost") == true)
|
|
197
|
+
ReclaimOverrides.ProviderInformation.FromCallback(object : ReclaimOverrides.ProviderInformation.FromCallbackHandler {
|
|
198
|
+
override fun fetchProviderInformation(
|
|
199
|
+
appId: String,
|
|
200
|
+
providerId: String,
|
|
201
|
+
sessionId: String,
|
|
202
|
+
signature: String,
|
|
203
|
+
timestamp: String,
|
|
204
|
+
callback: (Result<String>) -> Unit
|
|
205
|
+
) {
|
|
206
|
+
val args = Arguments.createMap()
|
|
207
|
+
args.putString("appId", appId)
|
|
208
|
+
args.putString("providerId", providerId)
|
|
209
|
+
args.putString("sessionId", sessionId)
|
|
210
|
+
args.putString("signature", signature)
|
|
211
|
+
args.putString("timestamp", timestamp)
|
|
212
|
+
val replyId = UUID.randomUUID().toString()
|
|
213
|
+
args.putString("replyId", replyId)
|
|
214
|
+
replyWithProviderInformationHandlers[replyId] = callback
|
|
215
|
+
emitOnProviderInformationRequest(args)
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
else
|
|
219
|
+
(throw IllegalStateException("Invalid provider information. canFetchProviderInformationFromHost was not true and jsonString, url were also not provided."))
|
|
184
220
|
),
|
|
185
221
|
featureOptions = if (featureOptions == null) null else ReclaimOverrides.FeatureOptions(
|
|
186
222
|
cookiePersist = getBoolean(featureOptions, "cookiePersist"),
|
|
@@ -257,19 +293,32 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
257
293
|
appImageUrl = requireString(appInfo, "appImageUrl"),
|
|
258
294
|
isRecurring = getBoolean(appInfo, "isRecurring") ?: false,
|
|
259
295
|
),
|
|
296
|
+
capabilityAccessToken = capabilityAccessToken
|
|
260
297
|
) { result ->
|
|
261
298
|
result.onSuccess {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
promise?.
|
|
299
|
+
try {
|
|
300
|
+
Log.d(NAME, "(setOverrides) Success")
|
|
301
|
+
promise?.resolve(null)
|
|
302
|
+
} catch (e: Throwable) {
|
|
303
|
+
Log.e(NAME, "(setOverrides) Error resolving promise")
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
}.onFailure { error ->
|
|
307
|
+
try {
|
|
308
|
+
Log.d(NAME, "(setOverrides) Failure")
|
|
309
|
+
onPlatformException(promise, error)
|
|
310
|
+
} catch (e: Throwable) {
|
|
311
|
+
Log.e(NAME, "(setOverrides) Error rejecting promise", e)
|
|
265
312
|
}
|
|
313
|
+
}
|
|
266
314
|
}
|
|
267
315
|
}
|
|
268
316
|
}
|
|
269
317
|
|
|
318
|
+
private val replyHandlers: MutableMap<String, (Result<Boolean>) -> Unit> = mutableMapOf()
|
|
270
319
|
override fun reply(replyId: String?, reply: Boolean) {
|
|
271
320
|
if (replyId == null) {
|
|
272
|
-
Log.w(NAME, "Missing arg replyId")
|
|
321
|
+
Log.w(NAME, "(reply) Missing arg replyId")
|
|
273
322
|
return
|
|
274
323
|
}
|
|
275
324
|
reactContext.runOnUiQueueThread {
|
|
@@ -277,11 +326,40 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
277
326
|
if (callback != null) {
|
|
278
327
|
callback(Result.success(reply))
|
|
279
328
|
} else {
|
|
280
|
-
Log.w(NAME, "Missing reply handler for id: $replyId")
|
|
329
|
+
Log.w(NAME, "(reply) Missing reply handler for id: $replyId")
|
|
281
330
|
}
|
|
282
331
|
}
|
|
283
332
|
}
|
|
284
333
|
|
|
334
|
+
private val replyWithProviderInformationHandlers: MutableMap<String, (Result<String>) -> Unit> =
|
|
335
|
+
mutableMapOf()
|
|
336
|
+
|
|
337
|
+
override fun replyWithProviderInformation(replyId: String?, providerInformation: String?) {
|
|
338
|
+
if (replyId == null) {
|
|
339
|
+
Log.w(NAME, "(replyWithProviderInformation) Missing arg replyId")
|
|
340
|
+
return
|
|
341
|
+
}
|
|
342
|
+
reactContext.runOnUiQueueThread {
|
|
343
|
+
val callback = replyWithProviderInformationHandlers[replyId]
|
|
344
|
+
if (callback != null) {
|
|
345
|
+
callback(Result.success(providerInformation ?: ""))
|
|
346
|
+
} else {
|
|
347
|
+
Log.w(NAME, "(replyWithProviderInformation) Missing reply handler for id: $replyId")
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
private fun onPlatformException(promise: Promise?, exception: Throwable) {
|
|
353
|
+
if (exception is ReclaimVerification.ReclaimPlatformException) {
|
|
354
|
+
val userInfoMap = Arguments.createMap()
|
|
355
|
+
userInfoMap.putString("message", exception.internalErrorMessage)
|
|
356
|
+
userInfoMap.putString("errorCode", exception.errorCode)
|
|
357
|
+
promise?.reject("PLATFORM_ERROR", exception.message, exception, userInfoMap)
|
|
358
|
+
} else {
|
|
359
|
+
promise?.reject("PLATFORM_ERROR", "Unexpected Error", exception)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
285
363
|
@Suppress("SameParameterValue")
|
|
286
364
|
private fun hasValue(map: ReadableMap, key: String): Boolean {
|
|
287
365
|
return map.hasKey(key) && !map.isNull(key)
|
|
@@ -315,7 +393,8 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
315
393
|
throw TypeCastException("Value for key $key is not a Number")
|
|
316
394
|
}
|
|
317
395
|
|
|
318
|
-
private fun getString(map: ReadableMap
|
|
396
|
+
private fun getString(map: ReadableMap?, key: String): String? {
|
|
397
|
+
if (map == null) return null
|
|
319
398
|
return if (!map.hasKey(key) || map.isNull(key)) {
|
|
320
399
|
null
|
|
321
400
|
} else {
|
package/ios/InappRnSdk.mm
CHANGED
|
@@ -35,13 +35,13 @@ Api *api = [[Api alloc] init];
|
|
|
35
35
|
[api replyWithReplyId:replyId reply:reply];
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
- (void)replyWithProviderInformation:(nonnull NSString *)replyId providerInformation:(nonnull NSString *)providerInformation {
|
|
39
|
+
[api replyWithProviderInformationWithReplyId:replyId providerInformation:providerInformation];
|
|
40
|
+
}
|
|
41
|
+
|
|
38
42
|
- (void)startVerification:(JS::NativeInappRnSdk::Request &)request resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
39
43
|
NSLog(@"[InappRnSdk] starting verification");
|
|
40
44
|
|
|
41
|
-
bool hideLanding = true;
|
|
42
|
-
if (request.hideLanding().has_value()) {
|
|
43
|
-
hideLanding = request.hideLanding().value();
|
|
44
|
-
}
|
|
45
45
|
bool autoSubmit = false;
|
|
46
46
|
if (request.autoSubmit().has_value()) {
|
|
47
47
|
autoSubmit = request.autoSubmit().value();
|
|
@@ -85,7 +85,7 @@ Api *api = [[Api alloc] init];
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
NSLog(@"[InappRnSdk] starting verification now");
|
|
88
|
-
[api startVerificationWithAppId:request.appId() secret:request.secret() providerId:request.providerId() sessionTimestamp:timestamp sessionSessionId:sessionId sessionSignature:signature context:request.contextString() parameters:parameters
|
|
88
|
+
[api startVerificationWithAppId:request.appId() secret:request.secret() providerId:request.providerId() sessionTimestamp:timestamp sessionSessionId:sessionId sessionSignature:signature context:request.contextString() parameters:parameters autoSubmit:autoSubmit acceptAiProviders:acceptAiProviders webhookUrl:request.webhookUrl() completionHandler:^(NSDictionary<NSString *,id> * _Nullable result, NSError * _Nullable error) {
|
|
89
89
|
if (error != nil) {
|
|
90
90
|
NSLog(@"[InappRnSdk] Api Error: %@", error);
|
|
91
91
|
reject(@"VERIFICATION_ERROR", @"Verification Error", error);
|
|
@@ -115,9 +115,21 @@ Api *api = [[Api alloc] init];
|
|
|
115
115
|
if (overrides.provider().has_value()) {
|
|
116
116
|
JS::NativeInappRnSdk::ProviderInformation provider = overrides.provider().value();
|
|
117
117
|
if (provider.url() != nil && provider.url().length > 0) {
|
|
118
|
-
overridenProvider = [[OverridenProviderInformation alloc] initWithUrl:provider.url() jsonString:nil];
|
|
118
|
+
overridenProvider = [[OverridenProviderInformation alloc] initWithUrl:provider.url() jsonString:nil callback:nil];
|
|
119
119
|
} else if (provider.jsonString() != nil && provider.jsonString().length > 0) {
|
|
120
|
-
overridenProvider = [[OverridenProviderInformation alloc] initWithUrl:nil jsonString:provider.jsonString()];
|
|
120
|
+
overridenProvider = [[OverridenProviderInformation alloc] initWithUrl:nil jsonString:provider.jsonString() callback:nil];
|
|
121
|
+
} else if (provider.canFetchProviderInformationFromHost()) {
|
|
122
|
+
OverridenProviderCallbackHandler * callback = [[OverridenProviderCallbackHandler alloc] initWith_fetchProviderInformation:^(NSString * _Nonnull appId, NSString * _Nonnull providerId, NSString * _Nonnull sessionId, NSString * _Nonnull signature, NSString * _Nonnull timestamp, NSString * _Nonnull replyId) {
|
|
123
|
+
[self emitOnProviderInformationRequest:@{
|
|
124
|
+
@"appId": appId,
|
|
125
|
+
@"providerId": providerId,
|
|
126
|
+
@"sessionId": sessionId,
|
|
127
|
+
@"signature": signature,
|
|
128
|
+
@"timestamp": timestamp,
|
|
129
|
+
@"replyId": replyId
|
|
130
|
+
}];
|
|
131
|
+
}];
|
|
132
|
+
overridenProvider = [[OverridenProviderInformation alloc] initWithUrl:nil jsonString:nil callback:callback];
|
|
121
133
|
}
|
|
122
134
|
}
|
|
123
135
|
|
|
@@ -203,7 +215,12 @@ Api *api = [[Api alloc] init];
|
|
|
203
215
|
overridenAppInfo = [[OverridenReclaimAppInfo alloc] initWithAppName:appInfo.appName() appImageUrl:appInfo.appImageUrl() isRecurring:isRecurring];
|
|
204
216
|
}
|
|
205
217
|
|
|
206
|
-
|
|
218
|
+
NSString * _Nullable capabilityAccessToken = nil;
|
|
219
|
+
if (overrides.capabilityAccessToken() != nil) {
|
|
220
|
+
capabilityAccessToken = overrides.capabilityAccessToken();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
[api setOverridesWithProvider:overridenProvider featureOptions:overridenFeatureOptions logConsumer:overridenLogConsumer sessionManagement: sessionManagement appInfo:overridenAppInfo capabilityAccessToken: capabilityAccessToken completionHandler:^(NSError * _Nullable error) {
|
|
207
224
|
if (error != nil) {
|
|
208
225
|
reject(@"OVERRIDE_ERROR", @"Error on override", error);
|
|
209
226
|
} else {
|
|
@@ -212,4 +229,14 @@ Api *api = [[Api alloc] init];
|
|
|
212
229
|
}];
|
|
213
230
|
}
|
|
214
231
|
|
|
232
|
+
- (void)clearAllOverrides:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
233
|
+
[api clearAllOverridesWithCompletionHandler:^(NSError * _Nullable error) {
|
|
234
|
+
if (error != nil) {
|
|
235
|
+
reject(@"OVERRIDE_ERROR", @"Error on clearing overrides", error);
|
|
236
|
+
} else {
|
|
237
|
+
resolve(nil);
|
|
238
|
+
}
|
|
239
|
+
}];
|
|
240
|
+
}
|
|
241
|
+
|
|
215
242
|
@end
|
|
@@ -31,6 +31,14 @@
|
|
|
31
31
|
{
|
|
32
32
|
_eventEmitterCallback("onSessionUpdateRequest", value);
|
|
33
33
|
}
|
|
34
|
+
- (void)emitOnSessionIdentityUpdate:(NSDictionary *)value
|
|
35
|
+
{
|
|
36
|
+
_eventEmitterCallback("onSessionIdentityUpdate", value);
|
|
37
|
+
}
|
|
38
|
+
- (void)emitOnProviderInformationRequest:(NSDictionary *)value
|
|
39
|
+
{
|
|
40
|
+
_eventEmitterCallback("onProviderInformationRequest", value);
|
|
41
|
+
}
|
|
34
42
|
|
|
35
43
|
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
|
36
44
|
{
|
|
@@ -100,10 +108,18 @@ namespace facebook::react {
|
|
|
100
108
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "setOverrides", @selector(setOverrides:resolve:reject:), args, count);
|
|
101
109
|
}
|
|
102
110
|
|
|
111
|
+
static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_clearAllOverrides(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
112
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "clearAllOverrides", @selector(clearAllOverrides:reject:), args, count);
|
|
113
|
+
}
|
|
114
|
+
|
|
103
115
|
static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_reply(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
104
116
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "reply", @selector(reply:reply:), args, count);
|
|
105
117
|
}
|
|
106
118
|
|
|
119
|
+
static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_replyWithProviderInformation(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
120
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "replyWithProviderInformation", @selector(replyWithProviderInformation:providerInformation:), args, count);
|
|
121
|
+
}
|
|
122
|
+
|
|
107
123
|
static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_ping(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
108
124
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "ping", @selector(ping:reject:), args, count);
|
|
109
125
|
}
|
|
@@ -120,15 +136,23 @@ namespace facebook::react {
|
|
|
120
136
|
methodMap_["setOverrides"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkSpecJSI_setOverrides};
|
|
121
137
|
setMethodArgConversionSelector(@"setOverrides", 0, @"JS_NativeInappRnSdk_Overrides:");
|
|
122
138
|
|
|
139
|
+
methodMap_["clearAllOverrides"] = MethodMetadata {0, __hostFunction_NativeInappRnSdkSpecJSI_clearAllOverrides};
|
|
140
|
+
|
|
141
|
+
|
|
123
142
|
methodMap_["reply"] = MethodMetadata {2, __hostFunction_NativeInappRnSdkSpecJSI_reply};
|
|
124
143
|
|
|
125
144
|
|
|
145
|
+
methodMap_["replyWithProviderInformation"] = MethodMetadata {2, __hostFunction_NativeInappRnSdkSpecJSI_replyWithProviderInformation};
|
|
146
|
+
|
|
147
|
+
|
|
126
148
|
methodMap_["ping"] = MethodMetadata {0, __hostFunction_NativeInappRnSdkSpecJSI_ping};
|
|
127
149
|
|
|
128
150
|
eventEmitterMap_["onLogs"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
129
151
|
eventEmitterMap_["onSessionLogs"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
130
152
|
eventEmitterMap_["onSessionCreateRequest"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
131
153
|
eventEmitterMap_["onSessionUpdateRequest"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
154
|
+
eventEmitterMap_["onSessionIdentityUpdate"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
155
|
+
eventEmitterMap_["onProviderInformationRequest"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
132
156
|
setEventEmitterCallback([&](const std::string &name, id value) {
|
|
133
157
|
static_cast<AsyncEventEmitter<id> &>(*eventEmitterMap_[name]).emit(value);
|
|
134
158
|
});
|
|
@@ -58,7 +58,6 @@ namespace JS {
|
|
|
58
58
|
std::optional<JS::NativeInappRnSdk::SessionInformation> session() const;
|
|
59
59
|
NSString *contextString() const;
|
|
60
60
|
id<NSObject> _Nullable parameters() const;
|
|
61
|
-
std::optional<bool> hideLanding() const;
|
|
62
61
|
std::optional<bool> autoSubmit() const;
|
|
63
62
|
std::optional<bool> acceptAiProviders() const;
|
|
64
63
|
NSString *webhookUrl() const;
|
|
@@ -78,6 +77,7 @@ namespace JS {
|
|
|
78
77
|
struct ProviderInformation {
|
|
79
78
|
NSString *url() const;
|
|
80
79
|
NSString *jsonString() const;
|
|
80
|
+
bool canFetchProviderInformationFromHost() const;
|
|
81
81
|
|
|
82
82
|
ProviderInformation(NSDictionary *const v) : _v(v) {}
|
|
83
83
|
private:
|
|
@@ -167,6 +167,7 @@ namespace JS {
|
|
|
167
167
|
std::optional<JS::NativeInappRnSdk::LogConsumer> logConsumer() const;
|
|
168
168
|
std::optional<JS::NativeInappRnSdk::SessionManagement> sessionManagement() const;
|
|
169
169
|
std::optional<JS::NativeInappRnSdk::ReclaimAppInfo> appInfo() const;
|
|
170
|
+
NSString *capabilityAccessToken() const;
|
|
170
171
|
|
|
171
172
|
Overrides(NSDictionary *const v) : _v(v) {}
|
|
172
173
|
private:
|
|
@@ -189,8 +190,12 @@ namespace JS {
|
|
|
189
190
|
- (void)setOverrides:(JS::NativeInappRnSdk::Overrides &)overrides
|
|
190
191
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
191
192
|
reject:(RCTPromiseRejectBlock)reject;
|
|
193
|
+
- (void)clearAllOverrides:(RCTPromiseResolveBlock)resolve
|
|
194
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
192
195
|
- (void)reply:(NSString *)replyId
|
|
193
196
|
reply:(BOOL)reply;
|
|
197
|
+
- (void)replyWithProviderInformation:(NSString *)replyId
|
|
198
|
+
providerInformation:(NSString *)providerInformation;
|
|
194
199
|
- (void)ping:(RCTPromiseResolveBlock)resolve
|
|
195
200
|
reject:(RCTPromiseRejectBlock)reject;
|
|
196
201
|
|
|
@@ -206,6 +211,8 @@ facebook::react::EventEmitterCallback _eventEmitterCallback;
|
|
|
206
211
|
- (void)emitOnSessionLogs:(NSDictionary *)value;
|
|
207
212
|
- (void)emitOnSessionCreateRequest:(NSDictionary *)value;
|
|
208
213
|
- (void)emitOnSessionUpdateRequest:(NSDictionary *)value;
|
|
214
|
+
- (void)emitOnSessionIdentityUpdate:(NSDictionary *)value;
|
|
215
|
+
- (void)emitOnProviderInformationRequest:(NSDictionary *)value;
|
|
209
216
|
@end
|
|
210
217
|
|
|
211
218
|
namespace facebook::react {
|
|
@@ -262,11 +269,6 @@ inline id<NSObject> _Nullable JS::NativeInappRnSdk::Request::parameters() const
|
|
|
262
269
|
id const p = _v[@"parameters"];
|
|
263
270
|
return p;
|
|
264
271
|
}
|
|
265
|
-
inline std::optional<bool> JS::NativeInappRnSdk::Request::hideLanding() const
|
|
266
|
-
{
|
|
267
|
-
id const p = _v[@"hideLanding"];
|
|
268
|
-
return RCTBridgingToOptionalBool(p);
|
|
269
|
-
}
|
|
270
272
|
inline std::optional<bool> JS::NativeInappRnSdk::Request::autoSubmit() const
|
|
271
273
|
{
|
|
272
274
|
id const p = _v[@"autoSubmit"];
|
|
@@ -292,6 +294,11 @@ inline NSString *JS::NativeInappRnSdk::ProviderInformation::jsonString() const
|
|
|
292
294
|
id const p = _v[@"jsonString"];
|
|
293
295
|
return RCTBridgingToOptionalString(p);
|
|
294
296
|
}
|
|
297
|
+
inline bool JS::NativeInappRnSdk::ProviderInformation::canFetchProviderInformationFromHost() const
|
|
298
|
+
{
|
|
299
|
+
id const p = _v[@"canFetchProviderInformationFromHost"];
|
|
300
|
+
return RCTBridgingToBool(p);
|
|
301
|
+
}
|
|
295
302
|
inline std::optional<bool> JS::NativeInappRnSdk::FeatureOptions::cookiePersist() const
|
|
296
303
|
{
|
|
297
304
|
id const p = _v[@"cookiePersist"];
|
|
@@ -387,5 +394,10 @@ inline std::optional<JS::NativeInappRnSdk::ReclaimAppInfo> JS::NativeInappRnSdk:
|
|
|
387
394
|
id const p = _v[@"appInfo"];
|
|
388
395
|
return (p == nil ? std::nullopt : std::make_optional(JS::NativeInappRnSdk::ReclaimAppInfo(p)));
|
|
389
396
|
}
|
|
397
|
+
inline NSString *JS::NativeInappRnSdk::Overrides::capabilityAccessToken() const
|
|
398
|
+
{
|
|
399
|
+
id const p = _v[@"capabilityAccessToken"];
|
|
400
|
+
return RCTBridgingToOptionalString(p);
|
|
401
|
+
}
|
|
390
402
|
NS_ASSUME_NONNULL_END
|
|
391
403
|
#endif // RNInappRnSdkSpec_H
|
|
@@ -29,6 +29,11 @@ static jsi::Value __hostFunction_NativeInappRnSdkCxxSpecJSI_setOverrides(jsi::Ru
|
|
|
29
29
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asObject(rt)
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
|
+
static jsi::Value __hostFunction_NativeInappRnSdkCxxSpecJSI_clearAllOverrides(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
33
|
+
return static_cast<NativeInappRnSdkCxxSpecJSI *>(&turboModule)->clearAllOverrides(
|
|
34
|
+
rt
|
|
35
|
+
);
|
|
36
|
+
}
|
|
32
37
|
static jsi::Value __hostFunction_NativeInappRnSdkCxxSpecJSI_reply(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
33
38
|
static_cast<NativeInappRnSdkCxxSpecJSI *>(&turboModule)->reply(
|
|
34
39
|
rt,
|
|
@@ -37,6 +42,14 @@ static jsi::Value __hostFunction_NativeInappRnSdkCxxSpecJSI_reply(jsi::Runtime &
|
|
|
37
42
|
);
|
|
38
43
|
return jsi::Value::undefined();
|
|
39
44
|
}
|
|
45
|
+
static jsi::Value __hostFunction_NativeInappRnSdkCxxSpecJSI_replyWithProviderInformation(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
46
|
+
static_cast<NativeInappRnSdkCxxSpecJSI *>(&turboModule)->replyWithProviderInformation(
|
|
47
|
+
rt,
|
|
48
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
49
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt)
|
|
50
|
+
);
|
|
51
|
+
return jsi::Value::undefined();
|
|
52
|
+
}
|
|
40
53
|
static jsi::Value __hostFunction_NativeInappRnSdkCxxSpecJSI_ping(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
41
54
|
return static_cast<NativeInappRnSdkCxxSpecJSI *>(&turboModule)->ping(
|
|
42
55
|
rt
|
|
@@ -48,7 +61,9 @@ NativeInappRnSdkCxxSpecJSI::NativeInappRnSdkCxxSpecJSI(std::shared_ptr<CallInvok
|
|
|
48
61
|
methodMap_["startVerification"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkCxxSpecJSI_startVerification};
|
|
49
62
|
methodMap_["startVerificationFromUrl"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkCxxSpecJSI_startVerificationFromUrl};
|
|
50
63
|
methodMap_["setOverrides"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkCxxSpecJSI_setOverrides};
|
|
64
|
+
methodMap_["clearAllOverrides"] = MethodMetadata {0, __hostFunction_NativeInappRnSdkCxxSpecJSI_clearAllOverrides};
|
|
51
65
|
methodMap_["reply"] = MethodMetadata {2, __hostFunction_NativeInappRnSdkCxxSpecJSI_reply};
|
|
66
|
+
methodMap_["replyWithProviderInformation"] = MethodMetadata {2, __hostFunction_NativeInappRnSdkCxxSpecJSI_replyWithProviderInformation};
|
|
52
67
|
methodMap_["ping"] = MethodMetadata {0, __hostFunction_NativeInappRnSdkCxxSpecJSI_ping};
|
|
53
68
|
}
|
|
54
69
|
|