rauth-flutter

A lightweight, cross-platform Flutter/Dart library for adding reverse authentication via WhatsApp to your mobile or web apps.

This library allows you to generate a reverse authentication token in your Flutter application. The user verifies their identity via WhatsApp, and your app can send the session token to your backend for verification.

๐Ÿ”’ You must install rauth-provider on your Node.js backend to verify tokens issued by rauth-flutter.


โœ… Features

๐Ÿ“ฑ Client-Side Reverse Auth โ€“ Generate session tokens from your Flutter app without traditional OTP flows.

๐ŸŒ Cross-Platform โ€“ Works on Android, iOS, and Web (Flutter web).

๐Ÿ’ฌ WhatsApp-Based Verification โ€“ Lets users verify themselves via WhatsApp without requiring any SMS.

๐Ÿงฉ Plug-and-Play SDK โ€“ Just call RauthClient.init() with appId and phone number, and you're done.

๐Ÿ” Secure Token Generation โ€“ Uses HMAC signatures to prevent tampering or spoofing.

๐Ÿ–ผ QR + Link Options โ€“ Automatically returns a WhatsApp Web link and QR image for alternate login devices.

๐Ÿงช Easy Testing & Debugging โ€“ Returns session token, WhatsApp link, and QR image for easy integration.

๐Ÿš€ Production Ready โ€“ Designed to integrate securely with your backend for session verification via rauth-provider.


๐Ÿ”ง Install

Add to your pubspec.yaml:

dependencies:
  rauth_flutter:
    path: ../rauth-flutter # or use your published version

Then run:

flutter pub get

๐Ÿ“ฆ Prerequisites

  1. Create a free account at https://rauth.io
  2. Generate your appId and appSecret from the dashboard.
  3. Use this library in your Flutter app.
  4. Use rauth-provider on your backend to verify tokens.

๐Ÿ’ก Usage

Basic Example

import 'package:rauth_flutter/rauth_flutter.dart';

final client = RauthClient(appId: 'your-app-id', appSecret: 'your-app-secret');
final session = await client.init(phone: '+917000000000');

print('Session Token: \\${session.sessionToken}');
print('WhatsApp Link: \\${session.waLink}');
print('QR Image (base64): \\${session.qrImageLink}');

With UI (see demo app)

  • Input phone number
  • Call RauthClient.init(phone: ...)
  • Show QR code and WhatsApp link to user

๐Ÿ” Backend Verification Example

After the user verifies via WhatsApp, send the session token to your backend:

POST /login

{
  "phone": "+917000000000",
  "token": "dfsdf-fdsdfsdfsd-dsfsdfg84-fsadfgsdag"
}

Your backend (using rauth-provider) should validate the token and return a JWT or session data if verified.


๐Ÿ“ License

MIT

Libraries

rauth_flutter