Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinta365 committed Apr 29, 2024
1 parent a19234c commit eee3009
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/cryptokeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,44 @@ export async function generateKeyPair(
}
}

// Options for PEM formatted file write.
/**
* Options for PEM formatted file write.
*/
export interface ExportPEMKeyOptions {
// Optional path to write the PEM-formatted key to
/**
* Optional path to write the PEM-formatted key to
*/
filePath?: string;
// Optional for file write mode
/**
* Optional for file write mode
*/
mode?: number;
}

// Overload 1: Export without writing to a file
/**
* Exports a CryptoKey to PEM format.
*
* @param key - The CryptoKey to export.
* @returns {Promise<string>} A Promise resolving to the PEM-formatted key string.
*/
export function exportPEMKey(key: CryptoKey): Promise<string>;

// Overload 2: Export with a file path (default mode)
/**
* Exports a CryptoKey to PEM format with file path.
*
* @param key - The CryptoKey to export.
* @param filePathOrOptions - Path to write the PEM-formatted key to.
* @returns {Promise<string>} A Promise resolving to the PEM-formatted key string.
*/
export function exportPEMKey(key: CryptoKey, filePath: string): Promise<string>;

// Overload 3: Export with custom options
/**
* Exports a CryptoKey to PEM format with options.
*
* @param key - The CryptoKey to export.
* @param filePathOrOptions - an ExportPEMKeyOptions object.
* @returns {Promise<string>} A Promise resolving to the PEM-formatted key string.
*/
export function exportPEMKey(key: CryptoKey, options: ExportPEMKeyOptions): Promise<string>;

/**
Expand Down

0 comments on commit eee3009

Please sign in to comment.