Skip to content

Commit a433766

Browse files
committed
allow plugins to create custom auth providers
1 parent c93d50e commit a433766

File tree

11 files changed

+374
-440
lines changed

11 files changed

+374
-440
lines changed

packages/opencode/src/auth/anthropic.ts

Lines changed: 0 additions & 84 deletions
This file was deleted.

packages/opencode/src/auth/copilot.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/opencode/src/auth/index.ts

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,31 @@ import fs from "fs/promises"
44
import { z } from "zod"
55

66
export namespace Auth {
7-
export const Oauth = z.object({
8-
type: z.literal("oauth"),
9-
refresh: z.string(),
10-
access: z.string(),
11-
expires: z.number(),
12-
})
13-
14-
export const Api = z.object({
15-
type: z.literal("api"),
16-
key: z.string(),
17-
})
18-
19-
export const WellKnown = z.object({
20-
type: z.literal("wellknown"),
21-
key: z.string(),
22-
token: z.string(),
23-
})
24-
25-
export const Info = z.discriminatedUnion("type", [Oauth, Api, WellKnown])
7+
export const Oauth = z
8+
.object({
9+
type: z.literal("oauth"),
10+
refresh: z.string(),
11+
access: z.string(),
12+
expires: z.number(),
13+
})
14+
.openapi({ ref: "OAuth" })
15+
16+
export const Api = z
17+
.object({
18+
type: z.literal("api"),
19+
key: z.string(),
20+
})
21+
.openapi({ ref: "ApiAuth" })
22+
23+
export const WellKnown = z
24+
.object({
25+
type: z.literal("wellknown"),
26+
key: z.string(),
27+
token: z.string(),
28+
})
29+
.openapi({ ref: "WellKnownAuth" })
30+
31+
export const Info = z.discriminatedUnion("type", [Oauth, Api, WellKnown]).openapi({ ref: "Auth" })
2632
export type Info = z.infer<typeof Info>
2733

2834
const filepath = path.join(Global.Path.data, "auth.json")

0 commit comments

Comments
 (0)