diff options
| author | Dax Raad <[email protected]> | 2025-08-27 12:18:09 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-08-27 12:18:09 -0400 |
| commit | 0fbd7c84fd9f93f46eea2eec241a6fde07ce0d59 (patch) | |
| tree | 4704e8ebce75e3c4e2588ebb3b27309ea184ea92 /packages/sdk/js/src/gen/core/auth.gen.ts | |
| parent | 5c17ee52c5ad82dd759a777eb3ab613a00d27ddb (diff) | |
| download | opencode-0fbd7c84fd9f93f46eea2eec241a6fde07ce0d59.tar.gz opencode-0fbd7c84fd9f93f46eea2eec241a6fde07ce0d59.zip | |
sdk update
Diffstat (limited to 'packages/sdk/js/src/gen/core/auth.gen.ts')
| -rw-r--r-- | packages/sdk/js/src/gen/core/auth.gen.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/packages/sdk/js/src/gen/core/auth.gen.ts b/packages/sdk/js/src/gen/core/auth.gen.ts new file mode 100644 index 000000000..bc7b230f4 --- /dev/null +++ b/packages/sdk/js/src/gen/core/auth.gen.ts @@ -0,0 +1,41 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: "header" | "query" | "cookie" + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string + scheme?: "basic" | "bearer" + type: "apiKey" | "http" +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken, +): Promise<string | undefined> => { + const token = typeof callback === "function" ? await callback(auth) : callback + + if (!token) { + return + } + + if (auth.scheme === "bearer") { + return `Bearer ${token}` + } + + if (auth.scheme === "basic") { + return `Basic ${btoa(token)}` + } + + return token +} |
