@reclaimprotocol/inapp-rn-sdk 0.1.3
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 +43 -0
- package/LICENSE +20 -0
- package/README.md +292 -0
- package/android/build.gradle +130 -0
- package/android/generated/java/com/reclaimprotocol/inapp_rn_sdk/NativeInappRnSdkSpec.java +71 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNInappRnSdkSpec-generated.cpp +61 -0
- package/android/generated/jni/RNInappRnSdkSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI-generated.cpp +56 -0
- package/android/generated/jni/react/renderer/components/RNInappRnSdkSpec/RNInappRnSdkSpecJSI.h +930 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/reclaimprotocol/inapp_rn_sdk/InappRnSdkModule.kt +327 -0
- package/android/src/main/java/com/reclaimprotocol/inapp_rn_sdk/InappRnSdkPackage.kt +33 -0
- package/ios/InappRnSdk-Bridging-Header.h +1 -0
- package/ios/InappRnSdk.h +17 -0
- package/ios/InappRnSdk.mm +215 -0
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec-generated.mm +136 -0
- package/ios/generated/RNInappRnSdkSpec/RNInappRnSdkSpec.h +391 -0
- package/ios/generated/RNInappRnSdkSpecJSI-generated.cpp +56 -0
- package/ios/generated/RNInappRnSdkSpecJSI.h +930 -0
- package/ios/inapp_rn_sdk/Api.swift +405 -0
- package/lib/commonjs/ReclaimVerificationPlatformChannel.js +177 -0
- package/lib/commonjs/ReclaimVerificationPlatformChannel.js.map +1 -0
- package/lib/commonjs/index.js +43 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/specs/NativeInappRnSdk.js +23 -0
- package/lib/commonjs/specs/NativeInappRnSdk.js.map +1 -0
- package/lib/module/ReclaimVerificationPlatformChannel.js +171 -0
- package/lib/module/ReclaimVerificationPlatformChannel.js.map +1 -0
- package/lib/module/index.js +27 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/NativeInappRnSdk.js +24 -0
- package/lib/module/specs/NativeInappRnSdk.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/ReclaimVerificationPlatformChannel.d.ts +80 -0
- package/lib/typescript/commonjs/src/ReclaimVerificationPlatformChannel.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +12 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts +281 -0
- package/lib/typescript/commonjs/src/specs/NativeInappRnSdk.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/ReclaimVerificationPlatformChannel.d.ts +80 -0
- package/lib/typescript/module/src/ReclaimVerificationPlatformChannel.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +12 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts +281 -0
- package/lib/typescript/module/src/specs/NativeInappRnSdk.d.ts.map +1 -0
- package/package.json +204 -0
- package/react-native.config.js +12 -0
- package/src/ReclaimVerificationPlatformChannel.ts +245 -0
- package/src/index.tsx +32 -0
- package/src/specs/NativeInappRnSdk.ts +313 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import type { EventSubscription } from "react-native";
|
|
2
|
+
import NativeReclaimInappModule from "./specs/NativeInappRnSdk";
|
|
3
|
+
import * as NativeReclaimInappModuleTypes from "./specs/NativeInappRnSdk";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This namespace provides types involved in initiating and managing the verification process
|
|
7
|
+
* for proving claims about user data through various providers.
|
|
8
|
+
*/
|
|
9
|
+
export namespace ReclaimVerificationApi {
|
|
10
|
+
/**
|
|
11
|
+
* Represents user's session information for a verification attempt.
|
|
12
|
+
* This data class contains the necessary data to identify and validate a verification session.
|
|
13
|
+
*/
|
|
14
|
+
export type SessionInformation = NativeReclaimInappModuleTypes.SessionInformation;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents a request for a verification attempt.
|
|
18
|
+
*
|
|
19
|
+
* You can create a request using the [ReclaimVerification.Request] constructor or the [ReclaimVerification.Request.fromManifestMetaData] factory method.
|
|
20
|
+
*/
|
|
21
|
+
export type Request = NativeReclaimInappModuleTypes.Request;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Contains the proof and response data after verification
|
|
25
|
+
*/
|
|
26
|
+
export type Response = NativeReclaimInappModuleTypes.Response;
|
|
27
|
+
|
|
28
|
+
export namespace Overrides {
|
|
29
|
+
export type ProviderInformation = NativeReclaimInappModuleTypes.ProviderInformation;
|
|
30
|
+
export type FeatureOptions = NativeReclaimInappModuleTypes.FeatureOptions;
|
|
31
|
+
export interface LogConsumer {
|
|
32
|
+
/**
|
|
33
|
+
* Handler for consuming logs exported from the SDK.
|
|
34
|
+
* Defaults to false.
|
|
35
|
+
*/
|
|
36
|
+
onLogs?: (logJsonString: String, cancel: () => void) => void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* When enabled, logs are sent to reclaim that can be used to help you.
|
|
40
|
+
* Defaults to true.
|
|
41
|
+
*/
|
|
42
|
+
canSdkCollectTelemetry?: boolean;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Defaults to enabled when not in release mode.
|
|
46
|
+
*/
|
|
47
|
+
canSdkPrintLogs?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface SessionManagement {
|
|
50
|
+
onLog: (event: NativeReclaimInappModuleTypes.SessionLogEvent) => void;
|
|
51
|
+
onSessionCreateRequest: (event: NativeReclaimInappModuleTypes.SessionCreateRequestEvent) => Promise<boolean>;
|
|
52
|
+
onSessionUpdateRequest: (event: NativeReclaimInappModuleTypes.SessionUpdateRequestEvent) => Promise<boolean>;
|
|
53
|
+
};
|
|
54
|
+
export type ReclaimAppInfo = NativeReclaimInappModuleTypes.ReclaimAppInfo;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type OverrideConfig = {
|
|
58
|
+
provider?: Overrides.ProviderInformation,
|
|
59
|
+
featureOptions?: Overrides.FeatureOptions,
|
|
60
|
+
logConsumer?: Overrides.LogConsumer,
|
|
61
|
+
sessionManagement?: Overrides.SessionManagement,
|
|
62
|
+
appInfo?: Overrides.ReclaimAppInfo
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export enum ExceptionType {
|
|
66
|
+
Cancelled = "Cancelled",
|
|
67
|
+
Dismissed = "Dismissed",
|
|
68
|
+
SessionExpired = "SessionExpired",
|
|
69
|
+
Failed = "Failed",
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export class ReclaimVerificationException extends Error {
|
|
73
|
+
readonly innerError: Error
|
|
74
|
+
readonly type: ExceptionType
|
|
75
|
+
readonly sessionId: string
|
|
76
|
+
readonly "didSubmitManualVerification": boolean
|
|
77
|
+
readonly "reason": string
|
|
78
|
+
|
|
79
|
+
constructor(
|
|
80
|
+
message: string,
|
|
81
|
+
innerError: Error,
|
|
82
|
+
type: ExceptionType,
|
|
83
|
+
sessionId: string,
|
|
84
|
+
didSubmitManualVerification: boolean,
|
|
85
|
+
reason: string
|
|
86
|
+
) {
|
|
87
|
+
super(message);
|
|
88
|
+
this.innerError = innerError;
|
|
89
|
+
this.type = type;
|
|
90
|
+
this.sessionId = sessionId;
|
|
91
|
+
this.didSubmitManualVerification = didSubmitManualVerification;
|
|
92
|
+
this.reason = reason;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private static fromTypeName(name: string): ExceptionType {
|
|
96
|
+
switch (name) {
|
|
97
|
+
case "cancelled":
|
|
98
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Cancelled":
|
|
99
|
+
return ExceptionType.Cancelled;
|
|
100
|
+
case "dismissed":
|
|
101
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Dismissed":
|
|
102
|
+
return ExceptionType.Dismissed;
|
|
103
|
+
case "sessionExpired":
|
|
104
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.SessionExpired":
|
|
105
|
+
return ExceptionType.SessionExpired;
|
|
106
|
+
case "failed":
|
|
107
|
+
case "org.reclaimprotocol.inapp_sdk.ReclaimVerification.ReclaimVerificationException.Failed":
|
|
108
|
+
return ExceptionType.Failed;
|
|
109
|
+
}
|
|
110
|
+
return ExceptionType.Failed;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static fromError(error: Error, sessionIdHint: string): ReclaimVerificationException {
|
|
114
|
+
if (Object.hasOwn(error, 'userInfo')) {
|
|
115
|
+
// From native, we send information about error in userInfo
|
|
116
|
+
let unTypedError = (error as unknown as any);
|
|
117
|
+
let userInfo = unTypedError.userInfo;
|
|
118
|
+
if (userInfo) {
|
|
119
|
+
let type = ReclaimVerificationApi.ReclaimVerificationException.fromTypeName(unTypedError.userInfo.errorType);
|
|
120
|
+
let maybeSessionId = unTypedError?.userInfo?.sessionId
|
|
121
|
+
return new ReclaimVerificationException(
|
|
122
|
+
error.message,
|
|
123
|
+
error,
|
|
124
|
+
type,
|
|
125
|
+
(typeof maybeSessionId === 'string' && maybeSessionId)
|
|
126
|
+
? maybeSessionId : sessionIdHint,
|
|
127
|
+
unTypedError?.userInfo?.didSubmitManualVerification ?? false,
|
|
128
|
+
unTypedError?.userInfo?.reason ?? ""
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return new ReclaimVerificationException(
|
|
133
|
+
error.message,
|
|
134
|
+
error,
|
|
135
|
+
ReclaimVerificationApi.ExceptionType.Failed,
|
|
136
|
+
sessionIdHint,
|
|
137
|
+
false,
|
|
138
|
+
""
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export class ReclaimVerificationPlatformChannel {
|
|
145
|
+
async startVerification(request: ReclaimVerificationApi.Request): Promise<ReclaimVerificationApi.Response> {
|
|
146
|
+
try {
|
|
147
|
+
return await NativeReclaimInappModule.startVerification(request);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.info({
|
|
150
|
+
error
|
|
151
|
+
})
|
|
152
|
+
if (error instanceof Error) {
|
|
153
|
+
throw ReclaimVerificationApi.ReclaimVerificationException.fromError(error, request.session?.sessionId ?? "");
|
|
154
|
+
}
|
|
155
|
+
throw error
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async startVerificationFromUrl(requestUrl: string): Promise<ReclaimVerificationApi.Response> {
|
|
160
|
+
try {
|
|
161
|
+
return await NativeReclaimInappModule.startVerificationFromUrl(requestUrl);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.info({
|
|
164
|
+
error
|
|
165
|
+
})
|
|
166
|
+
if (error instanceof Error) {
|
|
167
|
+
throw ReclaimVerificationApi.ReclaimVerificationException.fromError(error, "");
|
|
168
|
+
}
|
|
169
|
+
throw error
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async ping(): Promise<boolean> {
|
|
174
|
+
return await NativeReclaimInappModule.ping();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private previousLogSubscription: EventSubscription | null = null;
|
|
178
|
+
private previousSessionManagementCancelCallback: null | (() => void) = null;
|
|
179
|
+
|
|
180
|
+
setOverrides({
|
|
181
|
+
provider,
|
|
182
|
+
featureOptions,
|
|
183
|
+
logConsumer,
|
|
184
|
+
sessionManagement,
|
|
185
|
+
appInfo
|
|
186
|
+
}: ReclaimVerificationApi.OverrideConfig) {
|
|
187
|
+
this.previousLogSubscription?.remove()
|
|
188
|
+
this.previousLogSubscription = null;
|
|
189
|
+
let callback = this.previousSessionManagementCancelCallback;
|
|
190
|
+
if (callback != null) {
|
|
191
|
+
callback();
|
|
192
|
+
}
|
|
193
|
+
this.previousSessionManagementCancelCallback = null;
|
|
194
|
+
|
|
195
|
+
let logConsumerRequest = logConsumer == null ? undefined : {
|
|
196
|
+
enableLogHandler: logConsumer?.onLogs != null,
|
|
197
|
+
canSdkCollectTelemetry: logConsumer?.canSdkCollectTelemetry,
|
|
198
|
+
canSdkPrintLogs: logConsumer?.canSdkPrintLogs
|
|
199
|
+
}
|
|
200
|
+
const onLogsListener = logConsumer?.onLogs;
|
|
201
|
+
if (onLogsListener != null) {
|
|
202
|
+
const cancel = () => {
|
|
203
|
+
this.previousLogSubscription?.remove();
|
|
204
|
+
this.previousLogSubscription = null;
|
|
205
|
+
};
|
|
206
|
+
this.previousLogSubscription = NativeReclaimInappModule.onLogs((arg) => {
|
|
207
|
+
onLogsListener(arg, cancel);
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let sessionManagementRequest = sessionManagement == null ? undefined : {
|
|
212
|
+
// A handler is provided, so we don't let SDK manage sessions
|
|
213
|
+
enableSdkSessionManagement: false
|
|
214
|
+
}
|
|
215
|
+
if (sessionManagement != null) {
|
|
216
|
+
let sessionCreateSubscription = NativeReclaimInappModule.onSessionCreateRequest(async (event) => {
|
|
217
|
+
const replyId = event.replyId;
|
|
218
|
+
let result = await sessionManagement.onSessionCreateRequest(event);
|
|
219
|
+
NativeReclaimInappModule.reply(replyId, result);
|
|
220
|
+
});
|
|
221
|
+
let sessionUpdateSubscription = NativeReclaimInappModule.onSessionUpdateRequest(async (event) => {
|
|
222
|
+
const replyId = event.replyId;
|
|
223
|
+
let result = await sessionManagement.onSessionUpdateRequest(event);
|
|
224
|
+
NativeReclaimInappModule.reply(replyId, result);
|
|
225
|
+
});
|
|
226
|
+
let sessionLogsSubscription = NativeReclaimInappModule.onSessionLogs((event) => {
|
|
227
|
+
sessionManagement.onLog(event);
|
|
228
|
+
});
|
|
229
|
+
const cancel = () => {
|
|
230
|
+
sessionCreateSubscription.remove()
|
|
231
|
+
sessionUpdateSubscription.remove()
|
|
232
|
+
sessionLogsSubscription.remove()
|
|
233
|
+
}
|
|
234
|
+
this.previousSessionManagementCancelCallback = cancel;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
NativeReclaimInappModule.setOverrides({
|
|
238
|
+
provider,
|
|
239
|
+
featureOptions,
|
|
240
|
+
logConsumer: logConsumerRequest,
|
|
241
|
+
sessionManagement: sessionManagementRequest,
|
|
242
|
+
appInfo
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReclaimVerificationPlatformChannel, type ReclaimVerificationApi } from './ReclaimVerificationPlatformChannel';
|
|
2
|
+
export { ReclaimVerificationPlatformChannel, ReclaimVerificationApi } from './ReclaimVerificationPlatformChannel';
|
|
3
|
+
export type { ReclaimVerificationApi as ReclaimVerificationApiType } from './ReclaimVerificationPlatformChannel';
|
|
4
|
+
|
|
5
|
+
export class ReclaimVerification {
|
|
6
|
+
public channel: ReclaimVerificationPlatformChannel;
|
|
7
|
+
|
|
8
|
+
private static defaultChannel: ReclaimVerificationPlatformChannel | null = null;
|
|
9
|
+
|
|
10
|
+
public constructor(channel?: ReclaimVerificationPlatformChannel) {
|
|
11
|
+
if (channel) {
|
|
12
|
+
this.channel = channel;
|
|
13
|
+
} else {
|
|
14
|
+
if (ReclaimVerification.defaultChannel == null) {
|
|
15
|
+
ReclaimVerification.defaultChannel = new ReclaimVerificationPlatformChannel();
|
|
16
|
+
}
|
|
17
|
+
this.channel = ReclaimVerification.defaultChannel;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public async startVerification(request: ReclaimVerificationApi.Request): Promise<ReclaimVerificationApi.Response> {
|
|
22
|
+
return this.channel.startVerification(request);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public async ping(): Promise<boolean> {
|
|
26
|
+
return this.channel.ping();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public setOverrides(overrides: ReclaimVerificationApi.OverrideConfig) {
|
|
30
|
+
this.channel.setOverrides(overrides);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
|
|
5
|
+
export interface SessionInformation {
|
|
6
|
+
/**
|
|
7
|
+
* The timestamp of the session creation.
|
|
8
|
+
*
|
|
9
|
+
* Represented as a string from number of milliseconds since
|
|
10
|
+
* the "Unix epoch" 1970-01-01T00:00:00Z (UTC).
|
|
11
|
+
*
|
|
12
|
+
* This value is independent of the time zone.
|
|
13
|
+
*
|
|
14
|
+
* This value is at most 8,640,000,000,000,000ms (100,000,000 days) from the Unix epoch.
|
|
15
|
+
*/
|
|
16
|
+
timestamp: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Unique identifier for the verification session
|
|
20
|
+
*/
|
|
21
|
+
sessionId: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Cryptographic signature to validate the session
|
|
25
|
+
*/
|
|
26
|
+
signature: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Represents a request for a verification attempt.
|
|
30
|
+
*
|
|
31
|
+
* You can create a request using the [ReclaimVerification.Request] constructor or the [ReclaimVerification.Request.fromManifestMetaData] factory method.
|
|
32
|
+
*/
|
|
33
|
+
export interface Request {
|
|
34
|
+
/**
|
|
35
|
+
* The Reclaim application ID for the verification process.
|
|
36
|
+
* If not provided, the appId will be fetched from:
|
|
37
|
+
* - the `AndroidManifest.xml` metadata along with secret on android:
|
|
38
|
+
*
|
|
39
|
+
* ```xml
|
|
40
|
+
* <meta-data android:name="org.reclaimprotocol.inapp_sdk.APP_ID"
|
|
41
|
+
* android:value="YOUR_RECLAIM_APP_ID" />
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* - the `ReclaimInAppSDKParam.ReclaimAppId` in Info.plist along with secret on iOS:
|
|
45
|
+
*
|
|
46
|
+
* ```xml
|
|
47
|
+
* <key>ReclaimInAppSDKParam</key>
|
|
48
|
+
* <dict>
|
|
49
|
+
* <key>ReclaimAppId</key>
|
|
50
|
+
* <string>YOUR_RECLAIM_APP_ID</string>
|
|
51
|
+
* <key>ReclaimAppSecret</key>
|
|
52
|
+
* <string>YOUR_RECLAIM_APP_SECRET</string>
|
|
53
|
+
* </dict>
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
appId: string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The Reclaim application secret for the verification process.
|
|
60
|
+
* If not provided, the secret will be fetched from:
|
|
61
|
+
* - the `AndroidManifest.xml` metadata along with appId on android:
|
|
62
|
+
*
|
|
63
|
+
* ```xml
|
|
64
|
+
* <meta-data android:name="org.reclaimprotocol.inapp_sdk.APP_SECRET"
|
|
65
|
+
* android:value="YOUR_RECLAIM_APP_SECRET" />
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* - the `ReclaimInAppSDKParam.ReclaimAppSecret` in Info.plist along with appId on iOS:
|
|
69
|
+
*
|
|
70
|
+
* ```xml
|
|
71
|
+
* <key>ReclaimInAppSDKParam</key>
|
|
72
|
+
* <dict>
|
|
73
|
+
* <key>ReclaimAppId</key>
|
|
74
|
+
* <string>YOUR_RECLAIM_APP_ID</string>
|
|
75
|
+
* <key>ReclaimAppSecret</key>
|
|
76
|
+
* <string>YOUR_RECLAIM_APP_SECRET</string>
|
|
77
|
+
* </dict>
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
secret: string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The identifier for the Reclaim data provider to use in verification
|
|
84
|
+
*/
|
|
85
|
+
providerId: string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Optional session information. If nil, SDK generates new session details.
|
|
89
|
+
*/
|
|
90
|
+
session?: SessionInformation | null; // Allow null as well
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Additional data to associate with the verification attempt
|
|
94
|
+
*/
|
|
95
|
+
contextString?: string; // Optional
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Key-value pairs for prefilling claim creation variables
|
|
99
|
+
*/
|
|
100
|
+
parameters?: { [key: string]: string }; // Use index signature for Map
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Whether to hide the landing page of the verification process. When false, shows an introductory page with claims to be proven.
|
|
104
|
+
*/
|
|
105
|
+
hideLanding?: boolean; // Optional
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Whether to automatically submit the proof after generation.
|
|
109
|
+
*/
|
|
110
|
+
autoSubmit?: boolean; // Optional
|
|
111
|
+
|
|
112
|
+
acceptAiProviders?: boolean; // Optional
|
|
113
|
+
webhookUrl?: string | null; // Optional and nullable
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Contains the proof and response data after verification
|
|
118
|
+
*/
|
|
119
|
+
export interface Response {
|
|
120
|
+
/**
|
|
121
|
+
* The session ID for the verification attempt
|
|
122
|
+
*/
|
|
123
|
+
sessionId: string;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Whether the proof was submitted manually
|
|
127
|
+
*/
|
|
128
|
+
didSubmitManualVerification: boolean;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The list of proofs generated during the verification attempt
|
|
132
|
+
*/
|
|
133
|
+
proofs: { [key: string]: any }[]; // Array of dictionaries
|
|
134
|
+
// proofs: string[]; // Array of dictionaries
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface ProviderInformation {
|
|
138
|
+
url?: string;
|
|
139
|
+
jsonString?: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Interface representing Feature Options.
|
|
144
|
+
*/
|
|
145
|
+
export interface FeatureOptions {
|
|
146
|
+
/**
|
|
147
|
+
* Whether to persist a cookie.
|
|
148
|
+
* Optional, defaults to null.
|
|
149
|
+
*/
|
|
150
|
+
cookiePersist?: boolean | null;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Whether to allow a single reclaim request.
|
|
154
|
+
* Optional, defaults to null.
|
|
155
|
+
*/
|
|
156
|
+
singleReclaimRequest?: boolean | null;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Idle time threshold (in milliseconds?) for triggering manual verification.
|
|
160
|
+
* Optional, defaults to null.
|
|
161
|
+
*/
|
|
162
|
+
idleTimeThresholdForManualVerificationTrigger?: number | null;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Session timeout (in milliseconds?) for triggering manual verification.
|
|
166
|
+
* Optional, defaults to null.
|
|
167
|
+
*/
|
|
168
|
+
sessionTimeoutForManualVerificationTrigger?: number | null;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* URL for the Attestor Browser RPC.
|
|
172
|
+
* Optional, defaults to null.
|
|
173
|
+
*/
|
|
174
|
+
attestorBrowserRpcUrl?: string | null;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Whether response redaction regex escaping is enabled.
|
|
178
|
+
* Optional, defaults to null.
|
|
179
|
+
*/
|
|
180
|
+
isResponseRedactionRegexEscapingEnabled?: boolean | null;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Whether AI flow is enabled.
|
|
184
|
+
* Optional, defaults to null.
|
|
185
|
+
*/
|
|
186
|
+
isAIFlowEnabled?: boolean | null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface LogConsumer {
|
|
190
|
+
/**
|
|
191
|
+
* Handler for consuming logs exported from the SDK.
|
|
192
|
+
* Defaults to false.
|
|
193
|
+
*/
|
|
194
|
+
enableLogHandler: boolean;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* When enabled, logs are sent to reclaim that can be used to help you.
|
|
198
|
+
* Defaults to true.
|
|
199
|
+
*/
|
|
200
|
+
canSdkCollectTelemetry?: boolean;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Defaults to enabled when not in release mode.
|
|
204
|
+
*/
|
|
205
|
+
canSdkPrintLogs?: boolean;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Interface representing Reclaim App Information.
|
|
210
|
+
*/
|
|
211
|
+
export interface ReclaimAppInfo {
|
|
212
|
+
/**
|
|
213
|
+
* The name of the application.
|
|
214
|
+
*/
|
|
215
|
+
appName: string;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* The URL of the application's image.
|
|
219
|
+
*/
|
|
220
|
+
appImageUrl: string;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Whether the reclaim is recurring.
|
|
224
|
+
* Optional, defaults to false.
|
|
225
|
+
*/
|
|
226
|
+
isRecurring?: boolean;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface SessionManagement {
|
|
230
|
+
/**
|
|
231
|
+
* Whether to enable SDK session management.
|
|
232
|
+
* Optional, defaults to true.
|
|
233
|
+
*
|
|
234
|
+
* When false, a handler must be provided. We'll not let SDK manage sessions in this case.
|
|
235
|
+
*/
|
|
236
|
+
enableSdkSessionManagement?: boolean;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface SessionLogEvent {
|
|
240
|
+
/**
|
|
241
|
+
* The app ID for the verification attempt
|
|
242
|
+
*/
|
|
243
|
+
appId: string;
|
|
244
|
+
/**
|
|
245
|
+
* The provider ID for the verification attempt
|
|
246
|
+
*/
|
|
247
|
+
providerId: string;
|
|
248
|
+
/**
|
|
249
|
+
* The session ID for the verification attempt
|
|
250
|
+
*/
|
|
251
|
+
sessionId: string;
|
|
252
|
+
/**
|
|
253
|
+
* The type of log event
|
|
254
|
+
*/
|
|
255
|
+
logType: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface SessionCreateRequestEvent {
|
|
259
|
+
/**
|
|
260
|
+
* The app ID for the verification attempt
|
|
261
|
+
*/
|
|
262
|
+
appId: string;
|
|
263
|
+
/**
|
|
264
|
+
* The provider ID for the verification attempt
|
|
265
|
+
*/
|
|
266
|
+
providerId: string;
|
|
267
|
+
/**
|
|
268
|
+
* The session ID for the verification attempt
|
|
269
|
+
*/
|
|
270
|
+
sessionId: string;
|
|
271
|
+
/**
|
|
272
|
+
* internal
|
|
273
|
+
*/
|
|
274
|
+
readonly replyId: string;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface SessionUpdateRequestEvent {
|
|
278
|
+
/**
|
|
279
|
+
* The session ID for the verification attempt
|
|
280
|
+
*/
|
|
281
|
+
sessionId: string;
|
|
282
|
+
/**
|
|
283
|
+
* The status type of this session event
|
|
284
|
+
*/
|
|
285
|
+
status: string;
|
|
286
|
+
/**
|
|
287
|
+
* internal
|
|
288
|
+
*/
|
|
289
|
+
readonly replyId: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface Overrides {
|
|
293
|
+
provider?: ProviderInformation | null,
|
|
294
|
+
featureOptions?: FeatureOptions | null,
|
|
295
|
+
logConsumer?: LogConsumer | null,
|
|
296
|
+
sessionManagement?: SessionManagement | null,
|
|
297
|
+
appInfo?: ReclaimAppInfo | null
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface Spec extends TurboModule {
|
|
301
|
+
startVerification(request: Request): Promise<Response>;
|
|
302
|
+
startVerificationFromUrl(requestUrl: string): Promise<Response>;
|
|
303
|
+
setOverrides(overrides: Overrides): Promise<void>;
|
|
304
|
+
reply(replyId: string, reply: boolean): void;
|
|
305
|
+
ping(): Promise<boolean>;
|
|
306
|
+
|
|
307
|
+
readonly onLogs: EventEmitter<string>
|
|
308
|
+
readonly onSessionLogs: EventEmitter<SessionLogEvent>
|
|
309
|
+
readonly onSessionCreateRequest: EventEmitter<SessionCreateRequestEvent>
|
|
310
|
+
readonly onSessionUpdateRequest: EventEmitter<SessionUpdateRequestEvent>
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('InappRnSdk');
|