@matchain/matchid-sdk-react 0.1.17 → 0.1.18
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/index.css +194 -63
- package/dist/index.d.mts +41 -16
- package/dist/index.d.ts +41 -16
- package/dist/index.js +527 -208
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +513 -194
- package/dist/index.mjs.map +1 -1
- package/example/src/components/Login/index.tsx +14 -19
- package/example/src/config/index.ts +9 -0
- package/example/src/pages/User.tsx +29 -22
- package/package.json +2 -1
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {Hooks,Components} from "@matchain/matchid-sdk-react
|
|
2
|
+
import {Hooks,Components} from "@matchain/matchid-sdk-react";
|
|
3
|
+
import {LoginMethod} from "@/config";
|
|
3
4
|
const { useUserInfo} = Hooks
|
|
4
5
|
const {EmailModal,LoginModal,LoginBox,LoginPanel} = Components
|
|
5
6
|
export default function Login(){
|
|
6
7
|
const {
|
|
7
|
-
loginByWallet,
|
|
8
|
-
loginByTwitter,
|
|
9
|
-
loginByGoogle,
|
|
10
8
|
loginByEmail,
|
|
11
9
|
getLoginEmailCode,
|
|
12
|
-
|
|
10
|
+
login,
|
|
13
11
|
} = useUserInfo();
|
|
14
12
|
const [email, setEmail] = React.useState('')
|
|
15
13
|
const [code, setCode] = React.useState('')
|
|
16
14
|
const [emailOpen, setEmailOpen] = React.useState(false)
|
|
17
15
|
const [loginOpen, setLoginOpen] = React.useState(false)
|
|
18
16
|
|
|
17
|
+
|
|
19
18
|
return (
|
|
20
19
|
<div className={`flex flex-col gap-10`}>
|
|
21
20
|
<div className={`flex gap-5`}>
|
|
22
21
|
<button className={`bg-gray-300 p-1 rounded`}
|
|
23
|
-
onClick={
|
|
24
|
-
</button>
|
|
25
|
-
<button className={`bg-gray-300 p-1 rounded`}
|
|
26
|
-
onClick={loginByTwitter}>Twitter
|
|
27
|
-
</button>
|
|
28
|
-
<button className={`bg-gray-300 p-1 rounded`}
|
|
29
|
-
onClick={loginByGoogle}>Google
|
|
30
|
-
</button>
|
|
31
|
-
<button className={`bg-gray-300 p-1 rounded`}
|
|
32
|
-
onClick={loginByTelegram}>Telegram
|
|
22
|
+
onClick={() => setLoginOpen(true)}>Open Modal
|
|
33
23
|
</button>
|
|
34
24
|
<button className={`bg-gray-300 p-1 rounded`}
|
|
35
25
|
onClick={() => setEmailOpen(true)}>Email
|
|
36
26
|
</button>
|
|
27
|
+
{
|
|
28
|
+
LoginMethod.map((method) => {
|
|
29
|
+
return <button key={method} className={`bg-gray-300 p-1 capitalize rounded`}
|
|
30
|
+
onClick={() => login(method)}>{method}
|
|
31
|
+
</button>
|
|
32
|
+
})
|
|
33
|
+
}
|
|
37
34
|
<EmailModal isOpen={emailOpen} onClose={() => setEmailOpen(false)} onBack={() => {
|
|
38
35
|
console.log('input email modal back event')
|
|
39
36
|
setEmailOpen(false)
|
|
40
37
|
}}/>
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
onClick={() => setLoginOpen(true)}>Modal
|
|
44
|
-
</button>
|
|
39
|
+
|
|
45
40
|
<LoginModal isOpen={loginOpen} onClose={() => setLoginOpen(false)}/>
|
|
46
41
|
|
|
47
42
|
</div>
|
|
@@ -66,7 +61,7 @@ export default function Login(){
|
|
|
66
61
|
</div>
|
|
67
62
|
<div className={`font-bold text-lg`}>LoginPanel</div>
|
|
68
63
|
<div className={`bg-gray-100 p-10`}>
|
|
69
|
-
<div className={`bg-white`}><LoginPanel onClose={() => console.log('onLoginPanelClose')}/></div>
|
|
64
|
+
<div className={`bg-white`}><LoginPanel onClose={() => console.log('onLoginPanelClose')} methods={['discord','github']}/></div>
|
|
70
65
|
</div>
|
|
71
66
|
</div>
|
|
72
67
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {Hooks, Components, Api} from "@matchain/matchid-sdk-react"
|
|
2
2
|
import React from "react";
|
|
3
3
|
import RoutePrivate from "../components/RoutePrivate";
|
|
4
|
+
import {LoginMethod} from "@/config";
|
|
4
5
|
|
|
5
6
|
const {useMatchEvents, useUserInfo, useWallet} = Hooks
|
|
6
7
|
const {
|
|
@@ -47,8 +48,7 @@ function LoginContent() {
|
|
|
47
48
|
refreshOverview,
|
|
48
49
|
did,
|
|
49
50
|
address,
|
|
50
|
-
|
|
51
|
-
bindTelegram,
|
|
51
|
+
bind,
|
|
52
52
|
auth
|
|
53
53
|
} = useUserInfo();
|
|
54
54
|
const [usernameOpen, setUsernameOpen] = React.useState(false)
|
|
@@ -67,17 +67,14 @@ function LoginContent() {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
return <div>
|
|
70
|
+
return <div className={`flex flex-col gap-[10px]`}>
|
|
71
71
|
<h1 className={`text-2xl`}>You are already logged in</h1>
|
|
72
72
|
<div className={`text-ellipsis break-words`}>token:{token}</div>
|
|
73
73
|
<div className={`text-ellipsis break-words`}>username:{username}</div>
|
|
74
74
|
<div className={`text-ellipsis break-words`}>did:{did}</div>
|
|
75
75
|
<div className={`text-ellipsis break-words`}>address:{address}</div>
|
|
76
76
|
<div className={`flex gap-[20px]`}>
|
|
77
|
-
<button className={`bg-gray-300 p-1 rounded
|
|
78
|
-
onClick={bindWallet}>Bind wallet
|
|
79
|
-
</button>
|
|
80
|
-
<button className={`bg-gray-300 p-1 rounded mr-5`}
|
|
77
|
+
<button className={`bg-gray-300 p-1 rounded`}
|
|
81
78
|
onClick={() => setUsernameOpen(true)}>Set username
|
|
82
79
|
</button>
|
|
83
80
|
<UsernameModal isOpen={usernameOpen} onClose={() => setUsernameOpen(false)} onBack={() => {
|
|
@@ -97,19 +94,28 @@ function LoginContent() {
|
|
|
97
94
|
alert('set password success')
|
|
98
95
|
setPasswordOpen(false)
|
|
99
96
|
}}/>
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
</div>
|
|
98
|
+
<div className={`flex gap-[20px]`}>
|
|
99
|
+
|
|
100
|
+
{
|
|
101
|
+
LoginMethod.map((method) => {
|
|
102
|
+
return <button key={method} className={`bg-gray-300 p-1 capitalize rounded`}
|
|
103
|
+
onClick={() => bind(method)}>Bind {method}
|
|
104
|
+
</button>
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
</div>
|
|
108
|
+
<div className={`flex gap-[20px]`}>
|
|
109
|
+
<button className={`bg-gray-300 p-1 rounded`}
|
|
110
|
+
onClick={onAuth}>Third party auth
|
|
111
|
+
</button>
|
|
112
|
+
<button className={`bg-gray-300 p-1 rounded`}
|
|
113
|
+
onClick={refreshOv}>Refresh Overview
|
|
114
|
+
</button>
|
|
115
|
+
<button className={`bg-gray-300 p-1 rounded`}
|
|
116
|
+
onClick={logout}>Logout
|
|
102
117
|
</button>
|
|
103
118
|
</div>
|
|
104
|
-
<button className={`bg-gray-300 p-1 rounded mr-5`}
|
|
105
|
-
onClick={onAuth}>Third party auth
|
|
106
|
-
</button>
|
|
107
|
-
<button className={`bg-gray-300 p-1 rounded mr-5`}
|
|
108
|
-
onClick={refreshOv}>Refresh Overview
|
|
109
|
-
</button>
|
|
110
|
-
<button className={`bg-gray-300 p-1 rounded`}
|
|
111
|
-
onClick={logout}>Logout
|
|
112
|
-
</button>
|
|
113
119
|
|
|
114
120
|
<QueryDisplay query={bindListQuery} name={"BindListQuery"}/>
|
|
115
121
|
<QueryDisplay query={pohListQuery} name={"PohListQuery"}/>
|
|
@@ -130,15 +136,16 @@ export default function User() {
|
|
|
130
136
|
}
|
|
131
137
|
})
|
|
132
138
|
return <div>
|
|
133
|
-
<RoutePrivate>
|
|
134
|
-
<LoginContent/>
|
|
135
|
-
</RoutePrivate>
|
|
136
139
|
|
|
137
140
|
<div className={`font-bold text-lg`}>LoginButton</div>
|
|
138
141
|
|
|
139
142
|
<div className={`bg-gray-100 p-5 mt-5`}>
|
|
140
|
-
<LoginButton methods={["wallet", "
|
|
143
|
+
<LoginButton methods={["wallet", "twitter", "email", "google"]} popoverPosition={"left"}/>
|
|
141
144
|
</div>
|
|
145
|
+
<RoutePrivate>
|
|
146
|
+
<LoginContent/>
|
|
147
|
+
</RoutePrivate>
|
|
148
|
+
|
|
142
149
|
|
|
143
150
|
</div>
|
|
144
151
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matchain/matchid-sdk-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@tanstack/react-query": "^5.62.11",
|
|
38
38
|
"axios": "^1.7.0",
|
|
39
|
+
"copy-to-clipboard": "^3.3.3",
|
|
39
40
|
"ethers": "^5.7.2",
|
|
40
41
|
"react-router-dom": "^6.0.0",
|
|
41
42
|
"styled-components": "^6.1.13",
|