@opexa/portal-components 0.0.261 → 0.0.263
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/useCreateVentajaWithdrawalMutation.d.ts +2 -2
- package/dist/client/hooks/useCreateVentajaWithdrawalMutation.js +5 -5
- package/dist/components/DepositWithdrawal/Withdrawal/VentajaWithdrawal/VentajaWithdrawal.js +2 -2
- package/dist/components/KYC/IdentityVerification.js +20 -15
- package/dist/components/KYC/KYC.d.ts +1 -1
- package/dist/components/KYC/KYC.js +3 -3
- package/dist/components/KYC/KYC.lazy.js +1 -3
- package/dist/components/KYC/useKYC.d.ts +0 -2
- package/dist/components/KYC/useKYC.js +0 -4
- package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.js +2 -2
- package/dist/components/SignUp/SignUpKYC/CaptureSelfie.js +3 -3
- package/dist/components/SignUp/SignUpKYC/ImageUploader.js +1 -1
- package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.d.ts +7 -0
- package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.js +9 -0
- package/dist/components/SignUp/SignUpKYC/utils.d.ts +9 -0
- package/dist/components/SignUp/SignUpKYC/utils.js +79 -0
- package/dist/components/shared/IdFrontImageField/IdFrontImageField.client.js +1 -1
- package/dist/components/shared/SelfieImageField/SelfieImageField.client.js +1 -1
- package/dist/components/shared/SelfieImageField/useSelfieImageField.js +19 -17
- package/dist/handlers/postTransformIdFrontImage.js +21 -6
- package/dist/handlers/postTransformSelfieImage.js +20 -9
- package/dist/services/queries.d.ts +1 -1
- package/dist/services/queries.js +4 -2
- package/dist/services/wallet.d.ts +5 -5
- package/dist/services/wallet.js +6 -5
- package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
- package/dist/utils/mutationKeys.d.ts +1 -1
- package/dist/utils/mutationKeys.js +1 -4
- package/package.json +1 -1
- package/dist/components/FeatureFlag/FeatureFlag.d.ts +0 -1
- package/dist/components/FeatureFlag/FeatureFlag.js +0 -29
- package/dist/components/FeatureFlag/index.d.ts +0 -1
- package/dist/components/FeatureFlag/index.js +0 -1
- package/dist/components/KYC/AutoOpen.d.ts +0 -1
- package/dist/components/KYC/AutoOpen.js +0 -40
- package/dist/components/KYC/backup/Header.d.ts +0 -1
- package/dist/components/KYC/backup/Header.js +0 -8
- package/dist/components/KYC/backup/Indicator.d.ts +0 -1
- package/dist/components/KYC/backup/Indicator.js +0 -9
- package/dist/components/KYC/backup/KYC.d.ts +0 -1
- package/dist/components/KYC/backup/KYC.js +0 -14
- package/dist/components/KYC/backup/KYC.lazy.d.ts +0 -1
- package/dist/components/KYC/backup/KYC.lazy.js +0 -26
- package/dist/components/KYC/backup/KYCContext.d.ts +0 -6
- package/dist/components/KYC/backup/KYCContext.js +0 -2
- package/dist/components/KYC/backup/Step1.d.ts +0 -1
- package/dist/components/KYC/backup/Step1.js +0 -13
- package/dist/components/KYC/backup/Step2.d.ts +0 -1
- package/dist/components/KYC/backup/Step2.js +0 -13
- package/dist/components/KYC/backup/Step3.d.ts +0 -1
- package/dist/components/KYC/backup/Step3.js +0 -13
- package/dist/components/KYC/backup/Step4.d.ts +0 -1
- package/dist/components/KYC/backup/Step4.js +0 -7
- package/dist/components/KYC/backup/useKYC.d.ts +0 -10
- package/dist/components/KYC/backup/useKYC.js +0 -8
- package/dist/components/KYC/loadModels.d.ts +0 -1
- package/dist/components/KYC/loadModels.js +0 -9
- package/dist/components/Messages/Message.d.ts +0 -1
- package/dist/components/Messages/Message.js +0 -35
- package/dist/components/Messages/MessageContext.d.ts +0 -6
- package/dist/components/Messages/MessageContext.js +0 -2
- package/dist/components/Messages/MessagePopup.d.ts +0 -1
- package/dist/components/Messages/MessagePopup.js +0 -20
- package/dist/components/Messages/MessageTrigger.d.ts +0 -8
- package/dist/components/Messages/MessageTrigger.js +0 -19
- package/dist/components/Quests/CountdownTimer.d.ts +0 -15
- package/dist/components/Quests/CountdownTimer.js +0 -33
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +0 -4
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +0 -78
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.d.ts +0 -8
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +0 -9
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +0 -4
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.js +0 -4
- package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +0 -4
- package/dist/components/Quests/WageringQuest/WageringQuest.js +0 -20
- package/dist/components/Quests/WageringQuest/WageringQuestModal.d.ts +0 -9
- package/dist/components/Quests/WageringQuest/WageringQuestModal.js +0 -9
- package/dist/components/SignUp/SignUp.lazy.d.ts +0 -12
- package/dist/components/SignUp/SignUp.lazy.js +0 -18
- package/dist/components/SignUp/SignUpContext.d.ts +0 -6
- package/dist/components/SignUp/SignUpContext.js +0 -2
- package/dist/components/SignUp/SignUpForm.d.ts +0 -1
- package/dist/components/SignUp/SignUpForm.js +0 -284
- package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.d.ts +0 -1
- package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.js +0 -198
- package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.d.ts +0 -1
- package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.js +0 -251
- package/dist/components/SignUp/SignUpPagcor/ImageUploader.d.ts +0 -10
- package/dist/components/SignUp/SignUpPagcor/ImageUploader.js +0 -41
- package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.d.ts +0 -1
- package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.js +0 -429
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.d.ts +0 -13
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.js +0 -26
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.d.ts +0 -7
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.js +0 -2
- package/dist/components/SignUp/SignUpPagcor/useImageUploader.d.ts +0 -11
- package/dist/components/SignUp/SignUpPagcor/useImageUploader.js +0 -20
- package/dist/components/shared/IdDocumentField.client.d.ts +0 -25
- package/dist/components/shared/IdDocumentField.client.js +0 -204
- package/dist/components/shared/IdDocumentField.d.ts +0 -2
- package/dist/components/shared/IdDocumentField.js +0 -11
- package/dist/components/shared/SelfieField.client.d.ts +0 -20
- package/dist/components/shared/SelfieField.client.js +0 -327
- package/dist/components/shared/SelfieField.d.ts +0 -2
- package/dist/components/shared/SelfieField.js +0 -11
- package/dist/constants/BranchCode.d.ts +0 -4
- package/dist/constants/BranchCode.js +0 -42
- package/dist/handlers.d.ts +0 -43
- package/dist/handlers.js +0 -297
- package/dist/icons/BellRingIcon.d.ts +0 -2
- package/dist/icons/BellRingIcon.js +0 -4
- package/dist/utils/dataUrlToBlob.d.ts +0 -1
- package/dist/utils/dataUrlToBlob.js +0 -11
- package/dist/utils/resizeImageSize.d.ts +0 -2
- package/dist/utils/resizeImageSize.js +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SetOptional } from 'type-fest';
|
|
2
|
-
import { type
|
|
2
|
+
import { type CreateVentajaDisbursementWithdrawalInput } from '../../services/wallet';
|
|
3
3
|
import type { Mutation } from '../../types';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const useCreateVentajaDisbursementWithdrawalMutation: Mutation<string, SetOptional<CreateVentajaDisbursementWithdrawalInput, 'id'>>;
|
|
@@ -2,18 +2,18 @@ import { ObjectId } from '@opexa/object-id';
|
|
|
2
2
|
import { useMutation } from '@tanstack/react-query';
|
|
3
3
|
import invariant from 'tiny-invariant';
|
|
4
4
|
import { ObjectType } from '../../services/ObjectType.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { createVentajaDisbursementWithdrawal, } from '../../services/wallet.js';
|
|
6
|
+
import { getCreateVentajaDisbursementWithdrawalMutationKey } from '../../utils/mutationKeys.js';
|
|
7
7
|
import { getSession } from '../services/getSession.js';
|
|
8
|
-
export const
|
|
8
|
+
export const useCreateVentajaDisbursementWithdrawalMutation = (config) => {
|
|
9
9
|
const mutation = useMutation({
|
|
10
10
|
...config,
|
|
11
|
-
mutationKey:
|
|
11
|
+
mutationKey: getCreateVentajaDisbursementWithdrawalMutationKey(),
|
|
12
12
|
mutationFn: async (input) => {
|
|
13
13
|
const id = input.id ?? ObjectId.generate(ObjectType.Withdrawal).toString();
|
|
14
14
|
const session = await getSession();
|
|
15
15
|
invariant(session.status === 'authenticated');
|
|
16
|
-
await
|
|
16
|
+
await createVentajaDisbursementWithdrawal({ ...input, id }, {
|
|
17
17
|
headers: {
|
|
18
18
|
Authorization: `Bearer ${session.token}`,
|
|
19
19
|
...(session.domain && {
|
|
@@ -6,7 +6,7 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
6
6
|
import { Controller, useForm } from 'react-hook-form';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { useShallow } from 'zustand/shallow';
|
|
9
|
-
import {
|
|
9
|
+
import { useCreateVentajaDisbursementWithdrawalMutation } from '../../../../client/hooks/useCreateVentajaWithdrawalMutation.js';
|
|
10
10
|
import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
|
|
11
11
|
import { useInstapayBankListQuery } from '../../../../client/hooks/useInstapayBankListQuery.js';
|
|
12
12
|
import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
|
|
@@ -35,7 +35,7 @@ export function VentajaWithdrawal() {
|
|
|
35
35
|
depositWithdrawal: ctx.depositWithdrawal,
|
|
36
36
|
})));
|
|
37
37
|
const [status, setStatus] = useState('waiting');
|
|
38
|
-
const createWithdrawalMutation =
|
|
38
|
+
const createWithdrawalMutation = useCreateVentajaDisbursementWithdrawalMutation({
|
|
39
39
|
onMutate() {
|
|
40
40
|
setStatus('processing');
|
|
41
41
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
|
-
import { useForm } from 'react-hook-form';
|
|
5
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import { useShallow } from 'zustand/shallow';
|
|
8
8
|
import { useCreateMemberVerificationMutation } from '../../client/hooks/useCreateMemberVerificationMutation.js';
|
|
@@ -10,13 +10,13 @@ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
|
10
10
|
import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
|
|
11
11
|
import { useUpdateMemberVerificationMutation } from '../../client/hooks/useUpdateMemberVerificationMutation.js';
|
|
12
12
|
import { toaster } from '../../client/utils/toaster.js';
|
|
13
|
-
import { HelpCircleIcon } from '../../icons/HelpCircleIcon.js';
|
|
14
13
|
import { Button } from '../../ui/Button/index.js';
|
|
15
14
|
import { Dialog } from '../../ui/Dialog/index.js';
|
|
16
15
|
import { Field } from '../../ui/Field/index.js';
|
|
17
16
|
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
18
17
|
import { getMemberVerificationQueryKey } from '../../utils/queryKeys.js';
|
|
19
|
-
import
|
|
18
|
+
import { IdFrontImageField } from '../shared/IdFrontImageField/index.js';
|
|
19
|
+
import { SelfieImageField } from '../shared/SelfieImageField/index.js';
|
|
20
20
|
import { useKYCContext } from './KYCContext.js';
|
|
21
21
|
const formSchema = z.object({
|
|
22
22
|
selfieImage: z.string().min(1, 'Selfie image is required.'),
|
|
@@ -97,19 +97,24 @@ export function IdentityVerification() {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
useEffect(() => {
|
|
100
|
-
if (kyc.
|
|
101
|
-
form.setValue('idFrontImage', kyc.idFrontImageId);
|
|
102
|
-
}
|
|
103
|
-
if (kyc.selfieImageId) {
|
|
100
|
+
if (kyc.selfieImageId)
|
|
104
101
|
form.setValue('selfieImage', kyc.selfieImageId);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
if (kyc.idFrontImageId)
|
|
103
|
+
form.setValue('idFrontImage', kyc.idFrontImageId);
|
|
104
|
+
}, [form, kyc.idFrontImageId, kyc.selfieImageId]);
|
|
105
|
+
return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center text-lg font-semibold", children: "Verify your identity" }), _jsx(Dialog.Description, { className: "text-text-secondary-700 mt-xs text-center text-sm", children: "Verify your details to confirm your identity and secure your access." }), _jsxs("div", { className: "border-border-primary bg-bg-primary text-text-placeholder mt-7 rounded-xl border p-lg text-xs leading-tight", children: [_jsx("h3", { className: "font-semibold", children: "Instructions" }), _jsxs("ol", { className: "mt-2 list-inside list-decimal", children: [_jsx("li", { children: "Upload a full photo of your ID." }), _jsx("li", { children: "Please ensure that all details in the uploaded image are legible." }), _jsx("li", { children: "Please ensure that the ID uploaded is within the validity period." })] })] }), _jsxs("form", { className: "mt-xl", onSubmit: form.handleSubmit(onSubmit), children: [_jsx(Controller, { control: form.control, name: "idFrontImage", render: (o) => (_jsxs(Field.Root, { invalid: o.fieldState.invalid, children: [_jsx(Field.Label, { children: "Front of your ID" }), _jsx(IdFrontImageField, { value: o.field.value, onChange: o.field.onChange, onError: (error) => {
|
|
106
|
+
form.setValue('idFrontImage', '');
|
|
107
|
+
form.setError('idFrontImage', {
|
|
108
|
+
type: 'validate',
|
|
109
|
+
message: error.message,
|
|
110
|
+
});
|
|
111
|
+
} }), _jsx(Field.ErrorText, { children: o.fieldState.error?.message })] })) }), _jsx(Controller, { control: form.control, name: "selfieImage", render: (o) => (_jsxs(Field.Root, { invalid: o.fieldState.invalid, className: "mt-3", children: [_jsx(Field.Label, { children: "Selfie holding your ID" }), _jsx(SelfieImageField, { value: o.field.value, onChange: o.field.onChange, onError: (error) => {
|
|
112
|
+
form.setValue('selfieImage', '');
|
|
113
|
+
form.setError('selfieImage', {
|
|
114
|
+
type: 'validate',
|
|
115
|
+
message: error.message,
|
|
116
|
+
});
|
|
117
|
+
} }), _jsx(Field.ErrorText, { children: o.fieldState.error?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-6", disabled: createPending || updatePending, children: "Continue" }), _jsx(Button, { variant: "outline", colorScheme: "gray", className: "mt-lg", type: "button", onClick: () => {
|
|
113
118
|
globalStore.kyc.setOpen(false);
|
|
114
119
|
}, children: "Skip for now" })] })] }));
|
|
115
120
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import dynamic from 'next/dynamic';
|
|
4
|
-
import Script from 'next/script';
|
|
5
4
|
import { useShallow } from 'zustand/shallow';
|
|
6
5
|
import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
7
6
|
const Component = dynamic(() => import('./KYC.lazy.js').then((m) => m.KYC), {
|
|
@@ -10,5 +9,6 @@ const Component = dynamic(() => import('./KYC.lazy.js').then((m) => m.KYC), {
|
|
|
10
9
|
});
|
|
11
10
|
export function KYC(props) {
|
|
12
11
|
const touched = useGlobalStore(useShallow((ctx) => ctx.kyc['~touched']));
|
|
13
|
-
|
|
12
|
+
if (touched)
|
|
13
|
+
return _jsx(Component, { ...props });
|
|
14
14
|
}
|
|
@@ -9,8 +9,6 @@ import { XIcon } from '../../icons/XIcon.js';
|
|
|
9
9
|
import { Dialog } from '../../ui/Dialog/index.js';
|
|
10
10
|
import { Portal } from '../../ui/Portal/index.js';
|
|
11
11
|
import { BasicInformation } from './BasicInformation.js';
|
|
12
|
-
import { CaptureIdDocument } from './CaptureIdDocument.js';
|
|
13
|
-
import { CaptureSelfie } from './CaptureSelfie.js';
|
|
14
12
|
import { IdentityVerification } from './IdentityVerification.js';
|
|
15
13
|
import { Indicator } from './Indicator.js';
|
|
16
14
|
import { KYCContext } from './KYCContext.js';
|
|
@@ -43,5 +41,5 @@ export function KYC(props) {
|
|
|
43
41
|
}, [steps, kyc]);
|
|
44
42
|
return (_jsxs(_Fragment, { children: [_jsx(KYCContext, { value: kyc, children: _jsx(Dialog.Root, { open: globalStore.kyc.open && hasMissingData, onOpenChange: (details) => {
|
|
45
43
|
globalStore.kyc.setOpen(details.open);
|
|
46
|
-
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: kyc.reset, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children:
|
|
44
|
+
}, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: kyc.reset, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: "bg-bg-primary-alt lg:min-h-auto mx-auto min-h-full w-full overflow-y-auto lg:w-fit", children: _jsxs("div", { className: "flex h-dvh w-full flex-col overflow-y-auto p-3xl sm:h-fit sm:overflow-auto lg:w-[400px]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx(Image, { src: props.logo, alt: "", width: 200, height: 100, className: "mx-auto mb-5 block h-7.5 w-auto", draggable: false }), _jsx(Indicator, {}), kyc.step === 1 && _jsx(BasicInformation, {}), kyc.step === 2 && _jsx(IdentityVerification, {}), kyc.step === 3 && _jsx(PersonalInformation, {})] }) }) })] }) }) }), _jsx(KYCReminder, { ...props })] }));
|
|
47
45
|
}
|
|
@@ -13,8 +13,6 @@ export interface UseKYCReturn {
|
|
|
13
13
|
setStep: (step: number) => void;
|
|
14
14
|
done: boolean;
|
|
15
15
|
setDone: (done: boolean) => void;
|
|
16
|
-
capturing: CaptureSubject | null;
|
|
17
|
-
setCapturing: (capturing: CaptureSubject | null) => void;
|
|
18
16
|
subscribe: (subscriber: Subscriber) => UnsubscribeFn;
|
|
19
17
|
triggerEvent: (detail: EventDetail) => void;
|
|
20
18
|
idFrontImageId: string | null;
|
|
@@ -4,7 +4,6 @@ export function useKYC() {
|
|
|
4
4
|
const [done, setDone] = useState(false);
|
|
5
5
|
const [idFrontImageId, setFrontImageId] = useState(null);
|
|
6
6
|
const [selfieImageId, setSelfieImageId] = useState(null);
|
|
7
|
-
const [capturing, setCapturing] = useState(null);
|
|
8
7
|
const subscribers = useRef([]);
|
|
9
8
|
const subscribe = (subscriber) => {
|
|
10
9
|
subscribers.current.push(subscriber);
|
|
@@ -20,7 +19,6 @@ export function useKYC() {
|
|
|
20
19
|
const reset = () => {
|
|
21
20
|
setStep(1);
|
|
22
21
|
setDone(false);
|
|
23
|
-
setCapturing(null);
|
|
24
22
|
setFrontImageId(null);
|
|
25
23
|
setSelfieImageId(null);
|
|
26
24
|
};
|
|
@@ -29,8 +27,6 @@ export function useKYC() {
|
|
|
29
27
|
setStep,
|
|
30
28
|
done,
|
|
31
29
|
setDone,
|
|
32
|
-
capturing,
|
|
33
|
-
setCapturing,
|
|
34
30
|
idFrontImageId,
|
|
35
31
|
setFrontImageId,
|
|
36
32
|
selfieImageId,
|
|
@@ -9,8 +9,8 @@ import { XIcon } from '../../../icons/XIcon.js';
|
|
|
9
9
|
import { Button } from '../../../ui/Button/index.js';
|
|
10
10
|
import { Dialog } from '../../../ui/Dialog/index.js';
|
|
11
11
|
import { Portal } from '../../../ui/Portal/index.js';
|
|
12
|
-
import { dataURLtoBlob, resizeFile } from '../../KYC/utils.js';
|
|
13
12
|
import { useSignUpKYCPropsContext } from './SignUpKYCContext.js';
|
|
13
|
+
import { dataURLtoBlob, resizeFile } from './utils.js';
|
|
14
14
|
export function CaptureIdDocument() {
|
|
15
15
|
const props = useSignUpKYCPropsContext();
|
|
16
16
|
const [videoStream, setVideoStream] = useState(null);
|
|
@@ -188,7 +188,7 @@ export function CaptureIdDocument() {
|
|
|
188
188
|
}
|
|
189
189
|
startCamera();
|
|
190
190
|
}
|
|
191
|
-
return (_jsx(Dialog.Root, { open: props.capturing === 'ID_DOCUMENT', lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: twMerge('bg-bg-primary-alt mx-auto h-full w-full items-start p-3xl pb-4xl lg:h-auto lg:w-fit lg:rounded-xl
|
|
191
|
+
return (_jsx(Dialog.Root, { open: props.capturing === 'ID_DOCUMENT', lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: twMerge('bg-bg-primary-alt mx-auto h-full w-full items-start overflow-y-auto p-3xl pb-4xl lg:h-auto lg:w-fit lg:rounded-xl', props.className), children: _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: () => {
|
|
192
192
|
stopCamera();
|
|
193
193
|
props.setCapturing(null);
|
|
194
194
|
}, 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 Picture of Your Front ID" }), _jsxs(Dialog.Description, { className: "lg:max-w-auto text-text-tertiary-600 mx-auto mt-sm max-w-[19rem] text-center text-sm lg:max-w-full", children: ["Make sure your ID is clearly visible, well-lit, and not blurry.", _jsx("br", { className: "hidden lg:block" }), " Avoid glare or reflections, and ensure all corners are within the frame."] }), _jsx("div", { id: "parent", className: "border-border-disabled mt-6 aspect-video rounded-xl border bg-black lg:mt-8", children: cameraError ? (_jsx("div", { className: "flex h-full items-center justify-center p-4", children: _jsxs("div", { className: "text-center", children: [_jsx("p", { className: "text-red-500 mb-2 text-sm", children: "Camera Error" }), _jsx("p", { className: "text-gray-400 text-xs", children: cameraError })] }) })) : captureInProgress ? (_jsxs("div", { className: "relative flex h-fit w-full flex-col items-center justify-center", children: [_jsx("video", { ref: videoElement, autoPlay: true, muted: true, playsInline: true, className: "relative h-[60vh] w-full rounded-lg object-cover md:aspect-video md:max-h-[333px]", width: "100%", height: "100%" }), _jsxs("div", { className: "pointer-events-none absolute inset-0 z-50", children: [_jsx("div", { className: twMerge('absolute inset-0 w-full bg-black/60 backdrop-blur-sm [clip-path:polygon(0%_0%,0%_100%,calc(50%-158px)_100%,calc(50%-158px)_calc(50%-100px),calc(50%+158px)_calc(50%-100px),calc(50%+158px)_calc(50%+100px),calc(50%-158px)_calc(50%+100px),calc(50%-158px)_100%,100%_100%,100%_0%)] md:[clip-path:polygon(0%_0%,0%_100%,calc(50%-225px)_100%,calc(50%-225px)_calc(50%-142px),calc(50%+225px)_calc(50%-142px),calc(50%+225px)_calc(50%+142px),calc(50%-225px)_calc(50%+142px),calc(50%-225px)_100%,100%_100%,100%_0%)]') }), _jsx("div", { className: "absolute inset-0 z-[60] mx-auto flex items-center justify-center", children: _jsx("div", { className: "relative aspect-[1011/638] h-[200px] md:h-[295px] md:w-[450px]", children: _jsx("div", { className: "h-full w-full rounded-lg border-4 border-dashed border-[#B54708]" }) }) })] })] })) : (_jsx("div", { ref: containerRef, className: "relative grid h-full w-full place-items-center rounded-lg object-contain md:max-h-[333px]" })) }), cameraError ? (_jsx("div", { className: "mt-4 text-center", children: _jsx(Button, { className: "mx-auto px-xl lg:w-fit", onClick: () => {
|
|
@@ -10,9 +10,9 @@ import { Button } from '../../../ui/Button/index.js';
|
|
|
10
10
|
import { Dialog } from '../../../ui/Dialog/index.js';
|
|
11
11
|
import { Portal } from '../../../ui/Portal/index.js';
|
|
12
12
|
import { onMobileDevice } from '../../../utils/onMobileDevice.js';
|
|
13
|
-
import PersonOverlayDesktop from '
|
|
14
|
-
import { dataURLtoBlob, loadFaceApiModels, resizeFile } from '../../KYC/utils.js';
|
|
13
|
+
import PersonOverlayDesktop from './PersonOverlayDesktop.js';
|
|
15
14
|
import { useSignUpKYCPropsContext } from './SignUpKYCContext.js';
|
|
15
|
+
import { dataURLtoBlob, loadFaceApiModels, resizeFile } from './utils.js';
|
|
16
16
|
export function CaptureSelfie() {
|
|
17
17
|
const props = useSignUpKYCPropsContext();
|
|
18
18
|
const mobileDevice = onMobileDevice();
|
|
@@ -244,7 +244,7 @@ export function CaptureSelfie() {
|
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
246
|
}, []);
|
|
247
|
-
return (_jsx(Dialog.Root, { open: props.capturing === 'SELFIE', lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: twMerge('bg-bg-primary-alt mx-auto h-full w-full items-start p-3xl pb-4xl lg:h-auto lg:w-fit lg:rounded-xl
|
|
247
|
+
return (_jsx(Dialog.Root, { open: props.capturing === 'SELFIE', lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: twMerge('bg-bg-primary-alt mx-auto h-full w-full items-start overflow-y-auto p-3xl pb-4xl lg:h-auto lg:w-fit lg:rounded-xl', props.className), children: _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: () => {
|
|
248
248
|
stopCamera();
|
|
249
249
|
props.setCapturing(null);
|
|
250
250
|
}, 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%" }), isCapturing && (_jsx("span", { className: "absolute inset-x-0 bottom-8 flex items-center justify-center text-5xl font-bold text-[#713B12CC] md:bottom-4", 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: ["Retake 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", children: ["Use Photo", _jsx(Camera01Icon, { className: "size-5" })] })] })), !captureInProgress && (_jsxs(Button, { className: twMerge('mx-auto mt-6 px-xl lg:mt-8', selectedImage && 'hidden'), onClick: startCamera, disabled: !modelsLoaded, type: "button", children: ["Start Camera", _jsx(Camera01Icon, { className: "size-5" })] }))] }) }) })] }) }));
|
|
@@ -5,8 +5,8 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
import { UploadCloud02Icon } from '../../../icons/UploadCloud02Icon.js';
|
|
7
7
|
import { Button } from '../../../ui/Button/index.js';
|
|
8
|
-
import { validateFile } from '../../KYC/utils.js';
|
|
9
8
|
import { useSignUpKYCPropsContext } from './SignUpKYCContext.js';
|
|
9
|
+
import { validateFile } from './utils.js';
|
|
10
10
|
function ImageUploader({ value, name, hasDescription = true, onChange, captureObject, }) {
|
|
11
11
|
const props = useSignUpKYCPropsContext();
|
|
12
12
|
const [previewUrl, setPreviewUrl] = useState(null);
|
|
@@ -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,9 @@
|
|
|
1
|
+
export declare function loadFaceApiModels(): Promise<void>;
|
|
2
|
+
export declare function dataURLtoBlob(dataURL: string): Blob;
|
|
3
|
+
export declare const resizeFile: (file: File) => Promise<unknown>;
|
|
4
|
+
export declare const MAX_FILE_SIZE = 10;
|
|
5
|
+
export declare const MAX_NAME_LENGTH = 52;
|
|
6
|
+
export declare const SUPPORTED_FILES: string[];
|
|
7
|
+
export declare function validateFile(file: File): "File too large" | "File name too long" | "Unsupported file" | undefined;
|
|
8
|
+
export declare function showPermissionInstructions(): void;
|
|
9
|
+
export declare const cameraErrorDescriptions: Record<string, string>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as faceapi from 'face-api.js';
|
|
2
|
+
import Resizer from 'react-image-file-resizer';
|
|
3
|
+
export async function loadFaceApiModels() {
|
|
4
|
+
// const url = `${STATIC_ENDPOINT}/models`;
|
|
5
|
+
const url = '/models';
|
|
6
|
+
await Promise.all([
|
|
7
|
+
faceapi.nets.tinyFaceDetector.loadFromUri(url),
|
|
8
|
+
faceapi.nets.faceLandmark68Net.loadFromUri(url),
|
|
9
|
+
faceapi.nets.faceRecognitionNet.loadFromUri(url),
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
12
|
+
export function dataURLtoBlob(dataURL) {
|
|
13
|
+
const parts = dataURL.split(';base64,');
|
|
14
|
+
const contentType = parts[0].split(':')[1];
|
|
15
|
+
const raw = window.atob(parts[1]);
|
|
16
|
+
const rawLength = raw.length;
|
|
17
|
+
const uInt8Array = new Uint8Array(rawLength);
|
|
18
|
+
for (let i = 0; i < rawLength; ++i) {
|
|
19
|
+
uInt8Array[i] = raw.charCodeAt(i);
|
|
20
|
+
}
|
|
21
|
+
return new Blob([uInt8Array], { type: contentType });
|
|
22
|
+
}
|
|
23
|
+
export const resizeFile = (file) => new Promise((resolve) => {
|
|
24
|
+
Resizer.imageFileResizer(file, 300, 300, 'jpeg', 100, 0, (uri) => {
|
|
25
|
+
resolve(uri);
|
|
26
|
+
}, 'file');
|
|
27
|
+
});
|
|
28
|
+
export const MAX_FILE_SIZE = 10; /* in MB */
|
|
29
|
+
export const MAX_NAME_LENGTH = 52;
|
|
30
|
+
export const SUPPORTED_FILES = [
|
|
31
|
+
/* add more supported ext */
|
|
32
|
+
'image/png',
|
|
33
|
+
'image/jpg',
|
|
34
|
+
'image/jpeg',
|
|
35
|
+
];
|
|
36
|
+
function removeFilenameExt(subject) {
|
|
37
|
+
const l = subject.split('.');
|
|
38
|
+
l.pop();
|
|
39
|
+
return l.join('.');
|
|
40
|
+
}
|
|
41
|
+
export function validateFile(file) {
|
|
42
|
+
const fileType = file.type;
|
|
43
|
+
const fileSize = file.size / (1024 * 1024);
|
|
44
|
+
const nameLength = removeFilenameExt(file.name).length;
|
|
45
|
+
if (fileSize > MAX_FILE_SIZE)
|
|
46
|
+
return 'File too large';
|
|
47
|
+
if (nameLength > MAX_NAME_LENGTH)
|
|
48
|
+
return 'File name too long';
|
|
49
|
+
if (!SUPPORTED_FILES.includes(fileType))
|
|
50
|
+
return 'Unsupported file';
|
|
51
|
+
}
|
|
52
|
+
export function showPermissionInstructions() {
|
|
53
|
+
const instructions = `
|
|
54
|
+
Camera access is blocked. To enable camera access:
|
|
55
|
+
|
|
56
|
+
Chrome/Edge:
|
|
57
|
+
1. Click the camera icon in the address bar
|
|
58
|
+
2. Select "Always allow" and click "Done"
|
|
59
|
+
3. Or go to Settings > Privacy and security > Site settings > Camera
|
|
60
|
+
|
|
61
|
+
Firefox:
|
|
62
|
+
1. Click the shield icon in the address bar
|
|
63
|
+
2. Click on "Camera blocked"
|
|
64
|
+
3. Select "Allow" and refresh the page
|
|
65
|
+
|
|
66
|
+
Safari:
|
|
67
|
+
1. Go to Safari > Settings > Websites > Camera
|
|
68
|
+
2. Find this website and change to "Allow"
|
|
69
|
+
|
|
70
|
+
After changing permissions, please refresh the page and try again.
|
|
71
|
+
`;
|
|
72
|
+
alert(instructions);
|
|
73
|
+
}
|
|
74
|
+
export const cameraErrorDescriptions = {
|
|
75
|
+
NotAllowedError: 'We were unable to detect a camera on your device. Please ensure it is properly connected and accessible to this application.',
|
|
76
|
+
NotReadableError: 'We were unable to access your camera. Please check if another application is using it or try reconnecting your device.',
|
|
77
|
+
NotFoundError: 'No camera was found. Please connect a camera and try again.',
|
|
78
|
+
NoIdDetectedError: 'No ID document was detected in the frame. Please ensure your ID is clearly visible and try again.',
|
|
79
|
+
};
|
|
@@ -43,7 +43,7 @@ export function IdFrontImageField__client(props) {
|
|
|
43
43
|
}, disabled: context.field?.disabled ||
|
|
44
44
|
context.query.isLoading ||
|
|
45
45
|
context.mutation.isPending ||
|
|
46
|
-
localProps.disabled, readOnly: context.field?.readOnly || localProps.readOnly, required: context.field?.required || localProps.required, className: "sr-only" }), !context.query.data?.url && (_jsxs("div", { className: "flex size-full flex-col justify-center", 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-placeholder-subtle size-4" }) }), _jsxs("h2", { className: "text-text-tertiary-600 mt-lg", children: [_jsxs("span", { className: "block text-center text-sm", children: [_jsx("button", { type: "button", onClick: () => {
|
|
46
|
+
localProps.disabled, readOnly: context.field?.readOnly || localProps.readOnly, required: context.field?.required || localProps.required, className: "sr-only" }), !context.query.data?.url && (_jsxs("div", { className: "flex size-full flex-col justify-center", children: [_jsx("div", { className: "border-border-primary shadow-xs mx-auto flex size-8 items-center justify-center rounded-sm border", children: context.query.isLoading ? (_jsx(Spinner02Icon, { className: "text-text-placeholder-subtle size-4" })) : (_jsx(UploadCloud02Icon, { className: "text-text-placeholder-subtle size-4" })) }), _jsxs("h2", { className: "text-text-tertiary-600 mt-lg", children: [_jsxs("span", { className: "block text-center text-sm", children: [_jsx("button", { type: "button", onClick: () => {
|
|
47
47
|
context.inputRef.current?.click();
|
|
48
48
|
}, disabled: context.field?.disabled ||
|
|
49
49
|
context.field?.readOnly ||
|
|
@@ -43,7 +43,7 @@ export function SelfieImageField__client(props) {
|
|
|
43
43
|
}, disabled: context.field?.disabled ||
|
|
44
44
|
context.query.isLoading ||
|
|
45
45
|
context.mutation.isPending ||
|
|
46
|
-
localProps.disabled, readOnly: context.field?.readOnly || localProps.readOnly, required: context.field?.required || localProps.required, className: "sr-only" }), !context.query.data?.url && (_jsxs("div", { className: "flex size-full flex-col justify-center", 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-placeholder-subtle size-4" }) }), _jsxs("h2", { className: "text-text-tertiary-600 mt-lg", children: [_jsxs("span", { className: "block text-center text-sm", children: [_jsx("button", { type: "button", onClick: () => {
|
|
46
|
+
localProps.disabled, readOnly: context.field?.readOnly || localProps.readOnly, required: context.field?.required || localProps.required, className: "sr-only" }), !context.query.data?.url && (_jsxs("div", { className: "flex size-full flex-col justify-center", children: [_jsx("div", { className: "border-border-primary shadow-xs mx-auto flex size-8 items-center justify-center rounded-sm border", children: context.query.isLoading ? (_jsx(Spinner02Icon, { className: "text-text-placeholder-subtle size-4" })) : (_jsx(UploadCloud02Icon, { className: "text-text-placeholder-subtle size-4" })) }), _jsxs("h2", { className: "text-text-tertiary-600 mt-lg", children: [_jsxs("span", { className: "block text-center text-sm", children: [_jsx("button", { type: "button", onClick: () => {
|
|
47
47
|
context.inputRef.current?.click();
|
|
48
48
|
}, disabled: context.field?.disabled ||
|
|
49
49
|
context.field?.readOnly ||
|
|
@@ -43,9 +43,14 @@ export function useSelfieImageField(props) {
|
|
|
43
43
|
const inputRef = useRef(null);
|
|
44
44
|
const maskRef = useRef(null);
|
|
45
45
|
const guideRef = useRef(null);
|
|
46
|
+
const [validatingFace, setValidatingFace] = useState(false);
|
|
46
47
|
const camera = useCamera({
|
|
47
|
-
async transform(
|
|
48
|
-
|
|
48
|
+
async transform(data) {
|
|
49
|
+
if (validatingFace)
|
|
50
|
+
return { ok: true, data };
|
|
51
|
+
setValidatingFace(true);
|
|
52
|
+
const hasFace = await validateFaceFromImage(data.image);
|
|
53
|
+
setValidatingFace(false);
|
|
49
54
|
if (!hasFace) {
|
|
50
55
|
return {
|
|
51
56
|
ok: false,
|
|
@@ -57,15 +62,15 @@ export function useSelfieImageField(props) {
|
|
|
57
62
|
}
|
|
58
63
|
const body = new FormData();
|
|
59
64
|
const guideRect = guideRef.current?.getBoundingClientRect();
|
|
60
|
-
const videoRect =
|
|
65
|
+
const videoRect = data.video.getBoundingClientRect();
|
|
61
66
|
invariant(guideRect, "'guideRef.getBoundingClientRect()' fails");
|
|
62
|
-
const scaleX =
|
|
63
|
-
const scaleY =
|
|
67
|
+
const scaleX = data.image.width / videoRect.width;
|
|
68
|
+
const scaleY = data.image.height / videoRect.height;
|
|
64
69
|
const cropTop = (guideRect.top - videoRect.top) * scaleY;
|
|
65
70
|
const cropLeft = (guideRect.left - videoRect.left) * scaleX;
|
|
66
71
|
const cropWidth = guideRect.width * scaleX;
|
|
67
72
|
const cropHeight = guideRect.height * scaleY;
|
|
68
|
-
body.append('image',
|
|
73
|
+
body.append('image', data.file);
|
|
69
74
|
body.append('cropTop', cropTop.toString());
|
|
70
75
|
body.append('cropLeft', cropLeft.toString());
|
|
71
76
|
body.append('cropWidth', cropWidth.toString());
|
|
@@ -75,8 +80,8 @@ export function useSelfieImageField(props) {
|
|
|
75
80
|
body,
|
|
76
81
|
});
|
|
77
82
|
const blob = await response.blob();
|
|
78
|
-
const file = new File([blob],
|
|
79
|
-
type:
|
|
83
|
+
const file = new File([blob], data.file.name, {
|
|
84
|
+
type: data.file.type,
|
|
80
85
|
endings: 'native',
|
|
81
86
|
lastModified: Date.now(),
|
|
82
87
|
});
|
|
@@ -84,8 +89,8 @@ export function useSelfieImageField(props) {
|
|
|
84
89
|
const image = new Image();
|
|
85
90
|
image.src = url;
|
|
86
91
|
image.alt = '';
|
|
87
|
-
image.width =
|
|
88
|
-
image.height =
|
|
92
|
+
image.width = data.image.width;
|
|
93
|
+
image.height = data.image.height;
|
|
89
94
|
return {
|
|
90
95
|
ok: true,
|
|
91
96
|
data: {
|
|
@@ -110,7 +115,7 @@ export function useSelfieImageField(props) {
|
|
|
110
115
|
}
|
|
111
116
|
setFaceFound(await validateFaceFromVideo(camera.videoRef.current, guideRef.current));
|
|
112
117
|
}, disclosure.open && !camera.data && !camera.error && !camera.loading
|
|
113
|
-
?
|
|
118
|
+
? 500
|
|
114
119
|
: null);
|
|
115
120
|
return {
|
|
116
121
|
field,
|
|
@@ -137,7 +142,7 @@ async function getImageFaceDetector() {
|
|
|
137
142
|
}
|
|
138
143
|
const detector = await FaceDetector.createFromOptions(__vision__, {
|
|
139
144
|
runningMode: 'IMAGE',
|
|
140
|
-
minDetectionConfidence: 0.
|
|
145
|
+
minDetectionConfidence: 0.8,
|
|
141
146
|
baseOptions: {
|
|
142
147
|
delegate: 'GPU',
|
|
143
148
|
modelAssetPath: 'https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite',
|
|
@@ -155,7 +160,7 @@ async function getVideoFaceDetector() {
|
|
|
155
160
|
}
|
|
156
161
|
const detector = await FaceDetector.createFromOptions(__vision__, {
|
|
157
162
|
runningMode: 'VIDEO',
|
|
158
|
-
minDetectionConfidence: 0.
|
|
163
|
+
minDetectionConfidence: 0.8,
|
|
159
164
|
baseOptions: {
|
|
160
165
|
delegate: 'GPU',
|
|
161
166
|
modelAssetPath: 'https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite',
|
|
@@ -185,10 +190,7 @@ async function validateFaceFromVideo(video, guide) {
|
|
|
185
190
|
const detection = result.detections.at(0);
|
|
186
191
|
if (!detection)
|
|
187
192
|
return false;
|
|
188
|
-
const
|
|
189
|
-
if (!category || category.score < 0.75)
|
|
190
|
-
return false;
|
|
191
|
-
const videoRect = video.getBoundingClientRect(); // DOM position & size
|
|
193
|
+
const videoRect = video.getBoundingClientRect();
|
|
192
194
|
const guideRect = guide.getBoundingClientRect();
|
|
193
195
|
if (!detection.boundingBox)
|
|
194
196
|
return false;
|
|
@@ -44,19 +44,34 @@ export async function postTransformIdFrontImage(request) {
|
|
|
44
44
|
height: parsed.data.cropHeight,
|
|
45
45
|
})
|
|
46
46
|
.resize({
|
|
47
|
+
fit: 'contain',
|
|
47
48
|
width: 1200,
|
|
48
49
|
height: 757,
|
|
49
50
|
kernel: sharp.kernel.lanczos3,
|
|
50
51
|
withoutEnlargement: true,
|
|
51
52
|
})
|
|
52
53
|
.modulate({
|
|
53
|
-
brightness: 1.
|
|
54
|
-
saturation: 1.
|
|
54
|
+
brightness: 1.03,
|
|
55
|
+
saturation: 1.05,
|
|
56
|
+
})
|
|
57
|
+
.median(1)
|
|
58
|
+
.blur(0.3)
|
|
59
|
+
.sharpen({
|
|
60
|
+
sigma: 1,
|
|
61
|
+
m1: 0.5,
|
|
62
|
+
m2: 1.0,
|
|
63
|
+
x1: 2,
|
|
64
|
+
y2: 10,
|
|
65
|
+
y3: 20,
|
|
66
|
+
})
|
|
67
|
+
.webp({
|
|
68
|
+
effort: 6,
|
|
69
|
+
quality: 100,
|
|
70
|
+
alphaQuality: 100,
|
|
71
|
+
lossless: false,
|
|
72
|
+
nearLossless: false,
|
|
73
|
+
smartSubsample: true,
|
|
55
74
|
})
|
|
56
|
-
.median(3)
|
|
57
|
-
.blur()
|
|
58
|
-
.sharpen()
|
|
59
|
-
.webp()
|
|
60
75
|
.toBuffer();
|
|
61
76
|
return new NextResponse(cropped, {
|
|
62
77
|
headers: {
|
|
@@ -44,23 +44,34 @@ export async function postTransformSelfieImage(request) {
|
|
|
44
44
|
height: parsed.data.cropHeight,
|
|
45
45
|
})
|
|
46
46
|
.resize({
|
|
47
|
+
fit: 'contain',
|
|
47
48
|
width: 1200,
|
|
48
49
|
height: 1200,
|
|
49
50
|
kernel: sharp.kernel.lanczos3,
|
|
50
51
|
withoutEnlargement: true,
|
|
51
52
|
})
|
|
53
|
+
.modulate({
|
|
54
|
+
brightness: 1.03,
|
|
55
|
+
saturation: 1.05,
|
|
56
|
+
})
|
|
57
|
+
.median(1)
|
|
58
|
+
.blur(0.3)
|
|
52
59
|
.sharpen({
|
|
53
|
-
sigma: 1
|
|
54
|
-
m1:
|
|
55
|
-
m2:
|
|
60
|
+
sigma: 1,
|
|
61
|
+
m1: 0.5,
|
|
62
|
+
m2: 1.0,
|
|
63
|
+
x1: 2,
|
|
64
|
+
y2: 10,
|
|
65
|
+
y3: 20,
|
|
56
66
|
})
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
.webp({
|
|
68
|
+
effort: 6,
|
|
69
|
+
quality: 100,
|
|
70
|
+
alphaQuality: 100,
|
|
71
|
+
lossless: false,
|
|
72
|
+
nearLossless: false,
|
|
73
|
+
smartSubsample: true,
|
|
60
74
|
})
|
|
61
|
-
.median(3)
|
|
62
|
-
.blur()
|
|
63
|
-
.webp()
|
|
64
75
|
.toBuffer();
|
|
65
76
|
return new NextResponse(cropped, {
|
|
66
77
|
headers: {
|
|
@@ -20,7 +20,7 @@ export declare const CREATE_MAYA_WITHDRAWAL = "\n mutation CreateMayaWithdrawal
|
|
|
20
20
|
export declare const CREATE_MAYA_APP_WITHDRAWAL = "\n mutation CreateMayaAppWithdrawal($input: CreateMayaAppWithdrawalInput!) {\n createMayaAppWithdrawal(input: $input) {\n ... on AccountNotVerifiedError {\n name: __typename\n message\n }\n ... on InvalidTransactionPasswordError {\n name: __typename\n message\n }\n ... on InvalidWithdrawalAmountError {\n name: __typename\n message\n }\n ... on NotEnoughBalanceError {\n name: __typename\n message\n }\n ... on WithdrawalDailyLimitExceededError {\n name: __typename\n message\n }\n ... on WalletDoesNotExistError {\n name: __typename\n message\n }\n ... on TransactionPasswordNotSetError {\n name: __typename\n message\n }\n }\n }\n";
|
|
21
21
|
export declare const CREATE_BANK_WITHDRAWAL = "\n mutation CreateBankWithdrawal($input: CreateBankWithdrawalInput!) {\n createBankWithdrawal(input: $input) {\n ... on MobileNumberNotVerifiedError {\n name: __typename\n message\n }\n }\n }\n";
|
|
22
22
|
export declare const CREATE_AIO_INSTAPAY_WITHDRAWAL = "\n mutation CreateAIOInstapayWithdrawal(\n $input: CreateAIOInstapayWithdrawalInput!\n ) {\n createAIOInstapayWithdrawal(input: $input) {\n ... on AccountNotVerifiedError {\n name: __typename\n message\n }\n ... on InvalidWithdrawalAmountError {\n name: __typename\n message\n }\n ... on WithdrawalDailyLimitExceededError {\n name: __typename\n message\n }\n ... on InvalidTransactionPasswordError {\n name: __typename\n message\n }\n ... on NotEnoughBalanceError {\n name: __typename\n message\n }\n ... on WalletDoesNotExistError {\n name: __typename\n message\n }\n ... on TransactionPasswordNotSetError {\n name: __typename\n message\n }\n }\n }\n";
|
|
23
|
-
export declare const CREATE_VENTAJA_WITHDRAWAL = "\n mutation
|
|
23
|
+
export declare const CREATE_VENTAJA_WITHDRAWAL = "\n mutation CreateVentajaDisbursementWithdrawal(\n $input: CreateVentajaDisbursementWithdrawalInput!\n ) {\n createVentajaDisbursementWithdrawal(input: $input) {\n ... on AccountNotVerifiedError {\n name: __typename\n message\n }\n ... on InvalidWithdrawalAmountError {\n name: __typename\n message\n }\n ... on WithdrawalDailyLimitExceededError {\n name: __typename\n message\n }\n ... on NotEnoughBalanceError {\n name: __typename\n message\n }\n ... on WalletDoesNotExistError {\n name: __typename\n message\n }\n }\n }\n";
|
|
24
24
|
export declare const CREATE_PISO_PAY_WITHDRAWAL = "\n mutation CreatePisopayWithdrawal(\n $input: CreatePisoPayRemittanceWithdrawalInput!\n $transactionPassword: String!\n ) {\n createPisoPayRemittanceWithdrawal(\n input: $input\n transactionPassword: $transactionPassword\n ) {\n ... on AccountNotVerifiedError {\n name: __typename\n message\n }\n ... on InvalidWithdrawalAmountError {\n name: __typename\n message\n }\n ... on WithdrawalDailyLimitExceededError {\n name: __typename\n message\n }\n ... on InvalidTransactionPasswordError {\n name: __typename\n message\n }\n ... on NotEnoughBalanceError {\n name: __typename\n message\n }\n ... on WalletDoesNotExistError {\n name: __typename\n message\n }\n ... on TransactionPasswordNotSetError {\n name: __typename\n message\n }\n }\n }\n";
|
|
25
25
|
export declare const CREATE_MANUAL_UPI_WITHDRAWAL = "\n mutation CreateManualUPIWithdrawal($input: CreateManualUPIWithdrawalInput!) {\n createManualUPIWithdrawal(input: $input) {\n ... on AccountNotVerifiedError {\n name: __typename\n message\n }\n ... on InvalidWithdrawalAmountError {\n name: __typename\n message\n }\n ... on WithdrawalDailyLimitExceededError {\n name: __typename\n message\n }\n ... on NotEnoughBalanceError {\n name: __typename\n message\n }\n ... on WalletDoesNotExistError {\n name: __typename\n message\n }\n }\n }\n";
|
|
26
26
|
export declare const CREATE_MANUAL_BANK_WITHDRAWAL = "\n mutation CreateManualBankWithdrawal(\n $input: CreateManualBankWithdrawalInput!\n ) {\n createManualBankWithdrawal(input: $input) {\n ... on AccountNotVerifiedError {\n name: __typename\n message\n }\n ... on InvalidWithdrawalAmountError {\n name: __typename\n message\n }\n ... on WithdrawalDailyLimitExceededError {\n name: __typename\n message\n }\n ... on NotEnoughBalanceError {\n name: __typename\n message\n }\n ... on WalletDoesNotExistError {\n name: __typename\n message\n }\n }\n }\n";
|