32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
/**
|
|
* Repository for refresh token storage and lifecycle management.
|
|
* Handles creation, lookup, and cleanup of JWT refresh tokens.
|
|
*/
|
|
/**
|
|
* Stores a new refresh token for a user.
|
|
* @param userId - ID of the user who owns the token.
|
|
* @param tokenHash - Hashed token value (never store the raw token).
|
|
* @param expiresAt - Expiration timestamp for the token.
|
|
* @returns Resolves when the row has been inserted.
|
|
*/
|
|
export declare function create(userId: string, tokenHash: string, expiresAt: Date): Promise<void>;
|
|
/**
|
|
* Finds a non-expired refresh token by its hash.
|
|
* @param tokenHash - Hashed token value to look up.
|
|
* @returns The owning user ID, or null if the token is missing or expired.
|
|
*/
|
|
export declare function findByTokenHash(tokenHash: string): Promise<{
|
|
user_id: string;
|
|
} | null>;
|
|
/**
|
|
* Deletes all refresh tokens for a user (e.g. on logout or password change).
|
|
* @param userId - ID of the user whose tokens should be removed.
|
|
* @returns Resolves when matching rows have been deleted.
|
|
*/
|
|
export declare function deleteByUserId(userId: string): Promise<void>;
|
|
/**
|
|
* Removes all refresh tokens that have passed their expiration time.
|
|
* @returns Resolves when expired rows have been deleted.
|
|
*/
|
|
export declare function deleteExpired(): Promise<void>;
|
|
//# sourceMappingURL=refreshTokenRepository.d.ts.map
|