@windrun-huaiin/third-ui 7.1.2 → 7.2.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/clerk/clerk-page-generator-client.d.ts +10 -0
- package/dist/clerk/clerk-page-generator-client.js +28 -0
- package/dist/clerk/clerk-page-generator-client.mjs +25 -0
- package/dist/clerk/clerk-page-generator.js +1 -0
- package/dist/clerk/clerk-page-generator.mjs +1 -0
- package/dist/clerk/client-page-generator.d.ts +10 -0
- package/dist/clerk/client-page-generator.js +28 -0
- package/dist/clerk/client-page-generator.mjs +25 -0
- package/dist/clerk/context/FingerprintProvider.d.ts +25 -0
- package/dist/clerk/context/FingerprintProvider.js +71 -0
- package/dist/clerk/context/FingerprintProvider.mjs +65 -0
- package/dist/clerk/fingerprint/fingerprint-client.d.ts +47 -0
- package/dist/clerk/fingerprint/fingerprint-client.js +183 -0
- package/dist/clerk/fingerprint/fingerprint-client.mjs +174 -0
- package/dist/clerk/fingerprint/fingerprint-provider.d.ts +25 -0
- package/dist/clerk/fingerprint/fingerprint-provider.js +71 -0
- package/dist/clerk/fingerprint/fingerprint-provider.mjs +65 -0
- package/dist/clerk/fingerprint/fingerprint-server.d.ts +22 -0
- package/dist/clerk/fingerprint/fingerprint-server.js +75 -0
- package/dist/clerk/fingerprint/fingerprint-server.mjs +71 -0
- package/dist/clerk/fingerprint/fingerprint-shared.d.ts +17 -0
- package/dist/clerk/fingerprint/fingerprint-shared.js +35 -0
- package/dist/clerk/fingerprint/fingerprint-shared.mjs +29 -0
- package/dist/clerk/fingerprint/fingerprint.d.ts +55 -0
- package/dist/clerk/fingerprint/fingerprint.js +17 -0
- package/dist/clerk/fingerprint/fingerprint.mjs +15 -0
- package/dist/clerk/fingerprint/index.d.ts +5 -0
- package/dist/clerk/fingerprint/index.js +29 -0
- package/dist/clerk/fingerprint/index.mjs +5 -0
- package/dist/clerk/fingerprint/server.d.ts +3 -0
- package/dist/clerk/fingerprint/server.js +15 -0
- package/dist/clerk/fingerprint/server.mjs +2 -0
- package/dist/clerk/fingerprint/types.d.ts +42 -0
- package/dist/clerk/fingerprint/use-fingerprint.d.ts +6 -0
- package/dist/clerk/fingerprint/use-fingerprint.js +182 -0
- package/dist/clerk/fingerprint/use-fingerprint.mjs +180 -0
- package/dist/clerk/fingerprint.d.ts +55 -0
- package/dist/clerk/fingerprint.js +237 -0
- package/dist/clerk/fingerprint.mjs +225 -0
- package/dist/clerk/hooks/useFingerprint.d.ts +6 -0
- package/dist/clerk/hooks/useFingerprint.js +182 -0
- package/dist/clerk/hooks/useFingerprint.mjs +180 -0
- package/dist/clerk/index.d.ts +3 -0
- package/dist/clerk/index.js +7 -0
- package/dist/clerk/index.mjs +3 -0
- package/dist/clerk/signin-with-fingerprint-client.d.ts +7 -0
- package/dist/clerk/signin-with-fingerprint-client.js +52 -0
- package/dist/clerk/signin-with-fingerprint-client.mjs +47 -0
- package/dist/clerk/signup-with-fingerprint-client.d.ts +7 -0
- package/dist/clerk/signup-with-fingerprint-client.js +52 -0
- package/dist/clerk/signup-with-fingerprint-client.mjs +47 -0
- package/dist/clerk/types.d.ts +42 -0
- package/dist/fuma/mdx/toc-base.js +1 -1
- package/dist/fuma/mdx/toc-base.mjs +1 -1
- package/dist/node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.js +3245 -0
- package/dist/node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.mjs +3218 -0
- 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
- 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
- package/dist/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/package.json +12 -1
- package/src/clerk/clerk-page-generator-client.tsx +37 -0
- package/src/clerk/clerk-page-generator.tsx +5 -1
- package/src/clerk/fingerprint/fingerprint-client.ts +202 -0
- package/src/clerk/fingerprint/fingerprint-provider.tsx +114 -0
- package/src/clerk/fingerprint/fingerprint-server.ts +88 -0
- package/src/clerk/fingerprint/fingerprint-shared.ts +29 -0
- package/src/clerk/fingerprint/index.ts +15 -0
- package/src/clerk/fingerprint/server.ts +9 -0
- package/src/clerk/fingerprint/types.ts +48 -0
- package/src/clerk/fingerprint/use-fingerprint.ts +208 -0
- package/src/clerk/index.ts +9 -2
- package/src/clerk/server.ts +1 -0
- package/src/clerk/signin-with-fingerprint-client.tsx +57 -0
- 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,183 @@
|
|
|
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
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fingerprint Client Utilities
|
|
8
|
+
* 客户端专用的指纹生成和管理逻辑
|
|
9
|
+
* 只能在浏览器环境中使用
|
|
10
|
+
*/
|
|
11
|
+
// Dynamic import to avoid SSR issues
|
|
12
|
+
let FingerprintJS = null;
|
|
13
|
+
/**
|
|
14
|
+
* 生成基于真实浏览器特征的fingerprint ID
|
|
15
|
+
* 使用FingerprintJS收集浏览器特征并生成唯一标识
|
|
16
|
+
* 只能在客户端使用
|
|
17
|
+
*/
|
|
18
|
+
function generateFingerprintId() {
|
|
19
|
+
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (typeof window === 'undefined') {
|
|
21
|
+
throw new Error('generateFingerprintId can only be used in browser environment');
|
|
22
|
+
}
|
|
23
|
+
// 首先检查现有ID
|
|
24
|
+
const existingId = getFingerprintId();
|
|
25
|
+
if (existingId && fingerprintShared.isValidFingerprintId(existingId)) {
|
|
26
|
+
return existingId;
|
|
27
|
+
}
|
|
28
|
+
// 检查cookie
|
|
29
|
+
const cookieId = getCookieValue(fingerprintShared.FINGERPRINT_COOKIE_NAME);
|
|
30
|
+
if (cookieId && fingerprintShared.isValidFingerprintId(cookieId)) {
|
|
31
|
+
// 同步到localStorage
|
|
32
|
+
localStorage.setItem(fingerprintShared.FINGERPRINT_STORAGE_KEY, cookieId);
|
|
33
|
+
return cookieId;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
// 等待FingerprintJS加载完成
|
|
37
|
+
if (!FingerprintJS) {
|
|
38
|
+
const module = yield Promise.resolve().then(function () { return require('../../node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.js'); });
|
|
39
|
+
FingerprintJS = module.default;
|
|
40
|
+
}
|
|
41
|
+
// 使用FingerprintJS生成基于浏览器特征的指纹
|
|
42
|
+
const fp = yield FingerprintJS.load();
|
|
43
|
+
const result = yield fp.get();
|
|
44
|
+
const fingerprintId = `fp_${result.visitorId}`;
|
|
45
|
+
// 存储到localStorage和cookie
|
|
46
|
+
localStorage.setItem(fingerprintShared.FINGERPRINT_STORAGE_KEY, fingerprintId);
|
|
47
|
+
setCookie(fingerprintShared.FINGERPRINT_COOKIE_NAME, fingerprintId, 365); // 365天过期
|
|
48
|
+
return fingerprintId;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.warn('Failed to generate fingerprint with FingerprintJS:', error);
|
|
52
|
+
// 降级方案:生成时间戳+随机数
|
|
53
|
+
const fallbackId = `fp_fallback_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
|
54
|
+
localStorage.setItem(fingerprintShared.FINGERPRINT_STORAGE_KEY, fallbackId);
|
|
55
|
+
setCookie(fingerprintShared.FINGERPRINT_COOKIE_NAME, fallbackId, 365);
|
|
56
|
+
return fallbackId;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 获取当前的fingerprint ID
|
|
62
|
+
* 只能在客户端使用
|
|
63
|
+
*/
|
|
64
|
+
function getFingerprintId() {
|
|
65
|
+
if (typeof window === 'undefined') {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
// 首先检查localStorage
|
|
69
|
+
const localStorageId = localStorage.getItem(fingerprintShared.FINGERPRINT_STORAGE_KEY);
|
|
70
|
+
if (localStorageId) {
|
|
71
|
+
return localStorageId;
|
|
72
|
+
}
|
|
73
|
+
// 检查cookie
|
|
74
|
+
const cookieId = getCookieValue(fingerprintShared.FINGERPRINT_COOKIE_NAME);
|
|
75
|
+
if (cookieId) {
|
|
76
|
+
// 同步到localStorage
|
|
77
|
+
localStorage.setItem(fingerprintShared.FINGERPRINT_STORAGE_KEY, cookieId);
|
|
78
|
+
return cookieId;
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 设置fingerprint ID到存储
|
|
84
|
+
* 只能在客户端使用
|
|
85
|
+
*/
|
|
86
|
+
function setFingerprintId(fingerprintId) {
|
|
87
|
+
if (typeof window === 'undefined') {
|
|
88
|
+
throw new Error('setFingerprintId can only be used in browser environment');
|
|
89
|
+
}
|
|
90
|
+
localStorage.setItem(fingerprintShared.FINGERPRINT_STORAGE_KEY, fingerprintId);
|
|
91
|
+
setCookie(fingerprintShared.FINGERPRINT_COOKIE_NAME, fingerprintId, 365);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 清除fingerprint ID
|
|
95
|
+
* 只能在客户端使用
|
|
96
|
+
*/
|
|
97
|
+
function clearFingerprintId() {
|
|
98
|
+
if (typeof window === 'undefined') {
|
|
99
|
+
throw new Error('clearFingerprintId can only be used in browser environment');
|
|
100
|
+
}
|
|
101
|
+
localStorage.removeItem(fingerprintShared.FINGERPRINT_STORAGE_KEY);
|
|
102
|
+
deleteCookie(fingerprintShared.FINGERPRINT_COOKIE_NAME);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 获取或生成fingerprint ID
|
|
106
|
+
* 如果不存在则自动生成新的
|
|
107
|
+
* 只能在客户端使用
|
|
108
|
+
*/
|
|
109
|
+
function getOrGenerateFingerprintId() {
|
|
110
|
+
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const existingId = getFingerprintId();
|
|
112
|
+
if (existingId) {
|
|
113
|
+
return existingId;
|
|
114
|
+
}
|
|
115
|
+
return yield generateFingerprintId();
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 创建包含fingerprint ID的fetch headers
|
|
120
|
+
* 只能在客户端使用
|
|
121
|
+
*/
|
|
122
|
+
function createFingerprintHeaders() {
|
|
123
|
+
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const fingerprintId = yield getOrGenerateFingerprintId();
|
|
125
|
+
return {
|
|
126
|
+
'x-fingerprint-id': fingerprintId,
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Hook for generating fingerprint headers
|
|
132
|
+
* 只能在客户端使用
|
|
133
|
+
*/
|
|
134
|
+
function useFingerprintHeaders() {
|
|
135
|
+
return createFingerprintHeaders;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Create a fetch wrapper that automatically includes fingerprint headers
|
|
139
|
+
* 只能在客户端使用
|
|
140
|
+
*/
|
|
141
|
+
function createFingerprintFetch() {
|
|
142
|
+
return (url, init) => tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
const fingerprintHeaders = yield createFingerprintHeaders();
|
|
144
|
+
const headers = Object.assign(Object.assign({}, fingerprintHeaders), ((init === null || init === void 0 ? void 0 : init.headers) || {}));
|
|
145
|
+
return fetch(url, Object.assign(Object.assign({}, init), { headers }));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// Cookie 辅助函数 (私有)
|
|
149
|
+
function getCookieValue(name) {
|
|
150
|
+
var _a;
|
|
151
|
+
if (typeof document === 'undefined') {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
const value = `; ${document.cookie}`;
|
|
155
|
+
const parts = value.split(`; ${name}=`);
|
|
156
|
+
if (parts.length === 2) {
|
|
157
|
+
return ((_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.split(';').shift()) || null;
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
function setCookie(name, value, days) {
|
|
162
|
+
if (typeof document === 'undefined') {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const expires = new Date();
|
|
166
|
+
expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
|
|
167
|
+
document.cookie = `${name}=${value};expires=${expires.toUTCString()};path=/;SameSite=Lax`;
|
|
168
|
+
}
|
|
169
|
+
function deleteCookie(name) {
|
|
170
|
+
if (typeof document === 'undefined') {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
exports.clearFingerprintId = clearFingerprintId;
|
|
177
|
+
exports.createFingerprintFetch = createFingerprintFetch;
|
|
178
|
+
exports.createFingerprintHeaders = createFingerprintHeaders;
|
|
179
|
+
exports.generateFingerprintId = generateFingerprintId;
|
|
180
|
+
exports.getFingerprintId = getFingerprintId;
|
|
181
|
+
exports.getOrGenerateFingerprintId = getOrGenerateFingerprintId;
|
|
182
|
+
exports.setFingerprintId = setFingerprintId;
|
|
183
|
+
exports.useFingerprintHeaders = useFingerprintHeaders;
|