message-verify 0.0.18-beta.0 → 0.0.20-beta.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.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -5
- package/dist/main.js +1 -1
- package/dist/main.umd.cjs +516 -0
- package/dist/resource.d.ts +2 -0
- package/dist/resource.js +9 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/getFingerprint.d.ts +1 -0
- package/dist/utils/getFingerprint.js +13 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/package.json +5 -1
- package/src/index.tsx +43 -11
- package/src/main.tsx +9 -5
- package/src/resource.ts +12 -0
- package/src/utils/getFingerprint.ts +12 -0
- package/src/utils/index.ts +2 -0
- package/stats.html +4949 -0
- package/vite.config.ts +23 -0
package/dist/resource.js
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
import { assign, customGet, customPost } from '@yqg/resource';
|
2
|
+
const urlPrefix = '/admin/';
|
3
|
+
const api = {
|
4
|
+
urlPrefix,
|
5
|
+
getCaptchaKey: customPost('captcha/key'),
|
6
|
+
reSendCode: customPost('sms/send'),
|
7
|
+
getCaptchaImgUrl: customGet('captcha/image/:captchaKey'),
|
8
|
+
};
|
9
|
+
export default assign(api);
|
@@ -1 +1 @@
|
|
1
|
-
{"root":["../src/index.tsx","../src/main.tsx","../src/vite-env.d.ts","../src/components/input.tsx","../src/components/modal.tsx"],"version":"5.7.3"}
|
1
|
+
{"root":["../src/index.tsx","../src/main.tsx","../src/resource.ts","../src/vite-env.d.ts","../src/components/input.tsx","../src/components/modal.tsx","../src/utils/getfingerprint.ts","../src/utils/index.ts"],"version":"5.7.3"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getEnvironmentFingerprint: () => Promise<string>;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import FingerprintJS from '@fingerprintjs/fingerprintjs';
|
2
|
+
export const getEnvironmentFingerprint = async () => {
|
3
|
+
try {
|
4
|
+
const fp = await FingerprintJS.load();
|
5
|
+
const result = await fp.get();
|
6
|
+
console.log('环境指纹', result.visitorId);
|
7
|
+
return result.visitorId;
|
8
|
+
}
|
9
|
+
catch (error) {
|
10
|
+
console.error('Failed to get fingerprint:', error);
|
11
|
+
throw new Error('FINGERPRINT_GET_FAILED');
|
12
|
+
}
|
13
|
+
};
|
package/package.json
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "message-verify",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.20-beta.0",
|
4
4
|
"type": "module",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"dependencies": {
|
7
|
+
"@fingerprintjs/fingerprintjs": "^4.6.2",
|
8
|
+
"@yqg/resource": "^1.3.8",
|
7
9
|
"react": "^19.0.0",
|
8
10
|
"react-dom": "^19.0.0"
|
9
11
|
},
|
@@ -16,6 +18,7 @@
|
|
16
18
|
"eslint-plugin-react-hooks": "^5.2.0",
|
17
19
|
"eslint-plugin-react-refresh": "^0.4.19",
|
18
20
|
"globals": "^16.0.0",
|
21
|
+
"rollup-plugin-visualizer": "^5.14.0",
|
19
22
|
"typescript": "~5.7.2",
|
20
23
|
"typescript-eslint": "^8.26.1",
|
21
24
|
"vite": "^6.3.1"
|
@@ -23,6 +26,7 @@
|
|
23
26
|
"scripts": {
|
24
27
|
"dev": "vite",
|
25
28
|
"build": "tsc -b",
|
29
|
+
"analyze": "vite build",
|
26
30
|
"lint": "eslint .",
|
27
31
|
"preview": "vite preview"
|
28
32
|
}
|
package/src/index.tsx
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
import { useEffect, useState } from 'react'
|
2
2
|
import Modal from './components/modal'
|
3
3
|
import Input from './components/input'
|
4
|
+
import Api from './resource'
|
5
|
+
import { getEnvironmentFingerprint } from './utils'
|
6
|
+
// import Button from './components/button'
|
7
|
+
|
8
|
+
// const buttonStyle: React.CSSProperties = {
|
9
|
+
// padding: '8px 16px',
|
10
|
+
// border: 'none',
|
11
|
+
// borderRadius: 4,
|
12
|
+
// fontSize: 14,
|
13
|
+
// cursor: 'pointer',
|
14
|
+
// };
|
4
15
|
|
5
16
|
interface Props {
|
6
17
|
data: {
|
@@ -8,15 +19,26 @@ interface Props {
|
|
8
19
|
verifyCodeKey: string;
|
9
20
|
sendSuccess: boolean;
|
10
21
|
};
|
22
|
+
refresh: () => void;
|
11
23
|
}
|
12
24
|
const App: React.FC<Props> = ({ data }) => {
|
13
25
|
const { mobile } = data || {};
|
14
26
|
const [countdown, setCountdown] = useState(60);
|
15
27
|
const [visible, setVisible] = useState(false);
|
28
|
+
const [captchaImage, setCaptchaImage] = useState('');
|
29
|
+
|
30
|
+
const getKey = async () => {
|
31
|
+
const res = await Api.getCaptchaKey();
|
32
|
+
console.log('res', res);
|
33
|
+
const image = await Api.getCaptchaImage({ captchaKey: res.data.key });
|
34
|
+
console.log('image', image);
|
35
|
+
setCaptchaImage(image);
|
36
|
+
}
|
16
37
|
|
17
38
|
useEffect(() => {
|
18
39
|
setVisible(true);
|
19
40
|
}, [])
|
41
|
+
|
20
42
|
useEffect(() => {
|
21
43
|
let timer: number | null = null;
|
22
44
|
if (visible && countdown > 0) {
|
@@ -24,33 +46,43 @@ const App: React.FC<Props> = ({ data }) => {
|
|
24
46
|
setCountdown((prev) => prev - 1);
|
25
47
|
}, 1000);
|
26
48
|
}
|
49
|
+
if (countdown === 0) {
|
50
|
+
getKey();
|
51
|
+
}
|
27
52
|
return () => {
|
28
53
|
if (timer) clearInterval(timer);
|
29
54
|
};
|
30
55
|
}, [visible, countdown]);
|
31
56
|
|
32
|
-
const handleResend = () => {
|
33
|
-
|
34
|
-
|
35
|
-
|
57
|
+
// const handleResend = async() => {
|
58
|
+
// setCountdown(60);
|
59
|
+
// await Api.greSendCode({ });
|
60
|
+
// // 这里可以加上重新发送验证码的逻辑
|
61
|
+
// };
|
36
62
|
|
37
63
|
return (
|
38
64
|
<>
|
39
|
-
<Modal visible={visible} onClose={() => setVisible(false)}
|
65
|
+
<Modal visible={visible} onClose={() => setVisible(false)}
|
66
|
+
// onOk={() => refresh()}
|
67
|
+
>
|
40
68
|
<div>已发送短信至您的手机:{mobile}</div>
|
41
|
-
<div style={{
|
69
|
+
{countdown > 0 ? null : <div style={{ marginTop: 8 }}>
|
70
|
+
<Input />
|
71
|
+
<img src={captchaImage} alt="验证码" style={{ width: 100, height: 30, marginLeft: 8 }} onClick={getKey} />
|
72
|
+
</div>}
|
73
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
|
42
74
|
<Input placeholder="请输入验证码" />
|
43
|
-
<
|
75
|
+
{/* <Button
|
44
76
|
disabled={countdown > 0}
|
45
77
|
onClick={handleResend}
|
46
78
|
style={countdown > 0 ? { marginLeft: 8 } : { marginLeft: 8, backgroundColor: '#1677ff', color: '#fff' }}
|
47
|
-
|
48
|
-
|
49
|
-
</button>
|
79
|
+
btnText={countdown > 0 ? `${countdown}秒` : '重新发送'}
|
80
|
+
/> */}
|
50
81
|
</div>
|
51
82
|
</Modal>
|
52
83
|
</>
|
53
84
|
)
|
54
85
|
}
|
55
86
|
|
56
|
-
export default App
|
87
|
+
export default App;
|
88
|
+
export { getEnvironmentFingerprint };
|
package/src/main.tsx
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
import { createRoot } from 'react-dom/client';
|
2
2
|
import App from './index'; // 或 './index'
|
3
3
|
|
4
|
-
createRoot(document.getElementById('root')!).render(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
createRoot(document.getElementById('root')!).render(
|
5
|
+
<App
|
6
|
+
data={{
|
7
|
+
mobile: '185****7760',
|
8
|
+
verifyCodeKey: 'e381c5f9-c7f4-4bf1-a948-744334fb0203',
|
9
|
+
sendSuccess: true
|
10
|
+
}}
|
11
|
+
refresh={() => {console.log('刷新')}}
|
12
|
+
/>);
|
package/src/resource.ts
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
import { assign, customGet, customPost } from '@yqg/resource';
|
2
|
+
const urlPrefix = '/admin/';
|
3
|
+
|
4
|
+
const api = {
|
5
|
+
urlPrefix,
|
6
|
+
|
7
|
+
getCaptchaKey: customPost('captcha/key'),
|
8
|
+
reSendCode: customPost('sms/send'),
|
9
|
+
getCaptchaImgUrl: customGet('captcha/image/:captchaKey'),
|
10
|
+
};
|
11
|
+
|
12
|
+
export default assign(api);
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import FingerprintJS from '@fingerprintjs/fingerprintjs';
|
2
|
+
export const getEnvironmentFingerprint = async(): Promise<string> =>{
|
3
|
+
try {
|
4
|
+
const fp = await FingerprintJS.load();
|
5
|
+
const result = await fp.get();
|
6
|
+
console.log('环境指纹', result.visitorId);
|
7
|
+
return result.visitorId;
|
8
|
+
} catch (error) {
|
9
|
+
console.error('Failed to get fingerprint:', error);
|
10
|
+
throw new Error('FINGERPRINT_GET_FAILED');
|
11
|
+
}
|
12
|
+
};
|