-
Notifications
You must be signed in to change notification settings - Fork 619
add thirdweb login client script #6125
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
64d3ed0 to
64336ae
Compare
| @@ -0,0 +1 @@ | |||
| (()=>{const e=(()=> {const e=document.currentScript;if(!e)throw new Error("Could not find script element");const o=new URL(e.src).origin,t=e.dataset.clientId;if(!t)throw new Error("Missing client-id");return{clientId:t,baseUrl:o}})(),o="tw.login:userAddress",t="tw.login:sessionKeyAddress",n="tw.login:code";function r(){const o=window.crypto.getRandomValues(new Uint8Array(4)).join("");localStorage.setItem(n,o);const t=new URL(e.baseUrl);t.searchParams.set("code",o),t.searchParams.set("clientId",e.clientId),t.searchParams.set("redirect",window.location.href),window.location.href=t.href}!(()=> {const e=funci(f(=> !e.hash)return null;try{return functiont( o=> =e.startsWith("#")?e.slice(1):e,t=atob(o),n=JSON.parse(t);if("userAddress"in n&&"sessionKeyAddress"in n&&"code"in n)return n;return null}(e.hash))}catch{return null}}(new) URL(window.location));e&&e.code===localStorage.getItem(n)&&(window.location.hash="",localStorage.setItem(n,e.code),localStorage.setItem(o,e.userAddress),localStorage.setItem(t,e.sessionKeyAddress));const s=localStorage.getItem(o),i=localStorage.getItem(t);s&&i?(console.log("handleIsLoggedIn"),window.thirdweb={isLoggedIn:!0,getAddress:()=>localStorage.getItem(o),logout:()=>{window.localStorage.removeItem(o),window.localStorage.removeItem(t),window.location.reload()}}):window.thirdweb={login:r,isLoggedIn:!1}})()})(); No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minified JavaScript contains syntax errors in the parseURLHash function implementation. Specifically, funci(f(=> and functiont( o=> are malformed arrow function expressions that will cause runtime errors. Please regenerate the minified file from the source code using a proper JavaScript minification tool to ensure the output is syntactically valid.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6125 +/- ##
=======================================
Coverage 56.87% 56.87%
=======================================
Files 1153 1153
Lines 63896 63896
Branches 5180 5180
=======================================
Hits 36344 36344
Misses 26825 26825
Partials 727 727
*This pull request uses carry forward flags. Click here to find out more. |
size-limit report 📦
|

PR-Codex overview
This PR refactors the login handling code in
tw-login.js, improving the structure and logic for managing user authentication and session storage. It consolidates variable definitions and streamlines the login flow.Detailed summary
targetId,clientId, andbaseUrlwith a singleglobalSetupobject.makeRequestfunction.onLoginfunction by usingglobalSetupvariables.