# SilverChat — Integration Pointer

> **The SilverChat component already exists as a mature implementation inside the SilverVPN repo.**
> This directory does not re-implement it; it tracks the integration of the existing SilverChat into SilverMetal OS images and Enhanced packages.

## Where SilverChat lives

- **Client**: [`SilverLABS/SilverVPN/clients/SilverVPN.Client.Chat`](https://git.silverlabs.uk/SilverLABS/SilverVPN) — local checkout typically at `../SilverVPN/clients/SilverVPN.Client.Chat/`
- **Server**: part of `SilverVPN.Api` — `Hubs/ChatHub.cs`, `Controllers/ChatController.cs`, `Controllers/ChatAttachmentController.cs`, `Controllers/ContactsController.cs`
- **Windows installer**: `../SilverVPN/installer/silverchat/` (WiX-based MSI)
- The brand "SilverChat" is already in use in shipped artefacts

## What's already built

**Client (MAUI cross-platform — Windows / macOS / Android / iOS / Linux)**:
- 13 ViewModels covering: contacts, conversations, group chat, invites, safety numbers, settings, login, contact details
- 13 XAML Views — feature-complete UX
- **Signal Protocol** crypto layer (the gold standard for E2EE):
  - `DoubleRatchet.cs` — Signal's Double Ratchet algorithm
  - `SignalSessionManager.cs`, `IdentityKeyStore.cs`, `PreKeyStore.cs`, `SessionStore.cs` — full identity / prekey / session machinery
  - `SafetyNumber.cs` — Signal-style verification
  - `ChatAttachmentCrypto.cs` — encrypted attachments
  - `GroupChatEventService.cs` — group chat
- **`VpnChatTransport.cs`** — chat is carried over the SilverVPN tunnel itself, eliminating third-party metadata exposure
- `MauiSecretKeyProvider.cs` — platform key storage abstraction
- Token refresh, routing prefs, inbound policy enforcement

**Server (in `SilverVPN.Api`)**:
- `Hubs/ChatHub.cs` — SignalR realtime hub
- `Controllers/ChatController.cs` — REST API
- `Controllers/ChatAttachmentController.cs` — attachment handling
- `Controllers/ContactsController.cs` — contacts API

This is **more mature than SilverMetal's original v1.1 plan** in three ways:
1. Signal Protocol natively, not a Matrix/Signal-fork tentative
2. Chat transported over the SilverVPN tunnel — better metadata hygiene than otherwise possible
3. Cross-platform via MAUI on day one — covers all SilverMetal flavours

## Decision

**Adopt-as-is, do not duplicate.** SilverChat is no longer a v1.1 effort; it is alpha-ready today and ships in **SilverMetal OS — Linux v1**.

This supersedes the earlier (deferred) plan to evaluate Matrix vs. Signal Protocol forks.

## SilverMetal's responsibility

Like `stack/vpn/`, this directory tracks **integration**, not development.

### SilverMetal OS — Linux v1
- [ ] Build `SilverVPN.Client.Chat` for Linux (MAUI on Linux is constrained — likely a Linux-native Avalonia/WPF-port branch may be needed; or fall back to web client until MAUI Linux support firms up)
- [ ] Package as `silverchat` `.deb` from a `build-deb-chat.sh` (mirror of `build-deb.sh`)
- [ ] Include in `linux/packages/include.list`
- [ ] Configure to pair via SilverVPN account number — single-sign-on across VPN + Chat

### SilverMetal OS — Pixel / Samsung / Motorola
- [ ] Bundle SilverChat MAUI Android client as system app in ROM
- [ ] First-run wires SilverChat to the user's account-number-derived identity

### SilverMetal Enhanced — Windows
- [ ] Use existing `installer/silverchat/SilverChat.wxs` MSI as-is or roll into the Enhanced installer
- [ ] Auto-launch on first login

### SilverMetal Enhanced — macOS
- [ ] Bundle MAUI macOS build into setup `.pkg`

### SilverMetal Enhanced — iOS
- [ ] App Store listing referenced in iOS setup guide
- [ ] MDM profile pre-configures SilverChat

### SilverMetal Enhanced — Android (generic)
- [ ] APK referenced as required install in profile

## Coordination

Changes to chat protocol, server APIs, or transport that affect SilverMetal integration should be flagged in this directory's CHANGELOG (to be created when first integration milestone starts).

Cross-repo issues that touch both projects should be opened in whichever repo owns the change, with a back-reference in the other.

## Not in scope here

- Voice / video calling — out of scope for v1; revisit post-Linux-v1
- Federation with Matrix / XMPP / etc. — not planned; SilverChat is a closed-network E2EE messenger by design (account-number-based, no public federation)
