@verified-network/verified-custody 0.1.8 → 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.
Files changed (65) hide show
  1. package/babel.config.json +12 -0
  2. package/dist/index.d.mts +165 -0
  3. package/dist/index.d.ts +165 -0
  4. package/dist/index.js +3 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +3 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +31 -38
  9. package/src/components/overlays.tsx +61 -0
  10. package/src/components/search.tsx +381 -0
  11. package/src/components/slider.tsx +29 -0
  12. package/src/components/success.tsx +142 -0
  13. package/src/customTypes.d.ts +37 -0
  14. package/src/index.ts +17 -0
  15. package/src/pages/addCosigners.tsx +1014 -0
  16. package/src/pages/contact.tsx +280 -0
  17. package/src/pages/createPin.tsx +693 -0
  18. package/src/pages/enterPin.tsx +821 -0
  19. package/src/pages/ftu.tsx +244 -0
  20. package/src/pages/index.tsx +170 -0
  21. package/src/pages/otp.tsx +410 -0
  22. package/src/services/contracts.ts +817 -0
  23. package/src/services/store.tsx +65 -0
  24. package/src/style.css +2030 -0
  25. package/src/utils/config.ts +103 -0
  26. package/src/utils/constants.ts +1966 -0
  27. package/src/utils/helpers.tsx +334 -0
  28. package/src/utils/types.ts +85 -0
  29. package/tsconfig.json +16 -0
  30. package/tsup.config.ts +36 -0
  31. package/README.md +0 -93
  32. package/dist/assets/icon128.png +0 -0
  33. package/dist/assets/icon16.png +0 -0
  34. package/dist/assets/icon32.png +0 -0
  35. package/dist/assets/icon48.png +0 -0
  36. package/dist/autoreload-bg.1777342b.js +0 -392
  37. package/dist/autoreload.af9e0afa.js +0 -393
  38. package/dist/main.js +0 -2
  39. package/dist/main.js.LICENSE.txt +0 -190
  40. package/dist/manifest.json +0 -39
  41. package/dist/src/scripts/background.js +0 -866
  42. package/dist/src/scripts/content.js +0 -22029
  43. package/dist/src/static/options.b1269179.js +0 -22033
  44. package/dist/src/static/options.html +0 -9
  45. package/dist/src/static/popup.e3c8c7b7.js +0 -22043
  46. package/dist/src/static/popup.html +0 -9
  47. package/dist/webext-prod/assets/icon128.png +0 -0
  48. package/dist/webext-prod/assets/icon16.png +0 -0
  49. package/dist/webext-prod/assets/icon32.png +0 -0
  50. package/dist/webext-prod/assets/icon48.png +0 -0
  51. package/dist/webext-prod/manifest.json +0 -36
  52. package/dist/webext-prod/src/scripts/background.js +0 -2
  53. package/dist/webext-prod/src/scripts/background.js.map +0 -1
  54. package/dist/webext-prod/src/scripts/content.js +0 -35
  55. package/dist/webext-prod/src/scripts/content.js.map +0 -1
  56. package/dist/webext-prod/src/static/options.a111dcd9.js +0 -2
  57. package/dist/webext-prod/src/static/options.a111dcd9.js.map +0 -1
  58. package/dist/webext-prod/src/static/options.html +0 -1
  59. package/dist/webext-prod/src/static/popup.70071e3e.js +0 -35
  60. package/dist/webext-prod/src/static/popup.70071e3e.js.map +0 -1
  61. package/dist/webext-prod/src/static/popup.cc04f56e.js +0 -2
  62. package/dist/webext-prod/src/static/popup.cc04f56e.js.map +0 -1
  63. package/dist/webext-prod/src/static/popup.e8a65b8a.js +0 -35
  64. package/dist/webext-prod/src/static/popup.e8a65b8a.js.map +0 -1
  65. package/dist/webext-prod/src/static/popup.html +0 -1
@@ -0,0 +1,280 @@
1
+ import React, { useState } from "react";
2
+ import { useVaultStore } from "../services/store";
3
+ import { errorToast, sendOTPVerification } from "../utils/helpers";
4
+ import PageSlider from "../components/slider";
5
+ import SearchBox from "../components/search";
6
+ import {
7
+ PrivacyOverlay,
8
+ TermsAndConditionsOverlay,
9
+ } from "../components/overlays";
10
+ import { imageAssets } from "../utils/constants";
11
+
12
+ const ContactPage = (props: {
13
+ setStep: (step: string) => void;
14
+ setIsLoading: (isLoading: boolean) => void;
15
+ setUserNumberFmt: (number: string) => void;
16
+ userNumberFmt: string;
17
+ setUserEmail: (email: string) => void;
18
+ userEmail: string;
19
+ setSelectedCountry: (country: {
20
+ name: string;
21
+ area: string;
22
+ flag: string;
23
+ }) => void;
24
+ selectedCountry: { name: string; area: string; flag: string };
25
+ allCountries: any;
26
+ }) => {
27
+ const [userNumber, setUserNumber] = useState("");
28
+ const [userInput, setUserInput] = useState("");
29
+ const [searchActive, setSearchActive] = useState(false);
30
+ const [sendOtpErrorText, setSendOtpErrorText] = useState("");
31
+
32
+ const { pk, vaultContract } = useVaultStore();
33
+
34
+ const handleButtonDisplay = () => {
35
+ const button = document.getElementById("verified-custd-mdl-contact-button");
36
+ if (button && props.selectedCountry.area && userNumber.length === 10) {
37
+ setSendOtpErrorText("");
38
+ button.className = "verified-custd-mdl-startup-button-active";
39
+ } else if (
40
+ button &&
41
+ props.userEmail?.length > 0 &&
42
+ isNaN(Number(props.userEmail)) &&
43
+ props.userEmail?.includes("@")
44
+ ) {
45
+ setSendOtpErrorText("");
46
+ button.className = "verified-custd-mdl-startup-button-active";
47
+ } else {
48
+ setSendOtpErrorText("");
49
+ button!.className = "verified-custd-mdl-startup-button";
50
+ }
51
+ };
52
+
53
+ const handleSendOTP = async () => {
54
+ if (
55
+ props.userEmail?.length > 0 &&
56
+ !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(props.userEmail)
57
+ ) {
58
+ setSendOtpErrorText("Invalid input, please check your email");
59
+ return;
60
+ }
61
+
62
+ const vaultId =
63
+ props.userEmail?.length > 0
64
+ ? props.userEmail
65
+ : `+${props.selectedCountry.area}${userNumber}`;
66
+ const channel = props.userEmail?.length > 0 ? "email" : "sms";
67
+
68
+ if (vaultId && channel && pk && vaultContract) {
69
+ props.setIsLoading(true);
70
+ await sendOTPVerification(vaultId, channel).then((res: any) => {
71
+ props.setIsLoading(false);
72
+ if (res) {
73
+ setSendOtpErrorText("");
74
+ props.setStep("3");
75
+ } else {
76
+ setSendOtpErrorText(
77
+ channel === "email"
78
+ ? "Error while sending otp to your email. Try again later."
79
+ : "Error while sending otp to your phone number. Try again later."
80
+ );
81
+ errorToast(
82
+ "Oops something went wrong",
83
+ props.userEmail?.length > 0
84
+ ? `Input a valid email and try again.`
85
+ : `Input a valid phone number and try again.`
86
+ );
87
+ }
88
+ });
89
+ }
90
+ };
91
+
92
+ return (
93
+ <div className="verified-custd-mdl-startup-language">
94
+ <div className="verified-custd-mdl-startup-contact">
95
+ <PageSlider sliderCount={[1, 2, 3]} currentSlider="0" />
96
+ <div className="verified-custd-mdl-startup-contact-content">
97
+ <p className="verified-custd-mdl-startup-contact-text">
98
+ Enter your phone number
99
+ </p>
100
+ <div className="verified-custd-mdl-st-contact-input">
101
+ <div className="verified-custd-mdl-st-contact-content-container">
102
+ <div
103
+ onClick={() => {
104
+ setSearchActive(!searchActive);
105
+ }}
106
+ className="verified-custd-mdl-st-contact-first-section"
107
+ >
108
+ <img
109
+ onClick={() => {
110
+ setSearchActive(!searchActive);
111
+ }}
112
+ alt="Country Flag"
113
+ className="verified-custd-mdl-st-contact-selection-icon"
114
+ src={props.selectedCountry.flag}
115
+ />
116
+ <p
117
+ onClick={() => {
118
+ setSearchActive(!searchActive);
119
+ }}
120
+ className="verified-custd-mdl-st-contact-selection-text"
121
+ >
122
+ + {props.selectedCountry.area}
123
+ </p>
124
+ {searchActive && (
125
+ <img
126
+ onClick={() => {
127
+ setSearchActive(!searchActive);
128
+ }}
129
+ alt="Dropdown Icon"
130
+ className="verified-custd-mdl-st-contact-dropdown"
131
+ src={imageAssets.arrowUp}
132
+ />
133
+ )}
134
+ {!searchActive && (
135
+ <img
136
+ onClick={() => {
137
+ setSearchActive(!searchActive);
138
+ }}
139
+ alt="Dropdown Icon"
140
+ className="verified-custd-mdl-st-contact-dropdown"
141
+ src={imageAssets.arrowDown}
142
+ />
143
+ )}
144
+ </div>
145
+
146
+ <input
147
+ onInputCapture={(e: any) => {
148
+ if (e.target.value === "") {
149
+ setUserInput(userInput + " ");
150
+ } else {
151
+ setUserInput(e.target.value);
152
+ }
153
+ const numericInput = e.target.value?.replace(/\D/g, "");
154
+ setUserNumber(numericInput);
155
+ let formattedNumber = "";
156
+ for (let i = 0; i < numericInput?.length; i++) {
157
+ formattedNumber += numericInput[i];
158
+ if ((i + 1) % 5 === 0 && i + 1 < numericInput?.length) {
159
+ formattedNumber += " ";
160
+ }
161
+ }
162
+ props.setUserNumberFmt(formattedNumber);
163
+ }}
164
+ onInput={(e) => {
165
+ handleButtonDisplay();
166
+ }}
167
+ value={props.userNumberFmt}
168
+ id="phone-input"
169
+ type="text"
170
+ className="verified-custd-mdl-st-contact-second-section"
171
+ placeholder="Enter your phone number"
172
+ />
173
+ </div>
174
+ {searchActive && (
175
+ <SearchBox
176
+ pageName="ftu/contact"
177
+ searchContent={props.allCountries}
178
+ type="area-code"
179
+ handleButtonDisplay={handleButtonDisplay}
180
+ setSelected={props.setSelectedCountry}
181
+ selected={props.selectedCountry}
182
+ searchActive={searchActive}
183
+ setSearchActive={setSearchActive}
184
+ contentMaxHeight="300"
185
+ contentbottomMargin="300"
186
+ />
187
+ )}
188
+ {userNumber.length !== 10 && userInput.length > 10 && (
189
+ <div className="verified-custd-mdl-st-contact-input-error">
190
+ <p className="verified-custd-mdl-input-error-text">
191
+ Invalid input, please check your phone number
192
+ </p>
193
+ </div>
194
+ )}
195
+ {sendOtpErrorText?.length > 0 && props.userEmail?.length === 0 && (
196
+ <div className="verified-custd-mdl-st-contact-input-error">
197
+ <p className="verified-custd-mdl-input-error-text">
198
+ {sendOtpErrorText}
199
+ </p>
200
+ </div>
201
+ )}
202
+ </div>
203
+ </div>
204
+ {!searchActive && (
205
+ <React.Fragment>
206
+ <div className="verified-custd-mdl-p-p-payment-portal-amount-info-separator">
207
+ <div className="verified-custd-mdl-p-p-payment-portal-line"></div>
208
+ <p className="verified-custd-mdl-p-payment-portal-separator-text">
209
+ OR
210
+ </p>
211
+ <div className="verified-custd-mdl-p-p-payment-portal-line"></div>
212
+ </div>
213
+ <div className="verified-custd-mdl-st-contact-input">
214
+ <input
215
+ onInputCapture={(e: any) => {
216
+ props.setUserEmail(e.target?.value);
217
+ props.setUserNumberFmt("");
218
+ setUserNumber("");
219
+ setUserInput("");
220
+ }}
221
+ onInput={(e) => {
222
+ handleButtonDisplay();
223
+ }}
224
+ type="text"
225
+ className="verified-custd-mdl-st-contact-second-section"
226
+ placeholder="Enter your email address"
227
+ />
228
+ {sendOtpErrorText?.length > 0 && props.userEmail?.length > 0 && (
229
+ <div className="verified-custd-mdl-st-contact-input-error">
230
+ <p className="verified-custd-mdl-input-error-text">
231
+ {sendOtpErrorText}
232
+ </p>
233
+ </div>
234
+ )}
235
+ </div>
236
+ </React.Fragment>
237
+ )}
238
+ </div>
239
+
240
+ {!searchActive && <div style={{ height: "80px" }}></div>}
241
+
242
+ <div className="verified-custd-mdl-startup-contact-footer">
243
+ <div className="verified-custd-mdl-st-contact-footer-first-section">
244
+ <TermsAndConditionsOverlay />
245
+ <button
246
+ id="verified-custd-mdl-contact-button"
247
+ onClick={async (e: any) => {
248
+ if (
249
+ e.target.className.includes(
250
+ "verified-custd-mdl-startup-button"
251
+ ) &&
252
+ e.target.className !== "verified-custd-mdl-startup-button"
253
+ ) {
254
+ e.target.className = "verified-custd-mdl-startup-button-click";
255
+ await handleSendOTP();
256
+ } else {
257
+ const buttonElement = document.getElementsByClassName(
258
+ "verified-custd-mdl-startup-button-active"
259
+ );
260
+ if (buttonElement.length > 0) {
261
+ buttonElement[0].className =
262
+ "verified-custd-mdl-startup-button-click";
263
+ await handleSendOTP();
264
+ }
265
+ }
266
+ }}
267
+ className="verified-custd-mdl-startup-button"
268
+ >
269
+ Get OTP
270
+ </button>
271
+ <div className="verified-custd-mdl-st-contact-footer-second-section">
272
+ <PrivacyOverlay />
273
+ </div>
274
+ </div>
275
+ </div>
276
+ </div>
277
+ );
278
+ };
279
+
280
+ export default ContactPage;