diff --git a/DESCRIPTION b/DESCRIPTION index c86bff43..eddfc6cf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,10 +30,10 @@ Depends: R (>= 3.5) Imports: ggplot2 (>= 3.4.0), - mirai (>= 0.12.0), - nanonext (>= 0.12.0), + mirai (>= 1.0.0), + nanonext (>= 1.0.0), RcppSimdJson (>= 0.1.9), - secretbase, + secretbase (>= 0.3.0), shiny (>= 1.4.0), xts, zoo diff --git a/NAMESPACE b/NAMESPACE index 1cd71785..1198b8d4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -80,8 +80,7 @@ importFrom(ggplot2,theme) importFrom(ggplot2,theme_grey) importFrom(mirai,mirai) importFrom(nanonext,ncurl) -importFrom(nanonext,strcat) -importFrom(secretbase,sha3) +importFrom(secretbase,sha256) importFrom(shiny,HTML) importFrom(shiny,checkboxInput) importFrom(shiny,column) diff --git a/NEWS.md b/NEWS.md index fe580556..34c43f87 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # ichimoku 1.5.1.9000 (development) +* `archive()` moves to SHA256 again (using the updated implementation in {secretbase}). + # ichimoku 1.5.1 * Fixes `oanda_studio()` so that the live chart no longer greys out when updating (with recent Shiny versions). diff --git a/R/archive.R b/R/archive.R index 18de462b..2c1b3646 100644 --- a/R/archive.R +++ b/R/archive.R @@ -45,11 +45,11 @@ #' #' @section Data Verification: #' -#' A SHA3-256 hash of the original object is written to the archive. This +#' A SHA256 hash of the original object is written to the archive. This #' allows the data integrity of the restored object to be verified when the #' archive is read back. #' -#' For write operations: confirmation of the SHA3-256 hash written to file +#' For write operations: confirmation of the SHA256 hash written to file #' is displayed. #' #' For read operations: a 'data verified' message is issued if the SHA256 @@ -130,7 +130,7 @@ archive <- function(..., object, file) { #' Write Objects to Archive #' -#' Internal function used to write objects, along with their SHA3-256 hash value, +#' Internal function used to write objects, along with their SHA-256 hash value, #' to archive files in the native RData format. #' #' @param object an object. @@ -154,9 +154,9 @@ writeArchive <- function(object, file) { } } - x_archive_secure_hash <- sha3(object) + x_archive_secure_hash <- sha256(object) save(object, x_archive_secure_hash, file = file, compress = TRUE) - message(sprintf("Archive written to '%s'\nSHA3-256: %s", file, x_archive_secure_hash)) + message(sprintf("Archive written to '%s'\nSHA256: %s", file, x_archive_secure_hash)) invisible(file) } @@ -164,7 +164,7 @@ writeArchive <- function(object, file) { #' Read Objects from Archive #' #' Internal function used to read objects from native RData files with stored -#' SHA3-256 hash values. +#' SHA256 hash values. #' #' @param file the name of the file or a connection where the object is saved to #' or read from. @@ -184,10 +184,10 @@ readArchive <- function(file) { stop("archive file was not created by archive()", call. = FALSE) message("Archive read from '", file, "'") - sha256 <- sha3(object) + sha256 <- sha256(object) if (identical(sha256, x_archive_secure_hash)) - message("Data verified by SHA3-256: ", sha256) else - warning(sprintf("SHA3-256 of restored object: %s\ndoes not match the original: %s", sha256, x_archive_secure_hash), call. = FALSE) + message("Data verified by SHA256: ", sha256) else + warning(sprintf("SHA256 of restored object: %s\ndoes not match the original: %s", sha256, x_archive_secure_hash), call. = FALSE) object diff --git a/R/data.R b/R/data.R index 4bbd16a2..ed26d017 100644 --- a/R/data.R +++ b/R/data.R @@ -38,7 +38,7 @@ .__global__ <- ".data" -.user_agent <- strcat("r-ichimoku/", as.character(packageVersion("ichimoku"))) +.user_agent <- sprintf("r-ichimoku/%s", as.character(packageVersion("ichimoku"))) .mlgrid_pairs <- { cols <- c("chikou", "close", "high", "low", "tenkan", "kijun", "senkouA", "senkouB", "cloudT", "cloudB") diff --git a/R/ichimoku-package.R b/R/ichimoku-package.R index f62c265d..7762f9b6 100644 --- a/R/ichimoku-package.R +++ b/R/ichimoku-package.R @@ -83,8 +83,8 @@ #' scale_x_continuous scale_y_continuous Stat StatIdentity theme theme_grey #' %+replace% #' @importFrom mirai mirai -#' @importFrom nanonext ncurl strcat -#' @importFrom secretbase sha3 +#' @importFrom nanonext ncurl +#' @importFrom secretbase sha256 #' @importFrom RcppSimdJson is_valid_json #' @importFrom shiny checkboxInput column downloadButton downloadHandler HTML #' fillPage fluidPage fluidRow hoverOpts invalidateLater isolate diff --git a/R/oanda.R b/R/oanda.R index 2acf1acf..dc85cc73 100644 --- a/R/oanda.R +++ b/R/oanda.R @@ -189,14 +189,14 @@ getPrices <- function(instrument, granularity, count = NULL, from = NULL, url <- sprintf( "https://api-fx%s.oanda.com/v3/instruments/%s/candles?granularity=%s&price=%s%s%s%s", switch(server, practice = "practice", live = "trade"), instrument, granularity, price, - if (length(count)) strcat("&count=", as.character(count)) else "", - if (length(from)) strcat("&from=", as.character(from)) else "", - if (length(to)) strcat("&to=", as.character(to)) else "" + if (length(count)) sprintf("&count=%s", as.character(count)) else "", + if (length(from)) sprintf("&from=%s", as.character(from)) else "", + if (length(to)) sprintf("&to=%s", as.character(to)) else "" ) resp <- ncurl(url, convert = FALSE, follow = TRUE, - headers = c(Authorization = strcat("Bearer ", apikey), + headers = c(Authorization = sprintf("Bearer %s", apikey), `Accept-Datetime-Format` = "UNIX", `User-Agent` = .user_agent), response = "date") @@ -326,7 +326,7 @@ oanda_stream <- function(instrument, display = 8L, limit, server, apikey) { url <- paste0("https://stream-fx", switch(server, practice = "practice", live = "trade"), ".oanda.com/v3/accounts/", do_$getAccount(server = server, apikey = apikey), "/pricing/stream?instruments=", instrument) - headers <- c(Authorization = strcat("Bearer ", apikey), + headers <- c(Authorization = sprintf("Bearer %s", apikey), `Accept-Datetime-Format` = "UNIX", `User-Agent` = .user_agent) @@ -1013,7 +1013,7 @@ oanda_positions <- function(instrument, time, server, apikey) { switch(server, practice = "practice", live = "trade"), instrument, if (missing(time)) "" else sprintf("?time=%.f", unclass(as.POSIXct(time)))) resp <- ncurl(url, convert = FALSE, follow = TRUE, - headers = c(Authorization = strcat("Bearer ", apikey), + headers = c(Authorization = sprintf("Bearer %s", apikey), `Accept-Datetime-Format` = "UNIX", `User-Agent` = .user_agent)) resp[["status"]] == 200L || stop("status code ", resp[["status"]], " - ", @@ -1105,7 +1105,7 @@ oanda_orders <- function(instrument, time, server, apikey) { switch(server, practice = "practice", live = "trade"), instrument, if (missing(time)) "" else sprintf("?time=%.f", unclass(as.POSIXct(time)))) resp <- ncurl(url, convert = FALSE, follow = TRUE, - headers = c(Authorization = strcat("Bearer ", apikey), + headers = c(Authorization = sprintf("Bearer %s", apikey), `Accept-Datetime-Format` = "UNIX", `User-Agent` = .user_agent)) resp[["status"]] == 200L || stop("status code ", resp[["status"]], " - ", diff --git a/R/switch.R b/R/switch.R index a83d0f98..cdcdd1a7 100644 --- a/R/switch.R +++ b/R/switch.R @@ -121,7 +121,7 @@ do_ <- function() { practice = "https://api-fxpractice.oanda.com/v3/accounts", live = "https://api-fxtrade.oanda.com/v3/accounts") resp <- ncurl(url, convert = FALSE, follow = TRUE, - headers = c("Authorization" = strcat("Bearer ", apikey), + headers = c("Authorization" = sprintf("Bearer %s", apikey), "User-Agent" = .user_agent)) resp[["status"]] == 200L || stop("status code ", resp[["status"]], " - ", deserialize_json(resp[["data"]]), call. = FALSE) @@ -140,7 +140,7 @@ do_ <- function() { do_$getAccount(server = server, apikey = apikey)) for (i in seq_len(2L)) { resp <- ncurl(url, convert = FALSE, follow = TRUE, - headers = c("Authorization" = strcat("Bearer ", apikey), + headers = c("Authorization" = sprintf("Bearer %s", apikey), "User-Agent" = .user_agent)) resp[["status"]] == 200L && break } diff --git a/man/archive.Rd b/man/archive.Rd index 183ee3b5..a5c2fe1e 100644 --- a/man/archive.Rd +++ b/man/archive.Rd @@ -40,11 +40,11 @@ For read operations: specify only 'file', or alternatively if no \section{Data Verification}{ - A SHA3-256 hash of the original object is written to the archive. This + A SHA256 hash of the original object is written to the archive. This allows the data integrity of the restored object to be verified when the archive is read back. - For write operations: confirmation of the SHA3-256 hash written to file + For write operations: confirmation of the SHA256 hash written to file is displayed. For read operations: a 'data verified' message is issued if the SHA256 diff --git a/vignettes/reference.Rmd b/vignettes/reference.Rmd index 09d2dc02..ae924ef3 100644 --- a/vignettes/reference.Rmd +++ b/vignettes/reference.Rmd @@ -349,11 +349,11 @@ object <- archive() #### Data Integrity Verification -Data integrity verification is performed by the SHA3-256 cryptographic hash algorithm from the 'secretbase' package. +Data integrity verification is performed by the SHA256 cryptographic hash algorithm from the 'secretbase' package. -When an archive is written, the serialised object is hashed and the hash is also stored in the archive. The SHA3-256 hash value is printed to the console as confirmation. +When an archive is written, the serialised object is hashed and the hash is also stored in the archive. The SHA256 hash value is printed to the console as confirmation. -When an archive is read back, the SHA3-256 hash of the restored object is checked against the hash of the original stored in the archive. If identical, a 'data verified' message is printed to the console along with the authenticated SHA3-256 hash. +When an archive is read back, the SHA256 hash of the restored object is checked against the hash of the original stored in the archive. If identical, a 'data verified' message is printed to the console along with the authenticated SHA256 hash. ## Supplementary Information