message-verify 1.0.1-beta.28 → 1.0.1-beta.29

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 CHANGED
@@ -5,15 +5,12 @@ import Fingerprint2 from 'fingerprintjs2';
5
5
  import ReLoginModal from './relogin-modal.js';
6
6
  let cachedFingerprint = null;
7
7
  export const initFingerprint = async () => {
8
- if (typeof window !== 'undefined') {
9
- const local = localStorage.getItem('__YQG_FINGERPRINT__');
10
- if (local)
11
- return Promise.resolve(local);
12
- }
13
8
  console.log('cachedFingerprint', cachedFingerprint);
14
9
  if (cachedFingerprint) {
10
+ // 已有缓存,直接返回 Promise
15
11
  return Promise.resolve(cachedFingerprint);
16
12
  }
13
+ // 首次异步获取并缓存
17
14
  return new Promise((resolve) => {
18
15
  Fingerprint2.get(function (components) {
19
16
  console.log('components', components);
@@ -24,9 +21,6 @@ export const initFingerprint = async () => {
24
21
  .join('###');
25
22
  const fingerprint = Fingerprint2.x64hash128(values, 31);
26
23
  cachedFingerprint = fingerprint;
27
- if (typeof window !== 'undefined') {
28
- localStorage.setItem('__YQG_FINGERPRINT__', fingerprint);
29
- }
30
24
  resolve(fingerprint);
31
25
  });
32
26
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "1.0.1-beta.28",
3
+ "version": "1.0.1-beta.29",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
package/src/index.tsx CHANGED
@@ -5,16 +5,13 @@ import ReLoginModal from './relogin-modal.js';
5
5
  import { ModalConfig, LoginModalConfig } from './utils/type.js';
6
6
 
7
7
  let cachedFingerprint: string | null = null;
8
-
9
8
  export const initFingerprint = async (): Promise<string> => {
10
- if (typeof window !== 'undefined') {
11
- const local = localStorage.getItem('__YQG_FINGERPRINT__');
12
- if (local) return Promise.resolve(local);
13
- }
14
- console.log('cachedFingerprint', cachedFingerprint);
9
+ console.log('cachedFingerprint', cachedFingerprint);
15
10
  if (cachedFingerprint) {
11
+ // 已有缓存,直接返回 Promise
16
12
  return Promise.resolve(cachedFingerprint);
17
13
  }
14
+ // 首次异步获取并缓存
18
15
  return new Promise((resolve) => {
19
16
  Fingerprint2.get(function (components) {
20
17
  console.log('components', components);
@@ -25,9 +22,6 @@ export const initFingerprint = async (): Promise<string> => {
25
22
  .join('###');
26
23
  const fingerprint = Fingerprint2.x64hash128(values, 31);
27
24
  cachedFingerprint = fingerprint;
28
- if (typeof window !== 'undefined') {
29
- localStorage.setItem('__YQG_FINGERPRINT__', fingerprint);
30
- }
31
25
  resolve(fingerprint);
32
26
  });
33
27
  });