@xtr-dev/rondevu-server 0.5.1 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ -- PostgreSQL schema for rondevu signaling system
2
+ -- Compatible with PostgreSQL 12+
3
+
4
+ -- WebRTC signaling offers with tags
5
+ CREATE TABLE IF NOT EXISTS offers (
6
+ id VARCHAR(64) PRIMARY KEY,
7
+ username VARCHAR(32) NOT NULL,
8
+ tags JSONB NOT NULL,
9
+ sdp TEXT NOT NULL,
10
+ created_at BIGINT NOT NULL,
11
+ expires_at BIGINT NOT NULL,
12
+ last_seen BIGINT NOT NULL,
13
+ answerer_username VARCHAR(32),
14
+ answer_sdp TEXT,
15
+ answered_at BIGINT
16
+ );
17
+
18
+ CREATE INDEX IF NOT EXISTS idx_offers_username ON offers(username);
19
+ CREATE INDEX IF NOT EXISTS idx_offers_expires ON offers(expires_at);
20
+ CREATE INDEX IF NOT EXISTS idx_offers_last_seen ON offers(last_seen);
21
+ CREATE INDEX IF NOT EXISTS idx_offers_answerer ON offers(answerer_username);
22
+ CREATE INDEX IF NOT EXISTS idx_offers_tags ON offers USING GIN(tags);
23
+
24
+ -- ICE candidates table
25
+ CREATE TABLE IF NOT EXISTS ice_candidates (
26
+ id BIGSERIAL PRIMARY KEY,
27
+ offer_id VARCHAR(64) NOT NULL REFERENCES offers(id) ON DELETE CASCADE,
28
+ username VARCHAR(32) NOT NULL,
29
+ role VARCHAR(8) NOT NULL CHECK (role IN ('offerer', 'answerer')),
30
+ candidate JSONB NOT NULL,
31
+ created_at BIGINT NOT NULL
32
+ );
33
+
34
+ CREATE INDEX IF NOT EXISTS idx_ice_offer ON ice_candidates(offer_id);
35
+ CREATE INDEX IF NOT EXISTS idx_ice_username ON ice_candidates(username);
36
+ CREATE INDEX IF NOT EXISTS idx_ice_created ON ice_candidates(created_at);
37
+
38
+ -- Credentials table
39
+ CREATE TABLE IF NOT EXISTS credentials (
40
+ name VARCHAR(32) PRIMARY KEY,
41
+ secret VARCHAR(512) NOT NULL UNIQUE,
42
+ created_at BIGINT NOT NULL,
43
+ expires_at BIGINT NOT NULL,
44
+ last_used BIGINT NOT NULL
45
+ );
46
+
47
+ CREATE INDEX IF NOT EXISTS idx_credentials_expires ON credentials(expires_at);
48
+
49
+ -- Rate limits table
50
+ CREATE TABLE IF NOT EXISTS rate_limits (
51
+ identifier VARCHAR(255) PRIMARY KEY,
52
+ count INT NOT NULL,
53
+ reset_time BIGINT NOT NULL
54
+ );
55
+
56
+ CREATE INDEX IF NOT EXISTS idx_rate_limits_reset ON rate_limits(reset_time);
57
+
58
+ -- Nonces table (replay attack prevention)
59
+ CREATE TABLE IF NOT EXISTS nonces (
60
+ nonce_key VARCHAR(255) PRIMARY KEY,
61
+ expires_at BIGINT NOT NULL
62
+ );
63
+
64
+ CREATE INDEX IF NOT EXISTS idx_nonces_expires ON nonces(expires_at);