api

package
v0.0.0-...-c4f7e29 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PresignImageUploadRequestPerUser ratelimit.BucketName = "PresignImageUploadRequestPerUser"
)

Variables

View Source
var AnonymousUserPromotionCodeAPIRequestSchema = validation.NewSimpleSchema(`
	{
		"type": "object",
		"additionalProperties": false,
		"properties": {
			"session_type": {
				"type": "string",
				"enum": ["cookie", "refresh_token"]
			},
			"refresh_token": { "type": "string" }
		},
		"required": ["session_type"]
	}
`)
View Source
var AnonymousUserPromotionCodeResponseSchema = validation.NewSimpleSchema(`
	{
		"type": "object",
		"properties": {
			"promotion_code": { "type": "string" },
			"expire_at": { "type": "string" }
		},
		"required": ["promotion_code", "expire_at"]
	}
`)
View Source
var AnonymousUserSignupAPIRequestSchema = validation.NewSimpleSchema(`
	{
		"type": "object",
		"additionalProperties": false,
		"properties": {
			"client_id": { "type": "string" },
			"session_type": {
				"type": "string",
				"enum": ["cookie", "refresh_token"]
			},
			"refresh_token": { "type": "string" }
		},
		"required": ["session_type"],
		"allOf": [
			{
				"if": { "properties": { "session_type": { "const": "refresh_token" } } },
				"then": {
					"required": ["client_id"]
				}
			}
		]
	}
`)
View Source
var AnonymousUserSignupAPIResponseSchema = validation.NewSimpleSchema(`
	{
		"type": "object",
		"properties": {
			"token_type": { "type": "string" },
			"access_token": { "type": "string" },
			"refresh_token": { "type": "string" },
			"expires_in": { "type": "integer" }
		},
		"required": ["token_type", "access_token", "expires_in"]
	}
`)
View Source
var AuthenticationFlowV1NonRestfulCreateRequestSchema *validation.SimpleSchema
View Source
var AuthenticationFlowV1NonRestfulGetRequestSchema = validation.NewSimpleSchema(`
	{
		"type": "object",
		"properties": {
			"state_token": { "type": "string" }
		},
		"required": ["state_token"]
	}
`)
View Source
var AuthenticationFlowV1NonRestfulInputRequestSchema = validation.NewSimpleSchema(`
	{
		"type": "object",
		"required": [],
		"properties": {
			"state_token": { "type": "string" }
		},
		"oneOf": [
			{
				"properties": {
					"input": {
						"type": "object"
					}
				},
				"required": ["input"]
			},
			{
				"properties": {
					"batch_input": {
						"type": "array",
						"items": {
							"type": "object"
						},
						"minItems": 1
					}
				},
				"required": ["batch_input"]
			}
		]
	}
`)
View Source
var WorkflowInputRequestSchema = validation.NewSimpleSchema(`
	{
		"type": "object",
		"additionalProperties": false,
		"properties": {
			"input": {
				"type": "object",
				"properties": {
					"kind": { "type": "string" },
					"data": { "type": "object" }
				},
				"required": ["kind", "data"]
			}
		},
		"required": ["input"]
	}
`)
View Source
var WorkflowNewRequestSchema = validation.NewSimpleSchema(`
	{
		"type": "object",
		"additionalProperties": false,
		"properties": {
			"intent": {
				"type": "object",
				"properties": {
					"kind": { "type": "string" },
					"data": { "type": "object" }
				},
				"required": ["kind", "data"]
			},
			"bind_user_agent": { "type": "boolean" }
		},
		"required": ["intent"]
	}
`)
View Source
var WorkflowV2RequestSchema = validation.NewSimpleSchema(`
	{
		"type": "object",
		"properties": {
			"action": {
				"enum": ["create", "input", "batch_input", "get"]
			}
		},
		"required": ["action"],
		"allOf": [
			{
				"if": {
					"properties": {
						"action": { "const": "create" }
					},
					"required": ["action"]
				},
				"then": {
					"properties": {
						"url_query": { "type": "string" },
						"intent": {
							"type": "object",
							"properties": {
								"kind": { "type": "string" },
								"data": { "type": "object" }
							},
							"required": ["kind", "data"]
						},
						"bind_user_agent": { "type": "boolean" },
						"batch_input": {
							"type": "array",
							"items": {
								"type": "object",
								"properties": {
									"kind": { "type": "string" },
									"data": { "type": "object" }
								},
								"required": ["kind", "data"]
							}
						}
					},
					"required": ["intent"]
				}
			},
			{
				"if": {
					"properties": {
						"action": { "const": "input" }
					},
					"required": ["action"]
				},
				"then": {
					"properties": {
						"workflow_id": { "type": "string" },
						"instance_id": { "type": "string" },
						"input": {
							"type": "object",
							"properties": {
								"kind": { "type": "string" },
								"data": { "type": "object" }
							},
							"required": ["kind", "data"]
						}
					},
					"required": ["workflow_id", "instance_id", "input"]
				}
			},
			{
				"if": {
					"properties": {
						"action": { "const": "batch_input" }
					},
					"required": ["action"]
				},
				"then": {
					"properties": {
						"workflow_id": { "type": "string" },
						"instance_id": { "type": "string" },
						"batch_input": {
							"type": "array",
							"items": {
								"type": "object",
								"properties": {
									"kind": { "type": "string" },
									"data": { "type": "object" }
								},
								"required": ["kind", "data"]
							},
							"minItems": 1
						}
					},
					"required": ["workflow_id", "instance_id", "batch_input"]
				}
			},
			{
				"if": {
					"properties": {
						"action": { "const": "get" }
					},
					"required": ["action"]
				},
				"then": {
					"properties": {
						"workflow_id": { "type": "string" },
						"instance_id": { "type": "string" }
					},
					"required": ["workflow_id", "instance_id"]
				}
			}
		]
	}
`)

Functions

func ConfigureAnonymousUserPromotionCodeRoute

func ConfigureAnonymousUserPromotionCodeRoute(route httproute.Route) httproute.Route

func ConfigureAnonymousUserSignupRoute

func ConfigureAnonymousUserSignupRoute(route httproute.Route) httproute.Route

func ConfigureAuthenticationFlowV1CreateRoute

func ConfigureAuthenticationFlowV1CreateRoute(route httproute.Route) httproute.Route

func ConfigureAuthenticationFlowV1GetRoute

func ConfigureAuthenticationFlowV1GetRoute(route httproute.Route) httproute.Route

func ConfigureAuthenticationFlowV1InputRoute

func ConfigureAuthenticationFlowV1InputRoute(route httproute.Route) httproute.Route

func ConfigureAuthenticationFlowV1WebsocketRoute

func ConfigureAuthenticationFlowV1WebsocketRoute(route httproute.Route) httproute.Route

func ConfigurePresignImagesUploadRoute

func ConfigurePresignImagesUploadRoute(route httproute.Route) httproute.Route

func ConfigureWorkflowGetRoute

func ConfigureWorkflowGetRoute(route httproute.Route) httproute.Route

func ConfigureWorkflowInputRoute

func ConfigureWorkflowInputRoute(route httproute.Route) httproute.Route

func ConfigureWorkflowNewRoute

func ConfigureWorkflowNewRoute(route httproute.Route) httproute.Route

func ConfigureWorkflowV2Route

func ConfigureWorkflowV2Route(route httproute.Route) httproute.Route

func ConfigureWorkflowWebsocketRoute

func ConfigureWorkflowWebsocketRoute(route httproute.Route) httproute.Route

func PresignImageUploadRequestBucketSpec

func PresignImageUploadRequestBucketSpec(userID string) ratelimit.BucketSpec

Types

type AnonymousUserHandler

type AnonymousUserHandler interface {
	SignupAnonymousUser(
		req *http.Request,
		clientID string,
		sessionType oauthhandler.WebSessionType,
		refreshToken string,
	) (*oauthhandler.SignupAnonymousUserResult, error)
}

type AnonymousUserPromotionCodeAPIHandler

type AnonymousUserPromotionCodeAPIHandler struct {
	Logger         AnonymousUserPromotionCodeAPIHandlerLogger
	Database       *appdb.Handle
	JSON           JSONResponseWriter
	PromotionCodes PromotionCodeIssuer
}

func (*AnonymousUserPromotionCodeAPIHandler) ServeHTTP

type AnonymousUserPromotionCodeAPIHandlerLogger

type AnonymousUserPromotionCodeAPIHandlerLogger struct{ *log.Logger }

type AnonymousUserPromotionCodeRequest

type AnonymousUserPromotionCodeRequest struct {
	SessionType  oauthhandler.WebSessionType `json:"session_type"`
	RefreshToken string                      `json:"refresh_token"`
}

type AnonymousUserPromotionCodeResponse

type AnonymousUserPromotionCodeResponse struct {
	PromotionCode string    `json:"promotion_code"`
	ExpireAt      time.Time `json:"expire_at"`
}

type AnonymousUserSignupAPIHandler

type AnonymousUserSignupAPIHandler struct {
	Logger               AnonymousUserSignupAPIHandlerLogger
	Database             *appdb.Handle
	JSON                 JSONResponseWriter
	AnonymousUserHandler AnonymousUserHandler
}

func (*AnonymousUserSignupAPIHandler) ServeHTTP

type AnonymousUserSignupAPIHandlerLogger

type AnonymousUserSignupAPIHandlerLogger struct{ *log.Logger }

func NewAnonymousUserSignupAPIHandlerLogger

func NewAnonymousUserSignupAPIHandlerLogger(lf *log.Factory) AnonymousUserSignupAPIHandlerLogger

type AnonymousUserSignupAPIRequest

type AnonymousUserSignupAPIRequest struct {
	ClientID     string                      `json:"client_id"`
	SessionType  oauthhandler.WebSessionType `json:"session_type"`
	RefreshToken string                      `json:"refresh_token"`
}

type AuthenticationFlowV1CookieManager

type AuthenticationFlowV1CookieManager interface {
	GetCookie(r *http.Request, def *httputil.CookieDef) (*http.Cookie, error)
	ClearCookie(def *httputil.CookieDef) *http.Cookie
	ValueCookie(def *httputil.CookieDef, value string) *http.Cookie
}

type AuthenticationFlowV1CreateHandler

type AuthenticationFlowV1CreateHandler struct {
	LoggerFactory  *log.Factory
	RedisHandle    *appredis.Handle
	JSON           JSONResponseWriter
	Cookies        AuthenticationFlowV1CookieManager
	Workflows      AuthenticationFlowV1WorkflowService
	OAuthSessions  AuthenticationFlowV1OAuthSessionService
	UIInfoResolver AuthenticationFlowV1UIInfoResolver
}

func (*AuthenticationFlowV1CreateHandler) ServeHTTP

type AuthenticationFlowV1GetHandler

type AuthenticationFlowV1GetHandler struct {
	LoggerFactory *log.Factory
	RedisHandle   *appredis.Handle
	JSON          JSONResponseWriter
	Workflows     AuthenticationFlowV1WorkflowService
}

func (*AuthenticationFlowV1GetHandler) ServeHTTP

type AuthenticationFlowV1InputHandler

type AuthenticationFlowV1InputHandler struct {
	LoggerFactory *log.Factory
	RedisHandle   *appredis.Handle
	JSON          JSONResponseWriter
	Cookies       AuthenticationFlowV1CookieManager
	Workflows     AuthenticationFlowV1WorkflowService
}

func (*AuthenticationFlowV1InputHandler) ServeHTTP

type AuthenticationFlowV1NonRestfulCreateRequest

type AuthenticationFlowV1NonRestfulCreateRequest struct {
	Type       authflow.FlowType `json:"type,omitempty"`
	Name       string            `json:"name,omitempty"`
	URLQuery   string            `json:"url_query,omitempty"`
	BatchInput []json.RawMessage `json:"batch_input,omitempty"`
}

func (*AuthenticationFlowV1NonRestfulCreateRequest) GetFlowReference

type AuthenticationFlowV1NonRestfulGetRequest

type AuthenticationFlowV1NonRestfulGetRequest struct {
	StateToken string `json:"state_token,omitempty"`
}

type AuthenticationFlowV1NonRestfulInputRequest

type AuthenticationFlowV1NonRestfulInputRequest struct {
	StateToken string            `json:"state_token,omitempty"`
	Input      json.RawMessage   `json:"input,omitempty"`
	BatchInput []json.RawMessage `json:"batch_input,omitempty"`
}

type AuthenticationFlowV1OAuthSessionService

type AuthenticationFlowV1OAuthSessionService interface {
	Get(entryID string) (*oauthsession.Entry, error)
}

type AuthenticationFlowV1UIInfoResolver

type AuthenticationFlowV1UIInfoResolver interface {
	GetOAuthSessionID(req *http.Request, urlQuery string) (string, bool)
	RemoveOAuthSessionID(w http.ResponseWriter, r *http.Request)
	ResolveForUI(r protocol.AuthorizationRequest) (*oidc.UIInfo, error)
}

type AuthenticationFlowV1WebsocketEventStore

type AuthenticationFlowV1WebsocketEventStore interface {
	ChannelName(websocketChannelName string) string
}

type AuthenticationFlowV1WebsocketHandler

type AuthenticationFlowV1WebsocketHandler struct {
	LoggerFactory *log.Factory
	RedisHandle   *appredis.Handle
	OriginMatcher AuthenticationFlowV1WebsocketOriginMatcher
	Events        AuthenticationFlowV1WebsocketEventStore
}

func (*AuthenticationFlowV1WebsocketHandler) Accept

func (*AuthenticationFlowV1WebsocketHandler) OnRedisSubscribe

func (h *AuthenticationFlowV1WebsocketHandler) OnRedisSubscribe(r *http.Request) error

func (*AuthenticationFlowV1WebsocketHandler) ServeHTTP

type AuthenticationFlowV1WebsocketOriginMatcher

type AuthenticationFlowV1WebsocketOriginMatcher interface {
	PrepareOriginMatcher(r *http.Request) (*originmatcher.T, error)
}

type AuthenticationFlowV1WorkflowService

type AuthenticationFlowV1WorkflowService interface {
	CreateNewFlow(intent authflow.PublicFlow, sessionOptions *authflow.SessionOptions) (*authflow.ServiceOutput, error)
	Get(stateToken string) (*authflow.ServiceOutput, error)
	FeedInput(stateToken string, rawMessage json.RawMessage) (*authflow.ServiceOutput, error)
}

type JSONResponseWriter

type JSONResponseWriter interface {
	WriteResponse(rw http.ResponseWriter, resp *api.Response)
}

type PresignImagesUploadHandler

type PresignImagesUploadHandler struct {
	Turbo           TurboResponseWriter
	HTTPProto       httputil.HTTPProto
	HTTPHost        httputil.HTTPHost
	AppID           config.AppID
	RateLimiter     RateLimiter
	PresignProvider PresignProvider
	Logger          PresignImagesUploadHandlerLogger
}

func (*PresignImagesUploadHandler) ServeHTTP

func (h *PresignImagesUploadHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type PresignImagesUploadHandlerLogger

type PresignImagesUploadHandlerLogger struct{ *log.Logger }

func NewPresignImagesUploadHandlerLogger

func NewPresignImagesUploadHandlerLogger(lf *log.Factory) PresignImagesUploadHandlerLogger

type PresignImagesUploadResponse

type PresignImagesUploadResponse struct {
	UploadURL string `json:"upload_url"`
}

type PresignProvider

type PresignProvider interface {
	PresignPostRequest(url *url.URL) error
}

type PromotionCodeIssuer

type PromotionCodeIssuer interface {
	IssuePromotionCode(
		req *http.Request,
		sessionType oauthhandler.WebSessionType,
		refreshToken string,
	) (code string, codeObj *anonymous.PromotionCode, err error)
}

type RateLimiter

type RateLimiter interface {
	Allow(spec ratelimit.BucketSpec) error
}

type TurboResponseWriter

type TurboResponseWriter interface {
	WriteResponse(rw http.ResponseWriter, req *http.Request, resp *api.Response)
}

type WorkflowGetCookieManager

type WorkflowGetCookieManager interface {
	GetCookie(r *http.Request, def *httputil.CookieDef) (*http.Cookie, error)
	ValueCookie(def *httputil.CookieDef, value string) *http.Cookie
}

type WorkflowGetHandler

type WorkflowGetHandler struct {
	JSON      JSONResponseWriter
	Workflows WorkflowGetWorkflowService
	Cookies   WorkflowGetCookieManager
}

func (*WorkflowGetHandler) ServeHTTP

func (h *WorkflowGetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type WorkflowGetWorkflowService

type WorkflowGetWorkflowService interface {
	Get(workflowID string, instanceID string, userAgentID string) (*workflow.ServiceOutput, error)
}

type WorkflowInputCookieManager

type WorkflowInputCookieManager interface {
	GetCookie(r *http.Request, def *httputil.CookieDef) (*http.Cookie, error)
	ValueCookie(def *httputil.CookieDef, value string) *http.Cookie
}

type WorkflowInputHandler

type WorkflowInputHandler struct {
	JSON      JSONResponseWriter
	Workflows WorkflowInputWorkflowService
	Cookies   WorkflowNewCookieManager
}

func (*WorkflowInputHandler) ServeHTTP

func (h *WorkflowInputHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type WorkflowInputRequest

type WorkflowInputRequest struct {
	Input workflow.InputJSON `json:"input"`
}

type WorkflowInputWorkflowService

type WorkflowInputWorkflowService interface {
	Get(workflowID string, instanceID string, userAgentID string) (*workflow.ServiceOutput, error)
	FeedInput(workflowID string, instanceID string, userAgentID string, input workflow.Input) (*workflow.ServiceOutput, error)
}

type WorkflowNewCookieManager

type WorkflowNewCookieManager interface {
	GetCookie(r *http.Request, def *httputil.CookieDef) (*http.Cookie, error)
	ClearCookie(def *httputil.CookieDef) *http.Cookie
	ValueCookie(def *httputil.CookieDef, value string) *http.Cookie
}

type WorkflowNewHandler

type WorkflowNewHandler struct {
	JSON           JSONResponseWriter
	Cookies        WorkflowNewCookieManager
	Workflows      WorkflowNewWorkflowService
	OAuthSessions  WorkflowNewOAuthSessionService
	UIInfoResolver WorkflowNewUIInfoResolver
}

func (*WorkflowNewHandler) ServeHTTP

func (h *WorkflowNewHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type WorkflowNewOAuthSessionService

type WorkflowNewOAuthSessionService interface {
	Get(entryID string) (*oauthsession.Entry, error)
}

type WorkflowNewRequest

type WorkflowNewRequest struct {
	Intent        workflow.IntentJSON `json:"intent"`
	BindUserAgent *bool               `json:"bind_user_agent"`
}

func (*WorkflowNewRequest) SetDefaults

func (c *WorkflowNewRequest) SetDefaults()

type WorkflowNewUIInfoResolver

type WorkflowNewUIInfoResolver interface {
	GetOAuthSessionIDLegacy(req *http.Request, urlQuery string) (string, bool)
	RemoveOAuthSessionID(w http.ResponseWriter, r *http.Request)
	ResolveForUI(r protocol.AuthorizationRequest) (*oidc.UIInfo, error)
}

type WorkflowNewWorkflowService

type WorkflowNewWorkflowService interface {
	CreateNewWorkflow(intent workflow.Intent, sessionOptions *workflow.SessionOptions) (*workflow.ServiceOutput, error)
}

type WorkflowResponse

type WorkflowResponse struct {
	Action   *workflow.WorkflowAction `json:"action"`
	Workflow *workflow.WorkflowOutput `json:"workflow"`
}

type WorkflowUserAgentCookieManager

type WorkflowUserAgentCookieManager interface {
	GetCookie(r *http.Request, def *httputil.CookieDef) (*http.Cookie, error)
	ValueCookie(def *httputil.CookieDef, value string) *http.Cookie
}

type WorkflowV2Action

type WorkflowV2Action string
const (
	WorkflowV2ActionCreate     WorkflowV2Action = "create"
	WorkflowV2ActionInput      WorkflowV2Action = "input"
	WorkflowV2ActionGet        WorkflowV2Action = "get"
	WorkflowV2ActionBatchInput WorkflowV2Action = "batch_input"
)

type WorkflowV2CookieManager

type WorkflowV2CookieManager interface {
	GetCookie(r *http.Request, def *httputil.CookieDef) (*http.Cookie, error)
	ClearCookie(def *httputil.CookieDef) *http.Cookie
	ValueCookie(def *httputil.CookieDef, value string) *http.Cookie
}

type WorkflowV2Handler

type WorkflowV2Handler struct {
	JSON           JSONResponseWriter
	Cookies        WorkflowV2CookieManager
	Workflows      WorkflowV2WorkflowService
	OAuthSessions  WorkflowV2OAuthSessionService
	UIInfoResolver WorkflowV2UIInfoResolver
}

func (*WorkflowV2Handler) ServeHTTP

func (h *WorkflowV2Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type WorkflowV2OAuthSessionService

type WorkflowV2OAuthSessionService interface {
	Get(entryID string) (*oauthsession.Entry, error)
}

type WorkflowV2Request

type WorkflowV2Request struct {
	Action WorkflowV2Action `json:"action"`

	// Create
	URLQuery      string               `json:"url_query,omitempty"`
	Intent        *workflow.IntentJSON `json:"intent,omitempty"`
	BindUserAgent *bool                `json:"bind_user_agent,omitempty"`

	// Input, Get, or BatchInput
	WorkflowID string `json:"workflow_id,omitempty"`
	InstanceID string `json:"instance_id,omitempty"`

	// Input
	Input *workflow.InputJSON `json:"input,omitempty"`

	// BatchInput, or Create
	BatchInput []*workflow.InputJSON `json:"batch_input,omitempty"`
}

func (*WorkflowV2Request) SetDefaults

func (r *WorkflowV2Request) SetDefaults()

type WorkflowV2UIInfoResolver

type WorkflowV2UIInfoResolver interface {
	GetOAuthSessionIDLegacy(req *http.Request, urlQuery string) (string, bool)
	RemoveOAuthSessionID(w http.ResponseWriter, r *http.Request)
	ResolveForUI(r protocol.AuthorizationRequest) (*oidc.UIInfo, error)
}

type WorkflowV2WorkflowService

type WorkflowV2WorkflowService interface {
	CreateNewWorkflow(intent workflow.Intent, sessionOptions *workflow.SessionOptions) (*workflow.ServiceOutput, error)
	Get(workflowID string, instanceID string, userAgentID string) (*workflow.ServiceOutput, error)
	FeedInput(workflowID string, instanceID string, userAgentID string, input workflow.Input) (*workflow.ServiceOutput, error)
}

type WorkflowWebsocketEventStore

type WorkflowWebsocketEventStore interface {
	ChannelName(workflowID string) (string, error)
}

type WorkflowWebsocketHandler

type WorkflowWebsocketHandler struct {
	Events        WorkflowWebsocketEventStore
	LoggerFactory *log.Factory
	RedisHandle   *appredis.Handle
	OriginMatcher WorkflowWebsocketOriginMatcher
}

func (*WorkflowWebsocketHandler) Accept

func (*WorkflowWebsocketHandler) OnRedisSubscribe

func (h *WorkflowWebsocketHandler) OnRedisSubscribe(r *http.Request) error

func (*WorkflowWebsocketHandler) ServeHTTP

type WorkflowWebsocketOriginMatcher

type WorkflowWebsocketOriginMatcher interface {
	PrepareOriginMatcher(r *http.Request) (*originmatcher.T, error)
}

Jump to

Keyboard shortcuts

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