@opengeni/api-router 2.12.4-canary.3 → 2.13.0-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@ import {
48
48
  requireWorkspace,
49
49
  withCodexAppsRequestAuthorization,
50
50
  consumeToolGatewayApproval,
51
- getWorkspaceArtifact,
51
+ getWorkspaceArtifactContentRef,
52
52
  issueToolGatewayApproval,
53
53
  ToolGatewayApprovalOperationStartedError,
54
54
  ToolGatewayApprovalRateLimitError,
@@ -719,24 +719,25 @@ function throwWorkspaceToolGatewayHttpError(error: unknown): never {
719
719
  throw error;
720
720
  }
721
721
 
722
- async function requireWorkspaceSiteToolAuthorization(
722
+ export async function requireWorkspaceSiteToolAuthorization(
723
723
  db: ApiRouteDeps["db"],
724
724
  grant: AccessGrant,
725
725
  context: WorkspaceSiteToolContext,
726
+ resolveVersion = getWorkspaceArtifactContentRef,
726
727
  ): Promise<void> {
727
728
  try {
728
- const detail = await getWorkspaceArtifact(db, grant.workspaceId, context.siteArtifactId);
729
- const currentVersion = detail.artifact.currentVersion;
730
- const requested = currentVersion?.requestedTools.some(
729
+ const { status, version } = await resolveVersion(
730
+ db,
731
+ grant.workspaceId,
732
+ context.siteArtifactId,
733
+ context.siteVersionId,
734
+ );
735
+ const requested = version.requestedTools.some(
731
736
  (identity) =>
732
737
  identity.serverId === context.identity.serverId &&
733
738
  identity.toolName === context.identity.toolName,
734
739
  );
735
- if (
736
- detail.artifact.status !== "active" ||
737
- currentVersion?.id !== context.siteVersionId ||
738
- !requested
739
- ) {
740
+ if (status !== "active" || version.id !== context.siteVersionId || !requested) {
740
741
  throw new HTTPException(403, { message: "site_tool_not_authorized" });
741
742
  }
742
743
  } catch (error) {