Title: wallet_authenticator is outdated and not in line with the message created by the react/web SDK · Issue #145 · thirdweb-dev/python-sdk · GitHub
Open Graph Title: wallet_authenticator is outdated and not in line with the message created by the react/web SDK · Issue #145 · thirdweb-dev/python-sdk
X Title: wallet_authenticator is outdated and not in line with the message created by the react/web SDK · Issue #145 · thirdweb-dev/python-sdk
Description: Hi there, I'll try to improve the issue ticket as i go but for now I realized (after a few hours) that the message body of the created by the react SDK and the verify method used in the python SDK are waay different. Judging by the conte...
Open Graph Description: Hi there, I'll try to improve the issue ticket as i go but for now I realized (after a few hours) that the message body of the created by the react SDK and the verify method used in the python SDK ...
X Description: Hi there, I'll try to improve the issue ticket as i go but for now I realized (after a few hours) that the message body of the created by the react SDK and the verify method used in the python ...
Opengraph URL: https://github.com/thirdweb-dev/python-sdk/issues/145
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"wallet_authenticator is outdated and not in line with the message created by the react/web SDK","articleBody":"Hi there,\r\n\r\nI'll try to improve the issue ticket as i go but for now I realized (after a few hours) that the message body of the created by the react SDK and the verify method used in the python SDK are waay different. Judging by the content, I think python one is the outdated option. For now I've overriden the `generate_message` and `verify` methods to get this working. Below is my code if anyone facing the same issue,\r\n\r\n```py\r\ndef format_time_for_message(timestamp):\r\n time = timestamp.strftime(\"%Y-%m-%dT%H:%M:%S\")\r\n microseconds = timestamp.strftime(\"%f\")[0:3]\r\n formatted_time = f\"{time}.{microseconds}Z\"\r\n \r\n return formatted_time\r\n \r\ndef generate_message(payload: ExtendedPayloadData) -> str:\r\n \"\"\"\r\n Generates an EIP-4361 compliant message to sign based on the login payload\r\n \"\"\"\r\n\r\n message = \"\"\r\n\r\n # Add the domain and login address for transparency\r\n message += f\"{payload.domain} wants you to sign in with your Ethereum account:\\n{payload.address}\\n\\n\"\r\n\r\n # Prompt user to make sure domain is correct to prevent phishing attacks\r\n message += \"Please ensure that the domain above matches the URL of the current website.\\n\\n\"\r\n\r\n message += f\"Version: {payload.version}\\n\"\r\n\r\n # Add data fields in compliance with the EIP-4361 standard\r\n if payload.chain_id is not None:\r\n message += f\"Chain ID: {payload.chain_id}\\n\"\r\n\r\n message += f\"Nonce: {payload.nonce}\\n\"\r\n message += f\"Issued At: {format_time_for_message(payload.issued_at)}\\n\"\r\n\r\n message += f\"Expiration Time: {format_time_for_message(payload.expiration_time)}\\n\"\r\n\r\n message += f\"Not Before: {format_time_for_message(payload.invalid_before)}\"\r\n\r\n return message\r\n\r\ndef verify(\r\n domain: str,\r\n payload,\r\n options: VerifyOptions = VerifyOptions()\r\n ) -> str:\r\n \"\"\"\r\n Server-side function to securely verify the address of the logged in client-side wallet\r\n by validating the provided client-side login request.\r\n\r\n ```python\r\n domain = \"example.com\"\r\n payload = sdk.auth.login(domain)\r\n\r\n # Verify the login request\r\n address = sdk.auth.verify(domain, payload)\r\n ```\r\n\r\n :param domain: The domain of the application to verify the login request for\r\n :param payload: The login payload to verify\r\n :return: The address of the logged in wallet that signed the payload\r\n \"\"\"\r\n\r\n # Check that the intended domain matches the domain of the payload\r\n if payload.payload.domain != domain:\r\n raise Exception(\r\n f\"Expected domain '{domain}' does not match domain on payload '{payload.payload.domain}'\"\r\n )\r\n\r\n # Check that the payload hasn't expired\r\n current_time = datetime.utcnow()\r\n if current_time.replace(\r\n tzinfo=pytz.utc\r\n ) > payload.payload.expiration_time.replace(tzinfo=pytz.utc):\r\n raise Exception(f\"Login request has expired\")\r\n\r\n # If chain ID is specified, check that it matches the chain ID of the signature\r\n if (\r\n options.chain_id is not None\r\n and options.chain_id != payload.payload.chain_id\r\n ):\r\n raise Exception(\r\n f\"Chain ID '{options.chain_id}' does not match payload chain ID '{payload.payload.chain_id}'\"\r\n )\r\n\r\n # Check that the signing address is the claimed wallet address\r\n message = generate_message(payload.payload)\r\n user_address = sdk.auth._recover_address(message, payload.signature)\r\n \r\n if user_address.lower() != payload.payload.address.lower():\r\n raise Exception(\r\n f\"The intended payload address '{payload.payload.address.lower()}' is not the payload signer\"\r\n )\r\n\r\n return user_address\r\n```","author":{"url":"https://github.com/ManZzup","@type":"Person","name":"ManZzup"},"datePublished":"2023-12-26T15:42:53Z","url":"https://github.com/thirdweb-dev/python-sdk/issues/145"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a6f7a913-7cc7-b283-9f66-85c6c34863be |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E15E:29B16A:1DBC0D1:27300A8:6B030A31 |
| html-safe-nonce | 966849860e8c51c710abafefbb97e04b9b2d093bd066f87eb0d2acca141d4ebf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTVFOjI5QjE2QToxREJDMEQxOjI3MzAwQTg6NkIwMzBBMzEiLCJ2aXNpdG9yX2lkIjoiNDI2MjE2MjYwODE3MTQ1Mjk3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2ec0e06628eed226b1c3ceb1dadc8ba18ec76d91ae29af45e261a144b345dc6a |
| hovercard-subject-tag | issue:2056515627 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/thirdweb-dev/python-sdk/145/issue_layout |
| twitter:image | https://opengraph.githubassets.com/583a9b4d21c5f89a38f05141e1d9a3963bde2f76ae4811888247416d5ea2bf04/thirdweb-dev/python-sdk/issues/145 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/583a9b4d21c5f89a38f05141e1d9a3963bde2f76ae4811888247416d5ea2bf04/thirdweb-dev/python-sdk/issues/145 |
| og:image:alt | Hi there, I'll try to improve the issue ticket as i go but for now I realized (after a few hours) that the message body of the created by the react SDK and the verify method used in the python SDK ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ManZzup |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/thirdweb-dev/python-sdk git https://github.com/thirdweb-dev/python-sdk.git |
| octolytics-dimension-user_id | 79496167 |
| octolytics-dimension-user_login | thirdweb-dev |
| octolytics-dimension-repository_id | 414355482 |
| octolytics-dimension-repository_nwo | thirdweb-dev/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 414355482 |
| octolytics-dimension-repository_network_root_nwo | thirdweb-dev/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width