fayda-auth-client
v1.0.4
Published
JavaScript/TypeScript SDK for Fayda IDA (Identity Authentication) services. Provides a simple and intuitive interface for OTP generation, Yes/No authentication, and eKYC (Electronic Know Your Customer) operations. Features: - OTP Management: Request and v
Downloads
399
Readme
Fayda Auth Client - JavaScript/TypeScript
JavaScript/TypeScript SDK for Fayda IDA (Identity Authentication) services. Provides a simple and intuitive interface for OTP generation, Yes/No authentication, and eKYC (Electronic Know Your Customer) operations. Features: - OTP Management: Request and validate OTPs for Fayda ID verification - Yes/No Authentication: Perform authentication using OTP challenges - eKYC Services: Retrieve verified identity details securely - Cryptographic Security: Supports RSA-OAEP encryption, AES-GCM decryption, and JWT signing/verification - PKCS12 Key Support: Secure key and certificate management using PKCS12 keystores - Flexible Configuration: Supports environment variables and programmatic configuration - Robust Reliability: Comprehensive error handling, logging, and response validation Designed for seamless integration with Node.js and TypeScript applications interacting with Fayda IDA services.
Features
- Framework Agnostic - Works with any Node.js application
- TypeScript Support - Full TypeScript definitions included
- Easy Integration - Simple factory pattern for instantiation
- Complete API Support - OTP, Authentication, and eKYC endpoints
- Cryptographic Security - RSA-OAEP encryption, AES-GCM decryption, and JWT signing
- PKCS12 Key Support - Secure key and certificate management
Installation
npm install fayda-auth-clientConfiguration
Create a configuration object with the following required properties:
const config = {
// Base Configuration
'fayda.base.url': 'https://base_url.fayda.et',
'fayda.partner.id': 'your-partner-id',
'fayda.env': 'Staging',
// Authentication Credentials
'clientId': 'your-client-id',
'secretKey': 'your-secret-key',
'appId': 'your_app_id',
// Partner Credentials
'partnerId': 'your-partner-id',
'partnerApiKey': 'your-api-key',
'mispLicenseKey': 'your-license-key',
'ida.reference.id': 'PARTNER',
// Certificate Paths
'p12.path': './keys',
'p12.password': 'your-password',
// SSL Configuration
'ida.ssl.verify': 'false',
// URLs (auto-constructed from base URL)
'ida.otp.url': '${fayda.base.url}/idauthentication/v1/otp/${mispLicenseKey}/${partnerId}/${partnerApiKey}',
'ida.auth.url': '${fayda.base.url}/idauthentication/v1/auth/${mispLicenseKey}/${partnerId}/${partnerApiKey}',
'ida.ekyc.url': '${fayda.base.url}/idauthentication/v1/kyc/${mispLicenseKey}/${partnerId}/${partnerApiKey}',
'ida.certificate.url': '${fayda.base.url}/idauthentication/v1/internal/getCertificate',
'ida.authmanager.url': '${fayda.base.url}/v1/authmanager/authenticate/clientidsecretkey'
};Quick Start
import { IdaClientFactory, OtpRequestDTO, AuthRequestDTO } from 'fayda-auth-client';
// Create client
const client = IdaClientFactory.createClient(config);
const otpRequest: OtpRequestDTO = {
individualId: '1234567890123456',
individualIdType: 'FAN',
requestTime: new Date().toISOString(),
otpChannel: ['EMAIL', 'PHONE']
};
const otpResponse = await client.requestOtp(otpRequest);
// Authenticate
const authRequest: AuthRequestDTO = {
id: 'fayda.identity.auth',
version: '1.0',
transactionID: '1234567890',
requestTime: new Date().toISOString(),
consentObtained: true,
individualId: '1234567890123456',
individualIdType: 'FAN',
otp: '123456',
requestedAuth: {
otp: true
}
};
const authResponse = await client.authenticate(authRequest);
// Perform eKYC
const ekycRequest: AuthRequestDTO = {
id: 'fayda.identity.auth',
version: '1.0',
transactionID: '1234567890',
requestTime: new Date().toISOString(),
consentObtained: true,
individualId: '1234567890123456',
individualIdType: 'FAN',
otp: '123456',
requestedAuth: {
otp: true,
demo: true
}
};
const ekycResponse = await client.performEkyc(ekycRequest);Building
npm install
npm run buildPublishing to npm
npm login
npm publish --access publicLicense
Apache License 2.0
