message-verify 1.0.1-beta.31 → 1.0.1-beta.33
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.js +14 -22
- package/dist/main.js +2 -1
- package/dist/verify-modal.js +2 -1
- package/package.json +1 -1
- package/src/index.tsx +15 -22
- package/src/main.tsx +2 -1
- package/src/verify-modal.tsx +2 -1
package/dist/index.js
CHANGED
@@ -3,30 +3,22 @@ import ReactDOM from 'react-dom/client';
|
|
3
3
|
import VerifyModal from './verify-modal.js';
|
4
4
|
import Fingerprint2 from 'fingerprintjs2';
|
5
5
|
import ReLoginModal from './relogin-modal.js';
|
6
|
-
|
6
|
+
let fingerprintPromise = null; // 用 Promise 本身作为缓存
|
7
7
|
export const initFingerprint = async () => {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
const values = components
|
20
|
-
.filter(component => includeKeys.includes(component.key))
|
21
|
-
.map(component => component.value)
|
22
|
-
.join('###');
|
23
|
-
console.log('values', values);
|
24
|
-
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
25
|
-
console.log('fingerprint', fingerprint);
|
26
|
-
// cachedFingerprint = fingerprint;
|
27
|
-
resolve(fingerprint);
|
8
|
+
if (!fingerprintPromise) {
|
9
|
+
fingerprintPromise = new Promise((resolve) => {
|
10
|
+
Fingerprint2.get(components => {
|
11
|
+
const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
|
12
|
+
const values = components
|
13
|
+
.filter(c => includeKeys.includes(c.key))
|
14
|
+
.map(c => c.value)
|
15
|
+
.join('###');
|
16
|
+
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
17
|
+
resolve(fingerprint);
|
18
|
+
});
|
28
19
|
});
|
29
|
-
}
|
20
|
+
}
|
21
|
+
return fingerprintPromise;
|
30
22
|
};
|
31
23
|
let modalRoot = null;
|
32
24
|
export const createMessageVerifyModal = (modalProps) => {
|
package/dist/main.js
CHANGED
@@ -4,7 +4,8 @@ import { createMessageVerifyModal, initFingerprint, createReLoginModal } from '.
|
|
4
4
|
import { axios } from '@yqg/resource';
|
5
5
|
const data = "{\"mobile\":\"188****4035\",\"verifyCodeKey\":\"3f025b33-988e-47c0-950d-6beb776d043f\",\"needValid\":true,\"step\":2,\"message\":\"需要填写验证码\"}";
|
6
6
|
const fp = await initFingerprint();
|
7
|
-
|
7
|
+
const fp2 = await initFingerprint();
|
8
|
+
console.log(fp, fp2);
|
8
9
|
const config = {
|
9
10
|
"transitional": {
|
10
11
|
"silentJSONParsing": true,
|
package/dist/verify-modal.js
CHANGED
@@ -11,7 +11,7 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
11
11
|
const [captchaImage, setCaptchaImage] = useState('');
|
12
12
|
const [captchCode, setCaptchCode] = useState('');
|
13
13
|
const [captchaKey, setCaptchaKey] = useState('');
|
14
|
-
const { data, http, lang, api = '/admin/sms/send', config, apiResolve } = props || {};
|
14
|
+
const { data, http, lang, api = '/admin/sms/send', config, apiResolve, apiReject } = props || {};
|
15
15
|
const dataObj = JSON.parse(data || '{}');
|
16
16
|
const { mobile, verifyCodeKey } = dataObj || {};
|
17
17
|
const getKey = async () => {
|
@@ -64,6 +64,7 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
64
64
|
};
|
65
65
|
return (_jsxs(Modal, { width: 420, visible: visible, onClose: () => {
|
66
66
|
setVisible(false);
|
67
|
+
apiReject();
|
67
68
|
props.onClose?.();
|
68
69
|
}, children: [_jsx("div", { style: { fontSize: 14, color: '#666' }, children: t('alreadySend', lang, { phone: mobile }) }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }, children: [_jsx(Input.OTP, { length: 6, value: otp, onChange: async (val) => {
|
69
70
|
setOtp(val);
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
@@ -4,30 +4,23 @@ import Fingerprint2 from 'fingerprintjs2';
|
|
4
4
|
import ReLoginModal from './relogin-modal.js';
|
5
5
|
import { ModalConfig, LoginModalConfig } from './utils/type.js';
|
6
6
|
|
7
|
-
|
7
|
+
let fingerprintPromise: Promise<string> | null = null; // 用 Promise 本身作为缓存
|
8
|
+
|
8
9
|
export const initFingerprint = async (): Promise<string> => {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
const values = components
|
21
|
-
.filter(component => includeKeys.includes(component.key))
|
22
|
-
.map(component => component.value)
|
23
|
-
.join('###');
|
24
|
-
console.log('values', values);
|
25
|
-
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
26
|
-
console.log('fingerprint', fingerprint);
|
27
|
-
// cachedFingerprint = fingerprint;
|
28
|
-
resolve(fingerprint);
|
10
|
+
if (!fingerprintPromise) {
|
11
|
+
fingerprintPromise = new Promise((resolve) => {
|
12
|
+
Fingerprint2.get(components => {
|
13
|
+
const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
|
14
|
+
const values = components
|
15
|
+
.filter(c => includeKeys.includes(c.key))
|
16
|
+
.map(c => c.value)
|
17
|
+
.join('###');
|
18
|
+
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
19
|
+
resolve(fingerprint);
|
20
|
+
});
|
29
21
|
});
|
30
|
-
}
|
22
|
+
}
|
23
|
+
return fingerprintPromise;
|
31
24
|
};
|
32
25
|
|
33
26
|
let modalRoot: ReactDOM.Root | null = null
|
package/src/main.tsx
CHANGED
@@ -5,7 +5,8 @@ import { axios } from '@yqg/resource';
|
|
5
5
|
const data = "{\"mobile\":\"188****4035\",\"verifyCodeKey\":\"3f025b33-988e-47c0-950d-6beb776d043f\",\"needValid\":true,\"step\":2,\"message\":\"需要填写验证码\"}";
|
6
6
|
|
7
7
|
const fp = await initFingerprint();
|
8
|
-
|
8
|
+
const fp2 = await initFingerprint();
|
9
|
+
console.log(fp, fp2);
|
9
10
|
|
10
11
|
const config = {
|
11
12
|
"transitional": {
|
package/src/verify-modal.tsx
CHANGED
@@ -12,7 +12,7 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
12
12
|
const [captchaImage, setCaptchaImage] = useState<string>('');
|
13
13
|
const [captchCode, setCaptchCode] = useState<string>('');
|
14
14
|
const [captchaKey, setCaptchaKey] = useState<string>('');
|
15
|
-
const { data, http, lang, api = '/admin/sms/send', config, apiResolve } = props || {};
|
15
|
+
const { data, http, lang, api = '/admin/sms/send', config, apiResolve, apiReject } = props || {};
|
16
16
|
const dataObj = JSON.parse(data || '{}');
|
17
17
|
const { mobile, verifyCodeKey } = dataObj || {};
|
18
18
|
|
@@ -72,6 +72,7 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
72
72
|
visible={visible}
|
73
73
|
onClose={() => {
|
74
74
|
setVisible(false);
|
75
|
+
apiReject();
|
75
76
|
props.onClose?.();
|
76
77
|
}}
|
77
78
|
>
|