-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use environment variables (#53)
* Make env var inputs explicit. https://design.tidyverse.org/inputs-explicit.html * Use userData instead of env. Closes #52. * Update GHA.
- Loading branch information
1 parent
7d5e3bd
commit 2f1f83d
Showing
21 changed files
with
242 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
Package: shinyslack | ||
Title: Integrate Slack and Shiny | ||
Version: 0.0.0.9008 | ||
Authors@R: c( | ||
person(given = "Jon", | ||
family = "Harmon", | ||
role = c("aut", "cre"), | ||
email = "[email protected]", | ||
Version: 0.0.0.9009 | ||
Authors@R: | ||
person("Jon", "Harmon", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0003-4781-4346")) | ||
) | ||
Description: Login to Shiny apps using Slack, and use Slack information in those | ||
apps. | ||
Description: Login to Shiny apps using Slack, and use Slack information in | ||
those apps. | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.3 | ||
URL: https://github.com/r4ds/shinyslack | ||
BugReports: https://github.com/r4ds/shinyslack/issues | ||
Depends: | ||
R (>= 3.5.0) | ||
Imports: | ||
cli, | ||
cookies (>= 0.2.1), | ||
|
@@ -26,16 +21,18 @@ Imports: | |
slackcalls, | ||
slackteams, | ||
sodium | ||
Remotes: | ||
r4ds/scenes, | ||
yonicd/slackcalls, | ||
yonicd/slackteams | ||
Depends: | ||
R (>= 2.10) | ||
Suggests: | ||
knitr, | ||
pkgload, | ||
rmarkdown, | ||
testthat (>= 3.0.0) | ||
VignetteBuilder: knitr | ||
VignetteBuilder: | ||
knitr | ||
Remotes: | ||
shinyworks/scenes, | ||
yonicd/slackcalls, | ||
yonicd/slackteams | ||
Config/testthat/edition: 3 | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.3.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,58 @@ | ||
#' Encrypt a String If Possible | ||
#' | ||
#' @inheritParams .shared-parameters | ||
#' @param string A length-1 character to encrypt (or decrypt). | ||
#' | ||
#' @return If `shinyslack_key` environment variable is set, the encrypted | ||
#' string. Otherwise the original string is returned. | ||
#' @return If `shinyslack_key` is non-empty, the encrypted string. Otherwise the | ||
#' original string is returned. | ||
#' @keywords internal | ||
.shinyslack_encrypt <- function(string) { | ||
shinyslack_key <- Sys.getenv("shinyslack_key", NA) | ||
|
||
if (!is.na(shinyslack_key)) { | ||
cli::cli_inform( | ||
c( | ||
"shinyslack_key found.", | ||
v = "Encrypting string." | ||
) | ||
) | ||
string <- sodium::bin2hex( | ||
sodium::data_encrypt( | ||
msg = charToRaw(string), | ||
key = charToRaw(shinyslack_key), | ||
nonce = .shinyslack_nonce | ||
) | ||
) | ||
.shinyslack_encrypt <- function(string, | ||
shinyslack_key = Sys.getenv("SHINYSLACK_KEY")) { | ||
if (isTRUE(as.logical(nchar(shinyslack_key)))) { | ||
cli::cli_inform(c("shinyslack_key set.", v = "Encrypting string.")) | ||
string <- .sodium_encrypt(string, shinyslack_key) | ||
} else { | ||
cli::cli_warn( | ||
c( | ||
"shinyslack_key not found.", | ||
x = "String not encoded." | ||
) | ||
) | ||
cli::cli_warn(c("shinyslack_key not found.", x = "String not encoded.")) | ||
} | ||
|
||
return(string) | ||
} | ||
|
||
.sodium_encrypt <- function(string, key) { | ||
return( | ||
sodium::bin2hex(sodium::data_encrypt( | ||
msg = charToRaw(string), | ||
key = charToRaw(key), | ||
nonce = .shinyslack_nonce | ||
)) | ||
) | ||
} | ||
|
||
#' Decrypt a String If Possible | ||
#' | ||
#' @inheritParams .shinyslack_encrypt | ||
#' @inheritParams .shared-parameters | ||
#' | ||
#' @return If `shinyslack_key` environment variable is set, the decrypted string | ||
#' (or "bad_string" if decryption fails). Otherwise the original string is | ||
#' @return If `shinyslack_key` is non-empty, the decrypted string (or | ||
#' "bad_string" if decryption fails). Otherwise the original string is | ||
#' returned. | ||
#' @keywords internal | ||
.shinyslack_decrypt <- function(string) { | ||
shinyslack_key <- Sys.getenv("shinyslack_key", NA) | ||
|
||
if (!is.na(shinyslack_key)) { | ||
.shinyslack_decrypt <- function(string, | ||
shinyslack_key = Sys.getenv("SHINYSLACK_KEY")) { | ||
if (length(string) && isTRUE(as.logical(nchar(shinyslack_key)))) { | ||
string <- tryCatch( | ||
error = function(cnd) "bad_string", | ||
rawToChar( | ||
sodium::data_decrypt( | ||
bin = sodium::hex2bin(string), | ||
key = charToRaw(shinyslack_key), | ||
nonce = .shinyslack_nonce | ||
) | ||
) | ||
.sodium_decrypt(string, shinyslack_key) | ||
) | ||
} | ||
|
||
return(string) | ||
} | ||
|
||
.sodium_decrypt <- function(string, key) { | ||
return( | ||
rawToChar(sodium::data_decrypt( | ||
bin = sodium::hex2bin(string), | ||
key = charToRaw(key), | ||
nonce = .shinyslack_nonce | ||
)) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.