login-with-facepass 1.0.2 → 1.0.4

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 (2) hide show
  1. package/index.js +167 -0
  2. package/package.json +1 -1
package/index.js ADDED
@@ -0,0 +1,167 @@
1
+ import React, { useState } from 'react';
2
+ import { ScanFace } from 'lucide-react';
3
+
4
+ const be_endpoint = ""
5
+
6
+ const createChallenge = async ({ email }) => {
7
+ const response = await fetch(be_endpoint + "/Public/login", {
8
+ method: "GET",
9
+ headers: {
10
+ "Content-Type": "application/json"
11
+ },
12
+ body: JSON.stringify({
13
+ "email": email
14
+ })
15
+ });
16
+
17
+ const data = await response.json();
18
+ return data;
19
+ };
20
+
21
+ const challengeApproval = async ({challengeId}) => {
22
+ //prompt every 500 ms
23
+ const response = await fetch(be_endpoint + "/Public/checkChallengeStatus", {
24
+ method: "GET",
25
+ headers: {
26
+ "Content-Type": "application/json"
27
+ },
28
+ body: JSON.stringify({
29
+ "challengeId": challengeId
30
+ })
31
+
32
+ })
33
+
34
+ const data = await response.json();
35
+ return data;
36
+
37
+ };
38
+
39
+
40
+ const LoginWithFacePass = ({ setJwt, setStatus }) => {
41
+ const [showPopup, setShowPopup] = useState(false);
42
+ const [email, setEmail] = useState("");
43
+
44
+ const handleSubmit = () => {
45
+ setShowPopup(false);
46
+
47
+ console.log("Email:", email);
48
+
49
+ setJwt("jwt: dsfaiohsd");
50
+ setStatus("approved");
51
+ };
52
+
53
+ const styles = {
54
+ overlay: {
55
+ position: "fixed",
56
+ top: 0,
57
+ left: 0,
58
+ width: "100%",
59
+ height: "100%",
60
+ background: "transparent",
61
+ display: "flex",
62
+ justifyContent: "center",
63
+ alignItems: "center",
64
+ zIndex: 1000
65
+
66
+ },
67
+ modal: {
68
+ background: "#18181b",
69
+ padding: "24px",
70
+ borderRadius: "10px",
71
+ width: "320px",
72
+ border: "1px solid #27272a",
73
+ boxShadow: "0 10px 30px rgba(0,0,0,0.6)",
74
+ color: "white"
75
+ },
76
+ input: {
77
+ width: "100%",
78
+ padding: "10px",
79
+ marginTop: "10px",
80
+ marginBottom: "16px",
81
+ borderRadius: "6px",
82
+ border: "1px solid #3f3f46",
83
+ background: "#09090b",
84
+ color: "white"
85
+ },
86
+ buttonRow: {
87
+ display: "flex",
88
+ gap: "10px",
89
+ justifyContent: "flex-end",
90
+ marginTop: "10px"
91
+ },
92
+
93
+ cancelButton: {
94
+ padding: "10px 16px",
95
+ borderRadius: "6px",
96
+ border: "1px solid #3f3f46",
97
+ background: "#18181b",
98
+ color: "#e4e4e7",
99
+ fontWeight: "500",
100
+ cursor: "pointer",
101
+ transition: "all 0.2s ease"
102
+ },
103
+
104
+ continueButton: {
105
+ padding: "10px 16px",
106
+ borderRadius: "6px",
107
+ border: "none",
108
+ background: "#22c55e",
109
+ color: "white",
110
+ fontWeight: "600",
111
+ cursor: "pointer",
112
+ transition: "all 0.2s ease"
113
+ }
114
+ };
115
+
116
+ return (
117
+ <div>
118
+ <button
119
+ className="demo-btn standard-btn"
120
+ onClick={() => setShowPopup(true)}
121
+ >
122
+ <ScanFace size={24} strokeWidth={3} />
123
+ Login with FacePass
124
+ </button>
125
+
126
+ {showPopup && (
127
+ <div style={styles.overlay}>
128
+ <div style={styles.modal}>
129
+ <h3>Enter your email</h3>
130
+
131
+ <input
132
+ style={styles.input}
133
+ type="email"
134
+ placeholder="your@email.com"
135
+ value={email}
136
+ onChange={(e) => setEmail(e.target.value)}
137
+ />
138
+
139
+ <div style={styles.buttonRow}>
140
+ <button
141
+ style={styles.cancelButton}
142
+ onMouseEnter={(e) => (e.target.style.background = "#27272a")}
143
+ onMouseLeave={(e) => (e.target.style.background = "#18181b")}
144
+ onClick={() => setShowPopup(false)}
145
+ >
146
+ Cancel
147
+ </button>
148
+
149
+ <button
150
+ style={styles.continueButton}
151
+ onMouseEnter={(e) => (e.target.style.background = "#16a34a")}
152
+ onMouseLeave={(e) => (e.target.style.background = "#22c55e")}
153
+ onClick={handleSubmit}
154
+ >
155
+ Continue
156
+ </button>
157
+ </div>
158
+ </div>
159
+ </div>
160
+ )}
161
+ </div>
162
+ );
163
+ };
164
+
165
+
166
+ export { LoginWithFacePass };
167
+ export default LoginWithFacePass;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "login-with-facepass",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {