@reclaimprotocol/inapp-rn-sdk 0.18.0 → 0.24.1-alpha.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 (56) hide show
  1. package/InappRnSdk.podspec +4 -27
  2. package/android/build.gradle +8 -59
  3. package/android/src/main/AndroidManifest.xml +1 -2
  4. package/android/src/main/java/com/reclaimprotocol/{inapp_rn_sdk → inapprnsdk}/InappRnSdkModule.kt +138 -70
  5. package/android/src/main/java/com/reclaimprotocol/{inapp_rn_sdk → inapprnsdk}/InappRnSdkPackage.kt +1 -1
  6. package/android/src/main/java/com/reclaimprotocol/{inapp_rn_sdk → inapprnsdk}/JsonExtension.kt +1 -1
  7. package/expo-plugin/src/index.ts +1 -1
  8. package/ios/InappRnSdk-Bridging-Header.h +0 -1
  9. package/ios/InappRnSdk.h +2 -13
  10. package/ios/InappRnSdk.mm +70 -16
  11. package/ios/inapp_rn_sdk/Api.swift +43 -0
  12. package/lib/module/NativeInappRnSdk.js.map +1 -0
  13. package/lib/module/index.js +57 -1
  14. package/lib/module/index.js.map +1 -1
  15. package/lib/typescript/expo-plugin/src/android/index.d.ts +3 -0
  16. package/lib/typescript/expo-plugin/src/android/index.d.ts.map +1 -0
  17. package/lib/typescript/expo-plugin/src/android/withReclaimAndroidManifest.d.ts +3 -0
  18. package/lib/typescript/expo-plugin/src/android/withReclaimAndroidManifest.d.ts.map +1 -0
  19. package/lib/typescript/expo-plugin/src/android/withReclaimProjectBuildGradle.d.ts +3 -0
  20. package/lib/typescript/expo-plugin/src/android/withReclaimProjectBuildGradle.d.ts.map +1 -0
  21. package/lib/typescript/expo-plugin/src/index.d.ts +4 -0
  22. package/lib/typescript/expo-plugin/src/index.d.ts.map +1 -0
  23. package/lib/typescript/package.json +1 -0
  24. package/lib/typescript/{commonjs/src/specs → src}/NativeInappRnSdk.d.ts +18 -9
  25. package/lib/typescript/src/NativeInappRnSdk.d.ts.map +1 -0
  26. package/lib/typescript/{module/src → src}/index.d.ts +17 -1
  27. package/lib/typescript/src/index.d.ts.map +1 -0
  28. package/package.json +84 -128
  29. package/src/{specs/NativeInappRnSdk.ts → NativeInappRnSdk.ts} +19 -9
  30. package/src/{index.ts → index.tsx} +85 -1
  31. package/android/generated/java/com/reclaimprotocol/inapp_rn_sdk/NativeInappRnSdkSpec.java +0 -99
  32. package/android/generated/jni/CMakeLists.txt +0 -36
  33. package/android/generated/jni/RNInappRnSdkSpec-generated.cpp +0 -88
  34. package/android/generated/jni/RNInappRnSdkSpec.h +0 -31
  35. package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI-generated.cpp +0 -85
  36. package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI.h +0 -1348
  37. package/android/src/main/AndroidManifestNew.xml +0 -2
  38. package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec-generated.mm +0 -197
  39. package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec.h +0 -494
  40. package/ios/generated/RNInappRnSdkSpecJSI-generated.cpp +0 -85
  41. package/ios/generated/RNInappRnSdkSpecJSI.h +0 -1348
  42. package/lib/commonjs/index.js +0 -389
  43. package/lib/commonjs/index.js.map +0 -1
  44. package/lib/commonjs/specs/NativeInappRnSdk.js +0 -24
  45. package/lib/commonjs/specs/NativeInappRnSdk.js.map +0 -1
  46. package/lib/module/specs/NativeInappRnSdk.js.map +0 -1
  47. package/lib/typescript/commonjs/package.json +0 -1
  48. package/lib/typescript/commonjs/src/index.d.ts +0 -192
  49. package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
  50. package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts.map +0 -1
  51. package/lib/typescript/module/src/index.d.ts.map +0 -1
  52. package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts +0 -345
  53. package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts.map +0 -1
  54. package/react-native.config.js +0 -12
  55. /package/lib/module/{specs/NativeInappRnSdk.js → NativeInappRnSdk.js} +0 -0
  56. /package/lib/{typescript/module → module}/package.json +0 -0
@@ -1,7 +1,6 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
4
 
6
5
  Pod::Spec.new do |s|
7
6
  s.name = "InappRnSdk"
@@ -11,34 +10,12 @@ Pod::Spec.new do |s|
11
10
  s.license = package["license"]
12
11
  s.authors = package["author"]
13
12
 
14
- # Try documentation/migration.md before updating this file. SDK supports iOS 13.0 and above.
15
13
  s.platforms = { :ios => min_ios_version_supported }
16
14
  s.source = { :git => "https://github.com/reclaimprotocol/reclaim-inapp-reactnative-sdk.git", :tag => "#{s.version}" }
17
15
 
18
- s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
19
- s.private_header_files = "ios/generated/**/*.h"
20
- s.dependency "ReclaimInAppSdk", "~> 0.18.0"
16
+ s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
17
+ s.private_header_files = "ios/**/*.h"
18
+ s.dependency "ReclaimInAppSdk", "~> 0.24.0"
21
19
 
22
- # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
23
- # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
24
- if respond_to?(:install_modules_dependencies, true)
25
- install_modules_dependencies(s)
26
- else
27
- s.dependency "React-Core"
28
-
29
- # Don't install the dependencies when we run `pod install` in the old architecture.
30
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
31
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
32
- s.pod_target_xcconfig = {
33
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
34
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
35
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
36
- }
37
- s.dependency "React-Codegen"
38
- s.dependency "RCT-Folly"
39
- s.dependency "RCTRequired"
40
- s.dependency "RCTTypeSafety"
41
- s.dependency "ReactCommon/turbomodule/core"
42
- end
43
- end
20
+ install_modules_dependencies(s)
44
21
  end
@@ -2,17 +2,10 @@ buildscript {
2
2
  ext.getExtOrDefault = {name ->
3
3
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['InappRnSdk_' + name]
4
4
  }
5
- String flutterStorageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"
6
- String reclaimStorageUrl = System.env.RECLAIM_STORAGE_BASE_URL ?: "https://reclaim-inapp-sdk.s3.ap-south-1.amazonaws.com/android/repo"
5
+
7
6
  repositories {
8
7
  google()
9
8
  mavenCentral()
10
- maven {
11
- url "$reclaimStorageUrl"
12
- }
13
- maven {
14
- url "$flutterStorageUrl/download.flutter.io"
15
- }
16
9
  }
17
10
 
18
11
  dependencies {
@@ -23,47 +16,23 @@ buildscript {
23
16
  }
24
17
 
25
18
 
26
- def isNewArchitectureEnabled() {
27
- return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
28
- }
29
-
30
19
  apply plugin: "com.android.library"
31
20
  apply plugin: "kotlin-android"
32
21
 
33
- if (isNewArchitectureEnabled()) {
34
- apply plugin: "com.facebook.react"
35
- }
22
+ apply plugin: "com.facebook.react"
36
23
 
37
24
  def getExtOrIntegerDefault(name) {
38
25
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["InappRnSdk_" + name]).toInteger()
39
26
  }
40
27
 
41
- def supportsNamespace() {
42
- def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
43
- def major = parsed[0].toInteger()
44
- def minor = parsed[1].toInteger()
45
-
46
- // Namespace support was added in 7.3.0
47
- return (major == 7 && minor >= 3) || major >= 8
48
- }
49
-
50
28
  android {
51
- if (supportsNamespace()) {
52
- namespace "com.reclaimprotocol.inapp_rn_sdk"
53
-
54
- sourceSets {
55
- main {
56
- manifest.srcFile "src/main/AndroidManifestNew.xml"
57
- }
58
- }
59
- }
29
+ namespace "com.reclaimprotocol.inapprnsdk"
60
30
 
61
31
  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
62
32
 
63
33
  defaultConfig {
64
34
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
65
35
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
66
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
67
36
  }
68
37
 
69
38
  buildFeatures {
@@ -87,28 +56,17 @@ android {
87
56
 
88
57
  sourceSets {
89
58
  main {
90
- if (isNewArchitectureEnabled()) {
91
- java.srcDirs += [
92
- "generated/java",
93
- "generated/jni"
94
- ]
95
- }
59
+ java.srcDirs += [
60
+ "generated/java",
61
+ "generated/jni"
62
+ ]
96
63
  }
97
64
  }
98
65
  }
99
66
 
100
- String flutterStorageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?: "https://storage.googleapis.com"
101
- String reclaimStorageUrl = System.env.RECLAIM_STORAGE_BASE_URL ?: "https://reclaim-inapp-sdk.s3.ap-south-1.amazonaws.com/android/repo"
102
-
103
67
  repositories {
104
68
  mavenCentral()
105
69
  google()
106
- maven {
107
- url "$reclaimStorageUrl"
108
- }
109
- maven {
110
- url "$flutterStorageUrl/download.flutter.io"
111
- }
112
70
  }
113
71
 
114
72
  def kotlin_version = getExtOrDefault("kotlinVersion")
@@ -117,14 +75,5 @@ dependencies {
117
75
  implementation "com.facebook.react:react-android"
118
76
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
119
77
 
120
- //noinspection UseTomlInstead
121
- implementation "org.reclaimprotocol:inapp_sdk:0.18.0"
122
- }
123
-
124
- if (isNewArchitectureEnabled()) {
125
- react {
126
- jsRootDir = file("../src/")
127
- libraryName = "InappRnSdk"
128
- codegenJavaPackageName = "com.reclaimprotocol.inapp_rn_sdk"
129
- }
78
+ implementation "org.reclaimprotocol:inapp_sdk:0.24.0"
130
79
  }
@@ -1,3 +1,2 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.reclaimprotocol.inapp_rn_sdk">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
2
  </manifest>
@@ -1,6 +1,5 @@
1
- package com.reclaimprotocol.inapp_rn_sdk
1
+ package com.reclaimprotocol.inapprnsdk
2
2
 
3
- import android.util.JsonReader
4
3
  import android.util.Log
5
4
  import com.facebook.react.bridge.Arguments
6
5
  import com.facebook.react.bridge.Promise
@@ -183,26 +182,33 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
183
182
 
184
183
  override fun setVerificationOptions(args: ReadableMap?, promise: Promise?) {
185
184
  val inputOptions = getMap(args, "options")
186
- var options: ReclaimVerification.VerificationOptions? = null
185
+ var options: ReclaimVerification.VerificationOptions? = null
187
186
  if (inputOptions != null) {
188
- val canUseAttestorAuthRequestProvider = getBoolean(inputOptions, "canUseAttestorAuthenticationRequest") == true;
189
- val claimCreationType: ReclaimVerification.VerificationOptions.ClaimCreationType = when (getString(inputOptions, "claimCreationType")) {
190
- "meChain" -> ReclaimVerification.VerificationOptions.ClaimCreationType.ME_CHAIN
191
- else -> ReclaimVerification.VerificationOptions.ClaimCreationType.STANDALONE
187
+ val canUseAttestorAuthRequestProvider =
188
+ getBoolean(inputOptions, "canUseAttestorAuthenticationRequest") == true
189
+ val claimCreationType: ReclaimVerification.VerificationOptions.ClaimCreationType =
190
+ when (getString(inputOptions, "claimCreationType")) {
191
+ "meChain" -> ReclaimVerification.VerificationOptions.ClaimCreationType.ME_CHAIN
192
+ else -> ReclaimVerification.VerificationOptions.ClaimCreationType.STANDALONE
192
193
 
193
- }
194
+ }
194
195
  val canAutoSubmit = getBoolean(inputOptions, "canAutoSubmit") ?: true
195
196
  val isCloseButtonVisible = getBoolean(inputOptions, "isCloseButtonVisible") ?: true
196
197
  options = ReclaimVerification.VerificationOptions(
197
- canDeleteCookiesBeforeVerificationStarts = getBoolean(inputOptions, "canDeleteCookiesBeforeVerificationStarts") ?: true,
198
+ canDeleteCookiesBeforeVerificationStarts = getBoolean(
199
+ inputOptions,
200
+ "canDeleteCookiesBeforeVerificationStarts"
201
+ ) ?: true,
198
202
  attestorAuthRequestProvider = if (canUseAttestorAuthRequestProvider) {
199
203
  object : ReclaimVerification.VerificationOptions.AttestorAuthRequestProvider {
200
204
  override fun fetchAttestorAuthenticationRequest(
201
- reclaimHttpProvider: Map<Any?, Any?>,
202
- callback: (Result<String>) -> Unit
205
+ reclaimHttpProvider: Map<Any?, Any?>, callback: (Result<String>) -> Unit
203
206
  ) {
204
207
  val args = Arguments.createMap()
205
- args.putString("reclaimHttpProviderJsonString", JSONObject(reclaimHttpProvider).toString())
208
+ args.putString(
209
+ "reclaimHttpProviderJsonString",
210
+ JSONObject(reclaimHttpProvider).toString()
211
+ )
206
212
  val replyId = UUID.randomUUID().toString()
207
213
  args.putString("replyId", replyId)
208
214
  replyWithString[replyId] = callback
@@ -214,13 +220,29 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
214
220
  },
215
221
  claimCreationType = claimCreationType,
216
222
  canAutoSubmit = canAutoSubmit,
217
- isCloseButtonVisible = isCloseButtonVisible
218
- )
223
+ isCloseButtonVisible = isCloseButtonVisible)
219
224
  }
220
225
  reactContext.runOnUiQueueThread {
221
226
  ReclaimVerification.setVerificationOptions(
222
- context = reactContext.applicationContext,
223
- options = options
227
+ context = reactContext.applicationContext, options = options
228
+ ) { result ->
229
+ result.onSuccess {
230
+ promise?.resolve(null)
231
+ }.onFailure { error ->
232
+ onPlatformException(promise, error)
233
+ }
234
+ }
235
+ }
236
+ }
237
+
238
+ override fun setConsoleLogging(
239
+ args: ReadableMap?, promise: Promise?
240
+ ) {
241
+ val enabled = if (args != null) (getBoolean(args, "enabled") == true) else false
242
+
243
+ reactContext.runOnUiQueueThread {
244
+ ReclaimVerification.setConsoleLogging(
245
+ context = reactContext.applicationContext, enabled = enabled
224
246
  ) { result ->
225
247
  result.onSuccess {
226
248
  promise?.resolve(null)
@@ -243,46 +265,49 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
243
265
  reactContext.runOnUiQueueThread {
244
266
  ReclaimVerification.setOverrides(
245
267
  context = reactContext.applicationContext,
246
- provider = if (provider == null) null else (
247
- if (hasValue(provider, "jsonString"))
248
- ReclaimOverrides.ProviderInformation.FromJsonString(
249
- requireString(
250
- provider, "jsonString"
251
- )
252
- )
253
- else if (hasValue(provider, "url"))
254
- ReclaimOverrides.ProviderInformation.FromUrl(
255
- requireString(
256
- provider, "url"
257
- )
258
- )
259
- else if (getBoolean(provider, "canFetchProviderInformationFromHost") == true)
260
- ReclaimOverrides.ProviderInformation.FromCallback(object : ReclaimOverrides.ProviderInformation.FromCallback.Handler {
261
- override fun fetchProviderInformation(
262
- appId: String,
263
- providerId: String,
264
- sessionId: String,
265
- signature: String,
266
- timestamp: String,
267
- resolvedVersion: String,
268
- callback: (Result<String>) -> Unit
269
- ) {
270
- val args = Arguments.createMap()
271
- args.putString("appId", appId)
272
- args.putString("providerId", providerId)
273
- args.putString("sessionId", sessionId)
274
- args.putString("signature", signature)
275
- args.putString("timestamp", timestamp)
276
- args.putString("resolvedVersion", resolvedVersion)
277
- val replyId = UUID.randomUUID().toString()
278
- args.putString("replyId", replyId)
279
- replyWithString[replyId] = callback
280
- emitOnProviderInformationRequest(args)
281
- }
282
- })
283
- else
284
- (throw IllegalStateException("Invalid provider information. canFetchProviderInformationFromHost was not true and jsonString, url were also not provided."))
285
- ),
268
+ provider = if (provider == null) null else (if (hasValue(
269
+ provider,
270
+ "jsonString"
271
+ )
272
+ ) ReclaimOverrides.ProviderInformation.FromJsonString(
273
+ requireString(
274
+ provider, "jsonString"
275
+ )
276
+ )
277
+ else if (hasValue(provider, "url")) ReclaimOverrides.ProviderInformation.FromUrl(
278
+ requireString(
279
+ provider, "url"
280
+ )
281
+ )
282
+ else if (getBoolean(
283
+ provider,
284
+ "canFetchProviderInformationFromHost"
285
+ ) == true
286
+ ) ReclaimOverrides.ProviderInformation.FromCallback(object :
287
+ ReclaimOverrides.ProviderInformation.FromCallback.Handler {
288
+ override fun fetchProviderInformation(
289
+ appId: String,
290
+ providerId: String,
291
+ sessionId: String,
292
+ signature: String,
293
+ timestamp: String,
294
+ resolvedVersion: String,
295
+ callback: (Result<String>) -> Unit
296
+ ) {
297
+ val args = Arguments.createMap()
298
+ args.putString("appId", appId)
299
+ args.putString("providerId", providerId)
300
+ args.putString("sessionId", sessionId)
301
+ args.putString("signature", signature)
302
+ args.putString("timestamp", timestamp)
303
+ args.putString("resolvedVersion", resolvedVersion)
304
+ val replyId = UUID.randomUUID().toString()
305
+ args.putString("replyId", replyId)
306
+ replyWithString[replyId] = callback
307
+ emitOnProviderInformationRequest(args)
308
+ }
309
+ })
310
+ else (throw IllegalStateException("Invalid provider information. canFetchProviderInformationFromHost was not true and jsonString, url were also not provided."))),
286
311
  featureOptions = if (featureOptions == null) null else ReclaimOverrides.FeatureOptions(
287
312
  cookiePersist = getBoolean(featureOptions, "cookiePersist"),
288
313
  singleReclaimRequest = getBoolean(featureOptions, "singleReclaimRequest"),
@@ -329,24 +354,27 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
329
354
  val replyId = UUID.randomUUID().toString()
330
355
  args.putString("replyId", replyId)
331
356
  replyWithString[replyId] = { it ->
332
- callback(it.fold(
333
- onSuccess = { value ->
334
- val value = JSONObject(value)
335
- Result.success(ReclaimOverrides.SessionManagement.InitResponse(
357
+ callback(it.fold(onSuccess = { value ->
358
+ val value = JSONObject(value)
359
+ Result.success(
360
+ ReclaimOverrides.SessionManagement.InitResponse(
336
361
  sessionId = value.getString("sessionId"),
337
362
  resolvedProviderVersion = value.getString("resolvedProviderVersion")
338
- ))
339
- },
340
- onFailure = { error ->
341
- Result.failure(error)
342
- }
343
- ))
363
+ )
364
+ )
365
+ }, onFailure = { error ->
366
+ Result.failure(error)
367
+ }))
344
368
  }
345
369
  emitOnSessionCreateRequest(args)
346
370
  }
347
371
 
348
372
  override fun logSession(
349
- appId: String, providerId: String, sessionId: String, logType: String, metadata: Map<String, Any?>?
373
+ appId: String,
374
+ providerId: String,
375
+ sessionId: String,
376
+ logType: String,
377
+ metadata: Map<String, Any?>?
350
378
  ) {
351
379
  val args = Arguments.createMap()
352
380
  args.putString("appId", appId)
@@ -386,7 +414,7 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
386
414
 
387
415
  }.onFailure { error ->
388
416
  try {
389
- Log.d(NAME, "(setOverrides) Failure")
417
+ Log.d(NAME, "(setOverrides) Failure", error)
390
418
  onPlatformException(promise, error)
391
419
  } catch (e: Throwable) {
392
420
  Log.e(NAME, "(setOverrides) Error rejecting promise", e)
@@ -396,6 +424,47 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
396
424
  }
397
425
  }
398
426
 
427
+ override fun startEventSubscription(event: String?) {
428
+ when (event) {
429
+ "sessionIdentityUpdate" -> {
430
+ reactContext.runOnUiQueueThread {
431
+ ReclaimVerification.setOverrides(
432
+ context = reactContext.applicationContext,
433
+ provider = null,
434
+ featureOptions = null,
435
+ logConsumer = null,
436
+ sessionManagement = null,
437
+ appInfo = null,
438
+ capabilityAccessToken = null,
439
+ sessionIdentityUpdateHandler = object : ReclaimOverrides.SessionIdentityUpdateHandler {
440
+ override fun onSessionIdentityUpdate(identity: ReclaimVerification.ReclaimSessionIdentity) {
441
+ val map = Arguments.createMap()
442
+ map.putString("appId", identity.appId)
443
+ map.putString("providerId", identity.providerId)
444
+ map.putString("sessionId", identity.sessionId)
445
+ emitOnSessionIdentityUpdate(map)
446
+ }
447
+ },
448
+ ) { result ->
449
+ result.onSuccess {
450
+ Log.d(NAME, "(startEventSubscription:sessionIdentityUpdate) Success")
451
+ }.onFailure { error ->
452
+ Log.d(NAME, "(startEventSubscription:sessionIdentityUpdate) Failure", error)
453
+ }
454
+ }
455
+ }
456
+ }
457
+
458
+ else -> {
459
+ Log.w(NAME, "(startEventSubscription) Unknown event subscription requested: $event")
460
+ }
461
+ }
462
+ }
463
+
464
+ override fun removeEventSubscription(event: String?) {
465
+ // do nothing for now, clearOverrides clear everything atm.
466
+ }
467
+
399
468
  private val replyHandlers: MutableMap<String, (Result<Boolean>) -> Unit> = mutableMapOf()
400
469
  override fun reply(replyId: String?, reply: Boolean) {
401
470
  if (replyId == null) {
@@ -412,8 +481,7 @@ class InappRnSdkModule(private val reactContext: ReactApplicationContext) :
412
481
  }
413
482
  }
414
483
 
415
- private val replyWithString: MutableMap<String, (Result<String>) -> Unit> =
416
- mutableMapOf()
484
+ private val replyWithString: MutableMap<String, (Result<String>) -> Unit> = mutableMapOf()
417
485
 
418
486
  override fun replyWithString(replyId: String?, value: String?) {
419
487
  if (replyId == null) {
@@ -1,4 +1,4 @@
1
- package com.reclaimprotocol.inapp_rn_sdk
1
+ package com.reclaimprotocol.inapprnsdk
2
2
 
3
3
  import com.facebook.react.BaseReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
@@ -1,4 +1,4 @@
1
- package com.reclaimprotocol.inapp_rn_sdk
1
+ package com.reclaimprotocol.inapprnsdk
2
2
 
3
3
  import org.json.JSONArray
4
4
  import org.json.JSONObject
@@ -1,4 +1,4 @@
1
- import { type ConfigPlugin, createRunOncePlugin, withPlugins } from '@expo/config-plugins';
1
+ import { type ConfigPlugin, withPlugins } from '@expo/config-plugins';
2
2
  import {
3
3
  withReclaimAndroidManifest,
4
4
  withReclaimProjectBuildGradle,
@@ -1 +0,0 @@
1
-
package/ios/InappRnSdk.h CHANGED
@@ -1,17 +1,6 @@
1
- #ifdef RCT_NEW_ARCH_ENABLED
2
- #import "generated/RNInappRnSdkSpec/RNInappRnSdkSpec.h"
3
-
4
- NS_ASSUME_NONNULL_BEGIN
1
+ #import <Foundation/Foundation.h>
2
+ #import <InappRnSdkSpec/InappRnSdkSpec.h>
5
3
 
6
4
  @interface InappRnSdk : NativeInappRnSdkSpecBase <NativeInappRnSdkSpec>
7
5
 
8
- NS_ASSUME_NONNULL_END
9
-
10
- #else
11
- #import <React/RCTBridgeModule.h>
12
-
13
- @interface InappRnSdk : NSObject <RCTBridgeModule>
14
- #endif
15
-
16
-
17
6
  @end
package/ios/InappRnSdk.mm CHANGED
@@ -11,13 +11,16 @@
11
11
  #endif
12
12
 
13
13
  @implementation InappRnSdk
14
- RCT_EXPORT_MODULE()
15
14
 
16
15
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
17
16
  (const facebook::react::ObjCTurboModule::InitParams &)params {
18
17
  return std::make_shared<facebook::react::NativeInappRnSdkSpecJSI>(params);
19
18
  }
20
19
 
20
+ + (NSString *)moduleName {
21
+ return @"InappRnSdk";
22
+ }
23
+
21
24
  Api *api = [[Api alloc] init];
22
25
 
23
26
  - (void)ping:(nonnull RCTPromiseResolveBlock)resolve
@@ -132,22 +135,24 @@ Api *api = [[Api alloc] init];
132
135
  }];
133
136
  }
134
137
 
135
- - (void)startVerificationFromJson:(nonnull NSString *)templateJsonString resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
138
+ - (void)startVerificationFromJson:(nonnull NSString *)templateJsonString
139
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
140
+ reject:(nonnull RCTPromiseRejectBlock)reject {
136
141
  NSLog(@"[InappRnSdk] starting verification");
137
142
 
138
143
  NSLog(@"[InappRnSdk] starting verification now");
139
144
  [api startVerificationFromJsonWithTemplate:templateJsonString
140
- completionHandler:^(
141
- NSDictionary<NSString *, id> *_Nullable result,
142
- NSError *_Nullable error) {
143
- if (error != nil) {
144
- NSLog(@"[InappRnSdk] Api Error: %@", error);
145
- reject(@"VERIFICATION_ERROR", @"Verification Error",
146
- error);
147
- } else {
148
- resolve(result);
149
- }
150
- }];
145
+ completionHandler:^(
146
+ NSDictionary<NSString *, id> *_Nullable result,
147
+ NSError *_Nullable error) {
148
+ if (error != nil) {
149
+ NSLog(@"[InappRnSdk] Api Error: %@", error);
150
+ reject(@"VERIFICATION_ERROR",
151
+ @"Verification Error", error);
152
+ } else {
153
+ resolve(result);
154
+ }
155
+ }];
151
156
  }
152
157
 
153
158
  - (void)setOverrides:(JS::NativeInappRnSdk::Overrides &)overrides
@@ -175,14 +180,16 @@ Api *api = [[Api alloc] init];
175
180
  initWith_fetchProviderInformation:^(
176
181
  NSString *_Nonnull appId, NSString *_Nonnull providerId,
177
182
  NSString *_Nonnull sessionId, NSString *_Nonnull signature,
178
- NSString *_Nonnull timestamp, NSString *_Nonnull resolvedVersion, NSString *_Nonnull replyId) {
183
+ NSString *_Nonnull timestamp,
184
+ NSString *_Nonnull resolvedVersion,
185
+ NSString *_Nonnull replyId) {
179
186
  [self emitOnProviderInformationRequest:@{
180
187
  @"appId" : appId,
181
188
  @"providerId" : providerId,
182
189
  @"sessionId" : sessionId,
183
190
  @"signature" : signature,
184
191
  @"timestamp" : timestamp,
185
- @"resolvedVersion": resolvedVersion,
192
+ @"resolvedVersion" : resolvedVersion,
186
193
  @"replyId" : replyId
187
194
  }];
188
195
  }];
@@ -285,7 +292,7 @@ Api *api = [[Api alloc] init];
285
292
  @"providerId" : providerId,
286
293
  @"timestamp" : timestamp,
287
294
  @"signature" : signature,
288
- @"providerVersion": providerVersion,
295
+ @"providerVersion" : providerVersion,
289
296
  @"replyId" : replyId
290
297
  }];
291
298
  }
@@ -408,4 +415,51 @@ Api *api = [[Api alloc] init];
408
415
  }];
409
416
  }
410
417
 
418
+ - (void)setConsoleLogging:(JS::NativeInappRnSdk::SetConsoleLoggingOptions &)args
419
+ resolve:(nonnull RCTPromiseResolveBlock)resolve
420
+ reject:(nonnull RCTPromiseRejectBlock)reject {
421
+ [api setConsoleLoggingWithEnabled:args.enabled()
422
+ completionHandler:^(NSError *_Nullable error) {
423
+ if (error != nil) {
424
+ reject(@"SET_CONSOLE_LOGGING",
425
+ @"Error on setting console logging", error);
426
+ } else {
427
+ resolve(nil);
428
+ }
429
+ }];
430
+ }
431
+
432
+ - (void)startEventSubscription:(nonnull NSString *)event {
433
+ if ([event isEqualToString:@"sessionIdentityUpdate"]) {
434
+ OverridenSessionIdentityUpdateHandler *_Nonnull handler =
435
+ [[OverridenSessionIdentityUpdateHandler alloc]
436
+ initWithHandler:^(NSString *_Nullable appId,
437
+ NSString *_Nullable providerId,
438
+ NSString *_Nullable sessionId) {
439
+ [self emitOnSessionIdentityUpdate:@{
440
+ @"appId" : appId,
441
+ @"providerId" : providerId,
442
+ @"sessionId" : sessionId
443
+ }];
444
+ }];
445
+
446
+ [api startSessionIdentityEventListenerWithListener:handler
447
+ completionHandler:^(
448
+ NSError *_Nullable error) {
449
+ if (error != nil) {
450
+ NSLog(@"[InappRnSdk] Api Error: %@",
451
+ error);
452
+ }
453
+ }];
454
+ } else {
455
+ NSLog(@"[InAppRnSdk] Unknown event subscription requested: %@", event);
456
+ }
457
+ }
458
+
459
+ - (void)removeEventSubscription:(nonnull NSString *)event {
460
+ if ([event isEqualToString:@"sessionIdentityUpdate"]) {
461
+ // do nothing for now, clearOverrides clear everything atm.
462
+ }
463
+ }
464
+
411
465
  @end