UNPKG

sms-verifier

Version:

ESP32 + SIM800L ile çalışan basit SMS doğrulama kütüphanesi

44 lines (40 loc) 956 B
const axios = require('axios'); class SmsVerifier { constructor({ espUrl, apiKey }) { this.axios = axios.create({ baseURL: espUrl, headers: { 'Content-Type': 'application/json', 'X-API-Key': apiKey } }); } async sendCode(phone) { try { // ESP32'ye sadece telefon numarası gönder const res = await this.axios.post('/send', { phone }); return { status: 'success', message: 'Doğrulama kodu gönderildi' }; } catch (error) { return { status: 'error', message: error.message }; } } async verifyCode(phone, code) { try { // ESP32'den doğrulama kontrolü const res = await this.axios.post('/verify', { phone, code }); return res.data.success; } catch (error) { return false; } } } module.exports = { SmsVerifier };