@opexa/portal-components 0.0.120 → 0.0.122
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/client/hooks/useBetRecordsQuery.js +4 -1
- package/dist/client/hooks/useClaimSpotBonusMutation.js +2 -6
- package/dist/client/hooks/useDepositRecordsQuery.js +1 -0
- package/dist/client/hooks/useGlobalStore.d.ts +2 -0
- package/dist/client/hooks/useGlobalStore.js +26 -0
- package/dist/client/hooks/useResetPasswordMutation.d.ts +3 -0
- package/dist/client/hooks/useResetPasswordMutation.js +12 -0
- package/dist/client/hooks/useTransactionRecordsQuery.js +1 -0
- package/dist/client/hooks/useWithdrawalRecordsQuery.js +1 -0
- package/dist/components/Bonuses/Bonuses.client.js +24 -14
- package/dist/components/Bonuses/ClaimSpotBonus.d.ts +1 -0
- package/dist/components/Bonuses/ClaimSpotBonus.js +13 -0
- package/dist/components/Bonuses/ClaimSpotBonus.lazy.d.ts +1 -0
- package/dist/components/Bonuses/ClaimSpotBonus.lazy.js +50 -0
- package/dist/components/ForgotPassword/ForgotPassword.d.ts +3 -0
- package/dist/components/ForgotPassword/ForgotPassword.js +14 -0
- package/dist/components/ForgotPassword/ForgotPassword.lazy.d.ts +8 -0
- package/dist/components/ForgotPassword/ForgotPassword.lazy.js +19 -0
- package/dist/components/ForgotPassword/ForgotPasswordForm.d.ts +1 -0
- package/dist/components/ForgotPassword/ForgotPasswordForm.js +136 -0
- package/dist/components/ForgotPassword/ForgotPasswordTrigger.d.ts +6 -0
- package/dist/components/ForgotPassword/ForgotPasswordTrigger.js +14 -0
- package/dist/components/ForgotPassword/index.d.ts +2 -0
- package/dist/components/ForgotPassword/index.js +2 -0
- package/dist/components/KYC/CaptureIdDocument.js +1 -2
- package/dist/components/KYC/CaptureSelfie.js +226 -1
- package/dist/components/KYC/DisplayImage.d.ts +4 -1
- package/dist/components/KYC/DisplayImage.js +2 -4
- package/dist/components/KYC/IdentityVerification.js +2 -2
- package/dist/components/KYC/PersonOverlayDesktop.d.ts +7 -0
- package/dist/components/KYC/PersonOverlayDesktop.js +9 -0
- package/dist/components/KYC/loadModels.d.ts +1 -0
- package/dist/components/KYC/loadModels.js +9 -0
- package/dist/components/KYC/useKYC.d.ts +2 -0
- package/dist/components/KYC/useKYC.js +3 -0
- package/dist/components/KYC/utils.d.ts +2 -0
- package/dist/components/KYC/utils.js +17 -0
- package/dist/components/SignIn/MobileNumberSignIn.js +4 -2
- package/dist/components/SignIn/NameAndPasswordSignIn.js +6 -1
- package/dist/images/ribbon-envelope.png +0 -0
- package/dist/ui/AlertDialog/AlertDialog.d.ts +154 -154
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +14 -14
- package/dist/ui/Avatar/Avatar.d.ts +9 -9
- package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
- package/dist/ui/Badge/Badge.d.ts +12 -12
- package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
- package/dist/ui/Badge/badge.recipe.d.ts +3 -3
- package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
- package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
- package/dist/ui/Collapsible/Collapsible.d.ts +32 -32
- package/dist/ui/Collapsible/collapsible.recipe.d.ts +8 -8
- package/dist/ui/Combobox/Combobox.d.ts +42 -42
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
- package/dist/ui/Dialog/Dialog.d.ts +154 -154
- package/dist/ui/Dialog/dialog.recipe.d.ts +14 -14
- package/dist/ui/Drawer/Drawer.d.ts +33 -33
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/Field/Field.d.ts +105 -0
- package/dist/ui/Field/field.recipe.d.ts +15 -0
- package/dist/ui/Field/field.recipe.js +5 -0
- package/dist/ui/Menu/Menu.d.ts +252 -252
- package/dist/ui/Menu/menu.recipe.d.ts +14 -14
- package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
- package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
- package/dist/ui/Popover/Popover.d.ts +121 -121
- package/dist/ui/Popover/popover.recipe.d.ts +11 -11
- package/dist/ui/Progress/Progress.d.ts +27 -27
- package/dist/ui/Progress/progress.recipe.d.ts +3 -3
- package/dist/ui/QrCode/QrCode.d.ts +25 -25
- package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
- package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
- package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
- package/dist/ui/Select/Select.d.ts +45 -45
- package/dist/ui/Select/select.recipe.d.ts +3 -3
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/table.anatomy.d.ts +1 -1
- package/dist/ui/Table/table.recipe.d.ts +3 -3
- package/dist/ui/Tabs/Tabs.d.ts +15 -15
- package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
- package/dist/utils/createErrorFromCode.d.ts +2 -0
- package/dist/utils/createErrorFromCode.js +11 -0
- package/dist/utils/getQueryClient.js +1 -1
- package/dist/utils/mutationKeys.d.ts +1 -0
- package/dist/utils/mutationKeys.js +4 -0
- package/package.json +2 -1
|
@@ -1,11 +1,236 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as faceapi from 'face-api.js';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { useUploadImageFileMutation } from '../../client/hooks/useUploadImageFileMutation.js';
|
|
2
6
|
import { ArrowLeftIcon } from '../../icons/ArrowLeftIcon.js';
|
|
3
7
|
import { Camera01Icon } from '../../icons/Camera01Icon.js';
|
|
4
8
|
import { XIcon } from '../../icons/XIcon.js';
|
|
5
9
|
import { Button } from '../../ui/Button/index.js';
|
|
6
10
|
import { Dialog } from '../../ui/Dialog/index.js';
|
|
7
11
|
import { useKYCContext } from './KYCContext.js';
|
|
12
|
+
import { loadFaceApiModels } from './loadModels.js';
|
|
13
|
+
import PersonOverlayDesktop from './PersonOverlayDesktop.js';
|
|
14
|
+
import { dataURLtoBlob, resizeFile } from './utils.js';
|
|
8
15
|
export function CaptureSelfie() {
|
|
9
16
|
const kyc = useKYCContext();
|
|
10
|
-
|
|
17
|
+
const { mutate, isPending } = useUploadImageFileMutation();
|
|
18
|
+
const [modelsLoaded, setModelsLoaded] = useState(false);
|
|
19
|
+
const [videoStream, setVideoStream] = useState(null);
|
|
20
|
+
const [cameraError, setCameraError] = useState(null);
|
|
21
|
+
const [captureInProgress, setCaptureInProgress] = useState(false);
|
|
22
|
+
const [selectedImage, setSelectedImage] = useState(null);
|
|
23
|
+
const [isFaceCentered, setIsFaceCentered] = useState(false);
|
|
24
|
+
const [countdown, setCountdown] = useState(3);
|
|
25
|
+
const videoRef = useRef(null);
|
|
26
|
+
const faceCanvasRef = useRef(null);
|
|
27
|
+
const detectionIntervalRef = useRef(null);
|
|
28
|
+
const countdownTimerRef = useRef(null);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
loadFaceApiModels()
|
|
31
|
+
.then(() => setModelsLoaded(true))
|
|
32
|
+
.catch(() => setModelsLoaded(false));
|
|
33
|
+
}, []);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (captureInProgress) {
|
|
36
|
+
startFaceDetection();
|
|
37
|
+
}
|
|
38
|
+
}, [captureInProgress]);
|
|
39
|
+
async function startCamera() {
|
|
40
|
+
setCaptureInProgress(true);
|
|
41
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
42
|
+
video: {
|
|
43
|
+
facingMode: 'environment',
|
|
44
|
+
aspectRatio: 16 / 9,
|
|
45
|
+
width: { ideal: 1920 },
|
|
46
|
+
height: { ideal: 1080 },
|
|
47
|
+
},
|
|
48
|
+
audio: false,
|
|
49
|
+
});
|
|
50
|
+
setVideoStream(stream);
|
|
51
|
+
if (videoRef.current) {
|
|
52
|
+
videoRef.current.srcObject = stream;
|
|
53
|
+
videoRef.current.onloadedmetadata = () => {
|
|
54
|
+
videoRef.current
|
|
55
|
+
?.play()
|
|
56
|
+
.then(() => {
|
|
57
|
+
if (modelsLoaded) {
|
|
58
|
+
startFaceDetection();
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
.catch((error) => {
|
|
62
|
+
console.error('Error playing video:', error);
|
|
63
|
+
setCameraError('Failed to play video stream. Please check your camera settings.');
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function startFaceDetection() {
|
|
69
|
+
if (!modelsLoaded) {
|
|
70
|
+
console.error('Cannot start face detection: video element not ready or models not loaded');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!faceCanvasRef.current) {
|
|
74
|
+
faceCanvasRef.current = faceapi.createCanvasFromMedia(videoRef.current);
|
|
75
|
+
const parentDiv = document.getElementById('parent');
|
|
76
|
+
faceCanvasRef.current.className = `absolute inset-0 m-auto h-${parentDiv?.clientHeight} w-${parentDiv?.clientWidth} md:aspect-video object-cover md:object-contain`;
|
|
77
|
+
faceCanvasRef.current.style.width = `${videoRef.current?.clientWidth}px`;
|
|
78
|
+
faceCanvasRef.current.style.height = `${videoRef.current?.clientHeight}px`;
|
|
79
|
+
}
|
|
80
|
+
const displaySize = {
|
|
81
|
+
width: videoRef.current?.clientWidth || 643,
|
|
82
|
+
height: videoRef.current?.clientHeight || 333,
|
|
83
|
+
};
|
|
84
|
+
// Clear any existing interval
|
|
85
|
+
if (detectionIntervalRef.current) {
|
|
86
|
+
clearInterval(detectionIntervalRef.current);
|
|
87
|
+
}
|
|
88
|
+
faceapi.matchDimensions(faceCanvasRef.current, displaySize);
|
|
89
|
+
let countdownInterval = null;
|
|
90
|
+
detectionIntervalRef.current = window.setInterval(async () => {
|
|
91
|
+
if (!videoRef.current || !faceCanvasRef.current) {
|
|
92
|
+
console.error('Video or canvas element is not ready');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const detection = await faceapi
|
|
97
|
+
.detectSingleFace(videoRef.current, new faceapi.TinyFaceDetectorOptions())
|
|
98
|
+
.withFaceLandmarks();
|
|
99
|
+
if (detection) {
|
|
100
|
+
const resizedDetection = faceapi.resizeResults(detection, displaySize);
|
|
101
|
+
const frame_height = resizedDetection.detection.box.height;
|
|
102
|
+
const frame_width = resizedDetection.detection.box.width;
|
|
103
|
+
const frame_x = resizedDetection.detection.box.x;
|
|
104
|
+
const frame_y = resizedDetection.detection.box.y;
|
|
105
|
+
const faceCenterX = frame_x + frame_width / 2;
|
|
106
|
+
const faceCenterY = frame_y + frame_height / 2;
|
|
107
|
+
const screenCenterX = displaySize.width / 2;
|
|
108
|
+
const screenCenterY = displaySize.height / 2;
|
|
109
|
+
const centerThresholdX = displaySize.width * 0.15;
|
|
110
|
+
const centerThresholdY = displaySize.height * 0.15;
|
|
111
|
+
const isFaceCentered = Math.abs(faceCenterX - screenCenterX) <= centerThresholdX &&
|
|
112
|
+
Math.abs(faceCenterY - screenCenterY) <= centerThresholdY;
|
|
113
|
+
setIsFaceCentered(isFaceCentered);
|
|
114
|
+
const faceDetectionConfidence = detection.detection.score * 100;
|
|
115
|
+
const context = faceCanvasRef.current.getContext('2d');
|
|
116
|
+
if (context) {
|
|
117
|
+
context.clearRect(0, 0, faceCanvasRef.current.width, faceCanvasRef.current.height);
|
|
118
|
+
faceapi.draw.drawDetections(faceCanvasRef.current, resizedDetection);
|
|
119
|
+
faceapi.draw.drawFaceLandmarks(faceCanvasRef.current, resizedDetection);
|
|
120
|
+
}
|
|
121
|
+
//adjust the faceDetectionConfidence if need
|
|
122
|
+
if (isFaceCentered && faceDetectionConfidence >= 65) {
|
|
123
|
+
if (!countdownInterval) {
|
|
124
|
+
countdownInterval = setInterval(() => {
|
|
125
|
+
setCountdown((prev) => {
|
|
126
|
+
if (prev === 1) {
|
|
127
|
+
clearInterval(countdownInterval);
|
|
128
|
+
countdownInterval = null;
|
|
129
|
+
captureImage();
|
|
130
|
+
return 3;
|
|
131
|
+
}
|
|
132
|
+
return prev - 1;
|
|
133
|
+
});
|
|
134
|
+
}, 1000);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
if (countdownInterval) {
|
|
139
|
+
clearInterval(countdownInterval);
|
|
140
|
+
countdownInterval = null;
|
|
141
|
+
setCountdown(3);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
console.error('Error during face detection:', error);
|
|
148
|
+
setCameraError('An error occurred while detecting your face. Please try again.');
|
|
149
|
+
}
|
|
150
|
+
}, 100);
|
|
151
|
+
}
|
|
152
|
+
function stopCamera() {
|
|
153
|
+
setCaptureInProgress(false);
|
|
154
|
+
if (detectionIntervalRef.current) {
|
|
155
|
+
clearInterval(detectionIntervalRef.current);
|
|
156
|
+
detectionIntervalRef.current = null;
|
|
157
|
+
}
|
|
158
|
+
if (countdownTimerRef.current) {
|
|
159
|
+
clearInterval(countdownTimerRef.current);
|
|
160
|
+
countdownTimerRef.current = null;
|
|
161
|
+
}
|
|
162
|
+
if (videoStream) {
|
|
163
|
+
videoStream.getTracks().forEach((track) => track.stop());
|
|
164
|
+
setVideoStream(null);
|
|
165
|
+
}
|
|
166
|
+
if (videoRef.current) {
|
|
167
|
+
videoRef.current.srcObject = null;
|
|
168
|
+
videoRef.current.pause();
|
|
169
|
+
}
|
|
170
|
+
setCountdown(3);
|
|
171
|
+
}
|
|
172
|
+
function captureImage() {
|
|
173
|
+
if (videoRef.current && faceCanvasRef.current) {
|
|
174
|
+
const canvas = document.createElement('canvas');
|
|
175
|
+
canvas.width = videoRef.current.videoWidth;
|
|
176
|
+
canvas.height = videoRef.current.videoHeight;
|
|
177
|
+
const context = canvas.getContext('2d');
|
|
178
|
+
if (context) {
|
|
179
|
+
context.drawImage(videoRef.current, 0, 0, canvas.width, canvas.height);
|
|
180
|
+
const imageData = canvas.toDataURL('image/png');
|
|
181
|
+
setSelectedImage(imageData);
|
|
182
|
+
stopCamera();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function retakePhoto() {
|
|
187
|
+
setSelectedImage(null);
|
|
188
|
+
setCaptureInProgress(true);
|
|
189
|
+
setCameraError(null);
|
|
190
|
+
if (faceCanvasRef.current) {
|
|
191
|
+
const canvas = faceCanvasRef.current.querySelector('canvas');
|
|
192
|
+
if (canvas) {
|
|
193
|
+
canvas.width = canvas.width;
|
|
194
|
+
}
|
|
195
|
+
faceCanvasRef.current.innerHTML = '';
|
|
196
|
+
}
|
|
197
|
+
if (videoRef.current) {
|
|
198
|
+
videoRef.current.play();
|
|
199
|
+
}
|
|
200
|
+
startCamera();
|
|
201
|
+
}
|
|
202
|
+
async function usePhoto() {
|
|
203
|
+
if (!selectedImage) {
|
|
204
|
+
console.error('No photo selected to use');
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const blob = dataURLtoBlob(selectedImage);
|
|
208
|
+
const img = new File([blob], 'image', { type: blob.type });
|
|
209
|
+
const resizedImage = (await resizeFile(img));
|
|
210
|
+
if (resizedImage) {
|
|
211
|
+
await mutate({
|
|
212
|
+
file: resizedImage,
|
|
213
|
+
}, {
|
|
214
|
+
onSuccess: (data) => {
|
|
215
|
+
kyc.setSelfieImageId(data);
|
|
216
|
+
kyc.setCapturing(null);
|
|
217
|
+
stopCamera();
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
useEffect(() => {
|
|
223
|
+
return () => {
|
|
224
|
+
if (detectionIntervalRef.current) {
|
|
225
|
+
clearInterval(detectionIntervalRef.current);
|
|
226
|
+
}
|
|
227
|
+
if (countdownTimerRef.current) {
|
|
228
|
+
clearInterval(countdownTimerRef.current);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}, []);
|
|
232
|
+
return (_jsxs("div", { className: "w-full p-4 lg:w-[640px] lg:px-12 lg:py-4xl", children: [_jsxs("button", { type: "button", className: "flex items-center gap-lg lg:absolute lg:right-5 lg:top-5 lg:p-md", onClick: () => {
|
|
233
|
+
stopCamera();
|
|
234
|
+
kyc.setCapturing(null);
|
|
235
|
+
}, children: [_jsx(XIcon, { className: "text-text-senary-300 hidden size-5 lg:block" }), _jsx(ArrowLeftIcon, { className: "text-text-senary-300 size-5 lg:hidden" }), _jsx("span", { className: "text-lg font-semibold lg:hidden", children: "Back" })] }), _jsx(Dialog.Title, { className: "mt-6 text-center text-lg font-semibold lg:mt-0", children: "Take a Selfie Holding Your ID" }), _jsx(Dialog.Description, { className: "text-text-tertiary-600 mx-auto mt-sm max-w-[19rem] text-center text-sm lg:max-w-full", children: "Make sure your face and ID are clearly visible, with no glare or blur." }), _jsx("div", { id: "parent", className: "border-border-disabled mt-6 aspect-video rounded-xl border bg-black lg:mt-8", children: captureInProgress ? (_jsxs("div", { className: "relative flex h-fit w-full flex-col items-center justify-center", children: [_jsx("video", { ref: videoRef, autoPlay: true, muted: true, className: "h-[60vh] w-full rounded-lg object-cover md:aspect-video md:h-[333px]", width: "100%", height: "100%" }), _jsx("canvas", { ref: faceCanvasRef, className: "absolute inset-0 h-[60vh] w-full object-cover md:aspect-video md:h-[333px] md:object-contain", width: "100%", height: "100%" }), isFaceCentered && (_jsx("span", { className: "absolute inset-x-0 bottom-4 flex items-center justify-center text-5xl font-bold text-[#713B12CC]", children: countdown })), !isFaceCentered && (_jsx("span", { className: "absolute inset-x-0 bottom-12 mx-auto w-1/2 text-center text-xs text-white md:bottom-3", children: "Please center your face in the camera view. Make sure your ID is clearly visible next to your face." })), _jsx(PersonOverlayDesktop, { isFaceCentered: isFaceCentered, width: videoRef.current?.clientWidth || 543, height: videoRef.current?.clientHeight || 333 })] })) : (selectedImage && (_jsx("img", { src: selectedImage, alt: "Captured Photo", className: "h-full w-full rounded-lg object-cover md:aspect-video md:h-[333px]" }))) }), selectedImage && (_jsxs("div", { className: "flex flex-col items-center justify-center gap-2 md:flex-row", children: [_jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-4 px-xl disabled:opacity-100", size: "sm", onClick: retakePhoto, type: "button", children: ["Rekate Photo", _jsx(Camera01Icon, { className: "size-5" })] }), _jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-4 px-xl disabled:opacity-100", size: "sm", onClick: usePhoto, type: "button", disabled: isPending, children: ["Use Photo", _jsx(Camera01Icon, { className: "size-5" })] })] })), !selectedImage && (_jsxs(Button, { className: "mx-auto mt-6 px-xl lg:mt-8", onClick: startCamera, disabled: !modelsLoaded, type: "button", children: ["Start Camera", _jsx(Camera01Icon, { className: "size-5" })] }))] }));
|
|
11
236
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Image from 'next/image';
|
|
3
3
|
import { useFileQuery } from '../../client/hooks/useFileQuery.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const kyc = useKYCContext();
|
|
7
|
-
const { data } = useFileQuery(kyc.idFrontImageId ?? '');
|
|
4
|
+
function DisplayImage({ id }) {
|
|
5
|
+
const { data } = useFileQuery(id ?? '');
|
|
8
6
|
return (_jsx("div", { className: "border-border-primary bg-bg-primary min-h-[11.25rem]", children: data?.url && (_jsx(Image, { src: data.url, alt: "Uploaded", className: "w-full object-contain", width: 500, height: 500 })) }));
|
|
9
7
|
}
|
|
10
8
|
export default DisplayImage;
|
|
@@ -25,13 +25,13 @@ export function IdentityVerification() {
|
|
|
25
25
|
}
|
|
26
26
|
function UploadIdDocument() {
|
|
27
27
|
const kyc = useKYCContext();
|
|
28
|
-
return (_jsxs("div", { className: "border-border-primary bg-bg-primary flex min-h-[11.25rem] flex-col justify-center gap-lg rounded-xl border px-3xl py-xl", children: [kyc.idFrontImageId ? (_jsx(DisplayImage, {})) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "border-border-primary shadow-xs mx-auto flex size-8 items-center justify-center rounded-sm border", children: _jsx(UploadCloud02Icon, { className: "text-text-quinary size-4" }) }), _jsxs("p", { className: "text-text-tertiary-600 text-center text-sm", children: [_jsx("span", { className: "text-button-secondary-fg font-semibold", children: "Click to upload" }), ' ', "or drag and drop", _jsx("br", {}), "PNG, JPG or JPEG (max. 10mb)", _jsx("br", {}), "or"] })] })), _jsx(Button, { size: "xs", variant: "outline", className: "mx-auto w-fit", onClick: () => {
|
|
28
|
+
return (_jsxs("div", { className: "border-border-primary bg-bg-primary flex min-h-[11.25rem] flex-col justify-center gap-lg rounded-xl border px-3xl py-xl", children: [kyc.idFrontImageId ? (_jsx(DisplayImage, { id: kyc.idFrontImageId })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "border-border-primary shadow-xs mx-auto flex size-8 items-center justify-center rounded-sm border", children: _jsx(UploadCloud02Icon, { className: "text-text-quinary size-4" }) }), _jsxs("p", { className: "text-text-tertiary-600 text-center text-sm", children: [_jsx("span", { className: "text-button-secondary-fg font-semibold", children: "Click to upload" }), ' ', "or drag and drop", _jsx("br", {}), "PNG, JPG or JPEG (max. 10mb)", _jsx("br", {}), "or"] })] })), _jsx(Button, { size: "xs", variant: "outline", className: "mx-auto w-fit", onClick: () => {
|
|
29
29
|
kyc.setCapturing('ID_DOCUMENT');
|
|
30
30
|
}, children: kyc.idFrontImageId ? 'Rekate Photo' : 'Take a Photo' })] }));
|
|
31
31
|
}
|
|
32
32
|
function UploadSelfie() {
|
|
33
33
|
const kyc = useKYCContext();
|
|
34
|
-
return (_jsxs("div", { className: "border-border-primary bg-bg-primary flex min-h-[11.25rem] flex-col justify-center gap-lg rounded-xl border px-3xl py-xl", children: [_jsx("div", { className: "border-border-primary shadow-xs mx-auto flex size-8 items-center justify-center rounded-sm border", children: _jsx(UploadCloud02Icon, { className: "text-text-quinary size-4" }) }), _jsx(Button, { size: "xs", variant: "outline", className: "mx-auto w-fit", onClick: () => {
|
|
34
|
+
return (_jsxs("div", { className: "border-border-primary bg-bg-primary flex min-h-[11.25rem] flex-col justify-center gap-lg rounded-xl border px-3xl py-xl", children: [kyc.selfieImageId ? (_jsx(DisplayImage, { id: kyc.selfieImageId })) : (_jsx("div", { className: "border-border-primary shadow-xs mx-auto flex size-8 items-center justify-center rounded-sm border", children: _jsx(UploadCloud02Icon, { className: "text-text-quinary size-4" }) })), _jsx(Button, { size: "xs", variant: "outline", className: "mx-auto w-fit", onClick: () => {
|
|
35
35
|
kyc.setCapturing('SELFIE');
|
|
36
36
|
}, children: "Take a photo" })] }));
|
|
37
37
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
function PersonOverlayDesktop({ isFaceCentered, height, width }) {
|
|
3
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "pointer-events-none absolute inset-0 hidden md:block", children: _jsxs("svg", { width: `${width}px`, height: `${height}px`, viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "xMidYMid meet", className: "max-h-full w-full", children: [_jsxs("defs", { children: [_jsx("path", { id: "head-shoulder-path", d: "M 389.605 124.529 C 390.221 129.441 390.638 134.433 390.846 139.492 L 390.932 151.978 C 390.841 155.321 390.658 158.636 390.388 161.919 C 388.294 162.987 388.18 164.214 389 168 L 390.277 171.709 L 395 181 C 395.61 182.222 396.985 183.052 398.459 183.693 L 399.097 183.956 C 401.81 185.016 404.425 186.275 406.923 187.715 L 420.473 198.503 C 424.405 202.729 427.713 207.542 430.252 212.795 L 435.357 229.337 C 435.78 232.162 436 235.055 436 238 V 244.833 V 258.5 H 436 V 272.167 V 285.833 H 436 V 299.5 V 313.167 H 436 V 320 C 436 321.36 435.73 322.651 435.242 323.827 L 429.827 329.242 C 428.651 329.73 427.36 330 426 330 H 418.275 H 402.825 V 330 H 387.375 H 371.925 V 330 H 356.475 H 341.025 V 330 H 325.575 H 310.125 V 330 H 294.675 H 279.225 V 330 H 263.775 H 248.325 V 330 H 232.875 H 217.425 V 330 H 201.975 H 186.525 V 330 H 171.075 H 155.625 V 330 H 140.175 H 124.725 V 330 H 117 C 115.641 330 114.349 329.73 113.173 329.242 L 107.758 323.827 C 107.27 322.651 107 321.36 107 320 V 313.167 V 299.5 H 107 V 285.833 V 272.167 H 107 V 258.5 V 244.833 H 107 V 238 C 107 235.088 107.214 232.227 107.628 229.433 L 112.622 213.056 C 115.107 207.848 118.347 203.067 122.2 198.856 L 135.494 188.055 C 137.641 186.783 139.877 185.647 142.19 184.656 L 143.186 184.241 C 144.876 183.555 146.441 182.623 147.83 181.498 L 153.722 172.52 C 154.177 170.759 154.329 168.902 154.116 167.011 L 153.981 165.769 C 153.85 164.525 153.732 163.276 153.627 162.022 C 151.354 158.847 151.164 155.472 151.069 152.068 L 151.153 139.492 C 151.36 134.462 151.773 129.498 152.383 124.613 L 152.394 124.529 L 154.894 109.723 C 155.95 104.771 157.212 99.9212 158.668 95.1875 L 163.727 81.0498 C 165.649 76.3661 167.77 71.8259 170.076 67.4453 L 177.715 54.5254 C 180.508 50.3027 183.489 46.274 186.641 42.457 L 196.832 31.4316 C 200.471 27.9227 204.28 24.6674 208.24 21.6846 L 220.789 13.4502 C 225.168 10.9758 229.688 8.8149 234.332 6.9912 L 248.66 2.544 C 253.508 1.4258 258.458 0.6639 263.493 0.2832 L 278.506 0.2832 C 283.541 0.6638 288.491 1.4259 293.339 2.544 L 307.667 6.9912 C 312.311 8.8149 316.831 10.9758 321.21 13.4502 L 333.759 21.6846 C 337.719 24.6673 341.528 27.9227 345.167 31.4316 L 355.359 42.458 C 358.511 46.2749 361.491 50.3038 364.284 54.5264 L 371.923 67.4453 C 374.229 71.826 376.35 76.3661 378.272 81.0498 L 383.331 95.1875 C 384.787 99.9212 386.049 104.771 387.105 109.723 L 389.605 124.529 Z" }), _jsxs("mask", { id: "outline-mask", children: [_jsx("rect", { width: "100%", height: "100%", fill: "white" }), _jsx("use", { href: "#head-shoulder-path", fill: "black" })] })] }), _jsx("rect", { width: "100%", height: "100%", fill: !isFaceCentered
|
|
4
|
+
? 'rgba(156, 156, 156, 0.40)'
|
|
5
|
+
: 'rgba(34, 139, 87, 0.75)', mask: "url(#outline-mask)" }), _jsx("use", { href: "#head-shoulder-path", fill: "none", stroke: !isFaceCentered ? '#B54708' : '#34D399', strokeWidth: "3", strokeDasharray: "10 5" })] }) }), _jsx("div", { className: "pointer-events-none absolute inset-0 block md:hidden", children: _jsxs("svg", { className: "block md:hidden", width: "100%", height: "100%", viewBox: "0 0 400 400", preserveAspectRatio: "xMidYMid slice", children: [_jsxs("defs", { children: [_jsx("path", { id: "fill-path", d: "M 300.85 220.1 C 301.15 223.9 302.705 227.284 305.171 230.096 V 230.097 L 311.15 234.9 L 316.351 238.504 C 320.778 242.037 324.741 246.126 328.135 250.665 L 336.459 265.409 C 338.554 270.577 340.015 276.069 340.746 281.79 V 320.036 V 359.74 V 369.667 L 340.28 374.731 C 338.938 377.967 336.351 380.555 333.115 381.896 H 300.872 H 264.633 H 228.396 H 192.158 H 155.921 H 119.682 H 83.4439 H 74.3844 L 69.319 381.896 C 66.0834 380.554 63.4953 377.967 62.1539 374.731 V 339.888 V 320.036 V 300.184 L 62.15 281.9 C 62.459 275.847 63.967 270.273 66.127 265.038 L 74.702 250.13 C 78.005 245.806 81.828 241.899 86.08 238.506 L 86.819 237.925 L 98.284 229.572 L 104.15 223.9 C 105.146 217.607 104.959 215.459 104.343 213.349 L 102.15 210.9 L 98.15 202.9 C 97.985 196.059 96.943 188.701 96.423 181.159 L 96.31 160.744 C 96.641 154.989 97.273 149.337 98.193 143.813 L 98.454 142.294 L 102.789 124.231 C 104.631 118.212 106.825 112.406 109.34 106.849 L 118.126 90.483 C 121.479 85.154 125.161 80.154 129.135 75.528 L 142.322 62.463 C 147.129 58.431 152.22 54.874 157.55 51.845 L 174.504 44.306 C 180.364 42.381 186.424 41.058 192.638 40.394 L 211.201 40.394 C 217.414 41.057 223.474 42.381 229.334 44.306 L 246.288 51.845 C 251.619 54.874 256.709 58.431 261.516 62.463 L 274.703 75.528 C 278.677 80.154 282.359 85.154 285.712 90.483 L 294.499 106.849 C 297.014 112.406 299.208 118.212 301.049 124.231 L 305.385 142.294 V 142.293 C 306.447 148.299 307.168 154.46 307.529 160.744 L 307.403 181.33 C 306.867 188.989 305.792 196.459 304.224 203.681 C 301.374 206.417 300.58 209.572 300.15 212.9 L 300.15 214.9 L 300.85 220.1 Z" }), _jsx("path", { id: "border-path", d: "M 300.85 220.1 C 301.15 223.9 302.705 227.284 305.171 230.096 V 230.097 L 311.15 234.9 L 316.351 238.504 C 320.778 242.037 324.741 246.126 328.135 250.665 L 336.459 265.409 C 338.554 270.577 340.015 276.069 340.746 281.79 V 320.036 V 359.74 V 369.667 L 340.28 374.731 C 338.938 377.967 336.351 380.555 333.115 381.896 H 300.872 H 264.633 H 228.396 H 192.158 H 155.921 H 119.682 H 83.4439 H 74.3844 L 69.319 381.896 C 66.0834 380.554 63.4953 377.967 62.1539 374.731 V 339.888 V 320.036 V 300.184 L 62.15 281.9 C 62.459 275.847 63.967 270.273 66.127 265.038 L 74.702 250.13 C 78.005 245.806 81.828 241.899 86.08 238.506 L 86.819 237.925 L 98.284 229.572 L 104.15 223.9 C 105.146 217.607 104.959 215.459 104.343 213.349 L 102.15 210.9 L 98.15 202.9 C 97.985 196.059 96.943 188.701 96.423 181.159 L 96.31 160.744 C 96.641 154.989 97.273 149.337 98.193 143.813 L 98.454 142.294 L 102.789 124.231 C 104.631 118.212 106.825 112.406 109.34 106.849 L 118.126 90.483 C 121.479 85.154 125.161 80.154 129.135 75.528 L 142.322 62.463 C 147.129 58.431 152.22 54.874 157.55 51.845 L 174.504 44.306 C 180.364 42.381 186.424 41.058 192.638 40.394 L 211.201 40.394 C 217.414 41.057 223.474 42.381 229.334 44.306 L 246.288 51.845 C 251.619 54.874 256.709 58.431 261.516 62.463 L 274.703 75.528 C 278.677 80.154 282.359 85.154 285.712 90.483 L 294.499 106.849 C 297.014 112.406 299.208 118.212 301.049 124.231 L 305.385 142.294 V 142.293 C 306.447 148.299 307.168 154.46 307.529 160.744 L 307.403 181.33 C 306.867 188.989 305.792 196.459 304.224 203.681 C 301.374 206.417 300.58 209.572 300.15 212.9 L 300.15 214.9 L 300.85 220.1 Z" }), _jsx("clipPath", { id: "face-cutout", children: _jsx("use", { href: "#fill-path" }) }), _jsxs("mask", { id: "face-mask", children: [_jsx("rect", { x: "0", y: "0", width: "400", height: "400", fill: "white" }), _jsx("use", { href: "#fill-path", fill: "black" })] })] }), _jsx("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: !isFaceCentered
|
|
6
|
+
? 'rgba(156, 156, 156, 0.40)'
|
|
7
|
+
: 'rgba(34, 139, 87, 0.75)', mask: "url(#face-mask)" }), _jsx("use", { href: "#border-path", fill: "none", stroke: !isFaceCentered ? '#B54708' : '#34D399', strokeWidth: "3", strokeDasharray: "12 8", strokeLinecap: "round", id: "border-element" })] }) })] }));
|
|
8
|
+
}
|
|
9
|
+
export default PersonOverlayDesktop;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadFaceApiModels(): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as faceapi from 'face-api.js';
|
|
2
|
+
export async function loadFaceApiModels() {
|
|
3
|
+
const MODEL_URL = '/models';
|
|
4
|
+
await Promise.all([
|
|
5
|
+
faceapi.nets.tinyFaceDetector.loadFromUri(MODEL_URL),
|
|
6
|
+
faceapi.nets.faceLandmark68Net.loadFromUri(MODEL_URL),
|
|
7
|
+
faceapi.nets.faceRecognitionNet.loadFromUri(MODEL_URL),
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
@@ -19,6 +19,8 @@ export interface UseKYCReturn {
|
|
|
19
19
|
triggerEvent: (detail: EventDetail) => void;
|
|
20
20
|
idFrontImageId: string | null;
|
|
21
21
|
setFrontImageId: (id: string | null) => void;
|
|
22
|
+
selfieImageId: string | null;
|
|
23
|
+
setSelfieImageId: (id: string | null) => void;
|
|
22
24
|
}
|
|
23
25
|
export declare function useKYC(): UseKYCReturn;
|
|
24
26
|
export {};
|
|
@@ -3,6 +3,7 @@ export function useKYC() {
|
|
|
3
3
|
const [step, setStep] = useState(1);
|
|
4
4
|
const [done, setDone] = useState(false);
|
|
5
5
|
const [idFrontImageId, setFrontImageId] = useState(null);
|
|
6
|
+
const [selfieImageId, setSelfieImageId] = useState(null);
|
|
6
7
|
const [capturing, setCapturing] = useState(null);
|
|
7
8
|
const subscribers = useRef([]);
|
|
8
9
|
const subscribe = (subscriber) => {
|
|
@@ -25,6 +26,8 @@ export function useKYC() {
|
|
|
25
26
|
setCapturing,
|
|
26
27
|
idFrontImageId,
|
|
27
28
|
setFrontImageId,
|
|
29
|
+
selfieImageId,
|
|
30
|
+
setSelfieImageId,
|
|
28
31
|
subscribe,
|
|
29
32
|
triggerEvent,
|
|
30
33
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Resizer from 'react-image-file-resizer';
|
|
2
|
+
export function dataURLtoBlob(dataURL) {
|
|
3
|
+
const parts = dataURL.split(';base64,');
|
|
4
|
+
const contentType = parts[0].split(':')[1];
|
|
5
|
+
const raw = window.atob(parts[1]);
|
|
6
|
+
const rawLength = raw.length;
|
|
7
|
+
const uInt8Array = new Uint8Array(rawLength);
|
|
8
|
+
for (let i = 0; i < rawLength; ++i) {
|
|
9
|
+
uInt8Array[i] = raw.charCodeAt(i);
|
|
10
|
+
}
|
|
11
|
+
return new Blob([uInt8Array], { type: contentType });
|
|
12
|
+
}
|
|
13
|
+
export const resizeFile = (file) => new Promise((resolve) => {
|
|
14
|
+
Resizer.imageFileResizer(file, 300, 300, 'jpeg', 100, 0, (uri) => {
|
|
15
|
+
resolve(uri);
|
|
16
|
+
}, 'file');
|
|
17
|
+
});
|
|
@@ -24,7 +24,9 @@ import { useSignInContext } from './SignInContext.js';
|
|
|
24
24
|
export function MobileNumberSignIn() {
|
|
25
25
|
const context = useSignInContext();
|
|
26
26
|
const dialog = useDialogContext();
|
|
27
|
-
const
|
|
27
|
+
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
28
|
+
signUp: ctx.signUp,
|
|
29
|
+
})));
|
|
28
30
|
const signInMutation = useSignInMutation();
|
|
29
31
|
const sendVerificationCodeMutation = useSendVerificationCodeMutation();
|
|
30
32
|
const localeInfo = useLocaleInfo();
|
|
@@ -98,7 +100,7 @@ export function MobileNumberSignIn() {
|
|
|
98
100
|
dialog.setOpen(false);
|
|
99
101
|
}, className: "border-border-primary bg-bg-primary text-text-secondary-700 mt-lg", children: [_jsx(FacebookIcon, { className: "size-6" }), "Continue with Facebook"] })] }), _jsxs("div", { className: "mt-6 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-tertiary-600", children: "Don't have an account?" }), _jsx("button", { type: "submit", className: "text-button-tertiary-fg font-semibold", onClick: () => {
|
|
100
102
|
dialog.setOpen(false);
|
|
101
|
-
|
|
103
|
+
globalStore.signUp.setOpen(true);
|
|
102
104
|
}, children: "Sign up" })] })] })), context.step === 2 && (_jsxs(_Fragment, { children: [_jsx("h2", { className: "mt-xl text-center text-lg font-semibold", children: "Check your Phone" }), _jsxs("p", { className: "text-text-secondary-700 mt-xs text-center text-sm", children: ["We\u2019ve sent a verification code to your mobile number", ' ', _jsx("span", { className: "font-semibold", children: mobileNumberParser.format(step1Form.getValues('mobileNumber')) }), ' ', "via text"] }), _jsxs("form", { ref: form2Ref, className: "mt-5", onSubmit: step2Form.handleSubmit(async ({ verificationCode }) => {
|
|
103
105
|
const { mobileNumber } = step1Form.getValues();
|
|
104
106
|
try {
|
|
@@ -25,6 +25,7 @@ export function NameAndPasswordSignIn() {
|
|
|
25
25
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
26
26
|
signIn: ctx.signIn,
|
|
27
27
|
signUp: ctx.signUp,
|
|
28
|
+
forgotPassword: ctx.forgotPassword,
|
|
28
29
|
})));
|
|
29
30
|
const signInMutation = useSignInMutation({
|
|
30
31
|
onSuccess(authenticator) {
|
|
@@ -85,6 +86,7 @@ export function NameAndPasswordSignIn() {
|
|
|
85
86
|
name: '',
|
|
86
87
|
password: '',
|
|
87
88
|
secretAnswer: '',
|
|
89
|
+
termsAccepted: false,
|
|
88
90
|
},
|
|
89
91
|
});
|
|
90
92
|
const secretQuestion = signInMutation.data
|
|
@@ -117,7 +119,10 @@ export function NameAndPasswordSignIn() {
|
|
|
117
119
|
signInMutation.reset();
|
|
118
120
|
form.setValue('secretAnswer', '');
|
|
119
121
|
},
|
|
120
|
-
}) }), _jsx(Field.ErrorText, { children: form.formState.errors.name?.message })] }), _jsx(Field.Root, { disabled: !!signInMutation.data, invalid: !!form.formState.errors.name, className: "mt-xl", children: _jsxs(PasswordInput.Root, { children: [_jsx(PasswordInput.Label, { children: "Password" }), _jsxs("div", { children: [_jsxs(PasswordInput.Control, { children: [_jsx(PasswordInput.Input, { placeholder: "Enter your password", ...form.register('password') }), _jsx(PasswordInput.VisibilityTrigger, { children: _jsx(PasswordInput.Indicator, { fallback: _jsx(EyeOffIcon, {}), asChild: true, children: _jsx(EyeIcon, {}) }) })] }), _jsx(Field.ErrorText, { children: form.formState.errors.password?.message })] }), _jsx("div", { className: "mt-2 flex justify-end", children: _jsx("button", { type: "button", tabIndex: -1, className: "text-button-tertiary-fg text-sm font-semibold",
|
|
122
|
+
}) }), _jsx(Field.ErrorText, { children: form.formState.errors.name?.message })] }), _jsx(Field.Root, { disabled: !!signInMutation.data, invalid: !!form.formState.errors.name, className: "mt-xl", children: _jsxs(PasswordInput.Root, { children: [_jsx(PasswordInput.Label, { children: "Password" }), _jsxs("div", { children: [_jsxs(PasswordInput.Control, { children: [_jsx(PasswordInput.Input, { placeholder: "Enter your password", ...form.register('password') }), _jsx(PasswordInput.VisibilityTrigger, { children: _jsx(PasswordInput.Indicator, { fallback: _jsx(EyeOffIcon, {}), asChild: true, children: _jsx(EyeIcon, {}) }) })] }), _jsx(Field.ErrorText, { children: form.formState.errors.password?.message })] }), _jsx("div", { className: "mt-2 flex justify-end", children: _jsx("button", { type: "button", tabIndex: -1, className: "text-button-tertiary-fg text-sm font-semibold", onClick: () => {
|
|
123
|
+
globalStore.forgotPassword.setOpen(true);
|
|
124
|
+
dialog.setOpen(false);
|
|
125
|
+
}, children: "Forgot Password" }) })] }) }), signInMutation.data && (_jsxs(Field.Root, { invalid: !!form.formState.errors.secretAnswer, className: "mt-xl", children: [_jsx(Field.Label, { children: secretQuestion }), _jsx(Field.Input, { placeholder: "Answer the security question", ...form.register('secretAnswer') }), _jsx(Field.ErrorText, { children: form.formState.errors.secretAnswer?.message })] })), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: signInMutation.isPending || authenticateMutation.isPending, children: "Log In" }), _jsx(Controller, { control: form.control, name: "termsAccepted", render: (o) => (_jsxs(Field.Root, { invalid: o.fieldState.invalid, className: "mt-xl", children: [_jsxs(Checkbox.Root, { checked: o.field.value, onCheckedChange: (details) => {
|
|
121
126
|
o.field.onChange(details.checked);
|
|
122
127
|
}, children: [_jsx(Checkbox.Control, { children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsxs(Checkbox.Label, { children: ["I am at least 21 years of age and I accept the", ' ', _jsx("span", { className: "text-brand-400 whitespace-nowrap underline underline-offset-2", children: "Terms and Conditions." })] }), _jsx(Checkbox.HiddenInput, {})] }), _jsx(Field.ErrorText, { className: "ml-6 text-xs", children: o.fieldState.error?.message })] })) })] }), _jsxs("div", { className: "mt-6 flex items-center gap-2", children: [_jsx("div", { className: "bg-text-tertiary-600/50 h-px flex-grow" }), _jsx("span", { className: "text-text-tertiary-600 text-sm font-semibold", children: "Log in directly with" }), _jsx("div", { className: "bg-text-tertiary-600/50 h-px flex-grow" })] }), _jsxs("div", { className: "mt-6", children: [_jsxs(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
|
|
123
128
|
dialog.setOpen(false);
|
|
Binary file
|