From 71eeb033a7e6dc27e5b8a82cf9f4188621254b0e Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Fri, 8 Sep 2023 20:30:04 -0700 Subject: [PATCH] Add *.d.ts files --- README.md | 10 ++++++++++ decrypt.d.ts | 7 +++++++ encrypt.d.ts | 7 +++++++ 3 files changed, 24 insertions(+) create mode 100644 decrypt.d.ts create mode 100644 encrypt.d.ts diff --git a/README.md b/README.md index 310b7b4..bc2d0f8 100644 --- a/README.md +++ b/README.md @@ -85,3 +85,13 @@ You can also import the function dynamically (useful for lazy-loading or testing ```javascript const { decrypt } = await import('https://cdn.statically.io/gh/ardislu/static-encrypt/master/decrypt.js'); ``` + +### TypeScript + +`*.d.ts` files are generated from the [JSDoc](https://jsdoc.app/) comments using `tsc`: + +``` +tsc --declaration --emitDeclarationOnly --allowJs .\decrypt.js .\encrypt.js +``` + +These `*.d.ts` files allow `encrypt` and `decrypt` to be imported in `.ts` files with typing. diff --git a/decrypt.d.ts b/decrypt.d.ts new file mode 100644 index 0000000..1ca1795 --- /dev/null +++ b/decrypt.d.ts @@ -0,0 +1,7 @@ +/** + * Decrypt an encrypted string. + * @param {string} content - The ciphertext to decrypt. + * @param {string} password - The password used to encrypt the string. + * @returns {Promise} A promise that resolves to the plaintext. + */ +export function decrypt(content: string, password: string): Promise; diff --git a/encrypt.d.ts b/encrypt.d.ts new file mode 100644 index 0000000..158def8 --- /dev/null +++ b/encrypt.d.ts @@ -0,0 +1,7 @@ +/** + * Encrypt a string. + * @param {string} plaintext - The string to encrypt. + * @param {string} password - The password used to encrypt the string. + * @returns {Promise} A promise that resolves to the ciphertext. + */ +export function encrypt(plaintext: string, password: string): Promise; -- 2.47.3