summaryrefslogtreecommitdiffhomepage
path: root/packages/auth-apikey/src/extension.ts
blob: 05d6462e2e9fdb1e0f80f1f0e3a466a9435d0703 (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);
	},
};