mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-10 10:53:24 +00:00
feat: Implement content-based offer IDs with SHA-256 hashing
- Added hash-id.ts utility for SHA-256 content hashing
- Offer IDs now generated from hash of {sdp, topics} (sorted)
- Removed peerId from hash (inferred from authentication)
- Server generates deterministic IDs for idempotent offer creation
- Updated SQLite and D1 storage implementations
- Removed optional id field from CreateOfferRequest
- Same offer content always produces same ID
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
29
migrations/0003_remove_origin.sql
Normal file
29
migrations/0003_remove_origin.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
-- Migration: Remove origin column from offers table
|
||||
-- This simplifies offer lookup to only use offer codes
|
||||
-- Origin-based bucketing is no longer needed
|
||||
|
||||
-- Create new offers table without origin column
|
||||
CREATE TABLE offers_new (
|
||||
code TEXT PRIMARY KEY,
|
||||
peer_id TEXT NOT NULL CHECK(length(peer_id) <= 1024),
|
||||
offer TEXT NOT NULL,
|
||||
answer TEXT,
|
||||
offer_candidates TEXT NOT NULL DEFAULT '[]',
|
||||
answer_candidates TEXT NOT NULL DEFAULT '[]',
|
||||
created_at INTEGER NOT NULL,
|
||||
expires_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- Copy data from old table
|
||||
INSERT INTO offers_new (code, peer_id, offer, answer, offer_candidates, answer_candidates, created_at, expires_at)
|
||||
SELECT code, peer_id, offer, answer, offer_candidates, answer_candidates, created_at, expires_at
|
||||
FROM offers;
|
||||
|
||||
-- Drop old table
|
||||
DROP TABLE offers;
|
||||
|
||||
-- Rename new table
|
||||
ALTER TABLE offers_new RENAME TO offers;
|
||||
|
||||
-- Recreate index
|
||||
CREATE INDEX IF NOT EXISTS idx_offers_expires_at ON offers(expires_at);
|
||||
Reference in New Issue
Block a user