Move the constants (mostly) into common package

This commit is contained in:
2023-05-30 20:22:34 -04:00
parent 97becd8c53
commit d330dceebe
19 changed files with 1358 additions and 29 deletions

View File

@@ -0,0 +1,15 @@
import { LOGIN_VALID_TIMEOUT, RESET_VALID_TIMEOUT, VERIFY_VALID_TIMEOUT } from '../env/timeouts';
import { TokenType } from '../enums/tokens';
import { parseTimeoutToMs } from './parseTimeoutToMs';
export const getDefaultExpiresFor = (type: TokenType | void) => {
if (type === TokenType.RESET) {
return Date.now() + parseTimeoutToMs(RESET_VALID_TIMEOUT);
}
if (type === TokenType.VERIFICATION) {
return Date.now() + parseTimeoutToMs(VERIFY_VALID_TIMEOUT);
}
return Date.now() + parseTimeoutToMs(LOGIN_VALID_TIMEOUT);
};