ES

@core / jobs

1.1.0 ▾
verificadoMIT
GitHub

Tareas en segundo plano sobre Postgres: cola durable, reintentos con backoff, cron y endpoint para serverless

Código9 archivosContexto~696 tokensescaneo superado

El árbol exacto que se inyectará, tras aplicar .genpmignore. Anclado a

src/lib/jobs/cron-auth.tssolo lectura · eef017d
// Protección del endpoint de cron: `Authorization: Bearer <CRON_SECRET>` comparado en tiempo constante.

export function isAuthorizedCron(authorization: string | null | undefined, secret = process.env.CRON_SECRET): boolean {
  if (!secret || secret.length < 32) throw new Error('CRON_SECRET must be set (>= 32 chars)');
  const given = new TextEncoder().encode(authorization ?? '');
  const expected = new TextEncoder().encode(`Bearer ${secret}`);
  let diff = given.length ^ expected.length;
  for (let i = 0; i < expected.length; i++) diff |= (given[i] ?? 0) ^ expected[i]!;
  return diff === 0;
}

Reportar @core/jobs

Inicia sesión con GitHub para reportar un paquete.