Examples
Service Account Pattern
const clients = {
reader: new VercelClient({
apiKey: process.env.VERCEL_READ_KEY,
}),
writer: new VercelClient({
apiKey: process.env.VERCEL_WRITE_KEY,
}),
};
Webhook Signature Verification
import crypto from 'crypto';
function verifyWebhookSignature(
payload: string, signature: string, secret: string
): boolean {
const expected = crypto.createHmac('sha256', secret).update(payload).digest('hex');
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}
Security Checklist
Audit Logging
interface AuditEntry {
timestamp: Date;
action: string;
userId: string;
resource: string;
result: 'success' | 'failure';
metadata?: Record<string, any>;
}
async function auditLog(entry: Omit<AuditEntry, 'timestamp'>): Promise<void> {
const log: AuditEntry = { ...entry, timestamp: new Date() };
// Log to Vercel analytics
await vercelClient.track('audit', log);
// Also log locally for compliance
console.log('[AUDIT]', JSON.stringify(log));
}
// Usage
await auditLog({
action: 'vercel.api.call',
userId: currentUser.id,
resource: '/v1/resource',
result: 'success',
});
Tons of Skills by Intent Solutions | jeremylongshore.com