Open klues opened 5 years ago
I use it the following way in my extension:
import CryptoPouch from 'crypto-pouch'
PouchDB.plugin(CryptoPouch);
and then
db.crypto(password)
The link is dead, where else can we get the browserified version?
At this time, we don't distribute browserified versions of crypto-pouch. That may change soon, though! In the meantime, you're best off creating your own, like this:
$ curl https://unpkg.com/crypto-pouch@4.0.0/index.js > crypto-pouch-original.js
$ npx browserify crypto-pouch-original.js -o crypto-pouch.js
Now you can include crypto-pouch.js
in your projects with a <script>
tag:
<script src="crypto-pouch.js" charset="utf-8"></script>
Let me know if that works for you :)
I'll leave this issue open until we distribute a browserified version ourselves.
Hey,
I'm struggeling to get crypto-pouch working in the browser. I tried the steps above and they didn't work.
First I had to do a npm add crypto-pouch before doing the browserfy (makes sense it needs it's dependencies there).
But even after that it fails in the browser with: "Invalid plugin: got "[object Object]", expected an object or a function"
It basically seems to fail when the plugin is being added to pouch:
if (typeof window !== 'undefined' && window.PouchDB) { window.PouchDB.plugin(exports) }
Hopefully someone can advice on how to get this running!
Best, Olav
it fails in the browser with: "Invalid plugin: got "[object Object]", expected an object or a function"
same here.
any advice on how to workaround this ?
Hey folks. I'm unable to reproduce this issue based on the info provided. If you can provide more info about your setup, I can try reproducing this again. Until then, this works on my end:
const CryptoPouch = require('crypto-pouch')
const PouchDB = require('pouchdb')
PouchDB.plugin(CryptoPouch)
const db = new PouchDB("test")
db.crypto("hello world")
.then(() => console.log("encrypted!"))
.then(() => db.post({hello: "world"}))
.then(({ id }) => console.log(id))
This prints:
encrypted!
f261a66f-df0d-49c5-9a8c-e071a59bc0c7
When reporting issues, please supply:
For my part, I tried with PouchDB v7.2.2 and v8.0.1.
I tried to "browserify" crypto-pouch and garbados-crypt, then import in an a html plas using a <script>
tag.
And get the error.
I tried to "browserify" crypto-pouch and garbados-crypt, then import in an a html plas using a
<script>
tag. And get the error.
You shouldn't need to browserify these things directly. Browserify the entry point of your program -- where you require these things, where your app starts. That will automatically bring in dependencies. Otherwise, IIRC, Browserify wraps these dependencies so they aren't available in a global context, as your setup requires.
The provided link in the readme: the browserified version from wzrd.in is dead.
So how could I get crypto-pouch running in a browser? Is there any other place to get a compiled js-file that can be used in browsers?