WaffleAuth Documentation

Getting Started

WaffleAuth is a powerful license key system for C# applications, specifically designed for XAML and WinForms projects. It provides robust license management with HWID binding and Discord Rich Presence integration.

Installation Steps:

  1. Add WaffleAuth.dll as a reference in your project
  2. Add the following using statement:
  3. using WaffleAuth;
  4. Configure your Firebase/Firestore database
  5. Set up your API endpoints

Requirements

Required NuGet Packages

WaffleAuth requires the following NuGet packages to be installed in your project:

  • Discord Rich Presence
  • Newtonsoft.Json

Installing NuGet Packages

You can install these packages using either:

Visual Studio NuGet Package Manager:

  1. Right-click your project in Solution Explorer
  2. Select "Manage NuGet Packages..."
  3. Search for each required package
  4. Click "Install" for each package

Package Manager Console:

Install-Package DiscordRichPresence
Install-Package Newtonsoft.Json

Note: Make sure to install these packages before trying to use WaffleAuth functionality.

Configuration Functions

Initial Configuration

Configure WaffleAuth at the start of your application:

// Required configuration
WaffleAuthFuncs.SetInitials("APP");
WaffleAuthFuncs.SetURL("https://firestore.googleapis.com/v1/projects/your-project-name/databases/(default)/documents");
WaffleAuthFuncs.SetEndPoint("https://firestore.googleapis.com/v1/projects/your-project-name/databases/(default)/documents:runQuery?key=");
WaffleAuthFuncs.SetAPIKey("YOUR-API-KEY");
WaffleAuthFuncs.SetActivationKey("KEY-HERE"); // Required activation key
WaffleAuthFuncs.Mode = "key"; // Set authentication mode
WaffleAuthFuncs.MsgBoxes(true);

Firebase Collections Setup

WaffleAuth requires two collections in your Firebase Firestore database:

  • licenses - Collection for storing license key data
  • accounts - Collection for storing user account data when using account mode

Important: Both collections must be created in your Firestore database before using WaffleAuth. The system will not automatically create these collections.

SetInitials(string userInitials)

Sets the prefix for generated license keys. This will appear before the hyphen in all generated keys.

WaffleAuthFuncs.SetInitials("APP");

Result format: APP-XXXXXXXXXXXXX

SetURL(string userURL)

Sets the Firestore database URL where license information will be stored. The URL should be in this format:

https://firestore.googleapis.com/v1/projects/your-project-name/databases/(default)/documents
WaffleAuthFuncs.SetURL("https://firestore.googleapis.com/v1/projects/your-project-name/databases/(default)/documents");

SetEndPoint(string endpointuser)

Sets the API endpoint used for license validation and queries.

WaffleAuthFuncs.SetEndPoint("https://firestore.googleapis.com/v1/projects/your-project-name/databases/(default)/documents:runQuery?key=");

SetAPIKey(string userapikey)

Sets the Firebase API key for authentication and database access.

WaffleAuthFuncs.SetAPIKey("YOUR-API-KEY");

SetActivationKey(string activationKey)

Sets the activation key required for the system to function. This must be set before using any other functionality.

WaffleAuthFuncs.SetActivationKey("KEY-HERE");

Mode(string mode)

Sets the authentication mode - either "key" for license key system or "account" for username/password authentication.

WaffleAuthFuncs.Mode = "key";     // Use license key system
WaffleAuthFuncs.Mode = "account"; // Use account system

MsgBoxes(bool showMsgBoxes)

Controls whether the system shows message box notifications for various events.

WaffleAuthFuncs.MsgBoxes(true);  // Enable notifications
WaffleAuthFuncs.MsgBoxes(false); // Disable notifications

Discord Rich Presence Configuration (Optional)

Set up Discord Rich Presence integration if desired:


// Configure Discord RPC (Optional)
WaffleAuthFuncs.SetRPCAppID("1320047337518928004"); // Your Discord App ID

// Initialize Rich Presence
WaffleAuthFuncs.InitializeDiscordRP(
    "Your Subtitle",      // Subtitle text
    "Your Description",   // Description text
    "large_image",        // Large image asset name
    "Large Image Text",   // Large image hover text 
    "small_image",        // Small image asset name
    "Small Image Text"    // Small image hover text
);

Key Management Functions

GenerateEarningKey(string keyType, string websiteUrl, int timeInSeconds, int customDurationInHours)

Generates a license key after the user visits a specified website for a set duration.

string key = await WaffleAuthFuncs.GenerateEarningKey(
    "free",                // Key type  
    "https://example.com", // Website to visit
    30,                    // Wait time in seconds
    24                     // License duration in hours
);

GenerateKey(string keyType, int customDurationInHours)

Generates a license key immediately with specified duration.

string key = await WaffleAuthFuncs.GenerateKey(
    "premium",            // Key type
    24                    // License duration in hours
);

CheckKey(string licenseKey)

Validates a license key independently. Use this for manual key validation.

bool isValid = await WaffleAuthFuncs.CheckKey("APP-XXXXXXXXXXXXX");

Initialize()

Checks for any existing valid licenses on the current machine. Useful for automatic login.

private void Init()
{
    bool hasExistingLicense = await WaffleAuthFuncs.Initialize();
    {
        if (hasExistingLicense)
        {
            // Your code here for valid license
        }
    }
}

Call this method when your application starts to check for existing valid licenses.

Key Information Functions

Access current key details:


// Get the current key type
string keyType = await WaffleAuthFuncs.GetType();

// Get the current key string
string currentKey = WaffleAuthFuncs.CurrentLogin;
// Can be used like: label1.Text = WaffleAuthFuncs.CurrentLogin;

Implementation Example

Basic Form Implementation

Here's a complete example of implementing WaffleAuth in a Windows Forms application:

using WaffleAuth;

namespace Le_Login_Tester
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            WaffleAuthFuncs.Mode = "accounts";
            WaffleAuthFuncs.SetActivationKey("KEY-HERE");
            WaffleAuthFuncs.SetURL("https://firestore.googleapis.com/v1/projects/your-project-name/databases/(default)/documents");
            WaffleAuthFuncs.SetEndPoint("https://firestore.googleapis.com/v1/projects/your-project-name/databases/(default)/documents:runQuery?key=");
            WaffleAuthFuncs.SetAPIKey("YOUR-API-KEY");
            WaffleAuthFuncs.MsgBoxes(true);
            WaffleAuthFuncs.Initialize();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            bool success = await WaffleAuthFuncs.CreateAccount("free", UsernameCreate.Text, PasswordCreate.Text);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            bool isValid = await WaffleAuthFuncs.CheckAccount(UsernameLogin.Text, PasswordLogin.Text);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            CurrentLabel.Text = WaffleAuthFuncs.CurrentLogin;
        }

        private async void button4_Click(object sender, EventArgs e)
        {
            TypeLabel.Text = await WaffleAuthFuncs.GetType();
        }

        private async void button6_Click(object sender, EventArgs e)
        {
            string key = await WaffleAuthFuncs.GenerateKey("free", 10);
            textBox2.Text = key;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            bool isValid = await WaffleAuthFuncs.CheckKey(keybox.Text);
        }
    }
}

Important Implementation Notes

  • Always configure WaffleAuth in your form's constructor before InitializeComponent()
  • Handle key validation failures appropriately for your application
  • Store sensitive information like API keys securely
  • Consider implementing a loading indicator during operations

Account Management Functions

CreateAccount(string accountType, string username, string password)

Creates a new user account with the specified type and credentials.

bool success = await WaffleAuthFuncs.CreateAccount(
    "free",             // Account type
    "username",         // Username 
    "password"          // Password
);

CheckAccount(string username, string password)

Validates user account credentials.

bool isValid = await WaffleAuthFuncs.CheckAccount(
    "username",         // Username
    "password"          // Password
);

Account Information Functions

Access current account details:

// Get the current account type
string accountType = await WaffleAuthFuncs.GetType();

// Get the current logged in username 
string currentUser = WaffleAuthFuncs.CurrentLogin;

Addons

Loading Addons

WaffleAuth supports loading external addons via DLL files. Place addon DLLs in the automatically created "Addons" folder.

Running Addon Methods

Use the AddonManager to execute methods from loaded addons:

// Basic method call
AddonManager.RunAddonMethod("MyAddon.dll", "MethodName");

// With parameters
AddonManager.RunAddonMethod("MyAddon.dll", "MethodName", "param1", true, 42);

Note: Parameters after the method name are optional and should match the method signature in the addon DLL.

Creating Custom Addons

Creating Custom Addons

Here's a basic template for creating your own WaffleAuth addon:

using System;
using System.Windows.Forms;

namespace ExampleAddon
{
    public class MainClass
    {
        public static void PrintMessage(string message)
        {
            MessageBox.Show($"Test: {message}");
        }
    }
}

Note: Make sure to compile your addon as a DLL and place it in the Addons folder.

Troubleshooting

Common Issues

  • Invalid API Key: Ensure your Firebase API key is correctly set and has necessary permissions
  • Database Connection: Verify your Firestore URL and endpoint configurations
  • HWID Mismatch: Keys are bound to specific machines and cannot be transferred
  • Expired Keys: Check the duration set during key generation