Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/service-utils/src/cf-worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export async function extractAuthorizationData(
origin,
bundleId,
secretKeyHash,
teamId: authInput.teamId,
targetAddress: authInput.targetAddress,
};
}
Expand Down
10 changes: 8 additions & 2 deletions packages/service-utils/src/core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,15 @@ export async function fetchTeamAndProject(
config: CoreServiceConfig,
): Promise<ApiResponse> {
const { apiUrl, serviceApiKey } = config;
const { teamId, clientId } = authData;

const clientId = authData.clientId;
const url = `${apiUrl}/v2/keys/use${clientId ? `?clientId=${clientId}` : ""}`;
const url = new URL("/v2/keys/use", apiUrl);
if (clientId) {
url.searchParams.set("clientId", clientId);
}
if (teamId) {
url.searchParams.set("teamId", teamId);
}
const response = await fetch(url, {
method: "GET",
headers: {
Expand Down
3 changes: 2 additions & 1 deletion packages/service-utils/src/core/authorize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type AuthorizationInput = {
jwt: string | null;
hashedJWT: string | null;
targetAddress?: string | string[];
teamId?: string;
// 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.
useWalletAuth?: string | null;
};
Expand Down Expand Up @@ -46,7 +47,7 @@ export async function authorize(
const cacheKey = authData.secretKeyHash
? `key-v2:secret-key:${authData.secretKeyHash}`
: authData.hashedJWT
? `key-v2:dashboard-jwt:${authData.hashedJWT}`
? `key-v2:dashboard-jwt:${authData.hashedJWT}:${authData.teamId ?? "default"}`
: authData.clientId
? `key-v2:client-id:${authData.clientId}`
: null;
Expand Down
2 changes: 2 additions & 0 deletions packages/service-utils/src/core/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export type CoreAuthInput = {
// for passing it from the subdomain or path or other service specific things
clientId?: string;
// For providing a specific team the user is trying to authenticate for. Used only for dashboard auth.
teamId?: string;
// for passing in the address target in RPC or bundler services
targetAddress?: string | string[];
};
1 change: 1 addition & 0 deletions packages/service-utils/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export function extractAuthorizationData(
origin,
bundleId,
targetAddress: authInput.targetAddress,
teamId: authInput.teamId,
useWalletAuth,
};
}
Expand Down
Loading