Files
waste-go/web/src/types.ts
Fredrik Johansson add7c5fea8 Add yaw2 invite interoperability
Protocol:
- invite.go: include full 64-char `net` hash in waste: invite blob
  (matches yaw2's `net` field — any client parsing the base64 JSON can
  join without knowing the plaintext name). Expose NetHash() helper.
- netmgr: add JoinByHash() — join via full 64-char hex hash alone,
  storing the short ID as display name. Enables joining yaw2 networks
  from a URL that only carries the hash.
- anchor: expose RunByHash() so netmgr can pass a pre-computed hash
  directly without a name→hash roundtrip.
- ipc/proto: add network_hash field to join_network — routes to
  JoinByHash when present and network_name is absent.

Web UI:
- Parse ?net=<64hex> (yaw2 URL param) and ?a=<anchor> in addition to
  existing ?n= / ?invite= params. Hash-only joins send network_hash.
- Sidebar shows yaw: contact card (yaw:<masterID>?n=<alias>) using the
  master identity — compatible with yaw2 contact card format. Click to
  copy to clipboard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 23:29:45 +02:00

108 lines
2.2 KiB
TypeScript

// Types mirroring internal/proto — keep in sync with proto.go
export type PeerID = string // 64-char lowercase hex
export interface PeerInfo {
id: PeerID
alias: string
public_key: string
created_at: string
}
export interface NetworkInfo {
network_id: string
network_name: string
local_peer?: PeerInfo
share_dir?: string
download_dir?: string
}
export interface ChatMessage {
mid?: string
from: PeerID
to?: PeerID
room: string
text: string
ts: number // Unix ms
}
export interface FileEntry {
name: string
size_bytes: number
}
export interface FileOffer {
xid: string
name: string
size: number
sha256: string
}
// ── IPC message types ─────────────────────────────────────────────────────────
export type IpcMsgType =
// commands
| 'send_message'
| 'join_network'
| 'leave_network'
| 'get_state'
| 'send_file'
| 'set_share_dir'
| 'generate_invite'
| 'get_file_list'
| 'export_identity'
| 'import_identity'
// events
| 'state_snapshot'
| 'message_received'
| 'peer_connected'
| 'peer_disconnected'
| 'session_ready'
| 'network_joined'
| 'network_left'
| 'file_list'
| 'file_progress'
| 'file_complete'
| 'incoming_file'
| 'invite_generated'
| 'identity_exported'
| 'identity_imported'
| 'error'
export interface IpcMessage {
type: IpcMsgType
// routing
network_id?: string
// send_message
room?: string
to?: PeerID
body?: string
// join_network
network_name?: string
network_hash?: string // 64-char hex (yaw2 `net` field) — alternative to network_name
share_dir?: string
// send_file / set_share_dir
path?: string
peer_id?: PeerID
// identity
passphrase?: string
backup?: string
// events
peer?: PeerInfo
nick?: string
message?: ChatMessage
offer?: FileOffer
transfer_id?: string
bytes_received?: number
total_bytes?: number
master_alias?: string
master_id?: string
local_peer?: PeerInfo
connected_peers?: PeerInfo[]
rooms?: string[]
networks?: NetworkInfo[]
error_message?: string
invite?: string
files?: FileEntry[]
}