Expand README with links to related repositories and NPM packages

This commit is contained in:
2025-11-17 21:41:55 +01:00
parent 8a65626225
commit 7ca42c42aa
5 changed files with 63 additions and 15 deletions

View File

@@ -30,6 +30,7 @@ export class SQLiteStorage implements Storage {
created_at INTEGER NOT NULL,
expires_at INTEGER NOT NULL,
last_seen INTEGER NOT NULL,
secret TEXT,
answerer_peer_id TEXT,
answer_sdp TEXT,
answered_at INTEGER
@@ -83,8 +84,8 @@ export class SQLiteStorage implements Storage {
// Use transaction for atomic creation
const transaction = this.db.transaction((offersWithIds: (CreateOfferRequest & { id: string })[]) => {
const offerStmt = this.db.prepare(`
INSERT INTO offers (id, peer_id, sdp, created_at, expires_at, last_seen)
VALUES (?, ?, ?, ?, ?, ?)
INSERT INTO offers (id, peer_id, sdp, created_at, expires_at, last_seen, secret)
VALUES (?, ?, ?, ?, ?, ?, ?)
`);
const topicStmt = this.db.prepare(`
@@ -102,7 +103,8 @@ export class SQLiteStorage implements Storage {
offer.sdp,
now,
offer.expiresAt,
now
now,
offer.secret || null
);
// Insert topics
@@ -118,6 +120,7 @@ export class SQLiteStorage implements Storage {
createdAt: now,
expiresAt: offer.expiresAt,
lastSeen: now,
secret: offer.secret,
});
}
});
@@ -195,7 +198,8 @@ export class SQLiteStorage implements Storage {
async answerOffer(
offerId: string,
answererPeerId: string,
answerSdp: string
answerSdp: string,
secret?: string
): Promise<{ success: boolean; error?: string }> {
// Check if offer exists and is not expired
const offer = await this.getOfferById(offerId);
@@ -207,6 +211,14 @@ export class SQLiteStorage implements Storage {
};
}
// Verify secret if offer is protected
if (offer.secret && offer.secret !== secret) {
return {
success: false,
error: 'Invalid or missing secret'
};
}
// Check if offer already has an answerer
if (offer.answererPeerId) {
return {
@@ -382,6 +394,7 @@ export class SQLiteStorage implements Storage {
createdAt: row.created_at,
expiresAt: row.expires_at,
lastSeen: row.last_seen,
secret: row.secret || undefined,
answererPeerId: row.answerer_peer_id || undefined,
answerSdp: row.answer_sdp || undefined,
answeredAt: row.answered_at || undefined,