From bfb4c46697b944fc0726f91e0c134be6c063b54a Mon Sep 17 00:00:00 2001 From: Christian Panse Date: Tue, 4 Apr 2023 16:16:20 +0200 Subject: [PATCH] Import PKI in Namespace - adapt to current R version (4.2) - roxygen2::roxygenize() --- DESCRIPTION | 13 ++++++------- NAMESPACE | 6 +++++- R/encrypt.R | 3 ++- R/init-store.R | 3 ++- R/update-store.R | 6 ++++-- man/initStore.Rd | 32 +++++++++++++------------------- man/ssErr.Rd | 11 +++++------ man/updateStore.Rd | 30 ++++++++++++++---------------- 8 files changed, 51 insertions(+), 53 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4596b07..fc2cc01 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,19 +1,18 @@ Package: shinyStore Type: Package Title: Web Storage API for Shiny -Version: 0.1.0 -Date: 2014-08-05 +Version: 0.1.1 Author: Trestle Technology, LLC. Maintainer: Jeff Allen Description: A Web Storage API for Shiny allowing Shiny applications to store persistent data on the client browser. License: MIT Depends: - R (>= 2.15.1) + R (>= 4.2) Imports: - shiny (>= 0.9.0), + PKI (>= 0.1.11), + shiny (>= 1.7), RJSONIO (>= 1.0-0) -Suggests: - PKI (>= 0.1-1) BugReports: https://github.com/trestletech/shinyStore/issues -Roxygen: list(wrap = TRUE) +RoxygenNote: 7.2.1 +Encoding: UTF-8 diff --git a/NAMESPACE b/NAMESPACE index b93ad8d..23486f8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,9 @@ -# Generated by roxygen2 (4.0.1): do not edit by hand +# Generated by roxygen2: do not edit by hand export(initStore) export(ssErr) export(updateStore) +import(shiny) +importFrom(PKI,PKI.decrypt) +importFrom(PKI,PKI.encrypt) +importFrom(RJSONIO,toJSON) diff --git a/R/encrypt.R b/R/encrypt.R index 5a53a33..6c084d9 100644 --- a/R/encrypt.R +++ b/R/encrypt.R @@ -1,4 +1,5 @@ +#' @importFrom PKI PKI.decrypt .onLoad <- function(libname, pkgname){ shiny::registerInputHandler("shinyStore", function(val, shinysession, name){ key <- .global$privKey @@ -21,7 +22,7 @@ arr <- split(arr, ceiling(seq_along(arr)/2)) byt <- unlist(lapply(arr, function(x){ paste(x, collapse="") })) ra <- as.raw(strtoi(byt, base="16")) - msg <- rawToChar(PKI.decrypt(ra, key)) + msg <- rawToChar(PKI::PKI.decrypt(ra, key)) }) obj <- RJSONIO::fromJSON(msg) diff --git a/R/init-store.R b/R/init-store.R index 8bb6d2e..3986ff2 100644 --- a/R/init-store.R +++ b/R/init-store.R @@ -12,6 +12,7 @@ #' @param privateKey the private key to use to decrypt data. Must be provided #' if you're going to have any encrypted fields. #' @export +#' @import shiny initStore <- function(id, namespace, privateKey=NULL){ if (missing(id) || missing(namespace)){ stop("Must provide both an ID and a namespace when initializing a store") @@ -32,4 +33,4 @@ initStore <- function(id, namespace, privateKey=NULL){ HTML(paste0("")), div(class="shiny-store", id=id) ) -} \ No newline at end of file +} diff --git a/R/update-store.R b/R/update-store.R index 3d20ea4..003e040 100644 --- a/R/update-store.R +++ b/R/update-store.R @@ -14,6 +14,8 @@ #' it will expect a PKI public key in the form generated by \code{\link{PKI.load.key}} #' which will then be used to encrypt the fields. #' @export +#' @importFrom PKI PKI.encrypt +#' @importFrom RJSONIO toJSON updateStore <- function(session, name, value, encrypt=NULL){ if (missing(name) || missing(value) || missing(session)){ stop("Must provide a name, a value, and a session") @@ -38,11 +40,11 @@ updateStore <- function(session, name, value, encrypt=NULL){ warning("Text to encrypt is longer than 215 bytes, may fail.") } - enc <- PKI.encrypt(charToRaw(json), key) + enc <- PKI::PKI.encrypt(charToRaw(json), key) char <- paste0(as.character(enc), collapse="") li[[name]] <- list(encV="1.0", data=char) } session$sendCustomMessage("shinyStore", li) -} \ No newline at end of file +} diff --git a/man/initStore.Rd b/man/initStore.Rd index 714b0d4..9414590 100644 --- a/man/initStore.Rd +++ b/man/initStore.Rd @@ -1,4 +1,5 @@ -% Generated by roxygen2 (4.0.1): do not edit by hand +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/init-store.R \name{initStore} \alias{initStore} \title{Initialize shinyStore in an application's UI} @@ -6,26 +7,19 @@ initStore(id, namespace, privateKey = NULL) } \arguments{ - \item{id}{The identifier of the store (determines the - name of the store on the \code{input} reactive object in - your \code{server.R} file).} +\item{id}{The identifier of the store (determines the name of the store on the +\code{input} reactive object in your \code{server.R} file).} - \item{namespace}{Not a \code{namespace} in the - traditional R sense, but rather the identifying prefix to - use when storing any object in the browser's local - storage. This is the only means by which we can separate - data stored for different applications that are being - hosted at the same (sub-)domain.} +\item{namespace}{Not a \code{namespace} in the traditional R sense, but rather +the identifying prefix to use when storing any object in the browser's local +storage. This is the only means by which we can separate data stored for +different applications that are being hosted at the same (sub-)domain.} - \item{privateKey}{the private key to use to decrypt data. - Must be provided if you're going to have any encrypted - fields.} +\item{privateKey}{the private key to use to decrypt data. Must be provided +if you're going to have any encrypted fields.} } \description{ -Though shinyStore doesn't have any user-visible elements, -you still must initialize it in your application's -\code{ui.R} file. You should execute this function in your -ui.R file to setup the input element associated with your -store. +Though shinyStore doesn't have any user-visible elements, you still must +initialize it in your application's \code{ui.R} file. You should execute this +function in your ui.R file to setup the input element associated with your store. } - diff --git a/man/ssErr.Rd b/man/ssErr.Rd index 4bc4f48..bbbec65 100644 --- a/man/ssErr.Rd +++ b/man/ssErr.Rd @@ -1,4 +1,5 @@ -% Generated by roxygen2 (4.0.1): do not edit by hand +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ss-err.R \name{ssErr} \alias{ssErr} \title{Get shinyStore error code} @@ -6,11 +7,9 @@ ssErr(obj) } \arguments{ - \item{obj}{The object to inspect for an error.} +\item{obj}{The object to inspect for an error.} } \description{ -Given a shinyStore object, gets the error code off of it. -Will return 0 if no error, or a positive integer if there -is an error. +Given a shinyStore object, gets the error code off of it. Will return 0 if +no error, or a positive integer if there is an error. } - diff --git a/man/updateStore.Rd b/man/updateStore.Rd index 954bcfc..4a1bba4 100644 --- a/man/updateStore.Rd +++ b/man/updateStore.Rd @@ -1,4 +1,5 @@ -% Generated by roxygen2 (4.0.1): do not edit by hand +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/update-store.R \name{updateStore} \alias{updateStore} \title{Update local storage} @@ -6,24 +7,21 @@ updateStore(session, name, value, encrypt = NULL) } \arguments{ - \item{session}{The session paramter from the - \code{\link{shinyServer}} function.} +\item{session}{The session paramter from the \code{\link{shinyServer}} +function.} - \item{name}{The name for this setting. This is the name - you'll reference later when you want to retrieve this - value from your storage object.} +\item{name}{The name for this setting. This is the name you'll reference +later when you want to retrieve this value from your storage object.} - \item{value}{The value for this setting. Can be a string, - in which case it will be passed through unbothered, or a - more complex object which will be translated to JSON.} +\item{value}{The value for this setting. Can be a string, in which case it +will be passed through unbothered, or a more complex object which will be +translated to JSON.} - \item{encrypt}{If NULL (the default), the field will not - be encrypted. Otherwise, it will expect a PKI public key - in the form generated by \code{\link{PKI.load.key}} which - will then be used to encrypt the fields.} +\item{encrypt}{If NULL (the default), the field will not be encrypted. Otherwise, +it will expect a PKI public key in the form generated by \code{\link{PKI.load.key}} +which will then be used to encrypt the fields.} } \description{ -Send the name of the field to update and the value which -should be stored in this user's local storage. +Send the name of the field to update and the value which should be stored +in this user's local storage. } -