The BioAuth SDK provides a simple interface for integrating biometric authentication into your applications.
npm install bioauth-sdk
Then import in your project:
import BioAuthSDK from '@/sdk';
Initialize the SDK with your API key:
const auth = new BioAuthSDK({
apiKey: 'YOUR_API_KEY',
baseURL: 'https://api.bioauth.com/v1' // Optional, defaults to production
});
Verify a user's biometric data:
const result = await auth.verifyBiometric({
faceImage: 'base64-encoded-image',
voiceSample: 'base64-encoded-audio',
userId: 'user-123'
});
Create, list, and revoke API keys:
// Create a new API key
const newKey = await auth.createApiKey('My New Key');
// List API keys
const keys = await auth.listApiKeys(limit, offset);
// Revoke an API key
await auth.revokeApiKey('key-id');
All methods throw errors that can be caught with try/catch:
try {
await auth.verifyBiometric(...);
} catch (error) {
console.error('Verification failed:', error);
}
The SDK is fully typed with TypeScript definitions included.
import BioAuthSDK from '@/sdk';
async function main() {
const auth = new BioAuthSDK({
apiKey: 'YOUR_API_KEY'
});
try {
// Verify biometrics
const verificationResult = await auth.verifyBiometric({
faceImage: 'base64-encoded-image',
voiceSample: 'base64-encoded-audio',
userId: 'user-123'
});
// Create API key
const newApiKey = await auth.createApiKey('My New Key');
console.log('Verification Result:', verificationResult);
console.log('New API Key:', newApiKey);
} catch (error) {
console.error('Error:', error);
}
}
main();
MIT