truescene-face-id-capture-sdk 1.0.0 → 1.0.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/README.md +113 -21
- package/dist/_redirects +0 -3
- package/dist/index.js +261 -346
- package/dist/internal/regions.js +5 -0
- package/dist/sdk/CaptureExperience.js +97 -125
- package/dist/sdk/element.js +94 -65
- package/dist/sdk/react/index.js +55 -25
- package/dist/types/internal/regions.d.ts +2 -0
- package/dist/types/sdk/CaptureExperience.d.ts +14 -10
- package/dist/types/sdk/element.d.ts +21 -12
- package/dist/types/sdk/index.d.ts +1 -1
- package/dist/types/sdk/react/index.d.ts +22 -16
- package/dist/types/sdk/types.d.ts +43 -4
- package/dist/utils/config.js +1 -1
- package/package.json +1 -1
package/dist/sdk/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createElement, useEffect, useRef } from 'react';
|
|
2
|
-
const TrueSceneCapture = ({ sessionToken,
|
|
2
|
+
const TrueSceneCapture = ({ sessionToken, region, compareTimeoutMs, autoStart, className, style, showHeader, showInstructions, showStatus, headerEyebrow, headerTitle, headerSubtitle, instructions, onReadyChange, onStepChange, onMetricsChange, onCapture, onVerificationCode, onVerificationError, onError, }) => {
|
|
3
3
|
const elementRef = useRef(null);
|
|
4
4
|
useEffect(() => {
|
|
5
5
|
if (typeof window === 'undefined') {
|
|
@@ -21,44 +21,74 @@ const TrueSceneCapture = ({ sessionToken, compareUrl, tokenHeader, tokenPrefix,
|
|
|
21
21
|
const element = elementRef.current;
|
|
22
22
|
if (!element)
|
|
23
23
|
return;
|
|
24
|
-
element.
|
|
25
|
-
}, [
|
|
24
|
+
element.region = region ?? undefined;
|
|
25
|
+
}, [region]);
|
|
26
26
|
useEffect(() => {
|
|
27
27
|
const element = elementRef.current;
|
|
28
28
|
if (!element)
|
|
29
29
|
return;
|
|
30
|
-
element.
|
|
31
|
-
}, [
|
|
30
|
+
element.compareTimeoutMs = compareTimeoutMs;
|
|
31
|
+
}, [compareTimeoutMs]);
|
|
32
32
|
useEffect(() => {
|
|
33
33
|
const element = elementRef.current;
|
|
34
34
|
if (!element)
|
|
35
35
|
return;
|
|
36
|
-
element.
|
|
37
|
-
}, [
|
|
36
|
+
element.autoStart = Boolean(autoStart);
|
|
37
|
+
}, [autoStart]);
|
|
38
38
|
useEffect(() => {
|
|
39
39
|
const element = elementRef.current;
|
|
40
40
|
if (!element)
|
|
41
41
|
return;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if (showHeader === undefined) {
|
|
43
|
+
element.removeAttribute('show-header');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
element.showHeader = Boolean(showHeader);
|
|
47
|
+
}, [showHeader]);
|
|
44
48
|
useEffect(() => {
|
|
45
49
|
const element = elementRef.current;
|
|
46
50
|
if (!element)
|
|
47
51
|
return;
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
if (showInstructions === undefined) {
|
|
53
|
+
element.removeAttribute('show-instructions');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
element.showInstructions = Boolean(showInstructions);
|
|
57
|
+
}, [showInstructions]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const element = elementRef.current;
|
|
60
|
+
if (!element)
|
|
61
|
+
return;
|
|
62
|
+
if (showStatus === undefined) {
|
|
63
|
+
element.removeAttribute('show-status');
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
element.showStatus = Boolean(showStatus);
|
|
67
|
+
}, [showStatus]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const element = elementRef.current;
|
|
70
|
+
if (!element)
|
|
71
|
+
return;
|
|
72
|
+
element.headerEyebrow = headerEyebrow ?? undefined;
|
|
73
|
+
}, [headerEyebrow]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const element = elementRef.current;
|
|
76
|
+
if (!element)
|
|
77
|
+
return;
|
|
78
|
+
element.headerTitle = headerTitle ?? undefined;
|
|
79
|
+
}, [headerTitle]);
|
|
50
80
|
useEffect(() => {
|
|
51
81
|
const element = elementRef.current;
|
|
52
82
|
if (!element)
|
|
53
83
|
return;
|
|
54
|
-
element.
|
|
55
|
-
}, [
|
|
84
|
+
element.headerSubtitle = headerSubtitle ?? undefined;
|
|
85
|
+
}, [headerSubtitle]);
|
|
56
86
|
useEffect(() => {
|
|
57
87
|
const element = elementRef.current;
|
|
58
88
|
if (!element)
|
|
59
89
|
return;
|
|
60
|
-
element.
|
|
61
|
-
}, [
|
|
90
|
+
element.instructions = instructions ?? undefined;
|
|
91
|
+
}, [instructions]);
|
|
62
92
|
useEffect(() => {
|
|
63
93
|
const element = elementRef.current;
|
|
64
94
|
if (!element)
|
|
@@ -79,13 +109,13 @@ const TrueSceneCapture = ({ sessionToken, compareUrl, tokenHeader, tokenPrefix,
|
|
|
79
109
|
const detail = event.detail;
|
|
80
110
|
onCapture?.(detail);
|
|
81
111
|
};
|
|
82
|
-
const
|
|
112
|
+
const verificationCodeHandler = (event) => {
|
|
83
113
|
const detail = event.detail;
|
|
84
|
-
|
|
114
|
+
onVerificationCode?.(detail);
|
|
85
115
|
};
|
|
86
|
-
const
|
|
116
|
+
const verificationErrorHandler = (event) => {
|
|
87
117
|
const detail = event.detail;
|
|
88
|
-
|
|
118
|
+
onVerificationError?.(detail);
|
|
89
119
|
};
|
|
90
120
|
const errorHandler = (event) => {
|
|
91
121
|
const detail = event.detail;
|
|
@@ -95,16 +125,16 @@ const TrueSceneCapture = ({ sessionToken, compareUrl, tokenHeader, tokenPrefix,
|
|
|
95
125
|
element.addEventListener('step-change', stepHandler);
|
|
96
126
|
element.addEventListener('metrics-change', metricsHandler);
|
|
97
127
|
element.addEventListener('capture', captureHandler);
|
|
98
|
-
element.addEventListener('
|
|
99
|
-
element.addEventListener('
|
|
128
|
+
element.addEventListener('verification-code', verificationCodeHandler);
|
|
129
|
+
element.addEventListener('verification-error', verificationErrorHandler);
|
|
100
130
|
element.addEventListener('error', errorHandler);
|
|
101
131
|
return () => {
|
|
102
132
|
element.removeEventListener('ready-change', readyHandler);
|
|
103
133
|
element.removeEventListener('step-change', stepHandler);
|
|
104
134
|
element.removeEventListener('metrics-change', metricsHandler);
|
|
105
135
|
element.removeEventListener('capture', captureHandler);
|
|
106
|
-
element.removeEventListener('
|
|
107
|
-
element.removeEventListener('
|
|
136
|
+
element.removeEventListener('verification-code', verificationCodeHandler);
|
|
137
|
+
element.removeEventListener('verification-error', verificationErrorHandler);
|
|
108
138
|
element.removeEventListener('error', errorHandler);
|
|
109
139
|
};
|
|
110
140
|
}, [
|
|
@@ -112,8 +142,8 @@ const TrueSceneCapture = ({ sessionToken, compareUrl, tokenHeader, tokenPrefix,
|
|
|
112
142
|
onStepChange,
|
|
113
143
|
onMetricsChange,
|
|
114
144
|
onCapture,
|
|
115
|
-
|
|
116
|
-
|
|
145
|
+
onVerificationCode,
|
|
146
|
+
onVerificationError,
|
|
117
147
|
onError,
|
|
118
148
|
]);
|
|
119
149
|
return createElement('truescene-capture', {
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { type CaptureStep, type FaceAndIdCaptureMetrics } from '../components/FaceAndIdCapture';
|
|
2
|
-
import
|
|
2
|
+
import { type Region } from '../internal/regions';
|
|
3
|
+
import type { CaptureImages, VerificationCodeResponse, VerificationError } from './types';
|
|
3
4
|
type ReadyState = {
|
|
4
5
|
faceReady: boolean;
|
|
5
6
|
idReady: boolean;
|
|
6
7
|
};
|
|
7
8
|
export type CaptureExperienceProps = {
|
|
8
9
|
sessionToken: string;
|
|
9
|
-
|
|
10
|
-
tokenHeader?: string;
|
|
11
|
-
tokenPrefix?: string;
|
|
12
|
-
tokenField?: string | null;
|
|
10
|
+
region?: Region;
|
|
13
11
|
autoStart?: boolean;
|
|
14
|
-
|
|
15
|
-
showDebugToggle?: boolean;
|
|
12
|
+
compareTimeoutMs?: number;
|
|
16
13
|
className?: string;
|
|
14
|
+
showHeader?: boolean;
|
|
15
|
+
showInstructions?: boolean;
|
|
16
|
+
showStatus?: boolean;
|
|
17
|
+
headerEyebrow?: string;
|
|
18
|
+
headerTitle?: string;
|
|
19
|
+
headerSubtitle?: string;
|
|
20
|
+
instructions?: string;
|
|
17
21
|
onReadyChange?: (ready: ReadyState) => void;
|
|
18
22
|
onStepChange?: (step: CaptureStep) => void;
|
|
19
23
|
onMetricsChange?: (metrics: FaceAndIdCaptureMetrics) => void;
|
|
20
24
|
onCapture?: (images: CaptureImages) => void;
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
onVerificationCode?: (result: VerificationCodeResponse | null) => void;
|
|
26
|
+
onVerificationError?: (error: VerificationError | null) => void;
|
|
23
27
|
onError?: (message: string) => void;
|
|
24
28
|
};
|
|
25
|
-
declare const CaptureExperience: ({ sessionToken,
|
|
29
|
+
declare const CaptureExperience: ({ sessionToken, region, autoStart, compareTimeoutMs, className, showHeader, showInstructions, showStatus, headerEyebrow, headerTitle, headerSubtitle, instructions, onReadyChange, onStepChange, onMetricsChange, onCapture, onVerificationCode, onVerificationError, onError, }: CaptureExperienceProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
30
|
export default CaptureExperience;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { REGION_URLS } from '../internal/regions';
|
|
2
|
+
type Region = keyof typeof REGION_URLS;
|
|
1
3
|
export declare class TrueSceneCaptureElement extends HTMLElement {
|
|
2
4
|
static observedAttributes: string[];
|
|
3
5
|
private root;
|
|
@@ -8,20 +10,27 @@ export declare class TrueSceneCaptureElement extends HTMLElement {
|
|
|
8
10
|
attributeChangedCallback(): void;
|
|
9
11
|
set sessionToken(value: string);
|
|
10
12
|
get sessionToken(): string;
|
|
11
|
-
set
|
|
12
|
-
get
|
|
13
|
-
set
|
|
14
|
-
get
|
|
15
|
-
set tokenPrefix(value: string | undefined);
|
|
16
|
-
get tokenPrefix(): string | undefined;
|
|
17
|
-
set tokenField(value: string | null | undefined);
|
|
18
|
-
get tokenField(): string | null | undefined;
|
|
13
|
+
set region(value: Region | undefined);
|
|
14
|
+
get region(): Region | undefined;
|
|
15
|
+
set compareTimeoutMs(value: number | undefined);
|
|
16
|
+
get compareTimeoutMs(): number | undefined;
|
|
19
17
|
set autoStart(value: boolean);
|
|
20
18
|
get autoStart(): boolean;
|
|
21
|
-
set
|
|
22
|
-
get
|
|
23
|
-
set
|
|
24
|
-
get
|
|
19
|
+
set showHeader(value: boolean);
|
|
20
|
+
get showHeader(): boolean;
|
|
21
|
+
set showInstructions(value: boolean);
|
|
22
|
+
get showInstructions(): boolean;
|
|
23
|
+
set showStatus(value: boolean);
|
|
24
|
+
get showStatus(): boolean;
|
|
25
|
+
set headerEyebrow(value: string | undefined | null);
|
|
26
|
+
get headerEyebrow(): string | undefined;
|
|
27
|
+
set headerTitle(value: string | undefined | null);
|
|
28
|
+
get headerTitle(): string | undefined;
|
|
29
|
+
set headerSubtitle(value: string | undefined | null);
|
|
30
|
+
get headerSubtitle(): string | undefined;
|
|
31
|
+
set instructions(value: string | undefined | null);
|
|
32
|
+
get instructions(): string | undefined;
|
|
25
33
|
private renderReact;
|
|
26
34
|
}
|
|
27
35
|
export declare const defineTrueSceneCapture: (tagName?: string) => void;
|
|
36
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { defineTrueSceneCapture, TrueSceneCaptureElement } from './element';
|
|
2
2
|
export type { CaptureExperienceProps } from './CaptureExperience';
|
|
3
|
-
export type { CaptureImages,
|
|
3
|
+
export type { CaptureImages, ExtractedIdentity, FaceMatchResult, VerificationCodeResponse, VerificationError, VerificationErrorCode, VerificationDocument, VerificationStatusResponse, } from './types';
|
|
4
4
|
export type { CaptureStep, FaceAndIdCaptureMetrics, } from '../components/FaceAndIdCapture';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
-
import type { CaptureImages,
|
|
2
|
+
import type { CaptureImages, VerificationCodeResponse, VerificationError } from '../types';
|
|
3
3
|
import type { CaptureStep, FaceAndIdCaptureMetrics } from '../../components/FaceAndIdCapture';
|
|
4
4
|
type ReadyState = {
|
|
5
5
|
faceReady: boolean;
|
|
@@ -7,34 +7,40 @@ type ReadyState = {
|
|
|
7
7
|
};
|
|
8
8
|
type TrueSceneCaptureElement = HTMLElement & {
|
|
9
9
|
sessionToken: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
tokenPrefix?: string;
|
|
13
|
-
tokenField?: string | null;
|
|
10
|
+
region?: 'eu' | 'us' | 'sandbox';
|
|
11
|
+
compareTimeoutMs?: number;
|
|
14
12
|
autoStart: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
showHeader: boolean;
|
|
14
|
+
showInstructions: boolean;
|
|
15
|
+
showStatus: boolean;
|
|
16
|
+
headerEyebrow?: string;
|
|
17
|
+
headerTitle?: string;
|
|
18
|
+
headerSubtitle?: string;
|
|
19
|
+
instructions?: string;
|
|
17
20
|
};
|
|
18
21
|
export type TrueSceneCaptureProps = {
|
|
19
22
|
sessionToken: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
tokenPrefix?: string;
|
|
23
|
-
tokenField?: string | null;
|
|
23
|
+
region: 'eu' | 'us' | 'sandbox';
|
|
24
|
+
compareTimeoutMs?: number;
|
|
24
25
|
autoStart?: boolean;
|
|
25
|
-
initialShowDebug?: boolean;
|
|
26
|
-
showDebugToggle?: boolean;
|
|
27
26
|
className?: string;
|
|
28
27
|
style?: CSSProperties;
|
|
28
|
+
showHeader?: boolean;
|
|
29
|
+
showInstructions?: boolean;
|
|
30
|
+
showStatus?: boolean;
|
|
31
|
+
headerEyebrow?: string;
|
|
32
|
+
headerTitle?: string;
|
|
33
|
+
headerSubtitle?: string;
|
|
34
|
+
instructions?: string;
|
|
29
35
|
onReadyChange?: (ready: ReadyState) => void;
|
|
30
36
|
onStepChange?: (step: CaptureStep) => void;
|
|
31
37
|
onMetricsChange?: (metrics: FaceAndIdCaptureMetrics) => void;
|
|
32
38
|
onCapture?: (images: CaptureImages) => void;
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
onVerificationCode?: (result: VerificationCodeResponse | null) => void;
|
|
40
|
+
onVerificationError?: (message: VerificationError | null) => void;
|
|
35
41
|
onError?: (message: string) => void;
|
|
36
42
|
};
|
|
37
|
-
declare const TrueSceneCapture: ({ sessionToken,
|
|
43
|
+
declare const TrueSceneCapture: ({ sessionToken, region, compareTimeoutMs, autoStart, className, style, showHeader, showInstructions, showStatus, headerEyebrow, headerTitle, headerSubtitle, instructions, onReadyChange, onStepChange, onMetricsChange, onCapture, onVerificationCode, onVerificationError, onError, }: TrueSceneCaptureProps) => import("react").ReactElement<{
|
|
38
44
|
ref: import("react").RefObject<TrueSceneCaptureElement | null>;
|
|
39
45
|
className: string | undefined;
|
|
40
46
|
style: CSSProperties | undefined;
|
|
@@ -3,11 +3,50 @@ export type CaptureImages = {
|
|
|
3
3
|
idImage: string | null;
|
|
4
4
|
fullImage: string | null;
|
|
5
5
|
};
|
|
6
|
-
export type
|
|
6
|
+
export type VerificationCodeResponse = {
|
|
7
|
+
verification_code: string;
|
|
8
|
+
expires_at: string;
|
|
9
|
+
};
|
|
10
|
+
export type VerificationErrorCode = 'MISSING_TOKEN' | 'MISSING_REGION' | 'HTTP_ERROR' | 'NETWORK_ERROR' | 'INVALID_RESPONSE' | 'REQUEST_TIMEOUT';
|
|
11
|
+
export type VerificationError = {
|
|
12
|
+
code: VerificationErrorCode;
|
|
13
|
+
message: string;
|
|
14
|
+
status?: number;
|
|
15
|
+
};
|
|
16
|
+
export type VerificationDocument = {
|
|
17
|
+
type: string;
|
|
18
|
+
number: string;
|
|
19
|
+
issuingCountry: string;
|
|
20
|
+
issuingAuthority: string;
|
|
21
|
+
issue_date: string;
|
|
22
|
+
expiry_date: string;
|
|
23
|
+
is_expired: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type ExtractedIdentity = {
|
|
26
|
+
first_name: string;
|
|
27
|
+
last_name: string;
|
|
28
|
+
full_name: string;
|
|
29
|
+
dob: string;
|
|
30
|
+
place_of_birth: string;
|
|
31
|
+
gender: string;
|
|
32
|
+
nationality: string;
|
|
33
|
+
};
|
|
34
|
+
export type FaceMatchResult = {
|
|
7
35
|
match: boolean;
|
|
8
|
-
|
|
36
|
+
confidence: number;
|
|
9
37
|
cosine_distance: number;
|
|
10
38
|
cosine_similarity: number;
|
|
11
|
-
|
|
12
|
-
|
|
39
|
+
};
|
|
40
|
+
export type VerificationStatusResponse = {
|
|
41
|
+
verification_id: string;
|
|
42
|
+
status: string;
|
|
43
|
+
decision?: string;
|
|
44
|
+
reason_codes?: string[];
|
|
45
|
+
document?: VerificationDocument;
|
|
46
|
+
extracted_identity?: ExtractedIdentity;
|
|
47
|
+
face_match?: FaceMatchResult;
|
|
48
|
+
liveness?: {
|
|
49
|
+
passed: boolean;
|
|
50
|
+
};
|
|
51
|
+
completed_at?: string;
|
|
13
52
|
};
|
package/dist/utils/config.js
CHANGED