( token: string, userId: string )
| 14 | } |
| 15 | |
| 16 | export async function createSession( |
| 17 | token: string, |
| 18 | userId: string |
| 19 | ): Promise<Session> { |
| 20 | const sessionId = encodeHexLowerCase(sha256(new TextEncoder().encode(token))); |
| 21 | const session: Session = { |
| 22 | id: sessionId, |
| 23 | userId, |
| 24 | expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30), |
| 25 | createdAt: new Date(), |
| 26 | updatedAt: new Date(), |
| 27 | }; |
| 28 | await db.session.create({ |
| 29 | data: session, |
| 30 | }); |
| 31 | return session; |
| 32 | } |
| 33 | |
| 34 | export const EMPTY_SESSION: SessionValidationResult = { |
| 35 | session: null, |
no outgoing calls
no test coverage detected