|
|
|
@ -4,15 +4,13 @@ import expressSession, { |
|
|
|
|
Store as BaseSessionStore, |
|
|
|
|
} from 'express-session'; |
|
|
|
|
|
|
|
|
|
import { DELETED } from '../lib/consts'; |
|
|
|
|
import { COOKIE_ORIGINAL_MAX_AGE, DELETED } from '../lib/consts'; |
|
|
|
|
|
|
|
|
|
import { getLocalHostUUID, query, timestamp, write } from '../lib/accessModule'; |
|
|
|
|
import { cname } from '../lib/cname'; |
|
|
|
|
import { getSessionSecret } from '../lib/getSessionSecret'; |
|
|
|
|
import { stderr, stdout, stdoutVar, uuid } from '../lib/shell'; |
|
|
|
|
|
|
|
|
|
const DEFAULT_COOKIE_ORIGINAL_MAX_AGE = 28800000; // 8 hours
|
|
|
|
|
|
|
|
|
|
export class SessionStore extends BaseSessionStore { |
|
|
|
|
constructor(options = {}) { |
|
|
|
|
super(options); |
|
|
|
@ -85,7 +83,7 @@ export class SessionStore extends BaseSessionStore { |
|
|
|
|
const data: SessionData = { |
|
|
|
|
cookie: { |
|
|
|
|
maxAge: cookieMaxAge, |
|
|
|
|
originalMaxAge: DEFAULT_COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
|
originalMaxAge: COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
|
}, |
|
|
|
|
passport: { user: userUuid }, |
|
|
|
|
}; |
|
|
|
@ -169,7 +167,7 @@ export class SessionStore extends BaseSessionStore { |
|
|
|
|
|
|
|
|
|
public static calculateCookieMaxAge( |
|
|
|
|
sessionModifiedDate: string, |
|
|
|
|
cookieOriginalMaxAge: number = DEFAULT_COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
|
cookieOriginalMaxAge: number = COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
|
) { |
|
|
|
|
const sessionModifiedEpoch = Date.parse(sessionModifiedDate); |
|
|
|
|
const sessionDeadlineEpoch = sessionModifiedEpoch + cookieOriginalMaxAge; |
|
|
|
@ -185,7 +183,7 @@ export default (async () => |
|
|
|
|
expressSession({ |
|
|
|
|
cookie: { |
|
|
|
|
httpOnly: true, |
|
|
|
|
maxAge: DEFAULT_COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
|
maxAge: COOKIE_ORIGINAL_MAX_AGE, |
|
|
|
|
secure: false, |
|
|
|
|
}, |
|
|
|
|
genid: ({ originalUrl }) => { |
|
|
|
|