Skip to main content

max / makenotwork

1.6 KB · 35 lines History Blame Raw
1 -- Content fingerprinting for anti-piracy: download tracking, streaming sessions, license activation binding.
2
3 -- Track every download/stream with a unique fingerprint for tracing leaked content.
4 CREATE TABLE download_fingerprints (
5 id BIGSERIAL PRIMARY KEY,
6 user_id UUID NOT NULL REFERENCES users(id),
7 content_type TEXT NOT NULL,
8 content_id TEXT NOT NULL,
9 fingerprint_id UUID NOT NULL DEFAULT gen_random_uuid(),
10 watermark_method TEXT,
11 ip_address INET,
12 user_agent TEXT,
13 created_at TIMESTAMPTZ NOT NULL DEFAULT now()
14 );
15 CREATE INDEX idx_download_fp_user ON download_fingerprints(user_id);
16 CREATE INDEX idx_download_fp_fingerprint ON download_fingerprints(fingerprint_id);
17 CREATE INDEX idx_download_fp_content ON download_fingerprints(content_type, content_id);
18
19 -- Server-side streaming session tracking for IP binding and concurrency enforcement.
20 CREATE TABLE streaming_sessions (
21 id BIGSERIAL PRIMARY KEY,
22 user_id UUID NOT NULL REFERENCES users(id),
23 content_id TEXT NOT NULL,
24 session_token UUID NOT NULL DEFAULT gen_random_uuid(),
25 ip_address INET NOT NULL,
26 started_at TIMESTAMPTZ NOT NULL DEFAULT now(),
27 last_active_at TIMESTAMPTZ NOT NULL DEFAULT now(),
28 expired BOOLEAN NOT NULL DEFAULT false
29 );
30 CREATE INDEX idx_stream_session_user ON streaming_sessions(user_id, expired);
31 CREATE INDEX idx_stream_session_token ON streaming_sessions(session_token);
32
33 -- Per-project opt-in for license verification (phone-home on first use).
34 ALTER TABLE projects ADD COLUMN license_verification_enabled BOOLEAN NOT NULL DEFAULT false;
35