Commit Graph

364 Commits

Author SHA1 Message Date
Jeff Emmett 2b5ef14946 Merge branch 'dev' 2026-03-02 19:01:07 -08:00
Jeff Emmett 7ffabe9b0a fix: use source 'card' and require funnelId for Flow Service deposit
Flow Service expects source to be wallet|card|bank, not 'transak'.
funnelId falls back to FUNNEL_ID env var when not in partnerOrderId.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 18:55:59 -08:00
Jeff Emmett bedc5652dc Merge branch 'dev' 2026-03-02 18:25:20 -08:00
Jeff Emmett 0ef5aad3ad chore: add backlog tasks 79-81
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 18:25:12 -08:00
Jeff Emmett 0fb8bb782e Merge branch 'dev' 2026-03-02 18:20:42 -08:00
Jeff Emmett 1af7df41bb feat: Tiptap rich text editor for rNotes — toolbar, slash commands, sync
Replace bare contenteditable divs with a full Tiptap editor (vanilla JS,
no React) inside the <folk-notes-app> web component. Adds formatting
toolbar (bold/italic/underline/strike/code, heading dropdown, lists,
blockquote, code block, link/image insert, undo/redo), slash command
menu (/ at start of empty block), syntax-highlighted code blocks via
lowlight, and task list checkboxes.

Zone-based rendering keeps the editor DOM persistent across re-renders.
Content stored as Tiptap JSON in the existing Automerge content field
with a new contentFormat discriminator. Legacy HTML notes auto-migrate
on first edit. Remote sync updates applied without cursor disruption.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 18:20:33 -08:00
Jeff Emmett a70d5fc1a2 fix: use c.req.json() for Transak webhook body parsing
Hono consumes the request body upstream, so c.req.raw.clone().text()
returns empty. Use c.req.json() directly and re-serialize for HMAC.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 18:10:04 -08:00
Jeff Emmett 4bca76cf45 fix: handle body read in Transak webhook — clone request for HMAC + JSON
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 18:08:24 -08:00
Jeff Emmett 34c96b5a45 feat: Transak credit card → USDC fiat on-ramp for rFunds TBFF
Add Transak widget integration so users can fund flows with a credit card.
Server receives webhook on order completion and deposits USDC into the flow
via the existing Flow Service API. Includes HMAC signature verification
when TRANSAK_WEBHOOK_SECRET is configured.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 18:04:53 -08:00
Jeff Emmett 7f3747bf74 Merge branch 'dev' 2026-03-02 17:09:17 -08:00
Jeff Emmett 46c2a0b035 feat: layered local-first data architecture — encrypted backup, relay persistence, at-rest encryption
Implement the 4-layer data model (device → encrypted backup → shared sync → federated):

- Extract shared encryption-utils from community-store (deriveSpaceKey, AES-256-GCM, rSEN format)
- Encrypt module docs at rest when space has meta.encrypted === true
- Fix relay mode persistence: relay-backup/relay-restore wire protocol + .automerge.enc blob storage
- Add backup store + REST API (PUT/GET/DELETE /api/backup/:space/:docId) with JWT auth
- Add client BackupSyncManager with delta-only push, full restore, auto-backup
- Wire backup stubs in encryptid-bridge to BackupSyncManager
- Add rspace-backups Docker volume
- Create docs/DATA-ARCHITECTURE.md design doc with threat model and data flow diagrams

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 17:09:07 -08:00
Jeff Emmett c906efc3e6 Merge branch 'dev' 2026-03-02 16:46:07 -08:00
Jeff Emmett 5ee59f86d6 feat: people online panel — live peer presence on canvas
- community-sync: re-announce on reconnect, handle peer-list/joined/left/ping events
- presence: export peerIdToColor helper
- server: track peer announcements, broadcast join/leave, relay ping-user
- canvas: people online badge + expandable panel with avatar dots and ping button

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:45:57 -08:00
Jeff Emmett 5241b37922 Merge branch 'dev' 2026-03-02 16:38:27 -08:00
Jeff Emmett 4dd212ef7d fix: add shared/local-first to EncryptID Docker build context
login-button.ts imports encryptid-bridge from shared/local-first/
which was missing from the Dockerfile.encryptid COPY steps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:38:18 -08:00
Jeff Emmett ac2eebb966 Merge branch 'dev' 2026-03-02 16:34:56 -08:00
Jeff Emmett 88118cd157 fix: use server-initiated WebAuthn flow for guardian acceptance and login
The guardian page and auth.rspace.online login page were using the
client-side authenticatePasskey()/registerPasskey() SDK functions which
generate their own challenge and return AuthenticationResult — but then
tried to send result.challenge and result.credential (both undefined)
to the server. This caused postgres to throw "UNDEFINED_VALUE" resulting
in a 500 "Internal Server Error" that the client couldn't parse as JSON.

Fix: use the proper server-initiated flow matching rstack-identity.ts:
1. POST /api/auth/start (or /register/start) to get server challenge
2. navigator.credentials.get/create with that challenge
3. POST /api/auth/complete (or /register/complete) with challenge + credential

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:34:43 -08:00
Jeff Emmett dc6c6a4042 Merge branch 'dev' 2026-03-02 16:25:37 -08:00
Jeff Emmett 9443178d1c feat: Phase 5 — remove PostgreSQL from rForum, rSpace now fully PG-free
Migrate rForum provisioning metadata from shared PG pool to Automerge.
rForum was the last module using PostgreSQL; shared/db/pool.ts is now archived.

- Create modules/rforum/schemas.ts (ForumDoc, ForumInstance, ProvisionLog)
- Rewrite mod.ts: replace sql with Automerge getDoc/changeDoc, add onInit
- Rewrite provisioner.ts: pass SyncServer, logStep/updateInstance via changeDoc
- Fix dashboard snake_case → camelCase field references
- Archive schema.sql and shared/db/pool.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:25:26 -08:00
Jeff Emmett 1cbced27f8 docs: add rSpace ecosystem ontology
Documents the three-layer architecture (rStack foundation, rSpace platform,
rApps modules) covering identity, local-first data, micropayments, wallet
abstraction, spatial canvas, module system, and token/value architecture.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:22:13 -08:00
Jeff Emmett bb97580386 Merge branch 'dev' 2026-03-02 16:08:59 -08:00
Jeff Emmett 9ffd5de10a chore: add backlog task files (task-77, task-78)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:05:24 -08:00
Jeff Emmett 125d3a3c40 Merge branch 'dev' 2026-03-02 15:48:13 -08:00
Jeff Emmett 8900eb32b9 feat: Phase 4 — remove PostgreSQL from 11 modules, switch to Automerge
Replace all sql.unsafe() calls with Automerge document operations
across rfunds, rbooks, rsplat, rnotes, rwork, rvote, rcal, rfiles,
rcart, rtrips, and rinbox. Only rforum retains PG (Discourse provisioning).

Each module now uses _syncServer.getDoc/changeDoc/setDoc for all CRUD,
with ensureDoc() helpers for lazy document creation. Schema SQL files
archived to .sql.archived. Adds Automerge round-trip test suite (35 tests).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 15:48:01 -08:00
Jeff Emmett d1b5e6e122 Merge branch 'dev' 2026-03-02 15:22:26 -08:00
Jeff Emmett 88d618c1af feat: replace My Account submenu with consolidated popup modal
Consolidates email, device, recovery, postal address, data storage,
and dark mode settings into a single scrollable modal with collapsible
section cards — matching the existing My Spaces modal pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 15:22:13 -08:00
Jeff Emmett f7143a3ed7 Merge branch 'dev' 2026-03-02 15:18:42 -08:00
Jeff Emmett 25174b87e6 fix: bump rCal JS cache version to v=4
Bust Cloudflare CDN cache after unified layout deploy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 15:18:29 -08:00
Jeff Emmett 41244f943b Merge branch 'dev' 2026-03-02 15:07:42 -08:00
Jeff Emmett 2ce0b4730c feat: rCal unified layout — no tabs, auto-map, lunar overlay, scroll zoom
Remove the 3-tab system (Temporal/Spatial/Lunar) in favor of a unified view:
- Calendar always primary with floating/docked/minimizable map panel
- Lunar phases as compact overlay bar below nav (click to expand synodic detail)
- Scroll/trackpad zoom controls temporal granularity with 120ms debounce
- 'm' key cycles map panel: floating → docked → minimized → floating
- Mobile: floating map full-width, docked stacks vertically
- cal-demo.ts cleaned up (dead tab-switching code removed)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 15:07:31 -08:00
Jeff Emmett dadd2f85c0 Merge branch 'dev' 2026-03-02 14:50:26 -08:00
Jeff Emmett 22db2f439f feat: client-side encryption wiring + space scoping UI (Phase 5+6)
Phase 5 — EncryptID → DocCrypto bridge:
- Add EncryptedDocBridge connecting WebAuthn PRF to document encryption
- Add per-doc relay mode to SyncServer (encrypted spaces bypass participant mode)
- Wire encryption toggle to syncServer.setRelayOnly() on PATCH /:slug/encryption
- Restore relay mode for encrypted spaces on server startup
- Initialize DocBridge from PRF on login, clear on sign-out (both login-button + identity)
- Use bridge helpers for encrypted backup toggle in My Account

Phase 6 — Space scoping UI:
- Add "Modules" tab to Edit Space modal (enable/disable modules, scope toggles, encryption)
- Auto-filter app switcher by space's enabledModules via renderShell()
- Show "G" badge on global-scoped modules in app switcher
- Show lock icon in header for encrypted spaces
- Add getSpaceShellMeta() helper for auto-populating shell options

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:50:16 -08:00
Jeff Emmett 77c712f130 Merge branch 'dev' 2026-03-02 14:48:50 -08:00
Jeff Emmett 33156cc249 fix: resolve all pre-existing tsc --noEmit errors (10 errors across 5 files)
- folk-map-viewer.ts: remove explicit return type, let TS infer
- test-x402.ts: cast account as any (test script, readContract unused)
- key-derivation.ts: cast Uint8Array at WebCrypto boundaries (BufferSource/ArrayBuffer)
- wallet-store.ts: cast .buffer as ArrayBuffer
- webauthn.ts: cast PRF output as ArrayBuffer | undefined

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:48:37 -08:00
Jeff Emmett a9ebba03cb Merge branch 'dev' 2026-03-02 14:30:25 -08:00
Jeff Emmett 03a7b6d063 feat: add explicit ports with drag-to-connect wiring to rFunds canvas
Adds named, colored ports to every node type (source outflow, funnel
inflow/spending/overflow, outcome inflow/overflow) with a full wiring
state machine supporting both click-to-wire and drag-to-wire interaction.
Edges now originate from specific port positions. Outcomes gain overflow
allocations so fully-funded outcomes can cascade surplus onward.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:30:14 -08:00
Jeff Emmett e3f588d1f4 Merge branch 'dev' 2026-03-02 14:02:17 -08:00
Jeff Emmett ef3d0ce447 feat: batch local-first migration for 10 modules (Phase 3)
Add Automerge schemas, lifecycle hooks (onInit, docSchemas), and
local-first client wrappers for all remaining PG modules:
rWork, rVote, rCal, rFiles, rCart, rBooks, rTrips, rInbox, rSplat, rFunds.

Each module now:
- Defines typed Automerge document schemas (schemas.ts)
- Registers docSchemas and onInit hook with SyncServer reference
- Moves initDB() from top-level to onInit for unified startup
- Has a client-side local-first wrapper (local-first-client.ts)

Dual-write route handlers will be wired incrementally per module
following the rNotes pattern established in Phase 2.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:01:58 -08:00
Jeff Emmett 58a864b991 Merge branch 'dev' 2026-03-02 13:51:43 -08:00
Jeff Emmett 6a7f21dc19 feat: rNotes local-first pilot migration (Phase 2)
Migrate rNotes from PostgreSQL to Automerge local-first stack with
dual-write support. Reads go Automerge-first with PG fallback; writes
go to both backends during the migration window.

- Add Automerge schemas for NotebookDoc (schemas.ts)
- Add lifecycle hooks (onInit, onSpaceCreate) to rnotes module
- Dual-write all 8 API routes (notebooks + notes CRUD)
- Add NotesLocalFirstClient wrapping DocSyncManager + EncryptedDocStore
- Enhance migration runner with --dry-run, --module, --verify flags
- Add listDocs() to SyncServer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:51:31 -08:00
Jeff Emmett a9c92424d4 Merge branch 'dev' 2026-03-02 13:36:09 -08:00
Jeff Emmett b2ea5e04cf feat: unified space lifecycle & module scoping contract (Phase 0+1)
Extend RSpaceModule with scoping, lifecycle hooks (onInit, onSpaceCreate/Delete
with SpaceLifecycleContext, onSpaceEnable/Disable), and DocSchema support.
Add scoping to all 25 modules (8 space, 11 global-configurable, 6 global-fixed).
Consolidate 4 space creation endpoints into shared createSpace() function.
Add enabledModules enforcement middleware and module configuration API
(GET/PATCH /api/spaces/:slug/modules). Deprecation header on /api/communities.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:35:41 -08:00
Jeff Emmett a54661d4d4 fix: use correct /rX prefix in all module getApiBase() methods
All module components were matching URL paths without the 'r' prefix
(e.g., /notes instead of /rnotes), causing API calls to fail when
modules are mounted at /:space/:moduleId. Also adds space attribute
fallback for canvas-embedded usage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:34:17 -08:00
Jeff Emmett 347c7193d0 fix: rcal API base URL — match /rcal path and fall back to space attribute
The regex matched /cal instead of /rcal, so getApiBase() always returned
empty string, causing 404s on api/events, api/lunar, and api/sources.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:27:49 -08:00
Jeff Emmett f0d27bde16 feat: replace static rFunds diagram with interactive flow canvas
Transform the Diagram tab from a read-only SVG into a full interactive
canvas with draggable nodes, zoom/pan, Sankey-width edges with +/-
allocation controls, slide-in editor panel, live simulation, node CRUD,
keyboard shortcuts, and lz-string URL sharing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:16:55 -08:00
Jeff Emmett b252004f48 fix: disconnect from spaces and redirect on EncryptID sign-out
Prevents stale WebSocket reconnect loops after sign-out by adding an
intentional-disconnect flag to CommunitySync. Canvas and shell pages
now redirect to homepage when the user signs out.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:15:09 -08:00
Jeff Emmett e7f9507d9d test: add stack view + wiring test page
Standalone test harness for flow tubes, particle animation, and
interactive port wiring with event logging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:03:29 -08:00
Jeff Emmett 4ebbf9f116 feat: add Copy to Space context menu for shapes
Right-click shapes (single or multi-selected) to copy them to another
space the user owns or is a member of. Server endpoint handles ID
remapping, arrow reference preservation, and position centering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 12:58:44 -08:00
Jeff Emmett 1f0ef59369 feat: add flow tubes, stable particle animation, and interactive port wiring
Replace invisible particle-only flow visualization with colored 3D tubes
between layers, spread horizontally to avoid overlap. Particles now travel
along tube paths. Add click-to-wire interaction on I/O port chips with
visual feedback (glow/breathe/dim). Prevent animation restart on Automerge
sync by surgically updating flow elements in-place.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 12:55:16 -08:00
Jeff Emmett 91494a9c5c feat: port spatio-temporal calendar from standalone rcal-online
Rewrite folk-calendar-view with 5 views (Day/Week/Month/Season/Year),
3 tabs (Temporal/Spatial/Lunar), Leaflet map with event markers and
transit polylines, temporal-spatial zoom coupling, and lunar phase display.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 12:45:24 -08:00