@reclaimprotocol/inapp-rn-sdk 0.3.1 → 0.7.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 +2 -1
- package/README.md +19 -17
- package/android/build.gradle +3 -3
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI.h +45 -35
- package/android/src/main/java/com/reclaimprotocol/inapp_rn_sdk/InappRnSdkModule.kt +18 -12
- package/ios/InappRnSdk.mm +8 -13
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec.h +18 -12
- package/ios/generated/RNInappRnSdkSpecJSI.h +45 -35
- package/ios/inapp_rn_sdk/Api.swift +32 -21
- package/lib/commonjs/index.js +227 -22
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeInappRnSdk.js.map +1 -1
- package/lib/module/index.js +223 -21
- 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 +41 -10
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts +18 -11
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +41 -10
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts +18 -11
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/index.ts +378 -65
- package/src/specs/NativeInappRnSdk.ts +22 -13
- package/lib/commonjs/platform.js +0 -212
- package/lib/commonjs/platform.js.map +0 -1
- package/lib/module/platform.js +0 -206
- package/lib/module/platform.js.map +0 -1
- package/lib/typescript/commonjs/src/platform.d.ts +0 -18
- package/lib/typescript/commonjs/src/platform.d.ts.map +0 -1
- package/lib/typescript/module/src/platform.d.ts +0 -18
- package/lib/typescript/module/src/platform.d.ts.map +0 -1
- package/src/platform.ts +0 -218
package/src/index.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import type { EventSubscription } from 'react-native';
|
|
2
|
+
import NativeReclaimInappModule, * as NativeReclaimInappModuleTypes from './specs/NativeInappRnSdk';
|
|
4
3
|
/**
|
|
5
4
|
* [ReclaimVerification] is the main class for interacting with the Reclaim verification system.
|
|
6
5
|
* It provides methods to start verification processes, manage platform configurations,
|
|
7
6
|
* and handle verification options.
|
|
8
|
-
*
|
|
7
|
+
*
|
|
9
8
|
* The class can be instantiated with a custom platform implementation, or will use
|
|
10
9
|
* the default [PlatformImpl] if none is provided.
|
|
11
10
|
*/
|
|
@@ -25,10 +24,18 @@ export class ReclaimVerification {
|
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
public async startVerification(
|
|
27
|
+
public async startVerification(
|
|
28
|
+
request: ReclaimVerification.Request
|
|
29
|
+
): Promise<ReclaimVerification.Response> {
|
|
29
30
|
return this.platform.startVerification(request);
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
public async startVerificationFromUrl(
|
|
34
|
+
requestUrl: string
|
|
35
|
+
): Promise<ReclaimVerification.Response> {
|
|
36
|
+
return this.platform.startVerificationFromUrl(requestUrl);
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
public async ping(): Promise<boolean> {
|
|
33
40
|
return this.platform.ping();
|
|
34
41
|
}
|
|
@@ -41,12 +48,13 @@ export class ReclaimVerification {
|
|
|
41
48
|
return this.platform.clearAllOverrides();
|
|
42
49
|
}
|
|
43
50
|
|
|
44
|
-
public setVerificationOptions(
|
|
51
|
+
public setVerificationOptions(
|
|
52
|
+
options?: ReclaimVerification.VerificationOptions | null
|
|
53
|
+
) {
|
|
45
54
|
return this.platform.setVerificationOptions(options);
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
57
|
|
|
49
|
-
|
|
50
58
|
/**
|
|
51
59
|
* This namespace provides types involved in initiating and managing the verification process
|
|
52
60
|
* for proving claims about user data through various providers.
|
|
@@ -56,7 +64,8 @@ export namespace ReclaimVerification {
|
|
|
56
64
|
* Represents user's session information for a verification attempt.
|
|
57
65
|
* This data class contains the necessary data to identify and validate a verification session.
|
|
58
66
|
*/
|
|
59
|
-
export type SessionInformation =
|
|
67
|
+
export type SessionInformation =
|
|
68
|
+
NativeReclaimInappModuleTypes.SessionInformation;
|
|
60
69
|
|
|
61
70
|
/**
|
|
62
71
|
* Represents a request for a verification attempt.
|
|
@@ -86,12 +95,18 @@ export namespace ReclaimVerification {
|
|
|
86
95
|
}
|
|
87
96
|
|
|
88
97
|
export const isProof = (value: Record<string, any>): value is Proof => {
|
|
89
|
-
return
|
|
90
|
-
|
|
98
|
+
return (
|
|
99
|
+
typeof value === 'object' &&
|
|
100
|
+
value !== null &&
|
|
101
|
+
'identifier' in value &&
|
|
102
|
+
'signatures' in value &&
|
|
103
|
+
'witnesses' in value
|
|
104
|
+
);
|
|
105
|
+
};
|
|
91
106
|
|
|
92
107
|
export const asProofs = (proofs: Record<string, any>[]): Proof[] => {
|
|
93
108
|
return proofs.filter(isProof);
|
|
94
|
-
}
|
|
109
|
+
};
|
|
95
110
|
|
|
96
111
|
export interface ProviderClaimData {
|
|
97
112
|
owner: string;
|
|
@@ -113,14 +128,28 @@ export namespace ReclaimVerification {
|
|
|
113
128
|
|
|
114
129
|
export interface VerificationOptions {
|
|
115
130
|
canDeleteCookiesBeforeVerificationStarts: boolean;
|
|
116
|
-
fetchAttestorAuthenticationRequest: (
|
|
131
|
+
fetchAttestorAuthenticationRequest: (
|
|
132
|
+
reclaimHttpProviderJsonString: string
|
|
133
|
+
) => Promise<string>;
|
|
134
|
+
claimCreationType?: 'standalone' | 'meChain'; // Optional
|
|
135
|
+
/**
|
|
136
|
+
* Whether to automatically submit the proof after generation. Defaults to true.
|
|
137
|
+
*/
|
|
138
|
+
canAutoSubmit?: boolean; // Optional
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Whether the close button is visible. Defaults to true.
|
|
142
|
+
*/
|
|
143
|
+
isCloseButtonVisible?: boolean; // Optional
|
|
117
144
|
}
|
|
118
145
|
|
|
119
146
|
export namespace Overrides {
|
|
120
147
|
export interface ProviderInformation {
|
|
121
148
|
url?: string;
|
|
122
149
|
jsonString?: string;
|
|
123
|
-
callback?: (
|
|
150
|
+
callback?: (
|
|
151
|
+
request: NativeReclaimInappModuleTypes.ProviderInformationRequest
|
|
152
|
+
) => Promise<string>;
|
|
124
153
|
}
|
|
125
154
|
export type FeatureOptions = NativeReclaimInappModuleTypes.FeatureOptions;
|
|
126
155
|
export interface LogConsumer {
|
|
@@ -143,59 +172,70 @@ export namespace ReclaimVerification {
|
|
|
143
172
|
}
|
|
144
173
|
export interface SessionManagement {
|
|
145
174
|
onLog: (event: NativeReclaimInappModuleTypes.SessionLogEvent) => void;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Receive request for creating a session and return a session id.
|
|
177
|
+
* @param event Receive request for creating a session and return a session id.
|
|
178
|
+
* @returns A session id.
|
|
179
|
+
*/
|
|
180
|
+
onSessionCreateRequest: (
|
|
181
|
+
event: NativeReclaimInappModuleTypes.SessionCreateRequestEvent
|
|
182
|
+
) => Promise<string>;
|
|
183
|
+
onSessionUpdateRequest: (
|
|
184
|
+
event: NativeReclaimInappModuleTypes.SessionUpdateRequestEvent
|
|
185
|
+
) => Promise<boolean>;
|
|
186
|
+
}
|
|
149
187
|
export type ReclaimAppInfo = NativeReclaimInappModuleTypes.ReclaimAppInfo;
|
|
150
188
|
}
|
|
151
189
|
|
|
152
190
|
export type OverrideConfig = {
|
|
153
|
-
provider?: Overrides.ProviderInformation
|
|
154
|
-
featureOptions?: Overrides.FeatureOptions
|
|
155
|
-
logConsumer?: Overrides.LogConsumer
|
|
156
|
-
sessionManagement?: Overrides.SessionManagement
|
|
157
|
-
appInfo?: Overrides.ReclaimAppInfo
|
|
158
|
-
capabilityAccessToken?: string | null
|
|
159
|
-
}
|
|
191
|
+
provider?: Overrides.ProviderInformation;
|
|
192
|
+
featureOptions?: Overrides.FeatureOptions;
|
|
193
|
+
logConsumer?: Overrides.LogConsumer;
|
|
194
|
+
sessionManagement?: Overrides.SessionManagement;
|
|
195
|
+
appInfo?: Overrides.ReclaimAppInfo;
|
|
196
|
+
capabilityAccessToken?: string | null;
|
|
197
|
+
};
|
|
160
198
|
|
|
161
199
|
export enum ExceptionType {
|
|
162
|
-
Cancelled =
|
|
163
|
-
Dismissed =
|
|
164
|
-
SessionExpired =
|
|
165
|
-
Failed =
|
|
200
|
+
Cancelled = 'Cancelled',
|
|
201
|
+
Dismissed = 'Dismissed',
|
|
202
|
+
SessionExpired = 'SessionExpired',
|
|
203
|
+
Failed = 'Failed',
|
|
166
204
|
}
|
|
167
205
|
|
|
168
206
|
export class ReclaimPlatformException extends Error {
|
|
169
|
-
readonly innerError: Error
|
|
170
|
-
readonly reason?: string
|
|
171
|
-
readonly details?: any
|
|
207
|
+
readonly innerError: Error;
|
|
208
|
+
readonly reason?: string;
|
|
209
|
+
readonly details?: any;
|
|
172
210
|
|
|
173
211
|
constructor(message: string, innerError: Error) {
|
|
174
212
|
super(message);
|
|
175
213
|
this.innerError = innerError;
|
|
176
214
|
this.reason = innerError.message;
|
|
177
215
|
if ('userInfo' in innerError) {
|
|
178
|
-
const details: any = innerError.userInfo
|
|
179
|
-
this.details = details
|
|
216
|
+
const details: any = innerError.userInfo;
|
|
217
|
+
this.details = details;
|
|
180
218
|
if ('message' in details) {
|
|
181
|
-
this.reason = details.message || this.reason
|
|
219
|
+
this.reason = details.message || this.reason;
|
|
182
220
|
}
|
|
183
221
|
}
|
|
184
222
|
}
|
|
185
223
|
|
|
186
|
-
static isReclaimPlatformException(
|
|
187
|
-
|
|
224
|
+
static isReclaimPlatformException(
|
|
225
|
+
error: Error
|
|
226
|
+
): error is ReclaimPlatformException {
|
|
227
|
+
return error instanceof ReclaimPlatformException;
|
|
188
228
|
}
|
|
189
229
|
}
|
|
190
230
|
|
|
191
231
|
export class ReclaimVerificationException extends Error {
|
|
192
|
-
readonly innerError: Error
|
|
193
|
-
readonly type: ExceptionType
|
|
194
|
-
readonly sessionId: string
|
|
195
|
-
readonly
|
|
196
|
-
readonly
|
|
232
|
+
readonly 'innerError': Error;
|
|
233
|
+
readonly 'type': ExceptionType;
|
|
234
|
+
readonly 'sessionId': string;
|
|
235
|
+
readonly 'didSubmitManualVerification': boolean;
|
|
236
|
+
readonly 'reason': string;
|
|
197
237
|
|
|
198
|
-
constructor(
|
|
238
|
+
'constructor'(
|
|
199
239
|
message: string,
|
|
200
240
|
innerError: Error,
|
|
201
241
|
type: ExceptionType,
|
|
@@ -211,39 +251,46 @@ export namespace ReclaimVerification {
|
|
|
211
251
|
this.reason = reason;
|
|
212
252
|
}
|
|
213
253
|
|
|
214
|
-
private static fromTypeName(name: string): ExceptionType {
|
|
254
|
+
private static 'fromTypeName'(name: string): ExceptionType {
|
|
215
255
|
switch (name) {
|
|
216
|
-
case
|
|
217
|
-
case
|
|
256
|
+
case 'cancelled':
|
|
257
|
+
case 'org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Cancelled':
|
|
218
258
|
return ExceptionType.Cancelled;
|
|
219
|
-
case
|
|
220
|
-
case
|
|
259
|
+
case 'dismissed':
|
|
260
|
+
case 'org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Dismissed':
|
|
221
261
|
return ExceptionType.Dismissed;
|
|
222
|
-
case
|
|
223
|
-
case
|
|
262
|
+
case 'sessionExpired':
|
|
263
|
+
case 'org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.SessionExpired':
|
|
224
264
|
return ExceptionType.SessionExpired;
|
|
225
|
-
case
|
|
226
|
-
case
|
|
265
|
+
case 'failed':
|
|
266
|
+
case 'org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Failed':
|
|
227
267
|
return ExceptionType.Failed;
|
|
228
268
|
}
|
|
229
269
|
return ExceptionType.Failed;
|
|
230
270
|
}
|
|
231
271
|
|
|
232
|
-
static fromError(
|
|
272
|
+
static 'fromError'(
|
|
273
|
+
error: Error,
|
|
274
|
+
sessionIdHint: string
|
|
275
|
+
): ReclaimVerificationException {
|
|
233
276
|
if ('userInfo' in error) {
|
|
234
277
|
// From native, we send information about error in userInfo
|
|
235
278
|
let userInfo = error.userInfo as any;
|
|
236
279
|
if (userInfo) {
|
|
237
|
-
let type =
|
|
238
|
-
|
|
280
|
+
let type =
|
|
281
|
+
ReclaimVerification.ReclaimVerificationException.fromTypeName(
|
|
282
|
+
userInfo.errorType
|
|
283
|
+
);
|
|
284
|
+
let maybeSessionId = userInfo?.sessionId;
|
|
239
285
|
return new ReclaimVerificationException(
|
|
240
286
|
error.message,
|
|
241
287
|
error,
|
|
242
288
|
type,
|
|
243
|
-
|
|
244
|
-
? maybeSessionId
|
|
289
|
+
typeof maybeSessionId === 'string' && maybeSessionId
|
|
290
|
+
? maybeSessionId
|
|
291
|
+
: sessionIdHint,
|
|
245
292
|
userInfo?.didSubmitManualVerification ?? false,
|
|
246
|
-
userInfo?.reason ??
|
|
293
|
+
userInfo?.reason ?? ''
|
|
247
294
|
);
|
|
248
295
|
}
|
|
249
296
|
}
|
|
@@ -253,26 +300,292 @@ export namespace ReclaimVerification {
|
|
|
253
300
|
ReclaimVerification.ExceptionType.Failed,
|
|
254
301
|
sessionIdHint,
|
|
255
302
|
false,
|
|
256
|
-
|
|
303
|
+
''
|
|
257
304
|
);
|
|
258
305
|
}
|
|
259
306
|
|
|
260
|
-
static isReclaimVerificationException(
|
|
261
|
-
|
|
307
|
+
static 'isReclaimVerificationException'(
|
|
308
|
+
error: Error
|
|
309
|
+
): error is ReclaimVerificationException {
|
|
310
|
+
return error instanceof ReclaimVerificationException;
|
|
262
311
|
}
|
|
263
312
|
}
|
|
264
313
|
|
|
265
314
|
export abstract class Platform {
|
|
266
|
-
abstract startVerification(
|
|
315
|
+
abstract startVerification(
|
|
316
|
+
request: ReclaimVerification.Request
|
|
317
|
+
): Promise<ReclaimVerification.Response>;
|
|
318
|
+
|
|
319
|
+
abstract startVerificationFromUrl(
|
|
320
|
+
requestUrl: string
|
|
321
|
+
): Promise<ReclaimVerification.Response>;
|
|
267
322
|
|
|
268
|
-
abstract
|
|
323
|
+
abstract ping(): Promise<boolean>;
|
|
269
324
|
|
|
270
|
-
abstract
|
|
325
|
+
abstract setOverrides(
|
|
326
|
+
config: ReclaimVerification.OverrideConfig
|
|
327
|
+
): Promise<void>;
|
|
271
328
|
|
|
272
|
-
abstract
|
|
329
|
+
abstract clearAllOverrides(): Promise<void>;
|
|
273
330
|
|
|
274
|
-
abstract
|
|
331
|
+
abstract setVerificationOptions(
|
|
332
|
+
options?: ReclaimVerification.VerificationOptions | null
|
|
333
|
+
): Promise<void>;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export class PlatformImpl extends ReclaimVerification.Platform {
|
|
338
|
+
override async startVerification(
|
|
339
|
+
request: ReclaimVerification.Request
|
|
340
|
+
): Promise<ReclaimVerification.Response> {
|
|
341
|
+
try {
|
|
342
|
+
const response =
|
|
343
|
+
await NativeReclaimInappModule.startVerification(request);
|
|
344
|
+
return {
|
|
345
|
+
...response,
|
|
346
|
+
proofs: ReclaimVerification.ReclaimResult.asProofs(response.proofs),
|
|
347
|
+
};
|
|
348
|
+
} catch (error) {
|
|
349
|
+
console.info({
|
|
350
|
+
error,
|
|
351
|
+
});
|
|
352
|
+
if (error instanceof Error) {
|
|
353
|
+
throw ReclaimVerification.ReclaimVerificationException.fromError(
|
|
354
|
+
error,
|
|
355
|
+
request.session?.sessionId ?? ''
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
throw error;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
275
361
|
|
|
276
|
-
|
|
362
|
+
override async startVerificationFromUrl(
|
|
363
|
+
requestUrl: string
|
|
364
|
+
): Promise<ReclaimVerification.Response> {
|
|
365
|
+
try {
|
|
366
|
+
const response =
|
|
367
|
+
await NativeReclaimInappModule.startVerificationFromUrl(requestUrl);
|
|
368
|
+
return {
|
|
369
|
+
...response,
|
|
370
|
+
proofs: ReclaimVerification.ReclaimResult.asProofs(response.proofs),
|
|
371
|
+
};
|
|
372
|
+
} catch (error) {
|
|
373
|
+
console.info({
|
|
374
|
+
error,
|
|
375
|
+
});
|
|
376
|
+
if (error instanceof Error) {
|
|
377
|
+
throw ReclaimVerification.ReclaimVerificationException.fromError(
|
|
378
|
+
error,
|
|
379
|
+
''
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
throw error;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
override async ping(): Promise<boolean> {
|
|
387
|
+
return await NativeReclaimInappModule.ping();
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
private previousSessionManagementCancelCallback: null | (() => void) = null;
|
|
391
|
+
disposeSessionManagement() {
|
|
392
|
+
let callback = this.previousSessionManagementCancelCallback;
|
|
393
|
+
if (callback != null && callback != undefined) {
|
|
394
|
+
callback();
|
|
395
|
+
}
|
|
396
|
+
this.previousSessionManagementCancelCallback = null;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
private previousLogSubscription: EventSubscription | null = null;
|
|
400
|
+
disposeLogListener() {
|
|
401
|
+
this.previousLogSubscription?.remove();
|
|
402
|
+
this.previousLogSubscription = null;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
private previousProviderRequestCancelCallback: null | (() => void) = null;
|
|
406
|
+
private disposeProviderRequestListener() {
|
|
407
|
+
let callback = this.previousProviderRequestCancelCallback;
|
|
408
|
+
if (callback != null && callback != undefined) {
|
|
409
|
+
callback();
|
|
410
|
+
}
|
|
411
|
+
this.previousProviderRequestCancelCallback = null;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
override async setOverrides({
|
|
415
|
+
provider,
|
|
416
|
+
featureOptions,
|
|
417
|
+
logConsumer,
|
|
418
|
+
sessionManagement,
|
|
419
|
+
appInfo,
|
|
420
|
+
capabilityAccessToken,
|
|
421
|
+
}: ReclaimVerification.OverrideConfig) {
|
|
422
|
+
let providerCallback = provider?.callback;
|
|
423
|
+
let providerOverride = !provider
|
|
424
|
+
? null
|
|
425
|
+
: {
|
|
426
|
+
url: provider?.url,
|
|
427
|
+
jsonString: provider?.jsonString,
|
|
428
|
+
canFetchProviderInformationFromHost: !!providerCallback,
|
|
429
|
+
};
|
|
430
|
+
if (providerCallback) {
|
|
431
|
+
this.disposeProviderRequestListener();
|
|
432
|
+
let providerRequestSubscription =
|
|
433
|
+
NativeReclaimInappModule.onProviderInformationRequest(async (event) => {
|
|
434
|
+
try {
|
|
435
|
+
let result = await providerCallback(event);
|
|
436
|
+
NativeReclaimInappModule.replyWithString(event.replyId, result);
|
|
437
|
+
} catch (error) {
|
|
438
|
+
console.error(error);
|
|
439
|
+
NativeReclaimInappModule.replyWithString(event.replyId, '');
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
const cancel = () => {
|
|
443
|
+
providerRequestSubscription.remove();
|
|
444
|
+
};
|
|
445
|
+
this.previousProviderRequestCancelCallback = cancel;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const onLogsListener = logConsumer?.onLogs;
|
|
449
|
+
let logConsumerRequest = !logConsumer
|
|
450
|
+
? undefined
|
|
451
|
+
: {
|
|
452
|
+
enableLogHandler: !!onLogsListener,
|
|
453
|
+
canSdkCollectTelemetry: logConsumer?.canSdkCollectTelemetry,
|
|
454
|
+
canSdkPrintLogs: logConsumer?.canSdkPrintLogs,
|
|
455
|
+
};
|
|
456
|
+
if (onLogsListener) {
|
|
457
|
+
this.disposeLogListener();
|
|
458
|
+
const cancel = () => {
|
|
459
|
+
this.previousLogSubscription?.remove();
|
|
460
|
+
this.previousLogSubscription = null;
|
|
461
|
+
};
|
|
462
|
+
this.previousLogSubscription = NativeReclaimInappModule.onLogs((arg) => {
|
|
463
|
+
onLogsListener(arg, cancel);
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
let sessionManagementRequest = !sessionManagement
|
|
468
|
+
? undefined
|
|
469
|
+
: {
|
|
470
|
+
// A handler is provided, so we don't let SDK manage sessions
|
|
471
|
+
enableSdkSessionManagement: false,
|
|
472
|
+
};
|
|
473
|
+
if (sessionManagement) {
|
|
474
|
+
this.disposeSessionManagement();
|
|
475
|
+
let sessionCreateSubscription =
|
|
476
|
+
NativeReclaimInappModule.onSessionCreateRequest(async (event) => {
|
|
477
|
+
const replyId = event.replyId;
|
|
478
|
+
try {
|
|
479
|
+
let result = await sessionManagement.onSessionCreateRequest(event);
|
|
480
|
+
NativeReclaimInappModule.replyWithString(replyId, result);
|
|
481
|
+
} catch (error) {
|
|
482
|
+
console.error(error);
|
|
483
|
+
NativeReclaimInappModule.reply(replyId, false);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
let sessionUpdateSubscription =
|
|
487
|
+
NativeReclaimInappModule.onSessionUpdateRequest(async (event) => {
|
|
488
|
+
const replyId = event.replyId;
|
|
489
|
+
try {
|
|
490
|
+
let result = await sessionManagement.onSessionUpdateRequest(event);
|
|
491
|
+
NativeReclaimInappModule.reply(replyId, result);
|
|
492
|
+
} catch (error) {
|
|
493
|
+
console.error(error);
|
|
494
|
+
NativeReclaimInappModule.reply(replyId, false);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
let sessionLogsSubscription = NativeReclaimInappModule.onSessionLogs(
|
|
498
|
+
(event) => {
|
|
499
|
+
try {
|
|
500
|
+
sessionManagement.onLog(event);
|
|
501
|
+
} catch (error) {
|
|
502
|
+
console.error(error);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
);
|
|
506
|
+
const cancel = () => {
|
|
507
|
+
sessionCreateSubscription.remove();
|
|
508
|
+
sessionUpdateSubscription.remove();
|
|
509
|
+
sessionLogsSubscription.remove();
|
|
510
|
+
};
|
|
511
|
+
this.previousSessionManagementCancelCallback = cancel;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
try {
|
|
515
|
+
return await NativeReclaimInappModule.setOverrides({
|
|
516
|
+
provider: providerOverride,
|
|
517
|
+
featureOptions,
|
|
518
|
+
logConsumer: logConsumerRequest,
|
|
519
|
+
sessionManagement: sessionManagementRequest,
|
|
520
|
+
appInfo,
|
|
521
|
+
capabilityAccessToken,
|
|
522
|
+
});
|
|
523
|
+
} catch (error) {
|
|
524
|
+
throw new ReclaimVerification.ReclaimPlatformException(
|
|
525
|
+
'Failed to set overrides',
|
|
526
|
+
error as Error
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
override async clearAllOverrides() {
|
|
532
|
+
this.disposeProviderRequestListener();
|
|
533
|
+
this.disposeLogListener();
|
|
534
|
+
this.disposeSessionManagement();
|
|
535
|
+
return NativeReclaimInappModule.clearAllOverrides();
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
private previousAttestorAuthRequestCancelCallback: null | (() => void) = null;
|
|
539
|
+
disposeAttestorAuthRequestListener() {
|
|
540
|
+
let callback = this.previousAttestorAuthRequestCancelCallback;
|
|
541
|
+
if (callback != null && callback != undefined) {
|
|
542
|
+
callback();
|
|
543
|
+
}
|
|
544
|
+
this.previousAttestorAuthRequestCancelCallback = null;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
override async setVerificationOptions(
|
|
548
|
+
options?: ReclaimVerification.VerificationOptions | null
|
|
549
|
+
): Promise<void> {
|
|
550
|
+
let args: NativeReclaimInappModuleTypes.VerificationOptions | null = null;
|
|
551
|
+
if (options) {
|
|
552
|
+
let canUseAttestorAuthenticationRequest =
|
|
553
|
+
options.fetchAttestorAuthenticationRequest != null;
|
|
554
|
+
args = {
|
|
555
|
+
canDeleteCookiesBeforeVerificationStarts:
|
|
556
|
+
options.canDeleteCookiesBeforeVerificationStarts,
|
|
557
|
+
canUseAttestorAuthenticationRequest:
|
|
558
|
+
canUseAttestorAuthenticationRequest,
|
|
559
|
+
claimCreationType: options.claimCreationType ?? 'standalone',
|
|
560
|
+
canAutoSubmit: options.canAutoSubmit ?? true,
|
|
561
|
+
isCloseButtonVisible: options.isCloseButtonVisible ?? true,
|
|
562
|
+
};
|
|
563
|
+
if (canUseAttestorAuthenticationRequest) {
|
|
564
|
+
this.disposeAttestorAuthRequestListener();
|
|
565
|
+
let attestorAuthRequestSubscription =
|
|
566
|
+
NativeReclaimInappModule.onReclaimAttestorAuthRequest(
|
|
567
|
+
async (event) => {
|
|
568
|
+
let result = await options.fetchAttestorAuthenticationRequest(
|
|
569
|
+
event.reclaimHttpProviderJsonString
|
|
570
|
+
);
|
|
571
|
+
NativeReclaimInappModule.replyWithString(event.replyId, result);
|
|
572
|
+
}
|
|
573
|
+
);
|
|
574
|
+
const cancel = () => {
|
|
575
|
+
attestorAuthRequestSubscription.remove();
|
|
576
|
+
};
|
|
577
|
+
this.previousAttestorAuthRequestCancelCallback = cancel;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
try {
|
|
581
|
+
return await NativeReclaimInappModule.setVerificationOptions({
|
|
582
|
+
options: args,
|
|
583
|
+
});
|
|
584
|
+
} catch (error) {
|
|
585
|
+
throw new ReclaimVerification.ReclaimPlatformException(
|
|
586
|
+
'Failed to set verification options',
|
|
587
|
+
error as Error
|
|
588
|
+
);
|
|
589
|
+
}
|
|
277
590
|
}
|
|
278
591
|
}
|
|
@@ -99,12 +99,8 @@ export interface Request {
|
|
|
99
99
|
*/
|
|
100
100
|
parameters?: { [key: string]: string }; // Use index signature for Map
|
|
101
101
|
|
|
102
|
-
/**
|
|
103
|
-
* Whether to automatically submit the proof after generation.
|
|
104
|
-
*/
|
|
105
|
-
autoSubmit?: boolean; // Optional
|
|
106
|
-
|
|
107
102
|
acceptAiProviders?: boolean; // Optional
|
|
103
|
+
|
|
108
104
|
webhookUrl?: string | null; // Optional and nullable
|
|
109
105
|
}
|
|
110
106
|
|
|
@@ -168,12 +164,6 @@ export interface FeatureOptions {
|
|
|
168
164
|
*/
|
|
169
165
|
attestorBrowserRpcUrl?: string | null;
|
|
170
166
|
|
|
171
|
-
/**
|
|
172
|
-
* Whether response redaction regex escaping is enabled.
|
|
173
|
-
* Optional, defaults to null.
|
|
174
|
-
*/
|
|
175
|
-
isResponseRedactionRegexEscapingEnabled?: boolean | null;
|
|
176
|
-
|
|
177
167
|
/**
|
|
178
168
|
* Whether AI flow is enabled.
|
|
179
169
|
* Optional, defaults to null.
|
|
@@ -274,9 +264,13 @@ export interface SessionCreateRequestEvent {
|
|
|
274
264
|
*/
|
|
275
265
|
providerId: string;
|
|
276
266
|
/**
|
|
277
|
-
* The session
|
|
267
|
+
* The session timestamp for the verification attempt
|
|
278
268
|
*/
|
|
279
|
-
|
|
269
|
+
timestamp: string;
|
|
270
|
+
/**
|
|
271
|
+
* The session signature for the verification attempt
|
|
272
|
+
*/
|
|
273
|
+
signature: string;
|
|
280
274
|
/**
|
|
281
275
|
* internal
|
|
282
276
|
*/
|
|
@@ -322,6 +316,21 @@ export interface ProviderInformationRequest {
|
|
|
322
316
|
export interface VerificationOptions {
|
|
323
317
|
canDeleteCookiesBeforeVerificationStarts: boolean;
|
|
324
318
|
canUseAttestorAuthenticationRequest: boolean;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* The type of claim creation to use. Defaults to 'standalone'.
|
|
322
|
+
*/
|
|
323
|
+
claimCreationType: 'standalone' | 'meChain';
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Whether to automatically submit the proof after generation. Defaults to true.
|
|
327
|
+
*/
|
|
328
|
+
canAutoSubmit: boolean;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Whether the close button is visible. Defaults to true.
|
|
332
|
+
*/
|
|
333
|
+
isCloseButtonVisible: boolean;
|
|
325
334
|
}
|
|
326
335
|
|
|
327
336
|
export interface VerificationOptionsOptional {
|