/** * Badge Service * * HTTP service for serving certification badges with verification endpoints. * Designed for deployment on Vercel/Cloudflare edge with caching. * * @module badge-service */ import type { CertificationLevel } from "../certification/types.js"; /** * Certification record for badge lookup */ export interface CertificationRecord { /** Unique certification ID */ id: string; /** Project identifier (hashed) */ projectHash: string; /** Certification level */ level: CertificationLevel; /** Overall score (0-100) */ score: number; /** When certification was issued */ issuedAt: string; /** Expiration date (30 days from issue) */ expiresAt: string; /** Sigstore bundle for verification */ sigstoreBundle?: { mediaType: string; verificationMaterial: Record; messageSignature: Record; }; /** Rekor transparency log index */ rekorLogIndex?: number; /** Signature URL for verification */ signatureUrl?: string; /** Certificate URL for verification */ certUrl?: string; } /** * Verification response */ export interface VerificationResponse { /** Whether the certification is valid */ valid: boolean; /** Certification ID */ certificationId: string; /** Certification level if valid */ level?: CertificationLevel; /** Score if valid */ score?: number; /** Issue date */ issuedAt?: string; /** Expiration date */ expiresAt?: string; /** Whether it's expired */ expired?: boolean; /** Sigstore bundle if available */ sigstoreBundle?: CertificationRecord["sigstoreBundle"]; /** Rekor log index if available */ rekorLogIndex?: number; /** Verification command for CLI */ verifyCommand?: string; /** Error message if invalid */ error?: string; } /** * Badge embed code formats */ export interface BadgeEmbedCode { /** Markdown format */ markdown: string; /** HTML format */ html: string; /** Badge URL */ url: string; /** Verification URL */ verifyUrl: string; } /** * Interface for certification storage */ export interface CertificationStorage { /** Get certification by ID */ getCertification(id: string): Promise; /** Store a certification */ storeCertification(record: CertificationRecord): Promise; /** List all certifications */ listCertifications(): Promise; } /** * In-memory storage for development/testing */ export declare class MemoryCertificationStorage implements CertificationStorage { private certifications; getCertification(id: string): Promise; storeCertification(record: CertificationRecord): Promise; listCertifications(): Promise; } /** * Generate an expired/invalid badge SVG */ export declare function generateExpiredBadgeSvg(): string; /** * Generate a not-found badge SVG */ export declare function generateNotFoundBadgeSvg(): string; /** * Check if a certification is expired */ export declare function isExpired(cert: CertificationRecord, graceMinutes?: number): boolean; /** * Add days to a date */ export declare function addDays(dateStr: string, days: number): string; /** * Generate embed code for a certification badge */ export declare function generateBadgeEmbedCode(certificationId: string, baseUrl?: string): BadgeEmbedCode; /** * Handle badge SVG request */ export declare function handleBadgeRequest(certId: string, storage: CertificationStorage): Promise<{ svg: string; status: number; headers: Record; }>; /** * Handle verification request */ export declare function handleVerifyRequest(certId: string, storage: CertificationStorage): Promise<{ json: VerificationResponse; status: number; }>; /** * Handle embed code request */ export declare function handleEmbedRequest(certId: string, storage: CertificationStorage, baseUrl?: string): Promise<{ json: BadgeEmbedCode | { error: string; }; status: number; }>; export { generateBadgeSvg, generateScoreBadgeSvg, } from "../certification/badge.js"; //# sourceMappingURL=index.d.ts.map