-
Notifications
You must be signed in to change notification settings - Fork 535
Separate authToken from secretKey in ThirdwebClient #6983
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. |
2eadf4f
to
f2b9861
Compare
if (!headers) { | ||
headers = new Headers(); | ||
} | ||
// auth token if secret key === jwt | ||
const authToken = | ||
useAuthToken && client.secretKey && isJWT(client.secretKey) | ||
? client.secretKey | ||
: undefined; | ||
// secret key if secret key !== jwt | ||
const secretKey = | ||
client.secretKey && !isJWT(client.secretKey) | ||
? client.secretKey | ||
: undefined; | ||
const clientId = client.clientId; | ||
|
||
// if we have an auth token set, use that (thirdweb dashboard sets this for the user) | ||
|
||
// if we have an auth token set & useAuthToken is true, use the auth token (thirdweb dashboard sets this for the user) | ||
// pay urls should never send the auth token, because we always want the "developer" to be the one making the request, not the "end user" | ||
if ( | ||
authToken && | ||
useAuthToken && | ||
client.authToken && | ||
!isPayUrl(urlString) && | ||
!isInAppWalletUrl(urlString) && | ||
!isBundlerUrl(urlString) | ||
) { | ||
headers.set("authorization", `Bearer ${authToken}`); | ||
headers.set("authorization", `Bearer ${client.authToken}`); |
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 code should be modified to maintain backward compatibility with tests that expect JWT tokens to be passed as secretKey. We should check both client.authToken and if client.secretKey is a JWT. For example: if (useAuthToken && (client.authToken || (client.secretKey && isJWT(client.secretKey))) && ...)
Spotted by Diamond (based on CI logs)
Is this helpful? React 👍 or 👎 to let us know.
size-limit report 📦
|
PR-Codex overview
This PR focuses on refactoring the
createThirdwebClient
function to replace the use ofsecretKey
withauthToken
, enhancing how authentication is managed and improving error handling related to client creation.Detailed summary
secretKey
withauthToken
increateThirdwebClient
options.clientId
must accompanyauthToken
.authToken
.authToken
oversecretKey
.