// Tickets as the dashboard signs them, made in Node for the server's tests // (the Python oracle shows the same JSON at the same moment: ticket.test.ts). import { deflateSync } from 'node:zlib'; import { signature, TICKET_SALT } from '../src/ticket.js'; export function signTicket(payload: unknown, secret: string, at = Math.floor(Date.now() / 1000), salt = TICKET_SALT): string { const json = Buffer.from(JSON.stringify(payload)); const packed = deflateSync(json); const body = packed.length < json.length - 1 ? `.${packed.toString('base64url')}` : json.toString('base64url'); let stamp = Buffer.alloc(0); for (let rest = at; rest > 0; rest = Math.floor(rest / 256)) stamp = Buffer.concat([Buffer.from([rest % 256]), stamp]); const value = `${body}.${stamp.toString('base64url')}`; return `${value}.${signature(value, secret, salt)}`; }