starpc 0.46.2 → 0.47.1

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.
@@ -48,7 +48,7 @@ export async function runAbortControllerTest(client) {
48
48
  const errMsg = err.message;
49
49
  errorReturned = true;
50
50
  if (errMsg !== ERR_RPC_ABORT) {
51
- throw new Error('unexpected error: ' + errMsg);
51
+ throw new Error('unexpected error: ' + errMsg, { cause: err });
52
52
  }
53
53
  }
54
54
  if (!errorReturned) {
@@ -69,7 +69,9 @@ export async function runAbortControllerTest(client) {
69
69
  }
70
70
  catch (err) {
71
71
  if (msgs.length < 3) {
72
- throw new Error('expected at least three messages before error');
72
+ throw new Error('expected at least three messages before error', {
73
+ cause: err,
74
+ });
73
75
  }
74
76
  throw err;
75
77
  }
@@ -58,7 +58,7 @@ export async function runAbortControllerTest(client: Client) {
58
58
  const errMsg = (err as Error).message
59
59
  errorReturned = true
60
60
  if (errMsg !== ERR_RPC_ABORT) {
61
- throw new Error('unexpected error: ' + errMsg)
61
+ throw new Error('unexpected error: ' + errMsg, { cause: err })
62
62
  }
63
63
  }
64
64
  if (!errorReturned) {
@@ -80,7 +80,9 @@ export async function runAbortControllerTest(client: Client) {
80
80
  }
81
81
  } catch (err) {
82
82
  if (msgs.length < 3) {
83
- throw new Error('expected at least three messages before error')
83
+ throw new Error('expected at least three messages before error', {
84
+ cause: err,
85
+ })
84
86
  }
85
87
  throw err
86
88
  }
package/echo/server.go CHANGED
@@ -37,7 +37,7 @@ func (*EchoServer) EchoServerStream(msg *EchoMsg, strm SRPCEchoer_EchoServerStre
37
37
  responses := 5
38
38
  tkr := time.NewTicker(time.Millisecond * 200)
39
39
  defer tkr.Stop()
40
- for i := 0; i < responses; i++ {
40
+ for range responses {
41
41
  if err := strm.MsgSend(msg); err != nil {
42
42
  return err
43
43
  }
package/go.mod CHANGED
@@ -2,23 +2,22 @@ module github.com/aperturerobotics/starpc
2
2
 
3
3
  go 1.25
4
4
 
5
- replace (
6
- // This fork uses go-protobuf-lite and adds post-quantum crypto support.
7
- github.com/libp2p/go-libp2p => github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0 // aperture
8
-
9
- // This fork uses go-protobuf-lite.
10
- github.com/libp2p/go-msgio => github.com/aperturerobotics/go-libp2p-msgio v0.0.0-20240511033615-1b69178aa5c8 // aperture
5
+ require (
6
+ github.com/aperturerobotics/common v0.30.7 // latest
7
+ github.com/aperturerobotics/protobuf-go-lite v0.12.2 // latest
8
+ github.com/aperturerobotics/util v1.32.4 // latest
11
9
  )
12
10
 
13
11
  require (
14
- github.com/aperturerobotics/common v0.30.1-0.20260203095300-e0754eb22a37 // latest
15
- github.com/aperturerobotics/protobuf-go-lite v0.12.1 // latest
16
- github.com/aperturerobotics/util v1.32.3 // latest
12
+ github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017 // aperture-2
13
+ github.com/aperturerobotics/cli v1.1.0 // indirect
14
+ github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260131050911-b5f94b044584 // indirect
15
+ github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726 // indirect
16
+ github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 // wasi
17
17
  )
18
18
 
19
19
  require (
20
20
  github.com/coder/websocket v1.8.14 // latest
21
- github.com/libp2p/go-libp2p v0.47.0 // latest
22
21
  github.com/libp2p/go-yamux/v4 v4.0.2 // latest
23
22
  github.com/pkg/errors v0.9.1 // latest
24
23
  github.com/sirupsen/logrus v1.9.4 // latest
@@ -26,33 +25,10 @@ require (
26
25
  )
27
26
 
28
27
  require (
29
- github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017 // aperture-2
30
- github.com/aperturerobotics/cli v1.1.0 // indirect
31
- github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260131050911-b5f94b044584 // indirect
32
- github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726 // indirect
33
- github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 // wasi
34
- )
35
-
36
- require (
37
- github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260203094828-3faf47d2c868 // indirect
38
- github.com/ipfs/go-cid v0.4.1 // indirect
39
- github.com/klauspost/cpuid/v2 v2.2.8 // indirect
28
+ github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260204215916-dc1f0fed8cfc // indirect
40
29
  github.com/libp2p/go-buffer-pool v0.1.0 // indirect
41
- github.com/minio/sha256-simd v1.0.1 // indirect
42
- github.com/mr-tron/base58 v1.2.0 // indirect
43
- github.com/multiformats/go-base32 v0.1.0 // indirect
44
- github.com/multiformats/go-base36 v0.2.0 // indirect
45
- github.com/multiformats/go-multiaddr v0.13.0 // indirect
46
- github.com/multiformats/go-multibase v0.2.0 // indirect
47
- github.com/multiformats/go-multihash v0.2.3 // indirect
48
- github.com/multiformats/go-multistream v0.5.0 // indirect
49
- github.com/multiformats/go-varint v0.0.7 // indirect
50
- github.com/spaolacci/murmur3 v1.1.0 // indirect
51
30
  github.com/tetratelabs/wazero v1.11.0 // indirect
52
31
  github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
53
- golang.org/x/crypto v0.45.0 // indirect
54
- golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
55
- golang.org/x/mod v0.32.0 // indirect
32
+ golang.org/x/mod v0.33.0 // indirect
56
33
  golang.org/x/sys v0.40.0 // indirect
57
- lukechampine.com/blake3 v1.3.0 // indirect
58
34
  )
package/go.sum CHANGED
@@ -2,82 +2,47 @@ github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017 h1:3U7
2
2
  github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017/go.mod h1:lNSJTKECIUFAnfeSqy01kXYTYe1BHubW7198jNX3nEw=
3
3
  github.com/aperturerobotics/cli v1.1.0 h1:7a+YRC+EY3npAnTzhHV5gLCiw91KS0Ts3XwLILGOsT8=
4
4
  github.com/aperturerobotics/cli v1.1.0/go.mod h1:M7BFP9wow5ytTzMyJQOOO991fGfsUqdTI7gGEsHfTQ8=
5
- github.com/aperturerobotics/common v0.30.1-0.20260203095300-e0754eb22a37 h1:ia/PiOkGovJUA2Evo3Qjn6mARVbpeACO5ENs5EKH3aQ=
6
- github.com/aperturerobotics/common v0.30.1-0.20260203095300-e0754eb22a37/go.mod h1:o3LkfVkdyNtWz31nGkCKuMP7H2dxarmYCYgXmy1zjtg=
7
- github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0 h1:tGwbeDoEeQCrUQL+ClUywldqvz9eRmhcVrGwGxz2xJg=
8
- github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0/go.mod h1:FJkAtQcP9XxqG1NNLNHKm+wLVIGSCQX2s6CEoD+w97g=
9
- github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260203094828-3faf47d2c868 h1:r2j7F1tGHkchPBLL55e44g/DfYqK2JV0Ed8suMAxmlU=
10
- github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260203094828-3faf47d2c868/go.mod h1:OBb/beWmr/pDIZAUfi86j/4tBh2v5ctTxKMqSnh9c/4=
5
+ github.com/aperturerobotics/common v0.30.7 h1:MfbgBHwRnCFPCWVXjKiqEBkFGpMf8Nk2pRsUiSuzxSc=
6
+ github.com/aperturerobotics/common v0.30.7/go.mod h1:rdhYmixjslfBT0lEMADQHWjgRKIDxZ+8Paxv4lGZfp0=
7
+ github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260204215916-dc1f0fed8cfc h1:MQKYvrnue6iT6DlQdGbaBYvyY/WuR63cbhUtRZjx4OM=
8
+ github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260204215916-dc1f0fed8cfc/go.mod h1:OBb/beWmr/pDIZAUfi86j/4tBh2v5ctTxKMqSnh9c/4=
11
9
  github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260131050911-b5f94b044584 h1:ER8DYYL71cTg39uZ+Gi699tL/hZoscUWDOw4DbizqhI=
12
10
  github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260131050911-b5f94b044584/go.mod h1:vEq8i7EKb32+KXGtIEZjjhNns+BdsL2dUMw4uhy3578=
13
11
  github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726 h1:4B1F0DzuqPzb6WqgCjWaqDD7JU9RDsevQG5OP0DFBgs=
14
12
  github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726/go.mod h1:SvGGBv3OVxUyqO0ZxA/nvs6z3cg7NIbZ64TnbV2OISo=
15
13
  github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 h1:4Dy3BAHh2kgVdHAqtlwcFsgY0kAwUe2m3rfFcaGwGQg=
16
14
  github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4/go.mod h1:tMgO7y6SJo/d9ZcvrpNqIQtdYT9de+QmYaHOZ4KnhOg=
17
- github.com/aperturerobotics/protobuf-go-lite v0.12.1 h1:o9of87F/LFS2p5xfq32CrU99dvfqIAalTP7ZzoZK6Kg=
18
- github.com/aperturerobotics/protobuf-go-lite v0.12.1/go.mod h1:lGH3s5ArCTXKI4wJdlNpaybUtwSjfAG0vdWjxOfMcF8=
19
- github.com/aperturerobotics/util v1.32.3 h1:wBc6L2guYMgLEzFwORH3CLMoMpfEqbV6pDqYervo3S0=
20
- github.com/aperturerobotics/util v1.32.3/go.mod h1:qfRZZUDn0sEfc43JRA6rKP8bwFxliqGqJZX+p1jeOnQ=
15
+ github.com/aperturerobotics/protobuf-go-lite v0.12.2 h1:ujwTKgpIYAVsv8VljB6PPMY5SI8i8m/NlIHAkkuxQcU=
16
+ github.com/aperturerobotics/protobuf-go-lite v0.12.2/go.mod h1:lGH3s5ArCTXKI4wJdlNpaybUtwSjfAG0vdWjxOfMcF8=
17
+ github.com/aperturerobotics/util v1.32.4 h1:+f4rZuGC0AfgvA6bEwxSiW3Px9awyqr/CB2ltHyX4a8=
18
+ github.com/aperturerobotics/util v1.32.4/go.mod h1:qfRZZUDn0sEfc43JRA6rKP8bwFxliqGqJZX+p1jeOnQ=
21
19
  github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
22
20
  github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
23
21
  github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
24
22
  github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
25
23
  github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
26
24
  github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
27
- github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
28
- github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk=
29
- github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
30
- github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
31
25
  github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
32
26
  github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
33
- github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA=
34
- github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg=
35
27
  github.com/libp2p/go-yamux/v4 v4.0.2 h1:nrLh89LN/LEiqcFiqdKDRHjGstN300C1269K/EX0CPU=
36
28
  github.com/libp2p/go-yamux/v4 v4.0.2/go.mod h1:C808cCRgOs1iBwY4S71T5oxgMxgLmqUw56qh4AeBW2o=
37
- github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
38
- github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
39
- github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
40
- github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
41
- github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE=
42
- github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI=
43
- github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0=
44
- github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4=
45
- github.com/multiformats/go-multiaddr v0.13.0 h1:BCBzs61E3AGHcYYTv8dqRH43ZfyrqM8RXVPT8t13tLQ=
46
- github.com/multiformats/go-multiaddr v0.13.0/go.mod h1:sBXrNzucqkFJhvKOiwwLyqamGa/P5EIXNPLovyhQCII=
47
- github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g=
48
- github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk=
49
- github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U=
50
- github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM=
51
- github.com/multiformats/go-multistream v0.5.0 h1:5htLSLl7lvJk3xx3qT/8Zm9J4K8vEOf/QGkvOGQAyiE=
52
- github.com/multiformats/go-multistream v0.5.0/go.mod h1:n6tMZiwiP2wUsR8DgfDWw1dydlEqV3l6N3/GBsX6ILA=
53
- github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8=
54
- github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU=
55
29
  github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
56
30
  github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
57
31
  github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
58
32
  github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
59
33
  github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
60
34
  github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=
61
- github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
62
- github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
63
35
  github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
64
36
  github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
65
37
  github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
66
38
  github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU=
67
39
  github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg=
68
40
  github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
69
- golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
70
- golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
71
- golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
72
- golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
73
- golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
74
- golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
75
- golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
41
+ golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
42
+ golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
76
43
  golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
77
44
  golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
78
45
  google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
79
46
  google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
80
47
  gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
81
48
  gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
82
- lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE=
83
- lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=
@@ -57,6 +57,9 @@ echo "Building TypeScript server/client..."
57
57
  echo "Building Rust server/client..."
58
58
  cargo build --release --bin integration-server --bin integration-client 2>&1 | grep -v "^warning:" || true
59
59
 
60
+ echo "Vendoring Go dependencies (needed for C++ build)..."
61
+ go mod vendor
62
+
60
63
  echo "Building C++ server/client..."
61
64
  mkdir -p "$REPO_DIR/build"
62
65
  pushd "$REPO_DIR/build" > /dev/null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starpc",
3
- "version": "0.46.2",
3
+ "version": "0.47.1",
4
4
  "description": "Streaming protobuf RPC service protocol over any two-way channel.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -90,8 +90,8 @@
90
90
  "integration:rust:cpp": "bash ./integration/cross-language/run.bash rust:cpp",
91
91
  "lint": "bun run lint:go && bun run lint:js",
92
92
  "lint:go": "bun run go:aptre -- lint",
93
- "lint:js": "ESLINT_USE_FLAT_CONFIG=false eslint -c .eslintrc.cjs --ignore-pattern *.js --ignore-pattern *.d.ts ./",
94
- "prepare": "husky",
93
+ "lint:js": "eslint ./",
94
+ "prepare": "husky && go mod vendor",
95
95
  "go:aptre": "go run -mod=mod github.com/aperturerobotics/common/cmd/aptre",
96
96
  "precommit": "lint-staged",
97
97
  "release": "npm run release:version && npm run release:commit",
@@ -107,12 +107,15 @@
107
107
  "./{srpc,echo,e2e,integration,rpcstream,cmd}/**/(*.ts|*.tsx|*.html|*.css)": "prettier --config .prettierrc.yaml --write"
108
108
  },
109
109
  "devDependencies": {
110
- "@typescript-eslint/eslint-plugin": "^8.54.0",
111
- "@typescript-eslint/parser": "^8.54.0",
110
+ "@eslint/js": "^10.0.0",
111
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
112
+ "@typescript-eslint/parser": "^8.55.0",
112
113
  "depcheck": "^1.4.6",
113
114
  "esbuild": "^0.27.0",
114
- "eslint": "^9.39.1",
115
- "eslint-config-prettier": "^10.0.2",
115
+ "eslint": "^10.0.0",
116
+ "eslint-config-prettier": "^10.0.0",
117
+ "eslint-plugin-unused-imports": "^4.4.1",
118
+ "globals": "^17.0.0",
116
119
  "happy-dom": "^20.5.0",
117
120
  "husky": "^9.1.7",
118
121
  "lint-staged": "^16.2.7",
@@ -125,7 +128,7 @@
125
128
  },
126
129
  "dependencies": {
127
130
  "@aptre/it-ws": "^1.1.2",
128
- "@aptre/protobuf-es-lite": "^0.5.3",
131
+ "@aptre/protobuf-es-lite": "^1.0.1",
129
132
  "@chainsafe/libp2p-yamux": "^7.0.1",
130
133
  "@libp2p/interface": "^2.6.1",
131
134
  "event-iterator": "^2.0.0",
@@ -138,6 +141,6 @@
138
141
  "ws": "^8.18.1"
139
142
  },
140
143
  "resolutions": {
141
- "@aptre/protobuf-es-lite": "0.5.3"
144
+ "@aptre/protobuf-es-lite": "1.0.1"
142
145
  }
143
146
  }
@@ -65,10 +65,6 @@ func proxyStreamTo(src, dst Stream, errCh chan error) {
65
65
  }
66
66
  }()
67
67
 
68
- srcErr := src.Close()
69
- if rerr == nil && srcErr != nil {
70
- rerr = srcErr
71
- }
72
68
  if rerr != nil && rerr != io.EOF {
73
69
  if errCh != nil {
74
70
  errCh <- rerr
package/srpc/errors.go CHANGED
@@ -3,6 +3,8 @@ package srpc
3
3
  import "errors"
4
4
 
5
5
  var (
6
+ // ErrReset is returned when a stream is reset.
7
+ ErrReset = errors.New("stream reset")
6
8
  // ErrUnimplemented is returned if the RPC method was not implemented.
7
9
  ErrUnimplemented = errors.New("unimplemented")
8
10
  // ErrCompleted is returned if a message is received after the rpc was completed.
package/srpc/mux.go CHANGED
@@ -1,6 +1,9 @@
1
1
  package srpc
2
2
 
3
- import "sync"
3
+ import (
4
+ "slices"
5
+ "sync"
6
+ )
4
7
 
5
8
  // Mux contains a set of <service, method> handlers.
6
9
  type Mux interface {
@@ -86,10 +89,8 @@ func (m *mux) HasServiceMethod(serviceID, methodID string) bool {
86
89
 
87
90
  handlers := m.services[serviceID]
88
91
  for _, mh := range handlers {
89
- for _, mhMethodID := range mh.GetMethodIDs() {
90
- if mhMethodID == methodID {
91
- return true
92
- }
92
+ if slices.Contains(mh.GetMethodIDs(), methodID) {
93
+ return true
93
94
  }
94
95
  }
95
96
 
@@ -3,26 +3,28 @@ package srpc
3
3
  import (
4
4
  "context"
5
5
  "io"
6
+ "math"
6
7
  "net"
7
8
 
8
- "github.com/libp2p/go-libp2p/core/network"
9
- ymuxer "github.com/libp2p/go-libp2p/p2p/muxer/yamux"
10
9
  yamux "github.com/libp2p/go-yamux/v4"
11
10
  )
12
11
 
13
12
  // NewYamuxConfig builds the default yamux configuration.
14
13
  func NewYamuxConfig() *yamux.Config {
15
- // Configuration options from go-libp2p-yamux:
16
- config := *ymuxer.DefaultTransport.Config()
14
+ config := yamux.DefaultConfig()
15
+ config.MaxStreamWindowSize = 16 * 1024 * 1024
16
+ config.LogOutput = io.Discard
17
+ config.ReadBufSize = 0
18
+ config.MaxIncomingStreams = math.MaxUint32
17
19
  config.AcceptBacklog = 512
18
20
  config.EnableKeepAlive = false
19
- return &config
21
+ return config
20
22
  }
21
23
 
22
24
  // NewMuxedConn constructs a new MuxedConn from a net.Conn.
23
25
  //
24
26
  // If yamuxConf is nil, uses defaults.
25
- func NewMuxedConn(conn net.Conn, outbound bool, yamuxConf *yamux.Config) (network.MuxedConn, error) {
27
+ func NewMuxedConn(conn net.Conn, outbound bool, yamuxConf *yamux.Config) (MuxedConn, error) {
26
28
  if yamuxConf == nil {
27
29
  yamuxConf = NewYamuxConfig()
28
30
  }
@@ -38,7 +40,7 @@ func NewMuxedConn(conn net.Conn, outbound bool, yamuxConf *yamux.Config) (networ
38
40
  return nil, err
39
41
  }
40
42
 
41
- return ymuxer.NewMuxedConn(sess), nil
43
+ return newYamuxConn(sess), nil
42
44
  }
43
45
 
44
46
  // NewMuxedConnWithRwc builds a new MuxedConn with a io.ReadWriteCloser.
@@ -49,7 +51,7 @@ func NewMuxedConnWithRwc(
49
51
  rwc io.ReadWriteCloser,
50
52
  outbound bool,
51
53
  yamuxConf *yamux.Config,
52
- ) (network.MuxedConn, error) {
54
+ ) (MuxedConn, error) {
53
55
  return NewMuxedConn(NewRwcConn(ctx, rwc, nil, nil, 10), outbound, yamuxConf)
54
56
  }
55
57
 
@@ -65,13 +67,13 @@ func NewClientWithConn(conn net.Conn, outbound bool, yamuxConf *yamux.Config) (C
65
67
  }
66
68
 
67
69
  // NewClientWithMuxedConn constructs a new client with a MuxedConn.
68
- func NewClientWithMuxedConn(conn network.MuxedConn) Client {
70
+ func NewClientWithMuxedConn(conn MuxedConn) Client {
69
71
  openStreamFn := NewOpenStreamWithMuxedConn(conn)
70
72
  return NewClient(openStreamFn)
71
73
  }
72
74
 
73
75
  // NewOpenStreamWithMuxedConn constructs a OpenStream func with a MuxedConn.
74
- func NewOpenStreamWithMuxedConn(conn network.MuxedConn) OpenStreamFunc {
76
+ func NewOpenStreamWithMuxedConn(conn MuxedConn) OpenStreamFunc {
75
77
  return func(ctx context.Context, msgHandler PacketDataHandler, closeHandler CloseHandler) (PacketWriter, error) {
76
78
  mstrm, err := conn.OpenStream(ctx)
77
79
  if err != nil {
@@ -0,0 +1,51 @@
1
+ package srpc
2
+
3
+ import (
4
+ "context"
5
+
6
+ yamux "github.com/libp2p/go-yamux/v4"
7
+ )
8
+
9
+ // yamuxConn wraps a yamux.Session to implement MuxedConn.
10
+ type yamuxConn yamux.Session
11
+
12
+ // newYamuxConn wraps a yamux.Session as a MuxedConn.
13
+ func newYamuxConn(sess *yamux.Session) MuxedConn {
14
+ return (*yamuxConn)(sess)
15
+ }
16
+
17
+ // yamux returns the underlying yamux.Session.
18
+ func (c *yamuxConn) yamux() *yamux.Session {
19
+ return (*yamux.Session)(c)
20
+ }
21
+
22
+ // Close closes the underlying yamux session.
23
+ func (c *yamuxConn) Close() error {
24
+ return c.yamux().Close()
25
+ }
26
+
27
+ // IsClosed returns whether the connection is closed.
28
+ func (c *yamuxConn) IsClosed() bool {
29
+ return c.yamux().IsClosed()
30
+ }
31
+
32
+ // OpenStream creates a new stream.
33
+ func (c *yamuxConn) OpenStream(ctx context.Context) (MuxedStream, error) {
34
+ s, err := c.yamux().OpenStream(ctx)
35
+ if err != nil {
36
+ return nil, err
37
+ }
38
+ return (*yamuxStream)(s), nil
39
+ }
40
+
41
+ // AcceptStream accepts an incoming stream.
42
+ func (c *yamuxConn) AcceptStream() (MuxedStream, error) {
43
+ s, err := c.yamux().AcceptStream()
44
+ if err != nil {
45
+ return nil, err
46
+ }
47
+ return (*yamuxStream)(s), nil
48
+ }
49
+
50
+ // _ is a type assertion
51
+ var _ MuxedConn = (*yamuxConn)(nil)
package/srpc/muxed.go ADDED
@@ -0,0 +1,46 @@
1
+ package srpc
2
+
3
+ import (
4
+ "context"
5
+ "io"
6
+ "time"
7
+ )
8
+
9
+ // MuxedConn represents a connection which has been multiplexed.
10
+ type MuxedConn interface {
11
+ io.Closer
12
+
13
+ // IsClosed returns whether a connection is fully closed.
14
+ IsClosed() bool
15
+
16
+ // OpenStream creates a new stream.
17
+ OpenStream(context.Context) (MuxedStream, error)
18
+
19
+ // AcceptStream accepts a stream opened by the other side.
20
+ AcceptStream() (MuxedStream, error)
21
+ }
22
+
23
+ // MuxedStream is a bidirectional io pipe within a connection.
24
+ type MuxedStream interface {
25
+ io.Reader
26
+ io.Writer
27
+ io.Closer
28
+
29
+ // CloseWrite closes the stream for writing but leaves it open for reading.
30
+ CloseWrite() error
31
+
32
+ // CloseRead closes the stream for reading but leaves it open for writing.
33
+ CloseRead() error
34
+
35
+ // Reset closes both ends of the stream, telling the remote side to hang up.
36
+ Reset() error
37
+
38
+ // SetDeadline sets the read and write deadlines.
39
+ SetDeadline(time.Time) error
40
+
41
+ // SetReadDeadline sets the read deadline.
42
+ SetReadDeadline(time.Time) error
43
+
44
+ // SetWriteDeadline sets the write deadline.
45
+ SetWriteDeadline(time.Time) error
46
+ }
package/srpc/server.go CHANGED
@@ -3,8 +3,6 @@ package srpc
3
3
  import (
4
4
  "context"
5
5
  "io"
6
-
7
- "github.com/libp2p/go-libp2p/core/network"
8
6
  )
9
7
 
10
8
  // Server handles incoming RPC streams with a mux.
@@ -39,7 +37,7 @@ func (s *Server) HandleStream(ctx context.Context, rwc io.ReadWriteCloser) {
39
37
  //
40
38
  // Starts HandleStream in a separate goroutine to handle the stream.
41
39
  // Returns context.Canceled or io.EOF when the loop is complete / closed.
42
- func (s *Server) AcceptMuxedConn(ctx context.Context, mc network.MuxedConn) error {
40
+ func (s *Server) AcceptMuxedConn(ctx context.Context, mc MuxedConn) error {
43
41
  for {
44
42
  if err := ctx.Err(); err != nil {
45
43
  return context.Canceled
@@ -0,0 +1,72 @@
1
+ package srpc
2
+
3
+ import (
4
+ "errors"
5
+ "time"
6
+
7
+ yamux "github.com/libp2p/go-yamux/v4"
8
+ )
9
+
10
+ // yamuxStream wraps a yamux.Stream to implement MuxedStream.
11
+ type yamuxStream yamux.Stream
12
+
13
+ // yamux returns the underlying yamux.Stream.
14
+ func (s *yamuxStream) yamux() *yamux.Stream {
15
+ return (*yamux.Stream)(s)
16
+ }
17
+
18
+ // Read reads from the stream, translating stream reset errors.
19
+ func (s *yamuxStream) Read(b []byte) (int, error) {
20
+ n, err := s.yamux().Read(b)
21
+ if errors.Is(err, yamux.ErrStreamReset) {
22
+ err = ErrReset
23
+ }
24
+ return n, err
25
+ }
26
+
27
+ // Write writes to the stream, translating stream reset errors.
28
+ func (s *yamuxStream) Write(b []byte) (int, error) {
29
+ n, err := s.yamux().Write(b)
30
+ if errors.Is(err, yamux.ErrStreamReset) {
31
+ err = ErrReset
32
+ }
33
+ return n, err
34
+ }
35
+
36
+ // Close closes the stream.
37
+ func (s *yamuxStream) Close() error {
38
+ return s.yamux().Close()
39
+ }
40
+
41
+ // CloseWrite closes the stream for writing.
42
+ func (s *yamuxStream) CloseWrite() error {
43
+ return s.yamux().CloseWrite()
44
+ }
45
+
46
+ // CloseRead closes the stream for reading.
47
+ func (s *yamuxStream) CloseRead() error {
48
+ return s.yamux().CloseRead()
49
+ }
50
+
51
+ // Reset closes both ends of the stream.
52
+ func (s *yamuxStream) Reset() error {
53
+ return s.yamux().Reset()
54
+ }
55
+
56
+ // SetDeadline sets the read and write deadlines.
57
+ func (s *yamuxStream) SetDeadline(t time.Time) error {
58
+ return s.yamux().SetDeadline(t)
59
+ }
60
+
61
+ // SetReadDeadline sets the read deadline.
62
+ func (s *yamuxStream) SetReadDeadline(t time.Time) error {
63
+ return s.yamux().SetReadDeadline(t)
64
+ }
65
+
66
+ // SetWriteDeadline sets the write deadline.
67
+ func (s *yamuxStream) SetWriteDeadline(t time.Time) error {
68
+ return s.yamux().SetWriteDeadline(t)
69
+ }
70
+
71
+ // _ is a type assertion
72
+ var _ MuxedStream = (*yamuxStream)(nil)
package/srpc/websocket.go CHANGED
@@ -4,7 +4,6 @@ import (
4
4
  "context"
5
5
 
6
6
  "github.com/coder/websocket"
7
- "github.com/libp2p/go-libp2p/core/network"
8
7
  "github.com/libp2p/go-yamux/v4"
9
8
  )
10
9
 
@@ -15,7 +14,7 @@ func NewWebSocketConn(
15
14
  conn *websocket.Conn,
16
15
  isServer bool,
17
16
  yamuxConf *yamux.Config,
18
- ) (network.MuxedConn, error) {
17
+ ) (MuxedConn, error) {
19
18
  nc := websocket.NetConn(ctx, conn, websocket.MessageBinary)
20
19
  return NewMuxedConn(nc, !isServer, yamuxConf)
21
20
  }