-
-
Notifications
You must be signed in to change notification settings - Fork 585
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
Move Olm account to IndexedDB #579
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fb99150
Move OLM account to IndexedDBd
dbkr 313cfac
Add comment
dbkr 7ecf313
Use a callback function at the store layer
dbkr a5c5da5
Lint
dbkr bae3f5c
It's a heap, not a stack
dbkr 59f228d
Migrate account from session store
dbkr a90f592
Add comment on deprecation
dbkr 4b7157b
Remove unnecessary 'if'
dbkr 9218e51
Add LocalStorageCryptoStore
dbkr 44b35cd
Lint
dbkr 6024163
s/accountData/pickledAccount/
dbkr 57d425f
Make the save function not return a promise
dbkr c4e70be
Better comment wording
dbkr defaa91
Remove unused function
dbkr 6ebfd17
jsdoc clarifications
dbkr 7e2c236
Missed a s/account data/picked account/
dbkr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
Copyright 2017 New Vector Ltd | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import Promise from 'bluebird'; | ||
import MemoryCryptoStore from './memory-crypto-store.js'; | ||
|
||
/** | ||
* Internal module. Partial localStorage backed storage for e2e. | ||
* This is not a full crypto store, just the in-memory store with | ||
* some things backed by localStorage. It exists because indexedDB | ||
* is broken in Firefox private mode or set to, "will not remember | ||
* history". | ||
* | ||
* @module | ||
*/ | ||
|
||
const E2E_PREFIX = "crypto."; | ||
const KEY_END_TO_END_ACCOUNT = E2E_PREFIX + "account"; | ||
|
||
/** | ||
* @implements {module:crypto/store/base~CryptoStore} | ||
*/ | ||
export default class LocalStorageCryptoStore extends MemoryCryptoStore { | ||
constructor() { | ||
super(); | ||
this.store = global.localStorage; | ||
} | ||
|
||
/** | ||
* Delete all data from this store. | ||
* | ||
* @returns {Promise} Promise which resolves when the store has been cleared. | ||
*/ | ||
deleteAllData() { | ||
this.store.removeItem(KEY_END_TO_END_ACCOUNT); | ||
return Promise.resolve(); | ||
} | ||
|
||
endToEndAccountTransaction(func) { | ||
const account = this.store.getItem(KEY_END_TO_END_ACCOUNT); | ||
return Promise.resolve(func(account, (newData) => { | ||
this.store.setItem(KEY_END_TO_END_ACCOUNT, newData); | ||
})); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pickled account