Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
640386e2c1 | ||
|
|
840a5bbf5f | ||
|
|
0f420fc6d0 |
@@ -252,7 +252,7 @@ AUTH RULES MANAGEMENT
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Auth Rules Table -->
|
<!-- Auth Rules Table -->
|
||||||
<div id="authRulesTableContainer" style="display: none;">
|
<div id="authRulesTableContainer" class="config-table-container">
|
||||||
<table class="config-table" id="authRulesTable">
|
<table class="config-table" id="authRulesTable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -264,6 +264,9 @@ AUTH RULES MANAGEMENT
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="authRulesTableBody">
|
<tbody id="authRulesTableBody">
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" style="text-align: center; font-style: italic;">Loading auth rules...</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -275,8 +278,8 @@ AUTH RULES MANAGEMENT
|
|||||||
|
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label for="authRulePubkey">Pubkey (nsec or hex):</label>
|
<label for="authRulePubkey">Pubkey (npub or hex):</label>
|
||||||
<input type="text" id="authRulePubkey" placeholder="nsec1... or 64-character hex pubkey">
|
<input type="text" id="authRulePubkey" placeholder="npub1... or 64-character hex pubkey">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="whitelistWarning" class="warning-box" style="display: none;">
|
<div id="whitelistWarning" class="warning-box" style="display: none;">
|
||||||
|
|||||||
63
api/index.js
63
api/index.js
@@ -1139,26 +1139,32 @@ function handleConfigUpdateResponse(responseData) {
|
|||||||
// Handle auth query responses
|
// Handle auth query responses
|
||||||
function handleAuthQueryResponse(responseData) {
|
function handleAuthQueryResponse(responseData) {
|
||||||
console.log('=== AUTH QUERY RESPONSE ===');
|
console.log('=== AUTH QUERY RESPONSE ===');
|
||||||
|
console.log('Full response:', responseData);
|
||||||
console.log('Query type:', responseData.query_type);
|
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);
|
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
|
// Update the current auth rules with the response data
|
||||||
if (responseData.data && Array.isArray(responseData.data)) {
|
if (rulesArray && Array.isArray(rulesArray) && rulesArray.length > 0) {
|
||||||
currentAuthRules = responseData.data;
|
currentAuthRules = rulesArray;
|
||||||
console.log('Updated currentAuthRules with', currentAuthRules.length, 'rules');
|
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...');
|
console.log('Auto-showing auth rules table since we received data...');
|
||||||
showAuthRulesTable();
|
showAuthRulesTable();
|
||||||
|
|
||||||
updateAuthRulesStatus('loaded');
|
updateAuthRulesStatus('loaded');
|
||||||
log(`Loaded ${responseData.total_results} auth rules from relay`, 'INFO');
|
log(`Loaded ${rulesCount} auth rules from relay`, 'INFO');
|
||||||
} else {
|
} else {
|
||||||
currentAuthRules = [];
|
currentAuthRules = [];
|
||||||
console.log('No auth rules data received, cleared 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...');
|
console.log('Auto-showing auth rules table with empty data...');
|
||||||
showAuthRulesTable();
|
showAuthRulesTable();
|
||||||
|
|
||||||
@@ -1167,10 +1173,10 @@ function handleAuthQueryResponse(responseData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof logTestEvent === 'function') {
|
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) {
|
if (rulesArray && rulesArray.length > 0) {
|
||||||
responseData.data.forEach((rule, index) => {
|
rulesArray.forEach((rule, index) => {
|
||||||
logTestEvent('RECV', `Rule ${index + 1}: ${rule.rule_type} - ${rule.pattern_value || rule.rule_target}`, 'AUTH_RULE');
|
logTestEvent('RECV', `Rule ${index + 1}: ${rule.rule_type} - ${rule.pattern_value || rule.rule_target}`, 'AUTH_RULE');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -1219,16 +1225,16 @@ function handleAuthRuleResponse(responseData) {
|
|||||||
console.log('=== AUTH RULE MODIFICATION RESPONSE ===');
|
console.log('=== AUTH RULE MODIFICATION RESPONSE ===');
|
||||||
console.log('Operation:', responseData.operation);
|
console.log('Operation:', responseData.operation);
|
||||||
console.log('Status:', responseData.status);
|
console.log('Status:', responseData.status);
|
||||||
|
console.log('Full response:', responseData);
|
||||||
|
|
||||||
// Handle auth rule addition/modification responses
|
// Handle auth rule addition/modification responses
|
||||||
if (responseData.status === 'success') {
|
if (responseData.status === 'success') {
|
||||||
const rulesProcessed = responseData.rules_processed || 0;
|
const rulesProcessed = responseData.rules_processed || 0;
|
||||||
log(`Successfully processed ${rulesProcessed} auth rule modifications`, 'INFO');
|
log(`Successfully processed ${rulesProcessed} auth rule modifications`, 'INFO');
|
||||||
|
|
||||||
// Refresh the auth rules display to show the new rules
|
// Always refresh the auth rules display to show the new rules
|
||||||
if (authRulesTableContainer && authRulesTableContainer.style.display !== 'none') {
|
console.log('Refreshing auth rules after successful modification...');
|
||||||
loadAuthRules();
|
loadAuthRules();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
log(`Failed to process auth rule modifications: ${responseData.message || 'Unknown error'}`, 'ERROR');
|
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>${rule.enabled !== false ? 'Active' : 'Inactive'}</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="inline-buttons">
|
<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>
|
<button onclick="deleteAuthRule(${index})" style="margin: 2px; padding: 4px 8px; font-size: 12px;">DELETE</button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -1672,13 +1677,9 @@ function displayAuthRules(rules) {
|
|||||||
function showAuthRulesTable() {
|
function showAuthRulesTable() {
|
||||||
console.log('=== SHOW AUTH RULES TABLE DEBUG ===');
|
console.log('=== SHOW AUTH RULES TABLE DEBUG ===');
|
||||||
console.log('authRulesTableContainer element:', authRulesTableContainer);
|
console.log('authRulesTableContainer element:', authRulesTableContainer);
|
||||||
console.log('Current display style:', authRulesTableContainer ? authRulesTableContainer.style.display : 'element not found');
|
|
||||||
|
|
||||||
if (authRulesTableContainer) {
|
if (authRulesTableContainer) {
|
||||||
authRulesTableContainer.style.display = 'block';
|
// Table is always visible now, just ensure we display the rules
|
||||||
console.log('Set authRulesTableContainer display to block');
|
|
||||||
|
|
||||||
// If we already have cached auth rules, display them immediately
|
|
||||||
if (currentAuthRules && currentAuthRules.length >= 0) {
|
if (currentAuthRules && currentAuthRules.length >= 0) {
|
||||||
console.log('Displaying cached auth rules:', currentAuthRules.length, 'rules');
|
console.log('Displaying cached auth rules:', currentAuthRules.length, 'rules');
|
||||||
displayAuthRules(currentAuthRules);
|
displayAuthRules(currentAuthRules);
|
||||||
@@ -1985,14 +1986,14 @@ function addBlacklistRule() {
|
|||||||
|
|
||||||
const inputValue = input.value.trim();
|
const inputValue = input.value.trim();
|
||||||
if (!inputValue) {
|
if (!inputValue) {
|
||||||
log('Please enter a pubkey or nsec', 'ERROR');
|
log('Please enter a pubkey or npub', 'ERROR');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert nsec or npub to hex if needed
|
// Convert npub to hex if needed
|
||||||
const hexPubkey = nsecToHex(inputValue);
|
const hexPubkey = nsecToHex(inputValue);
|
||||||
if (!hexPubkey) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2018,10 +2019,8 @@ function addBlacklistRule() {
|
|||||||
log(`Pubkey ${hexPubkey.substring(0, 16)}... added to blacklist`, 'INFO');
|
log(`Pubkey ${hexPubkey.substring(0, 16)}... added to blacklist`, 'INFO');
|
||||||
input.value = '';
|
input.value = '';
|
||||||
|
|
||||||
// Refresh auth rules display if visible
|
// Always refresh auth rules display after adding
|
||||||
if (authRulesTableContainer && authRulesTableContainer.style.display !== 'none') {
|
loadAuthRules();
|
||||||
loadAuthRules();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
log(`Failed to add rule: ${error.message}`, 'ERROR');
|
log(`Failed to add rule: ${error.message}`, 'ERROR');
|
||||||
@@ -2037,14 +2036,14 @@ function addWhitelistRule() {
|
|||||||
|
|
||||||
const inputValue = input.value.trim();
|
const inputValue = input.value.trim();
|
||||||
if (!inputValue) {
|
if (!inputValue) {
|
||||||
log('Please enter a pubkey or nsec', 'ERROR');
|
log('Please enter a pubkey or npub', 'ERROR');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert nsec or npub to hex if needed
|
// Convert npub to hex if needed
|
||||||
const hexPubkey = nsecToHex(inputValue);
|
const hexPubkey = nsecToHex(inputValue);
|
||||||
if (!hexPubkey) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2075,10 +2074,8 @@ function addWhitelistRule() {
|
|||||||
log(`Pubkey ${hexPubkey.substring(0, 16)}... added to whitelist`, 'INFO');
|
log(`Pubkey ${hexPubkey.substring(0, 16)}... added to whitelist`, 'INFO');
|
||||||
input.value = '';
|
input.value = '';
|
||||||
|
|
||||||
// Refresh auth rules display if visible
|
// Always refresh auth rules display after adding
|
||||||
if (authRulesTableContainer && authRulesTableContainer.style.display !== 'none') {
|
loadAuthRules();
|
||||||
loadAuthRules();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
log(`Failed to add rule: ${error.message}`, 'ERROR');
|
log(`Failed to add rule: ${error.message}`, 'ERROR');
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
BIN
build/main.o
BIN
build/main.o
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -10,8 +10,8 @@
|
|||||||
// Version information (auto-updated by build system)
|
// Version information (auto-updated by build system)
|
||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 1
|
#define VERSION_MINOR 1
|
||||||
#define VERSION_PATCH 22
|
#define VERSION_PATCH 25
|
||||||
#define VERSION "v0.1.22"
|
#define VERSION "v0.1.25"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -11,8 +11,13 @@ SERVER_URL="https://localhost:9443"
|
|||||||
UPLOAD_ENDPOINT="${SERVER_URL}/upload"
|
UPLOAD_ENDPOINT="${SERVER_URL}/upload"
|
||||||
TEST_FILE="test_blob_$(date +%s).txt"
|
TEST_FILE="test_blob_$(date +%s).txt"
|
||||||
CLEANUP_FILES=()
|
CLEANUP_FILES=()
|
||||||
NOSTR_PRIVKEY="22cc83aa57928a2800234c939240c9a6f0f44a33ea3838a860ed38930b195afd"
|
NOSTR_PRIVKEY="39079f9fbdead31b5ec1724479e62c892a6866699c7873613c19832caff447bd"
|
||||||
NOSTR_PUBKEY="8ff74724ed641b3c28e5a86d7c5cbc49c37638ace8c6c38935860e7a5eedde0e"
|
NOSTR_PUBKEY="2a38db7fc1ffdabb43c79b5ad525f7d97102d4d235efc257dfd1514571f8159f"
|
||||||
|
# NOSTR_PRIVKEY="22cc83aa57928a2800234c939240c9a6f0f44a33ea3838a860ed38930b195afd"
|
||||||
|
# NOSTR_PUBKEY="8ff74724ed641b3c28e5a86d7c5cbc49c37638ace8c6c38935860e7a5eedde0e"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Colors for output
|
# Colors for output
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
|
|||||||
Reference in New Issue
Block a user