message-verify 1.0.0-beta.6 → 1.0.0-beta.7
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 +7 -0
- package/package.json +1 -1
- package/src/index.tsx +7 -0
package/dist/index.js
CHANGED
@@ -2,7 +2,13 @@ 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
4
|
import Fingerprint2 from 'fingerprintjs2';
|
5
|
+
let cachedFingerprint = null;
|
5
6
|
export const initFingerprint = async () => {
|
7
|
+
if (cachedFingerprint) {
|
8
|
+
// 已有缓存,直接返回 Promise
|
9
|
+
return Promise.resolve(cachedFingerprint);
|
10
|
+
}
|
11
|
+
// 首次异步获取并缓存
|
6
12
|
return new Promise((resolve) => {
|
7
13
|
Fingerprint2.get(function (components) {
|
8
14
|
const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
|
@@ -11,6 +17,7 @@ export const initFingerprint = async () => {
|
|
11
17
|
.map(component => component.value)
|
12
18
|
.join('###');
|
13
19
|
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
20
|
+
cachedFingerprint = fingerprint;
|
14
21
|
resolve(fingerprint);
|
15
22
|
});
|
16
23
|
});
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
@@ -3,7 +3,13 @@ import VerifyModal from './verify-modal.js'
|
|
3
3
|
import Fingerprint2 from 'fingerprintjs2';
|
4
4
|
import { ModalConfig } from './utils/type.js';
|
5
5
|
|
6
|
+
let cachedFingerprint: string | null = null;
|
6
7
|
export const initFingerprint = async (): Promise<string> => {
|
8
|
+
if (cachedFingerprint) {
|
9
|
+
// 已有缓存,直接返回 Promise
|
10
|
+
return Promise.resolve(cachedFingerprint);
|
11
|
+
}
|
12
|
+
// 首次异步获取并缓存
|
7
13
|
return new Promise((resolve) => {
|
8
14
|
Fingerprint2.get(function (components) {
|
9
15
|
const includeKeys = ['userAgent', 'deviceMemory', 'cpuClass', 'hardwareConcurrency', 'platform'];
|
@@ -12,6 +18,7 @@ export const initFingerprint = async (): Promise<string> => {
|
|
12
18
|
.map(component => component.value)
|
13
19
|
.join('###');
|
14
20
|
const fingerprint = Fingerprint2.x64hash128(values, 31);
|
21
|
+
cachedFingerprint = fingerprint;
|
15
22
|
resolve(fingerprint);
|
16
23
|
});
|
17
24
|
});
|