v0.3.11 - Working on admin api

This commit is contained in:
Your Name
2025-09-25 11:25:50 -04:00
parent be99595bde
commit 036b0823b9
9 changed files with 1635 additions and 201 deletions

View File

@@ -951,12 +951,12 @@
relayStatus.textContent = 'CONNECTED - SUBSCRIBING...';
relayStatus.className = 'status connected';
// Send REQ message to subscribe to kind 33334 events
// Send REQ message to subscribe to kind 23455 events (ephemeral config events)
const reqMessage = [
"REQ",
subscriptionId,
{
"kinds": [33334],
"kinds": [23455],
"limit": 50
}
];
@@ -1176,10 +1176,10 @@
'max_limit': 'Maximum Query Limit'
};
// Process configuration tags
// Process configuration tags (no d tag filtering for ephemeral events)
const configData = {};
event.tags.forEach(tag => {
if (tag.length >= 2 && tag[0] !== 'd') { // Skip 'd' tag (relay identifier)
if (tag.length >= 2) {
configData[tag[0]] = tag[1];
}
});
@@ -1270,26 +1270,23 @@
const formInputs = configForm.querySelectorAll('input, select');
const newTags = [];
// Preserve the 'd' tag (relay identifier) from original event
const dTag = currentConfig.tags.find(tag => tag[0] === 'd');
if (dTag) {
newTags.push(dTag);
}
// Add updated configuration tags
// Add updated configuration tags (no d tag needed for ephemeral events)
formInputs.forEach(input => {
if (!input.disabled && input.name) {
newTags.push([input.name, input.value]);
}
});
// Create new kind 33334 event
// Create new kind 23455 event (ephemeral configuration event)
const newEvent = {
kind: 33334,
kind: 23455,
pubkey: userPubkey,
created_at: Math.floor(Date.now() / 1000),
tags: newTags,
content: currentConfig.content || 'C Nostr Relay Configuration'
content: JSON.stringify({
action: 'update_config',
config_data: Object.fromEntries(newTags.filter(tag => tag[0] !== 'd'))
})
};
console.log('Signing event with window.nostr.signEvent()...');
@@ -1660,7 +1657,7 @@
try {
log(`Deleting auth rule: ${rule.rule_type} - ${rule.pattern_value || rule.rule_target}`, 'INFO');
// TODO: Implement actual rule deletion via WebSocket kind 33335 event
// TODO: Implement actual rule deletion via WebSocket kind 23456 event
// For now, just remove from local array
currentAuthRules.splice(index, 1);
displayAuthRules(currentAuthRules);
@@ -1746,7 +1743,7 @@
if (editingAuthRule) {
log(`Updating auth rule: ${ruleData.rule_type} - ${ruleData.pattern_value}`, 'INFO');
// TODO: Implement actual rule update via WebSocket kind 33335 event
// TODO: Implement actual rule update via WebSocket kind 23456 event
// For now, just update local array
currentAuthRules[editingAuthRule.index] = { ...ruleData, id: editingAuthRule.id || Date.now() };
@@ -1754,7 +1751,7 @@
} else {
log(`Adding new auth rule: ${ruleData.rule_type} - ${ruleData.pattern_value}`, 'INFO');
// TODO: Implement actual rule creation via WebSocket kind 33335 event
// TODO: Implement actual rule creation via WebSocket kind 23456 event
// For now, just add to local array
currentAuthRules.push({ ...ruleData, id: Date.now() });
@@ -2021,7 +2018,7 @@
});
}
// Add auth rule via WebSocket (kind 33335 event)
// Add auth rule via WebSocket (kind 23456 event)
async function addAuthRuleViaWebSocket(ruleData) {
if (!isLoggedIn || !userPubkey) {
throw new Error('Must be logged in to add auth rules');
@@ -2064,13 +2061,12 @@
dbPatternType = 'pubkey';
}
// Create kind 33335 auth rule event with database schema values
// Create kind 23456 auth rule event (ephemeral auth management)
const authEvent = {
kind: 33335,
kind: 23456,
pubkey: userPubkey,
created_at: Math.floor(Date.now() / 1000),
tags: [
['d', 'auth-rules'], // Addressable event identifier
[dbRuleType, dbPatternType, ruleData.pattern_value]
],
content: JSON.stringify({