api

package
v0.0.0-...-51c5d51 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package api provides primitives to interact the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

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

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

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 generates requests for CreateSession with any type of body

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 generates requests for GenerateTotp with any type of body

func NewGetSessionRequest

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

NewGetSessionRequest generates requests for GetSession

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 generates requests for PostToc with any type of body

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type AddToc

type AddToc struct {

	// 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)

func (*Client) CreateSessionWithBody

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

func (*Client) GenerateTotp

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

func (*Client) GenerateTotpWithBody

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

func (*Client) GetSession

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

func (*Client) PostToc

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

func (*Client) PostTocWithBody

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

type ClientInterface

type ClientInterface interface {
	// CreateSession request  with any body
	CreateSessionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

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

	// GetSession request
	GetSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error)

	// PostToc request  with any body
	PostTocWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

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

	// GenerateTotp request  with any body
	GenerateTotpWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	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) (*CreateSessionResponse, error)

CreateSessionWithBodyWithResponse request with arbitrary body returning *CreateSessionResponse

func (*ClientWithResponses) CreateSessionWithResponse

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

func (*ClientWithResponses) GenerateTotpWithBodyWithResponse

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

GenerateTotpWithBodyWithResponse request with arbitrary body returning *GenerateTotpResponse

func (*ClientWithResponses) GenerateTotpWithResponse

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

func (*ClientWithResponses) GetSessionWithResponse

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

GetSessionWithResponse request returning *GetSessionResponse

func (*ClientWithResponses) PostTocWithBodyWithResponse

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

PostTocWithBodyWithResponse request with arbitrary body returning *PostTocResponse

func (*ClientWithResponses) PostTocWithResponse

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

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// CreateSession request  with any body
	CreateSessionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader) (*CreateSessionResponse, error)

	CreateSessionWithResponse(ctx context.Context, body CreateSessionJSONRequestBody) (*CreateSessionResponse, error)

	// GetSession request
	GetSessionWithResponse(ctx context.Context, id string) (*GetSessionResponse, error)

	// PostToc request  with any body
	PostTocWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader) (*PostTocResponse, error)

	PostTocWithResponse(ctx context.Context, id string, body PostTocJSONRequestBody) (*PostTocResponse, error)

	// GenerateTotp request  with any body
	GenerateTotpWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader) (*GenerateTotpResponse, error)

	GenerateTotpWithResponse(ctx context.Context, id string, body GenerateTotpJSONRequestBody) (*GenerateTotpResponse, error)
}

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

type CreateSessionJSONBody

type CreateSessionJSONBody NewSession

CreateSessionJSONBody defines parameters for CreateSession.

type CreateSessionJSONRequestBody

type CreateSessionJSONRequestBody CreateSessionJSONBody

CreateSessionJSONRequestBody defines body for CreateSession for application/json ContentType.

type CreateSessionResponse

type CreateSessionResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *SessionCredentials
	JSONDefault  *Error
}

func ParseCreateSessionResponse

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

ParseCreateSessionResponse parses an HTTP response from a CreateSessionWithResponse call

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 DefaultError

type DefaultError Error

DefaultError defines model for DefaultError.

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type Error

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

Error defines model for Error.

type GenerateTotpJSONBody

type GenerateTotpJSONBody SessionKeyEncryptionKey

GenerateTotpJSONBody defines parameters for GenerateTotp.

type GenerateTotpJSONRequestBody

type GenerateTotpJSONRequestBody GenerateTotpJSONBody

GenerateTotpJSONRequestBody defines body for GenerateTotp for application/json ContentType.

type GenerateTotpResponse

type GenerateTotpResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *TOTPCode
	JSONDefault  *Error
}

func ParseGenerateTotpResponse

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

ParseGenerateTotpResponse parses an HTTP response from a GenerateTotpWithResponse call

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 GetSessionResponse

type GetSessionResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Session
	JSONDefault  *Error
}

func ParseGetSessionResponse

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

ParseGetSessionResponse parses an HTTP response from a GetSessionWithResponse call

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 HttpRequestDoer

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

type NewSession

type NewSession struct {

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

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

NewSession defines model for NewSession.

type PostTocJSONBody

type PostTocJSONBody AddToc

PostTocJSONBody defines parameters for PostToc.

type PostTocJSONRequestBody

type PostTocJSONRequestBody PostTocJSONBody

PostTocJSONRequestBody defines body for PostToc for application/json ContentType.

type PostTocResponse

type PostTocResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSONDefault  *Error
}

func ParsePostTocResponse

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

ParsePostTocResponse parses an HTTP response from a PostTocWithResponse call

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 RequestEditorFn

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

RequestEditorFn is the function signature for the RequestEditor callback function

type ServerInterface

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

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) CreateSession

func (w *ServerInterfaceWrapper) CreateSession(ctx echo.Context) error

CreateSession converts echo context to params.

func (*ServerInterfaceWrapper) GenerateTotp

func (w *ServerInterfaceWrapper) GenerateTotp(ctx echo.Context) error

GenerateTotp converts echo context to params.

func (*ServerInterfaceWrapper) GetSession

func (w *ServerInterfaceWrapper) GetSession(ctx echo.Context) error

GetSession converts echo context to params.

func (*ServerInterfaceWrapper) PostToc

func (w *ServerInterfaceWrapper) PostToc(ctx echo.Context) error

PostToc converts echo context to params.

type Session

type Session struct {

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

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

	// When the sessions will expire and no longer accept Tocs
	ExpiresAt *time.Time `json:"expires_at,omitempty"`

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

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

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

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

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

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

Session defines model for Session.

type SessionCredentials

type SessionCredentials struct {
	// Embedded struct due to allOf(#/components/schemas/Session)
	Session `yaml:",inline"`
	// Embedded struct due to allOf(#/components/schemas/SessionTocEncryptionKey)
	SessionTocEncryptionKey `yaml:",inline"`
	// Embedded struct due to allOf(#/components/schemas/SessionKeyEncryptionKey)
	SessionKeyEncryptionKey `yaml:",inline"`
}

SessionCredentials defines model for SessionCredentials.

type SessionKeyEncryptionKey

type SessionKeyEncryptionKey struct {

	// 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 {

	// 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 TOTPCode

type TOTPCode struct {

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

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

	// 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 {

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

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

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

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

	// The actual share that players should keep secret
	Share string `json:"share"`

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

Toc defines model for Toc.

Jump to

Keyboard shortcuts

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