File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import type { APIRoute } from "astro" ;
1+ import type { APIRoute , AstroCookieSetOptions } from "astro" ;
22import { isHex } from "viem" ;
33import { corsHeaders } from "../../lib/cors" ;
44
@@ -22,9 +22,9 @@ export const POST: APIRoute = async ({ request, cookies }) => {
2222 const cookieOptions = {
2323 httpOnly : true ,
2424 secure : true ,
25- sameSite : "none " ,
25+ sameSite : "strict " ,
2626 path : "/" ,
27- } as const ;
27+ } as AstroCookieSetOptions ;
2828 cookies . set ( "xnode_auth_user" , user , cookieOptions ) ;
2929 if ( user ?. startsWith ( "eth:" ) ) {
3030 const signature = body . signature ;
Original file line number Diff line number Diff line change @@ -27,14 +27,21 @@ export const GET: APIRoute = async ({ request, cookies }) => {
2727
2828 const ip = request . headers . get ( "X-Forwarded-For" ) ;
2929
30- let requestedUser = cookies . get ( "xnode_auth_user" ) ?. value ;
30+ let requestedUser =
31+ cookies . get ( "xnode_auth_user" ) ?. value ??
32+ request . headers . get ( "Xnode-Auth-User" ) ??
33+ undefined ;
3134 if ( requestedUser ?. startsWith ( "eth:" ) ) {
32- const signature = cookies . get ( "xnode_auth_signature" ) ?. value ;
33- const timestamp = cookies . get ( "xnode_auth_timestamp " ) ?. value ;
34-
35+ const signature =
36+ cookies . get ( "xnode_auth_signature " ) ?. value ??
37+ request . headers . get ( "Xnode-Auth-Signature" ) ;
3538 if ( ! isHex ( signature ) ) {
3639 throw new Error ( `Signature ${ signature } is not valid hex.` ) ;
3740 }
41+
42+ const timestamp =
43+ cookies . get ( "xnode_auth_timestamp" ) ?. value ??
44+ request . headers . get ( "Xnode-Auth-Timestamp" ) ;
3845 if ( ! timestamp || isNaN ( Number ( timestamp ) ) ) {
3946 // add checks if timestamp in the future or too far in the past
4047 throw new Error ( `Timestamp ${ timestamp } is not a valid number.` ) ;
You can’t perform that action at this time.
0 commit comments