diff --git a/web/netlify/functions/authUser.ts b/web/netlify/functions/authUser.ts index ab320ff81..a672f322e 100644 --- a/web/netlify/functions/authUser.ts +++ b/web/netlify/functions/authUser.ts @@ -1,11 +1,13 @@ import middy from "@middy/core"; import jsonBodyParser from "@middy/http-json-body-parser"; -import { ETH_SIGNATURE_REGEX } from "consts/index"; -import { DEFAULT_CHAIN } from "consts/chains"; -import { SiweMessage } from "siwe"; -import * as jwt from "jose"; import { createClient } from "@supabase/supabase-js"; -import { netlifyUri } from "src/generatedNetlifyInfo.json"; +import * as jwt from "jose"; +import { SiweMessage } from "siwe"; + +import { DEFAULT_CHAIN } from "consts/chains"; +import { ETH_SIGNATURE_REGEX } from "consts/index"; + +import { netlifyUri, netlifyDeployUri } from "src/generatedNetlifyInfo.json"; import { Database } from "src/types/supabase-notification"; const authUser = async (event) => { @@ -35,7 +37,9 @@ const authUser = async (event) => { const siweMessage = new SiweMessage(message); - if (netlifyUri && netlifyUri !== siweMessage.uri) { + console.log({ netlifyUri, netlifyDeployUri }); + + if (netlifyUri && netlifyUri !== siweMessage.uri && netlifyDeployUri && netlifyDeployUri !== siweMessage.uri) { console.debug(`Invalid URI: expected ${netlifyUri} but got ${siweMessage.uri}`); throw new Error(`Invalid URI`); } @@ -45,11 +49,6 @@ const authUser = async (event) => { throw new Error(`Invalid chain ID`); } - if (!siweMessage.expirationTime || Date.parse(siweMessage.expirationTime) < Date.now()) { - console.debug(`Message expired: ${siweMessage.expirationTime} < ${new Date().toISOString()}`); - throw new Error("Message expired"); - } - const lowerCaseAddress = siweMessage.address.toLowerCase(); if (lowerCaseAddress !== address.toLowerCase()) { throw new Error("Address mismatch in provided address and message"); diff --git a/web/scripts/generateBuildInfo.sh b/web/scripts/generateBuildInfo.sh index 083ea4f9f..43e72fc7f 100755 --- a/web/scripts/generateBuildInfo.sh +++ b/web/scripts/generateBuildInfo.sh @@ -2,5 +2,5 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -jq -n --arg uri "$DEPLOY_PRIME_URL" '{ netlifyUri: $uri }' > src/generatedNetlifyInfo.json +jq -n --arg primeUri "$DEPLOY_PRIME_URL" --arg uri "$URL" '{ netlifyDeployUri: $primeUri, netlifyUri: $uri }' > src/generatedNetlifyInfo.json node $SCRIPT_DIR/gitInfo.js \ No newline at end of file