@tracetail/react 2.3.3 → 2.3.5
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/README.md +14 -105
- package/dist/index.d.ts +4 -75
- package/dist/index.esm.js +3 -131
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -132
- package/dist/index.js.map +1 -1
- package/package.json +15 -5
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> React hooks for TraceTail enterprise browser fingerprinting with **over 99.5% accuracy**. Built for React 18 with full TypeScript support.
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@tracetail/react)
|
|
6
6
|
[](https://www.npmjs.com/package/@tracetail/react)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
[](https://reactjs.org/)
|
|
@@ -76,49 +76,6 @@ function MyComponent() {
|
|
|
76
76
|
}
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
### `useEnhancedTraceTail`
|
|
80
|
-
|
|
81
|
-
Enhanced fingerprinting with fraud detection capabilities.
|
|
82
|
-
|
|
83
|
-
```tsx
|
|
84
|
-
import { useEnhancedTraceTail } from '@tracetail/react';
|
|
85
|
-
|
|
86
|
-
function SecurityComponent() {
|
|
87
|
-
const { fingerprint, loading, error } = useEnhancedTraceTail({
|
|
88
|
-
apiKey: 'your-api-key',
|
|
89
|
-
immediate: true
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
if (loading) return <div>Analyzing security...</div>;
|
|
93
|
-
if (error) return <div>Error: {error.message}</div>;
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<div>
|
|
97
|
-
<div className={`alert ${fingerprint?.threatLevel}`}>
|
|
98
|
-
<h3>Security Analysis</h3>
|
|
99
|
-
<p>Risk Level: {fingerprint?.threatLevel}</p>
|
|
100
|
-
<p>Risk Score: {(fingerprint?.riskScore * 100).toFixed(1)}%</p>
|
|
101
|
-
<p>Bot Probability: {(fingerprint?.botProbability * 100).toFixed(1)}%</p>
|
|
102
|
-
|
|
103
|
-
{fingerprint?.fraudSignals.length > 0 && (
|
|
104
|
-
<div>
|
|
105
|
-
<h4>Fraud Signals:</h4>
|
|
106
|
-
<ul>
|
|
107
|
-
{fingerprint.fraudSignals.map((signal, i) => (
|
|
108
|
-
<li key={i}>{signal}</li>
|
|
109
|
-
))}
|
|
110
|
-
</ul>
|
|
111
|
-
</div>
|
|
112
|
-
)}
|
|
113
|
-
|
|
114
|
-
{fingerprint?.geolocation && (
|
|
115
|
-
<p>Location: {fingerprint.geolocation.city}, {fingerprint.geolocation.country}</p>
|
|
116
|
-
)}
|
|
117
|
-
</div>
|
|
118
|
-
</div>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
79
|
|
|
123
80
|
### `useVisitorId`
|
|
124
81
|
|
|
@@ -155,51 +112,6 @@ function UserTrackingComponent() {
|
|
|
155
112
|
}
|
|
156
113
|
```
|
|
157
114
|
|
|
158
|
-
### `useFraudDetection`
|
|
159
|
-
|
|
160
|
-
Specialized hook for fraud detection with configurable thresholds.
|
|
161
|
-
|
|
162
|
-
```tsx
|
|
163
|
-
import { useFraudDetection } from '@tracetail/react';
|
|
164
|
-
|
|
165
|
-
function FraudCheck() {
|
|
166
|
-
const {
|
|
167
|
-
isFraudulent,
|
|
168
|
-
riskLevel,
|
|
169
|
-
riskScore,
|
|
170
|
-
botProbability,
|
|
171
|
-
fraudSignals,
|
|
172
|
-
loading,
|
|
173
|
-
recheck
|
|
174
|
-
} = useFraudDetection({
|
|
175
|
-
apiKey: 'your-api-key',
|
|
176
|
-
riskThreshold: 0.7, // Fraud threshold (0-1)
|
|
177
|
-
botThreshold: 0.5 // Bot detection threshold (0-1)
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
if (loading) return <div>🔍 Checking for fraud...</div>;
|
|
181
|
-
|
|
182
|
-
if (isFraudulent) {
|
|
183
|
-
return (
|
|
184
|
-
<div className="fraud-alert">
|
|
185
|
-
<h3>⚠️ High Risk Detected</h3>
|
|
186
|
-
<p>Additional verification required</p>
|
|
187
|
-
<p>Risk Score: {(riskScore * 100).toFixed(1)}%</p>
|
|
188
|
-
<p>Bot Probability: {(botProbability * 100).toFixed(1)}%</p>
|
|
189
|
-
<button onClick={recheck}>Recheck</button>
|
|
190
|
-
</div>
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return (
|
|
195
|
-
<div className="fraud-clear">
|
|
196
|
-
<h3>✅ Security Check Passed</h3>
|
|
197
|
-
<p>Risk Level: {riskLevel}</p>
|
|
198
|
-
<p>Score: {(riskScore * 100).toFixed(1)}%</p>
|
|
199
|
-
</div>
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
```
|
|
203
115
|
|
|
204
116
|
## 🌟 Advanced Usage
|
|
205
117
|
|
|
@@ -237,37 +149,34 @@ function SSRSafeComponent() {
|
|
|
237
149
|
### Custom Hook Pattern
|
|
238
150
|
|
|
239
151
|
```tsx
|
|
240
|
-
import {
|
|
152
|
+
import { useTraceTail } from '@tracetail/react';
|
|
241
153
|
|
|
242
|
-
function
|
|
243
|
-
const { fingerprint, loading, error } =
|
|
154
|
+
function useVisitorTracking() {
|
|
155
|
+
const { fingerprint, loading, error } = useTraceTail({
|
|
244
156
|
apiKey: process.env.REACT_APP_TRACETAIL_KEY!,
|
|
245
157
|
immediate: true
|
|
246
158
|
});
|
|
247
159
|
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
160
|
+
const trackingData = fingerprint ? {
|
|
161
|
+
visitorId: fingerprint.visitorId,
|
|
162
|
+
confidence: fingerprint.confidence,
|
|
163
|
+
isHighConfidence: fingerprint.confidence > 0.95,
|
|
164
|
+
processingTime: fingerprint.processingTime
|
|
253
165
|
} : null;
|
|
254
166
|
|
|
255
|
-
return {
|
|
167
|
+
return { trackingData, loading, error };
|
|
256
168
|
}
|
|
257
169
|
|
|
258
170
|
// Usage
|
|
259
171
|
function App() {
|
|
260
|
-
const {
|
|
172
|
+
const { trackingData, loading } = useVisitorTracking();
|
|
261
173
|
|
|
262
|
-
if (loading) return <div>
|
|
174
|
+
if (loading) return <div>Identifying visitor...</div>;
|
|
263
175
|
|
|
264
176
|
return (
|
|
265
177
|
<div>
|
|
266
|
-
{
|
|
267
|
-
|
|
268
|
-
) : (
|
|
269
|
-
<MainContent />
|
|
270
|
-
)}
|
|
178
|
+
<p>Visitor: {trackingData?.visitorId}</p>
|
|
179
|
+
<p>Confidence: {(trackingData?.confidence * 100).toFixed(1)}%</p>
|
|
271
180
|
</div>
|
|
272
181
|
);
|
|
273
182
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @tracetail/react - React Hooks for Enterprise Browser Fingerprinting
|
|
3
|
-
* Version: 2.3.
|
|
3
|
+
* Version: 2.3.4
|
|
4
4
|
*
|
|
5
|
-
* Over 99.5% accuracy browser fingerprinting with React hooks.
|
|
5
|
+
* Over 99.5% accuracy browser fingerprinting with React hooks and server-side processing.
|
|
6
6
|
* Perfect for fraud detection, user analytics, and security applications.
|
|
7
7
|
*/
|
|
8
8
|
import type { FC, ReactNode } from 'react';
|
|
9
|
-
import { FingerprintOptions, FingerprintResult
|
|
9
|
+
import { FingerprintOptions, FingerprintResult } from '@tracetail/js';
|
|
10
10
|
export interface UseTraceTailOptions extends FingerprintOptions {
|
|
11
11
|
immediate?: boolean;
|
|
12
12
|
suspense?: boolean;
|
|
@@ -18,13 +18,6 @@ export interface UseTraceTailReturn {
|
|
|
18
18
|
generate: () => Promise<FingerprintResult>;
|
|
19
19
|
regenerate: () => Promise<FingerprintResult>;
|
|
20
20
|
}
|
|
21
|
-
export interface UseEnhancedTraceTailReturn {
|
|
22
|
-
fingerprint: EnhancedFingerprintResult | null;
|
|
23
|
-
loading: boolean;
|
|
24
|
-
error: Error | null;
|
|
25
|
-
generate: () => Promise<EnhancedFingerprintResult>;
|
|
26
|
-
regenerate: () => Promise<EnhancedFingerprintResult>;
|
|
27
|
-
}
|
|
28
21
|
/**
|
|
29
22
|
* React hook for basic browser fingerprinting
|
|
30
23
|
*
|
|
@@ -46,33 +39,6 @@ export interface UseEnhancedTraceTailReturn {
|
|
|
46
39
|
* ```
|
|
47
40
|
*/
|
|
48
41
|
export declare function useTraceTail(options: UseTraceTailOptions): UseTraceTailReturn;
|
|
49
|
-
/**
|
|
50
|
-
* React hook for enhanced browser fingerprinting with fraud detection
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* import { useEnhancedTraceTail } from '@tracetail/react';
|
|
55
|
-
*
|
|
56
|
-
* function SecurityComponent() {
|
|
57
|
-
* const { fingerprint, loading, error } = useEnhancedTraceTail({
|
|
58
|
-
* apiKey: 'your-api-key',
|
|
59
|
-
* immediate: true
|
|
60
|
-
* });
|
|
61
|
-
*
|
|
62
|
-
* if (loading) return <div>Analyzing security...</div>;
|
|
63
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
64
|
-
*
|
|
65
|
-
* const riskLevel = fingerprint?.threatLevel || 'unknown';
|
|
66
|
-
* return (
|
|
67
|
-
* <div>
|
|
68
|
-
* <p>Risk Level: {riskLevel}</p>
|
|
69
|
-
* <p>Bot Probability: {(fingerprint?.botProbability * 100).toFixed(1)}%</p>
|
|
70
|
-
* </div>
|
|
71
|
-
* );
|
|
72
|
-
* }
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
export declare function useEnhancedTraceTail(options: UseTraceTailOptions): UseEnhancedTraceTailReturn;
|
|
76
42
|
/**
|
|
77
43
|
* React hook for visitor identification with persistent storage
|
|
78
44
|
*
|
|
@@ -104,42 +70,7 @@ export declare function useVisitorId(options: UseTraceTailOptions & {
|
|
|
104
70
|
error: Error | null;
|
|
105
71
|
refresh: () => Promise<void>;
|
|
106
72
|
};
|
|
107
|
-
|
|
108
|
-
* React hook for fraud detection with configurable thresholds
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```typescript
|
|
112
|
-
* import { useFraudDetection } from '@tracetail/react';
|
|
113
|
-
*
|
|
114
|
-
* function SecurityCheck() {
|
|
115
|
-
* const { isFraudulent, riskLevel, loading } = useFraudDetection({
|
|
116
|
-
* apiKey: 'your-api-key',
|
|
117
|
-
* riskThreshold: 0.7,
|
|
118
|
-
* botThreshold: 0.5
|
|
119
|
-
* });
|
|
120
|
-
*
|
|
121
|
-
* if (isFraudulent) {
|
|
122
|
-
* return <div>⚠️ High risk detected - additional verification required</div>;
|
|
123
|
-
* }
|
|
124
|
-
*
|
|
125
|
-
* return <div>✅ Security check passed (Risk: {riskLevel})</div>;
|
|
126
|
-
* }
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
export declare function useFraudDetection(options: UseTraceTailOptions & {
|
|
130
|
-
riskThreshold?: number;
|
|
131
|
-
botThreshold?: number;
|
|
132
|
-
}): {
|
|
133
|
-
isFraudulent: boolean;
|
|
134
|
-
riskLevel: 'low' | 'medium' | 'high' | null;
|
|
135
|
-
riskScore: number;
|
|
136
|
-
botProbability: number;
|
|
137
|
-
fraudSignals: string[];
|
|
138
|
-
loading: boolean;
|
|
139
|
-
error: Error | null;
|
|
140
|
-
recheck: () => Promise<void>;
|
|
141
|
-
};
|
|
142
|
-
export type { FingerprintOptions, FingerprintResult, EnhancedFingerprintResult, ComponentData } from '@tracetail/js';
|
|
73
|
+
export type { FingerprintOptions, FingerprintResult, ComponentData } from '@tracetail/js';
|
|
143
74
|
export { TraceTail } from '@tracetail/js';
|
|
144
75
|
interface TraceTailProviderProps {
|
|
145
76
|
children: ReactNode;
|
|
@@ -153,9 +84,7 @@ export declare const TraceTailProvider: FC<TraceTailProviderProps>;
|
|
|
153
84
|
export declare const getVersion: () => string;
|
|
154
85
|
declare const _default: {
|
|
155
86
|
useTraceTail: typeof useTraceTail;
|
|
156
|
-
useEnhancedTraceTail: typeof useEnhancedTraceTail;
|
|
157
87
|
useVisitorId: typeof useVisitorId;
|
|
158
|
-
useFraudDetection: typeof useFraudDetection;
|
|
159
88
|
TraceTailProvider: FC<TraceTailProviderProps>;
|
|
160
89
|
getVersion: () => string;
|
|
161
90
|
};
|
package/dist/index.esm.js
CHANGED
|
@@ -42,87 +42,7 @@ function useTraceTail(options) {
|
|
|
42
42
|
setError(null);
|
|
43
43
|
try {
|
|
44
44
|
const result = await traceTailRef.current.generateFingerprint({
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
setFingerprint(result);
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
const error = err instanceof Error ? err : new Error('Unknown error');
|
|
52
|
-
setError(error);
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
finally {
|
|
56
|
-
setLoading(false);
|
|
57
|
-
}
|
|
58
|
-
}, []);
|
|
59
|
-
const regenerate = useCallback(async () => {
|
|
60
|
-
setFingerprint(null);
|
|
61
|
-
return generate();
|
|
62
|
-
}, [generate]);
|
|
63
|
-
// Auto-generate on mount if immediate is true
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (options.immediate && !fingerprint && !loading) {
|
|
66
|
-
generate().catch(() => {
|
|
67
|
-
// Error is already handled in generate function
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}, [options.immediate, fingerprint, loading, generate]);
|
|
71
|
-
return {
|
|
72
|
-
fingerprint,
|
|
73
|
-
loading,
|
|
74
|
-
error,
|
|
75
|
-
generate,
|
|
76
|
-
regenerate
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* React hook for enhanced browser fingerprinting with fraud detection
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* import { useEnhancedTraceTail } from '@tracetail/react';
|
|
85
|
-
*
|
|
86
|
-
* function SecurityComponent() {
|
|
87
|
-
* const { fingerprint, loading, error } = useEnhancedTraceTail({
|
|
88
|
-
* apiKey: 'your-api-key',
|
|
89
|
-
* immediate: true
|
|
90
|
-
* });
|
|
91
|
-
*
|
|
92
|
-
* if (loading) return <div>Analyzing security...</div>;
|
|
93
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
94
|
-
*
|
|
95
|
-
* const riskLevel = fingerprint?.threatLevel || 'unknown';
|
|
96
|
-
* return (
|
|
97
|
-
* <div>
|
|
98
|
-
* <p>Risk Level: {riskLevel}</p>
|
|
99
|
-
* <p>Bot Probability: {(fingerprint?.botProbability * 100).toFixed(1)}%</p>
|
|
100
|
-
* </div>
|
|
101
|
-
* );
|
|
102
|
-
* }
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
function useEnhancedTraceTail(options) {
|
|
106
|
-
const [fingerprint, setFingerprint] = useState(null);
|
|
107
|
-
const [loading, setLoading] = useState(false);
|
|
108
|
-
const [error, setError] = useState(null);
|
|
109
|
-
const traceTailRef = useRef(null);
|
|
110
|
-
// Initialize TraceTail instance
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if (!traceTailRef.current) {
|
|
113
|
-
traceTailRef.current = new TraceTail(options);
|
|
114
|
-
}
|
|
115
|
-
}, [options.apiKey, options.endpoint]);
|
|
116
|
-
const generate = useCallback(async () => {
|
|
117
|
-
if (!traceTailRef.current) {
|
|
118
|
-
throw new Error('TraceTail not initialized');
|
|
119
|
-
}
|
|
120
|
-
setLoading(true);
|
|
121
|
-
setError(null);
|
|
122
|
-
try {
|
|
123
|
-
const result = await traceTailRef.current.generateEnhancedFingerprint({
|
|
124
|
-
includeComponents: true,
|
|
125
|
-
fraudDetection: true
|
|
45
|
+
verbose: true
|
|
126
46
|
});
|
|
127
47
|
setFingerprint(result);
|
|
128
48
|
return result;
|
|
@@ -211,52 +131,6 @@ function useVisitorId(options) {
|
|
|
211
131
|
refresh
|
|
212
132
|
};
|
|
213
133
|
}
|
|
214
|
-
/**
|
|
215
|
-
* React hook for fraud detection with configurable thresholds
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* ```typescript
|
|
219
|
-
* import { useFraudDetection } from '@tracetail/react';
|
|
220
|
-
*
|
|
221
|
-
* function SecurityCheck() {
|
|
222
|
-
* const { isFraudulent, riskLevel, loading } = useFraudDetection({
|
|
223
|
-
* apiKey: 'your-api-key',
|
|
224
|
-
* riskThreshold: 0.7,
|
|
225
|
-
* botThreshold: 0.5
|
|
226
|
-
* });
|
|
227
|
-
*
|
|
228
|
-
* if (isFraudulent) {
|
|
229
|
-
* return <div>⚠️ High risk detected - additional verification required</div>;
|
|
230
|
-
* }
|
|
231
|
-
*
|
|
232
|
-
* return <div>✅ Security check passed (Risk: {riskLevel})</div>;
|
|
233
|
-
* }
|
|
234
|
-
* ```
|
|
235
|
-
*/
|
|
236
|
-
function useFraudDetection(options) {
|
|
237
|
-
const riskThreshold = options.riskThreshold || 0.7;
|
|
238
|
-
const botThreshold = options.botThreshold || 0.5;
|
|
239
|
-
const { fingerprint, loading, error, generate } = useEnhancedTraceTail({
|
|
240
|
-
...options,
|
|
241
|
-
immediate: true
|
|
242
|
-
});
|
|
243
|
-
const isFraudulent = fingerprint ?
|
|
244
|
-
fingerprint.riskScore > riskThreshold || fingerprint.botProbability > botThreshold :
|
|
245
|
-
false;
|
|
246
|
-
const recheck = useCallback(async () => {
|
|
247
|
-
await generate();
|
|
248
|
-
}, [generate]);
|
|
249
|
-
return {
|
|
250
|
-
isFraudulent,
|
|
251
|
-
riskLevel: (fingerprint === null || fingerprint === void 0 ? void 0 : fingerprint.threatLevel) || null,
|
|
252
|
-
riskScore: (fingerprint === null || fingerprint === void 0 ? void 0 : fingerprint.riskScore) || 0,
|
|
253
|
-
botProbability: (fingerprint === null || fingerprint === void 0 ? void 0 : fingerprint.botProbability) || 0,
|
|
254
|
-
fraudSignals: (fingerprint === null || fingerprint === void 0 ? void 0 : fingerprint.fraudSignals) || [],
|
|
255
|
-
loading,
|
|
256
|
-
error,
|
|
257
|
-
recheck
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
134
|
const TraceTailProvider = ({ children }) => {
|
|
261
135
|
// This is a simple provider that could be extended with context
|
|
262
136
|
// For now, it just renders children since hooks manage their own instances
|
|
@@ -265,16 +139,14 @@ const TraceTailProvider = ({ children }) => {
|
|
|
265
139
|
/**
|
|
266
140
|
* Get the current React package version
|
|
267
141
|
*/
|
|
268
|
-
const getVersion = () => '2.3.
|
|
142
|
+
const getVersion = () => '2.3.4';
|
|
269
143
|
// Default export
|
|
270
144
|
var index = {
|
|
271
145
|
useTraceTail,
|
|
272
|
-
useEnhancedTraceTail,
|
|
273
146
|
useVisitorId,
|
|
274
|
-
useFraudDetection,
|
|
275
147
|
TraceTailProvider,
|
|
276
148
|
getVersion
|
|
277
149
|
};
|
|
278
150
|
|
|
279
|
-
export { TraceTailProvider, index as default, getVersion,
|
|
151
|
+
export { TraceTailProvider, index as default, getVersion, useTraceTail, useVisitorId };
|
|
280
152
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/index.tsx"],"sourcesContent":["/**\n * @tracetail/react - React Hooks for Enterprise Browser Fingerprinting\n * Version: 2.3.3\n * \n * Over 99.5% accuracy browser fingerprinting with React hooks.\n * Perfect for fraud detection, user analytics, and security applications.\n */\n\nimport { useEffect, useState, useCallback, useRef } from 'react';\nimport type { FC, ReactNode } from 'react';\nimport { TraceTail, FingerprintOptions, FingerprintResult, EnhancedFingerprintResult } from '@tracetail/js';\n\nexport interface UseTraceTailOptions extends FingerprintOptions {\n immediate?: boolean;\n suspense?: boolean;\n}\n\nexport interface UseTraceTailReturn {\n fingerprint: FingerprintResult | null;\n loading: boolean;\n error: Error | null;\n generate: () => Promise<FingerprintResult>;\n regenerate: () => Promise<FingerprintResult>;\n}\n\nexport interface UseEnhancedTraceTailReturn {\n fingerprint: EnhancedFingerprintResult | null;\n loading: boolean;\n error: Error | null;\n generate: () => Promise<EnhancedFingerprintResult>;\n regenerate: () => Promise<EnhancedFingerprintResult>;\n}\n\n/**\n * React hook for basic browser fingerprinting\n * \n * @example\n * ```typescript\n * import { useTraceTail } from '@tracetail/react';\n * \n * function MyComponent() {\n * const { fingerprint, loading, error } = useTraceTail({\n * apiKey: 'your-api-key',\n * immediate: true\n * });\n * \n * if (loading) return <div>Generating fingerprint...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * \n * return <div>Visitor ID: {fingerprint?.visitorId}</div>;\n * }\n * ```\n */\nexport function useTraceTail(options: UseTraceTailOptions): UseTraceTailReturn {\n const [fingerprint, setFingerprint] = useState<FingerprintResult | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n \n const traceTailRef = useRef<TraceTail | null>(null);\n \n // Initialize TraceTail instance\n useEffect(() => {\n if (!traceTailRef.current) {\n traceTailRef.current = new TraceTail(options);\n }\n }, [options.apiKey, options.endpoint]);\n\n const generate = useCallback(async (): Promise<FingerprintResult> => {\n if (!traceTailRef.current) {\n throw new Error('TraceTail not initialized');\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const result = await traceTailRef.current.generateFingerprint({\n includeComponents: true\n });\n setFingerprint(result);\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Unknown error');\n setError(error);\n throw error;\n } finally {\n setLoading(false);\n }\n }, []);\n\n const regenerate = useCallback(async (): Promise<FingerprintResult> => {\n setFingerprint(null);\n return generate();\n }, [generate]);\n\n // Auto-generate on mount if immediate is true\n useEffect(() => {\n if (options.immediate && !fingerprint && !loading) {\n generate().catch(() => {\n // Error is already handled in generate function\n });\n }\n }, [options.immediate, fingerprint, loading, generate]);\n\n return {\n fingerprint,\n loading,\n error,\n generate,\n regenerate\n };\n}\n\n/**\n * React hook for enhanced browser fingerprinting with fraud detection\n * \n * @example\n * ```typescript\n * import { useEnhancedTraceTail } from '@tracetail/react';\n * \n * function SecurityComponent() {\n * const { fingerprint, loading, error } = useEnhancedTraceTail({\n * apiKey: 'your-api-key',\n * immediate: true\n * });\n * \n * if (loading) return <div>Analyzing security...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * \n * const riskLevel = fingerprint?.threatLevel || 'unknown';\n * return (\n * <div>\n * <p>Risk Level: {riskLevel}</p>\n * <p>Bot Probability: {(fingerprint?.botProbability * 100).toFixed(1)}%</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useEnhancedTraceTail(options: UseTraceTailOptions): UseEnhancedTraceTailReturn {\n const [fingerprint, setFingerprint] = useState<EnhancedFingerprintResult | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n \n const traceTailRef = useRef<TraceTail | null>(null);\n \n // Initialize TraceTail instance\n useEffect(() => {\n if (!traceTailRef.current) {\n traceTailRef.current = new TraceTail(options);\n }\n }, [options.apiKey, options.endpoint]);\n\n const generate = useCallback(async (): Promise<EnhancedFingerprintResult> => {\n if (!traceTailRef.current) {\n throw new Error('TraceTail not initialized');\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const result = await traceTailRef.current.generateEnhancedFingerprint({\n includeComponents: true,\n fraudDetection: true\n });\n setFingerprint(result);\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Unknown error');\n setError(error);\n throw error;\n } finally {\n setLoading(false);\n }\n }, []);\n\n const regenerate = useCallback(async (): Promise<EnhancedFingerprintResult> => {\n setFingerprint(null);\n return generate();\n }, [generate]);\n\n // Auto-generate on mount if immediate is true\n useEffect(() => {\n if (options.immediate && !fingerprint && !loading) {\n generate().catch(() => {\n // Error is already handled in generate function\n });\n }\n }, [options.immediate, fingerprint, loading, generate]);\n\n return {\n fingerprint,\n loading,\n error,\n generate,\n regenerate\n };\n}\n\n/**\n * React hook for visitor identification with persistent storage\n * \n * @example\n * ```typescript\n * import { useVisitorId } from '@tracetail/react';\n * \n * function UserTrackingComponent() {\n * const { visitorId, isReturningVisitor, loading } = useVisitorId({\n * apiKey: 'your-api-key',\n * storageKey: 'app_visitor_id'\n * });\n * \n * return (\n * <div>\n * <p>Visitor: {visitorId}</p>\n * <p>Status: {isReturningVisitor ? 'Returning' : 'New'} visitor</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useVisitorId(options: UseTraceTailOptions & {\n storageKey?: string;\n}): {\n visitorId: string | null;\n isReturningVisitor: boolean;\n loading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n} {\n const storageKey = options.storageKey || 'tracetail_visitor_id';\n const [visitorId, setVisitorId] = useState<string | null>(null);\n const [isReturningVisitor, setIsReturningVisitor] = useState(false);\n \n const { fingerprint, loading, error, generate } = useTraceTail({\n ...options,\n immediate: true\n });\n\n // Update visitor ID when fingerprint changes\n useEffect(() => {\n if (fingerprint?.visitorId) {\n const storedVisitorId = localStorage.getItem(storageKey);\n \n if (storedVisitorId) {\n setIsReturningVisitor(storedVisitorId === fingerprint.visitorId);\n } else {\n setIsReturningVisitor(false);\n }\n \n setVisitorId(fingerprint.visitorId);\n localStorage.setItem(storageKey, fingerprint.visitorId);\n }\n }, [fingerprint?.visitorId, storageKey]);\n\n const refresh = useCallback(async () => {\n await generate();\n }, [generate]);\n\n return {\n visitorId,\n isReturningVisitor,\n loading,\n error,\n refresh\n };\n}\n\n/**\n * React hook for fraud detection with configurable thresholds\n * \n * @example\n * ```typescript\n * import { useFraudDetection } from '@tracetail/react';\n * \n * function SecurityCheck() {\n * const { isFraudulent, riskLevel, loading } = useFraudDetection({\n * apiKey: 'your-api-key',\n * riskThreshold: 0.7,\n * botThreshold: 0.5\n * });\n * \n * if (isFraudulent) {\n * return <div>⚠️ High risk detected - additional verification required</div>;\n * }\n * \n * return <div>✅ Security check passed (Risk: {riskLevel})</div>;\n * }\n * ```\n */\nexport function useFraudDetection(options: UseTraceTailOptions & {\n riskThreshold?: number;\n botThreshold?: number;\n}): {\n isFraudulent: boolean;\n riskLevel: 'low' | 'medium' | 'high' | null;\n riskScore: number;\n botProbability: number;\n fraudSignals: string[];\n loading: boolean;\n error: Error | null;\n recheck: () => Promise<void>;\n} {\n const riskThreshold = options.riskThreshold || 0.7;\n const botThreshold = options.botThreshold || 0.5;\n \n const { fingerprint, loading, error, generate } = useEnhancedTraceTail({\n ...options,\n immediate: true\n });\n\n const isFraudulent = fingerprint ? \n fingerprint.riskScore > riskThreshold || fingerprint.botProbability > botThreshold : \n false;\n\n const recheck = useCallback(async () => {\n await generate();\n }, [generate]);\n\n return {\n isFraudulent,\n riskLevel: fingerprint?.threatLevel || null,\n riskScore: fingerprint?.riskScore || 0,\n botProbability: fingerprint?.botProbability || 0,\n fraudSignals: fingerprint?.fraudSignals || [],\n loading,\n error,\n recheck\n };\n}\n\n// Re-export types and utilities from the base package\nexport type {\n FingerprintOptions,\n FingerprintResult,\n EnhancedFingerprintResult,\n ComponentData\n} from '@tracetail/js';\n\nexport { TraceTail } from '@tracetail/js';\n\n// React-specific utilities\ninterface TraceTailProviderProps {\n children: ReactNode;\n apiKey: string;\n options?: Partial<FingerprintOptions>;\n}\n\nexport const TraceTailProvider: FC<TraceTailProviderProps> = ({ children }) => {\n // This is a simple provider that could be extended with context\n // For now, it just renders children since hooks manage their own instances\n return <>{children}</>;\n};\n\n/**\n * Get the current React package version\n */\nexport const getVersion = (): string => '2.3.3';\n\n// Default export\nexport default {\n useTraceTail,\n useEnhancedTraceTail,\n useVisitorId,\n useFraudDetection,\n TraceTailProvider,\n getVersion\n};"],"names":["_jsx","_Fragment"],"mappings":";;;;;AAiCA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,YAAY,CAAC,OAA4B,EAAA;IACvD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAA2B,IAAI,CAAC;IAC9E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC;AAEtD,IAAA,MAAM,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,QAAQ,EAAE;AAClB,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAEd,OAAO;QACL,YAAY;QACZ,SAAS,EAAE,CAAA,WAAW,KAAA,IAAA,IAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,KAAI,IAAI;QAC3C,SAAS,EAAE,CAAA,WAAW,KAAA,IAAA,IAAX,WAAW,uBAAX,WAAW,CAAE,SAAS,KAAI,CAAC;QACtC,cAAc,EAAE,CAAA,WAAW,KAAA,IAAA,IAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,KAAI,CAAC;QAChD,YAAY,EAAE,CAAA,WAAW,KAAA,IAAA,IAAX,WAAW,uBAAX,WAAW,CAAE,YAAY,KAAI,EAAE;QAC7C,OAAO;QACP,KAAK;QACL;KACD;AACH;MAmBa,iBAAiB,GAA+B,CAAC,EAAE,QAAQ,EAAE,KAAI;;;IAG5E,OAAOA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI;AACxB;AAEA;;AAEG;MACU,UAAU,GAAG,MAAc;AAExC;AACA,YAAe;IACb,YAAY;IACZ,oBAAoB;IACpB,YAAY;IACZ,iBAAiB;IACjB,iBAAiB;IACjB;CACD;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/index.tsx"],"sourcesContent":["/**\n * @tracetail/react - React Hooks for Enterprise Browser Fingerprinting\n * Version: 2.3.4\n *\n * Over 99.5% accuracy browser fingerprinting with React hooks and server-side processing.\n * Perfect for fraud detection, user analytics, and security applications.\n */\n\nimport { useEffect, useState, useCallback, useRef } from 'react';\nimport type { FC, ReactNode } from 'react';\nimport { TraceTail, FingerprintOptions, FingerprintResult } from '@tracetail/js';\n\nexport interface UseTraceTailOptions extends FingerprintOptions {\n immediate?: boolean;\n suspense?: boolean;\n}\n\nexport interface UseTraceTailReturn {\n fingerprint: FingerprintResult | null;\n loading: boolean;\n error: Error | null;\n generate: () => Promise<FingerprintResult>;\n regenerate: () => Promise<FingerprintResult>;\n}\n\n\n/**\n * React hook for basic browser fingerprinting\n * \n * @example\n * ```typescript\n * import { useTraceTail } from '@tracetail/react';\n * \n * function MyComponent() {\n * const { fingerprint, loading, error } = useTraceTail({\n * apiKey: 'your-api-key',\n * immediate: true\n * });\n * \n * if (loading) return <div>Generating fingerprint...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * \n * return <div>Visitor ID: {fingerprint?.visitorId}</div>;\n * }\n * ```\n */\nexport function useTraceTail(options: UseTraceTailOptions): UseTraceTailReturn {\n const [fingerprint, setFingerprint] = useState<FingerprintResult | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n \n const traceTailRef = useRef<TraceTail | null>(null);\n \n // Initialize TraceTail instance\n useEffect(() => {\n if (!traceTailRef.current) {\n traceTailRef.current = new TraceTail(options);\n }\n }, [options.apiKey, options.endpoint]);\n\n const generate = useCallback(async (): Promise<FingerprintResult> => {\n if (!traceTailRef.current) {\n throw new Error('TraceTail not initialized');\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const result = await traceTailRef.current.generateFingerprint({\n verbose: true\n });\n setFingerprint(result);\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Unknown error');\n setError(error);\n throw error;\n } finally {\n setLoading(false);\n }\n }, []);\n\n const regenerate = useCallback(async (): Promise<FingerprintResult> => {\n setFingerprint(null);\n return generate();\n }, [generate]);\n\n // Auto-generate on mount if immediate is true\n useEffect(() => {\n if (options.immediate && !fingerprint && !loading) {\n generate().catch(() => {\n // Error is already handled in generate function\n });\n }\n }, [options.immediate, fingerprint, loading, generate]);\n\n return {\n fingerprint,\n loading,\n error,\n generate,\n regenerate\n };\n}\n\n\n/**\n * React hook for visitor identification with persistent storage\n * \n * @example\n * ```typescript\n * import { useVisitorId } from '@tracetail/react';\n * \n * function UserTrackingComponent() {\n * const { visitorId, isReturningVisitor, loading } = useVisitorId({\n * apiKey: 'your-api-key',\n * storageKey: 'app_visitor_id'\n * });\n * \n * return (\n * <div>\n * <p>Visitor: {visitorId}</p>\n * <p>Status: {isReturningVisitor ? 'Returning' : 'New'} visitor</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useVisitorId(options: UseTraceTailOptions & {\n storageKey?: string;\n}): {\n visitorId: string | null;\n isReturningVisitor: boolean;\n loading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n} {\n const storageKey = options.storageKey || 'tracetail_visitor_id';\n const [visitorId, setVisitorId] = useState<string | null>(null);\n const [isReturningVisitor, setIsReturningVisitor] = useState(false);\n \n const { fingerprint, loading, error, generate } = useTraceTail({\n ...options,\n immediate: true\n });\n\n // Update visitor ID when fingerprint changes\n useEffect(() => {\n if (fingerprint?.visitorId) {\n const storedVisitorId = localStorage.getItem(storageKey);\n \n if (storedVisitorId) {\n setIsReturningVisitor(storedVisitorId === fingerprint.visitorId);\n } else {\n setIsReturningVisitor(false);\n }\n \n setVisitorId(fingerprint.visitorId);\n localStorage.setItem(storageKey, fingerprint.visitorId);\n }\n }, [fingerprint?.visitorId, storageKey]);\n\n const refresh = useCallback(async () => {\n await generate();\n }, [generate]);\n\n return {\n visitorId,\n isReturningVisitor,\n loading,\n error,\n refresh\n };\n}\n\n\n// Re-export types and utilities from the base package\nexport type {\n FingerprintOptions,\n FingerprintResult,\n ComponentData\n} from '@tracetail/js';\n\nexport { TraceTail } from '@tracetail/js';\n\n// React-specific utilities\ninterface TraceTailProviderProps {\n children: ReactNode;\n apiKey: string;\n options?: Partial<FingerprintOptions>;\n}\n\nexport const TraceTailProvider: FC<TraceTailProviderProps> = ({ children }) => {\n // This is a simple provider that could be extended with context\n // For now, it just renders children since hooks manage their own instances\n return <>{children}</>;\n};\n\n/**\n * Get the current React package version\n */\nexport const getVersion = (): string => '2.3.4';\n\n// Default export\nexport default {\n useTraceTail,\n useVisitorId,\n TraceTailProvider,\n getVersion\n};"],"names":["_jsx","_Fragment"],"mappings":";;;;;AA0BA;;;;;;;;;;;;;;;;;;;AAmBG;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,CAAC,WAAW,CAAC,SAAS,CAAC;YACnC,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,SAAS,CAAC;QACzD;AACF,IAAA,CAAC,EAAE,CAAC,WAAW,KAAA,IAAA,IAAX,WAAW,KAAA,MAAA,GAAA,MAAA,GAAX,WAAW,CAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAExC,IAAA,MAAM,OAAO,GAAG,WAAW,CAAC,YAAW;QACrC,MAAM,QAAQ,EAAE;AAClB,IAAA,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAEd,OAAO;QACL,SAAS;QACT,kBAAkB;QAClB,OAAO;QACP,KAAK;QACL;KACD;AACH;MAmBa,iBAAiB,GAA+B,CAAC,EAAE,QAAQ,EAAE,KAAI;;;IAG5E,OAAOA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI;AACxB;AAEA;;AAEG;MACU,UAAU,GAAG,MAAc;AAExC;AACA,YAAe;IACb,YAAY;IACZ,YAAY;IACZ,iBAAiB;IACjB;CACD;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -45,87 +45,7 @@ function useTraceTail(options) {
|
|
|
45
45
|
setError(null);
|
|
46
46
|
try {
|
|
47
47
|
const result = await traceTailRef.current.generateFingerprint({
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
setFingerprint(result);
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
catch (err) {
|
|
54
|
-
const error = err instanceof Error ? err : new Error('Unknown error');
|
|
55
|
-
setError(error);
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
finally {
|
|
59
|
-
setLoading(false);
|
|
60
|
-
}
|
|
61
|
-
}, []);
|
|
62
|
-
const regenerate = react.useCallback(async () => {
|
|
63
|
-
setFingerprint(null);
|
|
64
|
-
return generate();
|
|
65
|
-
}, [generate]);
|
|
66
|
-
// Auto-generate on mount if immediate is true
|
|
67
|
-
react.useEffect(() => {
|
|
68
|
-
if (options.immediate && !fingerprint && !loading) {
|
|
69
|
-
generate().catch(() => {
|
|
70
|
-
// Error is already handled in generate function
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}, [options.immediate, fingerprint, loading, generate]);
|
|
74
|
-
return {
|
|
75
|
-
fingerprint,
|
|
76
|
-
loading,
|
|
77
|
-
error,
|
|
78
|
-
generate,
|
|
79
|
-
regenerate
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* React hook for enhanced browser fingerprinting with fraud detection
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* import { useEnhancedTraceTail } from '@tracetail/react';
|
|
88
|
-
*
|
|
89
|
-
* function SecurityComponent() {
|
|
90
|
-
* const { fingerprint, loading, error } = useEnhancedTraceTail({
|
|
91
|
-
* apiKey: 'your-api-key',
|
|
92
|
-
* immediate: true
|
|
93
|
-
* });
|
|
94
|
-
*
|
|
95
|
-
* if (loading) return <div>Analyzing security...</div>;
|
|
96
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
97
|
-
*
|
|
98
|
-
* const riskLevel = fingerprint?.threatLevel || 'unknown';
|
|
99
|
-
* return (
|
|
100
|
-
* <div>
|
|
101
|
-
* <p>Risk Level: {riskLevel}</p>
|
|
102
|
-
* <p>Bot Probability: {(fingerprint?.botProbability * 100).toFixed(1)}%</p>
|
|
103
|
-
* </div>
|
|
104
|
-
* );
|
|
105
|
-
* }
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
function useEnhancedTraceTail(options) {
|
|
109
|
-
const [fingerprint, setFingerprint] = react.useState(null);
|
|
110
|
-
const [loading, setLoading] = react.useState(false);
|
|
111
|
-
const [error, setError] = react.useState(null);
|
|
112
|
-
const traceTailRef = react.useRef(null);
|
|
113
|
-
// Initialize TraceTail instance
|
|
114
|
-
react.useEffect(() => {
|
|
115
|
-
if (!traceTailRef.current) {
|
|
116
|
-
traceTailRef.current = new js.TraceTail(options);
|
|
117
|
-
}
|
|
118
|
-
}, [options.apiKey, options.endpoint]);
|
|
119
|
-
const generate = react.useCallback(async () => {
|
|
120
|
-
if (!traceTailRef.current) {
|
|
121
|
-
throw new Error('TraceTail not initialized');
|
|
122
|
-
}
|
|
123
|
-
setLoading(true);
|
|
124
|
-
setError(null);
|
|
125
|
-
try {
|
|
126
|
-
const result = await traceTailRef.current.generateEnhancedFingerprint({
|
|
127
|
-
includeComponents: true,
|
|
128
|
-
fraudDetection: true
|
|
48
|
+
verbose: true
|
|
129
49
|
});
|
|
130
50
|
setFingerprint(result);
|
|
131
51
|
return result;
|
|
@@ -214,52 +134,6 @@ function useVisitorId(options) {
|
|
|
214
134
|
refresh
|
|
215
135
|
};
|
|
216
136
|
}
|
|
217
|
-
/**
|
|
218
|
-
* React hook for fraud detection with configurable thresholds
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* ```typescript
|
|
222
|
-
* import { useFraudDetection } from '@tracetail/react';
|
|
223
|
-
*
|
|
224
|
-
* function SecurityCheck() {
|
|
225
|
-
* const { isFraudulent, riskLevel, loading } = useFraudDetection({
|
|
226
|
-
* apiKey: 'your-api-key',
|
|
227
|
-
* riskThreshold: 0.7,
|
|
228
|
-
* botThreshold: 0.5
|
|
229
|
-
* });
|
|
230
|
-
*
|
|
231
|
-
* if (isFraudulent) {
|
|
232
|
-
* return <div>⚠️ High risk detected - additional verification required</div>;
|
|
233
|
-
* }
|
|
234
|
-
*
|
|
235
|
-
* return <div>✅ Security check passed (Risk: {riskLevel})</div>;
|
|
236
|
-
* }
|
|
237
|
-
* ```
|
|
238
|
-
*/
|
|
239
|
-
function useFraudDetection(options) {
|
|
240
|
-
const riskThreshold = options.riskThreshold || 0.7;
|
|
241
|
-
const botThreshold = options.botThreshold || 0.5;
|
|
242
|
-
const { fingerprint, loading, error, generate } = useEnhancedTraceTail({
|
|
243
|
-
...options,
|
|
244
|
-
immediate: true
|
|
245
|
-
});
|
|
246
|
-
const isFraudulent = fingerprint ?
|
|
247
|
-
fingerprint.riskScore > riskThreshold || fingerprint.botProbability > botThreshold :
|
|
248
|
-
false;
|
|
249
|
-
const recheck = react.useCallback(async () => {
|
|
250
|
-
await generate();
|
|
251
|
-
}, [generate]);
|
|
252
|
-
return {
|
|
253
|
-
isFraudulent,
|
|
254
|
-
riskLevel: (fingerprint === null || fingerprint === void 0 ? void 0 : fingerprint.threatLevel) || null,
|
|
255
|
-
riskScore: (fingerprint === null || fingerprint === void 0 ? void 0 : fingerprint.riskScore) || 0,
|
|
256
|
-
botProbability: (fingerprint === null || fingerprint === void 0 ? void 0 : fingerprint.botProbability) || 0,
|
|
257
|
-
fraudSignals: (fingerprint === null || fingerprint === void 0 ? void 0 : fingerprint.fraudSignals) || [],
|
|
258
|
-
loading,
|
|
259
|
-
error,
|
|
260
|
-
recheck
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
137
|
const TraceTailProvider = ({ children }) => {
|
|
264
138
|
// This is a simple provider that could be extended with context
|
|
265
139
|
// For now, it just renders children since hooks manage their own instances
|
|
@@ -268,13 +142,11 @@ const TraceTailProvider = ({ children }) => {
|
|
|
268
142
|
/**
|
|
269
143
|
* Get the current React package version
|
|
270
144
|
*/
|
|
271
|
-
const getVersion = () => '2.3.
|
|
145
|
+
const getVersion = () => '2.3.4';
|
|
272
146
|
// Default export
|
|
273
147
|
var index = {
|
|
274
148
|
useTraceTail,
|
|
275
|
-
useEnhancedTraceTail,
|
|
276
149
|
useVisitorId,
|
|
277
|
-
useFraudDetection,
|
|
278
150
|
TraceTailProvider,
|
|
279
151
|
getVersion
|
|
280
152
|
};
|
|
@@ -286,8 +158,6 @@ Object.defineProperty(exports, "TraceTail", {
|
|
|
286
158
|
exports.TraceTailProvider = TraceTailProvider;
|
|
287
159
|
exports.default = index;
|
|
288
160
|
exports.getVersion = getVersion;
|
|
289
|
-
exports.useEnhancedTraceTail = useEnhancedTraceTail;
|
|
290
|
-
exports.useFraudDetection = useFraudDetection;
|
|
291
161
|
exports.useTraceTail = useTraceTail;
|
|
292
162
|
exports.useVisitorId = useVisitorId;
|
|
293
163
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["/**\n * @tracetail/react - React Hooks for Enterprise Browser Fingerprinting\n * Version: 2.3.3\n * \n * Over 99.5% accuracy browser fingerprinting with React hooks.\n * Perfect for fraud detection, user analytics, and security applications.\n */\n\nimport { useEffect, useState, useCallback, useRef } from 'react';\nimport type { FC, ReactNode } from 'react';\nimport { TraceTail, FingerprintOptions, FingerprintResult, EnhancedFingerprintResult } from '@tracetail/js';\n\nexport interface UseTraceTailOptions extends FingerprintOptions {\n immediate?: boolean;\n suspense?: boolean;\n}\n\nexport interface UseTraceTailReturn {\n fingerprint: FingerprintResult | null;\n loading: boolean;\n error: Error | null;\n generate: () => Promise<FingerprintResult>;\n regenerate: () => Promise<FingerprintResult>;\n}\n\nexport interface UseEnhancedTraceTailReturn {\n fingerprint: EnhancedFingerprintResult | null;\n loading: boolean;\n error: Error | null;\n generate: () => Promise<EnhancedFingerprintResult>;\n regenerate: () => Promise<EnhancedFingerprintResult>;\n}\n\n/**\n * React hook for basic browser fingerprinting\n * \n * @example\n * ```typescript\n * import { useTraceTail } from '@tracetail/react';\n * \n * function MyComponent() {\n * const { fingerprint, loading, error } = useTraceTail({\n * apiKey: 'your-api-key',\n * immediate: true\n * });\n * \n * if (loading) return <div>Generating fingerprint...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * \n * return <div>Visitor ID: {fingerprint?.visitorId}</div>;\n * }\n * ```\n */\nexport function useTraceTail(options: UseTraceTailOptions): UseTraceTailReturn {\n const [fingerprint, setFingerprint] = useState<FingerprintResult | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n \n const traceTailRef = useRef<TraceTail | null>(null);\n \n // Initialize TraceTail instance\n useEffect(() => {\n if (!traceTailRef.current) {\n traceTailRef.current = new TraceTail(options);\n }\n }, [options.apiKey, options.endpoint]);\n\n const generate = useCallback(async (): Promise<FingerprintResult> => {\n if (!traceTailRef.current) {\n throw new Error('TraceTail not initialized');\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const result = await traceTailRef.current.generateFingerprint({\n includeComponents: true\n });\n setFingerprint(result);\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Unknown error');\n setError(error);\n throw error;\n } finally {\n setLoading(false);\n }\n }, []);\n\n const regenerate = useCallback(async (): Promise<FingerprintResult> => {\n setFingerprint(null);\n return generate();\n }, [generate]);\n\n // Auto-generate on mount if immediate is true\n useEffect(() => {\n if (options.immediate && !fingerprint && !loading) {\n generate().catch(() => {\n // Error is already handled in generate function\n });\n }\n }, [options.immediate, fingerprint, loading, generate]);\n\n return {\n fingerprint,\n loading,\n error,\n generate,\n regenerate\n };\n}\n\n/**\n * React hook for enhanced browser fingerprinting with fraud detection\n * \n * @example\n * ```typescript\n * import { useEnhancedTraceTail } from '@tracetail/react';\n * \n * function SecurityComponent() {\n * const { fingerprint, loading, error } = useEnhancedTraceTail({\n * apiKey: 'your-api-key',\n * immediate: true\n * });\n * \n * if (loading) return <div>Analyzing security...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * \n * const riskLevel = fingerprint?.threatLevel || 'unknown';\n * return (\n * <div>\n * <p>Risk Level: {riskLevel}</p>\n * <p>Bot Probability: {(fingerprint?.botProbability * 100).toFixed(1)}%</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useEnhancedTraceTail(options: UseTraceTailOptions): UseEnhancedTraceTailReturn {\n const [fingerprint, setFingerprint] = useState<EnhancedFingerprintResult | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n \n const traceTailRef = useRef<TraceTail | null>(null);\n \n // Initialize TraceTail instance\n useEffect(() => {\n if (!traceTailRef.current) {\n traceTailRef.current = new TraceTail(options);\n }\n }, [options.apiKey, options.endpoint]);\n\n const generate = useCallback(async (): Promise<EnhancedFingerprintResult> => {\n if (!traceTailRef.current) {\n throw new Error('TraceTail not initialized');\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const result = await traceTailRef.current.generateEnhancedFingerprint({\n includeComponents: true,\n fraudDetection: true\n });\n setFingerprint(result);\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Unknown error');\n setError(error);\n throw error;\n } finally {\n setLoading(false);\n }\n }, []);\n\n const regenerate = useCallback(async (): Promise<EnhancedFingerprintResult> => {\n setFingerprint(null);\n return generate();\n }, [generate]);\n\n // Auto-generate on mount if immediate is true\n useEffect(() => {\n if (options.immediate && !fingerprint && !loading) {\n generate().catch(() => {\n // Error is already handled in generate function\n });\n }\n }, [options.immediate, fingerprint, loading, generate]);\n\n return {\n fingerprint,\n loading,\n error,\n generate,\n regenerate\n };\n}\n\n/**\n * React hook for visitor identification with persistent storage\n * \n * @example\n * ```typescript\n * import { useVisitorId } from '@tracetail/react';\n * \n * function UserTrackingComponent() {\n * const { visitorId, isReturningVisitor, loading } = useVisitorId({\n * apiKey: 'your-api-key',\n * storageKey: 'app_visitor_id'\n * });\n * \n * return (\n * <div>\n * <p>Visitor: {visitorId}</p>\n * <p>Status: {isReturningVisitor ? 'Returning' : 'New'} visitor</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useVisitorId(options: UseTraceTailOptions & {\n storageKey?: string;\n}): {\n visitorId: string | null;\n isReturningVisitor: boolean;\n loading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n} {\n const storageKey = options.storageKey || 'tracetail_visitor_id';\n const [visitorId, setVisitorId] = useState<string | null>(null);\n const [isReturningVisitor, setIsReturningVisitor] = useState(false);\n \n const { fingerprint, loading, error, generate } = useTraceTail({\n ...options,\n immediate: true\n });\n\n // Update visitor ID when fingerprint changes\n useEffect(() => {\n if (fingerprint?.visitorId) {\n const storedVisitorId = localStorage.getItem(storageKey);\n \n if (storedVisitorId) {\n setIsReturningVisitor(storedVisitorId === fingerprint.visitorId);\n } else {\n setIsReturningVisitor(false);\n }\n \n setVisitorId(fingerprint.visitorId);\n localStorage.setItem(storageKey, fingerprint.visitorId);\n }\n }, [fingerprint?.visitorId, storageKey]);\n\n const refresh = useCallback(async () => {\n await generate();\n }, [generate]);\n\n return {\n visitorId,\n isReturningVisitor,\n loading,\n error,\n refresh\n };\n}\n\n/**\n * React hook for fraud detection with configurable thresholds\n * \n * @example\n * ```typescript\n * import { useFraudDetection } from '@tracetail/react';\n * \n * function SecurityCheck() {\n * const { isFraudulent, riskLevel, loading } = useFraudDetection({\n * apiKey: 'your-api-key',\n * riskThreshold: 0.7,\n * botThreshold: 0.5\n * });\n * \n * if (isFraudulent) {\n * return <div>⚠️ High risk detected - additional verification required</div>;\n * }\n * \n * return <div>✅ Security check passed (Risk: {riskLevel})</div>;\n * }\n * ```\n */\nexport function useFraudDetection(options: UseTraceTailOptions & {\n riskThreshold?: number;\n botThreshold?: number;\n}): {\n isFraudulent: boolean;\n riskLevel: 'low' | 'medium' | 'high' | null;\n riskScore: number;\n botProbability: number;\n fraudSignals: string[];\n loading: boolean;\n error: Error | null;\n recheck: () => Promise<void>;\n} {\n const riskThreshold = options.riskThreshold || 0.7;\n const botThreshold = options.botThreshold || 0.5;\n \n const { fingerprint, loading, error, generate } = useEnhancedTraceTail({\n ...options,\n immediate: true\n });\n\n const isFraudulent = fingerprint ? \n fingerprint.riskScore > riskThreshold || fingerprint.botProbability > botThreshold : \n false;\n\n const recheck = useCallback(async () => {\n await generate();\n }, [generate]);\n\n return {\n isFraudulent,\n riskLevel: fingerprint?.threatLevel || null,\n riskScore: fingerprint?.riskScore || 0,\n botProbability: fingerprint?.botProbability || 0,\n fraudSignals: fingerprint?.fraudSignals || [],\n loading,\n error,\n recheck\n };\n}\n\n// Re-export types and utilities from the base package\nexport type {\n FingerprintOptions,\n FingerprintResult,\n EnhancedFingerprintResult,\n ComponentData\n} from '@tracetail/js';\n\nexport { TraceTail } from '@tracetail/js';\n\n// React-specific utilities\ninterface TraceTailProviderProps {\n children: ReactNode;\n apiKey: string;\n options?: Partial<FingerprintOptions>;\n}\n\nexport const TraceTailProvider: FC<TraceTailProviderProps> = ({ children }) => {\n // This is a simple provider that could be extended with context\n // For now, it just renders children since hooks manage their own instances\n return <>{children}</>;\n};\n\n/**\n * Get the current React package version\n */\nexport const getVersion = (): string => '2.3.3';\n\n// Default export\nexport default {\n useTraceTail,\n useEnhancedTraceTail,\n useVisitorId,\n useFraudDetection,\n TraceTailProvider,\n getVersion\n};"],"names":["useState","useRef","useEffect","TraceTail","useCallback","_jsx","_Fragment"],"mappings":";;;;;;;;AAiCA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,YAAY,CAAC,OAA4B,EAAA;IACvD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAGA,cAAQ,CAA2B,IAAI,CAAC;IAC9E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAe,IAAI,CAAC;AAEtD,IAAA,MAAM,YAAY,GAAGC,YAAM,CAAmB,IAAI,CAAC;;IAGnDC,eAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YACzB,YAAY,CAAC,OAAO,GAAG,IAAIC,YAAS,CAAC,OAAO,CAAC;QAC/C;IACF,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEtC,IAAA,MAAM,QAAQ,GAAGC,iBAAW,CAAC,YAAuC;AAClE,QAAA,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;AACzB,YAAA,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC;QAC9C;QAEA,UAAU,CAAC,IAAI,CAAC;QAChB,QAAQ,CAAC,IAAI,CAAC;AAEd,QAAA,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AAO;QACP,KAAK;QACL;KACD;AACH;MAmBa,iBAAiB,GAA+B,CAAC,EAAE,QAAQ,EAAE,KAAI;;;IAG5E,OAAOC,cAAA,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI;AACxB;AAEA;;AAEG;MACU,UAAU,GAAG,MAAc;AAExC;AACA,YAAe;IACb,YAAY;IACZ,oBAAoB;IACpB,YAAY;IACZ,iBAAiB;IACjB,iBAAiB;IACjB;CACD;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["/**\n * @tracetail/react - React Hooks for Enterprise Browser Fingerprinting\n * Version: 2.3.4\n *\n * Over 99.5% accuracy browser fingerprinting with React hooks and server-side processing.\n * Perfect for fraud detection, user analytics, and security applications.\n */\n\nimport { useEffect, useState, useCallback, useRef } from 'react';\nimport type { FC, ReactNode } from 'react';\nimport { TraceTail, FingerprintOptions, FingerprintResult } from '@tracetail/js';\n\nexport interface UseTraceTailOptions extends FingerprintOptions {\n immediate?: boolean;\n suspense?: boolean;\n}\n\nexport interface UseTraceTailReturn {\n fingerprint: FingerprintResult | null;\n loading: boolean;\n error: Error | null;\n generate: () => Promise<FingerprintResult>;\n regenerate: () => Promise<FingerprintResult>;\n}\n\n\n/**\n * React hook for basic browser fingerprinting\n * \n * @example\n * ```typescript\n * import { useTraceTail } from '@tracetail/react';\n * \n * function MyComponent() {\n * const { fingerprint, loading, error } = useTraceTail({\n * apiKey: 'your-api-key',\n * immediate: true\n * });\n * \n * if (loading) return <div>Generating fingerprint...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * \n * return <div>Visitor ID: {fingerprint?.visitorId}</div>;\n * }\n * ```\n */\nexport function useTraceTail(options: UseTraceTailOptions): UseTraceTailReturn {\n const [fingerprint, setFingerprint] = useState<FingerprintResult | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n \n const traceTailRef = useRef<TraceTail | null>(null);\n \n // Initialize TraceTail instance\n useEffect(() => {\n if (!traceTailRef.current) {\n traceTailRef.current = new TraceTail(options);\n }\n }, [options.apiKey, options.endpoint]);\n\n const generate = useCallback(async (): Promise<FingerprintResult> => {\n if (!traceTailRef.current) {\n throw new Error('TraceTail not initialized');\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const result = await traceTailRef.current.generateFingerprint({\n verbose: true\n });\n setFingerprint(result);\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Unknown error');\n setError(error);\n throw error;\n } finally {\n setLoading(false);\n }\n }, []);\n\n const regenerate = useCallback(async (): Promise<FingerprintResult> => {\n setFingerprint(null);\n return generate();\n }, [generate]);\n\n // Auto-generate on mount if immediate is true\n useEffect(() => {\n if (options.immediate && !fingerprint && !loading) {\n generate().catch(() => {\n // Error is already handled in generate function\n });\n }\n }, [options.immediate, fingerprint, loading, generate]);\n\n return {\n fingerprint,\n loading,\n error,\n generate,\n regenerate\n };\n}\n\n\n/**\n * React hook for visitor identification with persistent storage\n * \n * @example\n * ```typescript\n * import { useVisitorId } from '@tracetail/react';\n * \n * function UserTrackingComponent() {\n * const { visitorId, isReturningVisitor, loading } = useVisitorId({\n * apiKey: 'your-api-key',\n * storageKey: 'app_visitor_id'\n * });\n * \n * return (\n * <div>\n * <p>Visitor: {visitorId}</p>\n * <p>Status: {isReturningVisitor ? 'Returning' : 'New'} visitor</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useVisitorId(options: UseTraceTailOptions & {\n storageKey?: string;\n}): {\n visitorId: string | null;\n isReturningVisitor: boolean;\n loading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n} {\n const storageKey = options.storageKey || 'tracetail_visitor_id';\n const [visitorId, setVisitorId] = useState<string | null>(null);\n const [isReturningVisitor, setIsReturningVisitor] = useState(false);\n \n const { fingerprint, loading, error, generate } = useTraceTail({\n ...options,\n immediate: true\n });\n\n // Update visitor ID when fingerprint changes\n useEffect(() => {\n if (fingerprint?.visitorId) {\n const storedVisitorId = localStorage.getItem(storageKey);\n \n if (storedVisitorId) {\n setIsReturningVisitor(storedVisitorId === fingerprint.visitorId);\n } else {\n setIsReturningVisitor(false);\n }\n \n setVisitorId(fingerprint.visitorId);\n localStorage.setItem(storageKey, fingerprint.visitorId);\n }\n }, [fingerprint?.visitorId, storageKey]);\n\n const refresh = useCallback(async () => {\n await generate();\n }, [generate]);\n\n return {\n visitorId,\n isReturningVisitor,\n loading,\n error,\n refresh\n };\n}\n\n\n// Re-export types and utilities from the base package\nexport type {\n FingerprintOptions,\n FingerprintResult,\n ComponentData\n} from '@tracetail/js';\n\nexport { TraceTail } from '@tracetail/js';\n\n// React-specific utilities\ninterface TraceTailProviderProps {\n children: ReactNode;\n apiKey: string;\n options?: Partial<FingerprintOptions>;\n}\n\nexport const TraceTailProvider: FC<TraceTailProviderProps> = ({ children }) => {\n // This is a simple provider that could be extended with context\n // For now, it just renders children since hooks manage their own instances\n return <>{children}</>;\n};\n\n/**\n * Get the current React package version\n */\nexport const getVersion = (): string => '2.3.4';\n\n// Default export\nexport default {\n useTraceTail,\n useVisitorId,\n TraceTailProvider,\n getVersion\n};"],"names":["useState","useRef","useEffect","TraceTail","useCallback","_jsx","_Fragment"],"mappings":";;;;;;;;AA0BA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,YAAY,CAAC,OAA4B,EAAA;IACvD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAGA,cAAQ,CAA2B,IAAI,CAAC;IAC9E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAe,IAAI,CAAC;AAEtD,IAAA,MAAM,YAAY,GAAGC,YAAM,CAAmB,IAAI,CAAC;;IAGnDC,eAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YACzB,YAAY,CAAC,OAAO,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AO;QACP,KAAK;QACL;KACD;AACH;MAmBa,iBAAiB,GAA+B,CAAC,EAAE,QAAQ,EAAE,KAAI;;;IAG5E,OAAOC,cAAA,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI;AACxB;AAEA;;AAEG;MACU,UAAU,GAAG,MAAc;AAExC;AACA,YAAe;IACb,YAAY;IACZ,YAAY;IACZ,iBAAiB;IACjB;CACD;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracetail/react",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5",
|
|
4
4
|
"description": "React hooks for TraceTail enterprise browser fingerprinting with over 99.5% accuracy. TypeScript support and React 18 compatibility.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,18 +17,28 @@
|
|
|
17
17
|
"react",
|
|
18
18
|
"hooks",
|
|
19
19
|
"fingerprinting",
|
|
20
|
-
"browser",
|
|
20
|
+
"browser-fingerprinting",
|
|
21
21
|
"fraud-detection",
|
|
22
22
|
"security",
|
|
23
23
|
"authentication",
|
|
24
24
|
"device-identification",
|
|
25
25
|
"privacy",
|
|
26
26
|
"enterprise",
|
|
27
|
-
"typescript"
|
|
27
|
+
"typescript",
|
|
28
|
+
"tracetail",
|
|
29
|
+
"live-demo"
|
|
28
30
|
],
|
|
29
31
|
"author": "TraceTail",
|
|
30
32
|
"license": "MIT",
|
|
31
|
-
"homepage": "https://tracetail.io",
|
|
33
|
+
"homepage": "https://demo.tracetail.io",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/tracetail/tracetail-js.git",
|
|
37
|
+
"directory": "packages/react"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/tracetail/tracetail-js/issues"
|
|
41
|
+
},
|
|
32
42
|
"engines": {
|
|
33
43
|
"node": ">=14"
|
|
34
44
|
},
|
|
@@ -53,4 +63,4 @@
|
|
|
53
63
|
"rollup": "^4.9.6",
|
|
54
64
|
"typescript": "^5.3.3"
|
|
55
65
|
}
|
|
56
|
-
}
|
|
66
|
+
}
|