### Get Client Information (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient The `clientInfo` function retrieves debugging or environment information, specifically the `workspaceId`. The `workspaceId` can be a string or undefined. ```typescript clientInfo(): { workspaceId: string | undefined; }; ``` -------------------------------- ### Get LockContext Source: https://cipherstash.com/docs/reference/protectjs/latest/classes/LockContext The getLockContext method retrieves the current lock context. It returns a Promise that resolves to a Result, containing either GetLockContextResponse on success or a ProtectError on failure. ```typescript getLockContext(): Promise>; ``` -------------------------------- ### Get Schema Name with getName() - TypeScript Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectValue The getName() method returns the string representation of the schema's name. This is a simple getter method. ```typescript getName(): string; ``` -------------------------------- ### ProtectClient Initialization Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Initializes the ProtectClient with a given configuration. This method returns a Promise that resolves to either a ProtectClient instance or a ProtectError. ```APIDOC ## init() ### Description Initializes the ProtectClient with encryption configuration. ### Method `init(config)` ### Parameters #### `config` (object) - Required Configuration object for encryption. ##### `config.v` (number) - Required Version of the encryption configuration. ##### `config.tables` (Record>) - Required Schema definition for tables and their columns, including encryption and indexing strategies. - **`cast_as`** (string) - Required - The data type to cast the column to ('string', 'number', 'bigint', 'boolean', 'date', 'json'). - **`indexes`** (object) - Optional - Configuration for column indexes. - **`ore`** (object) - Optional - Configuration for 'ore' indexes. - **`unique`** (object) - Optional - Configuration for unique indexes. - **`token_filters`** (array) - Optional - Filters to apply to tokens for unique indexing. - **`match`** (object) - Optional - Configuration for 'match' indexes. - **`tokenizer`** (object) - Optional - Tokenizer configuration ('standard' or 'ngram' with `token_length`). - **`token_filters`** (array) - Optional - Filters to apply to tokens for matching. - **`k`** (number) - Optional - Parameter for 'ngram' tokenizer. - **`m`** (number) - Optional - Parameter for 'ngram' tokenizer. - **`include_original`** (boolean) - Optional - Whether to include the original text in the index. - **`ste_vec`** (object) - Optional - Configuration for 'ste_vec' indexes. - **`prefix`** (string) - Required - Prefix for 'ste_vec' index. ### Returns `Promise>` - A Promise that resolves with the ProtectClient instance or a ProtectError. ### Request Example ```json { "v": 1, "tables": { "users": { "email": { "cast_as": "string", "indexes": { "unique": {}, "match": { "tokenizer": {"kind": "standard"} } } }, "name": { "cast_as": "string" } } } } ``` ### Response Example (Success) ```json { "//": "ProtectClient instance" } ``` ### Response Example (Error) ```json { "//": "ProtectError object" } ``` ``` -------------------------------- ### Initialize ProtectClient Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Initializes the ProtectClient with the provided configuration. This is the first step before performing any encryption or decryption operations. It returns a Promise that resolves to a Result object containing either the ProtectClient instance or a ProtectError. ```typescript async init(config: encryptConfig): Promise>; ``` -------------------------------- ### ProtectJS - Classes Source: https://cipherstash.com/docs/reference/protectjs/latest/index Provides classes for managing encryption contexts and related functionalities within the ProtectJS library. ```APIDOC ## Classes ### `LockContext` A class for managing and acquiring lock contexts, likely used for managing access to sensitive data or resources. #### Methods - **`acquire(options)`**: Acquires a lock context with the specified options. - **`release()`**: Releases the currently held lock context. #### Properties - **`options`** (*LockContextOptions*): The configuration options for this lock context. - **`isLocked`** (*boolean*): Indicates whether the context is currently locked. ``` -------------------------------- ### ProtectColumn Methods Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectColumn This section details the various methods available for configuring ProtectColumn, including setting data types, enabling different indexing strategies, and defining index parameters. ```APIDOC ## ProtectColumn Defined in: packages/schema/src/index.ts:137 ### Methods #### `dataType(castAs)` * **Description**: Set or override the cast_as value. * **Method**: (Implicitly called within a builder pattern, no direct HTTP method) * **Endpoint**: N/A * **Parameters**: * **Path Parameters**: None * **Query Parameters**: None * **Request Body**: None * **Request Example**: N/A * **Response**: * **Success Response (200)**: `ProtectColumn` object * **Response Example**: N/A #### `orderAndRange()` * **Description**: Enable ORE indexing (Order-Revealing Encryption). * **Method**: (Implicitly called within a builder pattern, no direct HTTP method) * **Endpoint**: N/A * **Parameters**: * **Path Parameters**: None * **Query Parameters**: None * **Request Body**: None * **Request Example**: N/A * **Response**: * **Success Response (200)**: `ProtectColumn` object * **Response Example**: N/A #### `equality(tokenFilters?)` * **Description**: Enable an Exact index. Optionally pass tokenFilters. * **Method**: (Implicitly called within a builder pattern, no direct HTTP method) * **Endpoint**: N/A * **Parameters**: * **Path Parameters**: None * **Query Parameters**: None * **Request Body**: None * **Parameters for `tokenFilters`**: * `tokenFilters` (array of objects) - Optional. Each object should have a `kind` property set to `"downcase"`. * **Request Example**: N/A * **Response**: * **Success Response (200)**: `ProtectColumn` object * **Response Example**: N/A #### `freeTextSearch(opts?)` * **Description**: Enable a Match index. Allows passing of custom match options. * **Method**: (Implicitly called within a builder pattern, no direct HTTP method) * **Endpoint**: N/A * **Parameters**: * **Path Parameters**: None * **Query Parameters**: None * **Request Body**: None * **Parameters for `opts`**: * `opts` (object) - Optional. Contains tokenizer and token filters. * `tokenizer?` (object) - Optional. Specifies the tokenizer kind. * `{ kind: "standard" }` * `{ kind: "ngram", token_length: number }` * `token_filters?` (array of objects) - Optional. Each object should have a `kind` property set to `"downcase"`. * `k?` (number) - Optional. * `m?` (number) - Optional. * `include_original?` (boolean) - Optional. * **Request Example**: N/A * **Response**: * **Success Response (200)**: `ProtectColumn` object * **Response Example**: N/A #### `build()` * **Description**: Builds the ProtectColumn configuration with specified indexes and data type. * **Method**: (Implicitly called within a builder pattern, no direct HTTP method) * **Endpoint**: N/A * **Parameters**: * **Path Parameters**: None * **Query Parameters**: None * **Request Body**: None * **Request Example**: N/A * **Response**: * **Success Response (200)**: Object containing `cast_as` and `indexes` configuration. * **Response Example**: ```json { "cast_as": "string" | "number" | "bigint" | "boolean" | "date" | "json", "indexes": { "ore"?: {}, "unique"?: { "token_filters"?: { "kind": "downcase" }[]; }, "match"?: { "tokenizer"?: | { "kind": "standard" } | { "kind": "ngram", "token_length": number }; "token_filters"?: { "kind": "downcase" }[]; "k"?: number; "m"?: number; "include_original"?: boolean; }, "ste_vec"?: { "prefix": string; } } } ``` #### `getName()` * **Description**: Retrieves the name of the column. * **Method**: (Implicitly called within a builder pattern, no direct HTTP method) * **Endpoint**: N/A * **Parameters**: * **Path Parameters**: None * **Query Parameters**: None * **Request Body**: None * **Request Example**: N/A * **Response**: * **Success Response (200)**: `string` (the column name) * **Response Example**: N/A ``` -------------------------------- ### LockContext Constructor Source: https://cipherstash.com/docs/reference/protectjs/latest/classes/LockContext Initializes a new instance of the LockContext class. ```APIDOC ## LockContext Constructor ### Description Initializes a new instance of the LockContext class. ### Method Constructor ### Parameters * __namedParameters (object) - Required - An object containing named parameters for initialization. ### Returns `LockContext` - The newly created LockContext instance. ### Request Example ```javascript const lockContext = new LockContext({}); ``` ### Response #### Success Response * `LockContext` (object) - An instance of the LockContext class. ### Response Example ```json { "instance": "LockContext" } ``` ``` -------------------------------- ### ProtectColumn build() Method and Schema Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectColumn Builds the configuration for a ProtectColumn, including the data type and various index configurations (ORE, unique, match, STE Vec). This method returns a configuration object detailing the column's settings. ```typescript build(): { cast_as: "string" | "number" | "bigint" | "boolean" | "date" | "json"; indexes: { ore?: { }; unique?: { token_filters?: { kind: "downcase"; }[]; }; match?: Required<{ tokenizer?: | { kind: "standard"; } | { kind: "ngram"; token_length: number; }; token_filters?: { kind: "downcase"; }[]; k?: number; m?: number; include_original?: boolean; }>; ste_vec?: { prefix: string; }; }; }; ``` -------------------------------- ### ProtectJS - Interfaces Source: https://cipherstash.com/docs/reference/protectjs/latest/index Defines the interfaces for core components of the ProtectJS library, including clients, errors, and data structures. ```APIDOC ## Interfaces ### `ProtectClient` Represents the primary interface for interacting with the CipherStash encryption service. #### Methods - **`encrypt(payload, options)`**: Encrypts data. - **`decrypt(payload, options)`**: Decrypts data. - **`search(payload, options)`**: Performs encrypted searches. - **`configure(config)`**: Configures the client. #### Properties - **`config`** (*ProtectClientConfig*): The current client configuration. ### `ProtectError` Represents a custom error type within the ProtectJS library. #### Properties - **`type`** (*string*): The type of error (e.g., 'ENCRYPTION_FAILED', 'DECRYPTION_FAILED'). - **`message`** (*string*): A human-readable error message. ### `ProtectValue` Represents an encrypted value, often used in request/response bodies. #### Properties - **`ciphertext`** (*string*): The encrypted data. - **`key_id`** (*string*): The identifier of the key used for encryption. - **`region`** (*string*): The region where the data is stored or encrypted. ### `ProtectColumn` Represents the encryption configuration for a specific column in a table. #### Properties - **`name`** (*string*): The name of the column. - **`type`** (*string*): The data type of the column. - **`encryption_type`** (*string*): The type of encryption applied to the column. - **`region`** (*string*): The region associated with the column's encryption. ### `ProtectTable` Represents the encryption configuration for an entire table. #### Properties - **`name`** (*string*): The name of the table. - **`columns`** (*Array*): An array of `ProtectColumn` configurations for the table. ``` -------------------------------- ### ProtectJS - Variables Source: https://cipherstash.com/docs/reference/protectjs/latest/index Exposes constants and enumerations used within the ProtectJS library. ```APIDOC ## Variables ### `ProtectErrorTypes` An enumeration or object containing predefined error type strings for `ProtectError` instances. This helps in identifying specific error conditions programmatically. ``` -------------------------------- ### ProtectJS - Core Functions Source: https://cipherstash.com/docs/reference/protectjs/latest/index Provides core functions for encrypting, decrypting, and managing protected data within the CipherStash ecosystem. ```APIDOC ## Functions ### `protect(value, options)` Encrypts a given value using the configured CipherStash client. - **value** (*string | object | number | boolean | null*) - The value to encrypt. - **options** (*ProtectOptions* - Optional) - Options for encryption, such as specifying the table, column, and region. ### `csTable(tableName, options)` Creates a table context for encryption/decryption operations. - **tableName** (*string*) - The name of the table. - **options** (*TableOptions* - Optional) - Options for the table context. ### `csColumn(columnName, options)` Creates a column context for encryption/decryption operations. - **columnName** (*string*) - The name of the column. - **options** (*ColumnOptions* - Optional) - Options for the column context. ### `csValue(value, options)` Creates a value context for encryption/decryption operations. - **value** (*any*) - The value to contextualize. - **options** (*ValueOptions* - Optional) - Options for the value context. ### `encryptedToPgComposite(encryptedData)` Converts encrypted data to a PostgreSQL composite type format. - **encryptedData** (*EncryptedData*) - The encrypted data structure. - **Returns**: (*object*) - A representation suitable for PostgreSQL composite types. ### `modelToEncryptedPgComposites(model, options)` Converts a data model into multiple encrypted PostgreSQL composite structures. - **model** (*object*) - The data model to convert. - **options** (*ModelToPgOptions* - Optional) - Options for the conversion process. - **Returns**: (*Array*) - An array of encrypted PostgreSQL composite structures. ### `bulkModelsToEncryptedPgComposites(models, options)` Converts an array of data models into multiple encrypted PostgreSQL composite structures in bulk. - **models** (*Array*) - An array of data models to convert. - **options** (*BulkModelToPgOptions* - Optional) - Options for the bulk conversion process. - **Returns**: (*Array*) - An array of encrypted PostgreSQL composite structures. ### `toFfiKeysetIdentifier(keyset)` Converts a keyset identifier to a format suitable for FFI (Foreign Function Interface). - **keyset** (*KeysetIdentifier*) - The keyset identifier. - **Returns**: (*object*) - The FFI-compatible keyset identifier. ### `isEncryptedPayload(payload)` Checks if a given payload conforms to the encrypted payload structure. - **payload** (*object*) - The payload to check. - **Returns**: (*boolean*) - True if the payload is an encrypted payload, false otherwise. ``` -------------------------------- ### ProtectTable Class Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectTable Documentation for the ProtectTable class, including its properties and methods. ```APIDOC ## ProtectTable Class ### Description Represents a table definition within the ProtectJS schema. ### Properties #### `tableName` - **tableName** (string) - Readonly - The name of the table. ### Methods #### `build()` ##### Description Builds a `TableDefinition` object by combining the `tableName` and configured columns. ##### Method `build(): TableDefinition` ##### Returns - **TableDefinition** - The generated table definition object. ``` -------------------------------- ### ProtectValue Methods Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectValue This section covers the methods available on the ProtectValue class. ```APIDOC ## ProtectValue Defined in: packages/schema/src/index.ts:108 ### Methods #### `dataType(castAs)` **Description**: Set or override the cast_as value. **Method**: Not applicable (method of a class) **Endpoint**: Not applicable #### Parameters - **castAs** (string | number | bigint | boolean | date | json) - Required - The data type to cast the value as. #### Returns - `ProtectValue` - The modified ProtectValue object. * * * #### `build()` **Description**: Builds the schema configuration for the ProtectValue. **Method**: Not applicable (method of a class) **Endpoint**: Not applicable #### Returns - **object** - The schema configuration. - **cast_as** (string | number | bigint | boolean | date | json) - The data type of the value. - **indexes** (object) - An object representing indexes for the value. Defaults to an empty object. #### Response Example ```json { "cast_as": "string", "indexes": {} } ``` * * * #### `getName()` **Description**: Retrieves the name of the ProtectValue. **Method**: Not applicable (method of a class) **Endpoint**: Not applicable #### Returns - **string** - The name of the ProtectValue. #### Response Example ```json "example_value_name" ``` ``` -------------------------------- ### Construct LockContext Source: https://cipherstash.com/docs/reference/protectjs/latest/classes/LockContext Initializes a new instance of the LockContext class. This constructor requires named parameters and returns a LockContext object. ```typescript new LockContext(__namedParameters): LockContext; ``` -------------------------------- ### Search Terms Operation Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Allows the creation of search terms for querying encrypted data. These terms can be used directly or with a specified lock context. ```APIDOC ## `createSearchTerms()` ### Description Creates search terms to be used in a query for encrypted data. This operation can optionally be configured with a lock context. ### Method Not applicable (this is a client-side function call) ### Endpoint Not applicable (this is a client-side function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **terms** (any) - Required - The search terms to be created. ### Request Example ```javascript // Example usage: await eqlClient.createSearchTerms(searchTerms); await eqlClient.createSearchTerms(searchTerms).withLockContext(lockContext); ``` ### Response #### Success Response (200) * **SearchTermsOperation** - An object representing the search terms operation. #### Response Example ```json { "operationType": "SearchTerms" } ``` ``` -------------------------------- ### ProtectColumn freeTextSearch() Method Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectColumn Enables a 'Match' index for full-text search on a ProtectColumn. Allows for custom index options, including tokenizer types (standard, ngram) and token filters. Returns the ProtectColumn instance for chaining. ```typescript freeTextSearch(opts?): ProtectColumn; ``` -------------------------------- ### TypeScript: Build TableDefinition from ProtectTable Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectTable This snippet demonstrates the `build()` method of the `ProtectTable` type. This method constructs and returns a `TableDefinition` object by combining the `tableName` with its configured columns. It is crucial for generating the final table schema. ```typescript build(): TableDefinition; ``` -------------------------------- ### ProtectClient Encryption Operations Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Provides methods for encrypting single items, models, and bulk items. ```APIDOC ## encrypt() ### Description Encrypts a single plaintext value. Returns an `EncryptOperation` object that can be awaited or used with `.withLockContext()`. ### Method `encrypt(plaintext, opts)` ### Parameters #### `plaintext` (JsPlaintext | null) - Required The data to encrypt. #### `opts` (object) - Optional Options for encryption. - **`column`** (string) - Required - The name of the column to encrypt for. - **`table`** (string) - Required - The name of the table the column belongs to. ### Returns `EncryptOperation` - An object representing the encryption operation. ### Request Example ```json { "plaintext": "sensitive data", "opts": { "column": "email", "table": "users" } } ``` ## encryptModel() ### Description Encrypts all fields of a model object based on the table schema. Returns an `EncryptModelOperation` object. ### Method `encryptModel(input, table)` ### Parameters #### `input` (T) - Required The model object to encrypt. #### `table` (string) - Required The name of the table associated with the model. ### Type Parameters `T` - A type extending `Record`, representing the model structure. ### Returns `EncryptModelOperation` - An object representing the model encryption operation. ### Request Example ```json { "input": { "email": "user@example.com", "name": "John Doe" }, "table": "users" } ``` ## bulkEncryptModels() ### Description Encrypts multiple model objects in bulk. Returns a `BulkEncryptModelsOperation` object. ### Method `bulkEncryptModels(input, table)` ### Parameters #### `input` (T[]) - Required An array of model objects to encrypt. #### `table` (string) - Required The name of the table associated with the models. ### Type Parameters `T` - A type extending `Record`, representing the model structure. ### Returns `BulkEncryptModelsOperation` - An object representing the bulk model encryption operation. ### Request Example ```json { "input": [ {"email": "user1@example.com", "name": "User One"}, {"email": "user2@example.com", "name": "User Two"} ], "table": "users" } ``` ## bulkEncrypt() ### Description Encrypts multiple plaintext values in bulk. Returns a `BulkEncryptOperation` object. ### Method `bulkEncrypt(plaintexts, opts)` ### Parameters #### `plaintexts` (Array) - Required An array of values to encrypt. #### `opts` (object) - Required Options for bulk encryption. - **`column`** (string) - Required - The name of the column to encrypt for. - **`table`** (string) - Required - The name of the table the column belongs to. ### Returns `BulkEncryptOperation` - An object representing the bulk encryption operation. ### Request Example ```json { "plaintexts": ["data1", "data2", "data3"], "opts": { "column": "data", "table": "logs" } } ``` ``` -------------------------------- ### Client Information API Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Retrieves information about the current client environment, such as the workspace ID, which can be useful for debugging or environment analysis. ```APIDOC ## `clientInfo()` ### Description Provides debugging or environment information for the current client. ### Method Not applicable (this is a client-side function call) ### Endpoint Not applicable (this is a client-side function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript const info = await eqlClient.clientInfo(); console.log(info.workspaceId); ``` ### Response #### Success Response (200) * **workspaceId** (string | undefined) - The ID of the current workspace, if available. #### Response Example ```json { "workspaceId": "your-workspace-id" } ``` ``` -------------------------------- ### Create Search Terms for Encrypted Data Queries (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient The `createSearchTerms` function generates operation objects used for querying encrypted data. It can be used directly or with an optional `lockContext`. The function returns a `SearchTermsOperation` object. ```typescript createSearchTerms(terms): SearchTermsOperation; ``` -------------------------------- ### ProtectColumn equality() Method Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectColumn Enables an exact match index for a ProtectColumn. Optionally accepts token filters, such as 'downcase', to modify the indexing behavior. Returns the ProtectColumn instance for chaining. ```typescript equality(tokenFilters?): ProtectColumn; ``` -------------------------------- ### ProtectClient Decryption Operations Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Provides methods for decrypting single items, models, and bulk items. ```APIDOC ## decrypt() ### Description Decrypts a single encrypted value. Returns a `DecryptOperation` object that can be awaited or used with `.withLockContext()`. ### Method `decrypt(encryptedData)` ### Parameters #### `encryptedData` (EncryptedData) - Required The encrypted data to decrypt. ### Returns `DecryptOperation` - An object representing the decryption operation. ### Request Example ```json { "encryptedData": "encrypted_value_here" } ``` ## decryptModel() ### Description Decrypts all fields of a model object. Returns a `DecryptModelOperation` object. ### Method `decryptModel(input)` ### Parameters #### `input` (T) - Required The model object with encrypted values. ### Type Parameters `T` - A type extending `Record`, representing the model structure. ### Returns `DecryptModelOperation` - An object representing the model decryption operation. ### Request Example ```json { "input": { "email": "encrypted_email_value", "name": "encrypted_name_value" } } ``` ## bulkDecryptModels() ### Description Decrypts multiple model objects in bulk. Returns a `BulkDecryptModelsOperation` object. ### Method `bulkDecryptModels(input)` ### Parameters #### `input` (T[]) - Required An array of model objects with encrypted values. ### Type Parameters `T` - A type extending `Record`, representing the model structure. ### Returns `BulkDecryptModelsOperation` - An object representing the bulk model decryption operation. ### Request Example ```json { "input": [ {"email": "encrypted_email_1", "name": "encrypted_name_1"}, {"email": "encrypted_email_2", "name": "encrypted_name_2"} ] } ``` ## bulkDecrypt() ### Description Decrypts multiple encrypted values in bulk. Returns a `BulkDecryptOperation` object. ### Method `bulkDecrypt(encryptedPayloads)` ### Parameters #### `encryptedPayloads` (Array) - Required An array of encrypted values to decrypt. ### Returns `BulkDecryptOperation` - An object representing the bulk decryption operation. ### Request Example ```json { "encryptedPayloads": ["encrypted_data_1", "encrypted_data_2"] } ``` ``` -------------------------------- ### Bulk Encrypt Plaintexts with ProtectClient Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Performs bulk encryption on an array of plaintext values. This method is designed for high-throughput encryption scenarios and returns a thenable BulkEncryptOperation. ```typescript bulkEncrypt(plaintexts: JsPlaintext[] | null[], opts: { column: string; table: string }): BulkEncryptOperation; ``` -------------------------------- ### ProtectColumn orderAndRange() Method Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectColumn Enables Order-Revealing Encryption (ORE) indexing for a ProtectColumn. This method returns the ProtectColumn instance for chaining. ```typescript orderAndRange(): ProtectColumn; ``` -------------------------------- ### ProtectJS - Type Aliases Source: https://cipherstash.com/docs/reference/protectjs/latest/index Defines various type aliases used within the ProtectJS library for better type safety and code readability. ```APIDOC ## Type Aliases - **Result**: Represents the outcome of an operation, potentially including data or an error. - **EncryptedPgComposite**: Represents encrypted data in a format compatible with PostgreSQL composite types. - **CtsRegions**: Defines the possible regions for CipherStash operations. - **IdentifyOptions**: Options for identifying encryption keys or configurations. - **CtsToken**: Represents a CipherStash token, often used for authentication or session management. - **Context**: A generic context object used across various operations. - **LockContextOptions**: Options for configuring a lock context. - **GetLockContextResponse**: The response structure when retrieving a lock context. - **ProtectClientConfig**: Configuration options for the ProtectClient. - **Client**: An alias for the `ProtectClient` interface. - **Encrypted**: A generic type for encrypted data. - **EncryptedPayload**: Represents a payload containing encrypted data. - **EncryptedData**: Detailed structure of encrypted data, including ciphertext, key ID, and region. - **SearchTerm**: Represents a term to be searched, potentially encrypted. - **KeysetIdentifier**: Identifies a specific keyset used for encryption/decryption. - **EncryptedSearchTerm**: Represents a search term that has been encrypted. - **EncryptPayload**: The structure of a payload intended for encryption. - **EncryptOptions**: Options specific to the encryption process. - **EncryptedFields**: Represents fields within a data structure that are encrypted. - **OtherFields**: Represents fields within a data structure that are not encrypted. - **DecryptedFields**: Represents fields within a data structure that have been decrypted. - **Decrypted**: Represents data that has been successfully decrypted. - **BulkEncryptPayload**: Payload structure for performing bulk encryption operations. - **BulkEncryptedData**: Represents the result of bulk encryption. - **BulkDecryptPayload**: Payload structure for performing bulk decryption operations. - **BulkDecryptedData**: Represents the result of bulk decryption. - **DecryptionResult**: The outcome of a decryption operation. - **ProtectTableColumn**: Represents a column within a protected table, including its encryption details. ``` -------------------------------- ### Bulk Encrypt Models with ProtectClient Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Encrypts multiple model objects in a single operation. This is optimized for performance when dealing with collections of data. The operation is thenable and supports lock contexts. ```typescript bulkEncryptModels>(input: T[], table: string): BulkEncryptModelsOperation; ``` -------------------------------- ### Build Schema Object with build() - TypeScript Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectValue The build() method constructs the schema object, including the 'cast_as' type and 'indexes'. The 'cast_as' can be one of several primitive types or JSON. The 'indexes' property is an object, typically initialized as empty. ```typescript build(): { cast_as: "string" | "number" | "bigint" | "boolean" | "date" | "json"; indexes: { }; }; ``` -------------------------------- ### getLockContext() Method Source: https://cipherstash.com/docs/reference/protectjs/latest/classes/LockContext Retrieves the current lock context. ```APIDOC ## getLockContext() ### Description Retrieves the current lock context information. ### Method GET (implicitly, as it's a retrieval operation) ### Endpoint `/getLockContext` (relative to the library's context) ### Parameters This method does not accept any parameters. ### Request Example ```javascript const result = await lockContext.getLockContext(); ``` ### Response #### Success Response (200) * `Result` (object) - A Promise that resolves to a Result object containing either the GetLockContextResponse on success or a ProtectError on failure. #### Response Example ```json { "success": true, "data": { "lockContextId": "some-id", "createdAt": "2023-10-27T10:00:00Z" } } ``` #### Error Response (e.g., 400 or 500) * `ProtectError` (object) - Details about the error that occurred. #### Error Response Example ```json { "success": false, "error": { "message": "Failed to retrieve lock context" } } ``` ``` -------------------------------- ### ProtectClientConfig 'clientKey' Property (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/ProtectClientConfig Details the optional 'clientKey' property for ProtectClientConfig, used to provide the client key for authentication or encryption purposes. ```typescript clientKey?: string; ``` -------------------------------- ### ProtectClientConfig 'accessKey' Property (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/ProtectClientConfig Details the optional 'accessKey' property for ProtectClientConfig, used to provide the access key for client authentication. ```typescript accessKey?: string; ``` -------------------------------- ### ProtectClientConfig 'keyset' Property (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/ProtectClientConfig Describes the optional 'keyset' property within ProtectClientConfig, used to specify the KeysetIdentifier for managing encryption keys. ```typescript keyset?: KeysetIdentifier; ``` -------------------------------- ### Encrypt Model with ProtectClient Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Encrypts all relevant fields within a model object. This is useful for encrypting entire data structures at once. The operation is thenable and supports lock contexts. ```typescript encryptModel>(input: T, table: string): EncryptModelOperation; ``` -------------------------------- ### Define ProtectClientConfig Type (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/ProtectClientConfig Defines the structure of the ProtectClientConfig object used for client-side configuration in CipherStash. It includes required schemas and optional properties like workspaceCrn, accessKey, clientId, clientKey, and keyset. ```typescript type ProtectClientConfig = { schemas: AtLeastOneCsTable>; workspaceCrn?: string; accessKey?: string; clientId?: string; clientKey?: string; keyset?: KeysetIdentifier; }; ``` -------------------------------- ### identify() Method Source: https://cipherstash.com/docs/reference/protectjs/latest/classes/LockContext Identifies the lock context using a JWT token. ```APIDOC ## identify() ### Description Identifies the lock context using a provided JWT token. ### Method POST (implicitly, as it's an action) ### Endpoint `/identify` (relative to the library's context) ### Parameters #### Query Parameters * **jwtToken** (string) - Required - The JSON Web Token to authenticate and identify the context. ### Request Example ```javascript const result = await lockContext.identify('your_jwt_token'); ``` ### Response #### Success Response (200) * `Result` (object) - A Promise that resolves to a Result object containing either a LockContext on success or a ProtectError on failure. #### Response Example ```json { "success": true, "data": { "instance": "LockContext" } } ``` #### Error Response (e.g., 400 or 500) * `ProtectError` (object) - Details about the error that occurred. #### Error Response Example ```json { "success": false, "error": { "message": "Invalid JWT token" } } ``` ``` -------------------------------- ### Bulk Decrypt Models with ProtectClient Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Decrypts multiple model objects in a single operation. This method is efficient for batch decryption tasks and supports the use of lock contexts. ```typescript bulkDecryptModels>(input: T[]): BulkDecryptModelsOperation; ``` -------------------------------- ### ProtectClientConfig 'workspaceCrn' Property (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/ProtectClientConfig Describes the optional 'workspaceCrn' property within ProtectClientConfig, used to specify the workspace CRN (Cloud Resource Name) for the client configuration. ```typescript workspaceCrn?: string; ``` -------------------------------- ### ProtectClientConfig 'schemas' Property (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/ProtectClientConfig Details the 'schemas' property within ProtectClientConfig, which is a required field. It specifies the structure for defining at least one table schema for Protect. ```typescript schemas: AtLeastOneCsTable>; ``` -------------------------------- ### Encrypt Plaintext with ProtectClient Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Encrypts a single plaintext value. This method returns an EncryptOperation object which is thenable, allowing for asynchronous handling of the encryption process. Optional lock contexts can be applied. ```typescript encrypt(plaintext: JsPlaintext | null, opts: { column: string; table: string }): EncryptOperation; ``` -------------------------------- ### Bulk Decrypt Encrypted Data with ProtectClient Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Decrypts an array of encrypted data values in a single batch operation. This is an efficient way to handle multiple decryption requests and returns a thenable BulkDecryptOperation. ```typescript bulkDecrypt(encryptedPayloads: EncryptedData[]): BulkDecryptOperation; ``` -------------------------------- ### Define EncryptOptions Type in TypeScript Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/EncryptOptions Defines the TypeScript type for EncryptOptions, used to specify encryption parameters for columns and tables. It requires ProtectColumn or ProtectValue for column encryption and a ProtectTable with ProtectTableColumn for table encryption. ```typescript type EncryptOptions = { column: | ProtectColumn | ProtectValue; table: ProtectTable; }; ``` -------------------------------- ### ProtectClientConfig 'clientId' Property (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/ProtectClientConfig Describes the optional 'clientId' property within ProtectClientConfig, used for specifying the client identifier. ```typescript clientId?: string; ``` -------------------------------- ### EncryptOptions 'column' Property Type in TypeScript Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/EncryptOptions Specifies the type for the 'column' property within EncryptOptions. This property can accept either a ProtectColumn or a ProtectValue, defining how a single column should be encrypted. ```typescript column: | ProtectColumn | ProtectValue; ``` -------------------------------- ### Index Signature for ProtectTableColumn (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/ProtectTableColumn Illustrates the index signature part of the ProtectTableColumn type, showing how string keys can map to ProtectColumn or nested structures containing ProtectValue. ```typescript [key: string]: | ProtectColumn | { [key: string]: | ProtectValue | { [key: string]: ProtectValue; }; } ``` -------------------------------- ### ProtectColumn dataType() Method Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectColumn Sets or overrides the 'cast_as' value for a ProtectColumn. This method returns the ProtectColumn instance, allowing for method chaining. ```typescript dataType(castAs): ProtectColumn; ``` -------------------------------- ### EncryptOptions 'table' Property Type in TypeScript Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/EncryptOptions Defines the type for the 'table' property within EncryptOptions. This property expects a ProtectTable generic type, parameterized with ProtectTableColumn, to manage table-level encryption settings. ```typescript table: ProtectTable; ``` -------------------------------- ### Identify LockContext using JWT Source: https://cipherstash.com/docs/reference/protectjs/latest/classes/LockContext The identify method takes a JWT token as input and returns a Promise that resolves to a Result. The Result can either contain a LockContext object upon success or a ProtectError upon failure. ```typescript identify(jwtToken): Promise>; ``` -------------------------------- ### ClientInitError Constant Source: https://cipherstash.com/docs/reference/protectjs/latest/variables/ProtectErrorTypes This TypeScript code defines the 'ClientInitError' constant, assigning it the string value 'ClientInitError'. This constant is part of the ProtectErrorTypes object and is used to represent errors occurring during the initialization phase of a CipherStash client. ```typescript ClientInitError: string = 'ClientInitError'; ``` -------------------------------- ### Decrypt Model with ProtectClient Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Decrypts all relevant fields within a model object containing encrypted values. This operation is thenable and can be used with lock contexts for secure decryption. ```typescript decryptModel>(input: T): DecryptModelOperation; ``` -------------------------------- ### Define SearchTerm Type (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/SearchTerm Defines the SearchTerm type, representing a value to be encrypted for search operations. It requires the value, column, and table, with an optional return type to specify how the search result should be formatted. ```TypeScript type SearchTerm = { value: JsPlaintext; column: ProtectColumn; table: ProtectTable; returnType?: "eql" | "composite-literal" | "escaped-composite-literal"; }; ``` -------------------------------- ### Define ProtectErrorTypes in TypeScript Source: https://cipherstash.com/docs/reference/protectjs/latest/variables/ProtectErrorTypes This code snippet defines the structure for ProtectErrorTypes in TypeScript. It declares an object containing string constants for various error conditions encountered within the CipherStash protect.js library, such as client initialization, encryption, decryption, lock context, and CTS token errors. ```typescript const ProtectErrorTypes: { ClientInitError: string; EncryptionError: string; DecryptionError: string; LockContextError: string; CtsTokenError: string; }; ``` -------------------------------- ### TypeScript: Define ProtectTable tableName Property Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectTable This snippet shows the definition of the `tableName` property within the `ProtectTable` type. It is a read-only string that specifies the name of the table. This property is essential for identifying the table within the schema. ```typescript readonly tableName: string; ``` -------------------------------- ### Decrypt Encrypted Data with ProtectClient Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectClient Decrypts an encrypted data value. Similar to encryption, this returns a DecryptOperation object that is thenable. Lock contexts can also be applied to this operation. ```typescript decrypt(encryptedData: EncryptedData): DecryptOperation; ``` -------------------------------- ### Define Data Type with dataType() - TypeScript Source: https://cipherstash.com/docs/reference/protectjs/latest/interfaces/ProtectValue The dataType() method allows you to set or override the 'cast_as' value for a ProtectValue schema. It returns the modified ProtectValue instance for chaining. ```typescript dataType(castAs): ProtectValue; ``` -------------------------------- ### DecryptionError Constant Source: https://cipherstash.com/docs/reference/protectjs/latest/variables/ProtectErrorTypes This TypeScript code defines the 'DecryptionError' constant, assigning it the string value 'DecryptionError'. This constant is used to identify and report errors encountered during the data decryption process within the CipherStash protect.js library. ```typescript DecryptionError: string = 'DecryptionError'; ``` -------------------------------- ### CtsTokenError Constant Source: https://cipherstash.com/docs/reference/protectjs/latest/variables/ProtectErrorTypes This TypeScript code defines the 'CtsTokenError' constant, assigning it the string value 'CtsTokenError'. This constant is used to denote errors specifically related to the handling or validation of CTS tokens in CipherStash. ```typescript CtsTokenError: string = 'CtsTokenError'; ``` -------------------------------- ### Define EncryptedSearchTerm Type (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/EncryptedSearchTerm Defines the EncryptedSearchTerm type, which can represent either an 'Encrypted' value or a 'string'. This type is used to specify the return type of a search term, differentiating between encrypted data and string literals (composite or escaped composite). ```typescript type EncryptedSearchTerm = | Encrypted | string; ``` -------------------------------- ### ProtectTableColumn Type Definition (TypeScript) Source: https://cipherstash.com/docs/reference/protectjs/latest/type-aliases/ProtectTableColumn Defines the ProtectTableColumn type, a recursive structure used to represent columns in a table. It can hold a ProtectColumn or a nested object that can contain ProtectValue or further nested objects. ```typescript type ProtectTableColumn = { [key: string]: | ProtectColumn | { [key: string]: | ProtectValue | { [key: string]: ProtectValue; }; }; }; ``` -------------------------------- ### LockContextError Constant Source: https://cipherstash.com/docs/reference/protectjs/latest/variables/ProtectErrorTypes This TypeScript code defines the 'LockContextError' constant, assigning it the string value 'LockContextError'. It serves as an error identifier for issues related to the lock context management within CipherStash's operations. ```typescript LockContextError: string = 'LockContextError'; ``` -------------------------------- ### EncryptionError Constant Source: https://cipherstash.com/docs/reference/protectjs/latest/variables/ProtectErrorTypes This TypeScript code defines the 'EncryptionError' constant, assigning it the string value 'EncryptionError'. It is used within the ProtectErrorTypes object to signify errors that occur during data encryption operations in CipherStash. ```typescript EncryptionError: string = 'EncryptionError'; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.