@windrun-huaiin/third-ui 7.1.2 → 7.2.1

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.
Files changed (77) hide show
  1. package/dist/clerk/clerk-page-generator-client.d.ts +10 -0
  2. package/dist/clerk/clerk-page-generator-client.js +28 -0
  3. package/dist/clerk/clerk-page-generator-client.mjs +25 -0
  4. package/dist/clerk/clerk-page-generator.js +1 -0
  5. package/dist/clerk/clerk-page-generator.mjs +1 -0
  6. package/dist/clerk/client-page-generator.d.ts +10 -0
  7. package/dist/clerk/client-page-generator.js +28 -0
  8. package/dist/clerk/client-page-generator.mjs +25 -0
  9. package/dist/clerk/context/FingerprintProvider.d.ts +25 -0
  10. package/dist/clerk/context/FingerprintProvider.js +71 -0
  11. package/dist/clerk/context/FingerprintProvider.mjs +65 -0
  12. package/dist/clerk/fingerprint/fingerprint-client.d.ts +47 -0
  13. package/dist/clerk/fingerprint/fingerprint-client.js +177 -0
  14. package/dist/clerk/fingerprint/fingerprint-client.mjs +168 -0
  15. package/dist/clerk/fingerprint/fingerprint-provider.d.ts +25 -0
  16. package/dist/clerk/fingerprint/fingerprint-provider.js +71 -0
  17. package/dist/clerk/fingerprint/fingerprint-provider.mjs +65 -0
  18. package/dist/clerk/fingerprint/fingerprint-server.d.ts +22 -0
  19. package/dist/clerk/fingerprint/fingerprint-server.js +75 -0
  20. package/dist/clerk/fingerprint/fingerprint-server.mjs +71 -0
  21. package/dist/clerk/fingerprint/fingerprint-shared.d.ts +17 -0
  22. package/dist/clerk/fingerprint/fingerprint-shared.js +35 -0
  23. package/dist/clerk/fingerprint/fingerprint-shared.mjs +29 -0
  24. package/dist/clerk/fingerprint/fingerprint.d.ts +55 -0
  25. package/dist/clerk/fingerprint/fingerprint.js +17 -0
  26. package/dist/clerk/fingerprint/fingerprint.mjs +15 -0
  27. package/dist/clerk/fingerprint/index.d.ts +5 -0
  28. package/dist/clerk/fingerprint/index.js +29 -0
  29. package/dist/clerk/fingerprint/index.mjs +5 -0
  30. package/dist/clerk/fingerprint/server.d.ts +3 -0
  31. package/dist/clerk/fingerprint/server.js +15 -0
  32. package/dist/clerk/fingerprint/server.mjs +2 -0
  33. package/dist/clerk/fingerprint/types.d.ts +44 -0
  34. package/dist/clerk/fingerprint/use-fingerprint.d.ts +6 -0
  35. package/dist/clerk/fingerprint/use-fingerprint.js +176 -0
  36. package/dist/clerk/fingerprint/use-fingerprint.mjs +174 -0
  37. package/dist/clerk/fingerprint.d.ts +55 -0
  38. package/dist/clerk/fingerprint.js +237 -0
  39. package/dist/clerk/fingerprint.mjs +225 -0
  40. package/dist/clerk/hooks/useFingerprint.d.ts +6 -0
  41. package/dist/clerk/hooks/useFingerprint.js +182 -0
  42. package/dist/clerk/hooks/useFingerprint.mjs +180 -0
  43. package/dist/clerk/index.d.ts +3 -0
  44. package/dist/clerk/index.js +7 -0
  45. package/dist/clerk/index.mjs +3 -0
  46. package/dist/clerk/signin-with-fingerprint-client.d.ts +7 -0
  47. package/dist/clerk/signin-with-fingerprint-client.js +52 -0
  48. package/dist/clerk/signin-with-fingerprint-client.mjs +47 -0
  49. package/dist/clerk/signup-with-fingerprint-client.d.ts +7 -0
  50. package/dist/clerk/signup-with-fingerprint-client.js +52 -0
  51. package/dist/clerk/signup-with-fingerprint-client.mjs +47 -0
  52. package/dist/clerk/types.d.ts +42 -0
  53. package/dist/fuma/mdx/toc-base.js +1 -1
  54. package/dist/fuma/mdx/toc-base.mjs +1 -1
  55. package/dist/node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.js +3212 -0
  56. package/dist/node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.mjs +3187 -0
  57. package/dist/node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.2/node_modules/tslib/tslib.es6.js +51 -0
  58. package/dist/node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.2/node_modules/tslib/tslib.es6.mjs +50 -1
  59. package/dist/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  60. package/dist/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  61. package/dist/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  62. package/dist/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  63. package/package.json +14 -3
  64. package/src/clerk/clerk-page-generator-client.tsx +37 -0
  65. package/src/clerk/clerk-page-generator.tsx +5 -1
  66. package/src/clerk/fingerprint/fingerprint-client.ts +194 -0
  67. package/src/clerk/fingerprint/fingerprint-provider.tsx +114 -0
  68. package/src/clerk/fingerprint/fingerprint-server.ts +88 -0
  69. package/src/clerk/fingerprint/fingerprint-shared.ts +29 -0
  70. package/src/clerk/fingerprint/index.ts +15 -0
  71. package/src/clerk/fingerprint/server.ts +9 -0
  72. package/src/clerk/fingerprint/types.ts +50 -0
  73. package/src/clerk/fingerprint/use-fingerprint.ts +200 -0
  74. package/src/clerk/index.ts +9 -2
  75. package/src/clerk/server.ts +1 -0
  76. package/src/clerk/signin-with-fingerprint-client.tsx +57 -0
  77. package/src/clerk/signup-with-fingerprint-client.tsx +57 -0
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Create a SignUp page with fingerprint support
3
+ * Note: This must be used within a FingerprintProvider
4
+ */
5
+ export declare function createSignUpPageWithFingerprint(): () => import("react/jsx-runtime").JSX.Element;
6
+ /**
7
+ * Create a SignIn page with fingerprint support
8
+ * Note: This must be used within a FingerprintProvider
9
+ */
10
+ export declare function createSignInPageWithFingerprint(): () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var signupWithFingerprintClient = require('./signup-with-fingerprint-client.js');
6
+ var signinWithFingerprintClient = require('./signin-with-fingerprint-client.js');
7
+
8
+ /**
9
+ * Create a SignUp page with fingerprint support
10
+ * Note: This must be used within a FingerprintProvider
11
+ */
12
+ function createSignUpPageWithFingerprint() {
13
+ return function SignUpPage() {
14
+ return (jsxRuntime.jsx("div", { className: "flex-1 flex justify-center mt-0 mb-32", children: jsxRuntime.jsx(signupWithFingerprintClient.SignUpWithFingerprint, {}) }));
15
+ };
16
+ }
17
+ /**
18
+ * Create a SignIn page with fingerprint support
19
+ * Note: This must be used within a FingerprintProvider
20
+ */
21
+ function createSignInPageWithFingerprint() {
22
+ return function SignInPage() {
23
+ return (jsxRuntime.jsx("div", { className: "flex-1 flex justify-center mb-64", children: jsxRuntime.jsx(signinWithFingerprintClient.SignInWithFingerprint, {}) }));
24
+ };
25
+ }
26
+
27
+ exports.createSignInPageWithFingerprint = createSignInPageWithFingerprint;
28
+ exports.createSignUpPageWithFingerprint = createSignUpPageWithFingerprint;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { SignUpWithFingerprint } from './signup-with-fingerprint-client.mjs';
4
+ import { SignInWithFingerprint } from './signin-with-fingerprint-client.mjs';
5
+
6
+ /**
7
+ * Create a SignUp page with fingerprint support
8
+ * Note: This must be used within a FingerprintProvider
9
+ */
10
+ function createSignUpPageWithFingerprint() {
11
+ return function SignUpPage() {
12
+ return (jsx("div", { className: "flex-1 flex justify-center mt-0 mb-32", children: jsx(SignUpWithFingerprint, {}) }));
13
+ };
14
+ }
15
+ /**
16
+ * Create a SignIn page with fingerprint support
17
+ * Note: This must be used within a FingerprintProvider
18
+ */
19
+ function createSignInPageWithFingerprint() {
20
+ return function SignInPage() {
21
+ return (jsx("div", { className: "flex-1 flex justify-center mb-64", children: jsx(SignInWithFingerprint, {}) }));
22
+ };
23
+ }
24
+
25
+ export { createSignInPageWithFingerprint, createSignUpPageWithFingerprint };
@@ -3,6 +3,7 @@
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var nextjs = require('@clerk/nextjs');
5
5
 
6
+ // Legacy page generators (for backward compatibility)
6
7
  function createSignInPage() {
7
8
  return function SignInPage() {
8
9
  return (jsxRuntime.jsx("div", { className: "flex-1 flex justify-center mb-64", children: jsxRuntime.jsx(nextjs.SignIn, {}) }));
@@ -1,6 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { SignIn, SignUp, Waitlist } from '@clerk/nextjs';
3
3
 
4
+ // Legacy page generators (for backward compatibility)
4
5
  function createSignInPage() {
5
6
  return function SignInPage() {
6
7
  return (jsx("div", { className: "flex-1 flex justify-center mb-64", children: jsx(SignIn, {}) }));
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Create a SignUp page with fingerprint support
3
+ * Note: This must be used within a FingerprintProvider
4
+ */
5
+ export declare function createSignUpPageWithFingerprint(): () => import("react/jsx-runtime").JSX.Element;
6
+ /**
7
+ * Create a SignIn page with fingerprint support
8
+ * Note: This must be used within a FingerprintProvider
9
+ */
10
+ export declare function createSignInPageWithFingerprint(): () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var signupWithFingerprintClient = require('./signup-with-fingerprint-client.js');
6
+ var signinWithFingerprintClient = require('./signin-with-fingerprint-client.js');
7
+
8
+ /**
9
+ * Create a SignUp page with fingerprint support
10
+ * Note: This must be used within a FingerprintProvider
11
+ */
12
+ function createSignUpPageWithFingerprint() {
13
+ return function SignUpPage() {
14
+ return (jsxRuntime.jsx("div", { className: "flex-1 flex justify-center mt-0 mb-32", children: jsxRuntime.jsx(signupWithFingerprintClient.SignUpWithFingerprint, {}) }));
15
+ };
16
+ }
17
+ /**
18
+ * Create a SignIn page with fingerprint support
19
+ * Note: This must be used within a FingerprintProvider
20
+ */
21
+ function createSignInPageWithFingerprint() {
22
+ return function SignInPage() {
23
+ return (jsxRuntime.jsx("div", { className: "flex-1 flex justify-center mb-64", children: jsxRuntime.jsx(signinWithFingerprintClient.SignInWithFingerprint, {}) }));
24
+ };
25
+ }
26
+
27
+ exports.createSignInPageWithFingerprint = createSignInPageWithFingerprint;
28
+ exports.createSignUpPageWithFingerprint = createSignUpPageWithFingerprint;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { SignUpWithFingerprint } from './signup-with-fingerprint-client.mjs';
4
+ import { SignInWithFingerprint } from './signin-with-fingerprint-client.mjs';
5
+
6
+ /**
7
+ * Create a SignUp page with fingerprint support
8
+ * Note: This must be used within a FingerprintProvider
9
+ */
10
+ function createSignUpPageWithFingerprint() {
11
+ return function SignUpPage() {
12
+ return (jsx("div", { className: "flex-1 flex justify-center mt-0 mb-32", children: jsx(SignUpWithFingerprint, {}) }));
13
+ };
14
+ }
15
+ /**
16
+ * Create a SignIn page with fingerprint support
17
+ * Note: This must be used within a FingerprintProvider
18
+ */
19
+ function createSignInPageWithFingerprint() {
20
+ return function SignInPage() {
21
+ return (jsx("div", { className: "flex-1 flex justify-center mb-64", children: jsx(SignInWithFingerprint, {}) }));
22
+ };
23
+ }
24
+
25
+ export { createSignInPageWithFingerprint, createSignUpPageWithFingerprint };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import type { FingerprintContextType, FingerprintProviderProps } from '../types';
3
+ /**
4
+ * Fingerprint Provider Component
5
+ * 为应用提供fingerprint和匿名用户管理功能
6
+ */
7
+ export declare function FingerprintProvider({ children, config }: FingerprintProviderProps): import("react/jsx-runtime").JSX.Element;
8
+ /**
9
+ * Hook to use fingerprint context
10
+ */
11
+ export declare function useFingerprintContext(): FingerprintContextType;
12
+ /**
13
+ * Safe hook to use fingerprint context - returns null if no provider
14
+ * 安全版本的fingerprint context hook - 如果没有Provider则返回null
15
+ */
16
+ export declare function useFingerprintContextSafe(): FingerprintContextType | null;
17
+ /**
18
+ * HOC for components that need fingerprint functionality
19
+ * Note: This HOC now requires config to be passed externally
20
+ */
21
+ export declare function withFingerprint<P extends object>(Component: React.ComponentType<P>, config: FingerprintProviderProps['config']): (props: P) => import("react/jsx-runtime").JSX.Element;
22
+ /**
23
+ * 组件:显示用户状态和积分信息(用于调试)
24
+ */
25
+ export declare function FingerprintDebugInfo(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,71 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
+ var useFingerprint = require('../hooks/useFingerprint.js');
7
+
8
+ const FingerprintContext = React.createContext(undefined);
9
+ /**
10
+ * Fingerprint Provider Component
11
+ * 为应用提供fingerprint和匿名用户管理功能
12
+ */
13
+ function FingerprintProvider({ children, config }) {
14
+ const fingerprintData = useFingerprint.useFingerprint(config);
15
+ return (jsxRuntime.jsx(FingerprintContext.Provider, { value: fingerprintData, children: children }));
16
+ }
17
+ /**
18
+ * Hook to use fingerprint context
19
+ */
20
+ function useFingerprintContext() {
21
+ const context = React.useContext(FingerprintContext);
22
+ if (context === undefined) {
23
+ throw new Error('useFingerprintContext must be used within a FingerprintProvider');
24
+ }
25
+ return context;
26
+ }
27
+ /**
28
+ * Safe hook to use fingerprint context - returns null if no provider
29
+ * 安全版本的fingerprint context hook - 如果没有Provider则返回null
30
+ */
31
+ function useFingerprintContextSafe() {
32
+ const context = React.useContext(FingerprintContext);
33
+ return context || null;
34
+ }
35
+ /**
36
+ * HOC for components that need fingerprint functionality
37
+ * Note: This HOC now requires config to be passed externally
38
+ */
39
+ function withFingerprint(Component, config) {
40
+ return function FingerprintWrappedComponent(props) {
41
+ return (jsxRuntime.jsx(FingerprintProvider, { config: config, children: jsxRuntime.jsx(Component, Object.assign({}, props)) }));
42
+ };
43
+ }
44
+ /**
45
+ * 组件:显示用户状态和积分信息(用于调试)
46
+ */
47
+ function FingerprintDebugInfo() {
48
+ const { fingerprintId, anonymousUser, credits, isLoading, isInitialized, error } = useFingerprintContext();
49
+ if (!process.env.NODE_ENV || process.env.NODE_ENV === 'production') {
50
+ return null;
51
+ }
52
+ return (jsxRuntime.jsxs("div", { style: {
53
+ position: 'fixed',
54
+ bottom: '10px',
55
+ right: '10px',
56
+ background: '#f0f0f0',
57
+ padding: '10px',
58
+ borderRadius: '5px',
59
+ fontSize: '12px',
60
+ fontFamily: 'monospace',
61
+ maxWidth: '300px',
62
+ zIndex: 9999,
63
+ border: '1px solid #ccc'
64
+ }, children: [jsxRuntime.jsx("h4", { style: { margin: '0 0 5px 0' }, children: "Fingerprint Debug" }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "FP ID:" }), " ", fingerprintId || 'None'] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "Loading:" }), " ", isLoading ? 'Yes' : 'No'] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "Initialized:" }), " ", isInitialized ? 'Yes' : 'No'] }), error && jsxRuntime.jsxs("div", { style: { color: 'red' }, children: [jsxRuntime.jsx("strong", { children: "Error:" }), " ", error] }), anonymousUser && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "User ID:" }), " ", anonymousUser.userId.slice(0, 8), "..."] })), credits && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "Credits:" }), " ", credits.balanceFree, "F + ", credits.balancePaid, "P = ", credits.totalBalance] }))] }));
65
+ }
66
+
67
+ exports.FingerprintDebugInfo = FingerprintDebugInfo;
68
+ exports.FingerprintProvider = FingerprintProvider;
69
+ exports.useFingerprintContext = useFingerprintContext;
70
+ exports.useFingerprintContextSafe = useFingerprintContextSafe;
71
+ exports.withFingerprint = withFingerprint;
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { createContext, useContext } from 'react';
4
+ import { useFingerprint } from '../hooks/useFingerprint.mjs';
5
+
6
+ const FingerprintContext = createContext(undefined);
7
+ /**
8
+ * Fingerprint Provider Component
9
+ * 为应用提供fingerprint和匿名用户管理功能
10
+ */
11
+ function FingerprintProvider({ children, config }) {
12
+ const fingerprintData = useFingerprint(config);
13
+ return (jsx(FingerprintContext.Provider, { value: fingerprintData, children: children }));
14
+ }
15
+ /**
16
+ * Hook to use fingerprint context
17
+ */
18
+ function useFingerprintContext() {
19
+ const context = useContext(FingerprintContext);
20
+ if (context === undefined) {
21
+ throw new Error('useFingerprintContext must be used within a FingerprintProvider');
22
+ }
23
+ return context;
24
+ }
25
+ /**
26
+ * Safe hook to use fingerprint context - returns null if no provider
27
+ * 安全版本的fingerprint context hook - 如果没有Provider则返回null
28
+ */
29
+ function useFingerprintContextSafe() {
30
+ const context = useContext(FingerprintContext);
31
+ return context || null;
32
+ }
33
+ /**
34
+ * HOC for components that need fingerprint functionality
35
+ * Note: This HOC now requires config to be passed externally
36
+ */
37
+ function withFingerprint(Component, config) {
38
+ return function FingerprintWrappedComponent(props) {
39
+ return (jsx(FingerprintProvider, { config: config, children: jsx(Component, Object.assign({}, props)) }));
40
+ };
41
+ }
42
+ /**
43
+ * 组件:显示用户状态和积分信息(用于调试)
44
+ */
45
+ function FingerprintDebugInfo() {
46
+ const { fingerprintId, anonymousUser, credits, isLoading, isInitialized, error } = useFingerprintContext();
47
+ if (!process.env.NODE_ENV || process.env.NODE_ENV === 'production') {
48
+ return null;
49
+ }
50
+ return (jsxs("div", { style: {
51
+ position: 'fixed',
52
+ bottom: '10px',
53
+ right: '10px',
54
+ background: '#f0f0f0',
55
+ padding: '10px',
56
+ borderRadius: '5px',
57
+ fontSize: '12px',
58
+ fontFamily: 'monospace',
59
+ maxWidth: '300px',
60
+ zIndex: 9999,
61
+ border: '1px solid #ccc'
62
+ }, children: [jsx("h4", { style: { margin: '0 0 5px 0' }, children: "Fingerprint Debug" }), jsxs("div", { children: [jsx("strong", { children: "FP ID:" }), " ", fingerprintId || 'None'] }), jsxs("div", { children: [jsx("strong", { children: "Loading:" }), " ", isLoading ? 'Yes' : 'No'] }), jsxs("div", { children: [jsx("strong", { children: "Initialized:" }), " ", isInitialized ? 'Yes' : 'No'] }), error && jsxs("div", { style: { color: 'red' }, children: [jsx("strong", { children: "Error:" }), " ", error] }), anonymousUser && (jsxs("div", { children: [jsx("strong", { children: "User ID:" }), " ", anonymousUser.userId.slice(0, 8), "..."] })), credits && (jsxs("div", { children: [jsx("strong", { children: "Credits:" }), " ", credits.balanceFree, "F + ", credits.balancePaid, "P = ", credits.totalBalance] }))] }));
63
+ }
64
+
65
+ export { FingerprintDebugInfo, FingerprintProvider, useFingerprintContext, useFingerprintContextSafe, withFingerprint };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Fingerprint Client Utilities
3
+ * 客户端专用的指纹生成和管理逻辑
4
+ * 只能在浏览器环境中使用
5
+ */
6
+ /**
7
+ * 生成基于真实浏览器特征的fingerprint ID
8
+ * 使用FingerprintJS收集浏览器特征并生成唯一标识
9
+ * 只能在客户端使用
10
+ */
11
+ export declare function generateFingerprintId(): Promise<string>;
12
+ /**
13
+ * 获取当前的fingerprint ID
14
+ * 只能在客户端使用
15
+ */
16
+ export declare function getFingerprintId(): string | null;
17
+ /**
18
+ * 设置fingerprint ID到存储
19
+ * 只能在客户端使用
20
+ */
21
+ export declare function setFingerprintId(fingerprintId: string): void;
22
+ /**
23
+ * 清除fingerprint ID
24
+ * 只能在客户端使用
25
+ */
26
+ export declare function clearFingerprintId(): void;
27
+ /**
28
+ * 获取或生成fingerprint ID
29
+ * 如果不存在则自动生成新的
30
+ * 只能在客户端使用
31
+ */
32
+ export declare function getOrGenerateFingerprintId(): Promise<string>;
33
+ /**
34
+ * 创建包含fingerprint ID的fetch headers
35
+ * 只能在客户端使用
36
+ */
37
+ export declare function createFingerprintHeaders(): Promise<Record<string, string>>;
38
+ /**
39
+ * Hook for generating fingerprint headers
40
+ * 只能在客户端使用
41
+ */
42
+ export declare function useFingerprintHeaders(): () => Promise<Record<string, string>>;
43
+ /**
44
+ * Create a fetch wrapper that automatically includes fingerprint headers
45
+ * 只能在客户端使用
46
+ */
47
+ export declare function createFingerprintFetch(): (url: string | URL | Request, init?: RequestInit) => Promise<Response>;
@@ -0,0 +1,177 @@
1
+ 'use strict';
2
+
3
+ var tslib_es6 = require('../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.2/node_modules/tslib/tslib.es6.js');
4
+ var fingerprintShared = require('./fingerprint-shared.js');
5
+ var fp_esm = require('../../node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.js');
6
+
7
+ /**
8
+ * Fingerprint Client Utilities
9
+ * 客户端专用的指纹生成和管理逻辑
10
+ * 只能在浏览器环境中使用
11
+ */
12
+ /**
13
+ * 生成基于真实浏览器特征的fingerprint ID
14
+ * 使用FingerprintJS收集浏览器特征并生成唯一标识
15
+ * 只能在客户端使用
16
+ */
17
+ function generateFingerprintId() {
18
+ return tslib_es6.__awaiter(this, void 0, void 0, function* () {
19
+ if (typeof window === 'undefined') {
20
+ throw new Error('generateFingerprintId can only be used in browser environment');
21
+ }
22
+ // 首先检查现有ID
23
+ const existingId = getFingerprintId();
24
+ if (existingId && fingerprintShared.isValidFingerprintId(existingId)) {
25
+ return existingId;
26
+ }
27
+ // 检查cookie
28
+ const cookieId = getCookieValue(fingerprintShared.FINGERPRINT_COOKIE_NAME);
29
+ if (cookieId && fingerprintShared.isValidFingerprintId(cookieId)) {
30
+ // 同步到localStorage
31
+ localStorage.setItem(fingerprintShared.FINGERPRINT_STORAGE_KEY, cookieId);
32
+ return cookieId;
33
+ }
34
+ try {
35
+ // 使用FingerprintJS生成基于浏览器特征的指纹
36
+ const fp = yield fp_esm.default.load();
37
+ const result = yield fp.get();
38
+ const fingerprintId = `fp_${result.visitorId}`;
39
+ // 存储到localStorage和cookie
40
+ localStorage.setItem(fingerprintShared.FINGERPRINT_STORAGE_KEY, fingerprintId);
41
+ setCookie(fingerprintShared.FINGERPRINT_COOKIE_NAME, fingerprintId, 365); // 365天过期
42
+ return fingerprintId;
43
+ }
44
+ catch (error) {
45
+ console.warn('Failed to generate fingerprint with FingerprintJS:', error);
46
+ // 降级方案:生成时间戳+随机数
47
+ const fallbackId = `fp_fallback_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
48
+ localStorage.setItem(fingerprintShared.FINGERPRINT_STORAGE_KEY, fallbackId);
49
+ setCookie(fingerprintShared.FINGERPRINT_COOKIE_NAME, fallbackId, 365);
50
+ return fallbackId;
51
+ }
52
+ });
53
+ }
54
+ /**
55
+ * 获取当前的fingerprint ID
56
+ * 只能在客户端使用
57
+ */
58
+ function getFingerprintId() {
59
+ if (typeof window === 'undefined') {
60
+ return null;
61
+ }
62
+ // 首先检查localStorage
63
+ const localStorageId = localStorage.getItem(fingerprintShared.FINGERPRINT_STORAGE_KEY);
64
+ if (localStorageId) {
65
+ return localStorageId;
66
+ }
67
+ // 检查cookie
68
+ const cookieId = getCookieValue(fingerprintShared.FINGERPRINT_COOKIE_NAME);
69
+ if (cookieId) {
70
+ // 同步到localStorage
71
+ localStorage.setItem(fingerprintShared.FINGERPRINT_STORAGE_KEY, cookieId);
72
+ return cookieId;
73
+ }
74
+ return null;
75
+ }
76
+ /**
77
+ * 设置fingerprint ID到存储
78
+ * 只能在客户端使用
79
+ */
80
+ function setFingerprintId(fingerprintId) {
81
+ if (typeof window === 'undefined') {
82
+ throw new Error('setFingerprintId can only be used in browser environment');
83
+ }
84
+ localStorage.setItem(fingerprintShared.FINGERPRINT_STORAGE_KEY, fingerprintId);
85
+ setCookie(fingerprintShared.FINGERPRINT_COOKIE_NAME, fingerprintId, 365);
86
+ }
87
+ /**
88
+ * 清除fingerprint ID
89
+ * 只能在客户端使用
90
+ */
91
+ function clearFingerprintId() {
92
+ if (typeof window === 'undefined') {
93
+ throw new Error('clearFingerprintId can only be used in browser environment');
94
+ }
95
+ localStorage.removeItem(fingerprintShared.FINGERPRINT_STORAGE_KEY);
96
+ deleteCookie(fingerprintShared.FINGERPRINT_COOKIE_NAME);
97
+ }
98
+ /**
99
+ * 获取或生成fingerprint ID
100
+ * 如果不存在则自动生成新的
101
+ * 只能在客户端使用
102
+ */
103
+ function getOrGenerateFingerprintId() {
104
+ return tslib_es6.__awaiter(this, void 0, void 0, function* () {
105
+ const existingId = getFingerprintId();
106
+ if (existingId) {
107
+ return existingId;
108
+ }
109
+ return yield generateFingerprintId();
110
+ });
111
+ }
112
+ /**
113
+ * 创建包含fingerprint ID的fetch headers
114
+ * 只能在客户端使用
115
+ */
116
+ function createFingerprintHeaders() {
117
+ return tslib_es6.__awaiter(this, void 0, void 0, function* () {
118
+ const fingerprintId = yield getOrGenerateFingerprintId();
119
+ return {
120
+ FINGERPRINT_HEADER_NAME: fingerprintId,
121
+ };
122
+ });
123
+ }
124
+ /**
125
+ * Hook for generating fingerprint headers
126
+ * 只能在客户端使用
127
+ */
128
+ function useFingerprintHeaders() {
129
+ return createFingerprintHeaders;
130
+ }
131
+ /**
132
+ * Create a fetch wrapper that automatically includes fingerprint headers
133
+ * 只能在客户端使用
134
+ */
135
+ function createFingerprintFetch() {
136
+ return (url, init) => tslib_es6.__awaiter(this, void 0, void 0, function* () {
137
+ const fingerprintHeaders = yield createFingerprintHeaders();
138
+ const headers = Object.assign(Object.assign({}, fingerprintHeaders), ((init === null || init === void 0 ? void 0 : init.headers) || {}));
139
+ return fetch(url, Object.assign(Object.assign({}, init), { headers }));
140
+ });
141
+ }
142
+ // Cookie 辅助函数 (私有)
143
+ function getCookieValue(name) {
144
+ var _a;
145
+ if (typeof document === 'undefined') {
146
+ return null;
147
+ }
148
+ const value = `; ${document.cookie}`;
149
+ const parts = value.split(`; ${name}=`);
150
+ if (parts.length === 2) {
151
+ return ((_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.split(';').shift()) || null;
152
+ }
153
+ return null;
154
+ }
155
+ function setCookie(name, value, days) {
156
+ if (typeof document === 'undefined') {
157
+ return;
158
+ }
159
+ const expires = new Date();
160
+ expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
161
+ document.cookie = `${name}=${value};expires=${expires.toUTCString()};path=/;SameSite=Lax`;
162
+ }
163
+ function deleteCookie(name) {
164
+ if (typeof document === 'undefined') {
165
+ return;
166
+ }
167
+ document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
168
+ }
169
+
170
+ exports.clearFingerprintId = clearFingerprintId;
171
+ exports.createFingerprintFetch = createFingerprintFetch;
172
+ exports.createFingerprintHeaders = createFingerprintHeaders;
173
+ exports.generateFingerprintId = generateFingerprintId;
174
+ exports.getFingerprintId = getFingerprintId;
175
+ exports.getOrGenerateFingerprintId = getOrGenerateFingerprintId;
176
+ exports.setFingerprintId = setFingerprintId;
177
+ exports.useFingerprintHeaders = useFingerprintHeaders;