Skip to content

Commit 724a470

Browse files
authored
Use latest WebRPC (#29)
1 parent 22f2acb commit 724a470

File tree

8 files changed

+77
-41
lines changed

8 files changed

+77
-41
lines changed

go.work.sum

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
22
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
33
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
4-
github.com/webrpc/gen-golang v0.16.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo=
5-
github.com/webrpc/gen-typescript v0.15.0/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y=
6-
github.com/webrpc/webrpc v0.21.0/go.mod h1:1WwQ1WRobFUjJiG34r8QMCXRLb1hr27+rdWmfWjSF2Y=
4+
github.com/webrpc/gen-golang v0.17.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo=
5+
github.com/webrpc/gen-typescript v0.16.1/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y=
6+
github.com/webrpc/webrpc v0.22.0/go.mod h1:eeABnLz9BC4F9GGw6UKebVPkzkFYLrZRlcOvh6o8n10=
77
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
88
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
99
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=

proto/authcontrol.gen.go

Lines changed: 16 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/authcontrol.gen.ts

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/* eslint-disable */
2-
// authcontrol v0.9.0 896c9dd61e9b52933577b35ac021a229cdc54fe2
2+
// authcontrol v0.9.1 809804f85757ee407e93c191d6d5bfb75b82cb56
33
// --
4-
// Code generated by webrpc-gen@v0.21.0 with typescript@v0.15.0 generator. DO NOT EDIT.
4+
// Code generated by webrpc-gen@v0.22.0 with typescript@v0.16.1 generator. DO NOT EDIT.
55
//
6-
// webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.15.0 -client -out=./authcontrol.gen.ts
6+
// webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.16.1 -client -out=./authcontrol.gen.ts
77

88
export const WebrpcHeader = "Webrpc"
99

10-
export const WebrpcHeaderValue = "webrpc@v0.21.0;gen-typescript@v0.15.0;[email protected].0"
10+
export const WebrpcHeaderValue = "webrpc@v0.22.0;gen-typescript@v0.16.1;[email protected].1"
1111

1212
// WebRPC description and code-gen version
1313
export const WebRPCVersion = "v1"
1414

1515
// Schema version of your RIDL schema
16-
export const WebRPCSchemaVersion = "v0.9.0"
16+
export const WebRPCSchemaVersion = "v0.9.1"
1717

1818
// Schema hash generated from your RIDL schema
19-
export const WebRPCSchemaHash = "896c9dd61e9b52933577b35ac021a229cdc54fe2"
19+
export const WebRPCSchemaHash = "809804f85757ee407e93c191d6d5bfb75b82cb56"
2020

2121
type WebrpcGenVersions = {
2222
webrpcGenVersion: string;
@@ -84,7 +84,7 @@ export enum SessionType {
8484

8585

8686
const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => {
87-
const reqHeaders = { ...headers, 'Content-Type': 'application/json' }
87+
const reqHeaders: {[key: string]: string} = { ...headers, 'Content-Type': 'application/json' }
8888
reqHeaders[WebrpcHeader] = WebrpcHeaderValue
8989

9090
return {
@@ -437,7 +437,30 @@ export enum errors {
437437
ProjectNotFound = 'ProjectNotFound',
438438
}
439439

440-
const webrpcErrorByCode: { [code: number]: any } = {
440+
export enum WebrpcErrorCodes {
441+
WebrpcEndpoint = 0,
442+
WebrpcRequestFailed = -1,
443+
WebrpcBadRoute = -2,
444+
WebrpcBadMethod = -3,
445+
WebrpcBadRequest = -4,
446+
WebrpcBadResponse = -5,
447+
WebrpcServerPanic = -6,
448+
WebrpcInternalError = -7,
449+
WebrpcClientDisconnected = -8,
450+
WebrpcStreamLost = -9,
451+
WebrpcStreamFinished = -10,
452+
Unauthorized = 1000,
453+
PermissionDenied = 1001,
454+
SessionExpired = 1002,
455+
MethodNotFound = 1003,
456+
RequestConflict = 1004,
457+
Aborted = 1005,
458+
Geoblocked = 1006,
459+
RateLimited = 1007,
460+
ProjectNotFound = 1008,
461+
}
462+
463+
export const webrpcErrorByCode: { [code: number]: any } = {
441464
[0]: WebrpcEndpointError,
442465
[-1]: WebrpcRequestFailedError,
443466
[-2]: WebrpcBadRouteError,

proto/authcontrol.ridl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
webrpc = v1
22

33
name = authcontrol
4-
version = v0.9.0
4+
version = v0.9.1
55

66
enum SessionType: uint16
77
- Public # Public access (anonymous)
@@ -12,12 +12,4 @@ enum SessionType: uint16
1212
- Admin # Admin-level access (jwt)
1313
- InternalService # Internal service-to-service access (jwt)
1414

15-
error 1000 Unauthorized "Unauthorized access" HTTP 401
16-
error 1001 PermissionDenied "Permission denied" HTTP 403
17-
error 1002 SessionExpired "Session expired" HTTP 403
18-
error 1003 MethodNotFound "Method not found" HTTP 404
19-
error 1004 RequestConflict "Conflict with target resource" HTTP 409
20-
error 1005 Aborted "Request aborted" HTTP 400
21-
error 1006 Geoblocked "Geoblocked region" HTTP 451
22-
error 1007 RateLimited "Rate-limited. Please slow down." HTTP 429
23-
error 1008 ProjectNotFound "Project not found" HTTP 401
15+
import "./errors.ridl"

proto/errors.ridl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
webrpc = v1
2+
3+
name = authcontrol
4+
version = v0.9.1
5+
6+
error 1000 Unauthorized "Unauthorized access" HTTP 401
7+
error 1001 PermissionDenied "Permission denied" HTTP 403
8+
error 1002 SessionExpired "Session expired" HTTP 403
9+
error 1003 MethodNotFound "Method not found" HTTP 404
10+
error 1004 RequestConflict "Conflict with target resource" HTTP 409
11+
error 1005 Aborted "Request aborted" HTTP 400
12+
error 1006 Geoblocked "Geoblocked region" HTTP 451
13+
error 1007 RateLimited "Rate-limited. Please slow down." HTTP 429
14+
error 1008 ProjectNotFound "Project not found" HTTP 401

proto/proto.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=authcontrol.ridl -target=golang@v0.16.0 -pkg=proto -client -out=./authcontrol.gen.go
2-
//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.15.0 -client -out=./authcontrol.gen.ts
1+
//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=authcontrol.ridl -target=golang@v0.17.0 -pkg=proto -client -out=./authcontrol.gen.go
2+
//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.16.1 -client -out=./authcontrol.gen.ts
33
package proto
44

55
const SessionType_Max SessionType = SessionType_InternalService + 1

tools/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.21
44

55
require (
66
github.com/goware/rerun v0.0.9
7-
github.com/webrpc/webrpc v0.21.0
7+
github.com/webrpc/webrpc v0.22.0
88
)
99

1010
require (
@@ -45,11 +45,11 @@ require (
4545
github.com/skeema/knownhosts v1.2.2 // indirect
4646
github.com/spf13/cast v1.6.0 // indirect
4747
github.com/webrpc/gen-dart v0.1.1 // indirect
48-
github.com/webrpc/gen-golang v0.16.0 // indirect
48+
github.com/webrpc/gen-golang v0.17.0 // indirect
4949
github.com/webrpc/gen-javascript v0.13.0 // indirect
5050
github.com/webrpc/gen-kotlin v0.1.0 // indirect
5151
github.com/webrpc/gen-openapi v0.15.0 // indirect
52-
github.com/webrpc/gen-typescript v0.15.0 // indirect
52+
github.com/webrpc/gen-typescript v0.16.1 // indirect
5353
github.com/xanzy/ssh-agent v0.3.3 // indirect
5454
golang.org/x/crypto v0.28.0 // indirect
5555
golang.org/x/mod v0.20.0 // indirect

tools/go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,18 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
206206
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
207207
github.com/webrpc/gen-dart v0.1.1 h1:PZh5oNNdA84Qxu8ixKDf1cT8Iv6t0g7x6q9aeX1bti4=
208208
github.com/webrpc/gen-dart v0.1.1/go.mod h1:yq0ThW3ANNulJLyR50jx1aZMEVBDp19VUHucK65ayPs=
209-
github.com/webrpc/gen-golang v0.16.0 h1:A41DrslXhvhSHUrpLx3Rdx3Jl3fxrk66L0z5M9MiT0A=
210-
github.com/webrpc/gen-golang v0.16.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo=
209+
github.com/webrpc/gen-golang v0.17.0 h1:qCvkhrIdEalQNYJEyqUhKiZ/wK5yEOhx0TJ5X0fzoKM=
210+
github.com/webrpc/gen-golang v0.17.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo=
211211
github.com/webrpc/gen-javascript v0.13.0 h1:tw7U1xueUjZz3cQAAA4/DZ90BHydkQKiJC4VXd/j2hg=
212212
github.com/webrpc/gen-javascript v0.13.0/go.mod h1:5EhapSJgzbiWrIGlqzZN9Lg9mE9209wwX+Du2dgn4EU=
213213
github.com/webrpc/gen-kotlin v0.1.0 h1:tnlinqbDgowEoSy8E3VovTdP2OjyOIbgACCbahRjNcc=
214214
github.com/webrpc/gen-kotlin v0.1.0/go.mod h1:PIPys9Gn1Ro7q7uoacydEX8CtqBlAJSV98A++tdj4ak=
215215
github.com/webrpc/gen-openapi v0.15.0 h1:RrHAcDTlm0YH+YCz12p0KLCYIwfHrxf4x6/LjJ6kePY=
216216
github.com/webrpc/gen-openapi v0.15.0/go.mod h1:fwY3ylZmdiCr+WXjR8Ek8wm08CFRr2/GaXI7Zd/Ou4Y=
217-
github.com/webrpc/gen-typescript v0.15.0 h1:cRnbarQiSoxA0taJ4V0v7TmHKE6UBhO6klvIrGu/CaM=
218-
github.com/webrpc/gen-typescript v0.15.0/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y=
219-
github.com/webrpc/webrpc v0.21.0 h1:gjZFP6FUL++2Lp4+Ts23kVvW9zk/sxvajZ+kXwB/ZuU=
220-
github.com/webrpc/webrpc v0.21.0/go.mod h1:1WwQ1WRobFUjJiG34r8QMCXRLb1hr27+rdWmfWjSF2Y=
217+
github.com/webrpc/gen-typescript v0.16.1 h1:4t9YNGROOV2ZL0UyB5wjWMpJklXDDNEj8eg05+8BF5Y=
218+
github.com/webrpc/gen-typescript v0.16.1/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y=
219+
github.com/webrpc/webrpc v0.22.0 h1:DkpXYA9p7em+Oqn76+VZrQJkrlbMEO8vBPpcjQ+lGvo=
220+
github.com/webrpc/webrpc v0.22.0/go.mod h1:eeABnLz9BC4F9GGw6UKebVPkzkFYLrZRlcOvh6o8n10=
221221
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
222222
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
223223
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

0 commit comments

Comments
 (0)