summaryrefslogtreecommitdiffhomepage
path: root/packages/auth-apikey/src/extension.ts
blob: ee68b605e8d13c656a18cd434414cf9a179f3d20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import type { AuthContract, Extension } from "@dispatch/kernel";
import { resolveApiKeyCredentials } from "./resolver.js";

export const apikeyAuth: AuthContract = {
  id: "apikey",
  resolve: async () =>
    resolveApiKeyCredentials(process.env as Readonly<Record<string, string | undefined>>),
};

export const extension: Extension = {
  manifest: {
    id: "auth-apikey",
    name: "API Key Auth",
    version: "0.0.0",
    apiVersion: "^0.1.0",
    trust: "bundled",
    contributes: { auth: ["apikey"] },
  },
  activate(host) {
    host.defineAuth(apikeyAuth);
  },
};