v0.3.10 - .

This commit is contained in:
Your Name
2025-09-24 10:49:48 -04:00
parent 01836a4b4c
commit be99595bde
7 changed files with 822 additions and 133 deletions

View File

@@ -1250,6 +1250,7 @@
console.log('Exited edit mode');
}
async function saveConfiguration() {
if (!isLoggedIn || !userPubkey) {
console.log('Must be logged in to save configuration');
@@ -1291,9 +1292,9 @@
content: currentConfig.content || 'C Nostr Relay Configuration'
};
console.log('Signing event with window.nostr...');
console.log('Signing event with window.nostr.signEvent()...');
// Sign the event using window.nostr (NIP-07 interface)
// Sign the event using the standard NIP-07 interface
const signedEvent = await window.nostr.signEvent(newEvent);
if (!signedEvent || !signedEvent.sig) {
@@ -1941,13 +1942,8 @@
return;
}
// Show warning about whitelist-only mode
if (warningDiv) {
warningDiv.style.display = 'block';
}
statusDiv.className = 'rule-status warning';
statusDiv.textContent = 'Adding to whitelist (will enable whitelist-only mode)...';
statusDiv.className = 'rule-status';
statusDiv.textContent = 'Adding to whitelist...';
// Create auth rule data
const ruleData = {
@@ -2038,33 +2034,64 @@
try {
log(`Adding auth rule: ${ruleData.rule_type} - ${ruleData.pattern_value.substring(0, 16)}...`, 'INFO');
// Create kind 33335 auth rule event
// Map client-side rule types to database schema values
let dbRuleType, dbPatternType, dbAction;
switch (ruleData.rule_type) {
case 'pubkey_blacklist':
dbRuleType = 'blacklist';
dbPatternType = 'pubkey';
dbAction = 'deny';
break;
case 'pubkey_whitelist':
dbRuleType = 'whitelist';
dbPatternType = 'pubkey';
dbAction = 'allow';
break;
case 'hash_blacklist':
dbRuleType = 'blacklist';
dbPatternType = 'pubkey'; // Schema supports: pubkey, kind, ip, global - using pubkey for hash for now
dbAction = 'deny';
break;
default:
throw new Error(`Unknown rule type: ${ruleData.rule_type}`);
}
// Map pattern type to database schema values
if (ruleData.pattern_type === 'Global') {
dbPatternType = 'global';
} else if (ruleData.pattern_type === 'pubkey') {
dbPatternType = 'pubkey';
}
// Create kind 33335 auth rule event with database schema values
const authEvent = {
kind: 33335,
pubkey: userPubkey,
created_at: Math.floor(Date.now() / 1000),
tags: [
['d', 'auth-rules'], // Addressable event identifier
[ruleData.rule_type, ruleData.pattern_type, ruleData.pattern_value]
[dbRuleType, dbPatternType, ruleData.pattern_value]
],
content: JSON.stringify({
action: 'add',
rule_type: ruleData.rule_type,
pattern_type: ruleData.pattern_type,
rule_type: dbRuleType,
pattern_type: dbPatternType,
pattern_value: ruleData.pattern_value,
rule_action: ruleData.action
rule_action: dbAction
})
};
// DEBUG: Log the complete event structure being sent
console.log('=== AUTH RULE EVENT DEBUG ===');
console.log('Rule Data:', ruleData);
console.log('Original Rule Data:', ruleData);
console.log('Mapped DB Values:', { dbRuleType, dbPatternType, dbAction });
console.log('Auth Event (before signing):', JSON.stringify(authEvent, null, 2));
console.log('Auth Event Tags:', authEvent.tags);
console.log('Auth Event Content:', authEvent.content);
console.log('=== END AUTH RULE EVENT DEBUG ===');
// Sign the event
// Sign the event using the standard NIP-07 interface
const signedEvent = await window.nostr.signEvent(authEvent);
if (!signedEvent || !signedEvent.sig) {
throw new Error('Event signing failed');