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("your-firestore-url");
WaffleAuthFuncs.SetEndPoint("your-endpoint");
WaffleAuthFuncs.SetAPIKey("your-api-key");
WaffleAuthFuncs.MsgBoxes(true);

// Check for existing license
bool hasLicense = await WaffleAuthFuncs.Initialize();

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.

WaffleAuthFuncs.SetURL("your-firestore-url");

SetEndPoint(string endpointuser)

Sets the API endpoint used for license validation and queries.

WaffleAuthFuncs.SetEndPoint("your-endpoint-url");

SetAPIKey(string userapikey)

Sets the Firebase API key for authentication and database access.

WaffleAuthFuncs.SetAPIKey("your-api-key");

MsgBoxes(bool showMsgBoxes)

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

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

Key Management Functions

GenerateEarningKeyAsync(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.GenerateEarningKeyAsync(
    "https://example.com",  // Website to visit
    30,                     // Wait time in seconds
    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.

bool hasExistingLicense = await WaffleAuthFuncs.Initialize();

Implementation Example

Basic Form Implementation

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


using WaffleAuth;

namespace License_Tester
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            // Initial configuration
            WaffleAuthFuncs.SetURL("https://firestore.googleapis.com/v1/projects/waffleauth/databases/(default)/documents/licenses");
            WaffleAuthFuncs.SetAPIKey("YOUR-API-KEY");
            WaffleAuthFuncs.SetEndPoint("https://firestore.googleapis.com/v1/projects/waffleauth/databases/(default)/documents:runQuery?key=");
            WaffleAuthFuncs.SetInitials("LA");
            WaffleAuthFuncs.MsgBoxes(true);
            InitializeComponent();
        }

        // Generate new key button click handler
        private async void button1_Click(object sender, EventArgs e)
        {
            string generatedKey = await WaffleAuthFuncs.GenerateEarningKeyAsync(
                "https://youtube.com",  // Website to visit
                2,                      // Wait time in seconds
                24                      // License duration in hours
            );

            label1.Text = generatedKey;
        }

        // Validate key button click handler
        private async void button2_Click(object sender, EventArgs e)
        {
            bool isKeyValid = await WaffleAuthFuncs.CheckKey(textBox1.Text);

            if (!isKeyValid)
            {
                Application.Exit();
            }
        }
    }
}

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 async operations

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

Premium Features

Premium Activation

Enable premium features with your premium key:

// Add after InitializeComponent()
WaffleAuthFuncs.SetPremiumKey("YOUR-PREMIUM-KEY"); // Replace with your premium key

Discord Rich Presence Integration

Set up Discord Rich Presence integration:

// Configure Discord RPC
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
);

Advanced Key Generation

Generate custom key types:

// Generate a custom key type
string key = await WaffleAuthFuncs.GenerateEarningKeyAsync(
    "Freemium",           // Custom key type
    "https://youtube.com", // Website URL
    2,                    // Time on site (seconds)
    24                    // Key duration (hours)
);

Key Information

Access current key details:

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

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