This commit is contained in:
shwoop 2025-09-18 16:37:34 +02:00
parent 7ce73c5490
commit bc95aa561e
No known key found for this signature in database
GPG key ID: 95A35B68C1E5F95A
4 changed files with 7 additions and 7 deletions

View file

@ -39,7 +39,6 @@ var wantsMsg = ` wants you to sign in with your Ethereum account:\n`
var address = `(0x[a-fA-F0-9]{40})\n`
// Optional statement (any line not containing "\n\n")
// var statement = `(?:[^\n]+\n)?`
var statement = `(?:.*\n)?`
// URI
@ -77,13 +76,15 @@ var siweMessageRegex = regexp.MustCompile(`(?m)^` + scheme + domain + wantsMsg +
var ErrMalformedSIWEMessage = errors.New("the message is asking to sign in with Ethereum but does not conform to EIP-4361")
const suggestiveLanguage = "wants you to sign in with your Ethereum account"
func validateSIWE(req *SignDataRequest) error {
for _, message := range req.Messages {
s, ok := message.Value.(string)
if !ok {
continue
}
if !strings.Contains(s, "wants you to sign in with your Ethereum account") {
if !strings.Contains(s, suggestiveLanguage) {
continue
}

View file

@ -92,7 +92,7 @@
},
"domain is RFC 3986 authority with userinfo and port": {
"msg": "test@127.0.0.1:8080 wants you to sign in with your Ethereum account:\n{{Account}}\n\nI accept the ServiceOrg Terms of Service: https://service.org/tos\n\nURI: https://service.org/login\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z",
"request_context":{
"request_context": {
"transport": "https",
"source": "test@127.0.0.1:8080"
}

View file

@ -32,5 +32,4 @@
"No scheme - ://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body": "service.org wants you to sign in with your Ethereum account:\n0x{{Account}}\n\n\nURI: ://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z",
"bad query - uri://user:pass@example.com:123/one/two.three ?q1=a1&q2=a2#body": "service.org wants you to sign in with your Ethereum account:\n0x{{Account}}\n\n\nURI: uri://user:pass@example.com:123/one/two.three ?q1=a1&q2=a2#body\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z",
"bad fragment - uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2 #body": "service.org wants you to sign in with your Ethereum account:\n0x{{Account}}\n\n\nURI: uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2 #body\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z"
}