hoodie-plugin-store-crypto
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -25,2 +25,3 @@ 'use strict' | ||
}, | ||
remote: options && options.remote, | ||
noPasswordCheckAutoFix: options != null && Boolean(options.noPasswordCheckAutoFix) | ||
@@ -27,0 +28,0 @@ } |
@@ -8,2 +8,3 @@ 'use strict' | ||
var createPasswordCheck = require('./utils/create-password-check') | ||
var pull = require('./utils/pull') | ||
var createResetKeys = require('./helpers/create-reset-keys') | ||
@@ -47,8 +48,31 @@ | ||
return store.pull(['hoodiePluginCryptoStore/salt']) | ||
if ('pull' in store) { | ||
return store.pull(['hoodiePluginCryptoStore/salt']) | ||
.catch(function (error) { | ||
console.warn("Couldn't pull docs from remote. Creating new salt!\nError: " + error) | ||
return [] | ||
}) | ||
.catch(function (error) { | ||
console.warn("Couldn't pull docs from remote. Creating new salt!\nError: " + error) | ||
return [] | ||
}) | ||
} | ||
if ('db' in store && state.remote != null) { | ||
return pull(['hoodiePluginCryptoStore/salt'], store.db, state.remote) | ||
.catch(function (err) { | ||
if (err.status === pouchdbErrors.UNAUTHORIZED.status) { | ||
console.warn('Could not check the existence of a salt document on a remote db.') | ||
return [] | ||
} | ||
if (err.status === 404) { | ||
return [err] | ||
} | ||
throw err | ||
}) | ||
} | ||
console.warn( | ||
'Could not check the existence of a salt document on a remote db.\n' + | ||
'Please use the "remote" option when using "pouchdb-hoodie-api".' | ||
) | ||
return [] | ||
}) | ||
@@ -55,0 +79,0 @@ |
@@ -10,2 +10,3 @@ 'use strict' | ||
var createPasswordCheck = require('./utils/create-password-check') | ||
var pull = require('./utils/pull') | ||
var decrypt = require('./helpers/decrypt-core') | ||
@@ -39,5 +40,32 @@ | ||
// get updated salt docs from remote | ||
return store.pull(['hoodiePluginCryptoStore/salt']) | ||
return Promise.resolve() | ||
// get updated salt docs from remote | ||
.then(function () { | ||
if ('pull' in store) { | ||
return store.pull(['hoodiePluginCryptoStore/salt']) | ||
} | ||
if ('db' in store && state.remote != null) { | ||
return pull(['hoodiePluginCryptoStore/salt'], store.db, state.remote) | ||
.catch(function (err) { | ||
if (err.status === pouchdbErrors.UNAUTHORIZED.status) { | ||
console.warn('Could not check the existence of a salt document on a remote db.') | ||
return [] | ||
} | ||
if (err.status === 404) { | ||
return [err] | ||
} | ||
throw err | ||
}) | ||
} | ||
console.warn( | ||
'Could not check the existence of a salt document on a remote db.\n' + | ||
'Please use the "remote" option when using "pouchdb-hoodie-api".' | ||
) | ||
return [] | ||
}) | ||
.then( | ||
@@ -44,0 +72,0 @@ function () { |
{ | ||
"name": "hoodie-plugin-store-crypto", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "End-to-end crypto plugin for the Hoodie client store.", | ||
@@ -55,2 +55,3 @@ "main": "index.js", | ||
"pouchdb-core": "^7.2.2", | ||
"pouchdb-hoodie-api": "^2.0.0", | ||
"pouchdb-replication": "^7.2.2", | ||
@@ -60,3 +61,3 @@ "puppeteer": "^5.2.1", | ||
"semantic-release": "^17.1.1", | ||
"snyk": "^1.381.1", | ||
"snyk": "^1.385.2", | ||
"standard": "^14.3.4", | ||
@@ -66,3 +67,3 @@ "tap-spec": "^5.0.0", | ||
"textlint": "^11.7.6", | ||
"textlint-rule-alex": "^2.1.0", | ||
"textlint-rule-alex": "^3.0.0", | ||
"textlint-rule-common-misspellings": "^1.0.1", | ||
@@ -81,3 +82,3 @@ "textlint-rule-rousseau": "^1.4.6", | ||
"randombytes": "^2.1.0", | ||
"uuid": "^3.4.0" | ||
"uuid": "^8.3.0" | ||
}, | ||
@@ -84,0 +85,0 @@ "release": { |
@@ -23,2 +23,5 @@ | index | [API] | [about cryptography] | [update] | [Contributing] | [Code of Conduct] | | ||
The [PouchDB](https://pouchdb.com/) plugin [pouchdb-hoodie-api](http://hoodiehq.github.io/pouchdb-hoodie-api/) | ||
is also supported! | ||
There is no server side to this plugin! | ||
@@ -67,3 +70,4 @@ | ||
- [with the Hoodie Plugin API](#usage-with-the-hoodie-plugin-api) | ||
- [with Browserify or Webpack](#usage-with-browserify-or-webpack) | ||
- [with a Bundler](#usage-with-a-bundler) | ||
- [with PouchDB and pouchdb-hoodie-api](#usage-with-pouchdb-and-pouchdb-hoodie-api) | ||
- [Get started](#get-started) | ||
@@ -127,3 +131,3 @@ - [Sign up / setup / start of using encryption](#setup) | ||
#### Usage with Browserify or Webpack | ||
#### Usage with a Bundler | ||
@@ -142,7 +146,7 @@ If you are using a client bundler (e.g. [Browserify](http://browserify.org/) | ||
```javascript | ||
var Hoodie = require('@hoodie/client') | ||
var PouchDB = require('pouchdb') | ||
var cryptoStore = require('hoodie-plugin-store-crypto') | ||
import Hoodie from '@hoodie/client' | ||
import PouchDB from 'pouchdb' | ||
import CryptoStore from 'hoodie-plugin-store-crypto' | ||
var hoodie = new Hoodie({ // create an instance of the hoodie-client | ||
const hoodie = new Hoodie({ // create an instance of the hoodie-client | ||
url: window.location.origin, | ||
@@ -152,4 +156,4 @@ PouchDB: PouchDB | ||
// sets up hoodie.cryptoStore | ||
var cryptoStore = new CryptoStore(hoodie.store, { /* some options */}) | ||
// sets up cryptoStore | ||
const cryptoStore = new CryptoStore(hoodie.store, { /* some options */}) | ||
@@ -169,2 +173,43 @@ cryptoStore.setup('test') | ||
#### Usage with PouchDB and pouchdb-hoodie-api | ||
To use this plugin with [PouchDB](https://pouchdb.com/) you must install the plugin | ||
[pouchdb-hoodie-api](http://hoodiehq.github.io/pouchdb-hoodie-api/). | ||
```js | ||
npm install --save-dev pouchdb-hoodie-api | ||
``` | ||
Setup is like the [usage with Bundler](#usage-with-a-bundler), but you must pass the | ||
the `db.hoodieApi()` from __pouchdb-hoodie-api__. And optionally a remote PouchDB database (or its URL) | ||
for checking and fetching the existence of the encryption setup. | ||
```javascript | ||
import PouchDB from 'pouchdb-browser' | ||
import hoodieApiPlugin from 'pouchdb-hoodie-api' | ||
import CryptoStore from 'hoodie-plugin-store-crypto' | ||
PouchDB.plugin(hoodieApiPlugin) | ||
const db = new PouchDB('local_db') | ||
const remoteDb = new PouchDB('https://example.com/my_db', { | ||
auth: { | ||
username: 'user', | ||
password: 'geheim' | ||
} | ||
}) | ||
// sets up cryptoStore | ||
const cryptoStore = new CryptoStore(db.hoodieApi(), { | ||
remote: remoteDb | ||
}) | ||
cryptoStore.setup('test') | ||
.then(() => { | ||
console.log('done') | ||
}) | ||
``` | ||
[Back to top](#table-of-contents) | ||
### Get started | ||
@@ -171,0 +216,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101202
49
2162
411
19
+ Addedcipher-base@1.0.5(transitive)
+ Addeduuid@8.3.2(transitive)
- Removedcipher-base@1.0.6(transitive)
Updateduuid@^8.3.0