Skip to content

Commit

Permalink
fix(storage-service): use a standard interface to set and get data
Browse files Browse the repository at this point in the history
In order to avoid naming confusion this project gonna use the same interface of the global JavaScript object Map.

BREAKING CHANGE: load -> get, save -> set, delete -> deleteDB
  • Loading branch information
willgm committed Jul 20, 2020
1 parent 55d58f8 commit dfd54bc
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 92 deletions.
6 changes: 3 additions & 3 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Buttons = {
// Here the user password is used as base crypto key
// and the user name is used as database name to fully scope the data:
cryptoStorage = new CryptoStorage(pass, user);
cryptoStorage.load('mynotes').then(notes => {
cryptoStorage.get('mynotes').then(notes => {
if (notes) {
value('text', notes);
updateStatus('Notes loaded for ' + user);
Expand All @@ -51,7 +51,7 @@ const Buttons = {
},

load() {
cryptoStorage.load('mynotes').then(notes => {
cryptoStorage.get('mynotes').then(notes => {
if (notes) {
value('text', notes);
updateStatus('Notes loaded.');
Expand All @@ -63,7 +63,7 @@ const Buttons = {

save() {
const notes = value('text');
cryptoStorage.save('mynotes', notes).then(() => {
cryptoStorage.set('mynotes', notes).then(() => {
updateStatus('Notes saved.');
});
},
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/js/search.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"kinds":{"128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method","4194304":"Type alias"},"rows":[{"id":0,"kind":256,"name":"CryptoStorageConfig","url":"interfaces/cryptostorageconfig.html","classes":"tsd-kind-interface"},{"id":1,"kind":1024,"name":"baseKey","url":"interfaces/cryptostorageconfig.html#basekey","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"CryptoStorageConfig"},{"id":2,"kind":1024,"name":"dbName","url":"interfaces/cryptostorageconfig.html#dbname","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"CryptoStorageConfig"},{"id":3,"kind":1024,"name":"storeName","url":"interfaces/cryptostorageconfig.html#storename","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"CryptoStorageConfig"},{"id":4,"kind":1024,"name":"salt","url":"interfaces/cryptostorageconfig.html#salt","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"CryptoStorageConfig"},{"id":5,"kind":1024,"name":"encryptIterations","url":"interfaces/cryptostorageconfig.html#encryptiterations","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"CryptoStorageConfig"},{"id":6,"kind":128,"name":"CryptoStorage","url":"classes/cryptostorage.html","classes":"tsd-kind-class"},{"id":7,"kind":1024,"name":"AuthenticityError","url":"classes/cryptostorage.html#authenticityerror","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-static","parent":"CryptoStorage"},{"id":8,"kind":1024,"name":"CryptoKeyError","url":"classes/cryptostorage.html#cryptokeyerror","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-static","parent":"CryptoStorage"},{"id":9,"kind":512,"name":"constructor","url":"classes/cryptostorage.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"CryptoStorage"},{"id":10,"kind":2048,"name":"load","url":"classes/cryptostorage.html#load","classes":"tsd-kind-method tsd-parent-kind-class","parent":"CryptoStorage"},{"id":11,"kind":2048,"name":"save","url":"classes/cryptostorage.html#save","classes":"tsd-kind-method tsd-parent-kind-class","parent":"CryptoStorage"},{"id":12,"kind":2048,"name":"clear","url":"classes/cryptostorage.html#clear","classes":"tsd-kind-method tsd-parent-kind-class","parent":"CryptoStorage"},{"id":13,"kind":2048,"name":"close","url":"classes/cryptostorage.html#close","classes":"tsd-kind-method tsd-parent-kind-class","parent":"CryptoStorage"},{"id":14,"kind":2048,"name":"delete","url":"classes/cryptostorage.html#delete","classes":"tsd-kind-method tsd-parent-kind-class","parent":"CryptoStorage"},{"id":15,"kind":4194304,"name":"InputData","url":"globals.html#inputdata","classes":"tsd-kind-type-alias"}],"index":{"version":"2.3.8","fields":["name","parent"],"fieldVectors":[["name/0",[0,9.614]],["parent/0",[]],["name/1",[1,24.277]],["parent/1",[0,0.878]],["name/2",[2,24.277]],["parent/2",[0,0.878]],["name/3",[3,24.277]],["parent/3",[0,0.878]],["name/4",[4,24.277]],["parent/4",[0,0.878]],["name/5",[5,24.277]],["parent/5",[0,0.878]],["name/6",[6,5.819]],["parent/6",[]],["name/7",[7,24.277]],["parent/7",[6,0.532]],["name/8",[8,24.277]],["parent/8",[6,0.532]],["name/9",[9,24.277]],["parent/9",[6,0.532]],["name/10",[10,24.277]],["parent/10",[6,0.532]],["name/11",[11,24.277]],["parent/11",[6,0.532]],["name/12",[12,24.277]],["parent/12",[6,0.532]],["name/13",[13,24.277]],["parent/13",[6,0.532]],["name/14",[14,24.277]],["parent/14",[6,0.532]],["name/15",[15,24.277]],["parent/15",[]]],"invertedIndex":[["authenticityerror",{"_index":7,"name":{"7":{}},"parent":{}}],["basekey",{"_index":1,"name":{"1":{}},"parent":{}}],["clear",{"_index":12,"name":{"12":{}},"parent":{}}],["close",{"_index":13,"name":{"13":{}},"parent":{}}],["constructor",{"_index":9,"name":{"9":{}},"parent":{}}],["cryptokeyerror",{"_index":8,"name":{"8":{}},"parent":{}}],["cryptostorage",{"_index":6,"name":{"6":{}},"parent":{"7":{},"8":{},"9":{},"10":{},"11":{},"12":{},"13":{},"14":{}}}],["cryptostorageconfig",{"_index":0,"name":{"0":{}},"parent":{"1":{},"2":{},"3":{},"4":{},"5":{}}}],["dbname",{"_index":2,"name":{"2":{}},"parent":{}}],["delete",{"_index":14,"name":{"14":{}},"parent":{}}],["encryptiterations",{"_index":5,"name":{"5":{}},"parent":{}}],["inputdata",{"_index":15,"name":{"15":{}},"parent":{}}],["load",{"_index":10,"name":{"10":{}},"parent":{}}],["salt",{"_index":4,"name":{"4":{}},"parent":{}}],["save",{"_index":11,"name":{"11":{}},"parent":{}}],["storename",{"_index":3,"name":{"3":{}},"parent":{}}]],"pipeline":[]}}
{"kinds":{"128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method","4194304":"Type alias"},"rows":[{"id":0,"kind":256,"name":"CryptoStorageConfig","url":"interfaces/cryptostorageconfig.html","classes":"tsd-kind-interface"},{"id":1,"kind":1024,"name":"baseKey","url":"interfaces/cryptostorageconfig.html#basekey","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"CryptoStorageConfig"},{"id":2,"kind":1024,"name":"dbName","url":"interfaces/cryptostorageconfig.html#dbname","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"CryptoStorageConfig"},{"id":3,"kind":1024,"name":"storeName","url":"interfaces/cryptostorageconfig.html#storename","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"CryptoStorageConfig"},{"id":4,"kind":1024,"name":"salt","url":"interfaces/cryptostorageconfig.html#salt","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"CryptoStorageConfig"},{"id":5,"kind":1024,"name":"encryptIterations","url":"interfaces/cryptostorageconfig.html#encryptiterations","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"CryptoStorageConfig"},{"id":6,"kind":128,"name":"CryptoStorage","url":"classes/cryptostorage.html","classes":"tsd-kind-class"},{"id":7,"kind":1024,"name":"AuthenticityError","url":"classes/cryptostorage.html#authenticityerror","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-static","parent":"CryptoStorage"},{"id":8,"kind":1024,"name":"CryptoKeyError","url":"classes/cryptostorage.html#cryptokeyerror","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-static","parent":"CryptoStorage"},{"id":9,"kind":512,"name":"constructor","url":"classes/cryptostorage.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"CryptoStorage"},{"id":10,"kind":2048,"name":"get","url":"classes/cryptostorage.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"CryptoStorage"},{"id":11,"kind":2048,"name":"set","url":"classes/cryptostorage.html#set","classes":"tsd-kind-method tsd-parent-kind-class","parent":"CryptoStorage"},{"id":12,"kind":2048,"name":"clear","url":"classes/cryptostorage.html#clear","classes":"tsd-kind-method tsd-parent-kind-class","parent":"CryptoStorage"},{"id":13,"kind":2048,"name":"close","url":"classes/cryptostorage.html#close","classes":"tsd-kind-method tsd-parent-kind-class","parent":"CryptoStorage"},{"id":14,"kind":2048,"name":"deleteDB","url":"classes/cryptostorage.html#deletedb","classes":"tsd-kind-method tsd-parent-kind-class","parent":"CryptoStorage"},{"id":15,"kind":4194304,"name":"InputData","url":"globals.html#inputdata","classes":"tsd-kind-type-alias"}],"index":{"version":"2.3.8","fields":["name","parent"],"fieldVectors":[["name/0",[0,9.614]],["parent/0",[]],["name/1",[1,24.277]],["parent/1",[0,0.878]],["name/2",[2,24.277]],["parent/2",[0,0.878]],["name/3",[3,24.277]],["parent/3",[0,0.878]],["name/4",[4,24.277]],["parent/4",[0,0.878]],["name/5",[5,24.277]],["parent/5",[0,0.878]],["name/6",[6,5.819]],["parent/6",[]],["name/7",[7,24.277]],["parent/7",[6,0.532]],["name/8",[8,24.277]],["parent/8",[6,0.532]],["name/9",[9,24.277]],["parent/9",[6,0.532]],["name/10",[10,24.277]],["parent/10",[6,0.532]],["name/11",[11,24.277]],["parent/11",[6,0.532]],["name/12",[12,24.277]],["parent/12",[6,0.532]],["name/13",[13,24.277]],["parent/13",[6,0.532]],["name/14",[14,24.277]],["parent/14",[6,0.532]],["name/15",[15,24.277]],["parent/15",[]]],"invertedIndex":[["authenticityerror",{"_index":7,"name":{"7":{}},"parent":{}}],["basekey",{"_index":1,"name":{"1":{}},"parent":{}}],["clear",{"_index":12,"name":{"12":{}},"parent":{}}],["close",{"_index":13,"name":{"13":{}},"parent":{}}],["constructor",{"_index":9,"name":{"9":{}},"parent":{}}],["cryptokeyerror",{"_index":8,"name":{"8":{}},"parent":{}}],["cryptostorage",{"_index":6,"name":{"6":{}},"parent":{"7":{},"8":{},"9":{},"10":{},"11":{},"12":{},"13":{},"14":{}}}],["cryptostorageconfig",{"_index":0,"name":{"0":{}},"parent":{"1":{},"2":{},"3":{},"4":{},"5":{}}}],["dbname",{"_index":2,"name":{"2":{}},"parent":{}}],["deletedb",{"_index":14,"name":{"14":{}},"parent":{}}],["encryptiterations",{"_index":5,"name":{"5":{}},"parent":{}}],["get",{"_index":10,"name":{"10":{}},"parent":{}}],["inputdata",{"_index":15,"name":{"15":{}},"parent":{}}],["salt",{"_index":4,"name":{"4":{}},"parent":{}}],["set",{"_index":11,"name":{"11":{}},"parent":{}}],["storename",{"_index":3,"name":{"3":{}},"parent":{}}]],"pipeline":[]}}
Loading

0 comments on commit dfd54bc

Please sign in to comment.