@reclaimprotocol/inapp-rn-sdk 0.7.3 → 0.9.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.
Files changed (40) hide show
  1. package/InappRnSdk.podspec +1 -1
  2. package/README.md +8 -6
  3. package/android/build.gradle +1 -1
  4. package/android/generated/java/com/reclaimprotocol/inapp_rn_sdk/NativeInappRnSdkSpec.java +4 -0
  5. package/android/generated/jni/RNInappRnSdkSpec-generated.cpp +6 -0
  6. package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI-generated.cpp +7 -0
  7. package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI.h +105 -25
  8. package/android/src/main/java/com/reclaimprotocol/inapp_rn_sdk/InappRnSdkModule.kt +46 -9
  9. package/android/src/main/java/com/reclaimprotocol/inapp_rn_sdk/JsonExtension.kt +18 -0
  10. package/ios/InappRnSdk.mm +267 -138
  11. package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec-generated.mm +13 -0
  12. package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec.h +45 -10
  13. package/ios/generated/RNInappRnSdkSpecJSI-generated.cpp +7 -0
  14. package/ios/generated/RNInappRnSdkSpecJSI.h +105 -25
  15. package/ios/inapp_rn_sdk/Api.swift +322 -154
  16. package/lib/commonjs/index.js +36 -1
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/commonjs/specs/NativeInappRnSdk.js.map +1 -1
  19. package/lib/module/index.js +36 -1
  20. package/lib/module/index.js.map +1 -1
  21. package/lib/module/specs/NativeInappRnSdk.js.map +1 -1
  22. package/lib/typescript/commonjs/src/index.d.ts +18 -2
  23. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts +23 -2
  25. package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts.map +1 -1
  26. package/lib/typescript/commonjs/user-workspace/src/App.d.ts +2 -0
  27. package/lib/typescript/commonjs/user-workspace/src/App.d.ts.map +1 -0
  28. package/lib/typescript/commonjs/user-workspace/src/App.overrides.d.ts +2 -0
  29. package/lib/typescript/commonjs/user-workspace/src/App.overrides.d.ts.map +1 -0
  30. package/lib/typescript/module/src/index.d.ts +18 -2
  31. package/lib/typescript/module/src/index.d.ts.map +1 -1
  32. package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts +23 -2
  33. package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts.map +1 -1
  34. package/lib/typescript/module/user-workspace/src/App.d.ts +2 -0
  35. package/lib/typescript/module/user-workspace/src/App.d.ts.map +1 -0
  36. package/lib/typescript/module/user-workspace/src/App.overrides.d.ts +2 -0
  37. package/lib/typescript/module/user-workspace/src/App.overrides.d.ts.map +1 -0
  38. package/package.json +8 -7
  39. package/src/index.ts +59 -3
  40. package/src/specs/NativeInappRnSdk.ts +25 -2
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
 
18
18
  s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
19
19
  s.private_header_files = "ios/generated/**/*.h"
20
- s.dependency "ReclaimInAppSdk", "~> 0.7.0"
20
+ s.dependency "ReclaimInAppSdk", "~> 0.9.0"
21
21
 
22
22
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
23
23
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
package/README.md CHANGED
@@ -110,13 +110,13 @@ Ignore if you already have this declaration in your `Podfile`.
110
110
 
111
111
  ```ruby
112
112
  # Cocoapods is the recommended way to install the SDK.
113
- pod 'ReclaimInAppSdk', '~> 0.7.0'
113
+ pod 'ReclaimInAppSdk', '~> 0.9.0'
114
114
  ```
115
115
 
116
116
  ##### From a specific tag
117
117
 
118
118
  ```ruby
119
- pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git', :tag => '0.7.0'
119
+ pod 'ReclaimInAppSdk', :git => 'https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git', :tag => '0.9.0'
120
120
  ```
121
121
 
122
122
  ##### From git HEAD
@@ -153,7 +153,7 @@ target 'InappRnSdkExample' do
153
153
  )
154
154
 
155
155
  # This is the line that you may need to add in your podfile.
156
- pod 'ReclaimInAppSdk', '~> 0.7.0'
156
+ pod 'ReclaimInAppSdk', '~> 0.9.0'
157
157
 
158
158
  pre_install do |installer|
159
159
  system("cd ../../ && npx bob build --target codegen")
@@ -292,13 +292,15 @@ error.innerError
292
292
 
293
293
  ## Troubleshooting
294
294
 
295
- ### Build failures for iOS in 0.7.0
295
+ ### Build failures for iOS in 0.7.x
296
296
 
297
- - An accidental breaking change causes 0.7.0, 0.7.1 to fail with build failures for ios. 0.7.2 fixes this issue.
297
+ - An accidental breaking change may cause 0.7.0, 0.7.1, 0.7.2 to fail with build failures for Android and iOS. Update 0.7.3 fixes this issue.
298
298
 
299
299
  ## Migration
300
300
 
301
- - Migration steps for [0.7.2](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/blob/main/documentation/migration.md#072)
301
+ - Migration steps for [0.9.0](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/blob/main/documentation/migration.md#090)
302
+ - Migration steps for [0.8.3](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/blob/main/documentation/migration.md#083)
303
+ - Migration steps for [0.7.3](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/blob/main/documentation/migration.md#073)
302
304
  - Migration steps for [0.6.0](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/blob/main/documentation/migration.md#060)
303
305
  - Migration steps for [0.3.1](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/blob/main/documentation/migration.md#031)
304
306
  - Migration steps for [0.3.0](https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk/blob/main/documentation/migration.md#030)
@@ -118,7 +118,7 @@ dependencies {
118
118
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
119
119
 
120
120
  //noinspection UseTomlInstead
121
- implementation "org.reclaimprotocol:inapp_sdk:0.7.3"
121
+ implementation "org.reclaimprotocol:inapp_sdk:0.9.0"
122
122
  }
123
123
 
124
124
  if (isNewArchitectureEnabled()) {
@@ -69,6 +69,10 @@ public abstract class NativeInappRnSdkSpec extends ReactContextBaseJavaModule im
69
69
  @DoNotStrip
70
70
  public abstract void startVerificationFromUrl(String requestUrl, Promise promise);
71
71
 
72
+ @ReactMethod
73
+ @DoNotStrip
74
+ public abstract void startVerificationFromJson(String templateJsonString, Promise promise);
75
+
72
76
  @ReactMethod
73
77
  @DoNotStrip
74
78
  public abstract void setOverrides(ReadableMap overrides, Promise promise);
@@ -22,6 +22,11 @@ static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_startVerifica
22
22
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "startVerificationFromUrl", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
23
23
  }
24
24
 
25
+ static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_startVerificationFromJson(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
26
+ static jmethodID cachedMethodId = nullptr;
27
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "startVerificationFromJson", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
28
+ }
29
+
25
30
  static facebook::jsi::Value __hostFunction_NativeInappRnSdkSpecJSI_setOverrides(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
26
31
  static jmethodID cachedMethodId = nullptr;
27
32
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "setOverrides", "(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
@@ -56,6 +61,7 @@ NativeInappRnSdkSpecJSI::NativeInappRnSdkSpecJSI(const JavaTurboModule::InitPara
56
61
  : JavaTurboModule(params) {
57
62
  methodMap_["startVerification"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkSpecJSI_startVerification};
58
63
  methodMap_["startVerificationFromUrl"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkSpecJSI_startVerificationFromUrl};
64
+ methodMap_["startVerificationFromJson"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkSpecJSI_startVerificationFromJson};
59
65
  methodMap_["setOverrides"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkSpecJSI_setOverrides};
60
66
  methodMap_["clearAllOverrides"] = MethodMetadata {0, __hostFunction_NativeInappRnSdkSpecJSI_clearAllOverrides};
61
67
  methodMap_["setVerificationOptions"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkSpecJSI_setVerificationOptions};
@@ -23,6 +23,12 @@ static jsi::Value __hostFunction_NativeInappRnSdkCxxSpecJSI_startVerificationFro
23
23
  count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
24
24
  );
25
25
  }
26
+ static jsi::Value __hostFunction_NativeInappRnSdkCxxSpecJSI_startVerificationFromJson(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
27
+ return static_cast<NativeInappRnSdkCxxSpecJSI *>(&turboModule)->startVerificationFromJson(
28
+ rt,
29
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
30
+ );
31
+ }
26
32
  static jsi::Value __hostFunction_NativeInappRnSdkCxxSpecJSI_setOverrides(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
27
33
  return static_cast<NativeInappRnSdkCxxSpecJSI *>(&turboModule)->setOverrides(
28
34
  rt,
@@ -66,6 +72,7 @@ NativeInappRnSdkCxxSpecJSI::NativeInappRnSdkCxxSpecJSI(std::shared_ptr<CallInvok
66
72
  : TurboModule("InappRnSdk", jsInvoker) {
67
73
  methodMap_["startVerification"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkCxxSpecJSI_startVerification};
68
74
  methodMap_["startVerificationFromUrl"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkCxxSpecJSI_startVerificationFromUrl};
75
+ methodMap_["startVerificationFromJson"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkCxxSpecJSI_startVerificationFromJson};
69
76
  methodMap_["setOverrides"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkCxxSpecJSI_setOverrides};
70
77
  methodMap_["clearAllOverrides"] = MethodMetadata {0, __hostFunction_NativeInappRnSdkCxxSpecJSI_clearAllOverrides};
71
78
  methodMap_["setVerificationOptions"] = MethodMetadata {1, __hostFunction_NativeInappRnSdkCxxSpecJSI_setVerificationOptions};
@@ -18,7 +18,7 @@ namespace facebook::react {
18
18
 
19
19
  #pragma mark - NativeInappRnSdkFeatureOptions
20
20
 
21
- template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5>
21
+ template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
22
22
  struct NativeInappRnSdkFeatureOptions {
23
23
  P0 cookiePersist;
24
24
  P1 singleReclaimRequest;
@@ -26,8 +26,10 @@ struct NativeInappRnSdkFeatureOptions {
26
26
  P3 sessionTimeoutForManualVerificationTrigger;
27
27
  P4 attestorBrowserRpcUrl;
28
28
  P5 isAIFlowEnabled;
29
+ P6 manualReviewMessage;
30
+ P7 loginPromptMessage;
29
31
  bool operator==(const NativeInappRnSdkFeatureOptions &other) const {
30
- return cookiePersist == other.cookiePersist && singleReclaimRequest == other.singleReclaimRequest && idleTimeThresholdForManualVerificationTrigger == other.idleTimeThresholdForManualVerificationTrigger && sessionTimeoutForManualVerificationTrigger == other.sessionTimeoutForManualVerificationTrigger && attestorBrowserRpcUrl == other.attestorBrowserRpcUrl && isAIFlowEnabled == other.isAIFlowEnabled;
32
+ return cookiePersist == other.cookiePersist && singleReclaimRequest == other.singleReclaimRequest && idleTimeThresholdForManualVerificationTrigger == other.idleTimeThresholdForManualVerificationTrigger && sessionTimeoutForManualVerificationTrigger == other.sessionTimeoutForManualVerificationTrigger && attestorBrowserRpcUrl == other.attestorBrowserRpcUrl && isAIFlowEnabled == other.isAIFlowEnabled && manualReviewMessage == other.manualReviewMessage && loginPromptMessage == other.loginPromptMessage;
31
33
  }
32
34
  };
33
35
 
@@ -45,7 +47,9 @@ struct NativeInappRnSdkFeatureOptionsBridging {
45
47
  bridging::fromJs<decltype(types.idleTimeThresholdForManualVerificationTrigger)>(rt, value.getProperty(rt, "idleTimeThresholdForManualVerificationTrigger"), jsInvoker),
46
48
  bridging::fromJs<decltype(types.sessionTimeoutForManualVerificationTrigger)>(rt, value.getProperty(rt, "sessionTimeoutForManualVerificationTrigger"), jsInvoker),
47
49
  bridging::fromJs<decltype(types.attestorBrowserRpcUrl)>(rt, value.getProperty(rt, "attestorBrowserRpcUrl"), jsInvoker),
48
- bridging::fromJs<decltype(types.isAIFlowEnabled)>(rt, value.getProperty(rt, "isAIFlowEnabled"), jsInvoker)};
50
+ bridging::fromJs<decltype(types.isAIFlowEnabled)>(rt, value.getProperty(rt, "isAIFlowEnabled"), jsInvoker),
51
+ bridging::fromJs<decltype(types.manualReviewMessage)>(rt, value.getProperty(rt, "manualReviewMessage"), jsInvoker),
52
+ bridging::fromJs<decltype(types.loginPromptMessage)>(rt, value.getProperty(rt, "loginPromptMessage"), jsInvoker)};
49
53
  return result;
50
54
  }
51
55
 
@@ -73,6 +77,14 @@ struct NativeInappRnSdkFeatureOptionsBridging {
73
77
  static std::optional<bool> isAIFlowEnabledToJs(jsi::Runtime &rt, decltype(types.isAIFlowEnabled) value) {
74
78
  return bridging::toJs(rt, value);
75
79
  }
80
+
81
+ static std::optional<jsi::String> manualReviewMessageToJs(jsi::Runtime &rt, decltype(types.manualReviewMessage) value) {
82
+ return bridging::toJs(rt, value);
83
+ }
84
+
85
+ static std::optional<jsi::String> loginPromptMessageToJs(jsi::Runtime &rt, decltype(types.loginPromptMessage) value) {
86
+ return bridging::toJs(rt, value);
87
+ }
76
88
  #endif
77
89
 
78
90
  static jsi::Object toJs(
@@ -98,6 +110,12 @@ struct NativeInappRnSdkFeatureOptionsBridging {
98
110
  if (value.isAIFlowEnabled) {
99
111
  result.setProperty(rt, "isAIFlowEnabled", bridging::toJs(rt, value.isAIFlowEnabled.value(), jsInvoker));
100
112
  }
113
+ if (value.manualReviewMessage) {
114
+ result.setProperty(rt, "manualReviewMessage", bridging::toJs(rt, value.manualReviewMessage.value(), jsInvoker));
115
+ }
116
+ if (value.loginPromptMessage) {
117
+ result.setProperty(rt, "loginPromptMessage", bridging::toJs(rt, value.loginPromptMessage.value(), jsInvoker));
118
+ }
101
119
  return result;
102
120
  }
103
121
  };
@@ -312,16 +330,17 @@ struct NativeInappRnSdkProviderInformationBridging {
312
330
 
313
331
  #pragma mark - NativeInappRnSdkProviderInformationRequest
314
332
 
315
- template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5>
333
+ template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
316
334
  struct NativeInappRnSdkProviderInformationRequest {
317
335
  P0 appId;
318
336
  P1 providerId;
319
337
  P2 sessionId;
320
338
  P3 signature;
321
339
  P4 timestamp;
322
- P5 replyId;
340
+ P5 resolvedVersion;
341
+ P6 replyId;
323
342
  bool operator==(const NativeInappRnSdkProviderInformationRequest &other) const {
324
- return appId == other.appId && providerId == other.providerId && sessionId == other.sessionId && signature == other.signature && timestamp == other.timestamp && replyId == other.replyId;
343
+ return appId == other.appId && providerId == other.providerId && sessionId == other.sessionId && signature == other.signature && timestamp == other.timestamp && resolvedVersion == other.resolvedVersion && replyId == other.replyId;
325
344
  }
326
345
  };
327
346
 
@@ -339,6 +358,7 @@ struct NativeInappRnSdkProviderInformationRequestBridging {
339
358
  bridging::fromJs<decltype(types.sessionId)>(rt, value.getProperty(rt, "sessionId"), jsInvoker),
340
359
  bridging::fromJs<decltype(types.signature)>(rt, value.getProperty(rt, "signature"), jsInvoker),
341
360
  bridging::fromJs<decltype(types.timestamp)>(rt, value.getProperty(rt, "timestamp"), jsInvoker),
361
+ bridging::fromJs<decltype(types.resolvedVersion)>(rt, value.getProperty(rt, "resolvedVersion"), jsInvoker),
342
362
  bridging::fromJs<decltype(types.replyId)>(rt, value.getProperty(rt, "replyId"), jsInvoker)};
343
363
  return result;
344
364
  }
@@ -364,6 +384,10 @@ struct NativeInappRnSdkProviderInformationRequestBridging {
364
384
  return bridging::toJs(rt, value);
365
385
  }
366
386
 
387
+ static jsi::String resolvedVersionToJs(jsi::Runtime &rt, decltype(types.resolvedVersion) value) {
388
+ return bridging::toJs(rt, value);
389
+ }
390
+
367
391
  static jsi::String replyIdToJs(jsi::Runtime &rt, decltype(types.replyId) value) {
368
392
  return bridging::toJs(rt, value);
369
393
  }
@@ -379,6 +403,7 @@ struct NativeInappRnSdkProviderInformationRequestBridging {
379
403
  result.setProperty(rt, "sessionId", bridging::toJs(rt, value.sessionId, jsInvoker));
380
404
  result.setProperty(rt, "signature", bridging::toJs(rt, value.signature, jsInvoker));
381
405
  result.setProperty(rt, "timestamp", bridging::toJs(rt, value.timestamp, jsInvoker));
406
+ result.setProperty(rt, "resolvedVersion", bridging::toJs(rt, value.resolvedVersion, jsInvoker));
382
407
  result.setProperty(rt, "replyId", bridging::toJs(rt, value.replyId, jsInvoker));
383
408
  return result;
384
409
  }
@@ -386,6 +411,54 @@ struct NativeInappRnSdkProviderInformationRequestBridging {
386
411
 
387
412
 
388
413
 
414
+ #pragma mark - NativeInappRnSdkProviderVersion
415
+
416
+ template <typename P0, typename P1>
417
+ struct NativeInappRnSdkProviderVersion {
418
+ P0 resolvedVersion;
419
+ P1 versionExpression;
420
+ bool operator==(const NativeInappRnSdkProviderVersion &other) const {
421
+ return resolvedVersion == other.resolvedVersion && versionExpression == other.versionExpression;
422
+ }
423
+ };
424
+
425
+ template <typename T>
426
+ struct NativeInappRnSdkProviderVersionBridging {
427
+ static T types;
428
+
429
+ static T fromJs(
430
+ jsi::Runtime &rt,
431
+ const jsi::Object &value,
432
+ const std::shared_ptr<CallInvoker> &jsInvoker) {
433
+ T result{
434
+ bridging::fromJs<decltype(types.resolvedVersion)>(rt, value.getProperty(rt, "resolvedVersion"), jsInvoker),
435
+ bridging::fromJs<decltype(types.versionExpression)>(rt, value.getProperty(rt, "versionExpression"), jsInvoker)};
436
+ return result;
437
+ }
438
+
439
+ #ifdef DEBUG
440
+ static jsi::String resolvedVersionToJs(jsi::Runtime &rt, decltype(types.resolvedVersion) value) {
441
+ return bridging::toJs(rt, value);
442
+ }
443
+
444
+ static jsi::String versionExpressionToJs(jsi::Runtime &rt, decltype(types.versionExpression) value) {
445
+ return bridging::toJs(rt, value);
446
+ }
447
+ #endif
448
+
449
+ static jsi::Object toJs(
450
+ jsi::Runtime &rt,
451
+ const T &value,
452
+ const std::shared_ptr<CallInvoker> &jsInvoker) {
453
+ auto result = facebook::jsi::Object(rt);
454
+ result.setProperty(rt, "resolvedVersion", bridging::toJs(rt, value.resolvedVersion, jsInvoker));
455
+ result.setProperty(rt, "versionExpression", bridging::toJs(rt, value.versionExpression, jsInvoker));
456
+ return result;
457
+ }
458
+ };
459
+
460
+
461
+
389
462
  #pragma mark - NativeInappRnSdkReclaimAppInfo
390
463
 
391
464
  template <typename P0, typename P1, typename P2>
@@ -548,7 +621,7 @@ struct NativeInappRnSdkReclaimSessionIdentityUpdateBridging {
548
621
 
549
622
  #pragma mark - NativeInappRnSdkRequest
550
623
 
551
- template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
624
+ template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
552
625
  struct NativeInappRnSdkRequest {
553
626
  P0 appId;
554
627
  P1 secret;
@@ -556,10 +629,9 @@ struct NativeInappRnSdkRequest {
556
629
  P3 session;
557
630
  P4 contextString;
558
631
  P5 parameters;
559
- P6 acceptAiProviders;
560
- P7 webhookUrl;
632
+ P6 providerVersion;
561
633
  bool operator==(const NativeInappRnSdkRequest &other) const {
562
- return appId == other.appId && secret == other.secret && providerId == other.providerId && session == other.session && contextString == other.contextString && parameters == other.parameters && acceptAiProviders == other.acceptAiProviders && webhookUrl == other.webhookUrl;
634
+ return appId == other.appId && secret == other.secret && providerId == other.providerId && session == other.session && contextString == other.contextString && parameters == other.parameters && providerVersion == other.providerVersion;
563
635
  }
564
636
  };
565
637
 
@@ -578,8 +650,7 @@ struct NativeInappRnSdkRequestBridging {
578
650
  bridging::fromJs<decltype(types.session)>(rt, value.getProperty(rt, "session"), jsInvoker),
579
651
  bridging::fromJs<decltype(types.contextString)>(rt, value.getProperty(rt, "contextString"), jsInvoker),
580
652
  bridging::fromJs<decltype(types.parameters)>(rt, value.getProperty(rt, "parameters"), jsInvoker),
581
- bridging::fromJs<decltype(types.acceptAiProviders)>(rt, value.getProperty(rt, "acceptAiProviders"), jsInvoker),
582
- bridging::fromJs<decltype(types.webhookUrl)>(rt, value.getProperty(rt, "webhookUrl"), jsInvoker)};
653
+ bridging::fromJs<decltype(types.providerVersion)>(rt, value.getProperty(rt, "providerVersion"), jsInvoker)};
583
654
  return result;
584
655
  }
585
656
 
@@ -608,11 +679,7 @@ struct NativeInappRnSdkRequestBridging {
608
679
  return bridging::toJs(rt, value);
609
680
  }
610
681
 
611
- static bool acceptAiProvidersToJs(jsi::Runtime &rt, decltype(types.acceptAiProviders) value) {
612
- return bridging::toJs(rt, value);
613
- }
614
-
615
- static std::optional<jsi::String> webhookUrlToJs(jsi::Runtime &rt, decltype(types.webhookUrl) value) {
682
+ static std::optional<jsi::Object> providerVersionToJs(jsi::Runtime &rt, decltype(types.providerVersion) value) {
616
683
  return bridging::toJs(rt, value);
617
684
  }
618
685
  #endif
@@ -634,11 +701,8 @@ struct NativeInappRnSdkRequestBridging {
634
701
  if (value.parameters) {
635
702
  result.setProperty(rt, "parameters", bridging::toJs(rt, value.parameters.value(), jsInvoker));
636
703
  }
637
- if (value.acceptAiProviders) {
638
- result.setProperty(rt, "acceptAiProviders", bridging::toJs(rt, value.acceptAiProviders.value(), jsInvoker));
639
- }
640
- if (value.webhookUrl) {
641
- result.setProperty(rt, "webhookUrl", bridging::toJs(rt, value.webhookUrl.value(), jsInvoker));
704
+ if (value.providerVersion) {
705
+ result.setProperty(rt, "providerVersion", bridging::toJs(rt, value.providerVersion.value(), jsInvoker));
642
706
  }
643
707
  return result;
644
708
  }
@@ -703,15 +767,16 @@ struct NativeInappRnSdkResponseBridging {
703
767
 
704
768
  #pragma mark - NativeInappRnSdkSessionCreateRequestEvent
705
769
 
706
- template <typename P0, typename P1, typename P2, typename P3, typename P4>
770
+ template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5>
707
771
  struct NativeInappRnSdkSessionCreateRequestEvent {
708
772
  P0 appId;
709
773
  P1 providerId;
710
774
  P2 timestamp;
711
775
  P3 signature;
712
- P4 replyId;
776
+ P4 providerVersion;
777
+ P5 replyId;
713
778
  bool operator==(const NativeInappRnSdkSessionCreateRequestEvent &other) const {
714
- return appId == other.appId && providerId == other.providerId && timestamp == other.timestamp && signature == other.signature && replyId == other.replyId;
779
+ return appId == other.appId && providerId == other.providerId && timestamp == other.timestamp && signature == other.signature && providerVersion == other.providerVersion && replyId == other.replyId;
715
780
  }
716
781
  };
717
782
 
@@ -728,6 +793,7 @@ struct NativeInappRnSdkSessionCreateRequestEventBridging {
728
793
  bridging::fromJs<decltype(types.providerId)>(rt, value.getProperty(rt, "providerId"), jsInvoker),
729
794
  bridging::fromJs<decltype(types.timestamp)>(rt, value.getProperty(rt, "timestamp"), jsInvoker),
730
795
  bridging::fromJs<decltype(types.signature)>(rt, value.getProperty(rt, "signature"), jsInvoker),
796
+ bridging::fromJs<decltype(types.providerVersion)>(rt, value.getProperty(rt, "providerVersion"), jsInvoker),
731
797
  bridging::fromJs<decltype(types.replyId)>(rt, value.getProperty(rt, "replyId"), jsInvoker)};
732
798
  return result;
733
799
  }
@@ -749,6 +815,10 @@ struct NativeInappRnSdkSessionCreateRequestEventBridging {
749
815
  return bridging::toJs(rt, value);
750
816
  }
751
817
 
818
+ static jsi::String providerVersionToJs(jsi::Runtime &rt, decltype(types.providerVersion) value) {
819
+ return bridging::toJs(rt, value);
820
+ }
821
+
752
822
  static jsi::String replyIdToJs(jsi::Runtime &rt, decltype(types.replyId) value) {
753
823
  return bridging::toJs(rt, value);
754
824
  }
@@ -763,6 +833,7 @@ struct NativeInappRnSdkSessionCreateRequestEventBridging {
763
833
  result.setProperty(rt, "providerId", bridging::toJs(rt, value.providerId, jsInvoker));
764
834
  result.setProperty(rt, "timestamp", bridging::toJs(rt, value.timestamp, jsInvoker));
765
835
  result.setProperty(rt, "signature", bridging::toJs(rt, value.signature, jsInvoker));
836
+ result.setProperty(rt, "providerVersion", bridging::toJs(rt, value.providerVersion, jsInvoker));
766
837
  result.setProperty(rt, "replyId", bridging::toJs(rt, value.replyId, jsInvoker));
767
838
  return result;
768
839
  }
@@ -1102,6 +1173,7 @@ protected:
1102
1173
  public:
1103
1174
  virtual jsi::Value startVerification(jsi::Runtime &rt, jsi::Object request) = 0;
1104
1175
  virtual jsi::Value startVerificationFromUrl(jsi::Runtime &rt, jsi::String requestUrl) = 0;
1176
+ virtual jsi::Value startVerificationFromJson(jsi::Runtime &rt, jsi::String templateJsonString) = 0;
1105
1177
  virtual jsi::Value setOverrides(jsi::Runtime &rt, jsi::Object overrides) = 0;
1106
1178
  virtual jsi::Value clearAllOverrides(jsi::Runtime &rt) = 0;
1107
1179
  virtual jsi::Value setVerificationOptions(jsi::Runtime &rt, jsi::Object args) = 0;
@@ -1208,6 +1280,14 @@ private:
1208
1280
  return bridging::callFromJs<jsi::Value>(
1209
1281
  rt, &T::startVerificationFromUrl, jsInvoker_, instance_, std::move(requestUrl));
1210
1282
  }
1283
+ jsi::Value startVerificationFromJson(jsi::Runtime &rt, jsi::String templateJsonString) override {
1284
+ static_assert(
1285
+ bridging::getParameterCount(&T::startVerificationFromJson) == 2,
1286
+ "Expected startVerificationFromJson(...) to have 2 parameters");
1287
+
1288
+ return bridging::callFromJs<jsi::Value>(
1289
+ rt, &T::startVerificationFromJson, jsInvoker_, instance_, std::move(templateJsonString));
1290
+ }
1211
1291
  jsi::Value setOverrides(jsi::Runtime &rt, jsi::Object overrides) override {
1212
1292
  static_assert(
1213
1293
  bridging::getParameterCount(&T::setOverrides) == 2,
@@ -1,5 +1,6 @@
1
1
  package com.reclaimprotocol.inapp_rn_sdk
2
2
 
3
+ import android.util.JsonReader
3
4
  import android.util.Log
4
5
  import com.facebook.react.bridge.Arguments
5
6
  import com.facebook.react.bridge.Promise
@@ -12,6 +13,7 @@ import org.json.JSONObject
12
13
  import org.reclaimprotocol.inapp_sdk.ReclaimOverrides
13
14
  import org.reclaimprotocol.inapp_sdk.ReclaimSessionStatus
14
15
  import org.reclaimprotocol.inapp_sdk.ReclaimVerification
16
+ import org.reclaimprotocol.inapp_sdk.ReclaimVerification.Request.ProviderVersion
15
17
  import java.util.UUID
16
18
 
17
19
  @ReactModule(name = InappRnSdkModule.NAME)
@@ -86,8 +88,12 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
86
88
  }
87
89
  }
88
90
  }
89
- val acceptAiProviders = getBoolean(request, "acceptAiProviders")
90
- val webhookUrl = getString(request, "webhookUrl")
91
+ val providerVersion = request.getMap("providerVersion").let { providerVersion ->
92
+ ProviderVersion(
93
+ resolvedVersion = getString(providerVersion, "resolvedVersion") ?: "",
94
+ versionExpression = getString(providerVersion, "versionExpression") ?: ""
95
+ )
96
+ }
91
97
  if (appId.isNullOrBlank() && secret.isNullOrBlank()) {
92
98
  verificationRequest = ReclaimVerification.Request.fromManifestMetaData(
93
99
  context = reactContext.applicationContext,
@@ -99,8 +105,7 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
99
105
  signature = getString(session, "signature") ?: "",
100
106
  ),
101
107
  parameters = parameters,
102
- acceptAiProviders = acceptAiProviders ?: false,
103
- webhookUrl = webhookUrl,
108
+ providerVersion = providerVersion,
104
109
  )
105
110
  } else {
106
111
  verificationRequest = ReclaimVerification.Request(
@@ -114,8 +119,7 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
114
119
  signature = getString(session, "signature") ?: "",
115
120
  ),
116
121
  parameters = parameters,
117
- acceptAiProviders = acceptAiProviders ?: false,
118
- webhookUrl = webhookUrl,
122
+ providerVersion = providerVersion,
119
123
  )
120
124
  }
121
125
  ReclaimVerification.startVerification(
@@ -140,6 +144,20 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
140
144
  }
141
145
  }
142
146
 
147
+ override fun startVerificationFromJson(templateJsonString: String, promise: Promise?) {
148
+ Log.d(NAME, "startVerificationFromJson")
149
+ val templateJson = HashMap<Any?, Any?>()
150
+ JSONObject(templateJsonString).toMap().forEach { (key, value) ->
151
+ templateJson[key] = value
152
+ }
153
+ val handler = ReclaimVerificationResultHandlerImpl(promise)
154
+ reactContext.runOnUiQueueThread {
155
+ ReclaimVerification.startVerificationFromJson(
156
+ context = reactContext.applicationContext, template = templateJson, handler = handler
157
+ )
158
+ }
159
+ }
160
+
143
161
  override fun setOverrides(overrides: ReadableMap?, promise: Promise?) {
144
162
  return setOverrides(
145
163
  provider = getMap(overrides, "provider"),
@@ -249,6 +267,7 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
249
267
  sessionId: String,
250
268
  signature: String,
251
269
  timestamp: String,
270
+ resolvedVersion: String,
252
271
  callback: (Result<String>) -> Unit
253
272
  ) {
254
273
  val args = Arguments.createMap()
@@ -257,6 +276,7 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
257
276
  args.putString("sessionId", sessionId)
258
277
  args.putString("signature", signature)
259
278
  args.putString("timestamp", timestamp)
279
+ args.putString("resolvedVersion", resolvedVersion)
260
280
  val replyId = UUID.randomUUID().toString()
261
281
  args.putString("replyId", replyId)
262
282
  replyWithString[replyId] = callback
@@ -276,7 +296,9 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
276
296
  featureOptions, "sessionTimeoutForManualVerificationTrigger"
277
297
  )?.toLong(),
278
298
  attestorBrowserRpcUrl = getString(featureOptions, "attestorBrowserRpcUrl"),
279
- isAIFlowEnabled = getBoolean(featureOptions, "isAIFlowEnabled")
299
+ isAIFlowEnabled = getBoolean(featureOptions, "isAIFlowEnabled"),
300
+ manualReviewMessage = getString(featureOptions, "manualReviewMessage"),
301
+ loginPromptMessage = getString(featureOptions, "loginPromptMessage")
280
302
  ),
281
303
  logConsumer = if (logConsumer == null) null else ReclaimOverrides.LogConsumer(
282
304
  logHandler = if (getBoolean(logConsumer, "enableLogHandler") != true) null else object :
@@ -298,16 +320,31 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
298
320
  providerId: String,
299
321
  timestamp: String,
300
322
  signature: String,
301
- callback: (Result<String>) -> Unit
323
+ providerVersion: String,
324
+ callback: (Result<ReclaimOverrides.SessionManagement.InitResponse>) -> Unit
302
325
  ) {
303
326
  val args = Arguments.createMap()
304
327
  args.putString("appId", appId)
305
328
  args.putString("providerId", providerId)
306
329
  args.putString("timestamp", timestamp)
307
330
  args.putString("signature", signature)
331
+ args.putString("providerVersion", providerVersion)
308
332
  val replyId = UUID.randomUUID().toString()
309
333
  args.putString("replyId", replyId)
310
- replyWithString[replyId] = callback
334
+ replyWithString[replyId] = { it ->
335
+ callback(it.fold(
336
+ onSuccess = { value ->
337
+ val value = JSONObject(value)
338
+ Result.success(ReclaimOverrides.SessionManagement.InitResponse(
339
+ sessionId = value.getString("sessionId"),
340
+ resolvedProviderVersion = value.getString("resolvedProviderVersion")
341
+ ))
342
+ },
343
+ onFailure = { error ->
344
+ Result.failure(error)
345
+ }
346
+ ))
347
+ }
311
348
  emitOnSessionCreateRequest(args)
312
349
  }
313
350
 
@@ -0,0 +1,18 @@
1
+ package com.reclaimprotocol.inapp_rn_sdk
2
+
3
+ import org.json.JSONArray
4
+ import org.json.JSONObject
5
+
6
+ fun JSONObject.toMap(): Map<String, *> = keys().asSequence().associateWith {
7
+ when (val value = this[it])
8
+ {
9
+ is JSONArray ->
10
+ {
11
+ val map = (0 until value.length()).associate { Pair(it.toString(), value[it]) }
12
+ JSONObject(map).toMap().values.toList()
13
+ }
14
+ is JSONObject -> value.toMap()
15
+ JSONObject.NULL -> null
16
+ else -> value
17
+ }
18
+ }