message-verify 0.0.47-beta.0 → 0.0.49-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 CHANGED
@@ -1,3 +1,4 @@
1
+ export declare const getFingerprint: () => Promise<string>;
1
2
  export type ModalConfig = {
2
3
  data: string;
3
4
  onClose?: () => void;
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
@@ -45,6 +45,6 @@ const api = {
45
45
  urlPrefix,
46
46
  getCaptchaKey: customPost('captcha/key'),
47
47
  reSendCode: customPost('sms/send'),
48
- getCaptchaImgUrl: (captchaKey) => { return `/admin/captcha/image/${captchaKey}`; },
48
+ getCaptchaImgUrl: (captchaKey) => { return `captcha/image/${captchaKey}`; },
49
49
  };
50
50
  export default assign(api);
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "0.0.47-beta.0",
3
+ "version": "0.0.49-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
@@ -51,7 +51,7 @@ const api = {
51
51
 
52
52
  getCaptchaKey: customPost('captcha/key'),
53
53
  reSendCode: customPost('sms/send'),
54
- getCaptchaImgUrl: (captchaKey: string) => {return `/admin/captcha/image/${captchaKey}`},
54
+ getCaptchaImgUrl: (captchaKey: string) => {return `captcha/image/${captchaKey}`},
55
55
  };
56
56
 
57
57
  export default assign(api);
@@ -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
- <Modal
84
- width={420}
85
- visible={visible}
86
- onClose={() => {
87
- setVisible(false);
88
- props.onClose?.();
89
- }}
90
- >
91
- <div style={{ fontSize: 14, color: '#666' }}>{t('alreadySend', lang, { phone: mobile})}</div>
92
-
93
- <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }}>
94
- <Input.OTP
95
- length={6}
96
- value={otp}
97
- onChange={(val) => {
98
- setOtp(val);
99
- if(val.length === 6) {
100
- http.defaults.headers.common['sms-code'] = val as string;
101
- http.defaults.headers.common['sms-code-key'] = verifyCodeKey as string;
102
- http(config);
103
- setVisible(false);
104
- }
105
- }} />
106
- <Button
107
- disabled={countdown > 0 || !captchCode}
108
- onClick={handleResend}
109
- style={{ padding: '8px' }}
110
- >
111
- {countdown > 0 ? t('countDownSecound', lang, { countdown }) : t('reSend', lang)}
112
- </Button>
113
- </div>
114
- {countdown > 0 ? null :
115
- <div style={{ marginTop: 12, display: 'flex', alignItems: 'center' }}>
116
- <Input
117
- placeholder={t('pleaseEnterPicVerifyCode', lang)}
118
- onChange={(e) => {
119
- setCaptchCode(e as string)
120
- }}
121
- style={{ width: 300 }}
122
- />
123
-
124
- {captchaImage && <img src={captchaImage} alt={t('verifyCode', lang)} style={{ width: 100, height: 30, marginLeft: 8 }} onClick={getKey} />}
125
- </div>}
126
- {(countdown > 0 || captchCode) ? null : <div style={{ fontSize: 14, color: 'red' }}>{t('pleaseEnterAndSend', lang)}</div>}
127
- </Modal>
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;
package/vite.config.ts CHANGED
@@ -8,7 +8,7 @@ export default defineConfig({
8
8
  server: {
9
9
  port: 5174, // 你的端口
10
10
  proxy: {
11
- '/messageVerify': {
11
+ '/admin': {
12
12
  target: 'https://chidori-admin-test.yangqianguan.com',
13
13
  changeOrigin: true,
14
14
  headers: {