Skip to content

Commit

Permalink
feat: improve error reporting for invalid magic links
Browse files Browse the repository at this point in the history
feat: improve error reporting for invalid magic links

feat: improve error reporting for invalid magic links

fix: unkown template literal error

fix: unkown template literal error
  • Loading branch information
aashir-motorway committed Nov 9, 2024
1 parent 21f72ff commit 91fc996
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/magic-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ function checkCurrentLocationForSignInLink() {
debug?.("Magic link header parsed:", message);
assertIsMessage(message);
} catch (err) {
debug?.("Ignoring invalid fragment identifier");
const errorMessage = err instanceof Error ? err.message : String(err);
debug?.(`Ignoring invalid fragment identifier: ${errorMessage}`);
return;
}
if (!message.userName || typeof message.userName !== "string") {
Expand Down Expand Up @@ -168,7 +169,9 @@ function assertIsMessage(
!("iat" in msg) ||
typeof msg.iat !== "number"
) {
throw new Error("Invalid magic link");
throw new Error(
"Invalid magic link, expecting exp, iat, and userName to be present"
);
}
}

Expand Down

0 comments on commit 91fc996

Please sign in to comment.