@@ -51,8 +51,8 @@ function dbInit(): sqlite.Database {
5151 db .run (`
5252 CREATE TABLE IF NOT EXISTS session (
5353 id_hash TEXT PRIMARY KEY,
54- session_exp INTEGER NOT NULL,
55- token_exp INTEGER NOT NULL,
54+ session_exp_epoch_ms INTEGER NOT NULL,
55+ token_exp_epoch_ms INTEGER NOT NULL,
5656 token_1_hash TEXT NOT NULL,
5757 token_2_hash TEXT
5858 )
@@ -66,8 +66,8 @@ function dbSelectSession(db: sqlite.Database, idHash: string): tcs.SessionData |
6666 return undefined ;
6767 }
6868 return {
69- sessionExp: new Date ( row .session_exp ) ,
70- tokenExp: new Date ( row .token_exp ) ,
69+ sessionExpEpochMs: row .session_exp_epoch_ms ,
70+ tokenExpEpochMs: row .token_exp_epoch_ms ,
7171 token1Hash: row .token_1_hash ,
7272 token2Hash: row .token_2_hash ,
7373 };
@@ -76,13 +76,13 @@ function dbSelectSession(db: sqlite.Database, idHash: string): tcs.SessionData |
7676function dbSetSession(db : sqlite .Database , action : tcs .SetSessionAction ): void {
7777 db .query (
7878 `
79- INSERT OR REPLACE INTO session (id_hash, session_exp, token_exp , token_1_hash, token_2_hash)
80- VALUES (:idHash, :sessionExp , :tokenExp , :token1Hash, :token2Hash)
79+ INSERT OR REPLACE INTO session (id_hash, session_exp_epoch_ms, token_exp_epoch_ms , token_1_hash, token_2_hash)
80+ VALUES (:idHash, :sessionExpEpochMs , :tokenExpEpochMs , :token1Hash, :token2Hash)
8181 ` ,
8282 ).run ({
8383 idHash: action .idHash ,
84- sessionExp : action .sessionData .sessionExp . getTime () ,
85- tokenExp : action .sessionData .tokenExp . getTime () ,
84+ sessionExpEpochMs : action .sessionData .sessionExpEpochMs ,
85+ tokenExpEpochMs : action .sessionData .tokenExpEpochMs ,
8686 token1Hash: action .sessionData .token1Hash ,
8787 token2Hash: action .sessionData .token2Hash ,
8888 });
@@ -208,8 +208,8 @@ You can use custom expiration times by passing configuration options to the func
208208import * as tcs from " tiny-cookie-session" ;
209209
210210const config = {
211- sessionExpiresIn : 5 * 60 * 60 * 1000 , // 5 hours
212- tokenExpiresIn : 10 * 60 * 1000 , // 10 minutes
211+ sessionExpiresInMs : 5 * 60 * 60 * 1000 , // 5 hours
212+ tokenExpiresInMs : 10 * 60 * 1000 , // 10 minutes
213213};
214214
215215tcs .consume ({ config /* other params */ });
@@ -219,21 +219,21 @@ tcs.login({ config });
219219
220220### Session Expiration Time
221221
222- The ` sessionExpiresIn ` value controls how long a session can remain active without user interaction,
222+ The ` sessionExpiresInMs ` value controls how long a session can remain active without user interaction,
223223often referred to as "log out after X minutes of inactivity."
224224
225- For example, with ` sessionExpiresIn : 30 * 60 * 1000` (30 minutes),
225+ For example, with ` sessionExpiresInMs : 30 * 60 * 1000` (30 minutes),
226226a user can remain logged in indefinitely by making requests at least every 29 minutes.
227227
228228### Token Expiration Time
229229
230- The ` tokenExpiresIn ` value controls how often the token is rotated.
230+ The ` tokenExpiresInMs ` value controls how often the token is rotated.
231231When a token expires but the session is still valid, the system generates a new token.
232232
233233You should set this to a value as short as possible, but still longer than the longest HTTP request
234234time your users might experience.
235235For example, if your app might take up to 3 minutes (in a single request) for uploading large files,
236- you should set ` tokenExpiresIn ` to 3 minutes.
236+ you should set ` tokenExpiresInMs ` to 3 minutes.
237237The only reason we don't rotate the token on every request is to handle a race condition
238238where the user makes two requests at the same time.
239239
@@ -280,7 +280,7 @@ or to identify attackers from other signals (e.g., IP address, User-Agent, geolo
280280
281281There are two possible approaches to mitigate this risk:
282282
283- 1 . Set a short session expiration time (` sessionExpiresIn ` ).
283+ 1 . Set a short session expiration time (` sessionExpiresInMs ` ).
2842842 . Implement a "Don't remember me" option.
285285
286286The "Don't remember me" feature can be implemented by removing the ` Expires ` and ` Max-Age `
0 commit comments