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(
157
157
origin,
158
158
bundleId,
159
159
secretKeyHash,
160
+ teamId : authInput . teamId ,
160
161
targetAddress : authInput . targetAddress ,
161
162
} ;
162
163
}
Original file line number Diff line number Diff line change @@ -158,9 +158,15 @@ export async function fetchTeamAndProject(
158
158
config : CoreServiceConfig ,
159
159
) : Promise < ApiResponse > {
160
160
const { apiUrl, serviceApiKey } = config ;
161
+ const { teamId, clientId } = authData ;
161
162
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
+ }
164
170
const response = await fetch ( url , {
165
171
method : "GET" ,
166
172
headers : {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export type AuthorizationInput = {
18
18
jwt : string | null ;
19
19
hashedJWT : string | null ;
20
20
targetAddress ?: string | string [ ] ;
21
+ teamId ?: string ;
21
22
// 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.
22
23
useWalletAuth ?: string | null ;
23
24
} ;
@@ -46,7 +47,7 @@ export async function authorize(
46
47
const cacheKey = authData . secretKeyHash
47
48
? `key-v2:secret-key:${ authData . secretKeyHash } `
48
49
: authData . hashedJWT
49
- ? `key-v2:dashboard-jwt:${ authData . hashedJWT } `
50
+ ? `key-v2:dashboard-jwt:${ authData . hashedJWT } : ${ authData . teamId ?? "default" } `
50
51
: authData . clientId
51
52
? `key-v2:client-id:${ authData . clientId } `
52
53
: null ;
Original file line number Diff line number Diff line change 1
1
export type CoreAuthInput = {
2
2
// for passing it from the subdomain or path or other service specific things
3
3
clientId ?: string ;
4
+ // For providing a specific team the user is trying to authenticate for. Used only for dashboard auth.
5
+ teamId ?: string ;
4
6
// for passing in the address target in RPC or bundler services
5
7
targetAddress ?: string | string [ ] ;
6
8
} ;
Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ export function extractAuthorizationData(
167
167
origin,
168
168
bundleId,
169
169
targetAddress : authInput . targetAddress ,
170
+ teamId : authInput . teamId ,
170
171
useWalletAuth,
171
172
} ;
172
173
}
You can’t perform that action at this time.
0 commit comments