starpc 0.36.0 → 0.36.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2022 Aperture Robotics, LLC.
1
+ Copyright (c) 2022-2025 Aperture Robotics, LLC.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
package/go.mod CHANGED
@@ -14,20 +14,20 @@ replace (
14
14
 
15
15
  require (
16
16
  github.com/aperturerobotics/protobuf-go-lite v0.8.0 // latest
17
- github.com/aperturerobotics/util v1.26.3 // latest
17
+ github.com/aperturerobotics/util v1.27.1 // latest
18
18
  )
19
19
 
20
20
  require (
21
21
  github.com/coder/websocket v1.8.12 // latest
22
- github.com/libp2p/go-libp2p v0.37.2 // latest
22
+ github.com/libp2p/go-libp2p v0.38.1 // latest
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.35.2 // latest
26
+ google.golang.org/protobuf v1.36.1 // latest
27
27
  )
28
28
 
29
29
  require (
30
- github.com/aperturerobotics/json-iterator-lite v1.0.0 // indirect
30
+ github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20240713111131-be6bf89c3008 // indirect
31
31
  github.com/ipfs/go-cid v0.4.1 // indirect
32
32
  github.com/klauspost/cpuid/v2 v2.2.8 // indirect
33
33
  github.com/libp2p/go-buffer-pool v0.1.0 // indirect
@@ -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.29.0 // indirect
45
- golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
46
- golang.org/x/sys v0.27.0 // indirect
44
+ golang.org/x/crypto v0.31.0 // indirect
45
+ golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect
46
+ golang.org/x/sys v0.28.0 // indirect
47
47
  lukechampine.com/blake3 v1.3.0 // indirect
48
48
  )
package/go.sum CHANGED
@@ -1,11 +1,11 @@
1
1
  github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0 h1:tGwbeDoEeQCrUQL+ClUywldqvz9eRmhcVrGwGxz2xJg=
2
2
  github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0/go.mod h1:FJkAtQcP9XxqG1NNLNHKm+wLVIGSCQX2s6CEoD+w97g=
3
- github.com/aperturerobotics/json-iterator-lite v1.0.0 h1:cihbrYWoK/S2RYXhJLpDZd+GUjVvFJN+D3w1VOqqHRI=
4
- github.com/aperturerobotics/json-iterator-lite v1.0.0/go.mod h1:snaApCEDtrHHP6UWSLKiYNOZU9A5NyzccKenx9oZEzg=
3
+ github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20240713111131-be6bf89c3008 h1:So9JeziaWKx2Fw8sK4AUN/szqKtJ0jEMhS6bU4sHbxs=
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.26.3 h1:Z7pjEJX27FDUQyP8OHlBcyEc8MGl8z/ZS1vpRBsIU9E=
8
- github.com/aperturerobotics/util v1.26.3/go.mod h1:D/N1pG02cPukZtwGggCeb8R/wq11Iy76xjSEGFYa06c=
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.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
57
- golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
58
- golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
59
- golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
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
+ golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo=
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.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
63
- golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
64
- google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
65
- google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
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.0",
3
+ "version": "0.36.2",
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,pre-commit,utf-8-validate,rimraf,starpc,@aptre/protobuf-es-lite,tsx'",
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": "go mod vendor && rimraf ./tools/bin",
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.8.0",
87
- "@typescript-eslint/parser": "^8.8.0",
83
+ "@typescript-eslint/eslint-plugin": "^8.24.1",
84
+ "@typescript-eslint/parser": "^8.24.1",
88
85
  "depcheck": "^1.4.6",
89
- "esbuild": "^0.24.0",
90
- "eslint": "^9.11.1",
91
- "eslint-config-prettier": "^9.1.0",
92
- "lint-staged": "^15.2.2",
93
- "pre-commit": "^1.2.2",
94
- "prettier": "^3.2.4",
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.6.2",
98
- "vitest": "^2.1.2"
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.1.2",
105
- "@libp2p/logger": "^5.1.0",
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",
@@ -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 Mux
18
- srpc *Server
19
- path string
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: mux,
27
- srpc: NewServer(mux),
28
- path: 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, &websocket.AcceptOptions{})
39
+ c, err := websocket.Accept(w, r, s.acceptOpts)
38
40
  if err != nil {
39
- w.WriteHeader(500)
40
- _, _ = w.Write([]byte(err.Error() + "\n"))
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")