autopass 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example.mjs +27 -0
- package/index.js +3 -2
- package/package.json +2 -1
package/example.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Autopass from './index.js'
|
|
2
|
+
import Corestore from 'corestore'
|
|
3
|
+
|
|
4
|
+
const store = new Corestore('example/' + process.argv[2])
|
|
5
|
+
|
|
6
|
+
let pass = null
|
|
7
|
+
|
|
8
|
+
if (process.argv[3]) {
|
|
9
|
+
const pair = Autopass.pair(store, process.argv[3])
|
|
10
|
+
pass = await pair.finished()
|
|
11
|
+
} else {
|
|
12
|
+
pass = new Autopass(store)
|
|
13
|
+
await pass.ready()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (pass.base.writable) {
|
|
17
|
+
const inv = await pass.createInvite()
|
|
18
|
+
console.log('invite', inv)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
onupdate()
|
|
22
|
+
pass.on('update', onupdate)
|
|
23
|
+
|
|
24
|
+
function onupdate () {
|
|
25
|
+
console.log('db changed, all entries:')
|
|
26
|
+
pass.list().on('data', console.log)
|
|
27
|
+
}
|
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const z32 = require('z32')
|
|
|
9
9
|
const b4a = require('b4a')
|
|
10
10
|
|
|
11
11
|
class AutopassPairer extends ReadyResource {
|
|
12
|
-
constructor (store, invite, opts) {
|
|
12
|
+
constructor (store, invite, opts = {}) {
|
|
13
13
|
super()
|
|
14
14
|
|
|
15
15
|
this.store = store
|
|
@@ -33,8 +33,9 @@ class AutopassPairer extends ReadyResource {
|
|
|
33
33
|
bootstrap: this.bootstrap
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
+
const store = this.store // we null this when passing it on, so avoid a nullptr
|
|
36
37
|
this.swarm.on('connection', (connection, peerInfo) => {
|
|
37
|
-
|
|
38
|
+
store.replicate(connection)
|
|
38
39
|
})
|
|
39
40
|
|
|
40
41
|
this.pairing = new BlindPairing(this.swarm)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autopass",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "standard && brittle test.js"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"brittle": "^3.7.0",
|
|
13
13
|
"corestore": "^6.18.4",
|
|
14
14
|
"hyperdht": "^6.20.1",
|
|
15
|
+
"standard": "^17.1.2",
|
|
15
16
|
"test-tmp": "^1.3.0"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|