// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import { APIPromise } from '../core/api-promise'; import { buildHeaders } from '../internal/headers'; import { RequestOptions } from '../internal/request-options'; export class Encryption extends APIResource { /** * Decrypt text previously encrypted with the same scheme used to store * `knowledge_store_config_bundles.config`. If `encryption_key` or `encryption_id` * are omitted, the `ENCRYPTION_KEY` / `ENCRYPTION_KEY_ID` env vars are used. */ decrypt(params: EncryptionDecryptParams, options?: RequestOptions): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post('/encryption/decrypt', { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Encrypt arbitrary text using AES-GCM, the same scheme used to store * `knowledge_store_config_bundles.config`. If `encryption_key` or `encryption_id` * are omitted, the `ENCRYPTION_KEY` / `ENCRYPTION_KEY_ID` env vars are used. */ encrypt(params: EncryptionEncryptParams, options?: RequestOptions): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post('/encryption/encrypt', { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Request schema for encrypting or decrypting arbitrary text. * * Attributes: text (str): The text to encrypt (plaintext) or decrypt (ciphertext). * encryption_key (str | None): Optional encryption key, must be exactly 32 bytes * when UTF-8 encoded. Defaults to the `ENCRYPTION_KEY` env var when omitted. * encryption_id (str | None): Optional key identifier embedded in / matched * against the ciphertext. Defaults to the `ENCRYPTION_KEY_ID` env var when * omitted. */ export interface EncryptionTextRequest { /** * Text to encrypt or decrypt. */ text: string; /** * Optional key identifier. Defaults to the ENCRYPTION_KEY_ID env var when omitted. */ encryption_id?: string | null; /** * Optional encryption key (must be exactly 32 bytes when UTF-8 encoded). Defaults * to the ENCRYPTION_KEY env var when omitted. */ encryption_key?: string | null; } /** * Response schema containing the encrypted or decrypted text. * * Attributes: result (str): The resulting encrypted or decrypted text. */ export interface EncryptionTextResponse { /** * The encrypted or decrypted text. */ result: string; } export interface EncryptionDecryptParams { /** * Body param: Text to encrypt or decrypt. */ text: string; /** * Body param: Optional key identifier. Defaults to the ENCRYPTION_KEY_ID env var * when omitted. */ encryption_id?: string | null; /** * Body param: Optional encryption key (must be exactly 32 bytes when UTF-8 * encoded). Defaults to the ENCRYPTION_KEY env var when omitted. */ encryption_key?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface EncryptionEncryptParams { /** * Body param: Text to encrypt or decrypt. */ text: string; /** * Body param: Optional key identifier. Defaults to the ENCRYPTION_KEY_ID env var * when omitted. */ encryption_id?: string | null; /** * Body param: Optional encryption key (must be exactly 32 bytes when UTF-8 * encoded). Defaults to the ENCRYPTION_KEY env var when omitted. */ encryption_key?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export declare namespace Encryption { export { type EncryptionTextRequest as EncryptionTextRequest, type EncryptionTextResponse as EncryptionTextResponse, type EncryptionDecryptParams as EncryptionDecryptParams, type EncryptionEncryptParams as EncryptionEncryptParams, }; }