API Key Preset Validator (services/apiKeyPresetValidation.server.ts)

trigger.dev · apps/webapp/app/services/apiKeyPresetValidation.server.ts · typescript · Apache-2.0
auth, integration, lang:typescript, tag:validation

Validates API key creation presets against available scopes and task parameters. Reuse when managing user permissions and API access configurations.

// Source: https://github.com/triggerdotdev/trigger.dev | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { FULL_ACCESS_PRESET_ID } from "@trigger.dev/rbac";

export type ApiKeyPreset = {
  id: string;
  available: boolean;
  label: string;
  description: string;
  scopes?: string[];
  usesTaskSelection?: boolean;
};

export function validateCreateApiKeyPreset({
  presets,
  presetId,
  taskScope,
  taskIdentifiers,
  hasTaskParameters,
}: {
  presets: ApiKeyPreset[] | null;
  presetId?: string;
  taskScope?: "all" | "selected";
  taskIdentifiers: string[];
  hasTaskParameters: boolean;
}): { presetId: string; usesTaskSelection: boolean } {
  const fullAccess = { presetId: FU

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key