@@ -440,7 +440,7 @@ ca/T0LLtgmbMmxSv/MmzIg==
440
440
// assert session has been updated
441
441
const updatedSessionCookie = response . cookies . get ( "__session" ) ;
442
442
expect ( updatedSessionCookie ) . toBeDefined ( ) ;
443
- const updatedSessionCookieValue = await decrypt (
443
+ const { payload : updatedSessionCookieValue } = await decrypt (
444
444
updatedSessionCookie ! . value ,
445
445
secret
446
446
) ;
@@ -795,13 +795,15 @@ ca/T0LLtgmbMmxSv/MmzIg==
795
795
`__txn_${ authorizationUrl . searchParams . get ( "state" ) } `
796
796
) ;
797
797
expect ( transactionCookie ) . toBeDefined ( ) ;
798
- expect ( await decrypt ( transactionCookie ! . value , secret ) ) . toEqual ( {
799
- nonce : authorizationUrl . searchParams . get ( "nonce" ) ,
800
- codeVerifier : expect . any ( String ) ,
801
- responseType : "code" ,
802
- state : authorizationUrl . searchParams . get ( "state" ) ,
803
- returnTo : "/"
804
- } ) ;
798
+ expect ( ( await decrypt ( transactionCookie ! . value , secret ) ) . payload ) . toEqual (
799
+ {
800
+ nonce : authorizationUrl . searchParams . get ( "nonce" ) ,
801
+ codeVerifier : expect . any ( String ) ,
802
+ responseType : "code" ,
803
+ state : authorizationUrl . searchParams . get ( "state" ) ,
804
+ returnTo : "/"
805
+ }
806
+ ) ;
805
807
} ) ;
806
808
807
809
it ( "should return an error if the discovery endpoint could not be fetched" , async ( ) => {
@@ -911,7 +913,9 @@ ca/T0LLtgmbMmxSv/MmzIg==
911
913
`__txn_${ authorizationUrl . searchParams . get ( "state" ) } `
912
914
) ;
913
915
expect ( transactionCookie ) . toBeDefined ( ) ;
914
- expect ( await decrypt ( transactionCookie ! . value , secret ) ) . toEqual ( {
916
+ expect (
917
+ ( await decrypt ( transactionCookie ! . value , secret ) ) . payload
918
+ ) . toEqual ( {
915
919
nonce : authorizationUrl . searchParams . get ( "nonce" ) ,
916
920
codeVerifier : expect . any ( String ) ,
917
921
responseType : "code" ,
@@ -1243,14 +1247,16 @@ ca/T0LLtgmbMmxSv/MmzIg==
1243
1247
`__txn_${ authorizationUrl . searchParams . get ( "state" ) } `
1244
1248
) ;
1245
1249
expect ( transactionCookie ) . toBeDefined ( ) ;
1246
- expect ( await decrypt ( transactionCookie ! . value , secret ) ) . toEqual ( {
1247
- nonce : authorizationUrl . searchParams . get ( "nonce" ) ,
1248
- maxAge : 3600 ,
1249
- codeVerifier : expect . any ( String ) ,
1250
- responseType : "code" ,
1251
- state : authorizationUrl . searchParams . get ( "state" ) ,
1252
- returnTo : "/"
1253
- } ) ;
1250
+ expect ( ( await decrypt ( transactionCookie ! . value , secret ) ) . payload ) . toEqual (
1251
+ {
1252
+ nonce : authorizationUrl . searchParams . get ( "nonce" ) ,
1253
+ maxAge : 3600 ,
1254
+ codeVerifier : expect . any ( String ) ,
1255
+ responseType : "code" ,
1256
+ state : authorizationUrl . searchParams . get ( "state" ) ,
1257
+ returnTo : "/"
1258
+ }
1259
+ ) ;
1254
1260
} ) ;
1255
1261
1256
1262
it ( "should store the returnTo path in the transaction state" , async ( ) => {
@@ -1288,13 +1294,15 @@ ca/T0LLtgmbMmxSv/MmzIg==
1288
1294
`__txn_${ authorizationUrl . searchParams . get ( "state" ) } `
1289
1295
) ;
1290
1296
expect ( transactionCookie ) . toBeDefined ( ) ;
1291
- expect ( await decrypt ( transactionCookie ! . value , secret ) ) . toEqual ( {
1292
- nonce : authorizationUrl . searchParams . get ( "nonce" ) ,
1293
- codeVerifier : expect . any ( String ) ,
1294
- responseType : "code" ,
1295
- state : authorizationUrl . searchParams . get ( "state" ) ,
1296
- returnTo : "https://example.com/dashboard"
1297
- } ) ;
1297
+ expect ( ( await decrypt ( transactionCookie ! . value , secret ) ) . payload ) . toEqual (
1298
+ {
1299
+ nonce : authorizationUrl . searchParams . get ( "nonce" ) ,
1300
+ codeVerifier : expect . any ( String ) ,
1301
+ responseType : "code" ,
1302
+ state : authorizationUrl . searchParams . get ( "state" ) ,
1303
+ returnTo : "https://example.com/dashboard"
1304
+ }
1305
+ ) ;
1298
1306
} ) ;
1299
1307
1300
1308
it ( "should prevent open redirects originating from the returnTo parameter" , async ( ) => {
@@ -1332,13 +1340,15 @@ ca/T0LLtgmbMmxSv/MmzIg==
1332
1340
`__txn_${ authorizationUrl . searchParams . get ( "state" ) } `
1333
1341
) ;
1334
1342
expect ( transactionCookie ) . toBeDefined ( ) ;
1335
- expect ( await decrypt ( transactionCookie ! . value , secret ) ) . toEqual ( {
1336
- nonce : authorizationUrl . searchParams . get ( "nonce" ) ,
1337
- codeVerifier : expect . any ( String ) ,
1338
- responseType : "code" ,
1339
- state : authorizationUrl . searchParams . get ( "state" ) ,
1340
- returnTo : "/"
1341
- } ) ;
1343
+ expect ( ( await decrypt ( transactionCookie ! . value , secret ) ) . payload ) . toEqual (
1344
+ {
1345
+ nonce : authorizationUrl . searchParams . get ( "nonce" ) ,
1346
+ codeVerifier : expect . any ( String ) ,
1347
+ responseType : "code" ,
1348
+ state : authorizationUrl . searchParams . get ( "state" ) ,
1349
+ returnTo : "/"
1350
+ }
1351
+ ) ;
1342
1352
} ) ;
1343
1353
1344
1354
describe ( "with pushed authorization requests" , async ( ) => {
@@ -1463,7 +1473,9 @@ ca/T0LLtgmbMmxSv/MmzIg==
1463
1473
const transactionCookie = transactionCookies [ 0 ] ;
1464
1474
const state = transactionCookie . name . replace ( "__txn_" , "" ) ;
1465
1475
expect ( transactionCookie ) . toBeDefined ( ) ;
1466
- expect ( await decrypt ( transactionCookie ! . value , secret ) ) . toEqual ( {
1476
+ expect (
1477
+ ( await decrypt ( transactionCookie ! . value , secret ) ) . payload
1478
+ ) . toEqual ( {
1467
1479
nonce : expect . any ( String ) ,
1468
1480
codeVerifier : expect . any ( String ) ,
1469
1481
responseType : "code" ,
@@ -1540,7 +1552,9 @@ ca/T0LLtgmbMmxSv/MmzIg==
1540
1552
const transactionCookie = transactionCookies [ 0 ] ;
1541
1553
const state = transactionCookie . name . replace ( "__txn_" , "" ) ;
1542
1554
expect ( transactionCookie ) . toBeDefined ( ) ;
1543
- expect ( await decrypt ( transactionCookie ! . value , secret ) ) . toEqual ( {
1555
+ expect (
1556
+ ( await decrypt ( transactionCookie ! . value , secret ) ) . payload
1557
+ ) . toEqual ( {
1544
1558
nonce : expect . any ( String ) ,
1545
1559
codeVerifier : expect . any ( String ) ,
1546
1560
responseType : "code" ,
@@ -1618,7 +1632,9 @@ ca/T0LLtgmbMmxSv/MmzIg==
1618
1632
const transactionCookie = transactionCookies [ 0 ] ;
1619
1633
const state = transactionCookie . name . replace ( "__txn_" , "" ) ;
1620
1634
expect ( transactionCookie ) . toBeDefined ( ) ;
1621
- expect ( await decrypt ( transactionCookie ! . value , secret ) ) . toEqual ( {
1635
+ expect (
1636
+ ( await decrypt ( transactionCookie ! . value , secret ) ) . payload
1637
+ ) . toEqual ( {
1622
1638
nonce : expect . any ( String ) ,
1623
1639
codeVerifier : expect . any ( String ) ,
1624
1640
responseType : "code" ,
@@ -2122,7 +2138,7 @@ ca/T0LLtgmbMmxSv/MmzIg==
2122
2138
// validate the session cookie
2123
2139
const sessionCookie = response . cookies . get ( "__session" ) ;
2124
2140
expect ( sessionCookie ) . toBeDefined ( ) ;
2125
- const session = await decrypt ( sessionCookie ! . value , secret ) ;
2141
+ const { payload : session } = await decrypt ( sessionCookie ! . value , secret ) ;
2126
2142
expect ( session ) . toEqual ( {
2127
2143
user : {
2128
2144
sub : DEFAULT . sub
@@ -2230,7 +2246,7 @@ ca/T0LLtgmbMmxSv/MmzIg==
2230
2246
// validate the session cookie
2231
2247
const sessionCookie = response . cookies . get ( "__session" ) ;
2232
2248
expect ( sessionCookie ) . toBeDefined ( ) ;
2233
- const session = await decrypt ( sessionCookie ! . value , secret ) ;
2249
+ const { payload : session } = await decrypt ( sessionCookie ! . value , secret ) ;
2234
2250
expect ( session ) . toEqual ( {
2235
2251
user : {
2236
2252
sub : DEFAULT . sub
@@ -2601,7 +2617,10 @@ ca/T0LLtgmbMmxSv/MmzIg==
2601
2617
// validate the session cookie
2602
2618
const sessionCookie = response . cookies . get ( "__session" ) ;
2603
2619
expect ( sessionCookie ) . toBeDefined ( ) ;
2604
- const session = await decrypt ( sessionCookie ! . value , secret ) ;
2620
+ const { payload : session } = await decrypt (
2621
+ sessionCookie ! . value ,
2622
+ secret
2623
+ ) ;
2605
2624
expect ( session ) . toEqual ( expectedSession ) ;
2606
2625
} ) ;
2607
2626
@@ -3051,7 +3070,10 @@ ca/T0LLtgmbMmxSv/MmzIg==
3051
3070
// validate the session cookie
3052
3071
const sessionCookie = response . cookies . get ( "__session" ) ;
3053
3072
expect ( sessionCookie ) . toBeDefined ( ) ;
3054
- const session = await decrypt ( sessionCookie ! . value , secret ) ;
3073
+ const { payload : session } = await decrypt (
3074
+ sessionCookie ! . value ,
3075
+ secret
3076
+ ) ;
3055
3077
expect ( session ) . toEqual ( {
3056
3078
user : {
3057
3079
sub : DEFAULT . sub ,
@@ -3177,7 +3199,10 @@ ca/T0LLtgmbMmxSv/MmzIg==
3177
3199
// validate the session cookie
3178
3200
const sessionCookie = response . cookies . get ( "__session" ) ;
3179
3201
expect ( sessionCookie ) . toBeDefined ( ) ;
3180
- const session = await decrypt ( sessionCookie ! . value , secret ) ;
3202
+ const { payload : session } = await decrypt (
3203
+ sessionCookie ! . value ,
3204
+ secret
3205
+ ) ;
3181
3206
expect ( session ) . toEqual ( {
3182
3207
user : {
3183
3208
sub : DEFAULT . sub ,
@@ -3273,7 +3298,7 @@ ca/T0LLtgmbMmxSv/MmzIg==
3273
3298
3274
3299
// validate that the session cookie has been updated
3275
3300
const updatedSessionCookie = response . cookies . get ( "__session" ) ;
3276
- const updatedSession = await decrypt < SessionData > (
3301
+ const { payload : updatedSession } = await decrypt < SessionData > (
3277
3302
updatedSessionCookie ! . value ,
3278
3303
secret
3279
3304
) ;
0 commit comments