@kyciris/core 0.1.0 → 0.1.1
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/dist/index.d.mts +207 -2
- package/dist/index.d.ts +207 -2
- package/dist/index.js +269 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +269 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable, platform-agnostic key/value storage used to persist the verification
|
|
3
|
+
* session so a paused flow survives the app being closed.
|
|
4
|
+
*
|
|
5
|
+
* Inject a concrete implementation: AsyncStorage on React Native, or an adapter
|
|
6
|
+
* around localStorage on web. Methods may be sync or async; results are awaited.
|
|
7
|
+
*/
|
|
8
|
+
interface KYCStorage {
|
|
9
|
+
/** Returns the stored value for a key, or null if absent */
|
|
10
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
11
|
+
/** Persists a value for a key */
|
|
12
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
13
|
+
/** Removes a stored key */
|
|
14
|
+
removeItem(key: string): void | Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The persisted verification session, used to resume an in-flight verification.
|
|
18
|
+
*/
|
|
19
|
+
interface KYCSession {
|
|
20
|
+
/** Identity ID owning the verification */
|
|
21
|
+
identityId: string;
|
|
22
|
+
/** Verification ID being completed */
|
|
23
|
+
verificationId: string;
|
|
24
|
+
/** External reference ID provided when starting (if any) */
|
|
25
|
+
externalId?: string;
|
|
26
|
+
/** Document type for the verification */
|
|
27
|
+
documentType?: 'IDENTITY_CARD' | 'DRIVING_LICENSE';
|
|
28
|
+
}
|
|
1
29
|
/**
|
|
2
30
|
* Credentials required to initialize the KYC SDK
|
|
3
31
|
*/
|
|
@@ -6,6 +34,11 @@ interface KYCCredentials {
|
|
|
6
34
|
apiKey: string;
|
|
7
35
|
/** Base URL of the KYC API */
|
|
8
36
|
baseUrl: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional storage adapter. When provided, the SDK persists the verification
|
|
39
|
+
* session on startVerification and reads it back to resume a paused flow.
|
|
40
|
+
*/
|
|
41
|
+
storage?: KYCStorage;
|
|
9
42
|
}
|
|
10
43
|
/**
|
|
11
44
|
* Parameters required to start a verification session
|
|
@@ -20,6 +53,24 @@ interface StartVerificationParams {
|
|
|
20
53
|
/** Optional external reference ID */
|
|
21
54
|
externalId?: string;
|
|
22
55
|
}
|
|
56
|
+
interface FaceMatchVerificationParams {
|
|
57
|
+
/** The identity ID to perform face match on */
|
|
58
|
+
identityId: string;
|
|
59
|
+
/** Base64 encoded image data, data URI, or file:// URI */
|
|
60
|
+
file: string;
|
|
61
|
+
/** MIME type of the image (default: image/jpeg) */
|
|
62
|
+
mimeType?: string;
|
|
63
|
+
}
|
|
64
|
+
interface FaceMatchStatusParams {
|
|
65
|
+
/** The identity ID to check face match status for */
|
|
66
|
+
identityId: string;
|
|
67
|
+
/** The face check ID from the face match verification response */
|
|
68
|
+
faceCheckId: string;
|
|
69
|
+
/** Polling interval in milliseconds (default: 3000) */
|
|
70
|
+
interval?: number;
|
|
71
|
+
/** Maximum time to wait in milliseconds (default: 120000) */
|
|
72
|
+
timeout?: number;
|
|
73
|
+
}
|
|
23
74
|
/**
|
|
24
75
|
* Response from starting a verification session
|
|
25
76
|
*/
|
|
@@ -61,6 +112,23 @@ interface UploadResult {
|
|
|
61
112
|
message: string;
|
|
62
113
|
/** Current status after upload */
|
|
63
114
|
status: string;
|
|
115
|
+
/** True when the step was already uploaded and the call was a no-op */
|
|
116
|
+
skipped?: boolean;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Parameters for uploading a single verification step in a resume-aware way.
|
|
120
|
+
*/
|
|
121
|
+
interface UploadStepParams {
|
|
122
|
+
/** The step to upload */
|
|
123
|
+
step: VerificationStep;
|
|
124
|
+
/** Base64 encoded image data, data URI, or file:// URI (React Native) */
|
|
125
|
+
imageData: string;
|
|
126
|
+
/** Verification ID to attach to; falls back to the persisted session */
|
|
127
|
+
verificationId?: string;
|
|
128
|
+
/** Identity ID used to skip already-uploaded steps; falls back to the persisted session */
|
|
129
|
+
identityId?: string;
|
|
130
|
+
/** MIME type of the image (default: image/jpeg) */
|
|
131
|
+
mimeType?: string;
|
|
64
132
|
}
|
|
65
133
|
/** Current status of a verification session */
|
|
66
134
|
interface VerificationStatus {
|
|
@@ -88,6 +156,73 @@ interface VerificationStatus {
|
|
|
88
156
|
/** When the verification was last updated */
|
|
89
157
|
updatedAt: string;
|
|
90
158
|
}
|
|
159
|
+
/** A single verification record as stored under an identity */
|
|
160
|
+
interface VerificationRecord {
|
|
161
|
+
/** Verification ID */
|
|
162
|
+
id: string;
|
|
163
|
+
/** Current verification status */
|
|
164
|
+
status: string;
|
|
165
|
+
/** External reference ID (if provided when starting) */
|
|
166
|
+
externalId: string | null;
|
|
167
|
+
/** Type of document being verified */
|
|
168
|
+
documentType: 'IDENTITY_CARD' | 'DRIVING_LICENSE';
|
|
169
|
+
/** Country code */
|
|
170
|
+
country: string;
|
|
171
|
+
/** Face match similarity score (0-1) */
|
|
172
|
+
faceMatchScore: number | null;
|
|
173
|
+
/** OCR extracted data from document */
|
|
174
|
+
ocrData: Record<string, any> | null;
|
|
175
|
+
/** Stored path of the uploaded selfie, or null if not uploaded yet */
|
|
176
|
+
selfiePath: string | null;
|
|
177
|
+
/** Stored path of the uploaded document front, or null if not uploaded yet */
|
|
178
|
+
documentFrontPath: string | null;
|
|
179
|
+
/** Stored path of the uploaded document back, or null if not uploaded yet */
|
|
180
|
+
documentBackPath: string | null;
|
|
181
|
+
/** Stored path of the document face crop, or null if not available */
|
|
182
|
+
documentFacePath: string | null;
|
|
183
|
+
/** Reason for rejection, if rejected */
|
|
184
|
+
rejectionReason: string | null;
|
|
185
|
+
/** Type of rejection, if rejected */
|
|
186
|
+
rejectionType: string | null;
|
|
187
|
+
/** When the verification was created */
|
|
188
|
+
createdAt: string;
|
|
189
|
+
/** When the verification was last updated */
|
|
190
|
+
updatedAt: string;
|
|
191
|
+
}
|
|
192
|
+
/** An identity with its associated verifications */
|
|
193
|
+
interface Identity {
|
|
194
|
+
/** Unique identity ID */
|
|
195
|
+
id: string;
|
|
196
|
+
/** Verifications linked to this identity */
|
|
197
|
+
verifications: VerificationRecord[];
|
|
198
|
+
/** When the identity was created */
|
|
199
|
+
createdAt: string;
|
|
200
|
+
/** When the identity was last updated */
|
|
201
|
+
updatedAt: string;
|
|
202
|
+
/** Additional OCR / identity fields */
|
|
203
|
+
[key: string]: any;
|
|
204
|
+
}
|
|
205
|
+
/** A single step a user must complete in a verification flow */
|
|
206
|
+
type VerificationStep = 'selfie' | 'document_front' | 'document_back';
|
|
207
|
+
/** Computed progress of an in-flight verification, used to resume a paused flow */
|
|
208
|
+
interface VerificationProgress {
|
|
209
|
+
/** Verification ID the progress refers to */
|
|
210
|
+
verificationId: string;
|
|
211
|
+
/** Document type for this verification */
|
|
212
|
+
documentType: 'IDENTITY_CARD' | 'DRIVING_LICENSE';
|
|
213
|
+
/** Current verification status */
|
|
214
|
+
status: string;
|
|
215
|
+
/** Whether the selfie has already been uploaded */
|
|
216
|
+
selfieUploaded: boolean;
|
|
217
|
+
/** Whether the document front has already been uploaded */
|
|
218
|
+
documentFrontUploaded: boolean;
|
|
219
|
+
/** Whether the document back has already been uploaded (always false for single-sided docs) */
|
|
220
|
+
documentBackUploaded: boolean;
|
|
221
|
+
/** Steps still required to finish, in the order they should be collected */
|
|
222
|
+
missingSteps: VerificationStep[];
|
|
223
|
+
/** True when no steps remain to be uploaded */
|
|
224
|
+
isComplete: boolean;
|
|
225
|
+
}
|
|
91
226
|
/** Event emitted when KYC status changes */
|
|
92
227
|
interface KYCStatusEvent {
|
|
93
228
|
/** Type of event: statusChanged or error */
|
|
@@ -122,11 +257,29 @@ declare class KYCCore {
|
|
|
122
257
|
private client;
|
|
123
258
|
private credentials;
|
|
124
259
|
private eventCallbacks;
|
|
260
|
+
private storage?;
|
|
261
|
+
/** Storage key under which the active verification session is persisted */
|
|
262
|
+
private static readonly SESSION_KEY;
|
|
125
263
|
/**
|
|
126
264
|
* Creates a new KYC Core instance
|
|
127
|
-
* @param credentials API credentials (apiKey and
|
|
265
|
+
* @param credentials API credentials (apiKey, baseUrl, and optional storage)
|
|
128
266
|
*/
|
|
129
267
|
constructor(credentials: KYCCredentials);
|
|
268
|
+
/**
|
|
269
|
+
* Persists the active verification session via the injected storage adapter.
|
|
270
|
+
* No-op when no storage was provided.
|
|
271
|
+
*/
|
|
272
|
+
private saveSession;
|
|
273
|
+
/**
|
|
274
|
+
* Reads the persisted verification session, or null if none exists or no
|
|
275
|
+
* storage adapter was provided.
|
|
276
|
+
*/
|
|
277
|
+
getSession(): Promise<KYCSession | null>;
|
|
278
|
+
/**
|
|
279
|
+
* Clears the persisted verification session. Call this once a verification is
|
|
280
|
+
* fully complete so the next flow starts fresh.
|
|
281
|
+
*/
|
|
282
|
+
clearSession(): Promise<void>;
|
|
130
283
|
/**
|
|
131
284
|
* Registers a callback for KYC status events
|
|
132
285
|
* @param callback Function to call when status changes
|
|
@@ -172,6 +325,58 @@ declare class KYCCore {
|
|
|
172
325
|
* @returns Current verification status including OCR data and face match score
|
|
173
326
|
*/
|
|
174
327
|
getStatus(verificationId: string): Promise<VerificationStatus>;
|
|
328
|
+
/**
|
|
329
|
+
* Fetches an identity along with all of its verification records.
|
|
330
|
+
* @param identityId The identity ID to fetch
|
|
331
|
+
* @returns The identity, including the verifications array with upload paths
|
|
332
|
+
*/
|
|
333
|
+
getIdentity(identityId: string): Promise<Identity>;
|
|
334
|
+
/**
|
|
335
|
+
* Returns the required steps for a given document type, in collection order.
|
|
336
|
+
* ID cards require both sides; driving licenses are single-sided.
|
|
337
|
+
*/
|
|
338
|
+
private getRequiredSteps;
|
|
339
|
+
/**
|
|
340
|
+
* Computes which steps a user has already completed and which are still missing
|
|
341
|
+
* for a verification, so a paused flow can be resumed without re-uploading.
|
|
342
|
+
*
|
|
343
|
+
* Both arguments are optional: when omitted they fall back to the persisted
|
|
344
|
+
* session (see the storage adapter). Pass a verificationId to target a specific
|
|
345
|
+
* verification; otherwise the most recently updated verification is used.
|
|
346
|
+
*
|
|
347
|
+
* @param identityId Identity ID owning the verification (defaults to the session)
|
|
348
|
+
* @param verificationId Verification ID to target (defaults to the session)
|
|
349
|
+
* @returns Progress describing uploaded steps and the steps still required
|
|
350
|
+
*/
|
|
351
|
+
getVerificationProgress(identityId?: string, verificationId?: string): Promise<VerificationProgress>;
|
|
352
|
+
/**
|
|
353
|
+
* Returns whether every required step of a verification has already been
|
|
354
|
+
* uploaded (both document sides where applicable, plus the selfie).
|
|
355
|
+
*
|
|
356
|
+
* This is the reliable way to tell a user who has fully submitted their
|
|
357
|
+
* documents (verification is now processing on the KYC backend) apart from one
|
|
358
|
+
* who paused mid-flow with steps still missing — both look "PENDING" from the
|
|
359
|
+
* outside. Derived purely from the identity's verification records.
|
|
360
|
+
*
|
|
361
|
+
* Returns `false` (rather than throwing) when the identity has no verification
|
|
362
|
+
* records yet, so callers can treat "nothing uploaded" as "documents missing".
|
|
363
|
+
*
|
|
364
|
+
* @param identityId Identity ID owning the verification (defaults to the session)
|
|
365
|
+
* @param verificationId Verification ID to target (defaults to the most recently updated)
|
|
366
|
+
* @returns True when no steps remain to be uploaded
|
|
367
|
+
*/
|
|
368
|
+
hasAllDocuments(identityId?: string, verificationId?: string): Promise<boolean>;
|
|
369
|
+
/**
|
|
370
|
+
* Uploads a single verification step (selfie, document front, or document back)
|
|
371
|
+
* in a resume-aware way: it resolves the verification from the persisted session
|
|
372
|
+
* when not given, and skips the upload if that step is already complete.
|
|
373
|
+
*
|
|
374
|
+
* @param params The step, image data, and optional verification/identity overrides
|
|
375
|
+
* @returns The upload result; `skipped` is true when the step was already uploaded
|
|
376
|
+
*/
|
|
377
|
+
uploadStep(params: UploadStepParams): Promise<UploadResult>;
|
|
378
|
+
faceMatchVerification(params: FaceMatchVerificationParams): Promise<any>;
|
|
379
|
+
faceMatchStatus({ identityId, faceCheckId, interval, timeout, }: FaceMatchStatusParams): Promise<VerificationStatus>;
|
|
175
380
|
/**
|
|
176
381
|
* Polls for verification status until completion or timeout
|
|
177
382
|
* @param verificationId The verification ID to check
|
|
@@ -194,4 +399,4 @@ declare class KYCCore {
|
|
|
194
399
|
*/
|
|
195
400
|
declare function createKYCClient(credentials: KYCCredentials): KYCCore;
|
|
196
401
|
|
|
197
|
-
export { KYCCore, type KYCCredentials, type KYCEventCallback, KYCSdkError, type KYCStatusEvent, type StartVerificationParams, type UploadDocumentParams, type UploadResult, type UploadSelfieParams, type VerificationSession, type VerificationStatus, createKYCClient };
|
|
402
|
+
export { type FaceMatchStatusParams, type FaceMatchVerificationParams, type Identity, KYCCore, type KYCCredentials, type KYCEventCallback, KYCSdkError, type KYCSession, type KYCStatusEvent, type KYCStorage, type StartVerificationParams, type UploadDocumentParams, type UploadResult, type UploadSelfieParams, type UploadStepParams, type VerificationProgress, type VerificationRecord, type VerificationSession, type VerificationStatus, type VerificationStep, createKYCClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable, platform-agnostic key/value storage used to persist the verification
|
|
3
|
+
* session so a paused flow survives the app being closed.
|
|
4
|
+
*
|
|
5
|
+
* Inject a concrete implementation: AsyncStorage on React Native, or an adapter
|
|
6
|
+
* around localStorage on web. Methods may be sync or async; results are awaited.
|
|
7
|
+
*/
|
|
8
|
+
interface KYCStorage {
|
|
9
|
+
/** Returns the stored value for a key, or null if absent */
|
|
10
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
11
|
+
/** Persists a value for a key */
|
|
12
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
13
|
+
/** Removes a stored key */
|
|
14
|
+
removeItem(key: string): void | Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The persisted verification session, used to resume an in-flight verification.
|
|
18
|
+
*/
|
|
19
|
+
interface KYCSession {
|
|
20
|
+
/** Identity ID owning the verification */
|
|
21
|
+
identityId: string;
|
|
22
|
+
/** Verification ID being completed */
|
|
23
|
+
verificationId: string;
|
|
24
|
+
/** External reference ID provided when starting (if any) */
|
|
25
|
+
externalId?: string;
|
|
26
|
+
/** Document type for the verification */
|
|
27
|
+
documentType?: 'IDENTITY_CARD' | 'DRIVING_LICENSE';
|
|
28
|
+
}
|
|
1
29
|
/**
|
|
2
30
|
* Credentials required to initialize the KYC SDK
|
|
3
31
|
*/
|
|
@@ -6,6 +34,11 @@ interface KYCCredentials {
|
|
|
6
34
|
apiKey: string;
|
|
7
35
|
/** Base URL of the KYC API */
|
|
8
36
|
baseUrl: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional storage adapter. When provided, the SDK persists the verification
|
|
39
|
+
* session on startVerification and reads it back to resume a paused flow.
|
|
40
|
+
*/
|
|
41
|
+
storage?: KYCStorage;
|
|
9
42
|
}
|
|
10
43
|
/**
|
|
11
44
|
* Parameters required to start a verification session
|
|
@@ -20,6 +53,24 @@ interface StartVerificationParams {
|
|
|
20
53
|
/** Optional external reference ID */
|
|
21
54
|
externalId?: string;
|
|
22
55
|
}
|
|
56
|
+
interface FaceMatchVerificationParams {
|
|
57
|
+
/** The identity ID to perform face match on */
|
|
58
|
+
identityId: string;
|
|
59
|
+
/** Base64 encoded image data, data URI, or file:// URI */
|
|
60
|
+
file: string;
|
|
61
|
+
/** MIME type of the image (default: image/jpeg) */
|
|
62
|
+
mimeType?: string;
|
|
63
|
+
}
|
|
64
|
+
interface FaceMatchStatusParams {
|
|
65
|
+
/** The identity ID to check face match status for */
|
|
66
|
+
identityId: string;
|
|
67
|
+
/** The face check ID from the face match verification response */
|
|
68
|
+
faceCheckId: string;
|
|
69
|
+
/** Polling interval in milliseconds (default: 3000) */
|
|
70
|
+
interval?: number;
|
|
71
|
+
/** Maximum time to wait in milliseconds (default: 120000) */
|
|
72
|
+
timeout?: number;
|
|
73
|
+
}
|
|
23
74
|
/**
|
|
24
75
|
* Response from starting a verification session
|
|
25
76
|
*/
|
|
@@ -61,6 +112,23 @@ interface UploadResult {
|
|
|
61
112
|
message: string;
|
|
62
113
|
/** Current status after upload */
|
|
63
114
|
status: string;
|
|
115
|
+
/** True when the step was already uploaded and the call was a no-op */
|
|
116
|
+
skipped?: boolean;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Parameters for uploading a single verification step in a resume-aware way.
|
|
120
|
+
*/
|
|
121
|
+
interface UploadStepParams {
|
|
122
|
+
/** The step to upload */
|
|
123
|
+
step: VerificationStep;
|
|
124
|
+
/** Base64 encoded image data, data URI, or file:// URI (React Native) */
|
|
125
|
+
imageData: string;
|
|
126
|
+
/** Verification ID to attach to; falls back to the persisted session */
|
|
127
|
+
verificationId?: string;
|
|
128
|
+
/** Identity ID used to skip already-uploaded steps; falls back to the persisted session */
|
|
129
|
+
identityId?: string;
|
|
130
|
+
/** MIME type of the image (default: image/jpeg) */
|
|
131
|
+
mimeType?: string;
|
|
64
132
|
}
|
|
65
133
|
/** Current status of a verification session */
|
|
66
134
|
interface VerificationStatus {
|
|
@@ -88,6 +156,73 @@ interface VerificationStatus {
|
|
|
88
156
|
/** When the verification was last updated */
|
|
89
157
|
updatedAt: string;
|
|
90
158
|
}
|
|
159
|
+
/** A single verification record as stored under an identity */
|
|
160
|
+
interface VerificationRecord {
|
|
161
|
+
/** Verification ID */
|
|
162
|
+
id: string;
|
|
163
|
+
/** Current verification status */
|
|
164
|
+
status: string;
|
|
165
|
+
/** External reference ID (if provided when starting) */
|
|
166
|
+
externalId: string | null;
|
|
167
|
+
/** Type of document being verified */
|
|
168
|
+
documentType: 'IDENTITY_CARD' | 'DRIVING_LICENSE';
|
|
169
|
+
/** Country code */
|
|
170
|
+
country: string;
|
|
171
|
+
/** Face match similarity score (0-1) */
|
|
172
|
+
faceMatchScore: number | null;
|
|
173
|
+
/** OCR extracted data from document */
|
|
174
|
+
ocrData: Record<string, any> | null;
|
|
175
|
+
/** Stored path of the uploaded selfie, or null if not uploaded yet */
|
|
176
|
+
selfiePath: string | null;
|
|
177
|
+
/** Stored path of the uploaded document front, or null if not uploaded yet */
|
|
178
|
+
documentFrontPath: string | null;
|
|
179
|
+
/** Stored path of the uploaded document back, or null if not uploaded yet */
|
|
180
|
+
documentBackPath: string | null;
|
|
181
|
+
/** Stored path of the document face crop, or null if not available */
|
|
182
|
+
documentFacePath: string | null;
|
|
183
|
+
/** Reason for rejection, if rejected */
|
|
184
|
+
rejectionReason: string | null;
|
|
185
|
+
/** Type of rejection, if rejected */
|
|
186
|
+
rejectionType: string | null;
|
|
187
|
+
/** When the verification was created */
|
|
188
|
+
createdAt: string;
|
|
189
|
+
/** When the verification was last updated */
|
|
190
|
+
updatedAt: string;
|
|
191
|
+
}
|
|
192
|
+
/** An identity with its associated verifications */
|
|
193
|
+
interface Identity {
|
|
194
|
+
/** Unique identity ID */
|
|
195
|
+
id: string;
|
|
196
|
+
/** Verifications linked to this identity */
|
|
197
|
+
verifications: VerificationRecord[];
|
|
198
|
+
/** When the identity was created */
|
|
199
|
+
createdAt: string;
|
|
200
|
+
/** When the identity was last updated */
|
|
201
|
+
updatedAt: string;
|
|
202
|
+
/** Additional OCR / identity fields */
|
|
203
|
+
[key: string]: any;
|
|
204
|
+
}
|
|
205
|
+
/** A single step a user must complete in a verification flow */
|
|
206
|
+
type VerificationStep = 'selfie' | 'document_front' | 'document_back';
|
|
207
|
+
/** Computed progress of an in-flight verification, used to resume a paused flow */
|
|
208
|
+
interface VerificationProgress {
|
|
209
|
+
/** Verification ID the progress refers to */
|
|
210
|
+
verificationId: string;
|
|
211
|
+
/** Document type for this verification */
|
|
212
|
+
documentType: 'IDENTITY_CARD' | 'DRIVING_LICENSE';
|
|
213
|
+
/** Current verification status */
|
|
214
|
+
status: string;
|
|
215
|
+
/** Whether the selfie has already been uploaded */
|
|
216
|
+
selfieUploaded: boolean;
|
|
217
|
+
/** Whether the document front has already been uploaded */
|
|
218
|
+
documentFrontUploaded: boolean;
|
|
219
|
+
/** Whether the document back has already been uploaded (always false for single-sided docs) */
|
|
220
|
+
documentBackUploaded: boolean;
|
|
221
|
+
/** Steps still required to finish, in the order they should be collected */
|
|
222
|
+
missingSteps: VerificationStep[];
|
|
223
|
+
/** True when no steps remain to be uploaded */
|
|
224
|
+
isComplete: boolean;
|
|
225
|
+
}
|
|
91
226
|
/** Event emitted when KYC status changes */
|
|
92
227
|
interface KYCStatusEvent {
|
|
93
228
|
/** Type of event: statusChanged or error */
|
|
@@ -122,11 +257,29 @@ declare class KYCCore {
|
|
|
122
257
|
private client;
|
|
123
258
|
private credentials;
|
|
124
259
|
private eventCallbacks;
|
|
260
|
+
private storage?;
|
|
261
|
+
/** Storage key under which the active verification session is persisted */
|
|
262
|
+
private static readonly SESSION_KEY;
|
|
125
263
|
/**
|
|
126
264
|
* Creates a new KYC Core instance
|
|
127
|
-
* @param credentials API credentials (apiKey and
|
|
265
|
+
* @param credentials API credentials (apiKey, baseUrl, and optional storage)
|
|
128
266
|
*/
|
|
129
267
|
constructor(credentials: KYCCredentials);
|
|
268
|
+
/**
|
|
269
|
+
* Persists the active verification session via the injected storage adapter.
|
|
270
|
+
* No-op when no storage was provided.
|
|
271
|
+
*/
|
|
272
|
+
private saveSession;
|
|
273
|
+
/**
|
|
274
|
+
* Reads the persisted verification session, or null if none exists or no
|
|
275
|
+
* storage adapter was provided.
|
|
276
|
+
*/
|
|
277
|
+
getSession(): Promise<KYCSession | null>;
|
|
278
|
+
/**
|
|
279
|
+
* Clears the persisted verification session. Call this once a verification is
|
|
280
|
+
* fully complete so the next flow starts fresh.
|
|
281
|
+
*/
|
|
282
|
+
clearSession(): Promise<void>;
|
|
130
283
|
/**
|
|
131
284
|
* Registers a callback for KYC status events
|
|
132
285
|
* @param callback Function to call when status changes
|
|
@@ -172,6 +325,58 @@ declare class KYCCore {
|
|
|
172
325
|
* @returns Current verification status including OCR data and face match score
|
|
173
326
|
*/
|
|
174
327
|
getStatus(verificationId: string): Promise<VerificationStatus>;
|
|
328
|
+
/**
|
|
329
|
+
* Fetches an identity along with all of its verification records.
|
|
330
|
+
* @param identityId The identity ID to fetch
|
|
331
|
+
* @returns The identity, including the verifications array with upload paths
|
|
332
|
+
*/
|
|
333
|
+
getIdentity(identityId: string): Promise<Identity>;
|
|
334
|
+
/**
|
|
335
|
+
* Returns the required steps for a given document type, in collection order.
|
|
336
|
+
* ID cards require both sides; driving licenses are single-sided.
|
|
337
|
+
*/
|
|
338
|
+
private getRequiredSteps;
|
|
339
|
+
/**
|
|
340
|
+
* Computes which steps a user has already completed and which are still missing
|
|
341
|
+
* for a verification, so a paused flow can be resumed without re-uploading.
|
|
342
|
+
*
|
|
343
|
+
* Both arguments are optional: when omitted they fall back to the persisted
|
|
344
|
+
* session (see the storage adapter). Pass a verificationId to target a specific
|
|
345
|
+
* verification; otherwise the most recently updated verification is used.
|
|
346
|
+
*
|
|
347
|
+
* @param identityId Identity ID owning the verification (defaults to the session)
|
|
348
|
+
* @param verificationId Verification ID to target (defaults to the session)
|
|
349
|
+
* @returns Progress describing uploaded steps and the steps still required
|
|
350
|
+
*/
|
|
351
|
+
getVerificationProgress(identityId?: string, verificationId?: string): Promise<VerificationProgress>;
|
|
352
|
+
/**
|
|
353
|
+
* Returns whether every required step of a verification has already been
|
|
354
|
+
* uploaded (both document sides where applicable, plus the selfie).
|
|
355
|
+
*
|
|
356
|
+
* This is the reliable way to tell a user who has fully submitted their
|
|
357
|
+
* documents (verification is now processing on the KYC backend) apart from one
|
|
358
|
+
* who paused mid-flow with steps still missing — both look "PENDING" from the
|
|
359
|
+
* outside. Derived purely from the identity's verification records.
|
|
360
|
+
*
|
|
361
|
+
* Returns `false` (rather than throwing) when the identity has no verification
|
|
362
|
+
* records yet, so callers can treat "nothing uploaded" as "documents missing".
|
|
363
|
+
*
|
|
364
|
+
* @param identityId Identity ID owning the verification (defaults to the session)
|
|
365
|
+
* @param verificationId Verification ID to target (defaults to the most recently updated)
|
|
366
|
+
* @returns True when no steps remain to be uploaded
|
|
367
|
+
*/
|
|
368
|
+
hasAllDocuments(identityId?: string, verificationId?: string): Promise<boolean>;
|
|
369
|
+
/**
|
|
370
|
+
* Uploads a single verification step (selfie, document front, or document back)
|
|
371
|
+
* in a resume-aware way: it resolves the verification from the persisted session
|
|
372
|
+
* when not given, and skips the upload if that step is already complete.
|
|
373
|
+
*
|
|
374
|
+
* @param params The step, image data, and optional verification/identity overrides
|
|
375
|
+
* @returns The upload result; `skipped` is true when the step was already uploaded
|
|
376
|
+
*/
|
|
377
|
+
uploadStep(params: UploadStepParams): Promise<UploadResult>;
|
|
378
|
+
faceMatchVerification(params: FaceMatchVerificationParams): Promise<any>;
|
|
379
|
+
faceMatchStatus({ identityId, faceCheckId, interval, timeout, }: FaceMatchStatusParams): Promise<VerificationStatus>;
|
|
175
380
|
/**
|
|
176
381
|
* Polls for verification status until completion or timeout
|
|
177
382
|
* @param verificationId The verification ID to check
|
|
@@ -194,4 +399,4 @@ declare class KYCCore {
|
|
|
194
399
|
*/
|
|
195
400
|
declare function createKYCClient(credentials: KYCCredentials): KYCCore;
|
|
196
401
|
|
|
197
|
-
export { KYCCore, type KYCCredentials, type KYCEventCallback, KYCSdkError, type KYCStatusEvent, type StartVerificationParams, type UploadDocumentParams, type UploadResult, type UploadSelfieParams, type VerificationSession, type VerificationStatus, createKYCClient };
|
|
402
|
+
export { type FaceMatchStatusParams, type FaceMatchVerificationParams, type Identity, KYCCore, type KYCCredentials, type KYCEventCallback, KYCSdkError, type KYCSession, type KYCStatusEvent, type KYCStorage, type StartVerificationParams, type UploadDocumentParams, type UploadResult, type UploadSelfieParams, type UploadStepParams, type VerificationProgress, type VerificationRecord, type VerificationSession, type VerificationStatus, type VerificationStep, createKYCClient };
|