@reclaimprotocol/inapp-rn-sdk 0.1.7 → 0.3.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/InappRnSdk.podspec +1 -1
- package/README.md +12 -7
- package/android/build.gradle +3 -3
- package/android/generated/java/com/reclaimprotocol/inapp_rn_sdk/NativeInappRnSdkSpec.java +24 -0
- package/android/generated/jni/RNInappRnSdkSpec-generated.cpp +21 -0
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI-generated.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI.h +348 -20
- package/android/src/main/java/com/reclaimprotocol/inapp_rn_sdk/InappRnSdkModule.kt +140 -20
- package/ios/InappRnSdk.mm +65 -11
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec-generated.mm +48 -0
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec.h +68 -6
- package/ios/generated/RNInappRnSdkSpecJSI-generated.cpp +22 -0
- package/ios/generated/RNInappRnSdkSpecJSI.h +348 -20
- package/ios/inapp_rn_sdk/Api.swift +124 -7
- package/lib/commonjs/ReclaimVerificationPlatformChannel.js +156 -36
- package/lib/commonjs/ReclaimVerificationPlatformChannel.js.map +1 -1
- package/lib/commonjs/index.js +14 -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 +153 -34
- package/lib/module/ReclaimVerificationPlatformChannel.js.map +1 -1
- package/lib/module/index.js +10 -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 +37 -4
- package/lib/typescript/commonjs/src/ReclaimVerificationPlatformChannel.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +5 -3
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts +38 -4
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/proof.d.ts.map +1 -1
- package/lib/typescript/module/src/ReclaimVerificationPlatformChannel.d.ts +37 -4
- package/lib/typescript/module/src/ReclaimVerificationPlatformChannel.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +5 -3
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts +38 -4
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts.map +1 -1
- package/lib/typescript/module/src/types/proof.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ReclaimVerificationPlatformChannel.ts +194 -41
- package/src/index.ts +12 -4
- package/src/specs/NativeInappRnSdk.ts +51 -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
|
|
@@ -9,9 +8,11 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
9
8
|
import com.facebook.react.bridge.WritableArray
|
|
10
9
|
import com.facebook.react.bridge.WritableMap
|
|
11
10
|
import com.facebook.react.module.annotations.ReactModule
|
|
11
|
+
import org.json.JSONObject
|
|
12
12
|
import org.reclaimprotocol.inapp_sdk.ReclaimOverrides
|
|
13
13
|
import org.reclaimprotocol.inapp_sdk.ReclaimSessionStatus
|
|
14
14
|
import org.reclaimprotocol.inapp_sdk.ReclaimVerification
|
|
15
|
+
import java.util.UUID
|
|
15
16
|
|
|
16
17
|
@ReactModule(name = InappRnSdkModule.NAME)
|
|
17
18
|
class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
@@ -39,7 +40,10 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
39
40
|
userInfoMap.putString("errorType", errorType)
|
|
40
41
|
userInfoMap.putString("sessionId", exception.sessionId)
|
|
41
42
|
userInfoMap.putBoolean("didSubmitManualVerification", exception.didSubmitManualVerification)
|
|
42
|
-
userInfoMap.putString(
|
|
43
|
+
userInfoMap.putString(
|
|
44
|
+
"reason",
|
|
45
|
+
if (exception is ReclaimVerification.ReclaimVerificationException.Failed) exception.reason else null
|
|
46
|
+
)
|
|
43
47
|
promise?.reject("VERIFICATION_ERROR", "Verification Error", exception, userInfoMap)
|
|
44
48
|
}
|
|
45
49
|
|
|
@@ -68,12 +72,12 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
68
72
|
}
|
|
69
73
|
val handler = ReclaimVerificationResultHandlerImpl(promise)
|
|
70
74
|
reactContext.runOnUiQueueThread {
|
|
71
|
-
val appId =getString(request,"appId")
|
|
72
|
-
val secret = getString(request,"secret")
|
|
75
|
+
val appId = getString(request, "appId")
|
|
76
|
+
val secret = getString(request, "secret")
|
|
73
77
|
val verificationRequest: ReclaimVerification.Request
|
|
74
78
|
val session = request.getMap("session")
|
|
75
79
|
val parametersRN = request.getMap("parameters")?.toHashMap()
|
|
76
|
-
val parameters =
|
|
80
|
+
val parameters = mutableMapOf<String, String>()
|
|
77
81
|
if (parametersRN != null) {
|
|
78
82
|
for (key in parametersRN.keys) {
|
|
79
83
|
val value = parametersRN[key]
|
|
@@ -82,7 +86,6 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
|
-
val hideLanding = getBoolean(request, "hideLanding")
|
|
86
89
|
val autoSubmit = getBoolean(request, "autoSubmit")
|
|
87
90
|
val acceptAiProviders = getBoolean(request, "acceptAiProviders")
|
|
88
91
|
val webhookUrl = getString(request, "webhookUrl")
|
|
@@ -97,7 +100,6 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
97
100
|
signature = getString(session, "signature") ?: "",
|
|
98
101
|
),
|
|
99
102
|
parameters = parameters,
|
|
100
|
-
hideLanding = hideLanding ?: true,
|
|
101
103
|
autoSubmit = autoSubmit ?: false,
|
|
102
104
|
acceptAiProviders = acceptAiProviders ?: false,
|
|
103
105
|
webhookUrl = webhookUrl,
|
|
@@ -114,16 +116,13 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
114
116
|
signature = getString(session, "signature") ?: "",
|
|
115
117
|
),
|
|
116
118
|
parameters = parameters,
|
|
117
|
-
hideLanding = hideLanding ?: true,
|
|
118
119
|
autoSubmit = autoSubmit ?: false,
|
|
119
120
|
acceptAiProviders = acceptAiProviders ?: false,
|
|
120
121
|
webhookUrl = webhookUrl,
|
|
121
122
|
)
|
|
122
123
|
}
|
|
123
124
|
ReclaimVerification.startVerification(
|
|
124
|
-
context = reactContext.applicationContext,
|
|
125
|
-
request = verificationRequest,
|
|
126
|
-
handler = handler
|
|
125
|
+
context = reactContext.applicationContext, request = verificationRequest, handler = handler
|
|
127
126
|
)
|
|
128
127
|
}
|
|
129
128
|
}
|
|
@@ -151,11 +150,64 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
151
150
|
logConsumer = getMap(overrides, "logConsumer"),
|
|
152
151
|
sessionManagement = getMap(overrides, "sessionManagement"),
|
|
153
152
|
appInfo = getMap(overrides, "appInfo"),
|
|
153
|
+
capabilityAccessToken = getString(overrides, "capabilityAccessToken"),
|
|
154
154
|
promise,
|
|
155
155
|
)
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
override fun clearAllOverrides(promise: Promise?) {
|
|
159
|
+
reactContext.runOnUiQueueThread {
|
|
160
|
+
ReclaimVerification.clearAllOverrides(
|
|
161
|
+
context = reactContext.applicationContext,
|
|
162
|
+
) { result ->
|
|
163
|
+
result.onSuccess {
|
|
164
|
+
promise?.resolve(null)
|
|
165
|
+
}.onFailure { error ->
|
|
166
|
+
onPlatformException(promise, error)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
override fun setVerificationOptions(args: ReadableMap?, promise: Promise?) {
|
|
173
|
+
val inputOptions = getMap(args, "options")
|
|
174
|
+
var options: ReclaimVerification.VerificationOptions? = null
|
|
175
|
+
if (inputOptions != null) {
|
|
176
|
+
val canUseAttestorAuthRequestProvider = getBoolean(inputOptions, "canUseAttestorAuthenticationRequest") == true;
|
|
177
|
+
options = ReclaimVerification.VerificationOptions(
|
|
178
|
+
canDeleteCookiesBeforeVerificationStarts = getBoolean(inputOptions, "canDeleteCookiesBeforeVerificationStarts") ?: true,
|
|
179
|
+
attestorAuthRequestProvider = if (canUseAttestorAuthRequestProvider) {
|
|
180
|
+
object : ReclaimVerification.VerificationOptions.AttestorAuthRequestProvider {
|
|
181
|
+
override fun fetchAttestorAuthenticationRequest(
|
|
182
|
+
reclaimHttpProvider: Map<Any?, Any?>,
|
|
183
|
+
callback: (Result<String>) -> Unit
|
|
184
|
+
) {
|
|
185
|
+
val args = Arguments.createMap()
|
|
186
|
+
args.putString("reclaimHttpProviderJsonString", JSONObject(reclaimHttpProvider).toString())
|
|
187
|
+
val replyId = UUID.randomUUID().toString()
|
|
188
|
+
args.putString("replyId", replyId)
|
|
189
|
+
replyWithString[replyId] = callback
|
|
190
|
+
emitOnReclaimAttestorAuthRequest(args)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
null
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
reactContext.runOnUiQueueThread {
|
|
199
|
+
ReclaimVerification.setVerificationOptions(
|
|
200
|
+
context = reactContext.applicationContext,
|
|
201
|
+
options = options
|
|
202
|
+
) { result ->
|
|
203
|
+
result.onSuccess {
|
|
204
|
+
promise?.resolve(null)
|
|
205
|
+
}.onFailure { error ->
|
|
206
|
+
onPlatformException(promise, error)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
159
211
|
|
|
160
212
|
private fun setOverrides(
|
|
161
213
|
provider: ReadableMap?,
|
|
@@ -163,24 +215,49 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
163
215
|
logConsumer: ReadableMap?,
|
|
164
216
|
sessionManagement: ReadableMap?,
|
|
165
217
|
appInfo: ReadableMap?,
|
|
218
|
+
capabilityAccessToken: String?,
|
|
166
219
|
promise: Promise?
|
|
167
220
|
) {
|
|
168
221
|
reactContext.runOnUiQueueThread {
|
|
169
222
|
ReclaimVerification.setOverrides(
|
|
170
223
|
context = reactContext.applicationContext,
|
|
171
224
|
provider = if (provider == null) null else (
|
|
172
|
-
if (
|
|
225
|
+
if (hasValue(provider, "jsonString"))
|
|
173
226
|
ReclaimOverrides.ProviderInformation.FromJsonString(
|
|
174
227
|
requireString(
|
|
175
228
|
provider, "jsonString"
|
|
176
229
|
)
|
|
177
230
|
)
|
|
178
|
-
else
|
|
231
|
+
else if (hasValue(provider, "url"))
|
|
179
232
|
ReclaimOverrides.ProviderInformation.FromUrl(
|
|
180
233
|
requireString(
|
|
181
234
|
provider, "url"
|
|
182
235
|
)
|
|
183
236
|
)
|
|
237
|
+
else if (getBoolean(provider, "canFetchProviderInformationFromHost") == true)
|
|
238
|
+
ReclaimOverrides.ProviderInformation.FromCallback(object : ReclaimOverrides.ProviderInformation.FromCallback.Handler {
|
|
239
|
+
override fun fetchProviderInformation(
|
|
240
|
+
appId: String,
|
|
241
|
+
providerId: String,
|
|
242
|
+
sessionId: String,
|
|
243
|
+
signature: String,
|
|
244
|
+
timestamp: String,
|
|
245
|
+
callback: (Result<String>) -> Unit
|
|
246
|
+
) {
|
|
247
|
+
val args = Arguments.createMap()
|
|
248
|
+
args.putString("appId", appId)
|
|
249
|
+
args.putString("providerId", providerId)
|
|
250
|
+
args.putString("sessionId", sessionId)
|
|
251
|
+
args.putString("signature", signature)
|
|
252
|
+
args.putString("timestamp", timestamp)
|
|
253
|
+
val replyId = UUID.randomUUID().toString()
|
|
254
|
+
args.putString("replyId", replyId)
|
|
255
|
+
replyWithString[replyId] = callback
|
|
256
|
+
emitOnProviderInformationRequest(args)
|
|
257
|
+
}
|
|
258
|
+
})
|
|
259
|
+
else
|
|
260
|
+
(throw IllegalStateException("Invalid provider information. canFetchProviderInformationFromHost was not true and jsonString, url were also not provided."))
|
|
184
261
|
),
|
|
185
262
|
featureOptions = if (featureOptions == null) null else ReclaimOverrides.FeatureOptions(
|
|
186
263
|
cookiePersist = getBoolean(featureOptions, "cookiePersist"),
|
|
@@ -257,19 +334,32 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
257
334
|
appImageUrl = requireString(appInfo, "appImageUrl"),
|
|
258
335
|
isRecurring = getBoolean(appInfo, "isRecurring") ?: false,
|
|
259
336
|
),
|
|
337
|
+
capabilityAccessToken = capabilityAccessToken
|
|
260
338
|
) { result ->
|
|
261
339
|
result.onSuccess {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
promise?.
|
|
340
|
+
try {
|
|
341
|
+
Log.d(NAME, "(setOverrides) Success")
|
|
342
|
+
promise?.resolve(null)
|
|
343
|
+
} catch (e: Throwable) {
|
|
344
|
+
Log.e(NAME, "(setOverrides) Error resolving promise")
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
}.onFailure { error ->
|
|
348
|
+
try {
|
|
349
|
+
Log.d(NAME, "(setOverrides) Failure")
|
|
350
|
+
onPlatformException(promise, error)
|
|
351
|
+
} catch (e: Throwable) {
|
|
352
|
+
Log.e(NAME, "(setOverrides) Error rejecting promise", e)
|
|
265
353
|
}
|
|
354
|
+
}
|
|
266
355
|
}
|
|
267
356
|
}
|
|
268
357
|
}
|
|
269
358
|
|
|
359
|
+
private val replyHandlers: MutableMap<String, (Result<Boolean>) -> Unit> = mutableMapOf()
|
|
270
360
|
override fun reply(replyId: String?, reply: Boolean) {
|
|
271
361
|
if (replyId == null) {
|
|
272
|
-
Log.w(NAME, "Missing arg replyId")
|
|
362
|
+
Log.w(NAME, "(reply) Missing arg replyId")
|
|
273
363
|
return
|
|
274
364
|
}
|
|
275
365
|
reactContext.runOnUiQueueThread {
|
|
@@ -277,11 +367,40 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
277
367
|
if (callback != null) {
|
|
278
368
|
callback(Result.success(reply))
|
|
279
369
|
} else {
|
|
280
|
-
Log.w(NAME, "Missing reply handler for id: $replyId")
|
|
370
|
+
Log.w(NAME, "(reply) Missing reply handler for id: $replyId")
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private val replyWithString: MutableMap<String, (Result<String>) -> Unit> =
|
|
376
|
+
mutableMapOf()
|
|
377
|
+
|
|
378
|
+
override fun replyWithString(replyId: String?, value: String?) {
|
|
379
|
+
if (replyId == null) {
|
|
380
|
+
Log.w(NAME, "(replyWithString) Missing arg replyId")
|
|
381
|
+
return
|
|
382
|
+
}
|
|
383
|
+
reactContext.runOnUiQueueThread {
|
|
384
|
+
val callback = replyWithString[replyId]
|
|
385
|
+
if (callback != null) {
|
|
386
|
+
callback(Result.success(value ?: ""))
|
|
387
|
+
} else {
|
|
388
|
+
Log.w(NAME, "(replyWithString) Missing reply handler for id: $replyId")
|
|
281
389
|
}
|
|
282
390
|
}
|
|
283
391
|
}
|
|
284
392
|
|
|
393
|
+
private fun onPlatformException(promise: Promise?, exception: Throwable) {
|
|
394
|
+
if (exception is ReclaimVerification.ReclaimPlatformException) {
|
|
395
|
+
val userInfoMap = Arguments.createMap()
|
|
396
|
+
userInfoMap.putString("message", exception.internalErrorMessage)
|
|
397
|
+
userInfoMap.putString("errorCode", exception.errorCode)
|
|
398
|
+
promise?.reject("PLATFORM_ERROR", exception.message, exception, userInfoMap)
|
|
399
|
+
} else {
|
|
400
|
+
promise?.reject("PLATFORM_ERROR", "Unexpected Error", exception)
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
285
404
|
@Suppress("SameParameterValue")
|
|
286
405
|
private fun hasValue(map: ReadableMap, key: String): Boolean {
|
|
287
406
|
return map.hasKey(key) && !map.isNull(key)
|
|
@@ -315,7 +434,8 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
|
|
|
315
434
|
throw TypeCastException("Value for key $key is not a Number")
|
|
316
435
|
}
|
|
317
436
|
|
|
318
|
-
private fun getString(map: ReadableMap
|
|
437
|
+
private fun getString(map: ReadableMap?, key: String): String? {
|
|
438
|
+
if (map == null) return null
|
|
319
439
|
return if (!map.hasKey(key) || map.isNull(key)) {
|
|
320
440
|
null
|
|
321
441
|
} 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)replyWithString:(nonnull NSString *)replyId value:(nonnull NSString *)value {
|
|
39
|
+
[api replyWithStringWithReplyId:replyId value:value];
|
|
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
|
|
|
@@ -167,7 +179,7 @@ Api *api = [[Api alloc] init];
|
|
|
167
179
|
}
|
|
168
180
|
overridenLogConsumer = [[OverridenLogConsumer alloc] initWithLogHandler: logHandler canSdkCollectTelemetry: canSDKCollectTelemetry canSdkPrintLogs: canSdkPrintLogs];
|
|
169
181
|
}
|
|
170
|
-
|
|
182
|
+
|
|
171
183
|
OverridenSessionManagement * _Nullable sessionManagement;
|
|
172
184
|
if (overrides.sessionManagement().has_value()) {
|
|
173
185
|
sessionManagement = [[OverridenSessionManagement alloc] initWithHandler:[[OverridenSessionHandler alloc] initWith_createSession:^(NSString * _Nonnull appId, NSString * _Nonnull providerId, NSString * _Nonnull sessionId, NSString * _Nonnull replyId) {
|
|
@@ -183,12 +195,12 @@ Api *api = [[Api alloc] init];
|
|
|
183
195
|
@"status": status,
|
|
184
196
|
@"replyId": replyId
|
|
185
197
|
}];
|
|
186
|
-
} _logSession:^(NSString * _Nonnull appId, NSString * _Nonnull providerId, NSString * _Nonnull sessionId, NSString * _Nonnull
|
|
198
|
+
} _logSession:^(NSString * _Nonnull appId, NSString * _Nonnull providerId, NSString * _Nonnull sessionId, NSString * _Nonnull logType) {
|
|
187
199
|
[self emitOnSessionLogs:@{
|
|
188
200
|
@"appId": appId,
|
|
189
201
|
@"providerId": providerId,
|
|
190
202
|
@"sessionId": sessionId,
|
|
191
|
-
@"
|
|
203
|
+
@"logType": logType
|
|
192
204
|
}];
|
|
193
205
|
}]];
|
|
194
206
|
}
|
|
@@ -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,41 @@ 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
|
+
|
|
242
|
+
- (void)setVerificationOptions:(JS::NativeInappRnSdk::VerificationOptionsOptional &)args resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
243
|
+
ReclaimApiVerificationOptions * _Nullable options = nil;
|
|
244
|
+
if (args.options().has_value()) {
|
|
245
|
+
JS::NativeInappRnSdk::VerificationOptions inputOptions = args.options().value();
|
|
246
|
+
if (inputOptions.canUseAttestorAuthenticationRequest()) {
|
|
247
|
+
options = [[ReclaimApiVerificationOptions alloc] initWithCanDeleteCookiesBeforeVerificationStarts:inputOptions.canDeleteCookiesBeforeVerificationStarts() fetchAttestorAuthenticationRequest:^(NSString * _Nonnull reclaimHttpProviderJsonString, NSString * _Nonnull replyId) {
|
|
248
|
+
[self emitOnReclaimAttestorAuthRequest:@{
|
|
249
|
+
@"reclaimHttpProviderJsonString": reclaimHttpProviderJsonString,
|
|
250
|
+
@"replyId": replyId
|
|
251
|
+
}];
|
|
252
|
+
}
|
|
253
|
+
];
|
|
254
|
+
} else {
|
|
255
|
+
options = [[ReclaimApiVerificationOptions alloc] initWithCanDeleteCookiesBeforeVerificationStarts:inputOptions.canDeleteCookiesBeforeVerificationStarts() fetchAttestorAuthenticationRequest:nil];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
}
|
|
259
|
+
[api setVerificationOptionsWithOptions:options completionHandler:^(NSError * _Nullable error) {
|
|
260
|
+
if (error != nil) {
|
|
261
|
+
reject(@"VERIFICATION_OPTIONS_ERROR", @"Error on setting verification options", error);
|
|
262
|
+
} else {
|
|
263
|
+
resolve(nil);
|
|
264
|
+
}
|
|
265
|
+
}];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
215
269
|
@end
|
|
@@ -31,6 +31,18 @@
|
|
|
31
31
|
{
|
|
32
32
|
_eventEmitterCallback("onSessionUpdateRequest", value);
|
|
33
33
|
}
|
|
34
|
+
- (void)emitOnProviderInformationRequest:(NSDictionary *)value
|
|
35
|
+
{
|
|
36
|
+
_eventEmitterCallback("onProviderInformationRequest", value);
|
|
37
|
+
}
|
|
38
|
+
- (void)emitOnReclaimAttestorAuthRequest:(NSDictionary *)value
|
|
39
|
+
{
|
|
40
|
+
_eventEmitterCallback("onReclaimAttestorAuthRequest", value);
|
|
41
|
+
}
|
|
42
|
+
- (void)emitOnSessionIdentityUpdate:(NSDictionary *)value
|
|
43
|
+
{
|
|
44
|
+
_eventEmitterCallback("onSessionIdentityUpdate", value);
|
|
45
|
+
}
|
|
34
46
|
|
|
35
47
|
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
|
36
48
|
{
|
|
@@ -86,6 +98,18 @@
|
|
|
86
98
|
return facebook::react::managedPointer<JS::NativeInappRnSdk::Overrides>(json);
|
|
87
99
|
}
|
|
88
100
|
@end
|
|
101
|
+
@implementation RCTCxxConvert (NativeInappRnSdk_VerificationOptions)
|
|
102
|
+
+ (RCTManagedPointer *)JS_NativeInappRnSdk_VerificationOptions:(id)json
|
|
103
|
+
{
|
|
104
|
+
return facebook::react::managedPointer<JS::NativeInappRnSdk::VerificationOptions>(json);
|
|
105
|
+
}
|
|
106
|
+
@end
|
|
107
|
+
@implementation RCTCxxConvert (NativeInappRnSdk_VerificationOptionsOptional)
|
|
108
|
+
+ (RCTManagedPointer *)JS_NativeInappRnSdk_VerificationOptionsOptional:(id)json
|
|
109
|
+
{
|
|
110
|
+
return facebook::react::managedPointer<JS::NativeInappRnSdk::VerificationOptionsOptional>(json);
|
|
111
|
+
}
|
|
112
|
+
@end
|
|
89
113
|
namespace facebook::react {
|
|
90
114
|
|
|
91
115
|
static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_startVerification(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
@@ -100,10 +124,22 @@ namespace facebook::react {
|
|
|
100
124
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "setOverrides", @selector(setOverrides:resolve:reject:), args, count);
|
|
101
125
|
}
|
|
102
126
|
|
|
127
|
+
static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_clearAllOverrides(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
128
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "clearAllOverrides", @selector(clearAllOverrides:reject:), args, count);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_setVerificationOptions(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
132
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "setVerificationOptions", @selector(setVerificationOptions:resolve:reject:), args, count);
|
|
133
|
+
}
|
|
134
|
+
|
|
103
135
|
static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_reply(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
104
136
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "reply", @selector(reply:reply:), args, count);
|
|
105
137
|
}
|
|
106
138
|
|
|
139
|
+
static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_replyWithString(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
140
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "replyWithString", @selector(replyWithString:value:), args, count);
|
|
141
|
+
}
|
|
142
|
+
|
|
107
143
|
static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_ping(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
108
144
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "ping", @selector(ping:reject:), args, count);
|
|
109
145
|
}
|
|
@@ -120,15 +156,27 @@ namespace facebook::react {
|
|
|
120
156
|
methodMap_["setOverrides"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkSpecJSI_setOverrides};
|
|
121
157
|
setMethodArgConversionSelector(@"setOverrides", 0, @"JS_NativeInappRnSdk_Overrides:");
|
|
122
158
|
|
|
159
|
+
methodMap_["clearAllOverrides"] = MethodMetadata {0, __hostFunction_NativeInappRnSdkSpecJSI_clearAllOverrides};
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
methodMap_["setVerificationOptions"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkSpecJSI_setVerificationOptions};
|
|
163
|
+
setMethodArgConversionSelector(@"setVerificationOptions", 0, @"JS_NativeInappRnSdk_VerificationOptionsOptional:");
|
|
164
|
+
|
|
123
165
|
methodMap_["reply"] = MethodMetadata {2, __hostFunction_NativeInappRnSdkSpecJSI_reply};
|
|
124
166
|
|
|
125
167
|
|
|
168
|
+
methodMap_["replyWithString"] = MethodMetadata {2, __hostFunction_NativeInappRnSdkSpecJSI_replyWithString};
|
|
169
|
+
|
|
170
|
+
|
|
126
171
|
methodMap_["ping"] = MethodMetadata {0, __hostFunction_NativeInappRnSdkSpecJSI_ping};
|
|
127
172
|
|
|
128
173
|
eventEmitterMap_["onLogs"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
129
174
|
eventEmitterMap_["onSessionLogs"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
130
175
|
eventEmitterMap_["onSessionCreateRequest"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
131
176
|
eventEmitterMap_["onSessionUpdateRequest"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
177
|
+
eventEmitterMap_["onProviderInformationRequest"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
178
|
+
eventEmitterMap_["onReclaimAttestorAuthRequest"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
179
|
+
eventEmitterMap_["onSessionIdentityUpdate"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
132
180
|
setEventEmitterCallback([&](const std::string &name, id value) {
|
|
133
181
|
static_cast<AsyncEventEmitter<id> &>(*eventEmitterMap_[name]).emit(value);
|
|
134
182
|
});
|
|
@@ -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:
|
|
@@ -178,6 +179,37 @@ namespace JS {
|
|
|
178
179
|
@interface RCTCxxConvert (NativeInappRnSdk_Overrides)
|
|
179
180
|
+ (RCTManagedPointer *)JS_NativeInappRnSdk_Overrides:(id)json;
|
|
180
181
|
@end
|
|
182
|
+
namespace JS {
|
|
183
|
+
namespace NativeInappRnSdk {
|
|
184
|
+
struct VerificationOptions {
|
|
185
|
+
bool canDeleteCookiesBeforeVerificationStarts() const;
|
|
186
|
+
bool canUseAttestorAuthenticationRequest() const;
|
|
187
|
+
|
|
188
|
+
VerificationOptions(NSDictionary *const v) : _v(v) {}
|
|
189
|
+
private:
|
|
190
|
+
NSDictionary *_v;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@interface RCTCxxConvert (NativeInappRnSdk_VerificationOptions)
|
|
196
|
+
+ (RCTManagedPointer *)JS_NativeInappRnSdk_VerificationOptions:(id)json;
|
|
197
|
+
@end
|
|
198
|
+
namespace JS {
|
|
199
|
+
namespace NativeInappRnSdk {
|
|
200
|
+
struct VerificationOptionsOptional {
|
|
201
|
+
std::optional<JS::NativeInappRnSdk::VerificationOptions> options() const;
|
|
202
|
+
|
|
203
|
+
VerificationOptionsOptional(NSDictionary *const v) : _v(v) {}
|
|
204
|
+
private:
|
|
205
|
+
NSDictionary *_v;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@interface RCTCxxConvert (NativeInappRnSdk_VerificationOptionsOptional)
|
|
211
|
+
+ (RCTManagedPointer *)JS_NativeInappRnSdk_VerificationOptionsOptional:(id)json;
|
|
212
|
+
@end
|
|
181
213
|
@protocol NativeInappRnSdkSpec <RCTBridgeModule, RCTTurboModule>
|
|
182
214
|
|
|
183
215
|
- (void)startVerification:(JS::NativeInappRnSdk::Request &)request
|
|
@@ -189,8 +221,15 @@ namespace JS {
|
|
|
189
221
|
- (void)setOverrides:(JS::NativeInappRnSdk::Overrides &)overrides
|
|
190
222
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
191
223
|
reject:(RCTPromiseRejectBlock)reject;
|
|
224
|
+
- (void)clearAllOverrides:(RCTPromiseResolveBlock)resolve
|
|
225
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
226
|
+
- (void)setVerificationOptions:(JS::NativeInappRnSdk::VerificationOptionsOptional &)args
|
|
227
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
228
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
192
229
|
- (void)reply:(NSString *)replyId
|
|
193
230
|
reply:(BOOL)reply;
|
|
231
|
+
- (void)replyWithString:(NSString *)replyId
|
|
232
|
+
value:(NSString *)value;
|
|
194
233
|
- (void)ping:(RCTPromiseResolveBlock)resolve
|
|
195
234
|
reject:(RCTPromiseRejectBlock)reject;
|
|
196
235
|
|
|
@@ -206,6 +245,9 @@ facebook::react::EventEmitterCallback _eventEmitterCallback;
|
|
|
206
245
|
- (void)emitOnSessionLogs:(NSDictionary *)value;
|
|
207
246
|
- (void)emitOnSessionCreateRequest:(NSDictionary *)value;
|
|
208
247
|
- (void)emitOnSessionUpdateRequest:(NSDictionary *)value;
|
|
248
|
+
- (void)emitOnProviderInformationRequest:(NSDictionary *)value;
|
|
249
|
+
- (void)emitOnReclaimAttestorAuthRequest:(NSDictionary *)value;
|
|
250
|
+
- (void)emitOnSessionIdentityUpdate:(NSDictionary *)value;
|
|
209
251
|
@end
|
|
210
252
|
|
|
211
253
|
namespace facebook::react {
|
|
@@ -262,11 +304,6 @@ inline id<NSObject> _Nullable JS::NativeInappRnSdk::Request::parameters() const
|
|
|
262
304
|
id const p = _v[@"parameters"];
|
|
263
305
|
return p;
|
|
264
306
|
}
|
|
265
|
-
inline std::optional<bool> JS::NativeInappRnSdk::Request::hideLanding() const
|
|
266
|
-
{
|
|
267
|
-
id const p = _v[@"hideLanding"];
|
|
268
|
-
return RCTBridgingToOptionalBool(p);
|
|
269
|
-
}
|
|
270
307
|
inline std::optional<bool> JS::NativeInappRnSdk::Request::autoSubmit() const
|
|
271
308
|
{
|
|
272
309
|
id const p = _v[@"autoSubmit"];
|
|
@@ -292,6 +329,11 @@ inline NSString *JS::NativeInappRnSdk::ProviderInformation::jsonString() const
|
|
|
292
329
|
id const p = _v[@"jsonString"];
|
|
293
330
|
return RCTBridgingToOptionalString(p);
|
|
294
331
|
}
|
|
332
|
+
inline bool JS::NativeInappRnSdk::ProviderInformation::canFetchProviderInformationFromHost() const
|
|
333
|
+
{
|
|
334
|
+
id const p = _v[@"canFetchProviderInformationFromHost"];
|
|
335
|
+
return RCTBridgingToBool(p);
|
|
336
|
+
}
|
|
295
337
|
inline std::optional<bool> JS::NativeInappRnSdk::FeatureOptions::cookiePersist() const
|
|
296
338
|
{
|
|
297
339
|
id const p = _v[@"cookiePersist"];
|
|
@@ -387,5 +429,25 @@ inline std::optional<JS::NativeInappRnSdk::ReclaimAppInfo> JS::NativeInappRnSdk:
|
|
|
387
429
|
id const p = _v[@"appInfo"];
|
|
388
430
|
return (p == nil ? std::nullopt : std::make_optional(JS::NativeInappRnSdk::ReclaimAppInfo(p)));
|
|
389
431
|
}
|
|
432
|
+
inline NSString *JS::NativeInappRnSdk::Overrides::capabilityAccessToken() const
|
|
433
|
+
{
|
|
434
|
+
id const p = _v[@"capabilityAccessToken"];
|
|
435
|
+
return RCTBridgingToOptionalString(p);
|
|
436
|
+
}
|
|
437
|
+
inline bool JS::NativeInappRnSdk::VerificationOptions::canDeleteCookiesBeforeVerificationStarts() const
|
|
438
|
+
{
|
|
439
|
+
id const p = _v[@"canDeleteCookiesBeforeVerificationStarts"];
|
|
440
|
+
return RCTBridgingToBool(p);
|
|
441
|
+
}
|
|
442
|
+
inline bool JS::NativeInappRnSdk::VerificationOptions::canUseAttestorAuthenticationRequest() const
|
|
443
|
+
{
|
|
444
|
+
id const p = _v[@"canUseAttestorAuthenticationRequest"];
|
|
445
|
+
return RCTBridgingToBool(p);
|
|
446
|
+
}
|
|
447
|
+
inline std::optional<JS::NativeInappRnSdk::VerificationOptions> JS::NativeInappRnSdk::VerificationOptionsOptional::options() const
|
|
448
|
+
{
|
|
449
|
+
id const p = _v[@"options"];
|
|
450
|
+
return (p == nil ? std::nullopt : std::make_optional(JS::NativeInappRnSdk::VerificationOptions(p)));
|
|
451
|
+
}
|
|
390
452
|
NS_ASSUME_NONNULL_END
|
|
391
453
|
#endif // RNInappRnSdkSpec_H
|