blind-peer-muxer 1.2.0 → 1.3.0

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.
Files changed (2) hide show
  1. package/index.js +14 -2
  2. package/package.json +8 -2
package/index.js CHANGED
@@ -1,18 +1,26 @@
1
1
  const { getEncoding } = require('./spec/hyperschema')
2
+ const { BlindPeerRequest: NotificationRequest } = require('blind-push/encodings')
2
3
  const Protomux = require('protomux')
3
4
 
4
5
  const Cores = getEncoding('@blind-peer/cores')
5
6
 
6
7
  module.exports = class BlindPeerChannel {
7
- constructor(stream, { oncores = noop, onopen = noop, onclose = noop } = {}) {
8
+ constructor(
9
+ stream,
10
+ { oncores = noop, onnotification = noop, onopen = noop, onclose = noop } = {}
11
+ ) {
8
12
  this.muxer = Protomux.from(stream)
9
13
  this.channel = this.muxer.createChannel({
10
14
  protocol: 'blind-peer',
11
- messages: [{ encoding: Cores, onmessage: oncores }],
15
+ messages: [
16
+ { encoding: Cores, onmessage: oncores },
17
+ { encoding: NotificationRequest, onmessage: onnotification }
18
+ ],
12
19
  onopen,
13
20
  onclose
14
21
  })
15
22
  this.wireCores = this.channel.messages[0]
23
+ this.wireNotification = this.channel.messages[1]
16
24
  this.channel.open()
17
25
  }
18
26
 
@@ -28,6 +36,10 @@ module.exports = class BlindPeerChannel {
28
36
  return this.wireCores.send(data)
29
37
  }
30
38
 
39
+ sendNotification(data) {
40
+ return this.wireNotification.send(data)
41
+ }
42
+
31
43
  uncork() {
32
44
  this.muxer.uncork()
33
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blind-peer-muxer",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Protomux channel muxer for blind peers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -13,7 +13,9 @@
13
13
  ],
14
14
  "scripts": {
15
15
  "format": "prettier --write .",
16
- "lint": "lunte && prettier --check ."
16
+ "lint": "lunte && prettier --check .",
17
+ "test": "npm run lint && brittle test/test.js",
18
+ "test:bare": "brittle-bare test/test.js"
17
19
  },
18
20
  "author": "Holepunch",
19
21
  "license": "Apache-2.0",
@@ -22,11 +24,15 @@
22
24
  },
23
25
  "homepage": "https://github.com/holepunchto/blind-peer-muxer",
24
26
  "devDependencies": {
27
+ "@hyperswarm/secret-stream": "^6.9.1",
28
+ "b4a": "^1.8.0",
29
+ "brittle": "^3.19.1",
25
30
  "lunte": "^1.4.0",
26
31
  "prettier": "^3.8.1",
27
32
  "prettier-config-holepunch": "^2.0.0"
28
33
  },
29
34
  "dependencies": {
35
+ "blind-push": "^0.2.3",
30
36
  "compact-encoding": "^3.0.0",
31
37
  "hyperschema": "^1.19.0",
32
38
  "protomux": "^3.10.1"