@utcp/sdk
Version:
Universal Tool Calling Protocol (UTCP) client library for TypeScript
42 lines • 1.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthSchema = exports.OAuth2AuthSchema = exports.BasicAuthSchema = exports.ApiKeyAuthSchema = void 0;
const zod_1 = require("zod");
/**
* Authentication using an API key.
*
* The key can be provided directly or sourced from an environment variable.
*/
exports.ApiKeyAuthSchema = zod_1.z.object({
auth_type: zod_1.z.literal('api_key'),
api_key: zod_1.z.string().describe('The API key for authentication.'),
var_name: zod_1.z.string().describe('The name of the header, query parameter, cookie or other container for the API key.'),
location: zod_1.z.enum(['header', 'query', 'cookie']).default('header').describe('Where to include the API key (header, query parameter, or cookie).'),
});
/**
* Authentication using a username and password.
*/
exports.BasicAuthSchema = zod_1.z.object({
auth_type: zod_1.z.literal('basic'),
username: zod_1.z.string().describe('The username for basic authentication.'),
password: zod_1.z.string().describe('The password for basic authentication.'),
});
/**
* Authentication using OAuth2.
*/
exports.OAuth2AuthSchema = zod_1.z.object({
auth_type: zod_1.z.literal('oauth2'),
token_url: zod_1.z.string().describe('The URL to fetch the OAuth2 token from.'),
client_id: zod_1.z.string().describe('The OAuth2 client ID.'),
client_secret: zod_1.z.string().describe('The OAuth2 client secret.'),
scope: zod_1.z.string().optional().describe('The OAuth2 scope.'),
});
/**
* Combined authentication types.
*/
exports.AuthSchema = zod_1.z.discriminatedUnion('auth_type', [
exports.ApiKeyAuthSchema,
exports.BasicAuthSchema,
exports.OAuth2AuthSchema,
]);
//# sourceMappingURL=auth.js.map