caelum0x f80b04ae0f feat(ritgram): move GitGram app into railyard as Ritgram, next to Rithub
Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram).
AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan.
Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-13 04:18:46 +03:00

53 lines
1.6 KiB
TypeScript

import jwt from 'jsonwebtoken';
const JWT_SECRET = process.env.JWT_SECRET || 'test-secret-key';
const JWT_REFRESH_SECRET = process.env.JWT_REFRESH_SECRET || 'test-refresh-secret';
/**
* Generate a valid access token for testing
*/
export function generateTestAccessToken(userId: string, expiresIn: string = '15m'): string {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return jwt.sign({ userId, type: 'access' }, JWT_SECRET, { expiresIn } as any);
}
/**
* Generate a valid refresh token for testing
*/
export function generateTestRefreshToken(userId: string, expiresIn: string = '7d'): string {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return jwt.sign({ userId, type: 'refresh' }, JWT_REFRESH_SECRET, { expiresIn } as any);
}
/**
* Generate both access and refresh tokens
*/
export function generateTestTokens(userId: string) {
return {
accessToken: generateTestAccessToken(userId),
refreshToken: generateTestRefreshToken(userId),
};
}
/**
* Generate an expired access token for testing auth failures
*/
export function generateExpiredToken(userId: string): string {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return jwt.sign({ userId, type: 'access' }, JWT_SECRET, { expiresIn: '0s' } as any);
}
/**
* Create auth header value
*/
export function authHeader(token: string): string {
return `Bearer ${token}`;
}
/**
* Standard test user IDs
*/
export const TEST_USER_ID = 'test-user-id-001';
export const TEST_USER_ID_2 = 'test-user-id-002';
export const TEST_ADMIN_ID = 'test-admin-id-001';