2024-12-13 09:57:12 +00:00
|
|
|
{% extends "base.html" %}
|
|
|
|
{% block content %}
|
|
|
|
<div class="min-h-screen bg-dark py-8 px-4">
|
|
|
|
<div class="max-w-xl mx-auto bg-dark-lighter rounded-lg shadow-lg p-6">
|
|
|
|
<h1 class="text-2xl font-bold mb-6 text-center">Subscribe to VPN Service</h1>
|
|
|
|
<form id="subscription-form" class="space-y-6">
|
|
|
|
<div>
|
2024-12-30 06:03:07 +00:00
|
|
|
<label class="block text-sm font-medium mb-2">User ID</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="user-id"
|
|
|
|
readonly
|
|
|
|
class="w-full px-3 py-2 bg-dark border border-gray-600 rounded-md text-white focus:outline-none focus:border-blue-500 font-mono text-sm"
|
2024-12-13 09:57:12 +00:00
|
|
|
>
|
2024-12-30 06:03:07 +00:00
|
|
|
<p class="mt-1 text-sm text-gray-400">Save this ID - you'll need it to manage your subscription</p>
|
2024-12-13 09:57:12 +00:00
|
|
|
</div>
|
|
|
|
|
2024-12-30 06:03:07 +00:00
|
|
|
<div>
|
|
|
|
<label class="block text-sm font-medium mb-2">WireGuard Public Key</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="public-key"
|
|
|
|
readonly
|
|
|
|
class="w-full px-3 py-2 bg-dark border border-gray-600 rounded-md text-white focus:outline-none focus:border-blue-500 font-mono text-sm"
|
|
|
|
>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
id="regenerate-keys"
|
|
|
|
class="mt-2 w-full px-3 py-2 bg-dark border border-gray-600 rounded-md text-white hover:bg-gray-800 transition-colors"
|
|
|
|
>
|
|
|
|
Regenerate Keys
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2024-12-13 09:57:12 +00:00
|
|
|
<div>
|
|
|
|
<label class="block text-sm font-medium mb-2">Duration</label>
|
|
|
|
<div class="space-y-4">
|
2024-12-30 06:03:07 +00:00
|
|
|
<input
|
|
|
|
type="range"
|
|
|
|
id="duration-slider"
|
|
|
|
min="1"
|
|
|
|
max="720"
|
2024-12-13 09:57:12 +00:00
|
|
|
value="24"
|
|
|
|
class="w-full"
|
|
|
|
>
|
|
|
|
<div class="flex justify-between text-sm text-gray-400">
|
|
|
|
<button type="button" data-hours="1" class="duration-preset hover:text-blue-400">1 Hour</button>
|
|
|
|
<button type="button" data-hours="24" class="duration-preset hover:text-blue-400">1 Day</button>
|
|
|
|
<button type="button" data-hours="168" class="duration-preset hover:text-blue-400">1 Week</button>
|
|
|
|
<button type="button" data-hours="720" class="duration-preset hover:text-blue-400">1 Month</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<p id="duration-display" class="mt-2 text-center text-gray-400"></p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="text-center">
|
|
|
|
<p class="text-2xl font-bold text-blue-400">
|
|
|
|
<span id="price-display">-</span> sats
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
2024-12-30 06:03:07 +00:00
|
|
|
<button
|
2024-12-13 09:57:12 +00:00
|
|
|
type="submit"
|
|
|
|
class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded transition-colors"
|
|
|
|
>
|
|
|
|
Pay with Bitcoin
|
|
|
|
</button>
|
2024-12-30 06:03:07 +00:00
|
|
|
|
|
|
|
<div class="mt-4 text-sm text-gray-400 space-y-1">
|
|
|
|
<p>• Keys are generated securely in your browser</p>
|
|
|
|
<p>• Your private key never leaves your device</p>
|
|
|
|
<p>• Configuration will be available after payment</p>
|
|
|
|
</div>
|
2024-12-13 09:57:12 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-12-30 07:07:53 +00:00
|
|
|
<script type="module">
|
|
|
|
import { WireGuard } from '/static/js/utils/wireguard.js';
|
|
|
|
import { Pricing } from '/static/js/pricing.js';
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', async function() {
|
|
|
|
const userId = Date.now().toString(); // Generate a unique user ID without prefix
|
|
|
|
document.getElementById('user-id').value = userId;
|
|
|
|
|
|
|
|
// Generate keys and set public key
|
|
|
|
const keyPair = await WireGuard.generateKeys();
|
|
|
|
document.getElementById('public-key').value = keyPair.publicKey;
|
|
|
|
|
|
|
|
// Store keys in local storage
|
|
|
|
WireGuard.saveKeys(userId, keyPair);
|
|
|
|
|
|
|
|
// Initialize pricing
|
|
|
|
Pricing.init({
|
|
|
|
formId: 'subscription-form',
|
|
|
|
sliderId: 'duration-slider',
|
|
|
|
priceDisplayId: 'price-display',
|
|
|
|
durationDisplayId: 'duration-display',
|
|
|
|
presetButtonClass: 'duration-preset'
|
|
|
|
});
|
|
|
|
|
|
|
|
// Regenerate keys button
|
|
|
|
document.getElementById('regenerate-keys').addEventListener('click', async function() {
|
|
|
|
const newKeyPair = await WireGuard.generateKeys();
|
|
|
|
document.getElementById('public-key').value = newKeyPair.publicKey;
|
|
|
|
WireGuard.saveKeys(userId, newKeyPair);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
2024-12-13 09:57:12 +00:00
|
|
|
{% endblock %}
|