@reclaimprotocol/inapp-rn-sdk 0.3.0 → 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 +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 +327 -32
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeInappRnSdk.js.map +1 -1
- package/lib/module/index.js +324 -14
- 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 +170 -9
- 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 +170 -9
- 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 +4 -2
- package/src/index.ts +566 -21
- package/src/specs/NativeInappRnSdk.ts +22 -13
- package/lib/commonjs/ReclaimVerificationPlatformChannel.js +0 -306
- package/lib/commonjs/ReclaimVerificationPlatformChannel.js.map +0 -1
- package/lib/commonjs/types/proof.js +0 -16
- package/lib/commonjs/types/proof.js.map +0 -1
- package/lib/module/ReclaimVerificationPlatformChannel.js +0 -299
- package/lib/module/ReclaimVerificationPlatformChannel.js.map +0 -1
- package/lib/module/types/proof.js +0 -12
- package/lib/module/types/proof.js.map +0 -1
- package/lib/typescript/commonjs/src/ReclaimVerificationPlatformChannel.d.ts +0 -115
- package/lib/typescript/commonjs/src/ReclaimVerificationPlatformChannel.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/proof.d.ts +0 -33
- package/lib/typescript/commonjs/src/types/proof.d.ts.map +0 -1
- package/lib/typescript/module/src/ReclaimVerificationPlatformChannel.d.ts +0 -115
- package/lib/typescript/module/src/ReclaimVerificationPlatformChannel.d.ts.map +0 -1
- package/lib/typescript/module/src/types/proof.d.ts +0 -33
- package/lib/typescript/module/src/types/proof.d.ts.map +0 -1
- package/src/ReclaimVerificationPlatformChannel.ts +0 -408
- package/src/types/proof.ts +0 -44
package/src/index.ts
CHANGED
|
@@ -1,40 +1,585 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { EventSubscription } from 'react-native';
|
|
2
|
+
import NativeReclaimInappModule, * as NativeReclaimInappModuleTypes from './specs/NativeInappRnSdk';
|
|
3
|
+
/**
|
|
4
|
+
* [ReclaimVerification] is the main class for interacting with the Reclaim verification system.
|
|
5
|
+
* It provides methods to start verification processes, manage platform configurations,
|
|
6
|
+
* and handle verification options.
|
|
7
|
+
*
|
|
8
|
+
* The class can be instantiated with a custom platform implementation, or will use
|
|
9
|
+
* the default [PlatformImpl] if none is provided.
|
|
10
|
+
*/
|
|
5
11
|
export class ReclaimVerification {
|
|
6
|
-
public
|
|
12
|
+
public platform: ReclaimVerification.Platform;
|
|
7
13
|
|
|
8
|
-
private static
|
|
14
|
+
private static defaultPlatform: ReclaimVerification.Platform | null = null;
|
|
9
15
|
|
|
10
|
-
public constructor(
|
|
11
|
-
if (
|
|
12
|
-
this.
|
|
16
|
+
public constructor(platform?: ReclaimVerification.Platform) {
|
|
17
|
+
if (platform) {
|
|
18
|
+
this.platform = platform;
|
|
13
19
|
} else {
|
|
14
|
-
if (ReclaimVerification.
|
|
15
|
-
ReclaimVerification.
|
|
20
|
+
if (ReclaimVerification.defaultPlatform == null) {
|
|
21
|
+
ReclaimVerification.defaultPlatform = new PlatformImpl();
|
|
16
22
|
}
|
|
17
|
-
this.
|
|
23
|
+
this.platform = ReclaimVerification.defaultPlatform;
|
|
18
24
|
}
|
|
19
25
|
}
|
|
20
26
|
|
|
21
|
-
public async startVerification(
|
|
22
|
-
|
|
27
|
+
public async startVerification(
|
|
28
|
+
request: ReclaimVerification.Request
|
|
29
|
+
): Promise<ReclaimVerification.Response> {
|
|
30
|
+
return this.platform.startVerification(request);
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
public async ping(): Promise<boolean> {
|
|
26
|
-
return this.
|
|
34
|
+
return this.platform.ping();
|
|
27
35
|
}
|
|
28
36
|
|
|
29
|
-
public setOverrides(overrides:
|
|
30
|
-
return this.
|
|
37
|
+
public setOverrides(overrides: ReclaimVerification.OverrideConfig) {
|
|
38
|
+
return this.platform.setOverrides(overrides);
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
public clearAllOverrides() {
|
|
34
|
-
return this.
|
|
42
|
+
return this.platform.clearAllOverrides();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public setVerificationOptions(
|
|
46
|
+
options?: ReclaimVerification.VerificationOptions | null
|
|
47
|
+
) {
|
|
48
|
+
return this.platform.setVerificationOptions(options);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* This namespace provides types involved in initiating and managing the verification process
|
|
54
|
+
* for proving claims about user data through various providers.
|
|
55
|
+
*/
|
|
56
|
+
export namespace ReclaimVerification {
|
|
57
|
+
/**
|
|
58
|
+
* Represents user's session information for a verification attempt.
|
|
59
|
+
* This data class contains the necessary data to identify and validate a verification session.
|
|
60
|
+
*/
|
|
61
|
+
export type SessionInformation =
|
|
62
|
+
NativeReclaimInappModuleTypes.SessionInformation;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Represents a request for a verification attempt.
|
|
66
|
+
*
|
|
67
|
+
* You can create a request using the [ReclaimVerification.Request] constructor or the [ReclaimVerification.Request.fromManifestMetaData] factory method.
|
|
68
|
+
*/
|
|
69
|
+
export type Request = NativeReclaimInappModuleTypes.Request;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Contains the proof and response data after verification
|
|
73
|
+
*/
|
|
74
|
+
export interface Response extends NativeReclaimInappModuleTypes.Response {
|
|
75
|
+
proofs: ReclaimResult.Proof[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export namespace ReclaimResult {
|
|
79
|
+
export interface Proof {
|
|
80
|
+
identifier: string;
|
|
81
|
+
signatures: string[];
|
|
82
|
+
/**
|
|
83
|
+
* A data associated with this [Proof].
|
|
84
|
+
* The data type of this object is dynamic and can be any JSON serializable Javascript object.
|
|
85
|
+
*/
|
|
86
|
+
publicData?: any | null;
|
|
87
|
+
witnesses: WitnessData[];
|
|
88
|
+
claimData: ProviderClaimData;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const isProof = (value: Record<string, any>): value is Proof => {
|
|
92
|
+
return (
|
|
93
|
+
typeof value === 'object' &&
|
|
94
|
+
value !== null &&
|
|
95
|
+
'identifier' in value &&
|
|
96
|
+
'signatures' in value &&
|
|
97
|
+
'witnesses' in value
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const asProofs = (proofs: Record<string, any>[]): Proof[] => {
|
|
102
|
+
return proofs.filter(isProof);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export interface ProviderClaimData {
|
|
106
|
+
owner: string;
|
|
107
|
+
provider: string;
|
|
108
|
+
/// int
|
|
109
|
+
timestampS: number;
|
|
110
|
+
/// int
|
|
111
|
+
epoch: number;
|
|
112
|
+
context: string;
|
|
113
|
+
identifier: string;
|
|
114
|
+
parameters: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface WitnessData {
|
|
118
|
+
id: string;
|
|
119
|
+
url: string;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface VerificationOptions {
|
|
124
|
+
canDeleteCookiesBeforeVerificationStarts: boolean;
|
|
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
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export namespace Overrides {
|
|
141
|
+
export interface ProviderInformation {
|
|
142
|
+
url?: string;
|
|
143
|
+
jsonString?: string;
|
|
144
|
+
callback?: (
|
|
145
|
+
request: NativeReclaimInappModuleTypes.ProviderInformationRequest
|
|
146
|
+
) => Promise<string>;
|
|
147
|
+
}
|
|
148
|
+
export type FeatureOptions = NativeReclaimInappModuleTypes.FeatureOptions;
|
|
149
|
+
export interface LogConsumer {
|
|
150
|
+
/**
|
|
151
|
+
* Handler for consuming logs exported from the SDK.
|
|
152
|
+
* Defaults to false.
|
|
153
|
+
*/
|
|
154
|
+
onLogs?: (logJsonString: String, cancel: () => void) => void;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* When enabled, logs are sent to reclaim that can be used to help you.
|
|
158
|
+
* Defaults to true.
|
|
159
|
+
*/
|
|
160
|
+
canSdkCollectTelemetry?: boolean;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Defaults to enabled when not in release mode.
|
|
164
|
+
*/
|
|
165
|
+
canSdkPrintLogs?: boolean;
|
|
166
|
+
}
|
|
167
|
+
export interface SessionManagement {
|
|
168
|
+
onLog: (event: NativeReclaimInappModuleTypes.SessionLogEvent) => void;
|
|
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
|
+
}
|
|
181
|
+
export type ReclaimAppInfo = NativeReclaimInappModuleTypes.ReclaimAppInfo;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export type OverrideConfig = {
|
|
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
|
+
};
|
|
192
|
+
|
|
193
|
+
export enum ExceptionType {
|
|
194
|
+
Cancelled = 'Cancelled',
|
|
195
|
+
Dismissed = 'Dismissed',
|
|
196
|
+
SessionExpired = 'SessionExpired',
|
|
197
|
+
Failed = 'Failed',
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export class ReclaimPlatformException extends Error {
|
|
201
|
+
readonly innerError: Error;
|
|
202
|
+
readonly reason?: string;
|
|
203
|
+
readonly details?: any;
|
|
204
|
+
|
|
205
|
+
constructor(message: string, innerError: Error) {
|
|
206
|
+
super(message);
|
|
207
|
+
this.innerError = innerError;
|
|
208
|
+
this.reason = innerError.message;
|
|
209
|
+
if ('userInfo' in innerError) {
|
|
210
|
+
const details: any = innerError.userInfo;
|
|
211
|
+
this.details = details;
|
|
212
|
+
if ('message' in details) {
|
|
213
|
+
this.reason = details.message || this.reason;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
static isReclaimPlatformException(
|
|
219
|
+
error: Error
|
|
220
|
+
): error is ReclaimPlatformException {
|
|
221
|
+
return error instanceof ReclaimPlatformException;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export class ReclaimVerificationException extends Error {
|
|
226
|
+
readonly 'innerError': Error;
|
|
227
|
+
readonly 'type': ExceptionType;
|
|
228
|
+
readonly 'sessionId': string;
|
|
229
|
+
readonly 'didSubmitManualVerification': boolean;
|
|
230
|
+
readonly 'reason': string;
|
|
231
|
+
|
|
232
|
+
'constructor'(
|
|
233
|
+
message: string,
|
|
234
|
+
innerError: Error,
|
|
235
|
+
type: ExceptionType,
|
|
236
|
+
sessionId: string,
|
|
237
|
+
didSubmitManualVerification: boolean,
|
|
238
|
+
reason: string
|
|
239
|
+
) {
|
|
240
|
+
super(message);
|
|
241
|
+
this.innerError = innerError;
|
|
242
|
+
this.type = type;
|
|
243
|
+
this.sessionId = sessionId;
|
|
244
|
+
this.didSubmitManualVerification = didSubmitManualVerification;
|
|
245
|
+
this.reason = reason;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
private static 'fromTypeName'(name: string): ExceptionType {
|
|
249
|
+
switch (name) {
|
|
250
|
+
case 'cancelled':
|
|
251
|
+
case 'org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Cancelled':
|
|
252
|
+
return ExceptionType.Cancelled;
|
|
253
|
+
case 'dismissed':
|
|
254
|
+
case 'org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Dismissed':
|
|
255
|
+
return ExceptionType.Dismissed;
|
|
256
|
+
case 'sessionExpired':
|
|
257
|
+
case 'org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.SessionExpired':
|
|
258
|
+
return ExceptionType.SessionExpired;
|
|
259
|
+
case 'failed':
|
|
260
|
+
case 'org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Failed':
|
|
261
|
+
return ExceptionType.Failed;
|
|
262
|
+
}
|
|
263
|
+
return ExceptionType.Failed;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
static 'fromError'(
|
|
267
|
+
error: Error,
|
|
268
|
+
sessionIdHint: string
|
|
269
|
+
): ReclaimVerificationException {
|
|
270
|
+
if ('userInfo' in error) {
|
|
271
|
+
// From native, we send information about error in userInfo
|
|
272
|
+
let userInfo = error.userInfo as any;
|
|
273
|
+
if (userInfo) {
|
|
274
|
+
let type =
|
|
275
|
+
ReclaimVerification.ReclaimVerificationException.fromTypeName(
|
|
276
|
+
userInfo.errorType
|
|
277
|
+
);
|
|
278
|
+
let maybeSessionId = userInfo?.sessionId;
|
|
279
|
+
return new ReclaimVerificationException(
|
|
280
|
+
error.message,
|
|
281
|
+
error,
|
|
282
|
+
type,
|
|
283
|
+
typeof maybeSessionId === 'string' && maybeSessionId
|
|
284
|
+
? maybeSessionId
|
|
285
|
+
: sessionIdHint,
|
|
286
|
+
userInfo?.didSubmitManualVerification ?? false,
|
|
287
|
+
userInfo?.reason ?? ''
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return new ReclaimVerificationException(
|
|
292
|
+
error.message,
|
|
293
|
+
error,
|
|
294
|
+
ReclaimVerification.ExceptionType.Failed,
|
|
295
|
+
sessionIdHint,
|
|
296
|
+
false,
|
|
297
|
+
''
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
static 'isReclaimVerificationException'(
|
|
302
|
+
error: Error
|
|
303
|
+
): error is ReclaimVerificationException {
|
|
304
|
+
return error instanceof ReclaimVerificationException;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export abstract class Platform {
|
|
309
|
+
abstract startVerification(
|
|
310
|
+
request: ReclaimVerification.Request
|
|
311
|
+
): Promise<ReclaimVerification.Response>;
|
|
312
|
+
|
|
313
|
+
abstract startVerificationFromUrl(
|
|
314
|
+
requestUrl: string
|
|
315
|
+
): Promise<ReclaimVerification.Response>;
|
|
316
|
+
|
|
317
|
+
abstract ping(): Promise<boolean>;
|
|
318
|
+
|
|
319
|
+
abstract setOverrides(
|
|
320
|
+
config: ReclaimVerification.OverrideConfig
|
|
321
|
+
): Promise<void>;
|
|
322
|
+
|
|
323
|
+
abstract clearAllOverrides(): Promise<void>;
|
|
324
|
+
|
|
325
|
+
abstract setVerificationOptions(
|
|
326
|
+
options?: ReclaimVerification.VerificationOptions | null
|
|
327
|
+
): Promise<void>;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
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;
|
|
35
391
|
}
|
|
36
392
|
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
}
|
|
39
584
|
}
|
|
40
|
-
}
|
|
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 {
|