diff options
| author | Dax Raad <[email protected]> | 2025-08-14 16:24:46 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-08-14 16:25:08 -0400 |
| commit | a433766a31fbf5c0597aec757de59a3d882c02fa (patch) | |
| tree | 6d8be3725830059c55b8260021e00c5501854922 /packages/sdk | |
| parent | c93d50e8c7af7911c41ba445b431a5428aaf15b8 (diff) | |
| download | opencode-a433766a31fbf5c0597aec757de59a3d882c02fa.tar.gz opencode-a433766a31fbf5c0597aec757de59a3d882c02fa.zip | |
allow plugins to create custom auth providers
Diffstat (limited to 'packages/sdk')
| -rw-r--r-- | packages/sdk/js/src/gen/sdk.gen.ts | 20 | ||||
| -rw-r--r-- | packages/sdk/js/src/gen/types.gen.ts | 56 |
2 files changed, 76 insertions, 0 deletions
diff --git a/packages/sdk/js/src/gen/sdk.gen.ts b/packages/sdk/js/src/gen/sdk.gen.ts index 8a26dfa70..5dd8552d5 100644 --- a/packages/sdk/js/src/gen/sdk.gen.ts +++ b/packages/sdk/js/src/gen/sdk.gen.ts @@ -77,6 +77,9 @@ import type { TuiClearPromptResponses, TuiExecuteCommandData, TuiExecuteCommandResponses, + AuthSetData, + AuthSetResponses, + AuthSetErrors, } from "./types.gen.js" import { client as _heyApiClient } from "./client.gen.js" @@ -517,6 +520,22 @@ class Tui extends _HeyApiClient { } } +class Auth extends _HeyApiClient { + /** + * Set authentication credentials + */ + public set<ThrowOnError extends boolean = false>(options: Options<AuthSetData, ThrowOnError>) { + return (options.client ?? this._client).put<AuthSetResponses, AuthSetErrors, ThrowOnError>({ + url: "/auth/{id}", + ...options, + headers: { + "Content-Type": "application/json", + ...options.headers, + }, + }) + } +} + export class OpencodeClient extends _HeyApiClient { /** * Respond to a permission request @@ -544,4 +563,5 @@ export class OpencodeClient extends _HeyApiClient { find = new Find({ client: this._client }) file = new File({ client: this._client }) tui = new Tui({ client: this._client }) + auth = new Auth({ client: this._client }) } diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts index 3652ea584..d2b990469 100644 --- a/packages/sdk/js/src/gen/types.gen.ts +++ b/packages/sdk/js/src/gen/types.gen.ts @@ -1105,6 +1105,35 @@ export type Agent = { } } +export type Auth = + | ({ + type: "oauth" + } & OAuth) + | ({ + type: "api" + } & ApiAuth) + | ({ + type: "wellknown" + } & WellKnownAuth) + +export type OAuth = { + type: "oauth" + refresh: string + access: string + expires: number +} + +export type ApiAuth = { + type: "api" + key: string +} + +export type WellKnownAuth = { + type: "wellknown" + key: string + token: string +} + export type EventSubscribeData = { body?: never path?: never @@ -1858,6 +1887,33 @@ export type TuiExecuteCommandResponses = { export type TuiExecuteCommandResponse = TuiExecuteCommandResponses[keyof TuiExecuteCommandResponses] +export type AuthSetData = { + body?: Auth + path: { + id: string + } + query?: never + url: "/auth/{id}" +} + +export type AuthSetErrors = { + /** + * Bad request + */ + 400: _Error +} + +export type AuthSetError = AuthSetErrors[keyof AuthSetErrors] + +export type AuthSetResponses = { + /** + * Successfully set authentication credentials + */ + 200: boolean +} + +export type AuthSetResponse = AuthSetResponses[keyof AuthSetResponses] + export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}) } |
