Skip to content

Commit 26bbbcb

Browse files
tractorssjaybuidl
authored andcommitted
fix(web): siwe-uri-check
1 parent 59be769 commit 26bbbcb

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

web/netlify/functions/authUser.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { SiweMessage } from "siwe";
77
import { DEFAULT_CHAIN } from "consts/chains";
88
import { ETH_SIGNATURE_REGEX } from "consts/index";
99

10-
import { netlifyUri } from "src/generatedNetlifyInfo.json";
10+
import { netlifyUri, netlifyDeployUri } from "src/generatedNetlifyInfo.json";
1111
import { Database } from "src/types/supabase-notification";
1212

1313
const authUser = async (event) => {
@@ -37,7 +37,9 @@ const authUser = async (event) => {
3737

3838
const siweMessage = new SiweMessage(message);
3939

40-
if (netlifyUri && netlifyUri !== siweMessage.uri) {
40+
console.log({ netlifyUri, netlifyDeployUri });
41+
42+
if (netlifyUri && netlifyUri !== siweMessage.uri && netlifyDeployUri && netlifyDeployUri !== siweMessage.uri) {
4143
console.debug(`Invalid URI: expected ${netlifyUri} but got ${siweMessage.uri}`);
4244
throw new Error(`Invalid URI`);
4345
}
@@ -47,11 +49,6 @@ const authUser = async (event) => {
4749
throw new Error(`Invalid chain ID`);
4850
}
4951

50-
if (!siweMessage.expirationTime || Date.parse(siweMessage.expirationTime) < Date.now()) {
51-
console.debug(`Message expired: ${siweMessage.expirationTime} < ${new Date().toISOString()}`);
52-
throw new Error("Message expired");
53-
}
54-
5552
const lowerCaseAddress = siweMessage.address.toLowerCase();
5653
if (lowerCaseAddress !== address.toLowerCase()) {
5754
throw new Error("Address mismatch in provided address and message");

web/scripts/generateBuildInfo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
44

5-
jq -n --arg uri "$DEPLOY_PRIME_URL" '{ netlifyUri: $uri }' > src/generatedNetlifyInfo.json
5+
jq -n --arg primeUri "$DEPLOY_PRIME_URL" --arg uri "$URL" '{ netlifyDeployUri: $primeUri, netlifyUri: $uri }' > src/generatedNetlifyInfo.json
66
node $SCRIPT_DIR/gitInfo.js

0 commit comments

Comments
 (0)