/** * JWT creation helpers for testing * * Provides functions to create valid and expired JWTs for testing * authentication flows. * * @example * ```typescript * // Create a valid JWT * const jwt = await createTestJWT('your-secret', { * sub: 'user-123', * username: 'TestUser', * global_name: 'Test User', * }); * * // Create an expired JWT for testing expiration handling * const expiredJwt = await createExpiredJWT('your-secret'); * * // Use in request headers * const response = await fetch('/api/protected', { * headers: { Authorization: `Bearer ${jwt}` }, * }); * ``` */ /** * JWT payload for test tokens */ export interface TestJWTPayload { /** Subject (user ID) */ sub: string; /** Username */ username: string; /** Display name (optional) */ global_name?: string | null; /** Avatar hash (optional) */ avatar?: string | null; } /** * Full JWT payload including standard claims */ export interface FullJWTPayload extends TestJWTPayload { /** Issued at (Unix timestamp) */ iat: number; /** Expiration (Unix timestamp) */ exp: number; /** Issuer */ iss: string; } /** * Creates a valid JWT for testing * * @param secret - The JWT signing secret * @param payload - The JWT payload (sub, username, etc.) * @param expiresInSeconds - How long until the token expires (default: 3600 = 1 hour) * @param issuer - The token issuer (default: 'xivdyetools-oauth-worker') * @returns A signed JWT string */ export declare function createTestJWT(secret: string, payload: TestJWTPayload, expiresInSeconds?: number, issuer?: string): Promise; /** * Creates an expired JWT for testing expiration handling * * @param secret - The JWT signing secret * @param payload - Optional custom payload (defaults provided) * @returns A signed but expired JWT string */ export declare function createExpiredJWT(secret: string, payload?: TestJWTPayload): Promise; /** * Creates a JWT with a specific expiration time * * @param secret - The JWT signing secret * @param payload - The JWT payload * @param expTimestamp - The expiration Unix timestamp * @returns A signed JWT string */ export declare function createJWTWithExpiration(secret: string, payload: TestJWTPayload, expTimestamp: number): Promise; //# sourceMappingURL=jwt.d.ts.map