mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40:09 +00:00
Add reported-issues, Goodreads sync & notifs
Introduce user-reported-issues and Goodreads shelf sync features and wire them into notifications. Adds Prisma migrations and schema changes (ReportedIssue, GoodreadsShelf, GoodreadsBookMapping), API endpoints for reporting (POST /audiobooks/[asin]/report-issue) and admin management (list, resolve/dismiss, replace), and an admin UI section to view/dismiss/replace reported issues. Adds a new notification event (issue_reported) with updates to notification schemas, docs and provider handling, plus a notification-events constants file. Refactors request creation to use createRequestForUser service, adds a Goodreads sync processor/service/hooks/UI modals, a scrape-resilience util, and related tests and minor integration updates.
This commit is contained in:
@@ -95,6 +95,39 @@ export class EncryptionService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a value matches the format produced by encrypt().
|
||||
* Validates: 3 colon-separated base64 parts where IV=16 bytes, authTag=16 bytes.
|
||||
*/
|
||||
isEncryptedFormat(value: string): boolean {
|
||||
if (typeof value !== 'string') return false;
|
||||
|
||||
const parts = value.split(':');
|
||||
if (parts.length !== 3) return false;
|
||||
|
||||
const [ivBase64, authTagBase64, encryptedBase64] = parts;
|
||||
|
||||
// All parts must be non-empty valid base64
|
||||
const base64Regex = /^[A-Za-z0-9+/]+=*$/;
|
||||
if (!ivBase64 || !authTagBase64 || !encryptedBase64) return false;
|
||||
if (!base64Regex.test(ivBase64) || !base64Regex.test(authTagBase64) || !base64Regex.test(encryptedBase64)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const iv = Buffer.from(ivBase64, 'base64');
|
||||
const authTag = Buffer.from(authTagBase64, 'base64');
|
||||
|
||||
// IV and authTag must decode to exactly the expected byte lengths
|
||||
if (iv.length !== IV_LENGTH) return false;
|
||||
if (authTag.length !== AUTH_TAG_LENGTH) return false;
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random encryption key (32 bytes)
|
||||
* @returns Base64-encoded random key
|
||||
|
||||
Reference in New Issue
Block a user