@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/platform.ts
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import type { EventSubscription } from "react-native";
|
|
2
|
-
import NativeReclaimInappModule from "./specs/NativeInappRnSdk";
|
|
3
|
-
import * as NativeReclaimInappModuleTypes from "./specs/NativeInappRnSdk";
|
|
4
|
-
import { ReclaimVerification } from "./index";
|
|
5
|
-
|
|
6
|
-
export class PlatformImpl extends ReclaimVerification.Platform {
|
|
7
|
-
override async startVerification(request: ReclaimVerification.Request): Promise<ReclaimVerification.Response> {
|
|
8
|
-
try {
|
|
9
|
-
const response = await NativeReclaimInappModule.startVerification(request);
|
|
10
|
-
return {
|
|
11
|
-
...response,
|
|
12
|
-
proofs: ReclaimVerification.ReclaimResult.asProofs(response.proofs),
|
|
13
|
-
}
|
|
14
|
-
} catch (error) {
|
|
15
|
-
console.info({
|
|
16
|
-
error
|
|
17
|
-
})
|
|
18
|
-
if (error instanceof Error) {
|
|
19
|
-
throw ReclaimVerification.ReclaimVerificationException.fromError(error, request.session?.sessionId ?? "");
|
|
20
|
-
}
|
|
21
|
-
throw error
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
override async startVerificationFromUrl(requestUrl: string): Promise<ReclaimVerification.Response> {
|
|
26
|
-
try {
|
|
27
|
-
const response = await NativeReclaimInappModule.startVerificationFromUrl(requestUrl);
|
|
28
|
-
return {
|
|
29
|
-
...response,
|
|
30
|
-
proofs: ReclaimVerification.ReclaimResult.asProofs(response.proofs),
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.info({
|
|
34
|
-
error
|
|
35
|
-
})
|
|
36
|
-
if (error instanceof Error) {
|
|
37
|
-
throw ReclaimVerification.ReclaimVerificationException.fromError(error, "");
|
|
38
|
-
}
|
|
39
|
-
throw error
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
override async ping(): Promise<boolean> {
|
|
44
|
-
return await NativeReclaimInappModule.ping();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private previousSessionManagementCancelCallback: null | (() => void) = null;
|
|
48
|
-
disposeSessionManagement() {
|
|
49
|
-
let callback = this.previousSessionManagementCancelCallback;
|
|
50
|
-
if (callback != null && callback != undefined) {
|
|
51
|
-
callback();
|
|
52
|
-
}
|
|
53
|
-
this.previousSessionManagementCancelCallback = null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private previousLogSubscription: EventSubscription | null = null;
|
|
57
|
-
disposeLogListener() {
|
|
58
|
-
this.previousLogSubscription?.remove()
|
|
59
|
-
this.previousLogSubscription = null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private previousProviderRequestCancelCallback: null | (() => void) = null;
|
|
63
|
-
private disposeProviderRequestListener() {
|
|
64
|
-
let callback = this.previousProviderRequestCancelCallback;
|
|
65
|
-
if (callback != null && callback != undefined) {
|
|
66
|
-
callback();
|
|
67
|
-
}
|
|
68
|
-
this.previousProviderRequestCancelCallback = null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
override async setOverrides({
|
|
72
|
-
provider,
|
|
73
|
-
featureOptions,
|
|
74
|
-
logConsumer,
|
|
75
|
-
sessionManagement,
|
|
76
|
-
appInfo,
|
|
77
|
-
capabilityAccessToken
|
|
78
|
-
}: ReclaimVerification.OverrideConfig) {
|
|
79
|
-
let providerCallback = provider?.callback;
|
|
80
|
-
let providerOverride = !provider ? null : {
|
|
81
|
-
url: provider?.url,
|
|
82
|
-
jsonString: provider?.jsonString,
|
|
83
|
-
canFetchProviderInformationFromHost: !!providerCallback,
|
|
84
|
-
}
|
|
85
|
-
if (providerCallback) {
|
|
86
|
-
this.disposeProviderRequestListener();
|
|
87
|
-
let providerRequestSubscription = NativeReclaimInappModule.onProviderInformationRequest(async (event) => {
|
|
88
|
-
try {
|
|
89
|
-
let result = await providerCallback(event);
|
|
90
|
-
NativeReclaimInappModule.replyWithString(event.replyId, result);
|
|
91
|
-
} catch (error) {
|
|
92
|
-
console.error(error);
|
|
93
|
-
NativeReclaimInappModule.replyWithString(event.replyId, "");
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
const cancel = () => {
|
|
97
|
-
providerRequestSubscription.remove();
|
|
98
|
-
}
|
|
99
|
-
this.previousProviderRequestCancelCallback = cancel;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const onLogsListener = logConsumer?.onLogs;
|
|
103
|
-
let logConsumerRequest = !logConsumer ? undefined : {
|
|
104
|
-
enableLogHandler: !!onLogsListener,
|
|
105
|
-
canSdkCollectTelemetry: logConsumer?.canSdkCollectTelemetry,
|
|
106
|
-
canSdkPrintLogs: logConsumer?.canSdkPrintLogs
|
|
107
|
-
}
|
|
108
|
-
if (onLogsListener) {
|
|
109
|
-
this.disposeLogListener();
|
|
110
|
-
const cancel = () => {
|
|
111
|
-
this.previousLogSubscription?.remove();
|
|
112
|
-
this.previousLogSubscription = null;
|
|
113
|
-
};
|
|
114
|
-
this.previousLogSubscription = NativeReclaimInappModule.onLogs((arg) => {
|
|
115
|
-
onLogsListener(arg, cancel);
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
let sessionManagementRequest = !sessionManagement ? undefined : {
|
|
120
|
-
// A handler is provided, so we don't let SDK manage sessions
|
|
121
|
-
enableSdkSessionManagement: false
|
|
122
|
-
}
|
|
123
|
-
if (sessionManagement) {
|
|
124
|
-
this.disposeSessionManagement();
|
|
125
|
-
let sessionCreateSubscription = NativeReclaimInappModule.onSessionCreateRequest(async (event) => {
|
|
126
|
-
const replyId = event.replyId;
|
|
127
|
-
try {
|
|
128
|
-
let result = await sessionManagement.onSessionCreateRequest(event);
|
|
129
|
-
NativeReclaimInappModule.reply(replyId, result);
|
|
130
|
-
} catch (error) {
|
|
131
|
-
console.error(error);
|
|
132
|
-
NativeReclaimInappModule.reply(replyId, false);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
let sessionUpdateSubscription = NativeReclaimInappModule.onSessionUpdateRequest(async (event) => {
|
|
136
|
-
const replyId = event.replyId;
|
|
137
|
-
try {
|
|
138
|
-
let result = await sessionManagement.onSessionUpdateRequest(event);
|
|
139
|
-
NativeReclaimInappModule.reply(replyId, result);
|
|
140
|
-
} catch (error) {
|
|
141
|
-
console.error(error);
|
|
142
|
-
NativeReclaimInappModule.reply(replyId, false);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
let sessionLogsSubscription = NativeReclaimInappModule.onSessionLogs((event) => {
|
|
146
|
-
try {
|
|
147
|
-
sessionManagement.onLog(event);
|
|
148
|
-
} catch (error) {
|
|
149
|
-
console.error(error);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
const cancel = () => {
|
|
153
|
-
sessionCreateSubscription.remove()
|
|
154
|
-
sessionUpdateSubscription.remove()
|
|
155
|
-
sessionLogsSubscription.remove()
|
|
156
|
-
}
|
|
157
|
-
this.previousSessionManagementCancelCallback = cancel;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
try {
|
|
161
|
-
return await NativeReclaimInappModule.setOverrides({
|
|
162
|
-
provider: providerOverride,
|
|
163
|
-
featureOptions,
|
|
164
|
-
logConsumer: logConsumerRequest,
|
|
165
|
-
sessionManagement: sessionManagementRequest,
|
|
166
|
-
appInfo,
|
|
167
|
-
capabilityAccessToken
|
|
168
|
-
});
|
|
169
|
-
} catch (error) {
|
|
170
|
-
throw new ReclaimVerification.ReclaimPlatformException("Failed to set overrides", error as Error);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
override async clearAllOverrides() {
|
|
175
|
-
this.disposeProviderRequestListener();
|
|
176
|
-
this.disposeLogListener();
|
|
177
|
-
this.disposeSessionManagement();
|
|
178
|
-
return NativeReclaimInappModule.clearAllOverrides();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
private previousAttestorAuthRequestCancelCallback: null | (() => void) = null;
|
|
182
|
-
disposeAttestorAuthRequestListener() {
|
|
183
|
-
let callback = this.previousAttestorAuthRequestCancelCallback;
|
|
184
|
-
if (callback != null && callback != undefined) {
|
|
185
|
-
callback();
|
|
186
|
-
}
|
|
187
|
-
this.previousAttestorAuthRequestCancelCallback = null;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
override async setVerificationOptions(options?: ReclaimVerification.VerificationOptions | null): Promise<void> {
|
|
191
|
-
let args: NativeReclaimInappModuleTypes.VerificationOptions | null = null
|
|
192
|
-
if (options) {
|
|
193
|
-
let canUseAttestorAuthenticationRequest = options.fetchAttestorAuthenticationRequest != null
|
|
194
|
-
args = {
|
|
195
|
-
canDeleteCookiesBeforeVerificationStarts: options.canDeleteCookiesBeforeVerificationStarts,
|
|
196
|
-
canUseAttestorAuthenticationRequest: canUseAttestorAuthenticationRequest,
|
|
197
|
-
}
|
|
198
|
-
if (canUseAttestorAuthenticationRequest) {
|
|
199
|
-
this.disposeAttestorAuthRequestListener();
|
|
200
|
-
let attestorAuthRequestSubscription = NativeReclaimInappModule.onReclaimAttestorAuthRequest(async (event) => {
|
|
201
|
-
let result = await options.fetchAttestorAuthenticationRequest(event.reclaimHttpProviderJsonString);
|
|
202
|
-
NativeReclaimInappModule.replyWithString(event.replyId, result);
|
|
203
|
-
});
|
|
204
|
-
const cancel = () => {
|
|
205
|
-
attestorAuthRequestSubscription.remove();
|
|
206
|
-
}
|
|
207
|
-
this.previousAttestorAuthRequestCancelCallback = cancel;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
try {
|
|
211
|
-
return await NativeReclaimInappModule.setVerificationOptions({
|
|
212
|
-
options: args
|
|
213
|
-
});
|
|
214
|
-
} catch (error) {
|
|
215
|
-
throw new ReclaimVerification.ReclaimPlatformException("Failed to set verification options", error as Error);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|