Add NRC (Nostr Relay Connect) protocol and web UI (v0.48.9)
Some checks failed
Go / build-and-release (push) Has been cancelled
Some checks failed
Go / build-and-release (push) Has been cancelled
- Implement NIP-NRC protocol for remote relay access through public relay tunnel - Add NRC bridge service with NIP-44 encrypted message tunneling - Add NRC client library for applications - Add session management with subscription tracking and expiry - Add URI parsing for nostr+relayconnect:// scheme with secret and CAT auth - Add NRC API endpoints for connection management (create/list/delete/get-uri) - Add RelayConnectView.svelte component for managing NRC connections in web UI - Add NRC database storage for connection secrets and labels - Add NRC CLI commands (generate, list, revoke) - Add support for Cashu Access Tokens (CAT) in NRC URIs - Add ScopeNRC constant for Cashu token scope - Add wasm build infrastructure and stub files Files modified: - app/config/config.go: NRC configuration options - app/handle-nrc.go: New API handlers for NRC connections - app/main.go: NRC bridge startup integration - app/server.go: Register NRC API routes - app/web/src/App.svelte: Add Relay Connect tab - app/web/src/RelayConnectView.svelte: New NRC management component - app/web/src/api.js: NRC API client functions - main.go: NRC CLI command handlers - pkg/bunker/acl_adapter.go: Add NRC scope mapping - pkg/cashu/token/token.go: Add ScopeNRC constant - pkg/database/nrc.go: NRC connection storage - pkg/protocol/nrc/: New NRC protocol implementation - docs/NIP-NRC.md: NIP specification document 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
62
cmd/wasmdb/main.go
Normal file
62
cmd/wasmdb/main.go
Normal file
@@ -0,0 +1,62 @@
|
||||
//go:build js && wasm
|
||||
|
||||
// Package main provides the WASM entry point for the WasmDB database.
|
||||
// It initializes the IndexedDB-backed Nostr event store and exposes
|
||||
// the database API to JavaScript via the global `wasmdb` object.
|
||||
//
|
||||
// Build with:
|
||||
// GOOS=js GOARCH=wasm go build -o wasmdb.wasm ./cmd/wasmdb
|
||||
//
|
||||
// Usage in JavaScript:
|
||||
// // Load wasm_exec.js first (Go WASM runtime)
|
||||
// const go = new Go();
|
||||
// const result = await WebAssembly.instantiateStreaming(fetch('wasmdb.wasm'), go.importObject);
|
||||
// go.run(result.instance);
|
||||
//
|
||||
// // Wait for ready
|
||||
// while (!wasmdb.isReady()) {
|
||||
// await new Promise(resolve => setTimeout(resolve, 100));
|
||||
// }
|
||||
//
|
||||
// // Use the API
|
||||
// await wasmdb.saveEvent(JSON.stringify(event));
|
||||
// const events = await wasmdb.queryEvents(JSON.stringify({kinds: [1], limit: 10}));
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"next.orly.dev/pkg/database"
|
||||
"next.orly.dev/pkg/wasmdb"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create context for the database
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
// Initialize the database with default config
|
||||
cfg := &database.DatabaseConfig{
|
||||
DataDir: ".",
|
||||
LogLevel: "info",
|
||||
}
|
||||
|
||||
db, err := wasmdb.NewWithConfig(ctx, cancel, cfg)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to initialize WasmDB: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Register the JavaScript bridge
|
||||
wasmdb.RegisterJSBridge(db, ctx, cancel)
|
||||
|
||||
fmt.Println("WasmDB initialized and JavaScript bridge registered")
|
||||
|
||||
// Wait for the database to be ready
|
||||
<-db.Ready()
|
||||
fmt.Println("WasmDB ready to serve requests")
|
||||
|
||||
// Keep the WASM module running
|
||||
// This is necessary because Go's main() returning would terminate the WASM instance
|
||||
select {}
|
||||
}
|
||||
Reference in New Issue
Block a user