@verified-network/verified-custody 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,821 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import { hashTheString, loadAllGoogleFonts } from "../utils/helpers";
3
+ import { defaultChainId, imageAssets } from "../utils/constants";
4
+ import {
5
+ acceptOrRejectInvitation,
6
+ initiateVaultRecovery,
7
+ restoreVaultLogin,
8
+ signVaultRecovery,
9
+ validateVaultPin,
10
+ } from "../services/contracts";
11
+ import PageSlider from "../components/slider";
12
+ import { LogoutOverlay, PrivacyOverlay } from "../components/overlays";
13
+ import Success from "../components/success";
14
+ import { VerifiedCustodyHelpers } from "../utils/types";
15
+
16
+ const EnterPinPage = (props: {
17
+ fontsLoaded?: boolean;
18
+ setisOnboard: (isOnboard: boolean) => void;
19
+ vaultId: string;
20
+ hashedVaultId: string;
21
+ encrptedPk: string;
22
+ vaultAddress: string;
23
+ vaultChannel: "sms" | "email";
24
+ actionText?: string;
25
+ title?: string;
26
+ origin?: string;
27
+ chainId?: number;
28
+ newChainId?: number;
29
+ action?: string;
30
+ reqVaultData?: any;
31
+ reqTxData?: any;
32
+ setIsLoading: (isLoading: boolean) => void;
33
+ helperFunctions?: VerifiedCustodyHelpers;
34
+ }) => {
35
+ const [fontsLoaded, setFontsLoaded] = useState(props.fontsLoaded || false);
36
+ const [pinIncorrect, setPinIncorrect] = useState(false);
37
+ const [pinHide, setPinHide] = useState(true); //hide pin by default
38
+ const [searchActive, setSearchActive] = useState(false);
39
+ const [showSuccess, setShowSuccess] = useState(false);
40
+ const [vaultData, setVaultData] = useState(null);
41
+ const [chainId, setChainId] = useState(props.newChainId || defaultChainId);
42
+ const [showChains, setShowChains] = useState(false);
43
+ const [showInvitation, setShowInvitation] = useState(false);
44
+ const [showInvitationSuccess, setShowInvitationSuccess] = useState(false);
45
+ const [showRejectInvitation, setShowRejectInvitation] = useState(false);
46
+ const [isAccepted, setIsAccepted] = useState(false);
47
+ const [pinIncorrectText, setPinIncorrectText] = useState("");
48
+
49
+ useEffect(() => {
50
+ const PreloadGoogleFonts = () => {
51
+ const isFontsLoaded = loadAllGoogleFonts(document);
52
+ setFontsLoaded(isFontsLoaded);
53
+ };
54
+ if (!props.fontsLoaded) {
55
+ PreloadGoogleFonts();
56
+ }
57
+ }, []);
58
+
59
+ //todo: add key actions to input focus change
60
+ const handlleInputFocus = (currentInput: any) => {
61
+ if (currentInput.value.length > 0) {
62
+ const nextInput = currentInput.nextElementSibling;
63
+ if (nextInput) {
64
+ nextInput.focus();
65
+ }
66
+ } else if (currentInput.value.length === 0) {
67
+ currentInput.focus();
68
+ }
69
+ };
70
+
71
+ const hanlePinPaste = (e: any) => {
72
+ const pastedText = e.clipboardData.getData("text");
73
+ const numbersFromText = pastedText?.replace(/\D/g, "");
74
+ const allOptInputs: any = document.getElementsByClassName("otp-input");
75
+ if (allOptInputs?.length === 4 && numbersFromText?.length > 0) {
76
+ for (let i = 0; i < allOptInputs.length; i++) {
77
+ if (numbersFromText[i]) {
78
+ allOptInputs[i].value = numbersFromText[i];
79
+ allOptInputs[i].focus();
80
+ }
81
+ }
82
+ }
83
+ };
84
+
85
+ const hanslePinBackspace = (e: any) => {
86
+ const previousInpput = e.target.previousElementSibling;
87
+ if (previousInpput) {
88
+ previousInpput.focus();
89
+ }
90
+ };
91
+
92
+ const handleButtonDisplay = () => {
93
+ const button: any = document.getElementById(
94
+ "verified-custd-mdl-otp-button"
95
+ );
96
+ const otp1: any = document.getElementById("verified-custd-mdl-otp-input-1");
97
+ const otp2: any = document.getElementById("verified-custd-mdl-otp-input-2");
98
+ const otp3: any = document.getElementById("verified-custd-mdl-otp-input-3");
99
+ const otp4: any = document.getElementById("verified-custd-mdl-otp-input-4");
100
+ if (
101
+ button &&
102
+ otp1?.value.length > 0 &&
103
+ otp2?.value.length > 0 &&
104
+ otp3?.value.length > 0 &&
105
+ otp4?.value.length > 0 &&
106
+ !pinIncorrect
107
+ ) {
108
+ button.className = "verified-custd-mdl-startup-button-active";
109
+ } else {
110
+ button.className = "verified-custd-mdl-startup-button";
111
+ }
112
+ };
113
+
114
+ const handleVerifyPin = async () => {
115
+ if (!props.helperFunctions) {
116
+ setPinIncorrectText(
117
+ "No Helper Functions. Please include all helper functions in the EnterPinPage props."
118
+ );
119
+ setPinIncorrect(true);
120
+ } else {
121
+ setPinIncorrectText("");
122
+ setPinIncorrect(false);
123
+ const otp1: any = document.getElementById(
124
+ "verified-custd-mdl-otp-input-1"
125
+ );
126
+ const otp2: any = document.getElementById(
127
+ "verified-custd-mdl-otp-input-2"
128
+ );
129
+ const otp3: any = document.getElementById(
130
+ "verified-custd-mdl-otp-input-3"
131
+ );
132
+ const otp4: any = document.getElementById(
133
+ "verified-custd-mdl-otp-input-4"
134
+ );
135
+ if (
136
+ otp1?.value?.length > 0 &&
137
+ otp2?.value?.length > 0 &&
138
+ otp3?.value?.length > 0 &&
139
+ otp4?.value?.length > 0 &&
140
+ props.hashedVaultId &&
141
+ props.encrptedPk
142
+ ) {
143
+ props.setIsLoading(true);
144
+ const fullOtp = otp1?.value + otp2?.value + otp3?.value + otp4?.value;
145
+ await validateVaultPin(
146
+ props.vaultId,
147
+ props.hashedVaultId,
148
+ fullOtp,
149
+ hashTheString(fullOtp),
150
+ props.encrptedPk,
151
+ props.vaultAddress,
152
+ props.vaultChannel,
153
+ Number(chainId)
154
+ ).then(async (res) => {
155
+ props.setIsLoading(false);
156
+ if (res) {
157
+ setVaultData(res);
158
+ if (
159
+ props.action === "getPk" &&
160
+ props.reqVaultData?.vaultId?.toLowerCase() ===
161
+ props.vaultId?.toLowerCase()
162
+ ) {
163
+ props.setIsLoading(true);
164
+ await initiateVaultRecovery(
165
+ props.helperFunctions.sendCreatorInitiation,
166
+ props.hashedVaultId,
167
+ hashTheString(fullOtp),
168
+ props.vaultId,
169
+ fullOtp,
170
+ props.encrptedPk,
171
+ props.vaultChannel,
172
+ Number(chainId)
173
+ ).then(async (res) => {
174
+ props.setIsLoading(false);
175
+ if (chrome?.storage?.local) {
176
+ await chrome.storage.local.remove("myVault");
177
+ }
178
+ if (res) {
179
+ setShowSuccess(true);
180
+ } else {
181
+ setPinIncorrectText(
182
+ `Account recovery failed. Verify you don't have pending account recovery process and Try again later`
183
+ );
184
+ setPinIncorrect(true);
185
+ }
186
+ });
187
+ } else if (props.action === "signRecovery") {
188
+ props.setIsLoading(true);
189
+ await signVaultRecovery(
190
+ props.helperFunctions.sendCreatorSigned,
191
+ props.helperFunctions.sendCreatorCompleted,
192
+ props.hashedVaultId,
193
+ hashTheString(fullOtp),
194
+ props.vaultId,
195
+ fullOtp,
196
+ props.encrptedPk,
197
+ props.reqVaultData?.vaultId,
198
+ props.reqVaultData?.hashedVaultId,
199
+ props.reqVaultData?.hashedVaultPin,
200
+ props.reqTxData?.id,
201
+ Number(chainId)
202
+ ).then(async (res) => {
203
+ props.setIsLoading(false);
204
+ if (
205
+ !props.reqTxData?.newUser &&
206
+ chrome?.storage?.local &&
207
+ !props.vaultAddress
208
+ ) {
209
+ await chrome.storage.local.remove("myVault");
210
+ }
211
+ if (res) {
212
+ setShowSuccess(true);
213
+ } else {
214
+ setPinIncorrectText(
215
+ `Error while signing transaction; it's either you are not a valid co-signer or you had signed this particular transaction before. Verify and try again later.`
216
+ );
217
+ setPinIncorrect(true);
218
+ }
219
+ });
220
+ } else if (
221
+ props.action === "completeRecovery" &&
222
+ props.reqVaultData?.vaultId?.toLowerCase() ===
223
+ props.vaultId?.toLowerCase()
224
+ ) {
225
+ props.setIsLoading(true);
226
+ await restoreVaultLogin(
227
+ props.hashedVaultId,
228
+ hashTheString(fullOtp),
229
+ props.vaultId,
230
+ fullOtp,
231
+ props.encrptedPk,
232
+ props.reqTxData?.id,
233
+ props.vaultChannel,
234
+ Number(chainId)
235
+ ).then(async (res) => {
236
+ props.setIsLoading(false);
237
+ if (res) {
238
+ setShowSuccess(true);
239
+ } else {
240
+ if (chrome?.storage?.local) {
241
+ await chrome.storage.local.remove("myVault");
242
+ }
243
+ setPinIncorrectText(
244
+ `Error while restoring login access. Verify all required co-signers had signed our account recovery and try again later.`
245
+ );
246
+ setPinIncorrect(true);
247
+ }
248
+ });
249
+ } else if (
250
+ props.action === "invitation" &&
251
+ props.reqVaultData?.vaultId?.toLowerCase() !==
252
+ props.vaultId?.toLowerCase() &&
253
+ props.reqVaultData?.coSignerId?.toLowerCase() ===
254
+ props.vaultId?.toLowerCase()
255
+ ) {
256
+ setPinIncorrectText("");
257
+ setPinIncorrect(false);
258
+ setShowInvitation(true);
259
+ } else if (
260
+ props.action === "invitation" &&
261
+ props.reqVaultData?.vaultId?.toLowerCase() ===
262
+ props.vaultId?.toLowerCase()
263
+ ) {
264
+ setPinIncorrectText(
265
+ `You cannot accept your own Co-Signer invitation. please logout and login to: ${props.reqVaultData?.coSignerId} account`
266
+ );
267
+ setPinIncorrect(true);
268
+ } else if (
269
+ props.action === "invitation" &&
270
+ props.reqVaultData?.coSignerId?.toLowerCase() !==
271
+ props.vaultId?.toLowerCase()
272
+ ) {
273
+ setPinIncorrectText(
274
+ `You cannot accept this Co-Signer invitation. please logout and login to: ${props.reqVaultData?.coSignerId} account`
275
+ );
276
+ setPinIncorrect(true);
277
+ } else if (
278
+ props.action === "getPk" &&
279
+ props.reqVaultData?.vaultId?.toLowerCase() !==
280
+ props.vaultId?.toLowerCase()
281
+ ) {
282
+ if (chrome?.storage?.local) {
283
+ await chrome.storage.local.remove("myVault");
284
+ }
285
+ setPinIncorrectText(
286
+ `You are not authorized to fetch account details. please logout and login to: ${props.reqVaultData?.vaultId} account`
287
+ );
288
+ setPinIncorrect(true);
289
+ } else if (
290
+ props.action === "completeRecovery" &&
291
+ props.reqVaultData?.vaultId?.toLowerCase() !==
292
+ props.vaultId?.toLowerCase()
293
+ ) {
294
+ if (chrome?.storage?.local) {
295
+ await chrome.storage.local.remove("myVault");
296
+ }
297
+ setPinIncorrectText(
298
+ `You are not authorized to restore login access for this account. please logout and login to: ${props.reqVaultData?.vaultId} account`
299
+ );
300
+ setPinIncorrect(true);
301
+ } else if (
302
+ props.action === "connect_wallet" &&
303
+ !props?.vaultAddress
304
+ ) {
305
+ setPinIncorrectText(
306
+ `Incomplete account details received. This may be due to incomplete/unexpected error from last login. Please logout and login back to recover account details.`
307
+ );
308
+ setPinIncorrect(true);
309
+ } else {
310
+ setPinIncorrectText("");
311
+ setPinIncorrect(false);
312
+ setShowSuccess(true);
313
+ }
314
+ } else {
315
+ setPinIncorrectText("");
316
+ setPinIncorrect(true);
317
+ }
318
+ });
319
+ }
320
+ }
321
+ };
322
+
323
+ const handleAcceptAndRejectInvitation = async (accepted: boolean) => {
324
+ const otp1: any = document.getElementById("verified-custd-mdl-otp-input-1");
325
+ const otp2: any = document.getElementById("verified-custd-mdl-otp-input-2");
326
+ const otp3: any = document.getElementById("verified-custd-mdl-otp-input-3");
327
+ const otp4: any = document.getElementById("verified-custd-mdl-otp-input-4");
328
+ const vaultId = props.vaultId;
329
+ if (
330
+ otp1?.value?.length > 0 &&
331
+ otp2?.value?.length > 0 &&
332
+ otp3?.value?.length > 0 &&
333
+ otp4?.value?.length > 0 &&
334
+ props?.reqVaultData?.hashedVaultId &&
335
+ props.reqVaultData?.hashedVaultPin &&
336
+ vaultId &&
337
+ props.helperFunctions?.sendCreatorAcceptance &&
338
+ props.helperFunctions?.sendCreatorRejection
339
+ ) {
340
+ props.setIsLoading(true);
341
+ const vaultPin = otp1?.value + otp2?.value + otp3?.value + otp4?.value;
342
+ const hashedVaultId = hashTheString(vaultId);
343
+ const hashedVaultPin = hashTheString(vaultPin);
344
+ await acceptOrRejectInvitation(
345
+ props.helperFunctions.sendCreatorAcceptance,
346
+ props.helperFunctions.sendCreatorRejection,
347
+ props.vaultChannel,
348
+ hashedVaultId,
349
+ hashedVaultPin,
350
+ props?.reqVaultData?.hashedVaultId,
351
+ props.reqVaultData?.hashedVaultPin,
352
+ props?.reqVaultData?.vaultId,
353
+ vaultId,
354
+ accepted,
355
+ null,
356
+ props.encrptedPk,
357
+ Number(chainId)
358
+ ).then((res) => {
359
+ props.setIsLoading(false);
360
+ if (res) {
361
+ setIsAccepted(accepted);
362
+ setShowInvitationSuccess(true);
363
+ }
364
+ });
365
+ }
366
+ };
367
+
368
+ return (
369
+ <React.Fragment>
370
+ {!showInvitation && (
371
+ <React.Fragment>
372
+ {!showSuccess && (
373
+ <div className="verified-custd-mdl-startup-language">
374
+ <div className="verified-custd-mdl-startup-contact">
375
+ <PageSlider sliderCount={[1]} currentSlider="0" />
376
+ <div className="verified-custd-mdl-startup-contact-content">
377
+ <div className="verified-custd-mdl-startup-contact-content-heder-cont">
378
+ <p
379
+ style={{ alignSelf: "center" }}
380
+ className="verified-custd-mdl-startup-contact-text"
381
+ >
382
+ Enter PIN
383
+ </p>
384
+ {/* <div className="verified-custd-mdl-portfolio-page-content-header-button-cont">
385
+ <button
386
+ onClick={() => setShowChains(!showChains)}
387
+ className="verified-custd-mdl-portfolio-page-content-header-button"
388
+ >
389
+ {chainConfig[chainId].chainName}
390
+ <img src={expandIcon} alt="Expand Icon" />
391
+ </button>
392
+ {showChains && (
393
+ <div className="verified-custd-mdl-portfolio-page-content-header-button-body">
394
+ {Object.keys(chainConfig).map((chn: any) => (
395
+ <div
396
+ onClick={() => {
397
+ setChainId(chn);
398
+ setShowChains(false);
399
+ }}
400
+ className="verified-custd-mdl-portfolio-page-content-header-button-body-cont"
401
+ >
402
+ <p className="verified-custd-mdl-portfolio-page-content-header-button-body-text">
403
+ {chainConfig[chn].chainName}
404
+ </p>
405
+ </div>
406
+ ))}
407
+ </div>
408
+ )}
409
+ </div> */}
410
+ </div>
411
+ <div className="verified-custd-mdl-startup-otp-text">
412
+ <p className="verified-custd-mdl-startup-otp-header-text">
413
+ Welcome back, please enter the{" "}
414
+ <span style={{ color: "#0C0C0E" }}>4-Digit PIN</span> for
415
+ your{" "}
416
+ <span style={{ color: "#0C0C0E" }}>{props.vaultId}</span>{" "}
417
+ account.
418
+ </p>
419
+ <div className="verified-custd-mdl-startup-otp-footer">
420
+ {props.actionText && (
421
+ <p className="verified-custd-mdl-startup-otp-footer-text">
422
+ {props.actionText ? `To ${props.actionText} ` : ""}{" "}
423
+ from origin: {props.origin || props.title}
424
+ </p>
425
+ )}
426
+ </div>
427
+ </div>
428
+ </div>
429
+ <div className="verified-custd-mdl-otp-input-container">
430
+ <div className="verified-custd-mdl-otp-input-group">
431
+ <input
432
+ onInputCapture={(e: any) => {
433
+ e.target.value = e.target.value?.replace(/\D/g, "");
434
+ setPinIncorrect(false);
435
+ }}
436
+ onInput={(e) => {
437
+ handlleInputFocus(e.target);
438
+ handleButtonDisplay();
439
+ }}
440
+ onKeyDown={(e: any) => {
441
+ if (e.key === "Backspace" && e.target.value === "") {
442
+ hanslePinBackspace(e);
443
+ }
444
+ }}
445
+ onPaste={(e) => {
446
+ hanlePinPaste(e);
447
+ }}
448
+ className={
449
+ pinIncorrect
450
+ ? "verified-custd-mdl-otp-input-red"
451
+ : "verified-custd-mdl-otp-input"
452
+ }
453
+ type={pinHide ? "password" : "text"}
454
+ maxLength={1}
455
+ id="verified-custd-mdl-otp-input-1"
456
+ />
457
+ <input
458
+ onInputCapture={(e: any) => {
459
+ e.target.value = e.target.value?.replace(/\D/g, "");
460
+ setPinIncorrect(false);
461
+ }}
462
+ onInput={(e) => {
463
+ handlleInputFocus(e.target);
464
+ handleButtonDisplay();
465
+ }}
466
+ onKeyDown={(e: any) => {
467
+ if (e.key === "Backspace" && e.target.value === "") {
468
+ hanslePinBackspace(e);
469
+ }
470
+ }}
471
+ className={
472
+ pinIncorrect
473
+ ? "verified-custd-mdl-otp-input-red"
474
+ : "verified-custd-mdl-otp-input"
475
+ }
476
+ type={pinHide ? "password" : "text"}
477
+ maxLength={1}
478
+ id="verified-custd-mdl-otp-input-2"
479
+ />
480
+ <input
481
+ onInputCapture={(e: any) => {
482
+ e.target.value = e.target.value?.replace(/\D/g, "");
483
+ setPinIncorrect(false);
484
+ }}
485
+ onInput={(e) => {
486
+ handlleInputFocus(e.target);
487
+ handleButtonDisplay();
488
+ }}
489
+ onKeyDown={(e: any) => {
490
+ if (e.key === "Backspace" && e.target.value === "") {
491
+ hanslePinBackspace(e);
492
+ }
493
+ }}
494
+ className={
495
+ pinIncorrect
496
+ ? "verified-custd-mdl-otp-input-red"
497
+ : "verified-custd-mdl-otp-input"
498
+ }
499
+ type={pinHide ? "password" : "text"}
500
+ maxLength={1}
501
+ id="verified-custd-mdl-otp-input-3"
502
+ />
503
+ <input
504
+ onInputCapture={(e: any) => {
505
+ e.target.value = e.target.value?.replace(/\D/g, "");
506
+ setPinIncorrect(false);
507
+ }}
508
+ onInput={(e) => {
509
+ handlleInputFocus(e.target);
510
+ handleButtonDisplay();
511
+ }}
512
+ onKeyDown={(e: any) => {
513
+ if (e.key === "Backspace" && e.target.value === "") {
514
+ hanslePinBackspace(e);
515
+ }
516
+ }}
517
+ className={
518
+ pinIncorrect
519
+ ? "verified-custd-mdl-otp-input-red"
520
+ : "verified-custd-mdl-otp-input"
521
+ }
522
+ type={pinHide ? "password" : "text"}
523
+ maxLength={1}
524
+ id="verified-custd-mdl-otp-input-4"
525
+ />
526
+ </div>
527
+ <div className="verified-custd-mdl-otp-timer">
528
+ {pinIncorrect && pinIncorrectText === "" && (
529
+ <p className="verified-custd-mdl-otp-incorrect-text">
530
+ Please enter the correct pin
531
+ </p>
532
+ )}
533
+ {pinIncorrect && pinIncorrectText?.length > 0 && (
534
+ <p className="verified-custd-mdl-otp-incorrect-text">
535
+ {pinIncorrectText}
536
+ </p>
537
+ )}
538
+ {!pinIncorrect && (
539
+ <p className="verified-custd-mdl-otp-incorrect-text"></p>
540
+ )}
541
+
542
+ {!pinHide && (
543
+ <img
544
+ style={{
545
+ cursor: "pointer",
546
+ width: "24px",
547
+ height: "24px",
548
+ }}
549
+ onClick={() => setPinHide(true)}
550
+ src={imageAssets.pinShow}
551
+ alt="show pin icon"
552
+ />
553
+ )}
554
+ {pinHide && (
555
+ <img
556
+ style={{
557
+ cursor: "pointer",
558
+ width: "24px",
559
+ height: "24px",
560
+ }}
561
+ onClick={() => setPinHide(false)}
562
+ src={imageAssets.pinHide}
563
+ alt="hide pin icon"
564
+ />
565
+ )}
566
+ </div>
567
+ </div>
568
+ </div>
569
+
570
+ {!searchActive && <div style={{ height: "100px" }}></div>}
571
+
572
+ <div className="verified-custd-mdl-startup-contact-footer">
573
+ <div className="verified-custd-mdl-st-contact-footer-first-section">
574
+ <LogoutOverlay
575
+ setisOnboard={props.setisOnboard}
576
+ setIsLoading={props.setIsLoading}
577
+ />
578
+ <button
579
+ id="verified-custd-mdl-otp-button"
580
+ onClick={async (e: any) => {
581
+ if (
582
+ e.target.className.includes(
583
+ "verified-custd-mdl-startup-button"
584
+ ) &&
585
+ e.target.className !==
586
+ "verified-custd-mdl-startup-button"
587
+ ) {
588
+ e.target.className =
589
+ "verified-custd-mdl-startup-button-click";
590
+ await handleVerifyPin();
591
+ } else {
592
+ const buttonElement = document.getElementsByClassName(
593
+ "verified-custd-mdl-startup-button-active"
594
+ );
595
+ if (buttonElement.length > 0) {
596
+ buttonElement[0].className =
597
+ "verified-custd-mdl-startup-button-click";
598
+ await handleVerifyPin();
599
+ }
600
+ }
601
+ }}
602
+ className="verified-custd-mdl-startup-button"
603
+ >
604
+ Proceed
605
+ </button>
606
+ <div className="verified-custd-mdl-st-contact-footer-second-section">
607
+ <PrivacyOverlay />
608
+ </div>
609
+ </div>
610
+ </div>
611
+ </div>
612
+ )}
613
+ {showSuccess && (
614
+ <Success
615
+ messageTosend={
616
+ props.action === "getPk"
617
+ ? {
618
+ type: "closePopup",
619
+ key: "",
620
+ value: "",
621
+ }
622
+ : props.action === "signRecovery"
623
+ ? {
624
+ type: "closePopup",
625
+ key: "",
626
+ value: "",
627
+ }
628
+ : props.action === "completeRecovery"
629
+ ? {
630
+ type: "closePopup",
631
+ key: "",
632
+ value: "",
633
+ }
634
+ : {
635
+ type: "vaultData",
636
+ key: "vaultData",
637
+ value: vaultData,
638
+ }
639
+ }
640
+ customTextHeader={"Successful"}
641
+ customTextFooter={
642
+ props.action === "getPk" && props.vaultChannel === "email"
643
+ ? "You have successfully initiated your account recovery process check your email for further instructions"
644
+ : props.action === "getPk" && props.vaultChannel === "sms"
645
+ ? "You have successfully initiated your account recovery process check your phone number messages for further instructions"
646
+ : props.action === "signRecovery"
647
+ ? `Congratulations! You have successfully signed account recovery transaction for user: ${props.reqVaultData?.vaultId}`
648
+ : props.action === "completeRecovery"
649
+ ? `Congratulations! You have successfully restored login access for your ${props?.vaultId} account`
650
+ : `Congratulations! You have successfully ${
651
+ props.action === "connect_wallet"
652
+ ? "connected your account"
653
+ : props?.actionText
654
+ ? props.actionText
655
+ : "logged in to your account."
656
+ } `
657
+ }
658
+ />
659
+ )}
660
+ </React.Fragment>
661
+ )}
662
+ {showInvitation && (
663
+ <React.Fragment>
664
+ {!showInvitationSuccess && (
665
+ <div
666
+ style={{ padding: "0", position: "relative" }}
667
+ className="verified-custd-mdl-startup-language"
668
+ >
669
+ <div className="verified-custd-mdl-startup-contact">
670
+ <PageSlider sliderCount={[1, 2, 3]} currentSlider="1" />
671
+ <div className="verified-custd-mdl-startup-contact-content">
672
+ <p className="verified-custd-mdl-startup-contact-text">
673
+ <b>{props.reqVaultData?.vaultId}</b> has requested you to be
674
+ a Co-Signer
675
+ </p>
676
+ </div>
677
+ </div>
678
+ <img
679
+ className="verified-custd-mdl-add-cosigner-body-icon"
680
+ src={imageAssets.addCoSignerIcon1}
681
+ alt=""
682
+ />
683
+ {!showRejectInvitation && (
684
+ <React.Fragment>
685
+ <div className="verified-custd-mdl-add-cosigner-more-body">
686
+ <div className="verified-custd-mdl-add-cosigner-more-header-cont">
687
+ <div className="verified-custd-mdl-add-cosigner-more-title-cont">
688
+ <p className="verified-custd-mdl-add-cosigner-more-title">
689
+ What is a Co-Signer?
690
+ </p>
691
+ </div>
692
+ </div>
693
+ <p
694
+ style={{
695
+ fontSize: "12px",
696
+ color: "var(--Neutral-600, #5B5D6E)",
697
+ }}
698
+ className="verified-custd-mdl-add-cosigner-more-label"
699
+ >
700
+ A Co-Signer is a person who has the right given by you to
701
+ generate a new pin on your behalf incase you forget it.{" "}
702
+ </p>
703
+
704
+ <div className="verified-custd-mdl-add-cosigner-body-text-cont">
705
+ <div className="verified-custd-mdl-add-cosigner-body-text-icon">
706
+ <img src={imageAssets.pkicon} alt="icon" />
707
+ </div>
708
+ <p className="verified-custd-mdl-add-cosigner-body-text-label">
709
+ As a Co Signer you can help{" "}
710
+ <span className="verified-custd-mdl-add-cosigner-body-text-label-bold">
711
+ reset PIN
712
+ </span>
713
+ </p>
714
+ </div>
715
+
716
+ <div className="verified-custd-mdl-add-cosigner-body-text-cont">
717
+ <div className="verified-custd-mdl-add-cosigner-body-text-icon">
718
+ <img src={imageAssets.encryptedIcon} alt="icon" />
719
+ </div>
720
+ <p className="verified-custd-mdl-add-cosigner-body-text-label">
721
+ Don’t worry, they{" "}
722
+ <span className="verified-custd-mdl-add-cosigner-body-text-label-bold">
723
+ will not get access
724
+ </span>{" "}
725
+ to your account in any way.
726
+ </p>
727
+ </div>
728
+ </div>
729
+ <div className="verified-custd-mdl-add-cosigner-buttons-cont">
730
+ <button
731
+ onClick={() => {
732
+ setShowRejectInvitation(true);
733
+ }}
734
+ className="verified-custd-mdl-add-cosigner-button-neut"
735
+ >
736
+ Reject
737
+ </button>
738
+
739
+ <button
740
+ onClick={async () => {
741
+ await handleAcceptAndRejectInvitation(true);
742
+ }}
743
+ className="verified-custd-mdl-add-cosigner-button-action"
744
+ >
745
+ Accept
746
+ </button>
747
+ </div>
748
+ </React.Fragment>
749
+ )}
750
+
751
+ {showRejectInvitation && (
752
+ <div className="verified-custd-mdl-add-cosigner-confirm-body-content-outter">
753
+ <div className="verified-custd-mdl-add-cosigner-confirm-body-content">
754
+ <div className="verified-custd-mdl-add-cosigner-confirm-body-cont">
755
+ <div className="verified-custd-mdl-add-cosigner-confirm-body-header">
756
+ <p className="verified-custd-mdl-add-cosigner-confirm-body-title">
757
+ Are you sure you want to reject this request?
758
+ </p>
759
+ <p
760
+ style={{
761
+ fontSize: "12px",
762
+ color: "var(--Neutral-600, #5B5D6E)",
763
+ }}
764
+ className="verified-custd-mdl-add-cosigner-confirm-body-label"
765
+ >
766
+ Once you reject to be a co-signer for{" "}
767
+ <b>{props.reqVaultData?.vaultId}</b>, you will not be
768
+ able to reset the PIN for them.
769
+ </p>
770
+ </div>
771
+
772
+ <div
773
+ style={{ width: "90%" }}
774
+ className="verified-custd-mdl-add-cosigner-buttons-cont"
775
+ >
776
+ <button
777
+ onClick={async () => {
778
+ await handleAcceptAndRejectInvitation(false);
779
+ }}
780
+ className="verified-custd-mdl-add-cosigner-button-action"
781
+ >
782
+ Yes
783
+ </button>
784
+
785
+ <button
786
+ onClick={() => {
787
+ setShowRejectInvitation(false);
788
+ }}
789
+ className="verified-custd-mdl-add-cosigner-button-action"
790
+ >
791
+ No
792
+ </button>
793
+ </div>
794
+ </div>
795
+ </div>
796
+ </div>
797
+ )}
798
+ </div>
799
+ )}
800
+ {showInvitationSuccess && (
801
+ <Success
802
+ messageTosend={{
803
+ type: "getPk",
804
+ key: "vaultData",
805
+ value: vaultData,
806
+ }}
807
+ customTextHeader="Successful"
808
+ customTextFooter={
809
+ isAccepted
810
+ ? `You have been added as a Co-Signer for ${props.reqVaultData?.vaultId}`
811
+ : `You rejected Co-signer reject from ${props.reqVaultData?.vaultId}`
812
+ }
813
+ />
814
+ )}
815
+ </React.Fragment>
816
+ )}
817
+ </React.Fragment>
818
+ );
819
+ };
820
+
821
+ export default EnterPinPage;