Getting Started with Secureify
Installation
1. Include the SDK
Add the Secureify SDK to your HTML file:
<script src="https://api.secureify.xyz/static/fingerprint-sdk.js"></script>
2. Initialize the SDK
const fp = new FingerprintSDK('your-api-key', {
endpoint: 'https://api.secureify.xyz', // Optional: defaults to https://api.secureify.xyz
autoRefresh: true, // Optional: automatically refresh device ID
refreshInterval: 300000, // Optional: refresh every 5 minutes
debug: false // Optional: enable debug logging
});
Basic Usage
Generate Device ID
try {
const deviceId = await fp.generateDeviceId();
console.log('Device ID:', deviceId);
} catch (error) {
console.error('Error generating device ID:', error);
}
Get Device Parameters
try {
const parameters = await fp.getParameters();
console.log('Device Parameters:', parameters);
} catch (error) {
console.error('Error getting parameters:', error);
}
Listen for Device ID Changes
const unsubscribe = fp.onDeviceIdChange((newDeviceId) => {
console.log('Device ID changed:', newDeviceId);
});
// Later, when you want to stop listening:
unsubscribe();
Advanced Configuration
Update Configuration
fp.configure({
autoRefresh: false,
refreshInterval: 600000, // 10 minutes
debug: true
});
Cleanup
// Call this when you're done using the SDK
fp.destroy();
Available Methods
generateDeviceId()
Generates a unique device identifier based on device characteristics.
- Returns: Promise
{
"deviceId": "SEC1_223fce73b659e214"
}
getParameters()
Collects comprehensive device information including: - Screen properties (width, height, color depth) - Browser information (user agent, language) - Hardware details (platform, memory) - Canvas fingerprint - WebGL information - Audio capabilities - Font detection - Browser features - Returns: Promise
{
"screen": {
"width": 1920,
"height": 1080,
"colorDepth": 24
},
"browser": {
"userAgent": "Mozilla/5.0...",
"language": "en-US"
},
"timezone": {
"offset": -120,
"timezone": "America/New_York"
}
}
onDeviceIdChange(callback)
Subscribe to device ID changes. - Parameters: callback(deviceId: string) - Returns: Function (unsubscribe) - Usage:
const unsubscribe = fp.onDeviceIdChange((deviceId) => {
console.log('New device ID:', deviceId);
});
configure(options)
Update SDK configuration. - Parameters: options object - Available options: - endpoint: API endpoint URL - autoRefresh: boolean - refreshInterval: number (milliseconds) - debug: boolean
destroy()
Cleanup SDK resources and stop auto-refresh.
Error Handling
try {
const deviceId = await fp.generateDeviceId();
} catch (error) {
if (error.message === 'API key is required') {
console.error('Please provide a valid API key');
} else {
console.error('Failed to generate device ID:', error);
}
}
Best Practices
- API Key Security
- Never expose your API key in client-side code
- Use environment variables and server-side proxies when possible
-
Rotate API keys periodically
-
Error Handling
- Always implement proper error handling for SDK method calls
- Log errors appropriately for debugging
-
Provide user-friendly error messages in production
-
Resource Management
- Call destroy() when you're done using the SDK
- Clean up event listeners and callbacks
-
Monitor memory usage when handling large amounts of data
-
Performance Optimization
- Choose appropriate refresh intervals based on your use case
- Cache device parameters when appropriate
-
Implement rate limiting for API calls
-
Security Considerations
- Use HTTPS endpoints only
- Validate all server responses
- Implement proper access controls
- Monitor for suspicious patterns
Troubleshooting
Common Issues and Solutions
- API Key Invalid
- Verify your API key is correct
- Check if the API key has necessary permissions
-
Ensure the key hasn't expired
-
Network Errors
- Check your internet connection
- Verify the endpoint URL is correct
- Check for CORS issues
-
Ensure your firewall isn't blocking requests
-
Parameter Collection Fails
- Check browser permissions
- Verify required APIs are available
- Enable debug mode for detailed logging