-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
45 lines (35 loc) · 1.21 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict'
module.exports = CryptoStore
var bindFunctions = require('./lib/bind-functions')
function CryptoStore (store, options) {
if (!(this instanceof CryptoStore)) return new CryptoStore(store, options)
var withIdPrefixStore = {} // store prefix APIs from hoodie-store. Workaround for #42
var state = {
getWithPrefixAPI: function (prefix) { // get a prefix API. This is a workaround for #42
if (prefix == null) {
return store
}
if (prefix in withIdPrefixStore) {
return withIdPrefixStore[prefix]
}
withIdPrefixStore[prefix] = store.withIdPrefix(prefix)
return withIdPrefixStore[prefix]
},
remote: options && options.remote,
noPasswordCheckAutoFix: options != null && Boolean(options.noPasswordCheckAutoFix)
}
if (state.noPasswordCheckAutoFix) {
console.warn(
'Salt doc without a password check is deprecated!\n\n' +
'Read more at https://github.com/Terreii/hoodie-plugin-store-crypto/' +
'blob/latest/docs/update.md#v3-update-notes'
)
}
var handler = {
on: store.on,
once: store.one,
removeListener: store.off
}
const api = bindFunctions(store, state, null, handler, true)
Object.assign(this, api)
}