v0.1.23 - Fixed auth rules on web page

This commit is contained in:
Your Name
2025-12-16 09:18:37 -04:00
parent 29e2421771
commit 0f420fc6d0
9 changed files with 14887 additions and 10735 deletions

View File

@@ -252,7 +252,7 @@ AUTH RULES MANAGEMENT
</div>
<!-- Auth Rules Table -->
<div id="authRulesTableContainer" style="display: none;">
<div id="authRulesTableContainer" class="config-table-container">
<table class="config-table" id="authRulesTable">
<thead>
<tr>
@@ -264,6 +264,9 @@ AUTH RULES MANAGEMENT
</tr>
</thead>
<tbody id="authRulesTableBody">
<tr>
<td colspan="5" style="text-align: center; font-style: italic;">Loading auth rules...</td>
</tr>
</tbody>
</table>
</div>
@@ -275,8 +278,8 @@ AUTH RULES MANAGEMENT
<div class="input-group">
<label for="authRulePubkey">Pubkey (nsec or hex):</label>
<input type="text" id="authRulePubkey" placeholder="nsec1... or 64-character hex pubkey">
<label for="authRulePubkey">Pubkey (npub or hex):</label>
<input type="text" id="authRulePubkey" placeholder="npub1... or 64-character hex pubkey">
</div>
<div id="whitelistWarning" class="warning-box" style="display: none;">

View File

@@ -1139,26 +1139,32 @@ function handleConfigUpdateResponse(responseData) {
// Handle auth query responses
function handleAuthQueryResponse(responseData) {
console.log('=== AUTH QUERY RESPONSE ===');
console.log('Full response:', responseData);
console.log('Query type:', responseData.query_type);
console.log('Total results:', responseData.total_results);
console.log('Count:', responseData.count);
console.log('Rules:', responseData.rules);
console.log('Data:', responseData.data);
// Backend can return rules in either 'rules' or 'data' field
const rulesArray = responseData.rules || responseData.data;
const rulesCount = responseData.count || responseData.total_results || 0;
// Update the current auth rules with the response data
if (responseData.data && Array.isArray(responseData.data)) {
currentAuthRules = responseData.data;
if (rulesArray && Array.isArray(rulesArray) && rulesArray.length > 0) {
currentAuthRules = rulesArray;
console.log('Updated currentAuthRules with', currentAuthRules.length, 'rules');
// Always show the auth rules table when we receive data (no VIEW RULES button anymore)
// Always show the auth rules table when we receive data
console.log('Auto-showing auth rules table since we received data...');
showAuthRulesTable();
updateAuthRulesStatus('loaded');
log(`Loaded ${responseData.total_results} auth rules from relay`, 'INFO');
log(`Loaded ${rulesCount} auth rules from relay`, 'INFO');
} else {
currentAuthRules = [];
console.log('No auth rules data received, cleared currentAuthRules');
// Show empty table (no VIEW RULES button anymore)
// Show empty table
console.log('Auto-showing auth rules table with empty data...');
showAuthRulesTable();
@@ -1167,10 +1173,10 @@ function handleAuthQueryResponse(responseData) {
}
if (typeof logTestEvent === 'function') {
logTestEvent('RECV', `Auth query response: ${responseData.query_type}, ${responseData.total_results} results`, 'AUTH_QUERY');
logTestEvent('RECV', `Auth query response: ${responseData.query_type}, ${rulesCount} results`, 'AUTH_QUERY');
if (responseData.data && responseData.data.length > 0) {
responseData.data.forEach((rule, index) => {
if (rulesArray && rulesArray.length > 0) {
rulesArray.forEach((rule, index) => {
logTestEvent('RECV', `Rule ${index + 1}: ${rule.rule_type} - ${rule.pattern_value || rule.rule_target}`, 'AUTH_RULE');
});
} else {
@@ -1219,16 +1225,16 @@ function handleAuthRuleResponse(responseData) {
console.log('=== AUTH RULE MODIFICATION RESPONSE ===');
console.log('Operation:', responseData.operation);
console.log('Status:', responseData.status);
console.log('Full response:', responseData);
// Handle auth rule addition/modification responses
if (responseData.status === 'success') {
const rulesProcessed = responseData.rules_processed || 0;
log(`Successfully processed ${rulesProcessed} auth rule modifications`, 'INFO');
// Refresh the auth rules display to show the new rules
if (authRulesTableContainer && authRulesTableContainer.style.display !== 'none') {
// Always refresh the auth rules display to show the new rules
console.log('Refreshing auth rules after successful modification...');
loadAuthRules();
}
} else {
log(`Failed to process auth rule modifications: ${responseData.message || 'Unknown error'}`, 'ERROR');
}
@@ -1654,7 +1660,6 @@ function displayAuthRules(rules) {
<td>${rule.enabled !== false ? 'Active' : 'Inactive'}</td>
<td>
<div class="inline-buttons">
<button onclick="editAuthRule(${index})" style="margin: 2px; padding: 4px 8px; font-size: 12px;">EDIT</button>
<button onclick="deleteAuthRule(${index})" style="margin: 2px; padding: 4px 8px; font-size: 12px;">DELETE</button>
</div>
</td>
@@ -1672,13 +1677,9 @@ function displayAuthRules(rules) {
function showAuthRulesTable() {
console.log('=== SHOW AUTH RULES TABLE DEBUG ===');
console.log('authRulesTableContainer element:', authRulesTableContainer);
console.log('Current display style:', authRulesTableContainer ? authRulesTableContainer.style.display : 'element not found');
if (authRulesTableContainer) {
authRulesTableContainer.style.display = 'block';
console.log('Set authRulesTableContainer display to block');
// If we already have cached auth rules, display them immediately
// Table is always visible now, just ensure we display the rules
if (currentAuthRules && currentAuthRules.length >= 0) {
console.log('Displaying cached auth rules:', currentAuthRules.length, 'rules');
displayAuthRules(currentAuthRules);
@@ -1985,14 +1986,14 @@ function addBlacklistRule() {
const inputValue = input.value.trim();
if (!inputValue) {
log('Please enter a pubkey or nsec', 'ERROR');
log('Please enter a pubkey or npub', 'ERROR');
return;
}
// Convert nsec or npub to hex if needed
// Convert npub to hex if needed
const hexPubkey = nsecToHex(inputValue);
if (!hexPubkey) {
log('Invalid pubkey format. Please enter nsec1..., npub1..., or 64-character hex', 'ERROR');
log('Invalid pubkey format. Please enter npub1... or 64-character hex', 'ERROR');
return;
}
@@ -2018,10 +2019,8 @@ function addBlacklistRule() {
log(`Pubkey ${hexPubkey.substring(0, 16)}... added to blacklist`, 'INFO');
input.value = '';
// Refresh auth rules display if visible
if (authRulesTableContainer && authRulesTableContainer.style.display !== 'none') {
// Always refresh auth rules display after adding
loadAuthRules();
}
})
.catch(error => {
log(`Failed to add rule: ${error.message}`, 'ERROR');
@@ -2037,14 +2036,14 @@ function addWhitelistRule() {
const inputValue = input.value.trim();
if (!inputValue) {
log('Please enter a pubkey or nsec', 'ERROR');
log('Please enter a pubkey or npub', 'ERROR');
return;
}
// Convert nsec or npub to hex if needed
// Convert npub to hex if needed
const hexPubkey = nsecToHex(inputValue);
if (!hexPubkey) {
log('Invalid pubkey format. Please enter nsec1..., npub1..., or 64-character hex', 'ERROR');
log('Invalid pubkey format. Please enter npub1... or 64-character hex', 'ERROR');
return;
}
@@ -2075,10 +2074,8 @@ function addWhitelistRule() {
log(`Pubkey ${hexPubkey.substring(0, 16)}... added to whitelist`, 'INFO');
input.value = '';
// Refresh auth rules display if visible
if (authRulesTableContainer && authRulesTableContainer.style.display !== 'none') {
// Always refresh auth rules display after adding
loadAuthRules();
}
})
.catch(error => {
log(`Failed to add rule: ${error.message}`, 'ERROR');

Binary file not shown.

Binary file not shown.

Binary file not shown.

4175
debug.log

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -10,8 +10,8 @@
// Version information (auto-updated by build system)
#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_PATCH 22
#define VERSION "v0.1.22"
#define VERSION_PATCH 23
#define VERSION "v0.1.23"
#include <stddef.h>
#include <stdint.h>