starpc 0.36.1 → 0.36.3
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/LICENSE +1 -1
- package/dist/srpc/common-rpc.js +6 -1
- package/go.mod +4 -4
- package/go.sum +8 -8
- package/integration/integration.go +4 -1
- package/package.json +15 -18
- package/srpc/common-rpc.go +1 -1
- package/srpc/common-rpc.ts +5 -1
- package/srpc/server-http.go +13 -10
package/LICENSE
CHANGED
package/dist/srpc/common-rpc.js
CHANGED
|
@@ -148,7 +148,12 @@ export class CommonRPC {
|
|
|
148
148
|
}
|
|
149
149
|
this.closed = err ?? true;
|
|
150
150
|
// note: this does nothing if _source is already ended.
|
|
151
|
-
|
|
151
|
+
if (err && err.message) {
|
|
152
|
+
await this.writeCallData(undefined, true, err.message);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
await this.writeCallCancel();
|
|
156
|
+
}
|
|
152
157
|
this._source.end();
|
|
153
158
|
this._rpcDataSource.end(err);
|
|
154
159
|
}
|
package/go.mod
CHANGED
|
@@ -14,7 +14,7 @@ replace (
|
|
|
14
14
|
|
|
15
15
|
require (
|
|
16
16
|
github.com/aperturerobotics/protobuf-go-lite v0.8.0 // latest
|
|
17
|
-
github.com/aperturerobotics/util v1.27.
|
|
17
|
+
github.com/aperturerobotics/util v1.27.1 // latest
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
require (
|
|
@@ -23,7 +23,7 @@ require (
|
|
|
23
23
|
github.com/libp2p/go-yamux/v4 v4.0.2-0.20240826150533-e92055b23e0e // master
|
|
24
24
|
github.com/pkg/errors v0.9.1 // latest
|
|
25
25
|
github.com/sirupsen/logrus v1.9.3 // latest
|
|
26
|
-
google.golang.org/protobuf v1.36.
|
|
26
|
+
google.golang.org/protobuf v1.36.1 // latest
|
|
27
27
|
)
|
|
28
28
|
|
|
29
29
|
require (
|
|
@@ -41,8 +41,8 @@ require (
|
|
|
41
41
|
github.com/multiformats/go-multistream v0.5.0 // indirect
|
|
42
42
|
github.com/multiformats/go-varint v0.0.7 // indirect
|
|
43
43
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
|
44
|
-
golang.org/x/crypto v0.
|
|
44
|
+
golang.org/x/crypto v0.31.0 // indirect
|
|
45
45
|
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect
|
|
46
|
-
golang.org/x/sys v0.
|
|
46
|
+
golang.org/x/sys v0.28.0 // indirect
|
|
47
47
|
lukechampine.com/blake3 v1.3.0 // indirect
|
|
48
48
|
)
|
package/go.sum
CHANGED
|
@@ -4,8 +4,8 @@ github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20240713111131-be6bf89c3
|
|
|
4
4
|
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20240713111131-be6bf89c3008/go.mod h1:snaApCEDtrHHP6UWSLKiYNOZU9A5NyzccKenx9oZEzg=
|
|
5
5
|
github.com/aperturerobotics/protobuf-go-lite v0.8.0 h1:SoiTAVArmOrNTX31e6CC5Bem6HuOElg3YYNhp4AAPQc=
|
|
6
6
|
github.com/aperturerobotics/protobuf-go-lite v0.8.0/go.mod h1:y49wVEezRHg78uQ2OzLLZbtTTWuox+ChmaTuh6FLJW8=
|
|
7
|
-
github.com/aperturerobotics/util v1.27.
|
|
8
|
-
github.com/aperturerobotics/util v1.27.
|
|
7
|
+
github.com/aperturerobotics/util v1.27.1 h1:htCjY/HvP8DusRxWiCFEbm8lMz7HzJSovdhSzVcrtuI=
|
|
8
|
+
github.com/aperturerobotics/util v1.27.1/go.mod h1:hurmxv5jC2CqkfhgySRYrXDcvqPk6BHUhHizu6yyXhE=
|
|
9
9
|
github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo=
|
|
10
10
|
github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
|
|
11
11
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
@@ -53,16 +53,16 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|
|
53
53
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
54
54
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
|
55
55
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
|
56
|
-
golang.org/x/crypto v0.
|
|
57
|
-
golang.org/x/crypto v0.
|
|
56
|
+
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
|
57
|
+
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
|
58
58
|
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo=
|
|
59
59
|
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c=
|
|
60
60
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
61
61
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
62
|
-
golang.org/x/sys v0.
|
|
63
|
-
golang.org/x/sys v0.
|
|
64
|
-
google.golang.org/protobuf v1.36.
|
|
65
|
-
google.golang.org/protobuf v1.36.
|
|
62
|
+
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
|
63
|
+
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
64
|
+
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
|
|
65
|
+
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
|
66
66
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
67
67
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
68
68
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
@@ -7,6 +7,7 @@ import (
|
|
|
7
7
|
|
|
8
8
|
"github.com/aperturerobotics/starpc/echo"
|
|
9
9
|
"github.com/aperturerobotics/starpc/srpc"
|
|
10
|
+
"github.com/coder/websocket"
|
|
10
11
|
"github.com/sirupsen/logrus"
|
|
11
12
|
)
|
|
12
13
|
|
|
@@ -18,7 +19,9 @@ func main() {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
// listen at: ws://localhost:4352/demo
|
|
21
|
-
server, err := srpc.NewHTTPServer(mux, "/demo"
|
|
22
|
+
server, err := srpc.NewHTTPServer(mux, "/demo", &websocket.AcceptOptions{
|
|
23
|
+
InsecureSkipVerify: true,
|
|
24
|
+
})
|
|
22
25
|
if err != nil {
|
|
23
26
|
logrus.Fatal(err.Error())
|
|
24
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starpc",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.3",
|
|
4
4
|
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"build": "npm run clean && tsc --project tsconfig.build.json --outDir ./dist/",
|
|
47
47
|
"check": "npm run typecheck",
|
|
48
48
|
"typecheck": "tsc --noEmit",
|
|
49
|
-
"deps": "depcheck --ignores 'bufferutil,
|
|
49
|
+
"deps": "depcheck --ignores 'bufferutil,utf-8-validate,rimraf,starpc,@aptre/protobuf-es-lite,tsx'",
|
|
50
50
|
"codegen": "npm run gen",
|
|
51
51
|
"ci": "npm run build && npm run lint:js && npm run lint:go",
|
|
52
52
|
"format": "npm run format:go && npm run format:js && npm run format:config",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"lint": "npm run lint:go && npm run lint:js",
|
|
66
66
|
"lint:go": "make lint",
|
|
67
67
|
"lint:js": "ESLINT_USE_FLAT_CONFIG=false eslint -c .eslintrc.cjs --ignore-pattern *.js --ignore-pattern *.d.ts ./",
|
|
68
|
-
"prepare": "
|
|
68
|
+
"prepare": "husky",
|
|
69
69
|
"precommit": "lint-staged",
|
|
70
70
|
"release": "npm run release:version && npm run release:commit",
|
|
71
71
|
"release:minor": "npm run release:version:minor && npm run release:commit",
|
|
@@ -75,34 +75,31 @@
|
|
|
75
75
|
"release:publish": "git push && git push --tags && npm run build && npm publish"
|
|
76
76
|
},
|
|
77
77
|
"preferUnplugged": true,
|
|
78
|
-
"pre-commit": [
|
|
79
|
-
"precommit"
|
|
80
|
-
],
|
|
81
78
|
"lint-staged": {
|
|
82
79
|
"package.json": "prettier --config .prettierrc.yaml --write",
|
|
83
80
|
"./{srpc,echo,e2e,integration,rpcstream,cmd}/**/(*.ts|*.tsx|*.html|*.css)": "prettier --config .prettierrc.yaml --write"
|
|
84
81
|
},
|
|
85
82
|
"devDependencies": {
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
87
|
-
"@typescript-eslint/parser": "^8.
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^8.24.1",
|
|
84
|
+
"@typescript-eslint/parser": "^8.24.1",
|
|
88
85
|
"depcheck": "^1.4.6",
|
|
89
|
-
"esbuild": "^0.
|
|
90
|
-
"eslint": "^9.
|
|
91
|
-
"eslint-config-prettier": "^
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"prettier": "^3.
|
|
86
|
+
"esbuild": "^0.25.0",
|
|
87
|
+
"eslint": "^9.20.1",
|
|
88
|
+
"eslint-config-prettier": "^10.0.1",
|
|
89
|
+
"husky": "^9.1.7",
|
|
90
|
+
"lint-staged": "^15.4.3",
|
|
91
|
+
"prettier": "^3.5.1",
|
|
95
92
|
"rimraf": "^6.0.1",
|
|
96
93
|
"tsx": "^4.19.1",
|
|
97
|
-
"typescript": "^5.
|
|
98
|
-
"vitest": "^
|
|
94
|
+
"typescript": "^5.7.3",
|
|
95
|
+
"vitest": "^3.0.5"
|
|
99
96
|
},
|
|
100
97
|
"dependencies": {
|
|
101
98
|
"@aptre/it-ws": "^1.0.1",
|
|
102
99
|
"@aptre/protobuf-es-lite": "^0.4.6",
|
|
103
100
|
"@chainsafe/libp2p-yamux": "^7.0.1",
|
|
104
|
-
"@libp2p/interface": "^2.
|
|
105
|
-
"@libp2p/logger": "^5.1.
|
|
101
|
+
"@libp2p/interface": "^2.5.0",
|
|
102
|
+
"@libp2p/logger": "^5.1.8",
|
|
106
103
|
"event-iterator": "^2.0.0",
|
|
107
104
|
"isomorphic-ws": "^5.0.0",
|
|
108
105
|
"it-first": "^3.0.6",
|
package/srpc/common-rpc.go
CHANGED
|
@@ -116,7 +116,7 @@ func (c *commonRPC) ReadOne() ([]byte, error) {
|
|
|
116
116
|
|
|
117
117
|
// WriteCallData writes a call data packet.
|
|
118
118
|
func (c *commonRPC) WriteCallData(data []byte, complete bool, err error) error {
|
|
119
|
-
outPkt := NewCallDataPacket(data, len(data) == 0,
|
|
119
|
+
outPkt := NewCallDataPacket(data, len(data) == 0, complete, err)
|
|
120
120
|
return c.writer.WritePacket(outPkt)
|
|
121
121
|
}
|
|
122
122
|
|
package/srpc/common-rpc.ts
CHANGED
|
@@ -176,7 +176,11 @@ export class CommonRPC {
|
|
|
176
176
|
}
|
|
177
177
|
this.closed = err ?? true
|
|
178
178
|
// note: this does nothing if _source is already ended.
|
|
179
|
-
|
|
179
|
+
if (err && err.message) {
|
|
180
|
+
await this.writeCallData(undefined, true, err.message)
|
|
181
|
+
} else {
|
|
182
|
+
await this.writeCallCancel()
|
|
183
|
+
}
|
|
180
184
|
this._source.end()
|
|
181
185
|
this._rpcDataSource.end(err)
|
|
182
186
|
}
|
package/srpc/server-http.go
CHANGED
|
@@ -14,18 +14,20 @@ import (
|
|
|
14
14
|
//
|
|
15
15
|
// NOTE: accepting websocket connections is stubbed out on GOOS=js!
|
|
16
16
|
type HTTPServer struct {
|
|
17
|
-
mux
|
|
18
|
-
srpc
|
|
19
|
-
path
|
|
17
|
+
mux Mux
|
|
18
|
+
srpc *Server
|
|
19
|
+
path string
|
|
20
|
+
acceptOpts *websocket.AcceptOptions
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
// NewHTTPServer builds a http server / handler.
|
|
23
24
|
// if path is empty, serves on all routes.
|
|
24
|
-
func NewHTTPServer(mux Mux, path string) (*HTTPServer, error) {
|
|
25
|
+
func NewHTTPServer(mux Mux, path string, acceptOpts *websocket.AcceptOptions) (*HTTPServer, error) {
|
|
25
26
|
return &HTTPServer{
|
|
26
|
-
mux:
|
|
27
|
-
srpc:
|
|
28
|
-
path:
|
|
27
|
+
mux: mux,
|
|
28
|
+
srpc: NewServer(mux),
|
|
29
|
+
path: path,
|
|
30
|
+
acceptOpts: acceptOpts,
|
|
29
31
|
}, nil
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -34,10 +36,11 @@ func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
34
36
|
return
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
c, err := websocket.Accept(w, r,
|
|
39
|
+
c, err := websocket.Accept(w, r, s.acceptOpts)
|
|
38
40
|
if err != nil {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
// NOTE: the error is already written with http.Error
|
|
42
|
+
// w.WriteHeader(500)
|
|
43
|
+
// _, _ = w.Write([]byte(err.Error() + "\n"))
|
|
41
44
|
return
|
|
42
45
|
}
|
|
43
46
|
defer c.Close(websocket.StatusInternalError, "closed")
|