Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import PKI in Namespace #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
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
6 changes: 5 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 2 additions & 1 deletion R/encrypt.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#' @importFrom PKI PKI.decrypt
.onLoad <- function(libname, pkgname){
shiny::registerInputHandler("shinyStore", function(val, shinysession, name){
key <- .global$privKey
Expand All @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion R/init-store.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -32,4 +33,4 @@ initStore <- function(id, namespace, privateKey=NULL){
HTML(paste0("<script type=\"text/javascript\">shinyStore.init('",namespace,"')</script>")),
div(class="shiny-store", id=id)
)
}
}
6 changes: 4 additions & 2 deletions R/update-store.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}
}
32 changes: 13 additions & 19 deletions man/initStore.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions man/ssErr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 14 additions & 16 deletions man/updateStore.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.