@decaf-ts/fabric-weaver
Version:
template for ts projects
101 lines (100 loc) • 4.9 kB
TypeScript
import { Logger } from "@decaf-ts/logging";
import { BCCSPConfig, CAConfig, CorsConfig, CSRConfig, DBConfig, IdemixConfig, Identity, IntermediateCAConfig, LDAPConfig, ServerTLSConfig, SigningConfig } from "../interfaces/fabric/fabric-ca-server-config";
import { MetricsConfig, OperationsConfig } from "../interfaces/fabric/general-configs";
export declare class FabricCAServerConfigBuilder {
private log;
private config;
constructor(logger?: Logger);
setVersion(version?: string): this;
/**
* @description Sets the port for the Fabric CA Server.
* @summary Configures the network port on which the Fabric CA Server will listen for incoming connections.
* @param {number} [port] - The port number for the Fabric CA Server to listen on.
* @return {this} The current instance of the builder for method chaining.
*/
setPort(port?: number): this;
setCors(cors?: CorsConfig): this;
/**
* @description Enables or disables debug mode for the Fabric CA Server.
* @summary Configures whether the Fabric CA Server should run in debug mode, providing more detailed logging and output.
* @param {boolean} [enable] - Whether to enable debug mode.
* @return {this} The current instance of the builder for method chaining.
*/
enableDebug(enable?: boolean): this;
setCrlSizeLimit(crlSizeLimit?: number): this;
setServerTLS(tlsConfig?: ServerTLSConfig): this;
setCA(config?: CAConfig): this;
setCrlExpiry(crlExpiry?: string): this;
setIdentities(ids?: Identity[] | Identity): this;
setMaxEnrollments(maxEnrollments?: number): this;
setDatabase(cfg?: DBConfig): this;
setLDAP(ldap?: LDAPConfig): this;
setAffiliations(affiliations?: {
[key: string]: string[];
}): this;
/**
* @description Removes unused profiles from the Fabric CA Server configuration.
* @summary This method allows you to remove the TLS and/or CA profiles from the configuration if they are not needed.
* Removing unused profiles can help streamline the configuration and potentially improve performance.
* @param {boolean} [removeTLSProfile=false] - Whether to remove the TLS profile.
* @param {boolean} [removeCAProfile=false] - Whether to remove the CA profile.
* @return {this} The current instance of the builder for method chaining.
* @example
* const builder = new FabricCAServerCommandBuilder();
* builder.removeUnusedProfiles(true, false); // Removes TLS profile, keeps CA profile
*
* @mermaid
* sequenceDiagram
* participant Client
* participant Builder as FabricCAServerCommandBuilder
* participant Config as FabricCAServerConfig
* Client->>Builder: removeUnusedProfiles(true, false)
* Builder->>Builder: Check removeTLSProfile
* alt removeTLSProfile is true
* Builder->>Config: Remove TLS profile
* end
* Builder->>Builder: Check removeCAProfile
* alt removeCAProfile is true
* Builder->>Config: Remove CA profile
* end
* Builder-->>Client: Return this
*/
removeUnusedProfiles(removeTLSProfile?: boolean, removeCAProfile?: boolean): this;
setSigning(cfg?: SigningConfig): this;
setCSR(csr?: CSRConfig): this;
setIdemix(idemix?: IdemixConfig): this;
setBCCSP(bccsp?: BCCSPConfig): this;
setCACount(count?: number): this;
setCAFiles(files?: string[]): this;
setIntermediate(int: IntermediateCAConfig): this;
setPasswordAttempts(attempts?: number): this;
setOperations(operations?: OperationsConfig): this;
setMetrics(metrics?: MetricsConfig): this;
/**
* @description Saves the current configuration to a file.
* @summary Writes the current Fabric CA Server configuration to a YAML file at the specified path. If the directory doesn't exist, it will be created.
* @param {string} cpath - The path where the configuration file should be saved.
* @return {this} The current instance of the builder for method chaining.
* @example
* const builder = new FabricCAServerCommandBuilder();
* builder.save('/path/to/config/fabric-ca-server.yaml');
*
* @mermaid
* sequenceDiagram
* participant Client
* participant Builder as FabricCAServerCommandBuilder
* participant FileSystem as File System
* Client->>Builder: saveConfig('/path/to/config/fabric-ca-server.yaml')
* Builder->>Builder: Check if cpath is defined
* alt cpath is defined
* Builder->>FileSystem: Check if directory exists
* alt Directory doesn't exist
* Builder->>FileSystem: Create directory
* end
* Builder->>Builder: Log debug message
* Builder->>FileSystem: Write YAML configuration to file
* end
* Builder-->>Client: Return this
*/
save(cpath?: string): this;
}