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