message-verify 1.0.1-beta.32 → 1.0.1-beta.34
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 -21
- package/dist/locales/en.d.ts +1 -0
- package/dist/locales/en.js +2 -1
- package/dist/locales/id.d.ts +1 -0
- package/dist/locales/id.js +2 -1
- package/dist/locales/zh.d.ts +1 -0
- package/dist/locales/zh.js +2 -1
- package/dist/main.js +2 -1
- package/dist/verify-modal.js +3 -2
- package/package.json +1 -1
- package/src/index.tsx +15 -21
- package/src/locales/en.ts +2 -1
- package/src/locales/id.ts +2 -1
- package/src/locales/zh.ts +2 -1
- package/src/main.tsx +2 -1
- package/src/verify-modal.tsx +3 -1
package/dist/index.js
CHANGED
@@ -3,29 +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
|
-
let
|
6
|
+
let fingerprintPromise = null; // 用 Promise 本身作为缓存
|
7
7
|
export const initFingerprint = async () => {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
.filter(component => includeKeys.includes(component.key))
|
20
|
-
.map(component => component.value)
|
21
|
-
.join('###');
|
22
|
-
console.log('values', values);
|
23
|
-
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
24
|
-
console.log('fingerprint', fingerprint);
|
25
|
-
cachedFingerprint = fingerprint;
|
26
|
-
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
|
+
});
|
27
19
|
});
|
28
|
-
}
|
20
|
+
}
|
21
|
+
return fingerprintPromise;
|
29
22
|
};
|
30
23
|
let modalRoot = null;
|
31
24
|
export const createMessageVerifyModal = (modalProps) => {
|
package/dist/locales/en.d.ts
CHANGED
package/dist/locales/en.js
CHANGED
@@ -9,5 +9,6 @@ export default {
|
|
9
9
|
countDownSecound: '{countdown} seconds',
|
10
10
|
accountAlert: 'Account Security Alert',
|
11
11
|
alertContent: 'Changes have been detected in your login environment or network information.To ensure account security, please log in again to verify your identity.',
|
12
|
-
ok: 'OK'
|
12
|
+
ok: 'OK',
|
13
|
+
chidoriOpenPro: 'Chidori has activated security protection for you'
|
13
14
|
};
|
package/dist/locales/id.d.ts
CHANGED
package/dist/locales/id.js
CHANGED
@@ -9,5 +9,6 @@ export default {
|
|
9
9
|
countDownSecound: '{countdown} detik',
|
10
10
|
accountAlert: 'Peringatan Keamanan Akun',
|
11
11
|
alertContent: 'Terdeteksi perubahan pada lingkungan login atau informasi jaringan Anda.Untuk menjaga keamanan akun, silakan login kembali untuk memverifikasi identitas Anda.',
|
12
|
-
ok: 'Baiklah'
|
12
|
+
ok: 'Baiklah',
|
13
|
+
chidoriOpenPro: 'chidori telah mengaktifkan keamanan untuk Anda'
|
13
14
|
};
|
package/dist/locales/zh.d.ts
CHANGED
package/dist/locales/zh.js
CHANGED
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);
|
@@ -109,6 +110,6 @@ const CreateMessageVerifyModal = ({ props }) => {
|
|
109
110
|
} }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, style: { padding: '8px' }, children: countdown > 0 ? t('countDownSecound', lang, { countdown }) : t('reSend', lang) })] }), countdown > 0 ? null :
|
110
111
|
_jsxs("div", { style: { marginTop: 12, display: 'flex', alignItems: 'center' }, children: [_jsx(Input, { placeholder: t('pleaseEnterPicVerifyCode', lang), onChange: (e) => {
|
111
112
|
setCaptchCode(e);
|
112
|
-
}, style: { width: 300 } }), captchaImage && _jsx("img", { src: captchaImage, alt: t('verifyCode', lang), style: { width: 100, height: 30, marginLeft: 8 }, onClick: getKey })] }), (countdown > 0 || captchCode) ? null : _jsx("div", { style: { fontSize: 14, color: 'red' }, children: t('pleaseEnterAndSend', lang) })] }));
|
113
|
+
}, style: { width: 300 } }), captchaImage && _jsx("img", { src: captchaImage, alt: t('verifyCode', lang), style: { width: 100, height: 30, marginLeft: 8 }, onClick: getKey })] }), (countdown > 0 || captchCode) ? null : _jsx("div", { style: { fontSize: 14, color: 'red' }, children: t('pleaseEnterAndSend', lang) }), _jsx("div", { style: { fontSize: 14, color: '#666', marginTop: 12 }, children: t('chidoriOpenPro', lang) })] }));
|
113
114
|
};
|
114
115
|
export default CreateMessageVerifyModal;
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
@@ -4,29 +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
|
-
let
|
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
|
-
.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);
|
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
|
+
});
|
28
21
|
});
|
29
|
-
}
|
22
|
+
}
|
23
|
+
return fingerprintPromise;
|
30
24
|
};
|
31
25
|
|
32
26
|
let modalRoot: ReactDOM.Root | null = null
|
package/src/locales/en.ts
CHANGED
@@ -9,5 +9,6 @@ export default {
|
|
9
9
|
countDownSecound: '{countdown} seconds',
|
10
10
|
accountAlert: 'Account Security Alert',
|
11
11
|
alertContent: 'Changes have been detected in your login environment or network information.To ensure account security, please log in again to verify your identity.',
|
12
|
-
ok: 'OK'
|
12
|
+
ok: 'OK',
|
13
|
+
chidoriOpenPro: 'Chidori has activated security protection for you'
|
13
14
|
};
|
package/src/locales/id.ts
CHANGED
@@ -9,5 +9,6 @@ export default {
|
|
9
9
|
countDownSecound: '{countdown} detik',
|
10
10
|
accountAlert: 'Peringatan Keamanan Akun',
|
11
11
|
alertContent: 'Terdeteksi perubahan pada lingkungan login atau informasi jaringan Anda.Untuk menjaga keamanan akun, silakan login kembali untuk memverifikasi identitas Anda.',
|
12
|
-
ok: 'Baiklah'
|
12
|
+
ok: 'Baiklah',
|
13
|
+
chidoriOpenPro: 'chidori telah mengaktifkan keamanan untuk Anda'
|
13
14
|
};
|
package/src/locales/zh.ts
CHANGED
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
|
>
|
@@ -142,6 +143,7 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
|
|
142
143
|
{captchaImage && <img src={captchaImage} alt={t('verifyCode', lang)} style={{ width: 100, height: 30, marginLeft: 8 }} onClick={getKey} />}
|
143
144
|
</div>}
|
144
145
|
{(countdown > 0 || captchCode) ? null : <div style={{ fontSize: 14, color: 'red' }}>{t('pleaseEnterAndSend', lang)}</div>}
|
146
|
+
<div style={{ fontSize: 14, color: '#666', marginTop: 12 }}>{t('chidoriOpenPro', lang)}</div>
|
145
147
|
</Modal>
|
146
148
|
);
|
147
149
|
};
|