message-verify 0.0.47-beta.0 → 0.0.48-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 +1 -0
- package/dist/index.js +14 -0
- package/dist/resource.js +1 -1
- package/package.json +2 -1
- package/src/index.tsx +15 -0
- package/src/resource.ts +1 -1
- package/src/verify-modal.tsx +50 -66
- package/vite.config.ts +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import ReactDOM from 'react-dom/client';
|
3
3
|
import VerifyModal from './verify-modal.js';
|
4
|
+
import Fingerprint2 from 'fingerprintjs2';
|
5
|
+
export const getFingerprint = () => {
|
6
|
+
return new Promise((resolve) => {
|
7
|
+
Fingerprint2.get(function (components) {
|
8
|
+
const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
|
9
|
+
const values = components
|
10
|
+
.filter(component => includeKeys.includes(component.key))
|
11
|
+
.map(component => component.value)
|
12
|
+
.join('###');
|
13
|
+
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
14
|
+
resolve(fingerprint);
|
15
|
+
});
|
16
|
+
});
|
17
|
+
};
|
4
18
|
let modalRoot = null;
|
5
19
|
export const createMessageVerifyModal = (modalProps) => {
|
6
20
|
const container = document.createElement('div');
|
package/dist/resource.js
CHANGED
@@ -2,7 +2,7 @@ import { assign, customPost } from '@yqg/resource';
|
|
2
2
|
// import { assign, axios as instance, customPost } from '@yqg/resource';
|
3
3
|
// import { message } from './compoments/index.js';
|
4
4
|
// import { YQG_SUCCESS } from './utils/status.js';
|
5
|
-
const urlPrefix = '/
|
5
|
+
const urlPrefix = '/admin/';
|
6
6
|
// axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
|
7
7
|
// instance.interceptors.response.use(
|
8
8
|
// (res) => {
|
package/package.json
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "message-verify",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.48-beta.0",
|
4
4
|
"type": "module",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"dependencies": {
|
7
7
|
"@yqg/resource": "^1.3.8",
|
8
|
+
"fingerprintjs2": "^2.1.4",
|
8
9
|
"react": "^19.0.0",
|
9
10
|
"react-dom": "^19.0.0"
|
10
11
|
},
|
package/src/index.tsx
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
import ReactDOM from 'react-dom/client'
|
2
2
|
import VerifyModal from './verify-modal.js'
|
3
|
+
import Fingerprint2 from 'fingerprintjs2';
|
4
|
+
|
5
|
+
export const getFingerprint = (): Promise<string> => {
|
6
|
+
return new Promise((resolve) => {
|
7
|
+
Fingerprint2.get(function (components) {
|
8
|
+
const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
|
9
|
+
const values = components
|
10
|
+
.filter(component => includeKeys.includes(component.key))
|
11
|
+
.map(component => component.value)
|
12
|
+
.join('###');
|
13
|
+
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
14
|
+
resolve(fingerprint);
|
15
|
+
});
|
16
|
+
});
|
17
|
+
};
|
3
18
|
|
4
19
|
export type ModalConfig = {
|
5
20
|
data: string;
|
package/src/resource.ts
CHANGED
@@ -3,7 +3,7 @@ import { assign, customPost } from '@yqg/resource';
|
|
3
3
|
// import { message } from './compoments/index.js';
|
4
4
|
// import { YQG_SUCCESS } from './utils/status.js';
|
5
5
|
|
6
|
-
const urlPrefix = '/
|
6
|
+
const urlPrefix = '/admin/';
|
7
7
|
// axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
|
8
8
|
// instance.interceptors.response.use(
|
9
9
|
// (res) => {
|
package/src/verify-modal.tsx
CHANGED
@@ -2,23 +2,7 @@ import { useEffect, useState } from 'react'
|
|
2
2
|
import { Modal, Input, Button, message } from './compoments/index.js'
|
3
3
|
import Api from './resource.js'
|
4
4
|
import t from './utils/i18n.js'
|
5
|
-
// import Fingerprint2 from 'fingerprintjs2';
|
6
5
|
|
7
|
-
// Fingerprint2.get(
|
8
|
-
// { }, // 用 as any 绕过类型检查
|
9
|
-
// function(components) {
|
10
|
-
// console.log('components', components);
|
11
|
-
// const excludeKeys = ['screenResolution', 'colorDepth', 'availableScreenResolution'];
|
12
|
-
// const values = components
|
13
|
-
// .filter(component => !excludeKeys.includes(component.key)) // 排除多个 key
|
14
|
-
// .map(component => component.value)
|
15
|
-
// .join('###');
|
16
|
-
// // const values = components.map(function (component) { return component.value }).join('###');
|
17
|
-
// // 生成 hash 指纹码
|
18
|
-
// const fingerprint = Fingerprint2.x64hash128(values, 31);
|
19
|
-
// console.log('fingerprint', fingerprint);
|
20
|
-
// }
|
21
|
-
// );
|
22
6
|
type ModalConfig = {
|
23
7
|
data: string;
|
24
8
|
onClose?: () => void;
|
@@ -51,7 +35,7 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
51
35
|
const res = await Api.getCaptchaKey();
|
52
36
|
const { body: key } = res.data || {};
|
53
37
|
setCaptchaKey(key);
|
54
|
-
if(key) {
|
38
|
+
if (key) {
|
55
39
|
const image = Api.getCaptchaImgUrl(key) as unknown;
|
56
40
|
setCaptchaImage(image as string);
|
57
41
|
}
|
@@ -72,60 +56,60 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
72
56
|
};
|
73
57
|
}, [visible, countdown]);
|
74
58
|
|
75
|
-
const handleResend = async() => {
|
59
|
+
const handleResend = async () => {
|
76
60
|
setCountdown(60);
|
77
|
-
const res = await Api.reSendCode({captchaKey, captcha: captchCode});
|
61
|
+
const res = await Api.reSendCode({ captchaKey, captcha: captchCode });
|
78
62
|
console.log('handleResend=>res', res);
|
79
63
|
message.success(t('sendSuccess', lang));
|
80
64
|
}
|
81
|
-
|
65
|
+
|
82
66
|
return (
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
67
|
+
<Modal
|
68
|
+
width={420}
|
69
|
+
visible={visible}
|
70
|
+
onClose={() => {
|
71
|
+
setVisible(false);
|
72
|
+
props.onClose?.();
|
73
|
+
}}
|
74
|
+
>
|
75
|
+
<div style={{ fontSize: 14, color: '#666' }}>{t('alreadySend', lang, { phone: mobile })}</div>
|
76
|
+
|
77
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }}>
|
78
|
+
<Input.OTP
|
79
|
+
length={6}
|
80
|
+
value={otp}
|
81
|
+
onChange={(val) => {
|
82
|
+
setOtp(val);
|
83
|
+
if (val.length === 6) {
|
84
|
+
http.defaults.headers.common['sms-code'] = val as string;
|
85
|
+
http.defaults.headers.common['sms-code-key'] = verifyCodeKey as string;
|
86
|
+
http(config);
|
87
|
+
setVisible(false);
|
88
|
+
}
|
89
|
+
}} />
|
90
|
+
<Button
|
91
|
+
disabled={countdown > 0 || !captchCode}
|
92
|
+
onClick={handleResend}
|
93
|
+
style={{ padding: '8px' }}
|
94
|
+
>
|
95
|
+
{countdown > 0 ? t('countDownSecound', lang, { countdown }) : t('reSend', lang)}
|
96
|
+
</Button>
|
97
|
+
</div>
|
98
|
+
{countdown > 0 ? null :
|
99
|
+
<div style={{ marginTop: 12, display: 'flex', alignItems: 'center' }}>
|
100
|
+
<Input
|
101
|
+
placeholder={t('pleaseEnterPicVerifyCode', lang)}
|
102
|
+
onChange={(e) => {
|
103
|
+
setCaptchCode(e as string)
|
104
|
+
}}
|
105
|
+
style={{ width: 300 }}
|
106
|
+
/>
|
107
|
+
|
108
|
+
{captchaImage && <img src={captchaImage} alt={t('verifyCode', lang)} style={{ width: 100, height: 30, marginLeft: 8 }} onClick={getKey} />}
|
109
|
+
</div>}
|
110
|
+
{(countdown > 0 || captchCode) ? null : <div style={{ fontSize: 14, color: 'red' }}>{t('pleaseEnterAndSend', lang)}</div>}
|
111
|
+
</Modal>
|
128
112
|
);
|
129
|
-
|
113
|
+
};
|
130
114
|
|
131
115
|
export default CreateMessageVerifyModal;
|