Open FranRom opened 8 months ago
This is what I tried, although the message I sign is correct, It's not working
const userSignature = async () => {
try {
const host = getTenantHost()
const NONCE = 32891757
const signedMessage = await Web3Token.sign(
async (message: string) => {
const issuedAtMatch = /Issued At: (.+)/.exec(message)
const issuedAt = issuedAtMatch ? issuedAtMatch[1] : 'N/A'
message = `${host} wants you to sign in with your account:\n${address}\n\nI accept the ${tenantName} Terms of Service\n\nURI: https://${tenantHost}\nVersion: 1\nChain ID: ${chainId}\nNonce: ${NONCE}\nIssued At: ${issuedAt}`
return await signMessageAsync({ message })
},
{
domain: tenantHost,
statement: `${host} wants you to sign in with your account: ${address}`,
nonce: 12345678
}
)
return signedMessage
} catch (error) {
console.error('Error signing message: ', error)
}
}
I've tried to add SIWE format to the message but it's not working well with the library. Is there any workaround or willing to add this feature in the future? https://docs.metamask.io/wallet/how-to/sign-data/siwe/