From eee300998514ee8602de9f31dbb43de40fd59a38 Mon Sep 17 00:00:00 2001 From: Pinta365 Date: Mon, 29 Apr 2024 19:00:12 +0200 Subject: [PATCH] docs --- src/cryptokeys.ts | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/cryptokeys.ts b/src/cryptokeys.ts index 8bbf4bf..4f9829b 100644 --- a/src/cryptokeys.ts +++ b/src/cryptokeys.ts @@ -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} A Promise resolving to the PEM-formatted key string. + */ export function exportPEMKey(key: CryptoKey): Promise; -// 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} A Promise resolving to the PEM-formatted key string. + */ export function exportPEMKey(key: CryptoKey, filePath: string): Promise; -// 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} A Promise resolving to the PEM-formatted key string. + */ export function exportPEMKey(key: CryptoKey, options: ExportPEMKeyOptions): Promise; /**