api

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.9.0 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSpec added in v0.4.0

func GetSpec() (swagger *openapi3.T, err error)

GetSpec returns the OpenAPI specification corresponding to the generated code in this file. External references in the spec are resolved through PathToRawSpec; externally-referenced files must be embedded in their corresponding Go packages (via the import-mapping feature). URL-based external refs are not supported.

func GetSpecJSON added in v0.4.0

func GetSpecJSON() ([]byte, error)

GetSpecJSON returns the raw JSON bytes of the embedded OpenAPI specification: decompressed but not unmarshaled. External references are not resolved here; the bytes are the spec exactly as embedded by codegen. The result is cached at package init time, so repeated calls are cheap.

func GetSwagger deprecated

func GetSwagger() (*openapi3.T, error)

GetSwagger returns the OpenAPI specification corresponding to the generated code in this file.

Deprecated: GetSwagger predates kin-openapi renaming openapi3.Swagger to openapi3.T. Use GetSpec instead. This wrapper is retained for backwards compatibility.

func Handler added in v0.4.0

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux added in v0.4.0

func HandlerFromMux(si ServerInterface, m ServeMux) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL added in v0.4.0

func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler

func HandlerWithOptions added in v0.4.0

func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func NewCreateSessionRequest

func NewCreateSessionRequest(server string, body CreateSessionJSONRequestBody) (*http.Request, error)

NewCreateSessionRequest calls the generic CreateSession builder with application/json body

func NewCreateSessionRequestWithBody

func NewCreateSessionRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewCreateSessionRequestWithBody constructs an http.Request for the CreateSession method, with any body, and a specified content type

func NewGenerateTotpRequest

func NewGenerateTotpRequest(server string, id string, body GenerateTotpJSONRequestBody) (*http.Request, error)

NewGenerateTotpRequest calls the generic GenerateTotp builder with application/json body

func NewGenerateTotpRequestWithBody

func NewGenerateTotpRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error)

NewGenerateTotpRequestWithBody constructs an http.Request for the GenerateTotp method, with any body, and a specified content type

func NewGetSessionRequest

func NewGetSessionRequest(server string, id string) (*http.Request, error)

NewGetSessionRequest constructs an http.Request for the GetSession method

func NewPostTocRequest

func NewPostTocRequest(server string, id string, body PostTocJSONRequestBody) (*http.Request, error)

NewPostTocRequest calls the generic PostToc builder with application/json body

func NewPostTocRequestWithBody

func NewPostTocRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error)

NewPostTocRequestWithBody constructs an http.Request for the PostToc method, with any body, and a specified content type

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type AddToc

type AddToc struct {
	// EncryptedToc The constituent's Toc encrypted with the session's public key
	EncryptedToc string `json:"encrypted_toc"`
}

AddToc defines model for AddToc.

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, body CreateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

CreateSession Start a new session

A session describes the workflow in which an applicant requires combining Tocs to generate a TOTP. The applicant must already have a Toc.

Takes a body of the `application/json` content type.

Corresponds with POST /sessions (the `CreateSession` operationId).

func (*Client) CreateSessionWithBody

func (c *Client) CreateSessionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

CreateSessionWithBody Start a new session

A session describes the workflow in which an applicant requires combining Tocs to generate a TOTP. The applicant must already have a Toc.

Takes any type of body and a specified content type.

Corresponds with POST /sessions (the `CreateSession` operationId).

func (*Client) GenerateTotp

func (c *Client) GenerateTotp(ctx context.Context, id string, body GenerateTotpJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

GenerateTotp Close the session and generate the TOTP

Takes a body of the `application/json` content type.

Corresponds with POST /sessions/{id}/totp (the `GenerateTotp` operationId).

func (*Client) GenerateTotpWithBody

func (c *Client) GenerateTotpWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

GenerateTotpWithBody Close the session and generate the TOTP

Takes any type of body and a specified content type.

Corresponds with POST /sessions/{id}/totp (the `GenerateTotp` operationId).

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error)

GetSession Retrieve a session details by its ID

Corresponds with GET /sessions/{id} (the `GetSession` operationId).

func (*Client) PostToc

func (c *Client) PostToc(ctx context.Context, id string, body PostTocJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

PostToc Join a new Toc to an existing session

Takes a body of the `application/json` content type.

Corresponds with POST /sessions/{id}/tocs (the `PostToc` operationId).

func (*Client) PostTocWithBody

func (c *Client) PostTocWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

PostTocWithBody Join a new Toc to an existing session

Takes any type of body and a specified content type.

Corresponds with POST /sessions/{id}/tocs (the `PostToc` operationId).

type ClientInterface

type ClientInterface interface {

	// CreateSessionWithBody Start a new session
	//
	// A session describes the workflow in which an applicant requires combining Tocs to generate a TOTP.
	// The applicant must already have a Toc.
	//
	// Takes any type of body and a specified content type.
	//
	// Corresponds with POST /sessions (the `CreateSession` operationId).
	CreateSessionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	// CreateSession Start a new session
	//
	// A session describes the workflow in which an applicant requires combining Tocs to generate a TOTP.
	// The applicant must already have a Toc.
	//
	// Takes a body of the `application/json` content type.
	//
	// Corresponds with POST /sessions (the `CreateSession` operationId).
	CreateSession(ctx context.Context, body CreateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetSession Retrieve a session details by its ID
	//
	// Corresponds with GET /sessions/{id} (the `GetSession` operationId).
	GetSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error)

	// PostTocWithBody Join a new Toc to an existing session
	//
	// Takes any type of body and a specified content type.
	//
	// Corresponds with POST /sessions/{id}/tocs (the `PostToc` operationId).
	PostTocWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	// PostToc Join a new Toc to an existing session
	//
	// Takes a body of the `application/json` content type.
	//
	// Corresponds with POST /sessions/{id}/tocs (the `PostToc` operationId).
	PostToc(ctx context.Context, id string, body PostTocJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GenerateTotpWithBody Close the session and generate the TOTP
	//
	// Takes any type of body and a specified content type.
	//
	// Corresponds with POST /sessions/{id}/totp (the `GenerateTotp` operationId).
	GenerateTotpWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GenerateTotp Close the session and generate the TOTP
	//
	// Takes a body of the `application/json` content type.
	//
	// Corresponds with POST /sessions/{id}/totp (the `GenerateTotp` operationId).
	GenerateTotp(ctx context.Context, id string, body GenerateTotpJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) CreateSessionWithBodyWithResponse

func (c *ClientWithResponses) CreateSessionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSessionResponse, error)

CreateSessionWithBodyWithResponse Start a new session

A session describes the workflow in which an applicant requires combining Tocs to generate a TOTP. The applicant must already have a Toc.

Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).

Corresponds with POST /sessions (the `CreateSession` operationId).

func (*ClientWithResponses) CreateSessionWithResponse

func (c *ClientWithResponses) CreateSessionWithResponse(ctx context.Context, body CreateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSessionResponse, error)

CreateSessionWithResponse Start a new session

A session describes the workflow in which an applicant requires combining Tocs to generate a TOTP. The applicant must already have a Toc.

Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).

Corresponds with POST /sessions (the `CreateSession` operationId).

func (*ClientWithResponses) GenerateTotpWithBodyWithResponse

func (c *ClientWithResponses) GenerateTotpWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GenerateTotpResponse, error)

GenerateTotpWithBodyWithResponse Close the session and generate the TOTP

Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).

Corresponds with POST /sessions/{id}/totp (the `GenerateTotp` operationId).

func (*ClientWithResponses) GenerateTotpWithResponse

func (c *ClientWithResponses) GenerateTotpWithResponse(ctx context.Context, id string, body GenerateTotpJSONRequestBody, reqEditors ...RequestEditorFn) (*GenerateTotpResponse, error)

GenerateTotpWithResponse Close the session and generate the TOTP

Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).

Corresponds with POST /sessions/{id}/totp (the `GenerateTotp` operationId).

func (*ClientWithResponses) GetSessionWithResponse

func (c *ClientWithResponses) GetSessionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSessionResponse, error)

GetSessionWithResponse Retrieve a session details by its ID

Returns a wrapper object for the known response body format(s).

Corresponds with GET /sessions/{id} (the `GetSession` operationId).

func (*ClientWithResponses) PostTocWithBodyWithResponse

func (c *ClientWithResponses) PostTocWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostTocResponse, error)

PostTocWithBodyWithResponse Join a new Toc to an existing session

Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).

Corresponds with POST /sessions/{id}/tocs (the `PostToc` operationId).

func (*ClientWithResponses) PostTocWithResponse

func (c *ClientWithResponses) PostTocWithResponse(ctx context.Context, id string, body PostTocJSONRequestBody, reqEditors ...RequestEditorFn) (*PostTocResponse, error)

PostTocWithResponse Join a new Toc to an existing session

Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).

Corresponds with POST /sessions/{id}/tocs (the `PostToc` operationId).

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {

	// CreateSessionWithBodyWithResponse Start a new session
	//
	// A session describes the workflow in which an applicant requires combining Tocs to generate a TOTP.
	// The applicant must already have a Toc.
	//
	// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).
	//
	// Corresponds with POST /sessions (the `CreateSession` operationId).
	CreateSessionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSessionResponse, error)

	// CreateSessionWithResponse Start a new session
	//
	// A session describes the workflow in which an applicant requires combining Tocs to generate a TOTP.
	// The applicant must already have a Toc.
	//
	// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
	//
	// Corresponds with POST /sessions (the `CreateSession` operationId).
	CreateSessionWithResponse(ctx context.Context, body CreateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSessionResponse, error)

	// GetSessionWithResponse Retrieve a session details by its ID
	//
	// Returns a wrapper object for the known response body format(s).
	//
	// Corresponds with GET /sessions/{id} (the `GetSession` operationId).
	GetSessionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSessionResponse, error)

	// PostTocWithBodyWithResponse Join a new Toc to an existing session
	//
	// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).
	//
	// Corresponds with POST /sessions/{id}/tocs (the `PostToc` operationId).
	PostTocWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostTocResponse, error)

	// PostTocWithResponse Join a new Toc to an existing session
	//
	// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
	//
	// Corresponds with POST /sessions/{id}/tocs (the `PostToc` operationId).
	PostTocWithResponse(ctx context.Context, id string, body PostTocJSONRequestBody, reqEditors ...RequestEditorFn) (*PostTocResponse, error)

	// GenerateTotpWithBodyWithResponse Close the session and generate the TOTP
	//
	// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).
	//
	// Corresponds with POST /sessions/{id}/totp (the `GenerateTotp` operationId).
	GenerateTotpWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GenerateTotpResponse, error)

	// GenerateTotpWithResponse Close the session and generate the TOTP
	//
	// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
	//
	// Corresponds with POST /sessions/{id}/totp (the `GenerateTotp` operationId).
	GenerateTotpWithResponse(ctx context.Context, id string, body GenerateTotpJSONRequestBody, reqEditors ...RequestEditorFn) (*GenerateTotpResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type CreateSession200JSONResponse added in v0.4.0

type CreateSession200JSONResponse SessionCredentials

func (CreateSession200JSONResponse) VisitCreateSessionResponse added in v0.4.0

func (response CreateSession200JSONResponse) VisitCreateSessionResponse(w http.ResponseWriter) error

type CreateSessionJSONRequestBody

type CreateSessionJSONRequestBody = NewSession

CreateSessionJSONRequestBody defines body for CreateSession for application/json ContentType.

type CreateSessionRequestObject added in v0.4.0

type CreateSessionRequestObject struct {
	Body *CreateSessionJSONRequestBody
}

type CreateSessionResponse

type CreateSessionResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	// JSON200 the response for an HTTP 200 `application/json` response
	JSON200 *SessionCredentials
	// JSONDefault the response for an HTTP default `application/json` response
	JSONDefault *DefaultError
}

func ParseCreateSessionResponse

func ParseCreateSessionResponse(rsp *http.Response) (*CreateSessionResponse, error)

ParseCreateSessionResponse parses an HTTP response from a CreateSessionWithResponse call

func (CreateSessionResponse) ContentType added in v0.4.0

func (r CreateSessionResponse) ContentType() string

ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers

func (CreateSessionResponse) GetBody added in v0.4.0

func (r CreateSessionResponse) GetBody() []byte

GetBody returns the raw response body bytes

func (CreateSessionResponse) GetJSON200 added in v0.4.0

func (r CreateSessionResponse) GetJSON200() *SessionCredentials

GetJSON200 returns the response for an HTTP 200 `application/json` response

func (CreateSessionResponse) GetJSONDefault added in v0.4.0

func (r CreateSessionResponse) GetJSONDefault() *DefaultError

GetJSONDefault returns the response for an HTTP default `application/json` response

func (CreateSessionResponse) Status

func (r CreateSessionResponse) Status() string

Status returns HTTPResponse.Status

func (CreateSessionResponse) StatusCode

func (r CreateSessionResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type CreateSessionResponseObject added in v0.4.0

type CreateSessionResponseObject interface {
	VisitCreateSessionResponse(w http.ResponseWriter) error
}

type CreateSessiondefaultJSONResponse added in v0.4.0

type CreateSessiondefaultJSONResponse struct {
	Body       Error
	StatusCode int
}

func (CreateSessiondefaultJSONResponse) VisitCreateSessionResponse added in v0.4.0

func (response CreateSessiondefaultJSONResponse) VisitCreateSessionResponse(w http.ResponseWriter) error

type DefaultError

type DefaultError = Error

DefaultError defines model for DefaultError.

type DefaultErrorJSONResponse added in v0.4.0

type DefaultErrorJSONResponse Error

type Error

type Error struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
}

Error defines model for Error.

type ErrorCode

type ErrorCode string

ErrorCode defines model for Error.Code.

const (
	Internal          ErrorCode = "Internal"
	InvalidKek        ErrorCode = "InvalidKek"
	InvalidRequest    ErrorCode = "InvalidRequest"
	InvalidTOTPSecret ErrorCode = "InvalidTOTPSecret"
	InvalidToc        ErrorCode = "InvalidToc"
	NotEnoughTocs     ErrorCode = "NotEnoughTocs"
	SessionExpired    ErrorCode = "SessionExpired"
	SessionNotFound   ErrorCode = "SessionNotFound"
	TocAlreadyExists  ErrorCode = "TocAlreadyExists"
)

Defines values for ErrorCode.

func (ErrorCode) Valid added in v0.4.0

func (e ErrorCode) Valid() bool

Valid indicates whether the value is a known member of the ErrorCode enum.

type GenerateTotp200JSONResponse added in v0.4.0

type GenerateTotp200JSONResponse TOTPCode

func (GenerateTotp200JSONResponse) VisitGenerateTotpResponse added in v0.4.0

func (response GenerateTotp200JSONResponse) VisitGenerateTotpResponse(w http.ResponseWriter) error

type GenerateTotpJSONRequestBody

type GenerateTotpJSONRequestBody = SessionKeyEncryptionKey

GenerateTotpJSONRequestBody defines body for GenerateTotp for application/json ContentType.

type GenerateTotpRequestObject added in v0.4.0

type GenerateTotpRequestObject struct {
	Id   string `json:"id"`
	Body *GenerateTotpJSONRequestBody
}

type GenerateTotpResponse

type GenerateTotpResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	// JSON200 the response for an HTTP 200 `application/json` response
	JSON200 *TOTPCode
	// JSONDefault the response for an HTTP default `application/json` response
	JSONDefault *DefaultError
}

func ParseGenerateTotpResponse

func ParseGenerateTotpResponse(rsp *http.Response) (*GenerateTotpResponse, error)

ParseGenerateTotpResponse parses an HTTP response from a GenerateTotpWithResponse call

func (GenerateTotpResponse) ContentType added in v0.4.0

func (r GenerateTotpResponse) ContentType() string

ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers

func (GenerateTotpResponse) GetBody added in v0.4.0

func (r GenerateTotpResponse) GetBody() []byte

GetBody returns the raw response body bytes

func (GenerateTotpResponse) GetJSON200 added in v0.4.0

func (r GenerateTotpResponse) GetJSON200() *TOTPCode

GetJSON200 returns the response for an HTTP 200 `application/json` response

func (GenerateTotpResponse) GetJSONDefault added in v0.4.0

func (r GenerateTotpResponse) GetJSONDefault() *DefaultError

GetJSONDefault returns the response for an HTTP default `application/json` response

func (GenerateTotpResponse) Status

func (r GenerateTotpResponse) Status() string

Status returns HTTPResponse.Status

func (GenerateTotpResponse) StatusCode

func (r GenerateTotpResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GenerateTotpResponseObject added in v0.4.0

type GenerateTotpResponseObject interface {
	VisitGenerateTotpResponse(w http.ResponseWriter) error
}

type GenerateTotpdefaultJSONResponse added in v0.4.0

type GenerateTotpdefaultJSONResponse struct {
	Body       Error
	StatusCode int
}

func (GenerateTotpdefaultJSONResponse) VisitGenerateTotpResponse added in v0.4.0

func (response GenerateTotpdefaultJSONResponse) VisitGenerateTotpResponse(w http.ResponseWriter) error

type GetSession200JSONResponse added in v0.4.0

type GetSession200JSONResponse Session

func (GetSession200JSONResponse) VisitGetSessionResponse added in v0.4.0

func (response GetSession200JSONResponse) VisitGetSessionResponse(w http.ResponseWriter) error

type GetSessionRequestObject added in v0.4.0

type GetSessionRequestObject struct {
	Id string `json:"id"`
}

type GetSessionResponse

type GetSessionResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	// JSON200 the response for an HTTP 200 `application/json` response
	JSON200 *Session
	// JSONDefault the response for an HTTP default `application/json` response
	JSONDefault *DefaultError
}

func ParseGetSessionResponse

func ParseGetSessionResponse(rsp *http.Response) (*GetSessionResponse, error)

ParseGetSessionResponse parses an HTTP response from a GetSessionWithResponse call

func (GetSessionResponse) ContentType added in v0.4.0

func (r GetSessionResponse) ContentType() string

ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers

func (GetSessionResponse) GetBody added in v0.4.0

func (r GetSessionResponse) GetBody() []byte

GetBody returns the raw response body bytes

func (GetSessionResponse) GetJSON200 added in v0.4.0

func (r GetSessionResponse) GetJSON200() *Session

GetJSON200 returns the response for an HTTP 200 `application/json` response

func (GetSessionResponse) GetJSONDefault added in v0.4.0

func (r GetSessionResponse) GetJSONDefault() *DefaultError

GetJSONDefault returns the response for an HTTP default `application/json` response

func (GetSessionResponse) Status

func (r GetSessionResponse) Status() string

Status returns HTTPResponse.Status

func (GetSessionResponse) StatusCode

func (r GetSessionResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetSessionResponseObject added in v0.4.0

type GetSessionResponseObject interface {
	VisitGetSessionResponse(w http.ResponseWriter) error
}

type GetSessiondefaultJSONResponse added in v0.4.0

type GetSessiondefaultJSONResponse struct {
	Body       Error
	StatusCode int
}

func (GetSessiondefaultJSONResponse) VisitGetSessionResponse added in v0.4.0

func (response GetSessiondefaultJSONResponse) VisitGetSessionResponse(w http.ResponseWriter) error

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type InvalidParamFormatError added in v0.4.0

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error added in v0.4.0

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap added in v0.4.0

func (e *InvalidParamFormatError) Unwrap() error

type MiddlewareFunc added in v0.4.0

type MiddlewareFunc func(http.Handler) http.Handler

type NewSession

type NewSession struct {
	// TocZero A Toc is a "piece" in which a TOTP secret gets split.
	TocZero Toc `json:"toc_zero"`

	// Ttl Seconds until the TOTP generation endpoint expires, starting from the first TOTP generated.
	// A session also expires one hour after creation, whichever comes first.
	Ttl *int `json:"ttl,omitempty"`
}

NewSession defines model for NewSession.

type PostToc200Response added in v0.4.0

type PostToc200Response struct {
}

func (PostToc200Response) VisitPostTocResponse added in v0.4.0

func (response PostToc200Response) VisitPostTocResponse(w http.ResponseWriter) error

type PostTocJSONRequestBody

type PostTocJSONRequestBody = AddToc

PostTocJSONRequestBody defines body for PostToc for application/json ContentType.

type PostTocRequestObject added in v0.4.0

type PostTocRequestObject struct {
	Id   string `json:"id"`
	Body *PostTocJSONRequestBody
}

type PostTocResponse

type PostTocResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	// JSONDefault the response for an HTTP default `application/json` response
	JSONDefault *DefaultError
}

func ParsePostTocResponse

func ParsePostTocResponse(rsp *http.Response) (*PostTocResponse, error)

ParsePostTocResponse parses an HTTP response from a PostTocWithResponse call

func (PostTocResponse) ContentType added in v0.4.0

func (r PostTocResponse) ContentType() string

ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers

func (PostTocResponse) GetBody added in v0.4.0

func (r PostTocResponse) GetBody() []byte

GetBody returns the raw response body bytes

func (PostTocResponse) GetJSONDefault added in v0.4.0

func (r PostTocResponse) GetJSONDefault() *DefaultError

GetJSONDefault returns the response for an HTTP default `application/json` response

func (PostTocResponse) Status

func (r PostTocResponse) Status() string

Status returns HTTPResponse.Status

func (PostTocResponse) StatusCode

func (r PostTocResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type PostTocResponseObject added in v0.4.0

type PostTocResponseObject interface {
	VisitPostTocResponse(w http.ResponseWriter) error
}

type PostTocdefaultJSONResponse added in v0.4.0

type PostTocdefaultJSONResponse struct {
	Body       Error
	StatusCode int
}

func (PostTocdefaultJSONResponse) VisitPostTocResponse added in v0.4.0

func (response PostTocdefaultJSONResponse) VisitPostTocResponse(w http.ResponseWriter) error

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type RequiredHeaderError added in v0.4.0

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error added in v0.4.0

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap added in v0.4.0

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError added in v0.4.0

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error added in v0.4.0

func (e *RequiredParamError) Error() string

type ServeMux added in v0.4.0

type ServeMux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	http.Handler
}

ServeMux is an abstraction of http.ServeMux.

type ServerInterface

type ServerInterface interface {
	// CreateSession Start a new session
	// (POST /sessions)
	CreateSession(w http.ResponseWriter, r *http.Request)
	// GetSession Retrieve a session details by its ID
	// (GET /sessions/{id})
	GetSession(w http.ResponseWriter, r *http.Request, id string)
	// PostToc Join a new Toc to an existing session
	// (POST /sessions/{id}/tocs)
	PostToc(w http.ResponseWriter, r *http.Request, id string)
	// GenerateTotp Close the session and generate the TOTP
	// (POST /sessions/{id}/totp)
	GenerateTotp(w http.ResponseWriter, r *http.Request, id string)
}

ServerInterface represents all server handlers.

func NewStrictHandler added in v0.4.0

func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface

func NewStrictHandlerWithOptions added in v0.4.0

func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictHTTPServerOptions) ServerInterface

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CreateSession

func (siw *ServerInterfaceWrapper) CreateSession(w http.ResponseWriter, r *http.Request)

CreateSession operation middleware

func (*ServerInterfaceWrapper) GenerateTotp

func (siw *ServerInterfaceWrapper) GenerateTotp(w http.ResponseWriter, r *http.Request)

GenerateTotp operation middleware

func (*ServerInterfaceWrapper) GetSession

func (siw *ServerInterfaceWrapper) GetSession(w http.ResponseWriter, r *http.Request)

GetSession operation middleware

func (*ServerInterfaceWrapper) PostToc

PostToc operation middleware

type Session

type Session struct {
	// Complete True when enough Tocs have been provided and TOTPs may be generated
	Complete bool `json:"complete"`

	// CreatedAt The time when the session started
	CreatedAt time.Time `json:"created_at"`

	// ExpiresAt When the session will expire: it no longer accepts Tocs nor generates TOTPs.
	// Set to one hour after creation, then shortened to `ttl` seconds after the first TOTP is generated.
	ExpiresAt time.Time `json:"expires_at"`

	// Id The identifier of a session
	Id string `json:"id"`

	// TocGroupId An identifier for the group of Tocs used in this session
	TocGroupId string `json:"toc_group_id"`

	// TocGroupKey The `group_key` of the Toc that started this session.
	// When set, only Tocs signed with it count towards the threshold, so forged Tocs can't break the session.
	TocGroupKey *[]byte `json:"toc_group_key,omitempty"`

	// TocsInGroup The total number of Tocs in the group
	TocsInGroup int `json:"tocs_in_group"`

	// TocsProvided The number of Tocs already provided by consituents to the oracle for this session
	TocsProvided int `json:"tocs_provided"`

	// TocsThreshold The minimum number of Tocs required
	TocsThreshold int `json:"tocs_threshold"`

	// Ttl Seconds until the TOTP generation endpoint expires, starting from the first token generated.
	Ttl int `json:"ttl"`
}

Session defines model for Session.

type SessionCredentials

type SessionCredentials struct {
	// Complete True when enough Tocs have been provided and TOTPs may be generated
	Complete bool `json:"complete"`

	// CreatedAt The time when the session started
	CreatedAt time.Time `json:"created_at"`

	// ExpiresAt When the session will expire: it no longer accepts Tocs nor generates TOTPs.
	// Set to one hour after creation, then shortened to `ttl` seconds after the first TOTP is generated.
	ExpiresAt time.Time `json:"expires_at"`

	// Id The identifier of a session
	Id string `json:"id"`

	// Kek A key used to encrypt the Toc encryption key held by the oracle.
	// This key is kept by the applicant and shared when a TOTP is generated.
	Kek []byte `json:"kek"`

	// Tek A public key used by constituents to encrypt their Tocs before sharing them with the oracle.
	// The applicant receives it when creating a sessions,
	// and must share it with constituents when requesting their approval.
	Tek string `json:"tek"`

	// TocGroupId An identifier for the group of Tocs used in this session
	TocGroupId string `json:"toc_group_id"`

	// TocGroupKey The `group_key` of the Toc that started this session.
	// When set, only Tocs signed with it count towards the threshold, so forged Tocs can't break the session.
	TocGroupKey *[]byte `json:"toc_group_key,omitempty"`

	// TocsInGroup The total number of Tocs in the group
	TocsInGroup int `json:"tocs_in_group"`

	// TocsProvided The number of Tocs already provided by consituents to the oracle for this session
	TocsProvided int `json:"tocs_provided"`

	// TocsThreshold The minimum number of Tocs required
	TocsThreshold int `json:"tocs_threshold"`

	// Ttl Seconds until the TOTP generation endpoint expires, starting from the first token generated.
	Ttl int `json:"ttl"`
}

SessionCredentials Returned when creating a new Session. This object should be kept secret by the applicant, and used when generating the TOTP.

type SessionKeyEncryptionKey

type SessionKeyEncryptionKey struct {
	// Kek A key used to encrypt the Toc encryption key held by the oracle.
	// This key is kept by the applicant and shared when a TOTP is generated.
	Kek []byte `json:"kek"`
}

SessionKeyEncryptionKey defines model for SessionKeyEncryptionKey.

type SessionTocEncryptionKey

type SessionTocEncryptionKey struct {
	// Tek A public key used by constituents to encrypt their Tocs before sharing them with the oracle.
	// The applicant receives it when creating a sessions,
	// and must share it with constituents when requesting their approval.
	Tek string `json:"tek"`
}

SessionTocEncryptionKey defines model for SessionTocEncryptionKey.

type StdHTTPServerOptions added in v0.4.0

type StdHTTPServerOptions struct {
	BaseURL          string
	BaseRouter       ServeMux
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StrictHTTPServerOptions added in v0.4.0

type StrictHTTPServerOptions struct {
	RequestErrorHandlerFunc  func(w http.ResponseWriter, r *http.Request, err error)
	ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StrictHandlerFunc added in v0.4.0

type StrictHandlerFunc = func(ctx context.Context, w http.ResponseWriter, r *http.Request, request any) (any, error)

StrictHandlerFunc and StrictMiddlewareFunc are type aliases rather than distinct named types, so middleware written against one generated package can be shared with every other generated package using the same framework.

type StrictMiddlewareFunc added in v0.4.0

type StrictMiddlewareFunc = func(f StrictHandlerFunc, operationID string) StrictHandlerFunc

type StrictServerInterface added in v0.4.0

type StrictServerInterface interface {
	// CreateSession Start a new session
	// (POST /sessions)
	CreateSession(ctx context.Context, request CreateSessionRequestObject) (CreateSessionResponseObject, error)
	// GetSession Retrieve a session details by its ID
	// (GET /sessions/{id})
	GetSession(ctx context.Context, request GetSessionRequestObject) (GetSessionResponseObject, error)
	// PostToc Join a new Toc to an existing session
	// (POST /sessions/{id}/tocs)
	PostToc(ctx context.Context, request PostTocRequestObject) (PostTocResponseObject, error)
	// GenerateTotp Close the session and generate the TOTP
	// (POST /sessions/{id}/totp)
	GenerateTotp(ctx context.Context, request GenerateTotpRequestObject) (GenerateTotpResponseObject, error)
}

StrictServerInterface represents all server handlers.

type TOTPCode

type TOTPCode struct {
	// SessionExpiresAt The time when this session will expire and cannot be called again
	SessionExpiresAt time.Time `json:"session_expires_at"`

	// Totp The current TOTP
	Totp string `json:"totp"`

	// TotpExpiresAt The time when the current TOTP will expire
	TotpExpiresAt time.Time `json:"totp_expires_at"`
}

TOTPCode defines model for TOTPCode.

type Toc

type Toc struct {
	// GroupId Each Toc is part of a group. Tocs from the same group can reconstruct a secret
	GroupId string `json:"group_id"`

	// GroupKey The Ed25519 public key the dealer generated for this group of Tocs.
	// Tocs dealt by older versions of farMFA have none, and are not protected against forged Tocs.
	GroupKey *[]byte `json:"group_key,omitempty"`

	// GroupSize The number of Tocs in the group
	GroupSize int `json:"group_size"`

	// GroupThreshold The nubmer of Tocs needed to reconstruct the secret
	GroupThreshold int `json:"group_threshold"`

	// Note Free-text to describe the purpose of a Toc
	Note *string `json:"note,omitempty"`

	// Share The actual share that players should keep secret
	Share []byte `json:"share"`

	// Signature The dealer's Ed25519 signature over every other field of this Toc, made with the private key of `group_key`,
	// which the dealer discards after dealing. The oracle ignores Tocs that are not signed with the session's `toc_group_key`.
	Signature *[]byte `json:"signature,omitempty"`

	// TocId A Toc is unique, this ID ensures a Toc is not reused
	TocId []byte `json:"toc_id"`
}

Toc A Toc is a "piece" in which a TOTP secret gets split.

type TooManyValuesForParamError added in v0.4.0

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error added in v0.4.0

type UnescapedCookieParamError added in v0.4.0

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error added in v0.4.0

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap added in v0.4.0

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError added in v0.4.0

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error added in v0.4.0

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap added in v0.4.0

func (e *UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL