diff --git a/go.work.sum b/go.work.sum index 0b0302e..0b48cab 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,9 +1,9 @@ cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/webrpc/gen-golang v0.16.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo= -github.com/webrpc/gen-typescript v0.15.0/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y= -github.com/webrpc/webrpc v0.21.0/go.mod h1:1WwQ1WRobFUjJiG34r8QMCXRLb1hr27+rdWmfWjSF2Y= +github.com/webrpc/gen-golang v0.17.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo= +github.com/webrpc/gen-typescript v0.16.1/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y= +github.com/webrpc/webrpc v0.22.0/go.mod h1:eeABnLz9BC4F9GGw6UKebVPkzkFYLrZRlcOvh6o8n10= golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= diff --git a/proto/authcontrol.gen.go b/proto/authcontrol.gen.go index fbcb8a1..8ac7be7 100644 --- a/proto/authcontrol.gen.go +++ b/proto/authcontrol.gen.go @@ -1,8 +1,8 @@ -// authcontrol v0.9.0 896c9dd61e9b52933577b35ac021a229cdc54fe2 +// authcontrol v0.9.1 809804f85757ee407e93c191d6d5bfb75b82cb56 // -- -// Code generated by webrpc-gen@v0.21.0 with golang@v0.16.0 generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.22.0 with golang@v0.17.0 generator. DO NOT EDIT. // -// webrpc-gen -schema=authcontrol.ridl -target=golang@v0.16.0 -pkg=proto -client -out=./authcontrol.gen.go +// webrpc-gen -schema=authcontrol.ridl -target=golang@v0.17.0 -pkg=proto -client -out=./authcontrol.gen.go package proto import ( @@ -15,7 +15,7 @@ import ( const WebrpcHeader = "Webrpc" -const WebrpcHeaderValue = "webrpc@v0.21.0;gen-golang@v0.16.0;authcontrol@v0.9.0" +const WebrpcHeaderValue = "webrpc@v0.22.0;gen-golang@v0.17.0;authcontrol@v0.9.1" // WebRPC description and code-gen version func WebRPCVersion() string { @@ -24,12 +24,12 @@ func WebRPCVersion() string { // Schema version of your RIDL schema func WebRPCSchemaVersion() string { - return "v0.9.0" + return "v0.9.1" } // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "896c9dd61e9b52933577b35ac021a229cdc54fe2" + return "809804f85757ee407e93c191d6d5bfb75b82cb56" } type WebrpcGenVersions struct { @@ -151,9 +151,16 @@ func (x *SessionType) Is(values ...SessionType) bool { return false } -var ( - methods = map[string]method{} -) +var methods = map[string]method{} + +func WebrpcMethods() map[string]method { + res := make(map[string]method, len(methods)) + for k, v := range methods { + res[k] = v + } + + return res +} var WebRPCServices = map[string][]string{} diff --git a/proto/authcontrol.gen.ts b/proto/authcontrol.gen.ts index fcb273b..5d6ac73 100644 --- a/proto/authcontrol.gen.ts +++ b/proto/authcontrol.gen.ts @@ -1,22 +1,22 @@ /* eslint-disable */ -// authcontrol v0.9.0 896c9dd61e9b52933577b35ac021a229cdc54fe2 +// authcontrol v0.9.1 809804f85757ee407e93c191d6d5bfb75b82cb56 // -- -// Code generated by webrpc-gen@v0.21.0 with typescript@v0.15.0 generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.22.0 with typescript@v0.16.1 generator. DO NOT EDIT. // -// webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.15.0 -client -out=./authcontrol.gen.ts +// webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.16.1 -client -out=./authcontrol.gen.ts export const WebrpcHeader = "Webrpc" -export const WebrpcHeaderValue = "webrpc@v0.21.0;gen-typescript@v0.15.0;authcontrol@v0.9.0" +export const WebrpcHeaderValue = "webrpc@v0.22.0;gen-typescript@v0.16.1;authcontrol@v0.9.1" // WebRPC description and code-gen version export const WebRPCVersion = "v1" // Schema version of your RIDL schema -export const WebRPCSchemaVersion = "v0.9.0" +export const WebRPCSchemaVersion = "v0.9.1" // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = "896c9dd61e9b52933577b35ac021a229cdc54fe2" +export const WebRPCSchemaHash = "809804f85757ee407e93c191d6d5bfb75b82cb56" type WebrpcGenVersions = { webrpcGenVersion: string; @@ -84,7 +84,7 @@ export enum SessionType { const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { - const reqHeaders = { ...headers, 'Content-Type': 'application/json' } + const reqHeaders: {[key: string]: string} = { ...headers, 'Content-Type': 'application/json' } reqHeaders[WebrpcHeader] = WebrpcHeaderValue return { @@ -437,7 +437,30 @@ export enum errors { ProjectNotFound = 'ProjectNotFound', } -const webrpcErrorByCode: { [code: number]: any } = { +export enum WebrpcErrorCodes { + WebrpcEndpoint = 0, + WebrpcRequestFailed = -1, + WebrpcBadRoute = -2, + WebrpcBadMethod = -3, + WebrpcBadRequest = -4, + WebrpcBadResponse = -5, + WebrpcServerPanic = -6, + WebrpcInternalError = -7, + WebrpcClientDisconnected = -8, + WebrpcStreamLost = -9, + WebrpcStreamFinished = -10, + Unauthorized = 1000, + PermissionDenied = 1001, + SessionExpired = 1002, + MethodNotFound = 1003, + RequestConflict = 1004, + Aborted = 1005, + Geoblocked = 1006, + RateLimited = 1007, + ProjectNotFound = 1008, +} + +export const webrpcErrorByCode: { [code: number]: any } = { [0]: WebrpcEndpointError, [-1]: WebrpcRequestFailedError, [-2]: WebrpcBadRouteError, diff --git a/proto/authcontrol.ridl b/proto/authcontrol.ridl index 4ad9dab..51a6bb4 100644 --- a/proto/authcontrol.ridl +++ b/proto/authcontrol.ridl @@ -1,7 +1,7 @@ webrpc = v1 name = authcontrol -version = v0.9.0 +version = v0.9.1 enum SessionType: uint16 - Public # Public access (anonymous) @@ -12,12 +12,4 @@ enum SessionType: uint16 - Admin # Admin-level access (jwt) - InternalService # Internal service-to-service access (jwt) -error 1000 Unauthorized "Unauthorized access" HTTP 401 -error 1001 PermissionDenied "Permission denied" HTTP 403 -error 1002 SessionExpired "Session expired" HTTP 403 -error 1003 MethodNotFound "Method not found" HTTP 404 -error 1004 RequestConflict "Conflict with target resource" HTTP 409 -error 1005 Aborted "Request aborted" HTTP 400 -error 1006 Geoblocked "Geoblocked region" HTTP 451 -error 1007 RateLimited "Rate-limited. Please slow down." HTTP 429 -error 1008 ProjectNotFound "Project not found" HTTP 401 +import "./errors.ridl" \ No newline at end of file diff --git a/proto/errors.ridl b/proto/errors.ridl new file mode 100644 index 0000000..0a81f86 --- /dev/null +++ b/proto/errors.ridl @@ -0,0 +1,14 @@ +webrpc = v1 + +name = authcontrol +version = v0.9.1 + +error 1000 Unauthorized "Unauthorized access" HTTP 401 +error 1001 PermissionDenied "Permission denied" HTTP 403 +error 1002 SessionExpired "Session expired" HTTP 403 +error 1003 MethodNotFound "Method not found" HTTP 404 +error 1004 RequestConflict "Conflict with target resource" HTTP 409 +error 1005 Aborted "Request aborted" HTTP 400 +error 1006 Geoblocked "Geoblocked region" HTTP 451 +error 1007 RateLimited "Rate-limited. Please slow down." HTTP 429 +error 1008 ProjectNotFound "Project not found" HTTP 401 diff --git a/proto/proto.go b/proto/proto.go index 1e28ede..8438526 100644 --- a/proto/proto.go +++ b/proto/proto.go @@ -1,5 +1,5 @@ -//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 -//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.15.0 -client -out=./authcontrol.gen.ts +//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 +//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.16.1 -client -out=./authcontrol.gen.ts package proto const SessionType_Max SessionType = SessionType_InternalService + 1 diff --git a/tools/go.mod b/tools/go.mod index 3a172e4..81934ec 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( github.com/goware/rerun v0.0.9 - github.com/webrpc/webrpc v0.21.0 + github.com/webrpc/webrpc v0.22.0 ) require ( @@ -45,11 +45,11 @@ require ( github.com/skeema/knownhosts v1.2.2 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/webrpc/gen-dart v0.1.1 // indirect - github.com/webrpc/gen-golang v0.16.0 // indirect + github.com/webrpc/gen-golang v0.17.0 // indirect github.com/webrpc/gen-javascript v0.13.0 // indirect github.com/webrpc/gen-kotlin v0.1.0 // indirect github.com/webrpc/gen-openapi v0.15.0 // indirect - github.com/webrpc/gen-typescript v0.15.0 // indirect + github.com/webrpc/gen-typescript v0.16.1 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect golang.org/x/crypto v0.28.0 // indirect golang.org/x/mod v0.20.0 // indirect diff --git a/tools/go.sum b/tools/go.sum index 7d2c6fc..5ca1403 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -206,18 +206,18 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/webrpc/gen-dart v0.1.1 h1:PZh5oNNdA84Qxu8ixKDf1cT8Iv6t0g7x6q9aeX1bti4= github.com/webrpc/gen-dart v0.1.1/go.mod h1:yq0ThW3ANNulJLyR50jx1aZMEVBDp19VUHucK65ayPs= -github.com/webrpc/gen-golang v0.16.0 h1:A41DrslXhvhSHUrpLx3Rdx3Jl3fxrk66L0z5M9MiT0A= -github.com/webrpc/gen-golang v0.16.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo= +github.com/webrpc/gen-golang v0.17.0 h1:qCvkhrIdEalQNYJEyqUhKiZ/wK5yEOhx0TJ5X0fzoKM= +github.com/webrpc/gen-golang v0.17.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo= github.com/webrpc/gen-javascript v0.13.0 h1:tw7U1xueUjZz3cQAAA4/DZ90BHydkQKiJC4VXd/j2hg= github.com/webrpc/gen-javascript v0.13.0/go.mod h1:5EhapSJgzbiWrIGlqzZN9Lg9mE9209wwX+Du2dgn4EU= github.com/webrpc/gen-kotlin v0.1.0 h1:tnlinqbDgowEoSy8E3VovTdP2OjyOIbgACCbahRjNcc= github.com/webrpc/gen-kotlin v0.1.0/go.mod h1:PIPys9Gn1Ro7q7uoacydEX8CtqBlAJSV98A++tdj4ak= github.com/webrpc/gen-openapi v0.15.0 h1:RrHAcDTlm0YH+YCz12p0KLCYIwfHrxf4x6/LjJ6kePY= github.com/webrpc/gen-openapi v0.15.0/go.mod h1:fwY3ylZmdiCr+WXjR8Ek8wm08CFRr2/GaXI7Zd/Ou4Y= -github.com/webrpc/gen-typescript v0.15.0 h1:cRnbarQiSoxA0taJ4V0v7TmHKE6UBhO6klvIrGu/CaM= -github.com/webrpc/gen-typescript v0.15.0/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y= -github.com/webrpc/webrpc v0.21.0 h1:gjZFP6FUL++2Lp4+Ts23kVvW9zk/sxvajZ+kXwB/ZuU= -github.com/webrpc/webrpc v0.21.0/go.mod h1:1WwQ1WRobFUjJiG34r8QMCXRLb1hr27+rdWmfWjSF2Y= +github.com/webrpc/gen-typescript v0.16.1 h1:4t9YNGROOV2ZL0UyB5wjWMpJklXDDNEj8eg05+8BF5Y= +github.com/webrpc/gen-typescript v0.16.1/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y= +github.com/webrpc/webrpc v0.22.0 h1:DkpXYA9p7em+Oqn76+VZrQJkrlbMEO8vBPpcjQ+lGvo= +github.com/webrpc/webrpc v0.22.0/go.mod h1:eeABnLz9BC4F9GGw6UKebVPkzkFYLrZRlcOvh6o8n10= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=