refactor: update dependencies and remove unused code
- Added new dependencies: `adler2`, `crc32fast`, `flate2`, `miniz_oxide`, and `libredox`. - Updated existing dependencies: `tokio-rustls` to version 0.26.4 and `filetime` to version 0.2.27. - Removed the `backup.rs` file as it is no longer needed. - Introduced tests for configuration and credential management. - Enhanced the `identity` module to generate W3C compliant DID documents. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
fd2a837bea
commit
f07ce10b1a
@@ -211,6 +211,62 @@ class RPCClient {
|
||||
})
|
||||
}
|
||||
|
||||
async resolveDid(did?: string): Promise<Record<string, unknown>> {
|
||||
return this.call({
|
||||
method: 'identity.resolve-did',
|
||||
params: did ? { did } : {},
|
||||
})
|
||||
}
|
||||
|
||||
async createPresentation(params: {
|
||||
holderId: string
|
||||
credentialIds: string[]
|
||||
}): Promise<Record<string, unknown>> {
|
||||
return this.call({
|
||||
method: 'identity.create-presentation',
|
||||
params: { holder_id: params.holderId, credential_ids: params.credentialIds },
|
||||
})
|
||||
}
|
||||
|
||||
async verifyPresentation(presentation: Record<string, unknown>): Promise<{
|
||||
valid: boolean
|
||||
holder_valid: boolean
|
||||
credentials: Array<{ id: string; valid: boolean; revoked: boolean }>
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'identity.verify-presentation',
|
||||
params: { presentation },
|
||||
})
|
||||
}
|
||||
|
||||
async createPsbt(params: {
|
||||
outputs: Array<{ address: string; amount_sats: number }>
|
||||
feeRateSatPerVbyte?: number
|
||||
}): Promise<{
|
||||
psbt_base64: string
|
||||
change_output_index: number
|
||||
total_amount_sats: number
|
||||
fee_rate_sat_per_vbyte: number
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'lnd.create-psbt',
|
||||
params: {
|
||||
outputs: params.outputs,
|
||||
fee_rate_sat_per_vbyte: params.feeRateSatPerVbyte ?? 10,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async finalizePsbt(signedPsbtBase64: string): Promise<{
|
||||
raw_final_tx: string
|
||||
broadcast: boolean
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'lnd.finalize-psbt',
|
||||
params: { signed_psbt_base64: signedPsbtBase64 },
|
||||
})
|
||||
}
|
||||
|
||||
async publishNostrIdentity(): Promise<{ event_id: string; success: number; failed: number }> {
|
||||
return this.call({
|
||||
method: 'node.nostr-publish',
|
||||
@@ -325,6 +381,21 @@ class RPCClient {
|
||||
})
|
||||
}
|
||||
|
||||
async detectUsbDevices(): Promise<{
|
||||
devices: Array<{
|
||||
type: string
|
||||
vendor_id: string
|
||||
product_id: string
|
||||
manufacturer: string
|
||||
product: string
|
||||
}>
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'system.detect-usb-devices',
|
||||
params: {},
|
||||
})
|
||||
}
|
||||
|
||||
async restartServer(): Promise<void> {
|
||||
return this.call({
|
||||
method: 'server.restart',
|
||||
@@ -381,6 +452,226 @@ class RPCClient {
|
||||
})
|
||||
}
|
||||
|
||||
// Federation
|
||||
async federationInvite(): Promise<{ code: string; did: string; onion: string }> {
|
||||
return this.call({
|
||||
method: 'federation.invite',
|
||||
params: {},
|
||||
})
|
||||
}
|
||||
|
||||
async federationJoin(code: string): Promise<{
|
||||
joined: boolean
|
||||
node: { did: string; onion: string; pubkey: string; trust_level: string }
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'federation.join',
|
||||
params: { code },
|
||||
})
|
||||
}
|
||||
|
||||
async federationListNodes(): Promise<{
|
||||
nodes: Array<{
|
||||
did: string
|
||||
pubkey: string
|
||||
onion: string
|
||||
trust_level: string
|
||||
added_at: string
|
||||
name?: string
|
||||
last_seen?: string
|
||||
last_state?: {
|
||||
timestamp: string
|
||||
apps: Array<{ id: string; status: string; version?: string }>
|
||||
cpu_usage_percent?: number
|
||||
mem_used_bytes?: number
|
||||
mem_total_bytes?: number
|
||||
disk_used_bytes?: number
|
||||
disk_total_bytes?: number
|
||||
uptime_secs?: number
|
||||
tor_active?: boolean
|
||||
}
|
||||
}>
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'federation.list-nodes',
|
||||
params: {},
|
||||
})
|
||||
}
|
||||
|
||||
async federationRemoveNode(did: string): Promise<{ removed: boolean; nodes_remaining: number }> {
|
||||
return this.call({
|
||||
method: 'federation.remove-node',
|
||||
params: { did },
|
||||
})
|
||||
}
|
||||
|
||||
async federationSetTrust(
|
||||
did: string,
|
||||
trustLevel: 'trusted' | 'observer' | 'untrusted',
|
||||
): Promise<{ updated: boolean; did: string; trust_level: string }> {
|
||||
return this.call({
|
||||
method: 'federation.set-trust',
|
||||
params: { did, trust_level: trustLevel },
|
||||
})
|
||||
}
|
||||
|
||||
async federationSyncState(): Promise<{
|
||||
synced: number
|
||||
failed: number
|
||||
results: Array<{ did: string; status: string; apps?: number; error?: string }>
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'federation.sync-state',
|
||||
params: {},
|
||||
timeout: 120000,
|
||||
})
|
||||
}
|
||||
|
||||
async federationDeployApp(params: {
|
||||
did: string
|
||||
appId: string
|
||||
version?: string
|
||||
marketplaceUrl?: string
|
||||
}): Promise<{ deployed: boolean; app_id: string; peer_did: string; peer_onion: string }> {
|
||||
return this.call({
|
||||
method: 'federation.deploy-app',
|
||||
params: {
|
||||
did: params.did,
|
||||
app_id: params.appId,
|
||||
version: params.version ?? 'latest',
|
||||
marketplace_url: params.marketplaceUrl ?? '',
|
||||
},
|
||||
timeout: 180000,
|
||||
})
|
||||
}
|
||||
|
||||
// VPN
|
||||
async vpnStatus(): Promise<{
|
||||
connected: boolean
|
||||
provider?: string
|
||||
interface?: string
|
||||
ip_address?: string
|
||||
hostname?: string
|
||||
peers_connected: number
|
||||
bytes_in: number
|
||||
bytes_out: number
|
||||
configured: boolean
|
||||
configured_provider: string
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'vpn.status',
|
||||
params: {},
|
||||
})
|
||||
}
|
||||
|
||||
async vpnConfigure(params: {
|
||||
provider: 'tailscale' | 'wireguard'
|
||||
auth_key?: string
|
||||
address?: string
|
||||
dns?: string
|
||||
peer?: {
|
||||
public_key: string
|
||||
endpoint: string
|
||||
allowed_ips?: string
|
||||
persistent_keepalive?: number
|
||||
}
|
||||
}): Promise<{ configured: boolean; provider: string; public_key?: string; address?: string }> {
|
||||
return this.call({
|
||||
method: 'vpn.configure',
|
||||
params,
|
||||
timeout: 60000,
|
||||
})
|
||||
}
|
||||
|
||||
async vpnDisconnect(): Promise<{ disconnected: boolean }> {
|
||||
return this.call({
|
||||
method: 'vpn.disconnect',
|
||||
params: {},
|
||||
})
|
||||
}
|
||||
|
||||
// Marketplace
|
||||
async marketplaceDiscover(): Promise<{
|
||||
apps: Array<{
|
||||
manifest: {
|
||||
app_id: string
|
||||
name: string
|
||||
version: string
|
||||
description: { short: string; long: string } | string
|
||||
author: { name: string; did: string; nostr_pubkey: string }
|
||||
container: { image: string; ports: Array<{ container: number; host: number }>; }
|
||||
category: string
|
||||
icon_url: string
|
||||
repo_url: string
|
||||
license: string
|
||||
}
|
||||
trust_score: number
|
||||
trust_tier: string
|
||||
relay_count: number
|
||||
first_seen: string
|
||||
nostr_pubkey: string
|
||||
}>
|
||||
relay_count: number
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'marketplace.discover',
|
||||
params: {},
|
||||
timeout: 30000,
|
||||
})
|
||||
}
|
||||
|
||||
// DNS
|
||||
async dnsStatus(): Promise<{
|
||||
provider: string
|
||||
servers: string[]
|
||||
doh_enabled: boolean
|
||||
doh_url: string | null
|
||||
resolv_conf_servers: string[]
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'network.dns-status',
|
||||
params: {},
|
||||
})
|
||||
}
|
||||
|
||||
async configureDns(params: {
|
||||
provider: 'system' | 'cloudflare' | 'google' | 'quad9' | 'mullvad' | 'custom'
|
||||
servers?: string[]
|
||||
}): Promise<{
|
||||
ok: boolean
|
||||
provider: string
|
||||
servers: string[]
|
||||
doh_enabled: boolean
|
||||
doh_url: string | null
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'network.configure-dns',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
// Disk management
|
||||
async diskStatus(): Promise<{
|
||||
used_bytes: number
|
||||
total_bytes: number
|
||||
free_bytes: number
|
||||
used_percent: number
|
||||
level: 'ok' | 'warning' | 'critical'
|
||||
}> {
|
||||
return this.call({ method: 'system.disk-status' })
|
||||
}
|
||||
|
||||
async diskCleanup(): Promise<{
|
||||
freed_bytes: number
|
||||
freed_human: string
|
||||
actions: string[]
|
||||
}> {
|
||||
return this.call({
|
||||
method: 'system.disk-cleanup',
|
||||
timeout: 60000,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const rpcClient = new RPCClient()
|
||||
|
||||
Reference in New Issue
Block a user