File tree Expand file tree Collapse file tree 6 files changed +19
-3
lines changed
packages/service-utils/src Expand file tree Collapse file tree 6 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @thirdweb-dev/service-utils " : patch
3+ ---
4+
5+ chore: Allow passing teamId with dashboard auth
Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ export async function extractAuthorizationData(
157157 origin,
158158 bundleId,
159159 secretKeyHash,
160+ teamId : authInput . teamId ,
160161 targetAddress : authInput . targetAddress ,
161162 } ;
162163}
Original file line number Diff line number Diff line change @@ -158,9 +158,15 @@ export async function fetchTeamAndProject(
158158 config : CoreServiceConfig ,
159159) : Promise < ApiResponse > {
160160 const { apiUrl, serviceApiKey } = config ;
161+ const { teamId, clientId } = authData ;
161162
162- const clientId = authData . clientId ;
163- const url = `${ apiUrl } /v2/keys/use${ clientId ? `?clientId=${ clientId } ` : "" } ` ;
163+ const url = new URL ( "/v2/keys/use" , apiUrl ) ;
164+ if ( clientId ) {
165+ url . searchParams . set ( "clientId" , clientId ) ;
166+ }
167+ if ( teamId ) {
168+ url . searchParams . set ( "teamId" , teamId ) ;
169+ }
164170 const response = await fetch ( url , {
165171 method : "GET" ,
166172 headers : {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export type AuthorizationInput = {
1818 jwt : string | null ;
1919 hashedJWT : string | null ;
2020 targetAddress ?: string | string [ ] ;
21+ teamId ?: string ;
2122 // IMPORTANT: this is a stringified boolean! Only pass in true or false here. IK it's not ideal, but it's required to pass it in the headers.
2223 useWalletAuth ?: string | null ;
2324} ;
@@ -46,7 +47,7 @@ export async function authorize(
4647 const cacheKey = authData . secretKeyHash
4748 ? `key-v2:secret-key:${ authData . secretKeyHash } `
4849 : authData . hashedJWT
49- ? `key-v2:dashboard-jwt:${ authData . hashedJWT } `
50+ ? `key-v2:dashboard-jwt:${ authData . hashedJWT } : ${ authData . teamId ?? "default" } `
5051 : authData . clientId
5152 ? `key-v2:client-id:${ authData . clientId } `
5253 : null ;
Original file line number Diff line number Diff line change 11export type CoreAuthInput = {
22 // for passing it from the subdomain or path or other service specific things
33 clientId ?: string ;
4+ // For providing a specific team the user is trying to authenticate for. Used only for dashboard auth.
5+ teamId ?: string ;
46 // for passing in the address target in RPC or bundler services
57 targetAddress ?: string | string [ ] ;
68} ;
Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ export function extractAuthorizationData(
167167 origin,
168168 bundleId,
169169 targetAddress : authInput . targetAddress ,
170+ teamId : authInput . teamId ,
170171 useWalletAuth,
171172 } ;
172173}
You can’t perform that action at this time.
0 commit comments