From 927d31a143a4d85f09712ce0b6ead947a9503347 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 22 Apr 2023 19:27:21 -0700 Subject: [PATCH] Drop default export The syntax for dynamically importing default is annoying --- README.md | 4 ++-- decrypt.js | 2 +- encrypt.js | 2 +- index.html | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fac9eef..cb21672 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ To integrate the decryption into your own frontend: 1. Import the `decrypt` function provided in `/decrypt.js`: ```javascript -import decrypt from 'https://cdn.jsdelivr.net/gh/ardislu/static-encrypt/decrypt.js'; +import { decrypt } from 'https://cdn.jsdelivr.net/gh/ardislu/static-encrypt/decrypt.js'; ``` 2. Pass the encrypted content string and the password to the `decrypt` function: @@ -63,5 +63,5 @@ plaintext You can also import the function dynamically (useful for lazy-loading or testing in DevTools): ```javascript -const { default: decrypt } = await import('https://cdn.jsdelivr.net/gh/ardislu/static-encrypt/decrypt.js'); +const { decrypt } = await import('https://cdn.jsdelivr.net/gh/ardislu/static-encrypt/decrypt.js'); ``` diff --git a/decrypt.js b/decrypt.js index ee4248b..a44f8f9 100644 --- a/decrypt.js +++ b/decrypt.js @@ -4,7 +4,7 @@ * @param {string} password - The password used to encrypt the string. * @returns {Promise} A promise that resolves to the plaintext. */ -export default async function decrypt(content, password) { +export async function decrypt(content, password) { const encoder = new TextEncoder(); const encodedPassword = encoder.encode(password); const additionalData = encoder.encode('https://github.com/ardislu/static-encrypt'); diff --git a/encrypt.js b/encrypt.js index e53edc8..f86ecea 100644 --- a/encrypt.js +++ b/encrypt.js @@ -4,7 +4,7 @@ * @param {string} password - The password used to encrypt the string. * @returns {Promise} A promise that resolves to the ciphertext. */ -export default async function encrypt(plaintext, password) { +export async function encrypt(plaintext, password) { const encoder = new TextEncoder(); const encodedPlaintext = encoder.encode(plaintext); const encodedPassword = encoder.encode(password); diff --git a/index.html b/index.html index 051e4a8..a999a2d 100644 --- a/index.html +++ b/index.html @@ -173,8 +173,8 @@