(payload = {}, options = {})
| 8 | * Generate a JWT token for testing |
| 9 | */ |
| 10 | export function generateTestToken(payload = {}, options = {}) { |
| 11 | const defaultPayload = { |
| 12 | id: 1, |
| 13 | email: "test@example.com", |
| 14 | name: "Test User", |
| 15 | ...payload |
| 16 | }; |
| 17 | |
| 18 | const defaultOptions = { |
| 19 | expiresIn: "1h", |
| 20 | ...options |
| 21 | }; |
| 22 | |
| 23 | // Use the same secret as the server for JWT verification |
| 24 | const secret = process.env.CB_ENCRYPTION_KEY_DEV || process.env.CB_ENCRYPTION_KEY || "0123456789abcdef0123456789abcdef"; |
| 25 | return jwt.sign(defaultPayload, secret, defaultOptions); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Generate auth headers for testing |
no outgoing calls