I think nip42 is FINALLY working.
This commit is contained in:
@@ -77,6 +77,21 @@ typedef struct {
|
||||
void* app_context; // Application context (unused, for compatibility)
|
||||
} nostr_request_t;
|
||||
|
||||
// Extended request structure for unified API
|
||||
typedef struct {
|
||||
const char* operation; // Operation type ("upload", "delete", "list", "publish", "admin")
|
||||
const char* auth_header; // Raw authorization header (optional)
|
||||
cJSON* event; // Parsed NOSTR event for validation (optional)
|
||||
const char* resource_hash; // Resource hash (SHA-256, optional)
|
||||
const char* mime_type; // MIME type (optional)
|
||||
long file_size; // File size (optional)
|
||||
const char* request_url; // Request URL for NIP-42 relay URL validation (optional)
|
||||
const char* challenge_id; // Challenge ID for NIP-42 verification (optional)
|
||||
int nip42_enabled; // Whether NIP-42 authentication is enabled
|
||||
const char* client_ip; // Client IP address (optional)
|
||||
void* app_context; // Application context (unused, for compatibility)
|
||||
} nostr_unified_request_t;
|
||||
|
||||
typedef struct {
|
||||
int valid; // 0 = invalid/denied, 1 = valid/allowed
|
||||
int error_code; // NOSTR_SUCCESS or specific error code
|
||||
@@ -98,13 +113,19 @@ int nostr_sha256(const unsigned char* data, size_t len, unsigned char* hash);
|
||||
void nostr_bytes_to_hex(const unsigned char* bytes, size_t len, char* hex_out);
|
||||
int nostr_crypto_init(void);
|
||||
|
||||
int nostr_validate_request(const nostr_request_t* request, nostr_request_result_t* result);
|
||||
int nostr_request_validator_init(const char* db_path, const char* app_name);
|
||||
// Unified API function (main entry point)
|
||||
int nostr_validate_unified_request(const nostr_unified_request_t* request, nostr_request_result_t* result);
|
||||
int ginxsom_request_validator_init(const char* db_path, const char* app_name);
|
||||
int nostr_auth_rules_enabled(void);
|
||||
void nostr_request_validator_cleanup(void);
|
||||
void ginxsom_request_validator_cleanup(void);
|
||||
void nostr_request_validator_force_cache_refresh(void);
|
||||
int nostr_request_validator_generate_nip42_challenge(void* challenge_struct, const char* client_ip);
|
||||
|
||||
// New NIP-42 challenge management functions
|
||||
int nostr_generate_nip42_challenge(char* challenge_out, size_t challenge_size, const char* client_ip);
|
||||
const char* nostr_request_validator_get_last_violation_type(void);
|
||||
void nostr_request_validator_clear_violation(void);
|
||||
|
||||
// Upload handling
|
||||
void handle_upload_request(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user