From 59ea256917f89b8c0b41b51b7de593df3af34645 Mon Sep 17 00:00:00 2001 From: jpcompartir Date: Tue, 27 Jan 2026 09:52:18 +0000 Subject: [PATCH 1/2] Fix the data - doc mismatch of the .error_msg arg/param --- R/data.R | 4 ++-- man/df_embeddings_hf.Rd | 2 +- man/df_sentiment_classification_example.Rd | 2 +- vignettes/.gitignore | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/R/data.R b/R/data.R index 14c731e..42b3869 100644 --- a/R/data.R +++ b/R/data.R @@ -28,7 +28,7 @@ #' \item{text}{Character; the original text that was embedded} #' \item{category}{Character; category classification of the text} #' \item{.error}{Logical; whether the embedding process failed} -#' \item{.error_message}{Character; error message if embedding failed (NA if successful)} +#' \item{.error_msg}{Character; error message if embedding failed (NA if successful)} #' \item{V1}{Numeric; embedding vector dimensions} #' \item{V2}{Numeric; embedding vector dimensions} #' \item{V3}{Numeric; embedding vector dimensions} @@ -815,7 +815,7 @@ #' \item{NEGATIVE}{Numeric; probability score for negative sentiment (0-1)} #' \item{POSITIVE}{Numeric; probability score for positive sentiment (0-1)} #' \item{.error}{Logical; whether the classification process failed} -#' \item{.error_message}{Character; error message if classification failed (NA if successful)} +#' \item{.error_msg}{Character; error message if classification failed (NA if successful)} #' } #' @source Generated using Hugging Face sentiment classification model via EndpointR functions "df_sentiment_classification_example" diff --git a/man/df_embeddings_hf.Rd b/man/df_embeddings_hf.Rd index ae7753b..e0bd787 100644 --- a/man/df_embeddings_hf.Rd +++ b/man/df_embeddings_hf.Rd @@ -11,7 +11,7 @@ A data frame with 3 rows and 773 variables: \item{text}{Character; the original text that was embedded} \item{category}{Character; category classification of the text} \item{.error}{Logical; whether the embedding process failed} -\item{.error_message}{Character; error message if embedding failed (NA if successful)} +\item{.error_msg}{Character; error message if embedding failed (NA if successful)} \item{V1}{Numeric; embedding vector dimensions} \item{V2}{Numeric; embedding vector dimensions} \item{V3}{Numeric; embedding vector dimensions} diff --git a/man/df_sentiment_classification_example.Rd b/man/df_sentiment_classification_example.Rd index 662137d..c4efb77 100644 --- a/man/df_sentiment_classification_example.Rd +++ b/man/df_sentiment_classification_example.Rd @@ -13,7 +13,7 @@ A data frame with 3 rows and 7 variables: \item{NEGATIVE}{Numeric; probability score for negative sentiment (0-1)} \item{POSITIVE}{Numeric; probability score for positive sentiment (0-1)} \item{.error}{Logical; whether the classification process failed} -\item{.error_message}{Character; error message if classification failed (NA if successful)} +\item{.error_msg}{Character; error message if classification failed (NA if successful)} } } \source{ diff --git a/vignettes/.gitignore b/vignettes/.gitignore index 097b241..9e2bd63 100644 --- a/vignettes/.gitignore +++ b/vignettes/.gitignore @@ -1,2 +1,4 @@ *.html *.R + +/.quarto/ From 713710952d0453077a53fe1972a84b96bcb1d942 Mon Sep 17 00:00:00 2001 From: jpcompartir Date: Tue, 27 Jan 2026 09:52:40 +0000 Subject: [PATCH 2/2] Add encryption info to the api_keys.Rmd vignette and catch a typo --- vignettes/api_keys.Rmd | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/vignettes/api_keys.Rmd b/vignettes/api_keys.Rmd index cbbbf1a..9f3dcdf 100644 --- a/vignettes/api_keys.Rmd +++ b/vignettes/api_keys.Rmd @@ -60,7 +60,7 @@ It is **paramount** that we handle our API keys securely. You need to avoid the - Uploading API keys to web services (GitHub, etc.) - Sharing API keys with other people - Including unencrypted API keys in your code (scripts, R/Quarto/markdown files, .ipynb etc.) -- Unencypted API keys appearing in your .Rhistory file (**especially** if this file is being uploaded anywhere) +- Unencrypted API keys appearing in your .Rhistory file (**especially** if this file is being uploaded anywhere) If you suspect you may have done one - or any number - of these things, go directly to where you got your key, invalidate the old one and generate a new one. If the key was given to you, go directly to the person and tell them that your key has been compromised and they will invalidate it for you, and provide you a new one. @@ -85,3 +85,39 @@ For each endpoint that EndpointR provides access to, you will need the correct e | | | | : API Key Lookup Table + +# Encrypting Your API Keys + +To avoid exposing your API keys in plain text it's sensible to encrypt them. The basic flow is to: + +1. Create an encryption key +2. Store this key securely, somewhere separate to where your other API keys are stored +3. Use this encryption key to encrypt your other API keys. Use R's input tool or a package like {askpass} to avoid inputting the key in your R Session +4. Decrypt your API keys whenever you need them, using your encryption key + +Here's an example in code where we make use of httr2's `secret_make_key`, `secret_encrypt` and `secret_decrypt` functions to achieve this. + +First we make an encryption key, remembering not to print it to the console/view its contents in our session + +```{r} +SUPER_SECRET_ENCRYPTION_DEVICE <- httr2::secret_make_key() # store this separately to your API keys, but still somewhere you can retrieve/access it from. +``` + +Then we take some information that we want to encrypt, and input it with askpass: +```{r, eval=FALSE} +info <- askpass::askpass() +encrypted_info <- httr2::secret_encrypt(info, SUPER_SECRET_ENCRYPTION_DEVICE) +encrypted_info +``` + +```{r, echo=FALSE} +info <- "What's the worst that could happen?" +encrypted_info <- httr2::secret_encrypt(info, SUPER_SECRET_ENCRYPTION_DEVICE) +encrypted_info +``` + +Now our secret is encrypted, we decrypt it to get the original information back. + +```{r} +httr2::secret_decrypt(encrypted_info, SUPER_SECRET_ENCRYPTION_DEVICE) +```