From: jordan Date: Wed, 2 Aug 2017 20:24:50 +0000 (-0700) Subject: Merge branch 'master' of github.com:Jlavatai/strapp X-Git-Url: https://git.kengrimes.com/?p=henge%2Fkiak.git;a=commitdiff_plain;h=a7e6c36b91dd1a36021f7459200436b3cb31d756;hp=81f466c54cf9a0a2428000d041651087a94aeb87 Merge branch 'master' of github.com:Jlavatai/strapp --- diff --git a/bootstrap.js b/bootstrap.js index ba48382..0757908 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -6,7 +6,7 @@ * @copyright Strapp.io */ -import fs from "fileManager" +import fs from "strappfileManager" /** @func Returns public key for the user * @desc Attempts to find a stored key. If unsucessful, ask user for key. If user diff --git a/strappCrypto.js b/strappCrypto.js index cc6fd75..e34db01 100644 --- a/strappCrypto.js +++ b/strappCrypto.js @@ -8,6 +8,7 @@ * @copyright Strapp.io */ +/* TODO: Replace with filesystem operations */ import {setItem, getItem} from "localForage" /** @func Generates a CryptoKey and returns a SHA-256 client key @@ -38,20 +39,22 @@ function generateKey() { }) } -/** @func Encrypts data with a public key - * @desc +/** @func Encrypts data with a public key assuming RSA + * @desc https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt * @arg {String} Public Key - * @return {Object} The encrypted data + * @return {Object} The encrypted data as a promise */ function encryptData(publicKey, data) { - + return crypto.subtle.encrypt({"name": "RSA-OAEP"}) } /** @func Decrypts data with a private key - * @desc + * @desc https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/decrypt * @arg {String} Private key to decrypt data - * @return {Object} The decrypted data + * @return {Object} The decrypted data as a promise */ -function decryptData(privateKey, data) { +function decryptData(privateKey, cipherText) { + /* TODO: Pass in private key or get it from localForage? */ + return crypto.subtle.decrypt({"name":"RSA-OAEP"}, privateKey, cipherText) } -function +