@matchain/matchid-sdk-react 0.1.55-alpha.9 → 0.1.56-alpha.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 (64) hide show
  1. package/dist/api.d.mts +2 -2
  2. package/dist/api.d.ts +2 -2
  3. package/dist/api.js +11 -12
  4. package/dist/api.js.map +1 -1
  5. package/dist/api.mjs +2 -2
  6. package/dist/assets/lottie.d.mts +1 -1
  7. package/dist/assets/lottie.d.ts +1 -1
  8. package/dist/chains.d.mts +1 -1
  9. package/dist/chains.d.ts +1 -1
  10. package/dist/{chunk-2T4RY5BM.mjs → chunk-FGJ25ONR.mjs} +285 -277
  11. package/dist/chunk-FGJ25ONR.mjs.map +1 -0
  12. package/dist/{chunk-GCIXXSIH.mjs → chunk-SG45XKMV.mjs} +2 -2
  13. package/dist/components.d.mts +3 -3
  14. package/dist/components.d.ts +3 -3
  15. package/dist/components.js +295 -287
  16. package/dist/components.js.map +1 -1
  17. package/dist/components.mjs +1 -1
  18. package/dist/hooks.d.mts +4 -2
  19. package/dist/hooks.d.ts +4 -2
  20. package/dist/hooks.js +103 -100
  21. package/dist/hooks.js.map +1 -1
  22. package/dist/hooks.mjs +1 -1
  23. package/dist/icon.d.mts +2 -2
  24. package/dist/icon.d.ts +2 -2
  25. package/dist/{index-Bx7ztInz.d.ts → index-4dZbgWG2.d.ts} +1 -1
  26. package/dist/{index-DXRGMAbv.d.mts → index-B50DU_xT.d.mts} +4 -4
  27. package/dist/{index-DXRGMAbv.d.ts → index-B50DU_xT.d.ts} +4 -4
  28. package/dist/{index-D6wTVWuu.d.mts → index-BKSGbw7b.d.mts} +3 -3
  29. package/dist/{index-DL0LMDQ0.d.mts → index-BXbfmVoU.d.mts} +2 -2
  30. package/dist/{index-BTO2pJRz.d.ts → index-BtjgRcNJ.d.ts} +3 -3
  31. package/dist/{index-DY5CjOq2.d.ts → index-C82WIWvx.d.ts} +5 -5
  32. package/dist/{index-DysgDUCb.d.mts → index-CDTTHSh0.d.mts} +14 -14
  33. package/dist/{index-DysgDUCb.d.ts → index-CDTTHSh0.d.ts} +14 -14
  34. package/dist/{index-BjdOd1te.d.mts → index-CHG4-0Z1.d.mts} +987 -981
  35. package/dist/{index-8h2kA48e.d.ts → index-CsUEaGtM.d.ts} +2 -2
  36. package/dist/{index-CopoHLm5.d.ts → index-CwHXzvvB.d.ts} +1 -1
  37. package/dist/{index-DueNjDv_.d.ts → index-D1Ep9UMx.d.ts} +987 -981
  38. package/dist/{index-HYPgwvkU.d.mts → index-D7E317WV.d.mts} +5 -5
  39. package/dist/{index-B-u8_Lcy.d.ts → index-DK7l3lsH.d.ts} +13 -11
  40. package/dist/{index-BW1GRpQ3.d.mts → index-FKxw4Vaa.d.mts} +1 -1
  41. package/dist/{index-D2hhRO2j.d.mts → index-TjbO7d74.d.mts} +1 -1
  42. package/dist/{index-Ba8t2zs6.d.mts → index-YPRyEYt6.d.mts} +13 -11
  43. package/dist/index.d.mts +20 -20
  44. package/dist/index.d.ts +20 -20
  45. package/dist/index.js +101 -93
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +2 -2
  48. package/dist/{types-Ch54HuTY.d.mts → types-DEsY_CPH.d.mts} +1 -1
  49. package/dist/{types-Ch54HuTY.d.ts → types-DEsY_CPH.d.ts} +1 -1
  50. package/dist/types.d.mts +1 -1
  51. package/dist/types.d.ts +1 -1
  52. package/dist/ui.d.mts +3 -4
  53. package/dist/ui.d.ts +3 -4
  54. package/dist/ui.js +13 -10
  55. package/dist/ui.js.map +1 -1
  56. package/dist/ui.mjs +3 -3
  57. package/example/package.json +3 -0
  58. package/example/src/App.tsx +7 -0
  59. package/example/src/pages/User/index.tsx +49 -4
  60. package/example/src/store/useStore.ts +14 -0
  61. package/example/yarn.lock +15 -0
  62. package/package.json +2 -3
  63. package/dist/chunk-2T4RY5BM.mjs.map +0 -1
  64. /package/dist/{chunk-GCIXXSIH.mjs.map → chunk-SG45XKMV.mjs.map} +0 -0
package/dist/ui.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  Field,
7
7
  HashPanel_default,
8
8
  Input,
9
- Lottie,
9
+ Lottie_default,
10
10
  Modal,
11
11
  ModalDrawer,
12
12
  ModalWithHeader,
@@ -16,7 +16,7 @@ import {
16
16
  Skeleton_default,
17
17
  Switch,
18
18
  Tabs
19
- } from "./chunk-2T4RY5BM.mjs";
19
+ } from "./chunk-FGJ25ONR.mjs";
20
20
  import "./chunk-JX73EY6V.mjs";
21
21
  import "./chunk-UA6XHZHX.mjs";
22
22
  import "./chunk-IZOOVZAD.mjs";
@@ -31,7 +31,7 @@ export {
31
31
  Field,
32
32
  HashPanel_default as HashPanel,
33
33
  Input,
34
- Lottie,
34
+ Lottie_default as Lottie,
35
35
  Modal,
36
36
  ModalDrawer,
37
37
  ModalWithHeader,
@@ -28,9 +28,12 @@
28
28
  "dependencies": {
29
29
  "@matchain/matchid-sdk-react": "../dist",
30
30
  "@zerodev/webauthn-key": "5.3.3",
31
+ "crypto": "^1.0.1",
32
+ "crypto-js": "^4.2.0",
31
33
  "eruda": "^3.4.1"
32
34
  },
33
35
  "devDependencies": {
36
+ "@types/crypto-js": "^4.2.2",
34
37
  "@types/node": "^22.9.0",
35
38
  "@vitejs/plugin-react": "^4.3.3",
36
39
  "autoprefixer": "^10.4.20",
@@ -15,6 +15,7 @@ import {LoginButton} from "@matchain/matchid-sdk-react/components";
15
15
  import UI from "@/pages/UI";
16
16
  import TgApp from "@/pages/TgApp";
17
17
  import {WagmiProvider} from "wagmi";
18
+ import useStore from "@/store/useStore";
18
19
 
19
20
 
20
21
  function Nav() {
@@ -84,6 +85,7 @@ function RouterApp() {
84
85
  color,
85
86
  setColor
86
87
  } = useLocalStore()
88
+ const {appSecret,setAppSecret} = useStore()
87
89
 
88
90
  return <Router>
89
91
  <div className={`mb-2 p-2 flex gap-2 flex-col`}>
@@ -103,6 +105,11 @@ function RouterApp() {
103
105
  <input value={appid} placeholder={"Appid"} className={"border-solid border"} onChange={(ele) => {
104
106
  setAppid(ele.target.value)
105
107
  }}/></div>
108
+ <div>
109
+ <label>AppSecret:</label>
110
+ <input value={appSecret} placeholder={"AppSecret"} className={"border-solid border"} onChange={(ele) => {
111
+ setAppSecret(ele.target.value)
112
+ }}/></div>
106
113
  <div>
107
114
  <label>AuthEndpoint:</label>
108
115
  <input value={endpoints?.auth || ''} placeholder={"Auth Endpoint"} className={"border-solid border"}
@@ -1,16 +1,57 @@
1
1
  import React, {useState} from "react";
2
- import {CEXList, LOGIN_METHOD_MAP, LoginMethod, LoginMethodList, RecommendLoginMethodList, WalletList} from "@/config";
2
+ import {CEXList, LOGIN_METHOD_MAP, LoginMethod} from "@/config";
3
3
  import {CEXType, LoginMethodType} from "@matchain/matchid-sdk-react/types";
4
- import {useMatchEvents, useUserInfo, useWallet} from "@matchain/matchid-sdk-react/hooks";
4
+ import {useMatchEvents, useUserInfo,} from "@matchain/matchid-sdk-react/hooks";
5
5
  import {
6
- LoginButton,
7
6
  UsernameModal,
8
7
  } from "@matchain/matchid-sdk-react/components";
9
8
  import BindListModal from "@/pages/User/components/BindListModal";
10
9
  import PohListModal from "@/pages/User/components/PohListModal";
11
- import ChainListModal from "@/pages/Wallet/components/ChainListModal";
12
10
  import ButtonGroup from "@/components/ButtonGroup";
11
+ import useStore from "@/store/useStore";
12
+ import hmacSHA256 from 'crypto-js/hmac-sha256';
13
+ import sha256 from 'crypto-js/sha256';
13
14
 
15
+ function UserAuthSign(fields: any, appSecretKey: string) {
16
+ const filteredFields = {...fields};
17
+ delete filteredFields["hash"];
18
+
19
+ const keys = Object.keys(filteredFields).sort();
20
+
21
+ const dataCheckString = keys
22
+ .filter(key => filteredFields[key] !== "")
23
+ .map(key => `${key}=${filteredFields[key]}`)
24
+ .join("\n");
25
+
26
+ const hash = sha256(appSecretKey);
27
+
28
+ const signature = hmacSHA256(dataCheckString, hash);
29
+
30
+ return {
31
+ data: dataCheckString,
32
+ secret: hash,
33
+ hash: signature.toString()
34
+ }
35
+ }
36
+
37
+ function AuthData({authData}: {
38
+ authData: any
39
+ }) {
40
+ const {appSecret} = useStore()
41
+ const {data, secret, hash} = UserAuthSign(authData, appSecret)
42
+
43
+ return <div>
44
+ <h2>Auth Data</h2>
45
+ <pre>{JSON.stringify(authData, null, 2)}</pre>
46
+ <h2>Auth String</h2>
47
+ <pre>{data}</pre>
48
+ <h2>Secret</h2>
49
+ <pre>{secret.toString()}</pre>
50
+
51
+ <h2>Hash</h2>
52
+ <pre>{hash}</pre>
53
+ </div>
54
+ }
14
55
 
15
56
  function LoginContent() {
16
57
  const {
@@ -28,6 +69,8 @@ function LoginContent() {
28
69
  } = useUserInfo();
29
70
  const [usernameOpen, setUsernameOpen] = useState(false)
30
71
  const [modal, setModal] = useState<'bindList' | 'pohList' | ''>('')
72
+
73
+ const [authData, setAuthData] = useState<any>(null)
31
74
  const refreshOv = async () => {
32
75
  await refreshOverview()
33
76
  alert('refreshed')
@@ -37,6 +80,7 @@ function LoginContent() {
37
80
  try {
38
81
  const res = await auth()
39
82
  console.log('auth', res)
83
+ setAuthData(res)
40
84
  } catch (e) {
41
85
  console.error('auth', e)
42
86
  }
@@ -71,6 +115,7 @@ function LoginContent() {
71
115
  setUsernameOpen(false)
72
116
  }}/>
73
117
  </ButtonGroup>
118
+ {authData && <AuthData authData={authData}/>}
74
119
  <ButtonGroup title={"Bind"}>
75
120
  {
76
121
  LoginMethod.map((method) => {
@@ -0,0 +1,14 @@
1
+ import {create} from 'zustand';
2
+
3
+ interface StoreState {
4
+ appSecret: string
5
+ setAppSecret: (appSecret: string) => void,
6
+
7
+ }
8
+
9
+ const useStore = create<StoreState>(set => ({
10
+ appSecret: '',
11
+ setAppSecret: (appSecret) => set({appSecret: appSecret}),
12
+ }));
13
+
14
+ export default useStore;
package/example/yarn.lock CHANGED
@@ -503,6 +503,11 @@
503
503
  dependencies:
504
504
  "@babel/types" "^7.20.7"
505
505
 
506
+ "@types/crypto-js@^4.2.2":
507
+ version "4.2.2"
508
+ resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-4.2.2.tgz#771c4a768d94eb5922cc202a3009558204df0cea"
509
+ integrity sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==
510
+
506
511
  "@types/estree@1.0.6":
507
512
  version "1.0.6"
508
513
  resolved "https://registry.npmmirror.com/@types/estree/-/estree-1.0.6.tgz"
@@ -676,6 +681,16 @@ cross-spawn@^7.0.0:
676
681
  shebang-command "^2.0.0"
677
682
  which "^2.0.1"
678
683
 
684
+ crypto-js@^4.2.0:
685
+ version "4.2.0"
686
+ resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.2.0.tgz#4d931639ecdfd12ff80e8186dba6af2c2e856631"
687
+ integrity sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==
688
+
689
+ crypto@^1.0.1:
690
+ version "1.0.1"
691
+ resolved "https://registry.yarnpkg.com/crypto/-/crypto-1.0.1.tgz#2af1b7cad8175d24c8a1b0778255794a21803037"
692
+ integrity sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==
693
+
679
694
  cssesc@^3.0.0:
680
695
  version "3.0.0"
681
696
  resolved "https://registry.npmmirror.com/cssesc/-/cssesc-3.0.0.tgz"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matchain/matchid-sdk-react",
3
- "version": "0.1.55-alpha.9",
3
+ "version": "0.1.56-alpha.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -67,7 +67,6 @@
67
67
  "license": "ISC",
68
68
  "description": "MatchID SDK",
69
69
  "peerDependencies": {
70
- "lottie-react": "^2.4.1",
71
70
  "react": "^18.0.0",
72
71
  "react-dom": "^18.0.0"
73
72
  },
@@ -80,7 +79,7 @@
80
79
  "copy-to-clipboard": "^3.3.3",
81
80
  "ethers": "^5.7.2",
82
81
  "lodash": "^4.17.21",
83
-
82
+ "lottie-react": "^2.4.1",
84
83
  "moment": "^2.30.1",
85
84
  "react-infinite-scroll-component": "^6.1.0",
86
85
  "react-intl": "^7.1.0",