[READ-ONLY] Mirror of https://github.com/thoda-dev/shhh. Self-hostable zero-knowledge pastebin for secrets that expire on their own
docker end-to-end-encryption nuxt nuxtjs pastebin secrets selft-hosted zero-knowledge
Something went wrong. Try again.
12345678910111213141516171819import { z } from 'zod'
export const pasteIdParamSchema = z.string().uuid()
export function isPasteAccessible(paste: { expiresAt: Date, maxReads: number | null, readCount: number }) { if (paste.expiresAt.getTime() <= Date.now()) return false if (paste.maxReads !== null && paste.readCount >= paste.maxReads) return false return true}
// The SQL counterpart of `isPasteAccessible`, negated: what the hourly purge deletes, and what the// admin tools count and delete on demand. One definition, so no caller can drift from the others.export function isPasteReclaimable() { return or( lte(schema.pastes.expiresAt, new Date()), and(isNotNull(schema.pastes.maxReads), gte(schema.pastes.readCount, schema.pastes.maxReads)) )}