| 1 | export interface APIErrorPayload { |
| 2 | code: string; |
| 3 | message: string; |
| 4 | } |
| 5 | |
| 6 | export type APIEnvelope<T> = |
| 7 | | { |
| 8 | ok: true; |
| 9 | data: T; |
| 10 | error?: never; |
| 11 | } |
| 12 | | { |
| 13 | ok: false; |
| 14 | error: APIErrorPayload; |
| 15 | data?: unknown; |
| 16 | }; |
| 17 | |
| 18 | export type ApprovalMode = "auto" | "manual"; |
| 19 | |
| 20 | export interface LeaseMetadata { |
| 21 | description?: string; |
| 22 | owner?: string; |
| 23 | thumbnail?: string; |
| 24 | tags?: string[]; |
| 25 | hide?: boolean; |
| 26 | } |
| 27 | |
| 28 | export interface Lease { |
| 29 | name?: string; |
| 30 | expires_at: string; |
| 31 | first_seen_at: string; |
| 32 | last_seen_at: string; |
| 33 | hostname: string; |
| 34 | udp_enabled?: boolean; |
| 35 | tcp_enabled?: boolean; |
| 36 | tcp_addr?: string; |
| 37 | metadata: LeaseMetadata; |
| 38 | ready: number; |
| 39 | } |
| 40 | |
| 41 | export interface PolicyLease extends Lease { |
| 42 | identity_key: string; |
| 43 | address: string; |
| 44 | bps: number; |
| 45 | client_ip: string; |
| 46 | reported_ip?: string; |
| 47 | is_approved: boolean; |
| 48 | is_banned: boolean; |
| 49 | is_denied: boolean; |
| 50 | is_ip_banned: boolean; |
| 51 | } |
| 52 | |
| 53 | export interface PublicStateResponse { |
| 54 | leases?: Lease[]; |
| 55 | landing_page_enabled: boolean; |
| 56 | } |
| 57 | |
| 58 | export interface PolicyPortSettings { |
| 59 | enabled: boolean; |
| 60 | max_leases: number; |
| 61 | } |
| 62 | |
| 63 | export interface PolicyStateResponse { |
| 64 | policy: PolicySettings; |
| 65 | leases?: PolicyLease[]; |
| 66 | } |
| 67 | |
| 68 | export interface PolicySettings { |
| 69 | approval_mode: ApprovalMode; |
| 70 | landing_page_enabled: boolean; |
| 71 | udp: PolicyPortSettings; |
| 72 | tcp_port: PolicyPortSettings; |
| 73 | } |
| 74 | |
| 75 | export interface AdminAuthStatusResponse { |
| 76 | authenticated: boolean; |
| 77 | } |
| 78 | |
| 79 | export interface AdminAuthLoginRequest { |
| 80 | token: string; |
| 81 | } |
| 82 | |
| 83 | export interface AdminAuthLoginResponse { |
| 84 | access_token?: string; |
| 85 | } |
| 86 | |
| 87 | export interface ENSStatus { |
| 88 | enabled: boolean; |
| 89 | verified: boolean; |
| 90 | provider?: string; |
| 91 | address?: string; |
| 92 | dnssec_state?: string; |
| 93 | ds_record?: string; |
| 94 | message?: string; |
| 95 | last_error?: string; |
| 96 | } |
| 97 | |
| 98 | export interface X402FacilitatorInfo { |
| 99 | enabled: boolean; |
| 100 | url?: string; |
| 101 | network?: string; |
| 102 | network_name?: string; |
| 103 | supported_url?: string; |
| 104 | pay_to?: string; |
| 105 | } |
| 106 | |
| 107 | export interface DomainResponse { |
| 108 | protocol_version: string; |
| 109 | release_version: string; |
| 110 | ens: ENSStatus; |
| 111 | x402: X402FacilitatorInfo; |
| 112 | } |
| 113 | |
| 114 | export interface RelayDescriptor { |
| 115 | api_https_addr?: string; |
| 116 | } |
| 117 | |
| 118 | export interface DiscoveryResponse { |
| 119 | relays?: RelayDescriptor[]; |
| 120 | } |
| 121 | |
| 122 | export interface ServiceStatusResponse { |
| 123 | hostname: string; |
| 124 | registered: boolean; |
| 125 | service_alive: boolean; |
| 126 | } |
| 127 | |
| 128 | export interface LeasePolicyUpdate { |
| 129 | identity_key: string; |
| 130 | bps?: number; |
| 131 | is_approved?: boolean; |
| 132 | is_banned?: boolean; |
| 133 | is_denied?: boolean; |
| 134 | } |
| 135 | |
| 136 | export interface IPPolicyUpdate { |
| 137 | ip: string; |
| 138 | is_banned: boolean; |
| 139 | } |