mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-10 19:03:24 +00:00
- Delete unused bloom.ts module (leftover from topic-based discovery) - Remove maxTopicsPerOffer configuration (no longer used) - Remove unused info field from Offer types - Simplify generateOfferHash() to only hash SDP (remove topics param) - Update outdated comments referencing deprecated features - Remove backward compatibility topics field from answer responses This completes the migration to V2 service-based architecture by removing all remnants of the V1 topic-based system. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
/**
|
|
* Generates a content-based offer ID using SHA-256 hash
|
|
* Creates deterministic IDs based on offer SDP content
|
|
* PeerID is not included as it's inferred from authentication
|
|
* Uses Web Crypto API for compatibility with both Node.js and Cloudflare Workers
|
|
*
|
|
* @param sdp - The WebRTC SDP offer
|
|
* @returns SHA-256 hash of the SDP content
|
|
*/
|
|
export async function generateOfferHash(sdp: string): Promise<string> {
|
|
// Sanitize and normalize the offer content
|
|
// Only include core offer content (not peerId - that's inferred from auth)
|
|
const sanitizedOffer = {
|
|
sdp
|
|
};
|
|
|
|
// Create non-prettified JSON string
|
|
const jsonString = JSON.stringify(sanitizedOffer);
|
|
|
|
// Convert string to Uint8Array for hashing
|
|
const encoder = new TextEncoder();
|
|
const data = encoder.encode(jsonString);
|
|
|
|
// Generate SHA-256 hash
|
|
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
|
|
|
// Convert hash to hex string
|
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
|
|
return hashHex;
|
|
}
|