-
Notifications
You must be signed in to change notification settings - Fork 675
Strip URL scheme from login domain #8706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "thirdweb": minor | ||
| --- | ||
|
|
||
| Stripe URL scheme from SIWE domain across all touchpoints | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,14 @@ | ||||||||||||||||||
| import type { LoginPayload } from "./types.js"; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Strips the URL scheme (e.g. "https://") from a domain string. | ||||||||||||||||||
| * Per EIP-4361, the domain field should be an RFC 3986 authority (host without scheme). | ||||||||||||||||||
| * @internal | ||||||||||||||||||
| */ | ||||||||||||||||||
| export function stripUrlScheme(domain: string): string { | ||||||||||||||||||
| return domain.replace(/^https?:\/\//, ""); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The regex pattern is case-sensitive and will fail to strip uppercase scheme variants like Impact: Domains like Fix: Make the regex case-insensitive: export function stripUrlScheme(domain: string): string {
return domain.replace(/^https?:\/\//i, "");
}
Suggested change
Spotted by Graphite
0xFirekeeper marked this conversation as resolved.
Outdated
|
||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Create an EIP-4361 & CAIP-122 compliant message to sign based on the login payload | ||||||||||||||||||
| * @param payload - The login payload containing the necessary information. | ||||||||||||||||||
|
|
@@ -8,7 +17,8 @@ import type { LoginPayload } from "./types.js"; | |||||||||||||||||
| */ | ||||||||||||||||||
| export function createLoginMessage(payload: LoginPayload): string { | ||||||||||||||||||
| const typeField = "Ethereum"; | ||||||||||||||||||
| const header = `${payload.domain} wants you to sign in with your ${typeField} account:`; | ||||||||||||||||||
| const domain = stripUrlScheme(payload.domain); | ||||||||||||||||||
| const header = `${domain} wants you to sign in with your ${typeField} account:`; | ||||||||||||||||||
| let prefix = [header, payload.address].join("\n"); | ||||||||||||||||||
| prefix = [prefix, payload.statement].join("\n\n"); | ||||||||||||||||||
| if (payload.statement) { | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.