INNER CODE UNIT · TypeScript

checkApiKeyAgainstServer

direktiv/direktiv · ui/src/api/authenticate/index.ts:14

export const checkApiKeyAgainstServer = (apiKey?: string) =>
  getNamespaces({
    apiKey,
    urlParams: {},
  })
    .then(() => true)
    /**
     * when the test call fails with a 401 or 403 our auth test fails, any
     * other error should bubble up, like a 500 or schema validation error
     */
    .catch((err) => {
      const parsedError = ApiErrorSchema.safeParse(err);
      if (parsedError.success) {
        const { status } = parsedError.data;
        if (status === 401 || status === 403) {
          return false;
        }
      }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…