v0.4.0 72f8f2e

session.connect.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3// Code generated by protoc-gen-connect-go. DO NOT EDIT.
4//
5// Source: ermite/session.proto
6
7package ermiteconnect
8
9import (
10	ermite "bnema.dev/ermite-api/gen/ermite"
11	connect "connectrpc.com/connect"
12	context "context"
13	errors "errors"
14	http "net/http"
15	strings "strings"
16)
17
18// This is a compile-time assertion to ensure that this generated file and the connect package are
19// compatible. If you get a compiler error that this constant is not defined, this code was
20// generated with a version of connect newer than the one compiled into your binary. You can fix the
21// problem by either regenerating this code with an older version of connect or updating the connect
22// version compiled into your binary.
23const _ = connect.IsAtLeastVersion1_13_0
24
25const (
26	// SessionServiceName is the fully-qualified name of the SessionService service.
27	SessionServiceName = "ermite.SessionService"
28)
29
30// These constants are the fully-qualified names of the RPCs defined in this package. They're
31// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
32//
33// Note that these are different from the fully-qualified method names used by
34// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
35// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
36// period.
37const (
38	// SessionServiceCreateLoginLinkProcedure is the fully-qualified name of the SessionService's
39	// CreateLoginLink RPC.
40	SessionServiceCreateLoginLinkProcedure = "/ermite.SessionService/CreateLoginLink"
41	// SessionServiceSignOutEverywhereProcedure is the fully-qualified name of the SessionService's
42	// SignOutEverywhere RPC.
43	SessionServiceSignOutEverywhereProcedure = "/ermite.SessionService/SignOutEverywhere"
44	// SessionServiceListPasskeysProcedure is the fully-qualified name of the SessionService's
45	// ListPasskeys RPC.
46	SessionServiceListPasskeysProcedure = "/ermite.SessionService/ListPasskeys"
47	// SessionServiceRemovePasskeyProcedure is the fully-qualified name of the SessionService's
48	// RemovePasskey RPC.
49	SessionServiceRemovePasskeyProcedure = "/ermite.SessionService/RemovePasskey"
50)
51
52// SessionServiceClient is a client for the ermite.SessionService service.
53type SessionServiceClient interface {
54	// CreateLoginLink creates a one-time link that signs the owner's browser
55	// in. The link is valid for a short time (about a minute), can be used
56	// once, and is kept in memory only: a server restart voids it. Opening it
57	// shows a confirmation page; only confirming it consumes the link and sets
58	// the session. Creating a new link does not void an earlier one. Fails with
59	// resource_exhausted when too many links are pending.
60	CreateLoginLink(context.Context, *connect.Request[ermite.CreateLoginLinkRequest]) (*connect.Response[ermite.CreateLoginLinkResponse], error)
61	// SignOutEverywhere ends every browser session at once, including those on
62	// other devices. Pending login links are not affected. Tokens are not
63	// affected either: revoke them with TokenService.
64	SignOutEverywhere(context.Context, *connect.Request[ermite.SignOutEverywhereRequest]) (*connect.Response[ermite.SignOutEverywhereResponse], error)
65	// ListPasskeys lists the owner's registered passkeys, oldest first. Fails
66	// with failed_precondition when the server has passkeys disabled.
67	ListPasskeys(context.Context, *connect.Request[ermite.ListPasskeysRequest]) (*connect.Response[ermite.ListPasskeysResponse], error)
68	// RemovePasskey removes one passkey. It also signs out every browser
69	// session, on every device, like SignOutEverywhere. Fails with not_found
70	// for an unknown id, invalid_argument for an id that is not base64url, and
71	// failed_precondition when the server has passkeys disabled.
72	RemovePasskey(context.Context, *connect.Request[ermite.RemovePasskeyRequest]) (*connect.Response[ermite.RemovePasskeyResponse], error)
73}
74
75// NewSessionServiceClient constructs a client for the ermite.SessionService service. By default, it
76// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
77// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
78// connect.WithGRPCWeb() options.
79//
80// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
81// http://api.acme.com or https://acme.com/grpc).
82func NewSessionServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SessionServiceClient {
83	baseURL = strings.TrimRight(baseURL, "/")
84	sessionServiceMethods := ermite.File_ermite_session_proto.Services().ByName("SessionService").Methods()
85	return &sessionServiceClient{
86		createLoginLink: connect.NewClient[ermite.CreateLoginLinkRequest, ermite.CreateLoginLinkResponse](
87			httpClient,
88			baseURL+SessionServiceCreateLoginLinkProcedure,
89			connect.WithSchema(sessionServiceMethods.ByName("CreateLoginLink")),
90			connect.WithClientOptions(opts...),
91		),
92		signOutEverywhere: connect.NewClient[ermite.SignOutEverywhereRequest, ermite.SignOutEverywhereResponse](
93			httpClient,
94			baseURL+SessionServiceSignOutEverywhereProcedure,
95			connect.WithSchema(sessionServiceMethods.ByName("SignOutEverywhere")),
96			connect.WithClientOptions(opts...),
97		),
98		listPasskeys: connect.NewClient[ermite.ListPasskeysRequest, ermite.ListPasskeysResponse](
99			httpClient,
100			baseURL+SessionServiceListPasskeysProcedure,
101			connect.WithSchema(sessionServiceMethods.ByName("ListPasskeys")),
102			connect.WithClientOptions(opts...),
103		),
104		removePasskey: connect.NewClient[ermite.RemovePasskeyRequest, ermite.RemovePasskeyResponse](
105			httpClient,
106			baseURL+SessionServiceRemovePasskeyProcedure,
107			connect.WithSchema(sessionServiceMethods.ByName("RemovePasskey")),
108			connect.WithClientOptions(opts...),
109		),
110	}
111}
112
113// sessionServiceClient implements SessionServiceClient.
114type sessionServiceClient struct {
115	createLoginLink   *connect.Client[ermite.CreateLoginLinkRequest, ermite.CreateLoginLinkResponse]
116	signOutEverywhere *connect.Client[ermite.SignOutEverywhereRequest, ermite.SignOutEverywhereResponse]
117	listPasskeys      *connect.Client[ermite.ListPasskeysRequest, ermite.ListPasskeysResponse]
118	removePasskey     *connect.Client[ermite.RemovePasskeyRequest, ermite.RemovePasskeyResponse]
119}
120
121// CreateLoginLink calls ermite.SessionService.CreateLoginLink.
122func (c *sessionServiceClient) CreateLoginLink(ctx context.Context, req *connect.Request[ermite.CreateLoginLinkRequest]) (*connect.Response[ermite.CreateLoginLinkResponse], error) {
123	return c.createLoginLink.CallUnary(ctx, req)
124}
125
126// SignOutEverywhere calls ermite.SessionService.SignOutEverywhere.
127func (c *sessionServiceClient) SignOutEverywhere(ctx context.Context, req *connect.Request[ermite.SignOutEverywhereRequest]) (*connect.Response[ermite.SignOutEverywhereResponse], error) {
128	return c.signOutEverywhere.CallUnary(ctx, req)
129}
130
131// ListPasskeys calls ermite.SessionService.ListPasskeys.
132func (c *sessionServiceClient) ListPasskeys(ctx context.Context, req *connect.Request[ermite.ListPasskeysRequest]) (*connect.Response[ermite.ListPasskeysResponse], error) {
133	return c.listPasskeys.CallUnary(ctx, req)
134}
135
136// RemovePasskey calls ermite.SessionService.RemovePasskey.
137func (c *sessionServiceClient) RemovePasskey(ctx context.Context, req *connect.Request[ermite.RemovePasskeyRequest]) (*connect.Response[ermite.RemovePasskeyResponse], error) {
138	return c.removePasskey.CallUnary(ctx, req)
139}
140
141// SessionServiceHandler is an implementation of the ermite.SessionService service.
142type SessionServiceHandler interface {
143	// CreateLoginLink creates a one-time link that signs the owner's browser
144	// in. The link is valid for a short time (about a minute), can be used
145	// once, and is kept in memory only: a server restart voids it. Opening it
146	// shows a confirmation page; only confirming it consumes the link and sets
147	// the session. Creating a new link does not void an earlier one. Fails with
148	// resource_exhausted when too many links are pending.
149	CreateLoginLink(context.Context, *connect.Request[ermite.CreateLoginLinkRequest]) (*connect.Response[ermite.CreateLoginLinkResponse], error)
150	// SignOutEverywhere ends every browser session at once, including those on
151	// other devices. Pending login links are not affected. Tokens are not
152	// affected either: revoke them with TokenService.
153	SignOutEverywhere(context.Context, *connect.Request[ermite.SignOutEverywhereRequest]) (*connect.Response[ermite.SignOutEverywhereResponse], error)
154	// ListPasskeys lists the owner's registered passkeys, oldest first. Fails
155	// with failed_precondition when the server has passkeys disabled.
156	ListPasskeys(context.Context, *connect.Request[ermite.ListPasskeysRequest]) (*connect.Response[ermite.ListPasskeysResponse], error)
157	// RemovePasskey removes one passkey. It also signs out every browser
158	// session, on every device, like SignOutEverywhere. Fails with not_found
159	// for an unknown id, invalid_argument for an id that is not base64url, and
160	// failed_precondition when the server has passkeys disabled.
161	RemovePasskey(context.Context, *connect.Request[ermite.RemovePasskeyRequest]) (*connect.Response[ermite.RemovePasskeyResponse], error)
162}
163
164// NewSessionServiceHandler builds an HTTP handler from the service implementation. It returns the
165// path on which to mount the handler and the handler itself.
166//
167// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
168// and JSON codecs. They also support gzip compression.
169func NewSessionServiceHandler(svc SessionServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
170	sessionServiceMethods := ermite.File_ermite_session_proto.Services().ByName("SessionService").Methods()
171	sessionServiceCreateLoginLinkHandler := connect.NewUnaryHandler(
172		SessionServiceCreateLoginLinkProcedure,
173		svc.CreateLoginLink,
174		connect.WithSchema(sessionServiceMethods.ByName("CreateLoginLink")),
175		connect.WithHandlerOptions(opts...),
176	)
177	sessionServiceSignOutEverywhereHandler := connect.NewUnaryHandler(
178		SessionServiceSignOutEverywhereProcedure,
179		svc.SignOutEverywhere,
180		connect.WithSchema(sessionServiceMethods.ByName("SignOutEverywhere")),
181		connect.WithHandlerOptions(opts...),
182	)
183	sessionServiceListPasskeysHandler := connect.NewUnaryHandler(
184		SessionServiceListPasskeysProcedure,
185		svc.ListPasskeys,
186		connect.WithSchema(sessionServiceMethods.ByName("ListPasskeys")),
187		connect.WithHandlerOptions(opts...),
188	)
189	sessionServiceRemovePasskeyHandler := connect.NewUnaryHandler(
190		SessionServiceRemovePasskeyProcedure,
191		svc.RemovePasskey,
192		connect.WithSchema(sessionServiceMethods.ByName("RemovePasskey")),
193		connect.WithHandlerOptions(opts...),
194	)
195	return "/ermite.SessionService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
196		switch r.URL.Path {
197		case SessionServiceCreateLoginLinkProcedure:
198			sessionServiceCreateLoginLinkHandler.ServeHTTP(w, r)
199		case SessionServiceSignOutEverywhereProcedure:
200			sessionServiceSignOutEverywhereHandler.ServeHTTP(w, r)
201		case SessionServiceListPasskeysProcedure:
202			sessionServiceListPasskeysHandler.ServeHTTP(w, r)
203		case SessionServiceRemovePasskeyProcedure:
204			sessionServiceRemovePasskeyHandler.ServeHTTP(w, r)
205		default:
206			http.NotFound(w, r)
207		}
208	})
209}
210
211// UnimplementedSessionServiceHandler returns CodeUnimplemented from all methods.
212type UnimplementedSessionServiceHandler struct{}
213
214func (UnimplementedSessionServiceHandler) CreateLoginLink(context.Context, *connect.Request[ermite.CreateLoginLinkRequest]) (*connect.Response[ermite.CreateLoginLinkResponse], error) {
215	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.SessionService.CreateLoginLink is not implemented"))
216}
217
218func (UnimplementedSessionServiceHandler) SignOutEverywhere(context.Context, *connect.Request[ermite.SignOutEverywhereRequest]) (*connect.Response[ermite.SignOutEverywhereResponse], error) {
219	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.SessionService.SignOutEverywhere is not implemented"))
220}
221
222func (UnimplementedSessionServiceHandler) ListPasskeys(context.Context, *connect.Request[ermite.ListPasskeysRequest]) (*connect.Response[ermite.ListPasskeysResponse], error) {
223	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.SessionService.ListPasskeys is not implemented"))
224}
225
226func (UnimplementedSessionServiceHandler) RemovePasskey(context.Context, *connect.Request[ermite.RemovePasskeyRequest]) (*connect.Response[ermite.RemovePasskeyResponse], error) {
227	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.SessionService.RemovePasskey is not implemented"))
228}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 18

↑↓ moveenter openesc close