@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.
- package/InappRnSdk.podspec +1 -1
- package/README.md +8 -6
- package/android/build.gradle +1 -1
- package/android/generated/java/com/reclaimprotocol/inapp_rn_sdk/NativeInappRnSdkSpec.java +4 -0
- package/android/generated/jni/RNInappRnSdkSpec-generated.cpp +6 -0
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI-generated.cpp +7 -0
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI.h +105 -25
- package/android/src/main/java/com/reclaimprotocol/inapp_rn_sdk/InappRnSdkModule.kt +46 -9
- package/android/src/main/java/com/reclaimprotocol/inapp_rn_sdk/JsonExtension.kt +18 -0
- package/ios/InappRnSdk.mm +267 -138
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec-generated.mm +13 -0
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec.h +45 -10
- package/ios/generated/RNInappRnSdkSpecJSI-generated.cpp +7 -0
- package/ios/generated/RNInappRnSdkSpecJSI.h +105 -25
- package/ios/inapp_rn_sdk/Api.swift +322 -154
- package/lib/commonjs/index.js +36 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeInappRnSdk.js.map +1 -1
- package/lib/module/index.js +36 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeInappRnSdk.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +18 -2
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts +23 -2
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts.map +1 -1
- package/lib/typescript/commonjs/user-workspace/src/App.d.ts +2 -0
- package/lib/typescript/commonjs/user-workspace/src/App.d.ts.map +1 -0
- package/lib/typescript/commonjs/user-workspace/src/App.overrides.d.ts +2 -0
- package/lib/typescript/commonjs/user-workspace/src/App.overrides.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +18 -2
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts +23 -2
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts.map +1 -1
- package/lib/typescript/module/user-workspace/src/App.d.ts +2 -0
- package/lib/typescript/module/user-workspace/src/App.d.ts.map +1 -0
- package/lib/typescript/module/user-workspace/src/App.overrides.d.ts +2 -0
- package/lib/typescript/module/user-workspace/src/App.overrides.d.ts.map +1 -0
- package/package.json +8 -7
- package/src/index.ts +59 -3
- package/src/specs/NativeInappRnSdk.ts +25 -2
|
@@ -4,10 +4,10 @@ import ReclaimInAppSdk
|
|
|
4
4
|
@objc public func ping() -> Bool {
|
|
5
5
|
return true
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
@MainActor
|
|
9
9
|
static fileprivate var replyHandlers: [String: (Result<Bool, any Error>) -> Void] = [:]
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
static fileprivate func setReplyCallback(
|
|
12
12
|
_ callback: @escaping (Result<Bool, any Error>) -> Void
|
|
13
13
|
) -> String {
|
|
@@ -17,7 +17,7 @@ import ReclaimInAppSdk
|
|
|
17
17
|
}
|
|
18
18
|
return replyId
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
@objc public func reply(replyId: String?, reply: Bool) {
|
|
22
22
|
if let replyId {
|
|
23
23
|
Task { @MainActor in
|
|
@@ -33,10 +33,10 @@ import ReclaimInAppSdk
|
|
|
33
33
|
NSLog("[Api.reply] Missing arg replyId")
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
@MainActor
|
|
38
38
|
static fileprivate var replyWithStringHandler: [String: (Result<String, any Error>) -> Void] = [:]
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
static fileprivate func setReplyWithStringCallback(
|
|
41
41
|
_ callback: @escaping (Result<String, any Error>) -> Void
|
|
42
42
|
) -> String {
|
|
@@ -46,7 +46,7 @@ import ReclaimInAppSdk
|
|
|
46
46
|
}
|
|
47
47
|
return replyId
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
@objc public func replyWithString(replyId: String?, value: String?) {
|
|
51
51
|
if let replyId {
|
|
52
52
|
Task { @MainActor in
|
|
@@ -55,14 +55,16 @@ import ReclaimInAppSdk
|
|
|
55
55
|
Api.replyWithStringHandler.removeValue(forKey: replyId)
|
|
56
56
|
callback(.success(value ?? ""))
|
|
57
57
|
} else {
|
|
58
|
-
NSLog(
|
|
58
|
+
NSLog(
|
|
59
|
+
"[Api.replyWithString] No callback found for replyId \(replyId)"
|
|
60
|
+
)
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
} else {
|
|
62
64
|
NSLog("[Api.replyWithString] Missing arg replyId")
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
|
|
66
68
|
@objc public func startVerification(
|
|
67
69
|
appId: String?,
|
|
68
70
|
secret: String?,
|
|
@@ -72,47 +74,59 @@ import ReclaimInAppSdk
|
|
|
72
74
|
sessionSignature: String?,
|
|
73
75
|
context: String?,
|
|
74
76
|
parameters: [String: String]?,
|
|
75
|
-
|
|
76
|
-
webhookUrl: String?
|
|
77
|
+
providerVersion: [String: String]?
|
|
77
78
|
) async throws -> [String: Any] {
|
|
78
79
|
var session: ReclaimSessionInformation? = nil
|
|
79
|
-
if let sessionTimestamp = sessionTimestamp,
|
|
80
|
+
if let sessionTimestamp = sessionTimestamp,
|
|
81
|
+
let sessionSessionId = sessionSessionId,
|
|
82
|
+
let sessionSignature = sessionSignature
|
|
83
|
+
{
|
|
80
84
|
session = .init(
|
|
81
85
|
timestamp: sessionTimestamp,
|
|
82
86
|
sessionId: sessionSessionId,
|
|
83
87
|
signature: sessionSignature
|
|
84
88
|
)
|
|
85
89
|
}
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
let providerVersion = ReclaimVerification.Request.Params.ProviderVersion(
|
|
91
|
+
exactVersion: providerVersion?["resolvedVersion"] ?? "",
|
|
92
|
+
versionExpression: providerVersion?["versionExpression"]
|
|
93
|
+
?? providerVersion?["resolvedVersion"] ?? ""
|
|
94
|
+
)
|
|
95
|
+
var request: ReclaimVerification.Request? = nil
|
|
96
|
+
if let appId = appId, let secret = secret,
|
|
97
|
+
!appId.isEmpty && !secret.isEmpty
|
|
98
|
+
{
|
|
99
|
+
request = .params(
|
|
100
|
+
.init(
|
|
101
|
+
appId: appId,
|
|
102
|
+
secret: secret,
|
|
103
|
+
providerId: providerId,
|
|
104
|
+
session: session,
|
|
105
|
+
context: context ?? "",
|
|
106
|
+
parameters: parameters ?? [String: String](),
|
|
107
|
+
providerVersion: providerVersion
|
|
108
|
+
)
|
|
109
|
+
)
|
|
97
110
|
} else {
|
|
98
|
-
.params(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
request = .params(
|
|
112
|
+
try .init(
|
|
113
|
+
providerId: providerId,
|
|
114
|
+
session: session,
|
|
115
|
+
context: context ?? "",
|
|
116
|
+
parameters: parameters ?? [String: String](),
|
|
117
|
+
providerVersion: providerVersion
|
|
118
|
+
)
|
|
119
|
+
)
|
|
106
120
|
}
|
|
107
|
-
return try await startVerificationWithRequest(request)
|
|
121
|
+
return try await startVerificationWithRequest(request!)
|
|
108
122
|
}
|
|
109
|
-
|
|
123
|
+
|
|
110
124
|
@objc public func startVerificationFromUrl(
|
|
111
125
|
url: String
|
|
112
126
|
) async throws -> [String: Any] {
|
|
113
127
|
return try await startVerificationWithRequest(.url(url))
|
|
114
128
|
}
|
|
115
|
-
|
|
129
|
+
|
|
116
130
|
@objc public func setOverrides(
|
|
117
131
|
provider: OverridenProviderInformation?,
|
|
118
132
|
featureOptions: OverridenFeatureOptions?,
|
|
@@ -121,55 +135,64 @@ import ReclaimInAppSdk
|
|
|
121
135
|
appInfo: OverridenReclaimAppInfo?,
|
|
122
136
|
capabilityAccessToken: String?
|
|
123
137
|
) async throws {
|
|
124
|
-
|
|
125
|
-
|
|
138
|
+
var providerOverrides: ReclaimOverrides.ProviderInformation? = nil
|
|
139
|
+
if let url = provider?.url {
|
|
140
|
+
providerOverrides = .url(url: url)
|
|
126
141
|
} else if let jsonString = provider?.jsonString {
|
|
127
|
-
.jsonString(jsonString: jsonString)
|
|
142
|
+
providerOverrides = .jsonString(jsonString: jsonString)
|
|
128
143
|
} else if let callback = provider?.callback {
|
|
129
|
-
.callback(callbackHandler: callback)
|
|
144
|
+
providerOverrides = .callback(callbackHandler: callback)
|
|
130
145
|
} else {
|
|
131
|
-
nil
|
|
146
|
+
providerOverrides = nil
|
|
132
147
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
148
|
+
|
|
149
|
+
var featureOptionsOverrides: ReclaimOverrides.FeatureOptions? = nil
|
|
150
|
+
if let featureOptions {
|
|
151
|
+
featureOptionsOverrides = .init(
|
|
136
152
|
cookiePersist: featureOptions.cookiePersist?.boolValue,
|
|
137
153
|
singleReclaimRequest: featureOptions.singleReclaimRequest?.boolValue,
|
|
138
|
-
idleTimeThresholdForManualVerificationTrigger: featureOptions
|
|
139
|
-
|
|
154
|
+
idleTimeThresholdForManualVerificationTrigger: featureOptions
|
|
155
|
+
.idleTimeThresholdForManualVerificationTrigger?.int64Value,
|
|
156
|
+
sessionTimeoutForManualVerificationTrigger: featureOptions
|
|
157
|
+
.sessionTimeoutForManualVerificationTrigger?.int64Value,
|
|
140
158
|
attestorBrowserRpcUrl: featureOptions.attestorBrowserRpcUrl,
|
|
141
|
-
isAIFlowEnabled: featureOptions.isAIFlowEnabled?.boolValue
|
|
159
|
+
isAIFlowEnabled: featureOptions.isAIFlowEnabled?.boolValue,
|
|
160
|
+
manualReviewMessage: featureOptions.manualReviewMessage,
|
|
161
|
+
loginPromptMessage: featureOptions.loginPromptMessage
|
|
142
162
|
)
|
|
143
163
|
} else {
|
|
144
|
-
nil
|
|
164
|
+
featureOptionsOverrides = nil
|
|
145
165
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
|
|
167
|
+
var logConsumerOverrides: ReclaimOverrides.LogConsumer? = nil
|
|
168
|
+
if let logConsumer = logConsumer {
|
|
169
|
+
logConsumerOverrides = .init(
|
|
149
170
|
logHandler: logConsumer.logHandler,
|
|
150
171
|
canSdkCollectTelemetry: logConsumer.canSdkCollectTelemetry,
|
|
151
172
|
canSdkPrintLogs: logConsumer.canSdkPrintLogs?.boolValue
|
|
152
173
|
)
|
|
153
174
|
} else {
|
|
154
|
-
nil
|
|
175
|
+
logConsumerOverrides = nil
|
|
155
176
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
177
|
+
|
|
178
|
+
var sessionManagementOverrides: ReclaimOverrides.SessionManagement? = nil
|
|
179
|
+
if let sessionManagement = sessionManagement {
|
|
180
|
+
sessionManagementOverrides = .init(handler: sessionManagement.handler)
|
|
159
181
|
} else {
|
|
160
|
-
nil
|
|
182
|
+
sessionManagementOverrides = nil
|
|
161
183
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
184
|
+
|
|
185
|
+
var appInfoOverrides: ReclaimOverrides.ReclaimAppInfo? = nil
|
|
186
|
+
if let appInfo {
|
|
187
|
+
appInfoOverrides = .init(
|
|
165
188
|
appName: appInfo.appName,
|
|
166
189
|
appImageUrl: appInfo.appImageUrl,
|
|
167
190
|
isRecurring: appInfo.isRecurring?.boolValue ?? false
|
|
168
191
|
)
|
|
169
192
|
} else {
|
|
170
|
-
nil
|
|
193
|
+
appInfoOverrides = nil
|
|
171
194
|
}
|
|
172
|
-
|
|
195
|
+
|
|
173
196
|
return try await ReclaimVerification.setOverrides(
|
|
174
197
|
provider: providerOverrides,
|
|
175
198
|
featureOptions: featureOptionsOverrides,
|
|
@@ -179,48 +202,85 @@ import ReclaimInAppSdk
|
|
|
179
202
|
capabilityAccessToken: capabilityAccessToken
|
|
180
203
|
)
|
|
181
204
|
}
|
|
182
|
-
|
|
205
|
+
|
|
183
206
|
@objc public func clearAllOverrides() async throws {
|
|
184
207
|
return try await ReclaimVerification.clearAllOverrides()
|
|
185
208
|
}
|
|
186
|
-
|
|
209
|
+
|
|
187
210
|
@objc public func setVerificationOptions(
|
|
188
211
|
options: ReclaimApiVerificationOptions?
|
|
189
212
|
) async throws {
|
|
190
|
-
return try await ReclaimVerification.setVerificationOptions(
|
|
213
|
+
return try await ReclaimVerification.setVerificationOptions(
|
|
214
|
+
options: options?.toSdkOptions()
|
|
215
|
+
)
|
|
191
216
|
}
|
|
192
|
-
|
|
193
|
-
func startVerificationWithRequest(_ request: ReclaimVerification.Request)
|
|
194
|
-
|
|
217
|
+
|
|
218
|
+
func startVerificationWithRequest(_ request: ReclaimVerification.Request)
|
|
219
|
+
async throws -> [String: Any]
|
|
220
|
+
{
|
|
221
|
+
NSLog("[Api] starting verification")
|
|
195
222
|
return try await withCheckedThrowingContinuation { continuation in
|
|
196
|
-
NSLog("[Api] starting verification going")
|
|
223
|
+
NSLog("[Api] starting verification going")
|
|
197
224
|
Task { @MainActor in
|
|
198
|
-
NSLog("[Api] starting verification doing")
|
|
225
|
+
NSLog("[Api] starting verification doing")
|
|
199
226
|
do {
|
|
200
227
|
let result = try await ReclaimVerification.startVerification(request)
|
|
201
228
|
let map: [String: Any] = [
|
|
202
229
|
"sessionId": result.sessionId,
|
|
203
230
|
"didSubmitManualVerification": result.didSubmitManualVerification,
|
|
204
|
-
"proofs": result.proofs
|
|
231
|
+
"proofs": result.proofs,
|
|
205
232
|
]
|
|
206
233
|
continuation.resume(returning: map)
|
|
207
234
|
} catch {
|
|
208
|
-
NSLog("[Api] failed verification \(error)")
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
235
|
+
NSLog("[Api] failed verification \(error)")
|
|
236
|
+
var apiError: ApiError? = nil
|
|
237
|
+
if error is ReclaimVerificationError {
|
|
238
|
+
switch error as! ReclaimVerificationError {
|
|
239
|
+
case .cancelled(let sessionId, let didSubmitManualVerification):
|
|
240
|
+
apiError = .init(
|
|
241
|
+
errorType: "cancelled",
|
|
242
|
+
sessionId: sessionId,
|
|
243
|
+
didSubmitManualVerification: didSubmitManualVerification,
|
|
244
|
+
reason: nil
|
|
245
|
+
)
|
|
246
|
+
case .dismissed(let sessionId, let didSubmitManualVerification):
|
|
247
|
+
apiError = .init(
|
|
248
|
+
errorType: "dismissed",
|
|
249
|
+
sessionId: sessionId,
|
|
250
|
+
didSubmitManualVerification: didSubmitManualVerification,
|
|
251
|
+
reason: nil
|
|
252
|
+
)
|
|
253
|
+
case .sessionExpired(
|
|
254
|
+
let sessionId,
|
|
255
|
+
let didSubmitManualVerification
|
|
256
|
+
):
|
|
257
|
+
apiError = .init(
|
|
258
|
+
errorType: "sessionExpired",
|
|
259
|
+
sessionId: sessionId,
|
|
260
|
+
didSubmitManualVerification: didSubmitManualVerification,
|
|
261
|
+
reason: nil
|
|
262
|
+
)
|
|
263
|
+
case .failed(
|
|
264
|
+
let sessionId,
|
|
265
|
+
let didSubmitManualVerification,
|
|
266
|
+
let reason
|
|
267
|
+
):
|
|
268
|
+
apiError = .init(
|
|
269
|
+
errorType: "failed",
|
|
270
|
+
sessionId: sessionId,
|
|
271
|
+
didSubmitManualVerification: didSubmitManualVerification,
|
|
272
|
+
reason: reason
|
|
273
|
+
)
|
|
219
274
|
}
|
|
220
275
|
} else {
|
|
221
|
-
|
|
276
|
+
apiError = ApiError(
|
|
277
|
+
errorType: "failed",
|
|
278
|
+
sessionId: request.maybeSessionId ?? "",
|
|
279
|
+
didSubmitManualVerification: false,
|
|
280
|
+
reason: "\(error)"
|
|
281
|
+
)
|
|
222
282
|
}
|
|
223
|
-
continuation.resume(throwing: apiError)
|
|
283
|
+
continuation.resume(throwing: apiError!)
|
|
224
284
|
}
|
|
225
285
|
}
|
|
226
286
|
}
|
|
@@ -232,20 +292,29 @@ import ReclaimInAppSdk
|
|
|
232
292
|
@objc public let sessionId: String?
|
|
233
293
|
@objc public let didSubmitManualVerification: Bool
|
|
234
294
|
@objc public let reason: String?
|
|
235
|
-
|
|
236
|
-
public init(
|
|
295
|
+
|
|
296
|
+
public init(
|
|
297
|
+
errorType: String,
|
|
298
|
+
sessionId: String?,
|
|
299
|
+
didSubmitManualVerification: Bool,
|
|
300
|
+
reason: String?
|
|
301
|
+
) {
|
|
237
302
|
self.errorType = errorType
|
|
238
303
|
self.sessionId = sessionId
|
|
239
304
|
self.didSubmitManualVerification = didSubmitManualVerification
|
|
240
305
|
self.reason = reason
|
|
241
|
-
super.init(
|
|
242
|
-
"
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
306
|
+
super.init(
|
|
307
|
+
domain: "ApiError",
|
|
308
|
+
code: 1,
|
|
309
|
+
userInfo: [
|
|
310
|
+
"errorType": errorType,
|
|
311
|
+
"sessionId": sessionId ?? "",
|
|
312
|
+
"didSubmitManualVerification": didSubmitManualVerification,
|
|
313
|
+
"reason": reason ?? "",
|
|
314
|
+
]
|
|
315
|
+
)
|
|
247
316
|
}
|
|
248
|
-
|
|
317
|
+
|
|
249
318
|
required init?(coder: NSCoder) {
|
|
250
319
|
fatalError("init(coder:) has not been implemented")
|
|
251
320
|
}
|
|
@@ -257,34 +326,50 @@ public typealias OverridenProviderCallback = (
|
|
|
257
326
|
_ sessionId: String,
|
|
258
327
|
_ signature: String,
|
|
259
328
|
_ timestamp: String,
|
|
329
|
+
_ resolvedVersion: String,
|
|
260
330
|
_ replyId: String
|
|
261
331
|
) -> Void
|
|
262
332
|
|
|
263
|
-
@objc(OverridenProviderCallbackHandler)
|
|
333
|
+
@objc(OverridenProviderCallbackHandler)
|
|
334
|
+
public class OverridenProviderCallbackHandler: NSObject, ReclaimOverrides
|
|
335
|
+
.ProviderInformation.CallbackHandler
|
|
336
|
+
{
|
|
264
337
|
@objc let _fetchProviderInformation: OverridenProviderCallback
|
|
265
|
-
|
|
266
|
-
@objc public init(
|
|
338
|
+
|
|
339
|
+
@objc public init(
|
|
340
|
+
_fetchProviderInformation: @escaping OverridenProviderCallback
|
|
341
|
+
) {
|
|
267
342
|
self._fetchProviderInformation = _fetchProviderInformation
|
|
268
343
|
}
|
|
269
|
-
|
|
344
|
+
|
|
270
345
|
public func fetchProviderInformation(
|
|
271
346
|
appId: String,
|
|
272
347
|
providerId: String,
|
|
273
348
|
sessionId: String,
|
|
274
349
|
signature: String,
|
|
275
350
|
timestamp: String,
|
|
351
|
+
resolvedVersion: String,
|
|
276
352
|
completion: @escaping (Result<String, any Error>) -> Void
|
|
277
353
|
) {
|
|
278
354
|
let replyId = Api.setReplyWithStringCallback(completion)
|
|
279
|
-
self._fetchProviderInformation(
|
|
355
|
+
self._fetchProviderInformation(
|
|
356
|
+
appId,
|
|
357
|
+
providerId,
|
|
358
|
+
sessionId,
|
|
359
|
+
signature,
|
|
360
|
+
timestamp,
|
|
361
|
+
resolvedVersion,
|
|
362
|
+
replyId
|
|
363
|
+
)
|
|
280
364
|
}
|
|
281
365
|
}
|
|
282
366
|
|
|
283
|
-
@objc(OverridenProviderInformation)
|
|
367
|
+
@objc(OverridenProviderInformation)
|
|
368
|
+
public class OverridenProviderInformation: NSObject {
|
|
284
369
|
@objc public var url: String?
|
|
285
370
|
@objc public var jsonString: String?
|
|
286
371
|
@objc public var callback: OverridenProviderCallbackHandler?
|
|
287
|
-
|
|
372
|
+
|
|
288
373
|
@objc public init(
|
|
289
374
|
url: String? = nil,
|
|
290
375
|
jsonString: String? = nil,
|
|
@@ -300,29 +385,37 @@ public typealias OverridenProviderCallback = (
|
|
|
300
385
|
// bool
|
|
301
386
|
@objc public var cookiePersist: NSNumber?
|
|
302
387
|
// bool
|
|
303
|
-
@objc
|
|
388
|
+
@objc public var singleReclaimRequest: NSNumber?
|
|
304
389
|
// int64 (long)
|
|
305
|
-
@objc
|
|
390
|
+
@objc public var idleTimeThresholdForManualVerificationTrigger: NSNumber?
|
|
306
391
|
// int64 (long)
|
|
307
|
-
@objc
|
|
308
|
-
@objc
|
|
392
|
+
@objc public var sessionTimeoutForManualVerificationTrigger: NSNumber?
|
|
393
|
+
@objc public var attestorBrowserRpcUrl: String?
|
|
309
394
|
// bool
|
|
310
|
-
@objc
|
|
311
|
-
|
|
395
|
+
@objc public var isAIFlowEnabled: NSNumber?
|
|
396
|
+
@objc public var manualReviewMessage: String?
|
|
397
|
+
@objc public var loginPromptMessage: String?
|
|
398
|
+
|
|
312
399
|
@objc public init(
|
|
313
400
|
cookiePersist: NSNumber? = nil,
|
|
314
401
|
singleReclaimRequest: NSNumber? = nil,
|
|
315
402
|
idleTimeThresholdForManualVerificationTrigger: NSNumber? = nil,
|
|
316
403
|
sessionTimeoutForManualVerificationTrigger: NSNumber? = nil,
|
|
317
404
|
attestorBrowserRpcUrl: String? = nil,
|
|
318
|
-
isAIFlowEnabled: NSNumber? = nil
|
|
405
|
+
isAIFlowEnabled: NSNumber? = nil,
|
|
406
|
+
manualReviewMessage: String? = nil,
|
|
407
|
+
loginPromptMessage: String? = nil
|
|
319
408
|
) {
|
|
320
409
|
self.cookiePersist = cookiePersist
|
|
321
410
|
self.singleReclaimRequest = singleReclaimRequest
|
|
322
|
-
self.idleTimeThresholdForManualVerificationTrigger =
|
|
323
|
-
|
|
411
|
+
self.idleTimeThresholdForManualVerificationTrigger =
|
|
412
|
+
idleTimeThresholdForManualVerificationTrigger
|
|
413
|
+
self.sessionTimeoutForManualVerificationTrigger =
|
|
414
|
+
sessionTimeoutForManualVerificationTrigger
|
|
324
415
|
self.attestorBrowserRpcUrl = attestorBrowserRpcUrl
|
|
325
416
|
self.isAIFlowEnabled = isAIFlowEnabled
|
|
417
|
+
self.manualReviewMessage = manualReviewMessage
|
|
418
|
+
self.loginPromptMessage = loginPromptMessage
|
|
326
419
|
}
|
|
327
420
|
}
|
|
328
421
|
|
|
@@ -330,7 +423,7 @@ public typealias OverridenProviderCallback = (
|
|
|
330
423
|
@objc public let appName: String
|
|
331
424
|
@objc public let appImageUrl: String
|
|
332
425
|
@objc public let isRecurring: NSNumber?
|
|
333
|
-
|
|
426
|
+
|
|
334
427
|
@objc public init(
|
|
335
428
|
appName: String,
|
|
336
429
|
appImageUrl: String,
|
|
@@ -357,7 +450,7 @@ public typealias OverridenProviderCallback = (
|
|
|
357
450
|
* Type: Bool.
|
|
358
451
|
*/
|
|
359
452
|
@objc public let canSdkPrintLogs: NSNumber?
|
|
360
|
-
|
|
453
|
+
|
|
361
454
|
@objc public init(
|
|
362
455
|
logHandler: OverridenLogHandler? = nil,
|
|
363
456
|
canSdkCollectTelemetry: Bool = true,
|
|
@@ -369,13 +462,16 @@ public typealias OverridenProviderCallback = (
|
|
|
369
462
|
}
|
|
370
463
|
}
|
|
371
464
|
|
|
372
|
-
@objc(OverridenLogHandler)
|
|
465
|
+
@objc(OverridenLogHandler)
|
|
466
|
+
public class OverridenLogHandler: NSObject, ReclaimOverrides.LogConsumer
|
|
467
|
+
.LogHandler
|
|
468
|
+
{
|
|
373
469
|
@objc let _onLogs: (String) -> Void
|
|
374
|
-
|
|
470
|
+
|
|
375
471
|
@objc public init(onLogs: @escaping (String) -> Void) {
|
|
376
472
|
self._onLogs = onLogs
|
|
377
473
|
}
|
|
378
|
-
|
|
474
|
+
|
|
379
475
|
@objc public func onLogs(logJsonString: String) {
|
|
380
476
|
self._onLogs(logJsonString)
|
|
381
477
|
}
|
|
@@ -386,6 +482,7 @@ public typealias OverridenCreateSessionCallback = (
|
|
|
386
482
|
_ providerId: String,
|
|
387
483
|
_ timestamp: String,
|
|
388
484
|
_ signature: String,
|
|
485
|
+
_ providerVersion: String,
|
|
389
486
|
_ replyId: String
|
|
390
487
|
) -> Void
|
|
391
488
|
public typealias OverridenUpdateSessionCallback = (
|
|
@@ -401,18 +498,22 @@ public typealias OverridenLogSessionCallback = (
|
|
|
401
498
|
_ logType: String
|
|
402
499
|
) -> Void
|
|
403
500
|
|
|
404
|
-
@objc(OverridenSessionManagement)
|
|
501
|
+
@objc(OverridenSessionManagement)
|
|
502
|
+
public class OverridenSessionManagement: NSObject {
|
|
405
503
|
@objc public let handler: OverridenSessionHandler
|
|
406
|
-
|
|
504
|
+
|
|
407
505
|
@objc public init(handler: OverridenSessionHandler) {
|
|
408
506
|
self.handler = handler
|
|
409
507
|
}
|
|
410
|
-
|
|
411
|
-
@objc(OverridenSessionHandler)
|
|
508
|
+
|
|
509
|
+
@objc(OverridenSessionHandler)
|
|
510
|
+
public class OverridenSessionHandler: NSObject, ReclaimOverrides
|
|
511
|
+
.SessionManagement.SessionHandler
|
|
512
|
+
{
|
|
412
513
|
@objc let _createSession: OverridenCreateSessionCallback
|
|
413
514
|
@objc let _updateSession: OverridenUpdateSessionCallback
|
|
414
515
|
@objc let _logSession: OverridenLogSessionCallback
|
|
415
|
-
|
|
516
|
+
|
|
416
517
|
@objc public init(
|
|
417
518
|
_createSession: @escaping OverridenCreateSessionCallback,
|
|
418
519
|
_updateSession: @escaping OverridenUpdateSessionCallback,
|
|
@@ -422,44 +523,94 @@ public typealias OverridenLogSessionCallback = (
|
|
|
422
523
|
self._updateSession = _updateSession
|
|
423
524
|
self._logSession = _logSession
|
|
424
525
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
526
|
+
|
|
527
|
+
public func createSession(
|
|
528
|
+
appId: String,
|
|
529
|
+
providerId: String,
|
|
530
|
+
timestamp: String,
|
|
531
|
+
signature: String,
|
|
532
|
+
providerVersion: String,
|
|
533
|
+
completion: @escaping (
|
|
534
|
+
Result<
|
|
535
|
+
ReclaimInAppSdk.ReclaimOverrides.SessionManagement.InitResponse,
|
|
536
|
+
any Error
|
|
537
|
+
>
|
|
538
|
+
) -> Void
|
|
539
|
+
) {
|
|
540
|
+
let replyId = Api.setReplyWithStringCallback({ value in
|
|
541
|
+
func process(value: String) {
|
|
542
|
+
let data = JSONUtility.fromString(value)
|
|
543
|
+
if let data = data as? [AnyHashable?: Any?] {
|
|
544
|
+
completion(
|
|
545
|
+
.success(
|
|
546
|
+
ReclaimOverrides.SessionManagement.InitResponse(
|
|
547
|
+
sessionId: data["sessionId"] as? String ?? "",
|
|
548
|
+
resolvedProviderVersion: data["resolvedProviderVersion"]
|
|
549
|
+
as? String ?? ""
|
|
550
|
+
)
|
|
551
|
+
)
|
|
552
|
+
)
|
|
553
|
+
} else {
|
|
554
|
+
print(
|
|
555
|
+
"Error parsing session init response as Map. Type was: \(type(of: data)), data was: \(String(describing: data))"
|
|
556
|
+
)
|
|
557
|
+
completion(
|
|
558
|
+
.success(
|
|
559
|
+
ReclaimOverrides.SessionManagement.InitResponse(
|
|
560
|
+
sessionId: "-",
|
|
561
|
+
resolvedProviderVersion: ""
|
|
562
|
+
)
|
|
563
|
+
)
|
|
564
|
+
)
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
})
|
|
568
|
+
self._createSession(
|
|
569
|
+
appId,
|
|
570
|
+
providerId,
|
|
571
|
+
timestamp,
|
|
572
|
+
signature,
|
|
573
|
+
providerVersion,
|
|
574
|
+
replyId
|
|
575
|
+
)
|
|
428
576
|
}
|
|
429
|
-
|
|
577
|
+
|
|
430
578
|
public func updateSession(
|
|
431
|
-
sessionId: String,
|
|
579
|
+
sessionId: String,
|
|
580
|
+
status: ReclaimInAppSdk.ReclaimOverrides.SessionManagement.SessionStatus,
|
|
581
|
+
completion: @escaping (Result<Bool, any Error>) -> Void
|
|
432
582
|
) {
|
|
433
|
-
|
|
583
|
+
var statusString: String? = nil
|
|
584
|
+
switch status {
|
|
434
585
|
case .USER_STARTED_VERIFICATION:
|
|
435
|
-
"USER_STARTED_VERIFICATION"
|
|
586
|
+
statusString = "USER_STARTED_VERIFICATION"
|
|
436
587
|
case .USER_INIT_VERIFICATION:
|
|
437
|
-
"USER_INIT_VERIFICATION"
|
|
588
|
+
statusString = "USER_INIT_VERIFICATION"
|
|
438
589
|
case .PROOF_GENERATION_STARTED:
|
|
439
|
-
"PROOF_GENERATION_STARTED"
|
|
590
|
+
statusString = "PROOF_GENERATION_STARTED"
|
|
440
591
|
case .PROOF_GENERATION_RETRY:
|
|
441
|
-
"PROOF_GENERATION_RETRY"
|
|
592
|
+
statusString = "PROOF_GENERATION_RETRY"
|
|
442
593
|
case .PROOF_GENERATION_SUCCESS:
|
|
443
|
-
"PROOF_GENERATION_SUCCESS"
|
|
594
|
+
statusString = "PROOF_GENERATION_SUCCESS"
|
|
444
595
|
case .PROOF_GENERATION_FAILED:
|
|
445
|
-
"PROOF_GENERATION_FAILED"
|
|
596
|
+
statusString = "PROOF_GENERATION_FAILED"
|
|
446
597
|
case .PROOF_SUBMITTED:
|
|
447
|
-
"PROOF_SUBMITTED"
|
|
598
|
+
statusString = "PROOF_SUBMITTED"
|
|
448
599
|
case .PROOF_SUBMISSION_FAILED:
|
|
449
|
-
"PROOF_SUBMISSION_FAILED"
|
|
600
|
+
statusString = "PROOF_SUBMISSION_FAILED"
|
|
450
601
|
case .PROOF_MANUAL_VERIFICATION_SUBMITTED:
|
|
451
|
-
"PROOF_MANUAL_VERIFICATION_SUBMITTED"
|
|
602
|
+
statusString = "PROOF_MANUAL_VERIFICATION_SUBMITTED"
|
|
452
603
|
}
|
|
453
604
|
let replyId = Api.setReplyCallback(completion)
|
|
454
|
-
self._updateSession(sessionId, statusString
|
|
605
|
+
self._updateSession(sessionId, statusString!, replyId)
|
|
455
606
|
}
|
|
456
|
-
|
|
607
|
+
|
|
457
608
|
public func logSession(
|
|
458
609
|
appId: String,
|
|
459
610
|
providerId: String,
|
|
460
611
|
sessionId: String,
|
|
461
612
|
logType: String,
|
|
462
|
-
metadata: [String
|
|
613
|
+
metadata: [String: (any Sendable)?]?
|
|
463
614
|
) {
|
|
464
615
|
self._logSession(appId, providerId, sessionId, logType)
|
|
465
616
|
}
|
|
@@ -471,22 +622,25 @@ public typealias ReclaimVerificationOptionFetchAttestorAuthRequestHandler = (
|
|
|
471
622
|
_ replyId: String
|
|
472
623
|
) -> Void
|
|
473
624
|
|
|
474
|
-
@objc(ReclaimApiVerificationOptions)
|
|
625
|
+
@objc(ReclaimApiVerificationOptions)
|
|
626
|
+
public class ReclaimApiVerificationOptions: NSObject {
|
|
475
627
|
public let canDeleteCookiesBeforeVerificationStarts: Bool
|
|
476
|
-
public let attestorAuthRequestProvider:
|
|
628
|
+
public let attestorAuthRequestProvider:
|
|
629
|
+
ReclaimVerification.VerificationOptions.AttestorAuthRequestProvider?
|
|
477
630
|
public let claimCreationType: String?
|
|
478
631
|
public let canAutoSubmit: Bool
|
|
479
632
|
public let isCloseButtonVisible: Bool
|
|
480
|
-
|
|
481
|
-
|
|
633
|
+
|
|
482
634
|
@objc public init(
|
|
483
635
|
canDeleteCookiesBeforeVerificationStarts: Bool,
|
|
484
|
-
fetchAttestorAuthenticationRequest:
|
|
636
|
+
fetchAttestorAuthenticationRequest:
|
|
637
|
+
ReclaimVerificationOptionFetchAttestorAuthRequestHandler?,
|
|
485
638
|
claimCreationType: String?,
|
|
486
639
|
canAutoSubmit: Bool,
|
|
487
640
|
isCloseButtonVisible: Bool
|
|
488
641
|
) {
|
|
489
|
-
self.canDeleteCookiesBeforeVerificationStarts =
|
|
642
|
+
self.canDeleteCookiesBeforeVerificationStarts =
|
|
643
|
+
canDeleteCookiesBeforeVerificationStarts
|
|
490
644
|
if let fetchAttestorAuthenticationRequest {
|
|
491
645
|
self.attestorAuthRequestProvider = _AttestorAuthRequestProvider(
|
|
492
646
|
fetchAttestorAuthenticationRequest: fetchAttestorAuthenticationRequest
|
|
@@ -498,34 +652,48 @@ public typealias ReclaimVerificationOptionFetchAttestorAuthRequestHandler = (
|
|
|
498
652
|
self.canAutoSubmit = canAutoSubmit
|
|
499
653
|
self.isCloseButtonVisible = isCloseButtonVisible
|
|
500
654
|
}
|
|
501
|
-
|
|
502
|
-
func claimCreationTypeApi()
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
655
|
+
|
|
656
|
+
func claimCreationTypeApi()
|
|
657
|
+
-> ReclaimVerification.VerificationOptions.ClaimCreationType
|
|
658
|
+
{
|
|
659
|
+
switch claimCreationType {
|
|
660
|
+
case "meChain": return .meChain
|
|
661
|
+
case _: return .standalone
|
|
506
662
|
}
|
|
507
663
|
}
|
|
508
|
-
|
|
664
|
+
|
|
509
665
|
func toSdkOptions() -> ReclaimVerification.VerificationOptions {
|
|
510
666
|
return .init(
|
|
511
|
-
canDeleteCookiesBeforeVerificationStarts:
|
|
667
|
+
canDeleteCookiesBeforeVerificationStarts:
|
|
668
|
+
canDeleteCookiesBeforeVerificationStarts,
|
|
512
669
|
attestorAuthRequestProvider: attestorAuthRequestProvider,
|
|
513
670
|
claimCreationType: claimCreationTypeApi(),
|
|
514
671
|
canAutoSubmit: canAutoSubmit,
|
|
515
672
|
isCloseButtonVisible: isCloseButtonVisible
|
|
516
673
|
)
|
|
517
674
|
}
|
|
518
|
-
|
|
519
|
-
class _AttestorAuthRequestProvider: ReclaimVerification.VerificationOptions
|
|
675
|
+
|
|
676
|
+
class _AttestorAuthRequestProvider: ReclaimVerification.VerificationOptions
|
|
677
|
+
.AttestorAuthRequestProvider
|
|
678
|
+
{
|
|
520
679
|
let fetchAttestorAuthenticationRequest: ReclaimVerificationOptionFetchAttestorAuthRequestHandler
|
|
521
|
-
|
|
522
|
-
init(
|
|
523
|
-
|
|
680
|
+
|
|
681
|
+
init(
|
|
682
|
+
fetchAttestorAuthenticationRequest: @escaping
|
|
683
|
+
ReclaimVerificationOptionFetchAttestorAuthRequestHandler
|
|
684
|
+
) {
|
|
685
|
+
self.fetchAttestorAuthenticationRequest =
|
|
686
|
+
fetchAttestorAuthenticationRequest
|
|
524
687
|
}
|
|
525
|
-
|
|
526
|
-
func fetchAttestorAuthenticationRequest(
|
|
688
|
+
|
|
689
|
+
func fetchAttestorAuthenticationRequest(
|
|
690
|
+
reclaimHttpProvider: [AnyHashable?: (any Sendable)?],
|
|
691
|
+
completion: @escaping (Result<String, any Error>) -> Void
|
|
692
|
+
) {
|
|
527
693
|
let replyId = Api.setReplyWithStringCallback(completion)
|
|
528
|
-
let reclaimHttpProviderJsonString = JSONUtility.toString(
|
|
694
|
+
let reclaimHttpProviderJsonString = JSONUtility.toString(
|
|
695
|
+
reclaimHttpProvider
|
|
696
|
+
)
|
|
529
697
|
fetchAttestorAuthenticationRequest(reclaimHttpProviderJsonString, replyId)
|
|
530
698
|
}
|
|
531
699
|
}
|