File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export async function sessionHooks({ event }: { event: EventHandler }) {
16
16
secure : process . env . NODE_ENV === "production" ,
17
17
sameSite : "lax" ,
18
18
httpOnly : true ,
19
+ maxAge : 29 * 24 * 60 * 60 ,
19
20
} ,
20
21
) ;
21
22
} ;
Original file line number Diff line number Diff line change @@ -154,4 +154,34 @@ describe("sessionHooks", () => {
154
154
expect ( retrievedValue1 ) . toBeUndefined ( ) ;
155
155
expect ( retrievedValue2 ) . toBeUndefined ( ) ;
156
156
} ) ;
157
+
158
+ it ( "should set cookies with 29-day expiry" , async ( ) => {
159
+ // Arrange
160
+ const event = {
161
+ request : { } ,
162
+ cookies : {
163
+ set : vi . fn ( ) ,
164
+ get : vi . fn ( ) ,
165
+ } ,
166
+ } ;
167
+
168
+ await sessionHooks ( { event } ) ;
169
+
170
+ // Act
171
+ await event . request . setSessionItem ( "testKey" , "testValue" ) ;
172
+
173
+ // Assert
174
+ expect ( event . cookies . set ) . toHaveBeenCalledWith (
175
+ "kinde_testKey" ,
176
+ "testValue" ,
177
+ expect . objectContaining ( {
178
+ maxAge : 29 * 24 * 60 * 60 ,
179
+ domain : process . env . KINDE_COOKIE_DOMAIN ,
180
+ path : "/" ,
181
+ secure : process . env . NODE_ENV === "production" ,
182
+ sameSite : "lax" ,
183
+ httpOnly : true ,
184
+ } ) ,
185
+ ) ;
186
+ } ) ;
157
187
} ) ;
You can’t perform that action at this time.
0 commit comments