(user: { id: string; email: string })
| 39 | ) {} |
| 40 | |
| 41 | private issue(user: { id: string; email: string }): AuthTokens { |
| 42 | const accessToken = signAccessToken( |
| 43 | { sub: user.id, email: user.email }, |
| 44 | this.cfg.jwtSecret, |
| 45 | this.cfg.accessTtlSec, |
| 46 | ); |
| 47 | const { token, tokenHash } = generateRefreshToken(); |
| 48 | this.store.refreshTokens.create({ |
| 49 | id: "rt_" + randomUUID(), |
| 50 | userId: user.id, |
| 51 | tokenHash, |
| 52 | expiresAt: Date.now() + this.cfg.refreshTtlSec * 1000, |
| 53 | createdAt: Date.now(), |
| 54 | }); |
| 55 | return { accessToken, refreshToken: token }; |
| 56 | } |
| 57 | |
| 58 | register(emailRaw: unknown, password: unknown): AuthResult { |
| 59 | const email = normEmail(emailRaw); |
no test coverage detected