├── .gitignore.license ├── go.mod.license ├── go.sum.license ├── .gitignore ├── id └── id.go ├── db ├── persist │ ├── sql │ │ ├── query │ │ │ ├── users.sql │ │ │ └── sessions.sql │ │ ├── gen │ │ │ ├── models.go │ │ │ ├── users.sql.go │ │ │ ├── db.go │ │ │ └── sessions.sql.go │ │ └── schema │ │ │ └── schema.sql │ ├── sessions.go │ ├── sqlite │ │ ├── sessions.go │ │ ├── sqlite.go │ │ └── users.go │ ├── postgres │ │ ├── user.go │ │ ├── sessions.go │ │ └── postgres.go │ ├── users.go │ └── persist.go └── ephemeral │ ├── kv │ ├── kv.go │ └── auth.go │ ├── bigcache │ └── bigcache.go │ ├── redis │ └── redis.go │ └── ephemeral.go ├── api ├── chatv1 │ └── chat.go ├── errors.go ├── authv1 │ ├── steps.go │ └── auth.go └── api.go ├── sqlc.yaml ├── buf.gen.yaml ├── .github └── workflows │ ├── reuse.yml │ ├── lint.yml │ ├── commit.yml │ ├── publish.yml │ └── commitlint.config.js ├── test └── integration │ ├── configuration.yaml │ └── auth_test.go ├── errwrap └── errors.go ├── main.go ├── config ├── default.yml └── config.go ├── .golangci.yml ├── dynamic_auth ├── dynamic_auth.go ├── choice.go └── form.go ├── .codeclimate.yml ├── logger └── logger.go ├── go.mod ├── gen ├── voice │ └── v1 │ │ ├── voice_hrpc.pb.go │ │ ├── voice_hrpc_client.pb.go │ │ └── voice.pb.go ├── sync │ └── v1 │ │ ├── sync_hrpc.pb.go │ │ └── sync_hrpc_client.pb.go ├── batch │ └── v1 │ │ ├── batch_hrpc.pb.go │ │ ├── batch_hrpc_client.pb.go │ │ └── batch.pb.go ├── mediaproxy │ └── v1 │ │ ├── mediaproxy_hrpc.pb.go │ │ └── mediaproxy_hrpc_client.pb.go ├── profile │ └── v1 │ │ ├── profile_hrpc.pb.go │ │ ├── profile_hrpc_client.pb.go │ │ ├── profile.pb.go │ │ └── stream.pb.go ├── auth │ └── v1 │ │ ├── auth_hrpc.pb.go │ │ └── auth_hrpc_client.pb.go └── emote │ └── v1 │ ├── emote_hrpc.pb.go │ ├── emote.pb.go │ └── emote_hrpc_client.pb.go ├── key └── key.go ├── server └── server.go └── LICENSES └── CC0-1.0.txt /.gitignore.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2021 None 2 | 3 | SPDX-License-Identifier: CC0-1.0 -------------------------------------------------------------------------------- /go.mod.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2021 None 2 | 3 | SPDX-License-Identifier: CC0-1.0 -------------------------------------------------------------------------------- /go.sum.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2021 None 2 | 3 | SPDX-License-Identifier: CC0-1.0 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | legato 2 | harmony-key.pub 3 | harmony-key.pem 4 | configuration.yaml 5 | test.db 6 | -------------------------------------------------------------------------------- /id/id.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package id 6 | 7 | type Generator interface { 8 | NextID() (uint64, error) 9 | } 10 | -------------------------------------------------------------------------------- /db/persist/sql/query/users.sql: -------------------------------------------------------------------------------- 1 | -- SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | -- 3 | -- SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | -- name: GetUserByEmail :one 6 | SELECT 7 | UserID, 8 | Passwd 9 | FROM Users WHERE Email=$1 LIMIT 1; 10 | -------------------------------------------------------------------------------- /api/chatv1/chat.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package chatv1impl 6 | 7 | import chatv1 "github.com/harmony-development/legato/gen/chat/v1" 8 | 9 | type ChatV1 struct { 10 | chatv1.DefaultChatService 11 | } 12 | -------------------------------------------------------------------------------- /sqlc.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | # 3 | # SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | version: 1 6 | packages: 7 | - path: "db/persist/sql/gen" 8 | engine: "postgresql" 9 | sql_package: "pgx/v4" 10 | schema: "./db/persist/sql/schema" 11 | queries: "./db/persist/sql/query" 12 | -------------------------------------------------------------------------------- /db/persist/sql/gen/models.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | // Code generated by sqlc. DO NOT EDIT. 6 | 7 | package gen 8 | 9 | type Authsession struct { 10 | Sessionid string 11 | Userid int64 12 | } 13 | 14 | type User struct { 15 | Userid int64 16 | Email string 17 | Passwd []byte 18 | } 19 | -------------------------------------------------------------------------------- /buf.gen.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | # 3 | # SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | version: v1 6 | managed: 7 | enabled: true 8 | go_package_prefix: 9 | default: github.com/harmony-development/legato/gen 10 | plugins: 11 | - name: go 12 | out: gen 13 | opt: paths=source_relative 14 | - name: go-hrpc 15 | out: gen 16 | opt: paths=source_relative 17 | -------------------------------------------------------------------------------- /.github/workflows/reuse.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: None 2 | # 3 | # SPDX-License-Identifier: CC0-1.0 4 | 5 | name: REUSE Compliance Check 6 | 7 | on: 8 | push: 9 | branches: [ main ] 10 | pull_request: 11 | branches: [ main ] 12 | 13 | jobs: 14 | reuse-lint: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: REUSE Compliance Check 19 | uses: fsfe/reuse-action@v1 20 | -------------------------------------------------------------------------------- /db/persist/sql/query/sessions.sql: -------------------------------------------------------------------------------- 1 | -- SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | -- 3 | -- SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | -- name: GetSession :one 6 | SELECT UserID FROM AuthSessions WHERE SessionID = $1; 7 | 8 | -- name: AddSession :exec 9 | INSERT INTO AuthSessions(UserID, SessionID) VALUES($1, $2); 10 | 11 | -- name: DeleteSession :exec 12 | DELETE FROM AuthSessions WHERE SessionID = $1; 13 | -------------------------------------------------------------------------------- /db/persist/sessions.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-or-later 5 | 6 | package persist 7 | 8 | import "context" 9 | 10 | type Sessions interface { 11 | Get(ctx context.Context, sessionID string) (userID uint64, err error) 12 | Add(ctx context.Context, sessionID string, userID uint64) error 13 | } 14 | -------------------------------------------------------------------------------- /test/integration/configuration.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | # 3 | # SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | address: 0.0.0.0 6 | port: 2289 7 | private-key-path: harmony-key.pub 8 | public-key-path: harmony-key.pem 9 | database: 10 | backend: sqlite 11 | sqlite: 12 | file: test.db 13 | epheremal: 14 | backend: bigcache 15 | debug: 16 | respond-with-errors: true 17 | log-errors: true 18 | -------------------------------------------------------------------------------- /db/ephemeral/kv/kv.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package kv 6 | 7 | import ( 8 | "github.com/harmony-development/legato/db/ephemeral" 9 | "github.com/philippgille/gokv" 10 | ) 11 | 12 | type database struct { 13 | store gokv.Store 14 | } 15 | 16 | func NewKVBackend(store gokv.Store) ephemeral.Database { 17 | return &database{ 18 | store: store, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /errwrap/errors.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package errwrap 6 | 7 | import "fmt" 8 | 9 | func Wrap(err error, wrap string) error { 10 | if err == nil { 11 | return nil 12 | } 13 | 14 | return fmt.Errorf("%s: %w", wrap, err) 15 | } 16 | 17 | func Wrapf(err error, wrap string, args ...interface{}) error { 18 | return Wrap(err, fmt.Sprintf(wrap, args...)) 19 | } 20 | -------------------------------------------------------------------------------- /db/persist/sql/schema/schema.sql: -------------------------------------------------------------------------------- 1 | -- SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | -- 3 | -- SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | CREATE TABLE IF NOT EXISTS AuthSessions ( 6 | SessionID TEXT PRIMARY KEY, 7 | UserID BIGINT NOT NULL 8 | ); 9 | 10 | CREATE TABLE IF NOT EXISTS Users ( 11 | UserID BIGINT PRIMARY KEY NOT NULL, 12 | Email TEXT NOT NULL UNIQUE, 13 | -- Password is a keyword so uhhh 14 | Passwd BYTEA NOT NULL 15 | ); 16 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package main 6 | 7 | import ( 8 | "log" 9 | "os" 10 | 11 | "github.com/harmony-development/legato/logger" 12 | "github.com/harmony-development/legato/server" 13 | ) 14 | 15 | func main() { 16 | l := logger.New(os.Stdin) 17 | 18 | server, err := server.New(l) 19 | if err != nil { 20 | log.Fatal(err) 21 | } 22 | 23 | log.Fatal(server.Listen()) 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: None 2 | # 3 | # SPDX-License-Identifier: CC0-1.0 4 | 5 | name: Lint legato 6 | 7 | on: 8 | push: 9 | branches: 10 | - main 11 | pull_request: 12 | branches: 13 | - main 14 | jobs: 15 | golangci: 16 | name: Lint Legato 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v2 20 | - name: golangci-lint 21 | uses: golangci/golangci-lint-action@v2 22 | with: 23 | version: latest 24 | -------------------------------------------------------------------------------- /.github/workflows/commit.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: None 2 | # 3 | # SPDX-License-Identifier: CC0-1.0 4 | 5 | name: Lint Commit Messages 6 | 7 | on: 8 | push: 9 | branches: [main] 10 | pull_request: 11 | branches: [main] 12 | 13 | jobs: 14 | commitlint: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v2 18 | with: 19 | fetch-depth: 0 20 | - uses: wagoid/commitlint-github-action@v4 21 | with: 22 | configFile: .github/workflows/commitlint.config.js 23 | -------------------------------------------------------------------------------- /config/default.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | # 3 | # SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | address: 0.0.0.0 6 | port: 2289 7 | privateKeyPath: harmony-key.pub 8 | publicKeyPath: harmony-key.pem 9 | idStart: 1627344000 10 | database: 11 | backend: postgres 12 | postgres: 13 | db: harmony 14 | host: 127.0.0.1 15 | password: "" 16 | port: 5432 17 | username: harmony 18 | epheremal: 19 | backend: redis 20 | redis: 21 | hosts: 22 | - 127.0.0.1 23 | password: "" 24 | debug: 25 | respondWithErrors: true 26 | logErrors: true 27 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | # 3 | # SPDX-License-Identifier: AGPL-3.0-or-later 4 | run: 5 | timeout: 5m 6 | skip-files: 7 | - ".*\\.pb\\.go" 8 | - ".*\\.hrpc\\.*.go" 9 | linters: 10 | enable-all: true 11 | disable: 12 | - exhaustivestruct 13 | # deprecated modules 14 | - golint 15 | - maligned 16 | - scopelint 17 | - interfacer 18 | linters-settings: 19 | wrapcheck: 20 | ignoreSigs: 21 | - .Errorf( 22 | - errors.New( 23 | - errors.Unwrap( 24 | - .Wrap( 25 | - .Wrapf( 26 | - .WithMessage( 27 | - .WithMessagef( 28 | - .WithStack( 29 | - api.NewError( 30 | -------------------------------------------------------------------------------- /db/persist/sql/gen/users.sql.go: -------------------------------------------------------------------------------- 1 | // Code generated by sqlc. DO NOT EDIT. 2 | // source: users.sql 3 | 4 | package gen 5 | 6 | import ( 7 | "context" 8 | ) 9 | 10 | const getUserByEmail = `-- name: GetUserByEmail :one 11 | 12 | SELECT 13 | UserID, 14 | Passwd 15 | FROM Users WHERE Email=$1 LIMIT 1 16 | ` 17 | 18 | type GetUserByEmailRow struct { 19 | Userid int64 20 | Passwd []byte 21 | } 22 | 23 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 24 | // 25 | // SPDX-License-Identifier: AGPL-3.0-or-later 26 | 27 | func (q *Queries) GetUserByEmail(ctx context.Context, email string) (GetUserByEmailRow, error) { 28 | row := q.db.QueryRow(ctx, getUserByEmail, email) 29 | var i GetUserByEmailRow 30 | err := row.Scan(&i.Userid, &i.Passwd) 31 | return i, err 32 | } 33 | -------------------------------------------------------------------------------- /db/persist/sql/gen/db.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | // Code generated by sqlc. DO NOT EDIT. 6 | 7 | package gen 8 | 9 | import ( 10 | "context" 11 | 12 | "github.com/jackc/pgconn" 13 | "github.com/jackc/pgx/v4" 14 | ) 15 | 16 | type DBTX interface { 17 | Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error) 18 | Query(context.Context, string, ...interface{}) (pgx.Rows, error) 19 | QueryRow(context.Context, string, ...interface{}) pgx.Row 20 | } 21 | 22 | func New(db DBTX) *Queries { 23 | return &Queries{db: db} 24 | } 25 | 26 | type Queries struct { 27 | db DBTX 28 | } 29 | 30 | func (q *Queries) WithTx(tx pgx.Tx) *Queries { 31 | return &Queries{ 32 | db: tx, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dynamic_auth/dynamic_auth.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package dynamicauth 6 | 7 | import authv1 "github.com/harmony-development/legato/gen/auth/v1" 8 | 9 | type StepType int 10 | 11 | const ( 12 | StepTypeChoice StepType = iota 13 | StepTypeForm 14 | ) 15 | 16 | type Step interface { 17 | ID() string 18 | StepType() StepType 19 | CanGoBack() bool 20 | ToProtoV1() *authv1.AuthStep 21 | } 22 | 23 | type BaseStep struct { 24 | stepType StepType 25 | id string 26 | canGoBack bool 27 | } 28 | 29 | func (s *BaseStep) ID() string { 30 | return s.id 31 | } 32 | 33 | func (s *BaseStep) CanGoBack() bool { 34 | return s.canGoBack 35 | } 36 | 37 | func (s *BaseStep) StepType() StepType { 38 | return s.stepType 39 | } 40 | -------------------------------------------------------------------------------- /db/persist/sqlite/sessions.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package sqlite 6 | 7 | import "context" 8 | 9 | type session struct { 10 | ID string `gorm:"primarykey"` 11 | UserID uint64 `gorm:"not null"` 12 | User *user 13 | } 14 | 15 | type sessions struct { 16 | *database 17 | } 18 | 19 | func (db *sessions) Get(ctx context.Context, sessionID string) (uint64, error) { 20 | var ses session 21 | 22 | err := db.db.First(&ses, "id = ?", sessionID).Error 23 | if err != nil { 24 | return 0, err 25 | } 26 | 27 | return ses.UserID, nil 28 | } 29 | 30 | func (db *sessions) Add(ctx context.Context, sessionID string, userID uint64) error { 31 | return db.db.Create(&session{ 32 | ID: sessionID, 33 | UserID: userID, 34 | }).Error 35 | } 36 | -------------------------------------------------------------------------------- /db/persist/postgres/user.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package postgres 6 | 7 | import ( 8 | "context" 9 | 10 | "github.com/harmony-development/legato/db/persist" 11 | ) 12 | 13 | type users struct { 14 | *database 15 | } 16 | 17 | func (db *users) Add(ctx context.Context, pers persist.UserInformation, ext persist.ExtendedUserInformation) error { 18 | panic("unimplemented") 19 | } 20 | 21 | func (db *users) Get( 22 | ctx context.Context, 23 | id uint64, 24 | ) ( 25 | ui persist.UserInformation, 26 | eui persist.ExtendedUserInformation, 27 | err error, 28 | ) { 29 | panic("unimplemented") 30 | } 31 | 32 | func (db *users) GetLocalByEmail( 33 | ctx context.Context, 34 | email string, 35 | ) ( 36 | persist.UserInformation, 37 | persist.LocalUserInformation, 38 | error, 39 | ) { 40 | panic("unimplemented") 41 | } 42 | -------------------------------------------------------------------------------- /api/errors.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package api 6 | 7 | import harmonytypesv1 "github.com/harmony-development/legato/gen/harmonytypes/v1" 8 | 9 | const ( 10 | ErrorBadAuthID = "h.bad-auth-id" 11 | ErrorBadChoice = "h.bad-auth-choice" 12 | ErrorBadFormData = "h.bad-form-data" 13 | ErrorBadCredentials = "h.bad-credentials" 14 | ErrorBadStep = "h.bad-step" 15 | 16 | ErrorInternalServerError = "h.internal-server-error" 17 | ErrorOther = "h.other" 18 | ) 19 | 20 | type Error harmonytypesv1.Error 21 | 22 | func (e *Error) Error() string { 23 | return e.HumanMessage 24 | } 25 | 26 | func NewError(code string) error { 27 | return &Error{ 28 | Identifier: code, 29 | } 30 | } 31 | 32 | func NewOther(msg string) error { 33 | return &Error{ 34 | Identifier: ErrorOther, 35 | HumanMessage: msg, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /db/persist/postgres/sessions.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-or-later 5 | 6 | package postgres 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | 12 | "github.com/harmony-development/legato/db/persist/sql/gen" 13 | ) 14 | 15 | type sessions struct { 16 | *database 17 | } 18 | 19 | func (db *sessions) Get(ctx context.Context, session string) (uint64, error) { 20 | val, err := db.queries.GetSession(ctx, session) 21 | if err != nil { 22 | return 0, fmt.Errorf("failed to get session %w", err) 23 | } 24 | 25 | return uint64(val), nil 26 | } 27 | 28 | func (db *sessions) Add(ctx context.Context, session string, userID uint64) error { 29 | return fmt.Errorf("failed to add session %w", db.queries.AddSession(ctx, gen.AddSessionParams{ 30 | Userid: int64(userID), 31 | Sessionid: session, 32 | })) 33 | } 34 | -------------------------------------------------------------------------------- /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | # 3 | # SPDX-License-Identifier: AGPL-3.0-or-later 4 | version: "2" # required to adjust maintainability checks 5 | exclude_patterns: 6 | - "gen/" 7 | plugins: 8 | golint: 9 | enabled: true 10 | checks: 11 | GoLint/Comments/DocComments: 12 | enabled: false 13 | checks: 14 | argument-count: 15 | config: 16 | threshold: 4 17 | complex-logic: 18 | config: 19 | threshold: 4 20 | file-lines: 21 | config: 22 | threshold: 250 23 | method-complexity: 24 | config: 25 | threshold: 5 26 | method-count: 27 | config: 28 | threshold: 20 29 | method-lines: 30 | config: 31 | threshold: 25 32 | nested-control-flow: 33 | config: 34 | threshold: 4 35 | return-statements: 36 | config: 37 | threshold: 4 38 | similar-code: 39 | config: 40 | threshold: # language-specific defaults. an override will affect all languages. 41 | identical-code: 42 | config: 43 | threshold: # language-specific defaults. an override will affect all languages. 44 | -------------------------------------------------------------------------------- /dynamic_auth/choice.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package dynamicauth 6 | 7 | import authv1 "github.com/harmony-development/legato/gen/auth/v1" 8 | 9 | type ChoiceStep struct { 10 | *BaseStep 11 | Options []string 12 | optionMap map[string]struct{} 13 | } 14 | 15 | func NewChoiceStep(options []string, id string, canGoBack bool) *ChoiceStep { 16 | optionMap := map[string]struct{}{} 17 | for _, o := range options { 18 | optionMap[o] = struct{}{} 19 | } 20 | 21 | return &ChoiceStep{ 22 | &BaseStep{ 23 | StepTypeChoice, 24 | id, 25 | canGoBack, 26 | }, 27 | options, 28 | optionMap, 29 | } 30 | } 31 | 32 | func (c *ChoiceStep) ToProtoV1() *authv1.AuthStep { 33 | return &authv1.AuthStep{ 34 | CanGoBack: c.canGoBack, 35 | Step: &authv1.AuthStep_Choice_{ 36 | Choice: &authv1.AuthStep_Choice{ 37 | Title: c.id, 38 | Options: c.Options, 39 | }, 40 | }, 41 | } 42 | } 43 | 44 | func (c *ChoiceStep) HasOption(option string) bool { 45 | _, ok := c.optionMap[option] 46 | 47 | return ok 48 | } 49 | -------------------------------------------------------------------------------- /db/ephemeral/kv/auth.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-or-later 5 | 6 | package kv 7 | 8 | import ( 9 | "context" 10 | 11 | "github.com/harmony-development/legato/db/ephemeral" 12 | "github.com/harmony-development/legato/errwrap" 13 | ) 14 | 15 | func (db *database) GetCurrentStep(ctx context.Context, authID string) (string, error) { 16 | var step string 17 | 18 | ok, err := db.store.Get(authID, &step) 19 | if err != nil { 20 | return "", errwrap.Wrapf(err, "failed to get step for ID %s", authID) 21 | } 22 | 23 | if !ok { 24 | return "", ephemeral.ErrStepNotFound 25 | } 26 | 27 | return step, nil 28 | } 29 | 30 | func (db *database) SetStep(ctx context.Context, authID string, step string) error { 31 | return errwrap.Wrapf(db.store.Set(authID, step), "failed to set step to %s for %s", step, authID) 32 | } 33 | 34 | func (db *database) DeleteAuthID(ctx context.Context, authID string) error { 35 | return errwrap.Wrapf(db.store.Delete(authID), "failed to delete auth ID %s", authID) 36 | } 37 | -------------------------------------------------------------------------------- /db/ephemeral/bigcache/bigcache.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package bigcache 6 | 7 | import ( 8 | "context" 9 | 10 | "github.com/apex/log" 11 | "github.com/harmony-development/legato/config" 12 | "github.com/harmony-development/legato/db/ephemeral" 13 | "github.com/harmony-development/legato/db/ephemeral/kv" 14 | "github.com/harmony-development/legato/errwrap" 15 | "github.com/philippgille/gokv/bigcache" 16 | "github.com/philippgille/gokv/encoding" 17 | ) 18 | 19 | type backend struct{} 20 | 21 | func Backend() ephemeral.Backend { 22 | return backend{} 23 | } 24 | 25 | func (backend) Name() string { 26 | return "bigcache" 27 | } 28 | 29 | // New creates a new ephemeral backend using bigcache. 30 | func (backend) New(ctx context.Context, l log.Interface, cfg *config.Config) (ephemeral.Database, error) { 31 | cache, err := bigcache.NewStore(bigcache.Options{ 32 | Codec: encoding.Gob, 33 | }) 34 | if err != nil { 35 | return nil, errwrap.Wrap(err, "failed to create bigcache store") 36 | } 37 | 38 | return kv.NewKVBackend(cache), nil 39 | } 40 | -------------------------------------------------------------------------------- /db/ephemeral/redis/redis.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-or-later 5 | 6 | package redis 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | 12 | "github.com/apex/log" 13 | "github.com/harmony-development/legato/config" 14 | "github.com/harmony-development/legato/db/ephemeral" 15 | "github.com/harmony-development/legato/db/ephemeral/kv" 16 | "github.com/philippgille/gokv/redis" 17 | ) 18 | 19 | type backend struct{} 20 | 21 | func Backend() ephemeral.Backend { 22 | return backend{} 23 | } 24 | 25 | func (backend) Name() string { 26 | return "redis" 27 | } 28 | 29 | // New creates a new ephemeral backend using redis. 30 | func (backend) New(ctx context.Context, l log.Interface, cfg *config.Config) (ephemeral.Database, error) { 31 | rdb, err := redis.NewClient(redis.Options{ 32 | Address: cfg.Epheremal.Redis.Hosts[0], 33 | Password: cfg.Epheremal.Redis.Password, 34 | }) 35 | if err != nil { 36 | return nil, fmt.Errorf("failed to connect to redis %w", err) 37 | } 38 | 39 | return kv.NewKVBackend(rdb), nil 40 | } 41 | -------------------------------------------------------------------------------- /db/persist/users.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-or-later 5 | 6 | package persist 7 | 8 | import "context" 9 | 10 | type UserInformation struct { 11 | ID uint64 12 | Username string 13 | } 14 | 15 | type ( 16 | // ExtendedUserInformation is a general interface for any additional user info. 17 | // (Local and Foreign users have different field associations). 18 | ExtendedUserInformation interface{ IsUserInfo() } 19 | isUserInfo struct{} 20 | ) 21 | 22 | func (isUserInfo) IsUserInfo() {} 23 | 24 | type LocalUserInformation struct { 25 | Email string 26 | Password []byte 27 | 28 | isUserInfo 29 | } 30 | 31 | type ForeignUserInformation struct { 32 | isUserInfo 33 | } 34 | 35 | type Users interface { 36 | Add(ctx context.Context, user UserInformation, info ExtendedUserInformation) error 37 | 38 | Get(ctx context.Context, id uint64) (UserInformation, ExtendedUserInformation, error) 39 | GetLocalByEmail(ctx context.Context, email string) (UserInformation, LocalUserInformation, error) 40 | } 41 | -------------------------------------------------------------------------------- /logger/logger.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package logger 6 | 7 | import ( 8 | "bufio" 9 | "io" 10 | "strings" 11 | 12 | "github.com/apex/log" 13 | "github.com/apex/log/handlers/cli" 14 | "github.com/apex/log/handlers/discard" 15 | ) 16 | 17 | type Logger struct { 18 | inputReader bufio.Reader 19 | log.Interface 20 | } 21 | 22 | func New(input io.ReadWriter) *Logger { 23 | return &Logger{ 24 | Interface: &log.Logger{ 25 | Handler: cli.New(input), 26 | Level: log.DebugLevel, 27 | }, 28 | inputReader: *bufio.NewReader(input), 29 | } 30 | } 31 | 32 | func NewNoop() log.Interface { 33 | return &log.Logger{ 34 | Level: log.DebugLevel, 35 | Handler: discard.New(), 36 | } 37 | } 38 | 39 | func Indent(level log.Level, s string, finish *string) string { 40 | var output strings.Builder 41 | for _, line := range strings.Split(s, "\n") { 42 | output.WriteRune('\n') 43 | output.WriteString(cli.Colors[level].Sprintf(" ║ ") + line) 44 | } 45 | 46 | if finish != nil { 47 | output.WriteString(cli.Colors[level].Sprintf("\n ╚ ") + *finish) 48 | } 49 | 50 | return output.String() 51 | } 52 | -------------------------------------------------------------------------------- /db/persist/sql/gen/sessions.sql.go: -------------------------------------------------------------------------------- 1 | // Code generated by sqlc. DO NOT EDIT. 2 | // source: sessions.sql 3 | 4 | package gen 5 | 6 | import ( 7 | "context" 8 | ) 9 | 10 | const addSession = `-- name: AddSession :exec 11 | INSERT INTO AuthSessions(UserID, SessionID) VALUES($1, $2) 12 | ` 13 | 14 | type AddSessionParams struct { 15 | Userid int64 16 | Sessionid string 17 | } 18 | 19 | func (q *Queries) AddSession(ctx context.Context, arg AddSessionParams) error { 20 | _, err := q.db.Exec(ctx, addSession, arg.Userid, arg.Sessionid) 21 | return err 22 | } 23 | 24 | const deleteSession = `-- name: DeleteSession :exec 25 | DELETE FROM AuthSessions WHERE SessionID = $1 26 | ` 27 | 28 | func (q *Queries) DeleteSession(ctx context.Context, sessionid string) error { 29 | _, err := q.db.Exec(ctx, deleteSession, sessionid) 30 | return err 31 | } 32 | 33 | const getSession = `-- name: GetSession :one 34 | 35 | SELECT UserID FROM AuthSessions WHERE SessionID = $1 36 | ` 37 | 38 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 39 | // 40 | // SPDX-License-Identifier: AGPL-3.0-or-later 41 | 42 | func (q *Queries) GetSession(ctx context.Context, sessionid string) (int64, error) { 43 | row := q.db.QueryRow(ctx, getSession, sessionid) 44 | var userid int64 45 | err := row.Scan(&userid) 46 | return userid, err 47 | } 48 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: None 2 | # 3 | # SPDX-License-Identifier: CC0-1.0 4 | 5 | name: Publish Legato 6 | 7 | on: 8 | workflow_dispatch: 9 | push: 10 | branches: [ main ] 11 | pull_request: 12 | branches: [ main ] 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | name: Build Legato 18 | steps: 19 | - name: Checkout Repo 20 | uses: actions/checkout@v2 21 | - name: Install dependencies 22 | run: | 23 | sudo apt update -yy 24 | sudo apt install -yy --no-install-recommends upx 25 | - name: Download Go 26 | uses: actions/setup-go@v2 27 | with: 28 | go-version: '^1.16.6' 29 | - name: Build Legato 30 | run: | 31 | go build -ldflags="-s -w -X 'github.com/harmony-development/legato/build.GitCommit=$(git rev-list -1 HEAD)'" 32 | - name: Pack with UPX 33 | run: | 34 | upx legato 35 | - name: Upload Release 36 | if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' 37 | env: 38 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 39 | run: | 40 | wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage 41 | chmod +x pyuploadtool-x86_64.AppImage 42 | ./pyuploadtool-x86_64.AppImage legato -------------------------------------------------------------------------------- /dynamic_auth/form.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package dynamicauth 6 | 7 | import ( 8 | "errors" 9 | 10 | authv1 "github.com/harmony-development/legato/gen/auth/v1" 11 | ) 12 | 13 | type FormStep struct { 14 | *BaseStep 15 | Fields []FormField 16 | } 17 | 18 | type FormField struct { 19 | Name string 20 | FieldType string 21 | } 22 | 23 | var ErrInvalidForm = errors.New("invalid form") 24 | 25 | func NewFormStep(fields []FormField, id string, canGoBack bool) *FormStep { 26 | return &FormStep{ 27 | &BaseStep{ 28 | StepTypeForm, 29 | id, 30 | canGoBack, 31 | }, 32 | fields, 33 | } 34 | } 35 | 36 | func (s *FormStep) ToProtoV1() *authv1.AuthStep { 37 | fields := make([]*authv1.AuthStep_Form_FormField, len(s.Fields)) 38 | 39 | for i, f := range s.Fields { 40 | fields[i] = &authv1.AuthStep_Form_FormField{ 41 | Name: f.Name, 42 | Type: f.FieldType, 43 | } 44 | } 45 | 46 | return &authv1.AuthStep{ 47 | Step: &authv1.AuthStep_Form_{ 48 | Form: &authv1.AuthStep_Form{ 49 | Title: s.BaseStep.id, 50 | Fields: fields, 51 | }, 52 | }, 53 | } 54 | } 55 | 56 | func (s *FormStep) ValidateFormV1(form *authv1.NextStepRequest_Form) error { 57 | if len(form.Fields) < len(s.Fields) { 58 | return ErrInvalidForm 59 | } 60 | 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /api/authv1/steps.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package authv1impl 6 | 7 | import dynamicauth "github.com/harmony-development/legato/dynamic_auth" 8 | 9 | // nolint 10 | // this is a protocol-level constant 11 | var initialStep = dynamicauth.NewChoiceStep( 12 | []string{ 13 | "login", 14 | "register", 15 | "other-options", 16 | }, "initial-step", false, 17 | ) 18 | 19 | // nolint 20 | // this is a protocol-level constant 21 | var loginStep = dynamicauth.NewFormStep( 22 | []dynamicauth.FormField{ 23 | {Name: "email", FieldType: "email"}, 24 | {Name: "password", FieldType: "password"}, 25 | }, "login", true, 26 | ) 27 | 28 | // nolint 29 | // this is a protocol-level constant 30 | var registerStep = dynamicauth.NewFormStep( 31 | []dynamicauth.FormField{ 32 | {Name: "email", FieldType: "email"}, 33 | {Name: "username", FieldType: "username"}, 34 | {Name: "password", FieldType: "new-password"}, 35 | }, "register", true, 36 | ) 37 | 38 | // nolint 39 | // this is a protocol-level constant 40 | var otherOptionsStep = dynamicauth.NewChoiceStep( 41 | []string{ 42 | "reset-password", 43 | }, "other-options", true, 44 | ) 45 | 46 | // nolint 47 | // this is a protocol-level constant 48 | var resetPasswordStep = dynamicauth.NewFormStep( 49 | []dynamicauth.FormField{ 50 | {Name: "email", FieldType: "email"}, 51 | }, "reset-password", true, 52 | ) 53 | -------------------------------------------------------------------------------- /db/persist/sqlite/sqlite.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package sqlite 6 | 7 | import ( 8 | "context" 9 | 10 | "github.com/apex/log" 11 | "github.com/harmony-development/legato/config" 12 | "github.com/harmony-development/legato/db/persist" 13 | "github.com/harmony-development/legato/errwrap" 14 | "gorm.io/driver/sqlite" 15 | "gorm.io/gorm" 16 | ) 17 | 18 | type database struct { 19 | db *gorm.DB 20 | } 21 | 22 | type backend struct{} 23 | 24 | func Backend() persist.Backend { 25 | return backend{} 26 | } 27 | 28 | func (b backend) Name() string { 29 | return "sqlite" 30 | } 31 | 32 | // New creates a new persistent backend using sqlite. 33 | func (b backend) New(ctx context.Context, l log.Interface, cfg *config.Config) (persist.Database, error) { 34 | db, err := gorm.Open(sqlite.Open(cfg.Database.SQLite.File), &gorm.Config{}) 35 | if err != nil { 36 | return nil, errwrap.Wrap(err, "failed to open sqlite database") 37 | } 38 | 39 | err = db.AutoMigrate( 40 | &user{}, 41 | &session{}, 42 | &foreignuser{}, 43 | &localuser{}, 44 | ) 45 | if err != nil { 46 | return nil, errwrap.Wrap(err, "database migration failed for sqlite") 47 | } 48 | 49 | return &database{ 50 | db: db, 51 | }, nil 52 | } 53 | 54 | func (d *database) Sessions() persist.Sessions { 55 | return &sessions{d} 56 | } 57 | 58 | func (d *database) Users() persist.Users { 59 | return &users{d} 60 | } 61 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/harmony-development/legato 2 | 3 | go 1.16 4 | 5 | require github.com/apex/log v1.9.0 6 | 7 | require ( 8 | github.com/fatih/color v1.12.0 9 | github.com/gofiber/fiber/v2 v2.18.0 10 | github.com/mattn/go-isatty v0.0.13 // indirect 11 | google.golang.org/protobuf v1.27.1 12 | ) 13 | 14 | require github.com/harmony-development/hrpc v0.0.0-20210907001704-79d3509faa2a 15 | 16 | require ( 17 | github.com/jackc/pgconn v1.10.0 18 | github.com/jackc/pgx/v4 v4.13.0 19 | ) 20 | 21 | require ( 22 | github.com/fsnotify/fsnotify v1.5.1 23 | github.com/go-redis/redis v6.15.9+incompatible // indirect 24 | github.com/kr/pretty v0.2.1 // indirect 25 | github.com/mattn/go-sqlite3 v1.14.8 // indirect 26 | github.com/onsi/gomega v1.15.0 // indirect 27 | github.com/philippgille/gokv v0.6.0 28 | github.com/philippgille/gokv/bigcache v0.6.0 29 | github.com/philippgille/gokv/encoding v0.6.0 30 | github.com/philippgille/gokv/redis v0.6.0 31 | github.com/philippgille/gokv/util v0.6.0 // indirect 32 | github.com/pkg/errors v0.9.1 // indirect 33 | github.com/sony/sonyflake v1.0.0 34 | github.com/thanhpk/randstr v1.0.4 35 | golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 36 | golang.org/x/net v0.0.0-20210825183410-e898025ed96a // indirect 37 | golang.org/x/sys v0.0.0-20210903071746-97244b99971b // indirect 38 | golang.org/x/text v0.3.7 // indirect 39 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b 40 | gorm.io/driver/sqlite v1.1.4 41 | gorm.io/gorm v1.21.14 42 | ) 43 | -------------------------------------------------------------------------------- /db/persist/persist.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-or-later 5 | 6 | package persist 7 | 8 | import ( 9 | "context" 10 | "errors" 11 | 12 | "github.com/apex/log" 13 | "github.com/harmony-development/legato/config" 14 | "github.com/harmony-development/legato/errwrap" 15 | ) 16 | 17 | var ErrDatabaseNotFound = errors.New("backend not found") 18 | 19 | // Database handles access to long-lived data. 20 | type Database interface { 21 | Sessions() Sessions 22 | Users() Users 23 | } 24 | 25 | type Backend interface { 26 | Name() string 27 | New(ctx context.Context, l log.Interface, cfg *config.Config) (Database, error) 28 | } 29 | 30 | type Factory map[string]Backend 31 | 32 | func NewFactory(backends ...Backend) Factory { 33 | res := make(map[string]Backend) 34 | for _, backend := range backends { 35 | res[backend.Name()] = backend 36 | } 37 | 38 | return res 39 | } 40 | 41 | // New creates a new backend by name, 42 | // or returns an error if there isn't one with that name or it fails to construct. 43 | func (b Factory) New(ctx context.Context, name string, l log.Interface, cfg *config.Config) (Database, error) { 44 | backend, ok := b[name] 45 | if !ok { 46 | return nil, errwrap.Wrapf(ErrDatabaseNotFound, "unknown persist backend %s", name) 47 | } 48 | 49 | db, err := backend.New(ctx, l, cfg) 50 | 51 | return db, errwrap.Wrap(err, "failed to create persist backend") 52 | } 53 | -------------------------------------------------------------------------------- /.github/workflows/commitlint.config.js: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | module.exports = { 6 | parserPreset: "conventional-changelog-conventionalcommits", 7 | rules: { 8 | "body-leading-blank": [2, "always"], 9 | "body-max-line-length": [2, "always", 120], 10 | "footer-leading-blank": [2, "always"], 11 | "footer-max-line-length": [2, "always", 120], 12 | "header-max-length": [2, "always", 120], 13 | "scope-case": [2, "always", "lower-case"], 14 | "scope-enum": [ 15 | 2, 16 | "always", 17 | [ 18 | "all", 19 | "codegen", 20 | "db", 21 | "sql", 22 | "logger", 23 | "config", 24 | "api", 25 | "ci", 26 | "docs", 27 | 28 | "auth", 29 | "auth/federation", 30 | 31 | "batch", 32 | "chat", 33 | "emote", 34 | "mediaproxy", 35 | "profile", 36 | "stream", 37 | "sync", 38 | "voice", 39 | ], 40 | ], 41 | "subject-case": [ 42 | 2, 43 | "never", 44 | ["sentence-case", "start-case", "pascal-case", "upper-case"], 45 | ], 46 | "scope-empty": [2, "never"], 47 | "subject-empty": [2, "never"], 48 | "subject-full-stop": [2, "never", "."], 49 | "type-case": [2, "always", "lower-case"], 50 | "type-empty": [2, "never"], 51 | "type-enum": [ 52 | 2, 53 | "always", 54 | [ 55 | "build", 56 | "feat", 57 | "fix", 58 | "perf", 59 | "refactor", 60 | "revert", 61 | "style", 62 | "test", 63 | ], 64 | ], 65 | }, 66 | }; 67 | -------------------------------------------------------------------------------- /gen/voice/v1/voice_hrpc.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package voicev1 8 | 9 | import ( 10 | context "context" 11 | errors "errors" 12 | server "github.com/harmony-development/hrpc/server" 13 | proto "google.golang.org/protobuf/proto" 14 | ) 15 | 16 | type VoiceServiceServer interface { 17 | // Endpoint to connect to a voice channel. 18 | Connect(context.Context, *ConnectRequest) (*ConnectResponse, error) 19 | // Endpoint to stream states of a voice connection. 20 | StreamState(context.Context, *StreamStateRequest) (chan *StreamStateResponse, error) 21 | } 22 | 23 | type DefaultVoiceService struct{} 24 | 25 | func (DefaultVoiceService) Connect(context.Context, *ConnectRequest) (*ConnectResponse, error) { 26 | return nil, errors.New("unimplemented") 27 | } 28 | func (DefaultVoiceService) StreamState(context.Context, *StreamStateRequest) (chan *StreamStateResponse, error) { 29 | return nil, errors.New("unimplemented") 30 | } 31 | 32 | type VoiceServiceHandler struct { 33 | Server VoiceServiceServer 34 | } 35 | 36 | func NewVoiceServiceHandler(server VoiceServiceServer) *VoiceServiceHandler { 37 | return &VoiceServiceHandler{Server: server} 38 | } 39 | func (h *VoiceServiceHandler) Name() string { 40 | return "VoiceService" 41 | } 42 | func (h *VoiceServiceHandler) Routes() map[string]server.RawHandler { 43 | return map[string]server.RawHandler{ 44 | "/protocol.voice.v1.VoiceService.Connect/": server.NewUnaryHandler(&ConnectRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 45 | return h.Server.Connect(c, req.(*ConnectRequest)) 46 | }), 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /db/ephemeral/ephemeral.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-or-later 5 | 6 | package ephemeral 7 | 8 | import ( 9 | "context" 10 | "errors" 11 | 12 | "github.com/apex/log" 13 | "github.com/harmony-development/legato/config" 14 | "github.com/harmony-development/legato/errwrap" 15 | ) 16 | 17 | type authDB interface { 18 | GetCurrentStep(ctx context.Context, authID string) (string, error) 19 | SetStep(ctx context.Context, authID string, step string) error 20 | DeleteAuthID(ctx context.Context, authID string) error 21 | } 22 | 23 | // Database handles access to short-lived data and pubsub. 24 | type Database interface { 25 | authDB 26 | } 27 | 28 | var ( 29 | ErrDatabaseNotFound = errors.New("database not found") 30 | ErrStepNotFound = errors.New("step not found") 31 | ) 32 | 33 | type Backend interface { 34 | Name() string 35 | New(ctx context.Context, l log.Interface, cfg *config.Config) (Database, error) 36 | } 37 | 38 | type Factory map[string]Backend 39 | 40 | func NewFactory(backends ...Backend) Factory { 41 | res := make(map[string]Backend) 42 | for _, backend := range backends { 43 | res[backend.Name()] = backend 44 | } 45 | 46 | return res 47 | } 48 | 49 | // New creates a new backend by name, 50 | // or returns an error if there isn't one with that name or it fails to construct. 51 | func (b Factory) New(ctx context.Context, name string, l log.Interface, cfg *config.Config) (Database, error) { 52 | backend, ok := b[name] 53 | if !ok { 54 | return nil, errwrap.Wrap(ErrDatabaseNotFound, name) 55 | } 56 | 57 | db, err := backend.New(ctx, l, cfg) 58 | 59 | return db, errwrap.Wrap(err, "failed to create backend") 60 | } 61 | -------------------------------------------------------------------------------- /db/persist/postgres/postgres.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-or-later 5 | 6 | package postgres 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | 12 | "github.com/apex/log" 13 | "github.com/harmony-development/legato/config" 14 | "github.com/harmony-development/legato/db/persist" 15 | "github.com/harmony-development/legato/db/persist/sql/gen" 16 | "github.com/harmony-development/legato/errwrap" 17 | "github.com/jackc/pgx/v4/pgxpool" 18 | ) 19 | 20 | type database struct { 21 | queries *gen.Queries 22 | 23 | s *sessions 24 | u *users 25 | } 26 | 27 | type backend struct{} 28 | 29 | func Backend() persist.Backend { 30 | return backend{} 31 | } 32 | 33 | func (b backend) Name() string { 34 | return "postgres" 35 | } 36 | 37 | // New creates a new persistent backend using postgres. 38 | func (b backend) New(ctx context.Context, l log.Interface, cfg *config.Config) (persist.Database, error) { 39 | username, password, host, port, db := 40 | cfg.Database.Postgres.Username, 41 | cfg.Database.Postgres.Password, 42 | cfg.Database.Postgres.Host, 43 | cfg.Database.Postgres.Port, 44 | cfg.Database.Postgres.DB 45 | 46 | connString := fmt.Sprintf( 47 | "postgres://%s:%s@%s:%d/%s", 48 | username, 49 | password, 50 | host, 51 | port, 52 | db, 53 | ) 54 | 55 | conn, err := pgxpool.Connect(ctx, connString) 56 | if err != nil { 57 | return nil, errwrap.Wrap(err, "failed to connect to postgres") 58 | } 59 | 60 | q := gen.New(conn) 61 | 62 | return &database{ 63 | queries: q, 64 | }, nil 65 | } 66 | 67 | func (d *database) Sessions() persist.Sessions { 68 | return d.s 69 | } 70 | 71 | func (d *database) Users() persist.Users { 72 | return d.u 73 | } 74 | -------------------------------------------------------------------------------- /gen/sync/v1/sync_hrpc.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package syncv1 8 | 9 | import ( 10 | context "context" 11 | errors "errors" 12 | server "github.com/harmony-development/hrpc/server" 13 | proto "google.golang.org/protobuf/proto" 14 | ) 15 | 16 | type PostboxServiceServer interface { 17 | // Endpoint to pull events. 18 | Pull(context.Context, *PullRequest) (*PullResponse, error) 19 | // Endpoint to push events. 20 | Push(context.Context, *PushRequest) (*PushResponse, error) 21 | } 22 | 23 | type DefaultPostboxService struct{} 24 | 25 | func (DefaultPostboxService) Pull(context.Context, *PullRequest) (*PullResponse, error) { 26 | return nil, errors.New("unimplemented") 27 | } 28 | func (DefaultPostboxService) Push(context.Context, *PushRequest) (*PushResponse, error) { 29 | return nil, errors.New("unimplemented") 30 | } 31 | 32 | type PostboxServiceHandler struct { 33 | Server PostboxServiceServer 34 | } 35 | 36 | func NewPostboxServiceHandler(server PostboxServiceServer) *PostboxServiceHandler { 37 | return &PostboxServiceHandler{Server: server} 38 | } 39 | func (h *PostboxServiceHandler) Name() string { 40 | return "PostboxService" 41 | } 42 | func (h *PostboxServiceHandler) Routes() map[string]server.RawHandler { 43 | return map[string]server.RawHandler{ 44 | "/protocol.sync.v1.PostboxService.Pull/": server.NewUnaryHandler(&PullRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 45 | return h.Server.Pull(c, req.(*PullRequest)) 46 | }), 47 | "/protocol.sync.v1.PostboxService.Push/": server.NewUnaryHandler(&PushRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 48 | return h.Server.Push(c, req.(*PushRequest)) 49 | }), 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /gen/batch/v1/batch_hrpc.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package batchv1 8 | 9 | import ( 10 | context "context" 11 | errors "errors" 12 | server "github.com/harmony-development/hrpc/server" 13 | proto "google.golang.org/protobuf/proto" 14 | ) 15 | 16 | type BatchServiceServer interface { 17 | // Batch requests. 18 | // Does not support batching stream requests. 19 | // Batched requests should be verified and an error should be thrown if they 20 | // are invalid. 21 | Batch(context.Context, *BatchRequest) (*BatchResponse, error) 22 | // BatchSame allows batching for requests using the same endpoint. 23 | // This allows for additional network optimizations since the endpoint doesn't 24 | // have to be sent for every request. 25 | BatchSame(context.Context, *BatchSameRequest) (*BatchSameResponse, error) 26 | } 27 | 28 | type DefaultBatchService struct{} 29 | 30 | func (DefaultBatchService) Batch(context.Context, *BatchRequest) (*BatchResponse, error) { 31 | return nil, errors.New("unimplemented") 32 | } 33 | func (DefaultBatchService) BatchSame(context.Context, *BatchSameRequest) (*BatchSameResponse, error) { 34 | return nil, errors.New("unimplemented") 35 | } 36 | 37 | type BatchServiceHandler struct { 38 | Server BatchServiceServer 39 | } 40 | 41 | func NewBatchServiceHandler(server BatchServiceServer) *BatchServiceHandler { 42 | return &BatchServiceHandler{Server: server} 43 | } 44 | func (h *BatchServiceHandler) Name() string { 45 | return "BatchService" 46 | } 47 | func (h *BatchServiceHandler) Routes() map[string]server.RawHandler { 48 | return map[string]server.RawHandler{ 49 | "/protocol.batch.v1.BatchService.Batch/": server.NewUnaryHandler(&BatchRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 50 | return h.Server.Batch(c, req.(*BatchRequest)) 51 | }), 52 | "/protocol.batch.v1.BatchService.BatchSame/": server.NewUnaryHandler(&BatchSameRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 53 | return h.Server.BatchSame(c, req.(*BatchSameRequest)) 54 | }), 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /api/api.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package api 6 | 7 | import ( 8 | "errors" 9 | "net/http" 10 | 11 | "github.com/apex/log" 12 | "github.com/gofiber/fiber/v2" 13 | "github.com/harmony-development/hrpc/server" 14 | "github.com/harmony-development/legato/config" 15 | "github.com/harmony-development/legato/errwrap" 16 | harmonytypesv1 "github.com/harmony-development/legato/gen/harmonytypes/v1" 17 | ) 18 | 19 | // FiberRPCHandler converts a RPC handler to a Fiber handler. 20 | func FiberRPCHandler(handler server.RawHandler) fiber.Handler { 21 | return func(c *fiber.Ctx) error { 22 | resp, err := handler(c.Context(), c.Request()) 23 | if err != nil { 24 | return err 25 | } 26 | 27 | return errwrap.Wrap(c.Send(resp), "failed to send response") 28 | } 29 | } 30 | 31 | func RegisterHandlers(app *fiber.App, l log.Interface, cfg *config.Config, all ...server.HRPCServiceHandler) { 32 | l.Info("Registering services...") 33 | 34 | for _, handler := range all { 35 | serviceLog := l.WithFields(log.Fields{ 36 | "service": handler.Name(), 37 | }) 38 | for path, handler := range handler.Routes() { 39 | serviceLog.Infof("Registered %s", path) 40 | app.All(path, FiberRPCHandler(handler)) 41 | } 42 | } 43 | } 44 | 45 | func newHarmonyError(cfg *config.Config, e error) (int, *harmonytypesv1.Error) { 46 | var herr *Error 47 | if errors.As(e, &herr) { 48 | return http.StatusBadRequest, &harmonytypesv1.Error{ 49 | Identifier: herr.Identifier, 50 | HumanMessage: herr.HumanMessage, 51 | MoreDetails: herr.MoreDetails, 52 | } 53 | } 54 | 55 | err := &harmonytypesv1.Error{ 56 | Identifier: ErrorInternalServerError, 57 | } 58 | if cfg.Debug.RespondWithErrors { 59 | err.HumanMessage = e.Error() 60 | } 61 | 62 | return http.StatusInternalServerError, err 63 | } 64 | 65 | func FiberErrorHandler(l log.Interface, cfg *config.Config) fiber.ErrorHandler { 66 | return func(c *fiber.Ctx, e error) error { 67 | if cfg.Debug.LogErrors && e != nil { 68 | l.WithError(e).WithFields(log.Fields{ 69 | "path": c.OriginalURL(), 70 | "error": e, 71 | }).Error("error in http handler") 72 | } 73 | 74 | contentType := string(c.Request().Header.Peek("Content-Type")) 75 | statusCode, err := newHarmonyError(cfg, e) 76 | 77 | data, marshalErr := server.MarshalHRPC(err, contentType) 78 | if marshalErr != nil { 79 | return errwrap.Wrapf(marshalErr, "failed to marshal error: (%s, %v)", contentType, e) 80 | } 81 | 82 | // nolint 83 | return c.Status(statusCode).Send(data) 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /key/key.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package key 6 | 7 | import ( 8 | "crypto/ed25519" 9 | "crypto/rand" 10 | "io" 11 | "os" 12 | 13 | "github.com/harmony-development/legato/errwrap" 14 | ) 15 | 16 | type Manager interface { 17 | GetPublicKey() []byte 18 | } 19 | 20 | type Ed25519KeyManager struct { 21 | pubKey ed25519.PublicKey 22 | privKey ed25519.PrivateKey 23 | } 24 | 25 | func NewEd25519KeyManagerFromFile(privKeyPath string, pubKeyPath string) (Manager, error) { 26 | var privKeyFile, pubKeyFile *os.File 27 | 28 | var err error 29 | 30 | if privKeyFile, err = os.Open(privKeyPath); err != nil { 31 | return nil, errwrap.Wrap(err, "failed to open private key file") 32 | } 33 | 34 | if pubKeyFile, err = os.Open(pubKeyPath); err != nil { 35 | return nil, errwrap.Wrap(err, "failed to open public key file") 36 | } 37 | 38 | return NewEd25519KeyManager(privKeyFile, pubKeyFile) 39 | } 40 | 41 | func NewEd25519KeyManager(privKeyReader io.Reader, pubKeyReader io.Reader) (Manager, error) { 42 | privKey, err := io.ReadAll(privKeyReader) 43 | if err != nil { 44 | return nil, errwrap.Wrap(err, "failed to read private key") 45 | } 46 | 47 | pubKey, err := io.ReadAll(pubKeyReader) 48 | if err != nil { 49 | return nil, errwrap.Wrap(err, "failed to read public key") 50 | } 51 | 52 | return &Ed25519KeyManager{ 53 | privKey: ed25519.PrivateKey(privKey), 54 | pubKey: ed25519.PublicKey(pubKey), 55 | }, nil 56 | } 57 | 58 | func (manager *Ed25519KeyManager) GetPublicKey() []byte { 59 | return manager.pubKey 60 | } 61 | 62 | func WriteEd25519KeysToFile(privKeyPath string, pubKeyPath string) error { 63 | privFile, err := os.Create(privKeyPath) 64 | if err != nil { 65 | return errwrap.Wrap(err, "failed to create private key file") 66 | } 67 | defer privFile.Close() 68 | 69 | pubFile, err := os.Create(pubKeyPath) 70 | if err != nil { 71 | return errwrap.Wrap(err, "failed to create public key file") 72 | } 73 | defer pubFile.Close() 74 | 75 | return WriteEd25519Keys(privFile, pubFile) 76 | } 77 | 78 | func WriteEd25519Keys(privKeyWriter io.Writer, pubKeyWriter io.Writer) error { 79 | pub, priv, err := ed25519.GenerateKey(rand.Reader) 80 | if err != nil { 81 | return errwrap.Wrap(err, "failed to generate ed25519 key paid") 82 | } 83 | 84 | if _, err := privKeyWriter.Write(priv); err != nil { 85 | return errwrap.Wrap(err, "failed to write private key") 86 | } 87 | 88 | if _, err := pubKeyWriter.Write(pub); err != nil { 89 | return errwrap.Wrap(err, "failed to write public key") 90 | } 91 | 92 | return nil 93 | } 94 | -------------------------------------------------------------------------------- /gen/voice/v1/voice_hrpc_client.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package voicev1 8 | 9 | import ( 10 | bytes "bytes" 11 | context "context" 12 | errors "errors" 13 | proto "google.golang.org/protobuf/proto" 14 | ioutil "io/ioutil" 15 | http "net/http" 16 | httptest "net/http/httptest" 17 | ) 18 | 19 | type VoiceServiceClient interface { 20 | // Endpoint to connect to a voice channel. 21 | Connect(context.Context, *ConnectRequest) (*ConnectResponse, error) 22 | // Endpoint to stream states of a voice connection. 23 | StreamState(context.Context, *StreamStateRequest) (chan *StreamStateResponse, error) 24 | } 25 | 26 | type HTTPVoiceServiceClient struct { 27 | Client http.Client 28 | BaseURL string 29 | } 30 | 31 | func (client *HTTPVoiceServiceClient) Connect(req *ConnectRequest) (*ConnectResponse, error) { 32 | data, marshalErr := proto.Marshal(req) 33 | if marshalErr != nil { 34 | return nil, marshalErr 35 | } 36 | reader := bytes.NewReader(data) 37 | resp, err := client.Client.Post(client.BaseURL+"/protocol.voice.v1.VoiceService.Connect/", "application/hrpc", reader) 38 | if err != nil { 39 | return nil, err 40 | } 41 | body, err := ioutil.ReadAll(resp.Body) 42 | if err != nil { 43 | return nil, err 44 | } 45 | ret := &ConnectResponse{} 46 | unmarshalErr := proto.Unmarshal(body, ret) 47 | if unmarshalErr != nil { 48 | return nil, unmarshalErr 49 | } 50 | return ret, nil 51 | } 52 | func (client *HTTPVoiceServiceClient) StreamState(req *StreamStateRequest) (chan *StreamStateResponse, error) { 53 | return nil, errors.New("unimplemented") 54 | } 55 | 56 | type HTTPTestVoiceServiceClient struct { 57 | Client interface { 58 | Test(*http.Request, ...int) (*http.Response, error) 59 | } 60 | } 61 | 62 | func (client *HTTPTestVoiceServiceClient) Connect(req *ConnectRequest) (*ConnectResponse, error) { 63 | data, marshalErr := proto.Marshal(req) 64 | if marshalErr != nil { 65 | return nil, marshalErr 66 | } 67 | reader := bytes.NewReader(data) 68 | testreq := httptest.NewRequest("POST", "/protocol.voice.v1.VoiceService.Connect/", reader) 69 | resp, err := client.Client.Test(testreq) 70 | if err != nil { 71 | return nil, err 72 | } 73 | body, err := ioutil.ReadAll(resp.Body) 74 | if err != nil { 75 | return nil, err 76 | } 77 | ret := &ConnectResponse{} 78 | unmarshalErr := proto.Unmarshal(body, ret) 79 | if unmarshalErr != nil { 80 | return nil, unmarshalErr 81 | } 82 | return ret, nil 83 | } 84 | func (client *HTTPTestVoiceServiceClient) StreamState(req *StreamStateRequest) (chan *StreamStateResponse, error) { 85 | return nil, errors.New("unimplemented") 86 | } 87 | -------------------------------------------------------------------------------- /gen/mediaproxy/v1/mediaproxy_hrpc.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package mediaproxyv1 8 | 9 | import ( 10 | context "context" 11 | errors "errors" 12 | server "github.com/harmony-development/hrpc/server" 13 | proto "google.golang.org/protobuf/proto" 14 | ) 15 | 16 | type MediaProxyServiceServer interface { 17 | // Endpoint to fetch metadata for a URL. 18 | FetchLinkMetadata(context.Context, *FetchLinkMetadataRequest) (*FetchLinkMetadataResponse, error) 19 | // Endpoint to instant view a website URL. 20 | InstantView(context.Context, *InstantViewRequest) (*InstantViewResponse, error) 21 | // Endpoint to query if the server can generate an instant view for a website URL. 22 | CanInstantView(context.Context, *CanInstantViewRequest) (*CanInstantViewResponse, error) 23 | } 24 | 25 | type DefaultMediaProxyService struct{} 26 | 27 | func (DefaultMediaProxyService) FetchLinkMetadata(context.Context, *FetchLinkMetadataRequest) (*FetchLinkMetadataResponse, error) { 28 | return nil, errors.New("unimplemented") 29 | } 30 | func (DefaultMediaProxyService) InstantView(context.Context, *InstantViewRequest) (*InstantViewResponse, error) { 31 | return nil, errors.New("unimplemented") 32 | } 33 | func (DefaultMediaProxyService) CanInstantView(context.Context, *CanInstantViewRequest) (*CanInstantViewResponse, error) { 34 | return nil, errors.New("unimplemented") 35 | } 36 | 37 | type MediaProxyServiceHandler struct { 38 | Server MediaProxyServiceServer 39 | } 40 | 41 | func NewMediaProxyServiceHandler(server MediaProxyServiceServer) *MediaProxyServiceHandler { 42 | return &MediaProxyServiceHandler{Server: server} 43 | } 44 | func (h *MediaProxyServiceHandler) Name() string { 45 | return "MediaProxyService" 46 | } 47 | func (h *MediaProxyServiceHandler) Routes() map[string]server.RawHandler { 48 | return map[string]server.RawHandler{ 49 | "/protocol.mediaproxy.v1.MediaProxyService.FetchLinkMetadata/": server.NewUnaryHandler(&FetchLinkMetadataRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 50 | return h.Server.FetchLinkMetadata(c, req.(*FetchLinkMetadataRequest)) 51 | }), 52 | "/protocol.mediaproxy.v1.MediaProxyService.InstantView/": server.NewUnaryHandler(&InstantViewRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 53 | return h.Server.InstantView(c, req.(*InstantViewRequest)) 54 | }), 55 | "/protocol.mediaproxy.v1.MediaProxyService.CanInstantView/": server.NewUnaryHandler(&CanInstantViewRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 56 | return h.Server.CanInstantView(c, req.(*CanInstantViewRequest)) 57 | }), 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /gen/profile/v1/profile_hrpc.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package profilev1 8 | 9 | import ( 10 | context "context" 11 | errors "errors" 12 | server "github.com/harmony-development/hrpc/server" 13 | proto "google.golang.org/protobuf/proto" 14 | ) 15 | 16 | type ProfileServiceServer interface { 17 | // Gets a user's profile. 18 | GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) 19 | // Updates the user's profile. 20 | UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) 21 | // Gets app data for a user (this can be used to store user preferences which 22 | // is synchronized across devices). 23 | GetAppData(context.Context, *GetAppDataRequest) (*GetAppDataResponse, error) 24 | // Sets the app data for a user. 25 | SetAppData(context.Context, *SetAppDataRequest) (*SetAppDataResponse, error) 26 | } 27 | 28 | type DefaultProfileService struct{} 29 | 30 | func (DefaultProfileService) GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) { 31 | return nil, errors.New("unimplemented") 32 | } 33 | func (DefaultProfileService) UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) { 34 | return nil, errors.New("unimplemented") 35 | } 36 | func (DefaultProfileService) GetAppData(context.Context, *GetAppDataRequest) (*GetAppDataResponse, error) { 37 | return nil, errors.New("unimplemented") 38 | } 39 | func (DefaultProfileService) SetAppData(context.Context, *SetAppDataRequest) (*SetAppDataResponse, error) { 40 | return nil, errors.New("unimplemented") 41 | } 42 | 43 | type ProfileServiceHandler struct { 44 | Server ProfileServiceServer 45 | } 46 | 47 | func NewProfileServiceHandler(server ProfileServiceServer) *ProfileServiceHandler { 48 | return &ProfileServiceHandler{Server: server} 49 | } 50 | func (h *ProfileServiceHandler) Name() string { 51 | return "ProfileService" 52 | } 53 | func (h *ProfileServiceHandler) Routes() map[string]server.RawHandler { 54 | return map[string]server.RawHandler{ 55 | "/protocol.profile.v1.ProfileService.GetProfile/": server.NewUnaryHandler(&GetProfileRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 56 | return h.Server.GetProfile(c, req.(*GetProfileRequest)) 57 | }), 58 | "/protocol.profile.v1.ProfileService.UpdateProfile/": server.NewUnaryHandler(&UpdateProfileRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 59 | return h.Server.UpdateProfile(c, req.(*UpdateProfileRequest)) 60 | }), 61 | "/protocol.profile.v1.ProfileService.GetAppData/": server.NewUnaryHandler(&GetAppDataRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 62 | return h.Server.GetAppData(c, req.(*GetAppDataRequest)) 63 | }), 64 | "/protocol.profile.v1.ProfileService.SetAppData/": server.NewUnaryHandler(&SetAppDataRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 65 | return h.Server.SetAppData(c, req.(*SetAppDataRequest)) 66 | }), 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /db/persist/sqlite/users.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package sqlite 6 | 7 | import ( 8 | "context" 9 | 10 | "github.com/harmony-development/legato/db/persist" 11 | ) 12 | 13 | type user struct { 14 | ID uint64 `gorm:"primarykey"` 15 | Username string `gorm:"unique"` 16 | 17 | Local *localuser 18 | Foreign *foreignuser 19 | } 20 | 21 | type localuser struct { 22 | Email string `gorm:"unique"` 23 | Password []byte 24 | 25 | UserID uint64 26 | ID int `gorm:"primarykey"` 27 | } 28 | 29 | type foreignuser struct { 30 | UserID uint64 31 | ID int `gorm:"primarykey"` 32 | } 33 | 34 | type users struct { 35 | *database 36 | } 37 | 38 | func (db *users) Add(ctx context.Context, pers persist.UserInformation, ext persist.ExtendedUserInformation) error { 39 | switch data := ext.(type) { 40 | case persist.ForeignUserInformation: 41 | return db.db.Create(&user{ 42 | ID: pers.ID, 43 | Username: pers.Username, 44 | Foreign: &foreignuser{}, 45 | }).Error 46 | case persist.LocalUserInformation: 47 | return db.db.Create(&user{ 48 | ID: pers.ID, 49 | Username: pers.Username, 50 | Local: &localuser{ 51 | Email: data.Email, 52 | Password: data.Password, 53 | }, 54 | }).Error 55 | default: 56 | panic("unhandled case") 57 | } 58 | } 59 | 60 | func (db *users) Get( 61 | ctx context.Context, 62 | id uint64, 63 | ) ( 64 | persist.UserInformation, 65 | persist.ExtendedUserInformation, 66 | error, 67 | ) { 68 | var user user 69 | 70 | err := db.db.Preload("Local").Preload("Foreign").First(&user, "id = ?", id).Error 71 | if err != nil { 72 | return persist.UserInformation{}, nil, err 73 | } 74 | 75 | userInfo := persist.UserInformation{ 76 | ID: user.ID, 77 | Username: user.Username, 78 | } 79 | 80 | var extendedUserInfo persist.ExtendedUserInformation 81 | 82 | switch { 83 | case user.Local != nil: 84 | extendedUserInfo = persist.LocalUserInformation{ 85 | Email: user.Local.Email, 86 | Password: user.Local.Password, 87 | } 88 | case user.Foreign != nil: 89 | extendedUserInfo = persist.ForeignUserInformation{} 90 | default: 91 | panic("unhandled / invalid db") 92 | } 93 | 94 | return userInfo, extendedUserInfo, err 95 | } 96 | 97 | func (db *users) GetLocalByEmail( 98 | ctx context.Context, 99 | email string, 100 | ) ( 101 | persist.UserInformation, 102 | persist.LocalUserInformation, 103 | error, 104 | ) { 105 | var luser localuser 106 | 107 | err := db.db.First(&luser, "email = ?", email).Error 108 | if err != nil { 109 | return persist.UserInformation{}, persist.LocalUserInformation{}, err 110 | } 111 | 112 | var user user 113 | 114 | err = db.db.First(&user, "id = ?", luser.UserID).Error 115 | if err != nil { 116 | return persist.UserInformation{}, persist.LocalUserInformation{}, err 117 | } 118 | 119 | user.Local = &luser 120 | 121 | return persist.UserInformation{ 122 | ID: user.ID, 123 | }, persist.LocalUserInformation{ 124 | Email: user.Local.Email, 125 | Password: user.Local.Password, 126 | }, nil 127 | } 128 | -------------------------------------------------------------------------------- /config/config.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package config 6 | 7 | import ( 8 | 9 | // for embedding default config. 10 | _ "embed" 11 | "errors" 12 | "os" 13 | 14 | "github.com/fsnotify/fsnotify" 15 | "github.com/harmony-development/legato/errwrap" 16 | "gopkg.in/yaml.v3" 17 | ) 18 | 19 | // nolint 20 | //go:embed default.yml 21 | var defaultConfig []byte 22 | 23 | type Config struct { 24 | // The address to listen on for HTTP requests. 25 | Address string 26 | // The port to listen on for HTTP requests. 27 | Port int 28 | PublicKeyPath string `yaml:"publicKeyPath"` 29 | PrivateKeyPath string `yaml:"privateKeyPath"` 30 | AuthIDLength int `yaml:"authIdLength"` 31 | IDStart int64 `yaml:"idStart"` 32 | Debug Debug 33 | Database Database 34 | Epheremal Epheremal 35 | } 36 | 37 | type Debug struct { 38 | RespondWithErrors bool `yaml:"respondWithErrors"` 39 | LogErrors bool `yaml:"logErrors"` 40 | } 41 | 42 | type Database struct { 43 | Backend string 44 | Postgres *PostgresConfig 45 | SQLite *SQLiteConfig 46 | } 47 | 48 | type Epheremal struct { 49 | Backend string 50 | Redis *RedisConfig 51 | } 52 | 53 | type RedisConfig struct { 54 | Hosts []string 55 | Password string 56 | } 57 | 58 | type PostgresConfig struct { 59 | Username string 60 | Password string 61 | Host string 62 | Port int 63 | DB string 64 | } 65 | 66 | type SQLiteConfig struct { 67 | File string 68 | } 69 | 70 | type Reader struct { 71 | ConfigName string 72 | } 73 | 74 | var ErrDefaultConfigCreated = errors.New("default configuration has been created, please edit it") 75 | 76 | func New(name string) *Reader { 77 | return &Reader{ 78 | ConfigName: name + ".yaml", 79 | } 80 | } 81 | 82 | func (c *Reader) ParseConfig() (*Config, error) { 83 | conf := &Config{} 84 | 85 | dat, err := os.ReadFile(c.ConfigName) 86 | if err != nil { 87 | if os.IsNotExist(err) { 88 | // stdlib doesn't have any permission bit enums so a "magic" number is ok here 89 | // nolint 90 | err := os.WriteFile(c.ConfigName, defaultConfig, 0o660) 91 | if err != nil { 92 | return nil, errwrap.Wrap(err, "failed to write default config") 93 | } 94 | 95 | return nil, ErrDefaultConfigCreated 96 | } 97 | 98 | return nil, errwrap.Wrap(err, "failed to read config file") 99 | } 100 | 101 | if err := yaml.Unmarshal(dat, conf); err != nil { 102 | return nil, errwrap.Wrap(err, "failed to parse config file") 103 | } 104 | 105 | return conf, nil 106 | } 107 | 108 | func (c *Reader) WatchConfig(onChange func(fsnotify.Event), onError func(error)) error { 109 | watcher, err := fsnotify.NewWatcher() 110 | if err != nil { 111 | return errwrap.Wrap(err, "failed to start fsnotify watcher") 112 | } 113 | 114 | go func() { 115 | for { 116 | select { 117 | case event := <-watcher.Events: 118 | onChange(event) 119 | case err := <-watcher.Errors: 120 | onError(err) 121 | } 122 | } 123 | }() 124 | 125 | if err := watcher.Add(c.ConfigName); err != nil { 126 | return errwrap.Wrap(err, "failed to add config to watcher") 127 | } 128 | 129 | return nil 130 | } 131 | -------------------------------------------------------------------------------- /gen/sync/v1/sync_hrpc_client.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package syncv1 8 | 9 | import ( 10 | bytes "bytes" 11 | context "context" 12 | proto "google.golang.org/protobuf/proto" 13 | ioutil "io/ioutil" 14 | http "net/http" 15 | httptest "net/http/httptest" 16 | ) 17 | 18 | type PostboxServiceClient interface { 19 | // Endpoint to pull events. 20 | Pull(context.Context, *PullRequest) (*PullResponse, error) 21 | // Endpoint to push events. 22 | Push(context.Context, *PushRequest) (*PushResponse, error) 23 | } 24 | 25 | type HTTPPostboxServiceClient struct { 26 | Client http.Client 27 | BaseURL string 28 | } 29 | 30 | func (client *HTTPPostboxServiceClient) Pull(req *PullRequest) (*PullResponse, error) { 31 | data, marshalErr := proto.Marshal(req) 32 | if marshalErr != nil { 33 | return nil, marshalErr 34 | } 35 | reader := bytes.NewReader(data) 36 | resp, err := client.Client.Post(client.BaseURL+"/protocol.sync.v1.PostboxService.Pull/", "application/hrpc", reader) 37 | if err != nil { 38 | return nil, err 39 | } 40 | body, err := ioutil.ReadAll(resp.Body) 41 | if err != nil { 42 | return nil, err 43 | } 44 | ret := &PullResponse{} 45 | unmarshalErr := proto.Unmarshal(body, ret) 46 | if unmarshalErr != nil { 47 | return nil, unmarshalErr 48 | } 49 | return ret, nil 50 | } 51 | func (client *HTTPPostboxServiceClient) Push(req *PushRequest) (*PushResponse, error) { 52 | data, marshalErr := proto.Marshal(req) 53 | if marshalErr != nil { 54 | return nil, marshalErr 55 | } 56 | reader := bytes.NewReader(data) 57 | resp, err := client.Client.Post(client.BaseURL+"/protocol.sync.v1.PostboxService.Push/", "application/hrpc", reader) 58 | if err != nil { 59 | return nil, err 60 | } 61 | body, err := ioutil.ReadAll(resp.Body) 62 | if err != nil { 63 | return nil, err 64 | } 65 | ret := &PushResponse{} 66 | unmarshalErr := proto.Unmarshal(body, ret) 67 | if unmarshalErr != nil { 68 | return nil, unmarshalErr 69 | } 70 | return ret, nil 71 | } 72 | 73 | type HTTPTestPostboxServiceClient struct { 74 | Client interface { 75 | Test(*http.Request, ...int) (*http.Response, error) 76 | } 77 | } 78 | 79 | func (client *HTTPTestPostboxServiceClient) Pull(req *PullRequest) (*PullResponse, error) { 80 | data, marshalErr := proto.Marshal(req) 81 | if marshalErr != nil { 82 | return nil, marshalErr 83 | } 84 | reader := bytes.NewReader(data) 85 | testreq := httptest.NewRequest("POST", "/protocol.sync.v1.PostboxService.Pull/", reader) 86 | resp, err := client.Client.Test(testreq) 87 | if err != nil { 88 | return nil, err 89 | } 90 | body, err := ioutil.ReadAll(resp.Body) 91 | if err != nil { 92 | return nil, err 93 | } 94 | ret := &PullResponse{} 95 | unmarshalErr := proto.Unmarshal(body, ret) 96 | if unmarshalErr != nil { 97 | return nil, unmarshalErr 98 | } 99 | return ret, nil 100 | } 101 | func (client *HTTPTestPostboxServiceClient) Push(req *PushRequest) (*PushResponse, error) { 102 | data, marshalErr := proto.Marshal(req) 103 | if marshalErr != nil { 104 | return nil, marshalErr 105 | } 106 | reader := bytes.NewReader(data) 107 | testreq := httptest.NewRequest("POST", "/protocol.sync.v1.PostboxService.Push/", reader) 108 | resp, err := client.Client.Test(testreq) 109 | if err != nil { 110 | return nil, err 111 | } 112 | body, err := ioutil.ReadAll(resp.Body) 113 | if err != nil { 114 | return nil, err 115 | } 116 | ret := &PushResponse{} 117 | unmarshalErr := proto.Unmarshal(body, ret) 118 | if unmarshalErr != nil { 119 | return nil, unmarshalErr 120 | } 121 | return ret, nil 122 | } 123 | -------------------------------------------------------------------------------- /gen/batch/v1/batch_hrpc_client.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package batchv1 8 | 9 | import ( 10 | bytes "bytes" 11 | context "context" 12 | proto "google.golang.org/protobuf/proto" 13 | ioutil "io/ioutil" 14 | http "net/http" 15 | httptest "net/http/httptest" 16 | ) 17 | 18 | type BatchServiceClient interface { 19 | // Batch requests. 20 | // Does not support batching stream requests. 21 | // Batched requests should be verified and an error should be thrown if they 22 | // are invalid. 23 | Batch(context.Context, *BatchRequest) (*BatchResponse, error) 24 | // BatchSame allows batching for requests using the same endpoint. 25 | // This allows for additional network optimizations since the endpoint doesn't 26 | // have to be sent for every request. 27 | BatchSame(context.Context, *BatchSameRequest) (*BatchSameResponse, error) 28 | } 29 | 30 | type HTTPBatchServiceClient struct { 31 | Client http.Client 32 | BaseURL string 33 | } 34 | 35 | func (client *HTTPBatchServiceClient) Batch(req *BatchRequest) (*BatchResponse, error) { 36 | data, marshalErr := proto.Marshal(req) 37 | if marshalErr != nil { 38 | return nil, marshalErr 39 | } 40 | reader := bytes.NewReader(data) 41 | resp, err := client.Client.Post(client.BaseURL+"/protocol.batch.v1.BatchService.Batch/", "application/hrpc", reader) 42 | if err != nil { 43 | return nil, err 44 | } 45 | body, err := ioutil.ReadAll(resp.Body) 46 | if err != nil { 47 | return nil, err 48 | } 49 | ret := &BatchResponse{} 50 | unmarshalErr := proto.Unmarshal(body, ret) 51 | if unmarshalErr != nil { 52 | return nil, unmarshalErr 53 | } 54 | return ret, nil 55 | } 56 | func (client *HTTPBatchServiceClient) BatchSame(req *BatchSameRequest) (*BatchSameResponse, error) { 57 | data, marshalErr := proto.Marshal(req) 58 | if marshalErr != nil { 59 | return nil, marshalErr 60 | } 61 | reader := bytes.NewReader(data) 62 | resp, err := client.Client.Post(client.BaseURL+"/protocol.batch.v1.BatchService.BatchSame/", "application/hrpc", reader) 63 | if err != nil { 64 | return nil, err 65 | } 66 | body, err := ioutil.ReadAll(resp.Body) 67 | if err != nil { 68 | return nil, err 69 | } 70 | ret := &BatchSameResponse{} 71 | unmarshalErr := proto.Unmarshal(body, ret) 72 | if unmarshalErr != nil { 73 | return nil, unmarshalErr 74 | } 75 | return ret, nil 76 | } 77 | 78 | type HTTPTestBatchServiceClient struct { 79 | Client interface { 80 | Test(*http.Request, ...int) (*http.Response, error) 81 | } 82 | } 83 | 84 | func (client *HTTPTestBatchServiceClient) Batch(req *BatchRequest) (*BatchResponse, error) { 85 | data, marshalErr := proto.Marshal(req) 86 | if marshalErr != nil { 87 | return nil, marshalErr 88 | } 89 | reader := bytes.NewReader(data) 90 | testreq := httptest.NewRequest("POST", "/protocol.batch.v1.BatchService.Batch/", reader) 91 | resp, err := client.Client.Test(testreq) 92 | if err != nil { 93 | return nil, err 94 | } 95 | body, err := ioutil.ReadAll(resp.Body) 96 | if err != nil { 97 | return nil, err 98 | } 99 | ret := &BatchResponse{} 100 | unmarshalErr := proto.Unmarshal(body, ret) 101 | if unmarshalErr != nil { 102 | return nil, unmarshalErr 103 | } 104 | return ret, nil 105 | } 106 | func (client *HTTPTestBatchServiceClient) BatchSame(req *BatchSameRequest) (*BatchSameResponse, error) { 107 | data, marshalErr := proto.Marshal(req) 108 | if marshalErr != nil { 109 | return nil, marshalErr 110 | } 111 | reader := bytes.NewReader(data) 112 | testreq := httptest.NewRequest("POST", "/protocol.batch.v1.BatchService.BatchSame/", reader) 113 | resp, err := client.Client.Test(testreq) 114 | if err != nil { 115 | return nil, err 116 | } 117 | body, err := ioutil.ReadAll(resp.Body) 118 | if err != nil { 119 | return nil, err 120 | } 121 | ret := &BatchSameResponse{} 122 | unmarshalErr := proto.Unmarshal(body, ret) 123 | if unmarshalErr != nil { 124 | return nil, unmarshalErr 125 | } 126 | return ret, nil 127 | } 128 | -------------------------------------------------------------------------------- /gen/auth/v1/auth_hrpc.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package authv1 8 | 9 | import ( 10 | context "context" 11 | errors "errors" 12 | server "github.com/harmony-development/hrpc/server" 13 | proto "google.golang.org/protobuf/proto" 14 | ) 15 | 16 | type AuthServiceServer interface { 17 | // Federate with a foreignserver, obtaining a token 18 | // you can use to call LoginFederated on it 19 | Federate(context.Context, *FederateRequest) (*FederateResponse, error) 20 | // Present a token to a foreignserver from a Federate call 21 | // on your homeserver in order to login 22 | LoginFederated(context.Context, *LoginFederatedRequest) (*LoginFederatedResponse, error) 23 | // Returns the public key of this server 24 | Key(context.Context, *KeyRequest) (*KeyResponse, error) 25 | // Begins an authentication session 26 | BeginAuth(context.Context, *BeginAuthRequest) (*BeginAuthResponse, error) 27 | // Goes to the next step of the authentication session, 28 | // possibly presenting user input 29 | NextStep(context.Context, *NextStepRequest) (*NextStepResponse, error) 30 | // Goes to the previous step of the authentication session 31 | // if possible 32 | StepBack(context.Context, *StepBackRequest) (*StepBackResponse, error) 33 | // Consume the steps of an authentication session 34 | // as a stream 35 | StreamSteps(context.Context, *StreamStepsRequest) (chan *StreamStepsResponse, error) 36 | // Check whether or not you're logged in and the session is valid 37 | CheckLoggedIn(context.Context, *CheckLoggedInRequest) (*CheckLoggedInResponse, error) 38 | } 39 | 40 | type DefaultAuthService struct{} 41 | 42 | func (DefaultAuthService) Federate(context.Context, *FederateRequest) (*FederateResponse, error) { 43 | return nil, errors.New("unimplemented") 44 | } 45 | func (DefaultAuthService) LoginFederated(context.Context, *LoginFederatedRequest) (*LoginFederatedResponse, error) { 46 | return nil, errors.New("unimplemented") 47 | } 48 | func (DefaultAuthService) Key(context.Context, *KeyRequest) (*KeyResponse, error) { 49 | return nil, errors.New("unimplemented") 50 | } 51 | func (DefaultAuthService) BeginAuth(context.Context, *BeginAuthRequest) (*BeginAuthResponse, error) { 52 | return nil, errors.New("unimplemented") 53 | } 54 | func (DefaultAuthService) NextStep(context.Context, *NextStepRequest) (*NextStepResponse, error) { 55 | return nil, errors.New("unimplemented") 56 | } 57 | func (DefaultAuthService) StepBack(context.Context, *StepBackRequest) (*StepBackResponse, error) { 58 | return nil, errors.New("unimplemented") 59 | } 60 | func (DefaultAuthService) StreamSteps(context.Context, *StreamStepsRequest) (chan *StreamStepsResponse, error) { 61 | return nil, errors.New("unimplemented") 62 | } 63 | func (DefaultAuthService) CheckLoggedIn(context.Context, *CheckLoggedInRequest) (*CheckLoggedInResponse, error) { 64 | return nil, errors.New("unimplemented") 65 | } 66 | 67 | type AuthServiceHandler struct { 68 | Server AuthServiceServer 69 | } 70 | 71 | func NewAuthServiceHandler(server AuthServiceServer) *AuthServiceHandler { 72 | return &AuthServiceHandler{Server: server} 73 | } 74 | func (h *AuthServiceHandler) Name() string { 75 | return "AuthService" 76 | } 77 | func (h *AuthServiceHandler) Routes() map[string]server.RawHandler { 78 | return map[string]server.RawHandler{ 79 | "/protocol.auth.v1.AuthService.Federate/": server.NewUnaryHandler(&FederateRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 80 | return h.Server.Federate(c, req.(*FederateRequest)) 81 | }), 82 | "/protocol.auth.v1.AuthService.LoginFederated/": server.NewUnaryHandler(&LoginFederatedRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 83 | return h.Server.LoginFederated(c, req.(*LoginFederatedRequest)) 84 | }), 85 | "/protocol.auth.v1.AuthService.Key/": server.NewUnaryHandler(&KeyRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 86 | return h.Server.Key(c, req.(*KeyRequest)) 87 | }), 88 | "/protocol.auth.v1.AuthService.BeginAuth/": server.NewUnaryHandler(&BeginAuthRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 89 | return h.Server.BeginAuth(c, req.(*BeginAuthRequest)) 90 | }), 91 | "/protocol.auth.v1.AuthService.NextStep/": server.NewUnaryHandler(&NextStepRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 92 | return h.Server.NextStep(c, req.(*NextStepRequest)) 93 | }), 94 | "/protocol.auth.v1.AuthService.StepBack/": server.NewUnaryHandler(&StepBackRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 95 | return h.Server.StepBack(c, req.(*StepBackRequest)) 96 | }), 97 | "/protocol.auth.v1.AuthService.CheckLoggedIn/": server.NewUnaryHandler(&CheckLoggedInRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 98 | return h.Server.CheckLoggedIn(c, req.(*CheckLoggedInRequest)) 99 | }), 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /gen/emote/v1/emote_hrpc.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package emotev1 8 | 9 | import ( 10 | context "context" 11 | errors "errors" 12 | server "github.com/harmony-development/hrpc/server" 13 | proto "google.golang.org/protobuf/proto" 14 | ) 15 | 16 | type EmoteServiceServer interface { 17 | // Endpoint to create an emote pack. 18 | CreateEmotePack(context.Context, *CreateEmotePackRequest) (*CreateEmotePackResponse, error) 19 | // Endpoint to get the emote packs you have equipped. 20 | GetEmotePacks(context.Context, *GetEmotePacksRequest) (*GetEmotePacksResponse, error) 21 | // Endpoint to get the emotes in an emote pack. 22 | GetEmotePackEmotes(context.Context, *GetEmotePackEmotesRequest) (*GetEmotePackEmotesResponse, error) 23 | // Endpoint to add an emote to an emote pack that you own. 24 | AddEmoteToPack(context.Context, *AddEmoteToPackRequest) (*AddEmoteToPackResponse, error) 25 | // Endpoint to delete an emote pack that you own. 26 | DeleteEmotePack(context.Context, *DeleteEmotePackRequest) (*DeleteEmotePackResponse, error) 27 | // Endpoint to delete an emote from an emote pack. 28 | DeleteEmoteFromPack(context.Context, *DeleteEmoteFromPackRequest) (*DeleteEmoteFromPackResponse, error) 29 | // Endpoint to dequip an emote pack that you have equipped. 30 | DequipEmotePack(context.Context, *DequipEmotePackRequest) (*DequipEmotePackResponse, error) 31 | // Endpoint to equip an emote pack. 32 | EquipEmotePack(context.Context, *EquipEmotePackRequest) (*EquipEmotePackResponse, error) 33 | } 34 | 35 | type DefaultEmoteService struct{} 36 | 37 | func (DefaultEmoteService) CreateEmotePack(context.Context, *CreateEmotePackRequest) (*CreateEmotePackResponse, error) { 38 | return nil, errors.New("unimplemented") 39 | } 40 | func (DefaultEmoteService) GetEmotePacks(context.Context, *GetEmotePacksRequest) (*GetEmotePacksResponse, error) { 41 | return nil, errors.New("unimplemented") 42 | } 43 | func (DefaultEmoteService) GetEmotePackEmotes(context.Context, *GetEmotePackEmotesRequest) (*GetEmotePackEmotesResponse, error) { 44 | return nil, errors.New("unimplemented") 45 | } 46 | func (DefaultEmoteService) AddEmoteToPack(context.Context, *AddEmoteToPackRequest) (*AddEmoteToPackResponse, error) { 47 | return nil, errors.New("unimplemented") 48 | } 49 | func (DefaultEmoteService) DeleteEmotePack(context.Context, *DeleteEmotePackRequest) (*DeleteEmotePackResponse, error) { 50 | return nil, errors.New("unimplemented") 51 | } 52 | func (DefaultEmoteService) DeleteEmoteFromPack(context.Context, *DeleteEmoteFromPackRequest) (*DeleteEmoteFromPackResponse, error) { 53 | return nil, errors.New("unimplemented") 54 | } 55 | func (DefaultEmoteService) DequipEmotePack(context.Context, *DequipEmotePackRequest) (*DequipEmotePackResponse, error) { 56 | return nil, errors.New("unimplemented") 57 | } 58 | func (DefaultEmoteService) EquipEmotePack(context.Context, *EquipEmotePackRequest) (*EquipEmotePackResponse, error) { 59 | return nil, errors.New("unimplemented") 60 | } 61 | 62 | type EmoteServiceHandler struct { 63 | Server EmoteServiceServer 64 | } 65 | 66 | func NewEmoteServiceHandler(server EmoteServiceServer) *EmoteServiceHandler { 67 | return &EmoteServiceHandler{Server: server} 68 | } 69 | func (h *EmoteServiceHandler) Name() string { 70 | return "EmoteService" 71 | } 72 | func (h *EmoteServiceHandler) Routes() map[string]server.RawHandler { 73 | return map[string]server.RawHandler{ 74 | "/protocol.emote.v1.EmoteService.CreateEmotePack/": server.NewUnaryHandler(&CreateEmotePackRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 75 | return h.Server.CreateEmotePack(c, req.(*CreateEmotePackRequest)) 76 | }), 77 | "/protocol.emote.v1.EmoteService.GetEmotePacks/": server.NewUnaryHandler(&GetEmotePacksRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 78 | return h.Server.GetEmotePacks(c, req.(*GetEmotePacksRequest)) 79 | }), 80 | "/protocol.emote.v1.EmoteService.GetEmotePackEmotes/": server.NewUnaryHandler(&GetEmotePackEmotesRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 81 | return h.Server.GetEmotePackEmotes(c, req.(*GetEmotePackEmotesRequest)) 82 | }), 83 | "/protocol.emote.v1.EmoteService.AddEmoteToPack/": server.NewUnaryHandler(&AddEmoteToPackRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 84 | return h.Server.AddEmoteToPack(c, req.(*AddEmoteToPackRequest)) 85 | }), 86 | "/protocol.emote.v1.EmoteService.DeleteEmotePack/": server.NewUnaryHandler(&DeleteEmotePackRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 87 | return h.Server.DeleteEmotePack(c, req.(*DeleteEmotePackRequest)) 88 | }), 89 | "/protocol.emote.v1.EmoteService.DeleteEmoteFromPack/": server.NewUnaryHandler(&DeleteEmoteFromPackRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 90 | return h.Server.DeleteEmoteFromPack(c, req.(*DeleteEmoteFromPackRequest)) 91 | }), 92 | "/protocol.emote.v1.EmoteService.DequipEmotePack/": server.NewUnaryHandler(&DequipEmotePackRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 93 | return h.Server.DequipEmotePack(c, req.(*DequipEmotePackRequest)) 94 | }), 95 | "/protocol.emote.v1.EmoteService.EquipEmotePack/": server.NewUnaryHandler(&EquipEmotePackRequest{}, func(c context.Context, req proto.Message) (proto.Message, error) { 96 | return h.Server.EquipEmotePack(c, req.(*EquipEmotePackRequest)) 97 | }), 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /test/integration/auth_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package auth_test 6 | 7 | import ( 8 | "strings" 9 | "testing" 10 | 11 | authv1 "github.com/harmony-development/legato/gen/auth/v1" 12 | "github.com/harmony-development/legato/logger" 13 | "github.com/harmony-development/legato/server" 14 | ) 15 | 16 | func contains(s string, ss []string) bool { 17 | for _, it := range ss { 18 | if it == s { 19 | return true 20 | } 21 | } 22 | 23 | return false 24 | } 25 | 26 | func test(t *testing.T, s string, i int, fn func(t *testing.T, i int)) { 27 | t.Helper() 28 | t.Logf("%sTesting %s", strings.Repeat("\t", i), s) 29 | fn(t, i+1) 30 | } 31 | 32 | func beginAuth(client authv1.HTTPTestAuthServiceClient, authid *string) func(t *testing.T, i int) { 33 | return func(t *testing.T, i int) { 34 | t.Helper() 35 | 36 | resp, err := client.BeginAuth(&authv1.BeginAuthRequest{}) 37 | if err != nil { 38 | t.Fatalf("error: %s", err) 39 | } 40 | 41 | *authid = resp.AuthId 42 | } 43 | } 44 | 45 | func firstAuthStep(client authv1.HTTPTestAuthServiceClient, authid, is string) func(t *testing.T, i int) { 46 | return func(t *testing.T, i int) { 47 | t.Helper() 48 | 49 | resp, err := client.NextStep(&authv1.NextStepRequest{ 50 | AuthId: authid, 51 | }) 52 | if err != nil { 53 | t.Fatalf("error: %s", err) 54 | } 55 | 56 | choice, ok := resp.Step.Step.(*authv1.AuthStep_Choice_) 57 | if !ok { 58 | t.Fatalf("first thing wasn't choice") 59 | } 60 | 61 | if !contains(is, choice.Choice.Options) { 62 | t.Fatalf("no '%s' in options", is) 63 | } 64 | } 65 | } 66 | 67 | func formAuthStep(client authv1.HTTPTestAuthServiceClient, authid, step string) func(t *testing.T, i int) { 68 | return func(t *testing.T, i int) { 69 | t.Helper() 70 | 71 | resp, err := client.NextStep(&authv1.NextStepRequest{ 72 | AuthId: authid, 73 | Step: &authv1.NextStepRequest_Choice_{ 74 | Choice: &authv1.NextStepRequest_Choice{ 75 | Choice: step, 76 | }, 77 | }, 78 | }) 79 | if err != nil { 80 | t.Fatalf("error: %s", err) 81 | } 82 | 83 | _, ok := resp.Step.Step.(*authv1.AuthStep_Form_) 84 | if !ok { 85 | t.Fatalf("step wasn't form") 86 | } 87 | } 88 | } 89 | 90 | func register( 91 | client authv1.HTTPTestAuthServiceClient, 92 | authid, 93 | username, 94 | email, 95 | password string, 96 | ) func(t *testing.T, i int) { 97 | return func(t *testing.T, i int) { 98 | t.Helper() 99 | 100 | resp, err := client.NextStep(&authv1.NextStepRequest{ 101 | AuthId: authid, 102 | Step: &authv1.NextStepRequest_Form_{ 103 | Form: &authv1.NextStepRequest_Form{ 104 | Fields: []*authv1.NextStepRequest_FormFields{ 105 | { 106 | Field: &authv1.NextStepRequest_FormFields_String_{ 107 | String_: email, 108 | }, 109 | }, 110 | { 111 | Field: &authv1.NextStepRequest_FormFields_String_{ 112 | String_: username, 113 | }, 114 | }, 115 | { 116 | Field: &authv1.NextStepRequest_FormFields_Bytes{ 117 | Bytes: []byte(password), 118 | }, 119 | }, 120 | }, 121 | }, 122 | }, 123 | }) 124 | if err != nil { 125 | t.Fatalf("error: %s", err) 126 | } 127 | 128 | session, ok := resp.Step.Step.(*authv1.AuthStep_Session) 129 | if !ok { 130 | t.Fatalf("register wasn't session, got %+v", resp.Step.Step) 131 | } 132 | 133 | _ = session 134 | } 135 | } 136 | 137 | func login(client authv1.HTTPTestAuthServiceClient, authid, email, password string) func(t *testing.T, i int) { 138 | return func(t *testing.T, i int) { 139 | t.Helper() 140 | 141 | resp, err := client.NextStep(&authv1.NextStepRequest{ 142 | AuthId: authid, 143 | Step: &authv1.NextStepRequest_Form_{ 144 | Form: &authv1.NextStepRequest_Form{ 145 | Fields: []*authv1.NextStepRequest_FormFields{ 146 | { 147 | Field: &authv1.NextStepRequest_FormFields_String_{ 148 | String_: email, 149 | }, 150 | }, 151 | { 152 | Field: &authv1.NextStepRequest_FormFields_Bytes{ 153 | Bytes: []byte(password), 154 | }, 155 | }, 156 | }, 157 | }, 158 | }, 159 | }) 160 | if err != nil { 161 | t.Fatalf("error: %s", err) 162 | } 163 | 164 | session, ok := resp.Step.Step.(*authv1.AuthStep_Session) 165 | if !ok { 166 | t.Fatalf("login wasn't session, got %+v", resp.Step.Step) 167 | } 168 | 169 | _ = session 170 | } 171 | } 172 | 173 | // nolint 174 | // Integration tests cannot be parallelized 175 | func TestAuth(t *testing.T) { 176 | l := logger.NewNoop() 177 | 178 | serv, err := server.New(l) 179 | if err != nil { 180 | t.Fatal(err) 181 | } 182 | 183 | client := authv1.HTTPTestAuthServiceClient{} 184 | client.Client = serv 185 | 186 | test(t, "client auth", 0, func(t *testing.T, i int) { 187 | var authid string 188 | const ( 189 | username = "kili-test" 190 | email = "uhh@eee@aaa" 191 | password = "kala-test" 192 | ) 193 | 194 | test(t, "begin auth", i, beginAuth(client, &authid)) 195 | test(t, "first auth step", i, firstAuthStep(client, authid, "register")) 196 | test(t, "get register form", i, formAuthStep(client, authid, "register")) 197 | 198 | test(t, "register account", i, register(client, authid, username, email, password)) 199 | 200 | test(t, "begin auth again", i, beginAuth(client, &authid)) 201 | test(t, "first auth step again", i, firstAuthStep(client, authid, "login")) 202 | test(t, "get login form", i, formAuthStep(client, authid, "login")) 203 | 204 | test(t, "login account", i, login(client, authid, email, password)) 205 | }) 206 | } 207 | -------------------------------------------------------------------------------- /gen/mediaproxy/v1/mediaproxy_hrpc_client.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package mediaproxyv1 8 | 9 | import ( 10 | bytes "bytes" 11 | context "context" 12 | proto "google.golang.org/protobuf/proto" 13 | ioutil "io/ioutil" 14 | http "net/http" 15 | httptest "net/http/httptest" 16 | ) 17 | 18 | type MediaProxyServiceClient interface { 19 | // Endpoint to fetch metadata for a URL. 20 | FetchLinkMetadata(context.Context, *FetchLinkMetadataRequest) (*FetchLinkMetadataResponse, error) 21 | // Endpoint to instant view a website URL. 22 | InstantView(context.Context, *InstantViewRequest) (*InstantViewResponse, error) 23 | // Endpoint to query if the server can generate an instant view for a website URL. 24 | CanInstantView(context.Context, *CanInstantViewRequest) (*CanInstantViewResponse, error) 25 | } 26 | 27 | type HTTPMediaProxyServiceClient struct { 28 | Client http.Client 29 | BaseURL string 30 | } 31 | 32 | func (client *HTTPMediaProxyServiceClient) FetchLinkMetadata(req *FetchLinkMetadataRequest) (*FetchLinkMetadataResponse, error) { 33 | data, marshalErr := proto.Marshal(req) 34 | if marshalErr != nil { 35 | return nil, marshalErr 36 | } 37 | reader := bytes.NewReader(data) 38 | resp, err := client.Client.Post(client.BaseURL+"/protocol.mediaproxy.v1.MediaProxyService.FetchLinkMetadata/", "application/hrpc", reader) 39 | if err != nil { 40 | return nil, err 41 | } 42 | body, err := ioutil.ReadAll(resp.Body) 43 | if err != nil { 44 | return nil, err 45 | } 46 | ret := &FetchLinkMetadataResponse{} 47 | unmarshalErr := proto.Unmarshal(body, ret) 48 | if unmarshalErr != nil { 49 | return nil, unmarshalErr 50 | } 51 | return ret, nil 52 | } 53 | func (client *HTTPMediaProxyServiceClient) InstantView(req *InstantViewRequest) (*InstantViewResponse, error) { 54 | data, marshalErr := proto.Marshal(req) 55 | if marshalErr != nil { 56 | return nil, marshalErr 57 | } 58 | reader := bytes.NewReader(data) 59 | resp, err := client.Client.Post(client.BaseURL+"/protocol.mediaproxy.v1.MediaProxyService.InstantView/", "application/hrpc", reader) 60 | if err != nil { 61 | return nil, err 62 | } 63 | body, err := ioutil.ReadAll(resp.Body) 64 | if err != nil { 65 | return nil, err 66 | } 67 | ret := &InstantViewResponse{} 68 | unmarshalErr := proto.Unmarshal(body, ret) 69 | if unmarshalErr != nil { 70 | return nil, unmarshalErr 71 | } 72 | return ret, nil 73 | } 74 | func (client *HTTPMediaProxyServiceClient) CanInstantView(req *CanInstantViewRequest) (*CanInstantViewResponse, error) { 75 | data, marshalErr := proto.Marshal(req) 76 | if marshalErr != nil { 77 | return nil, marshalErr 78 | } 79 | reader := bytes.NewReader(data) 80 | resp, err := client.Client.Post(client.BaseURL+"/protocol.mediaproxy.v1.MediaProxyService.CanInstantView/", "application/hrpc", reader) 81 | if err != nil { 82 | return nil, err 83 | } 84 | body, err := ioutil.ReadAll(resp.Body) 85 | if err != nil { 86 | return nil, err 87 | } 88 | ret := &CanInstantViewResponse{} 89 | unmarshalErr := proto.Unmarshal(body, ret) 90 | if unmarshalErr != nil { 91 | return nil, unmarshalErr 92 | } 93 | return ret, nil 94 | } 95 | 96 | type HTTPTestMediaProxyServiceClient struct { 97 | Client interface { 98 | Test(*http.Request, ...int) (*http.Response, error) 99 | } 100 | } 101 | 102 | func (client *HTTPTestMediaProxyServiceClient) FetchLinkMetadata(req *FetchLinkMetadataRequest) (*FetchLinkMetadataResponse, error) { 103 | data, marshalErr := proto.Marshal(req) 104 | if marshalErr != nil { 105 | return nil, marshalErr 106 | } 107 | reader := bytes.NewReader(data) 108 | testreq := httptest.NewRequest("POST", "/protocol.mediaproxy.v1.MediaProxyService.FetchLinkMetadata/", reader) 109 | resp, err := client.Client.Test(testreq) 110 | if err != nil { 111 | return nil, err 112 | } 113 | body, err := ioutil.ReadAll(resp.Body) 114 | if err != nil { 115 | return nil, err 116 | } 117 | ret := &FetchLinkMetadataResponse{} 118 | unmarshalErr := proto.Unmarshal(body, ret) 119 | if unmarshalErr != nil { 120 | return nil, unmarshalErr 121 | } 122 | return ret, nil 123 | } 124 | func (client *HTTPTestMediaProxyServiceClient) InstantView(req *InstantViewRequest) (*InstantViewResponse, error) { 125 | data, marshalErr := proto.Marshal(req) 126 | if marshalErr != nil { 127 | return nil, marshalErr 128 | } 129 | reader := bytes.NewReader(data) 130 | testreq := httptest.NewRequest("POST", "/protocol.mediaproxy.v1.MediaProxyService.InstantView/", reader) 131 | resp, err := client.Client.Test(testreq) 132 | if err != nil { 133 | return nil, err 134 | } 135 | body, err := ioutil.ReadAll(resp.Body) 136 | if err != nil { 137 | return nil, err 138 | } 139 | ret := &InstantViewResponse{} 140 | unmarshalErr := proto.Unmarshal(body, ret) 141 | if unmarshalErr != nil { 142 | return nil, unmarshalErr 143 | } 144 | return ret, nil 145 | } 146 | func (client *HTTPTestMediaProxyServiceClient) CanInstantView(req *CanInstantViewRequest) (*CanInstantViewResponse, error) { 147 | data, marshalErr := proto.Marshal(req) 148 | if marshalErr != nil { 149 | return nil, marshalErr 150 | } 151 | reader := bytes.NewReader(data) 152 | testreq := httptest.NewRequest("POST", "/protocol.mediaproxy.v1.MediaProxyService.CanInstantView/", reader) 153 | resp, err := client.Client.Test(testreq) 154 | if err != nil { 155 | return nil, err 156 | } 157 | body, err := ioutil.ReadAll(resp.Body) 158 | if err != nil { 159 | return nil, err 160 | } 161 | ret := &CanInstantViewResponse{} 162 | unmarshalErr := proto.Unmarshal(body, ret) 163 | if unmarshalErr != nil { 164 | return nil, unmarshalErr 165 | } 166 | return ret, nil 167 | } 168 | -------------------------------------------------------------------------------- /server/server.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Carson Black 2 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-or-later 5 | 6 | package server 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | "os" 12 | "strconv" 13 | "time" 14 | 15 | "github.com/apex/log" 16 | "github.com/fatih/color" 17 | "github.com/fsnotify/fsnotify" 18 | "github.com/gofiber/fiber/v2" 19 | fiberLogger "github.com/gofiber/fiber/v2/middleware/logger" 20 | "github.com/harmony-development/legato/api" 21 | authv1impl "github.com/harmony-development/legato/api/authv1" 22 | "github.com/harmony-development/legato/build" 23 | "github.com/harmony-development/legato/config" 24 | "github.com/harmony-development/legato/db/ephemeral" 25 | "github.com/harmony-development/legato/db/ephemeral/bigcache" 26 | "github.com/harmony-development/legato/db/ephemeral/redis" 27 | "github.com/harmony-development/legato/db/persist" 28 | "github.com/harmony-development/legato/db/persist/postgres" 29 | "github.com/harmony-development/legato/db/persist/sqlite" 30 | "github.com/harmony-development/legato/errwrap" 31 | authv1 "github.com/harmony-development/legato/gen/auth/v1" 32 | "github.com/harmony-development/legato/key" 33 | "github.com/harmony-development/legato/logger" 34 | "github.com/sony/sonyflake" 35 | ) 36 | 37 | const startupMessage = `Version %s 38 | __ __ 39 | / /___ ___ _ ___ _ / /_ ___ 40 | / // -_)/ _ ` + "`" + `// _ ` + "`" + `// __// _ \ 41 | /_/ \__/ \_, / \_,_/ \__/ \___/ 42 | /___/ Commit %s 43 | ` 44 | 45 | // nolint 46 | var persistFactory = persist.NewFactory( 47 | postgres.Backend(), 48 | sqlite.Backend(), 49 | ) 50 | 51 | // nolint 52 | var ephemeralFactory = ephemeral.NewFactory( 53 | bigcache.Backend(), 54 | redis.Backend(), 55 | ) 56 | 57 | // Server is an instance of Legato. 58 | type Server struct { 59 | *fiber.App 60 | cfg *config.Config 61 | l log.Interface 62 | sonyflake *sonyflake.Sonyflake 63 | } 64 | 65 | // New creates a new server. 66 | func New(l log.Interface) (*Server, error) { 67 | cfg, err := newConfig(l, "configuration") 68 | if err != nil { 69 | return nil, err 70 | } 71 | 72 | persist, err := persistFactory.New(context.TODO(), cfg.Database.Backend, l, cfg) 73 | if err != nil { 74 | return nil, errwrap.Wrap(err, "failed to create persist backend") 75 | } 76 | 77 | ephemeral, err := ephemeralFactory.New(context.TODO(), cfg.Epheremal.Backend, l, cfg) 78 | if err != nil { 79 | return nil, errwrap.Wrap(err, "failed to create ephemeral backend") 80 | } 81 | 82 | keyManager, err := tryMakeKeyManager(cfg.PrivateKeyPath, cfg.PublicKeyPath) 83 | if err != nil { 84 | return nil, err 85 | } 86 | 87 | sonyflake := sonyflake.NewSonyflake(sonyflake.Settings{ 88 | StartTime: time.UnixMilli(cfg.IDStart), 89 | }) 90 | s := newFiber(l, cfg) 91 | api.RegisterHandlers(s, l, cfg, 92 | authv1.NewAuthServiceHandler( 93 | authv1impl.New(keyManager, ephemeral, persist, sonyflake, cfg), 94 | ), 95 | ) 96 | 97 | return &Server{s, cfg, l, sonyflake}, nil 98 | } 99 | 100 | // Listen begins listening to the configured port. 101 | func (s *Server) Listen() error { 102 | s.l.Info(formatStartup(s.cfg.Address, s.cfg.Port)) 103 | 104 | return fmt.Errorf("error occurred while listening %w", s.App.Listen(s.cfg.Address+":"+strconv.Itoa(s.cfg.Port))) 105 | } 106 | 107 | func newConfig(l log.Interface, name string) (*config.Config, error) { 108 | l.Info("Reading config...") 109 | 110 | configReader := config.New(name) 111 | 112 | cfg, err := configReader.ParseConfig() 113 | if err != nil { 114 | return nil, errwrap.Wrap(err, "failed to read config") 115 | } 116 | 117 | if err := configReader.WatchConfig(func(ev fsnotify.Event) { 118 | l.Info("Config change detected, reloading...") 119 | newConfig, err := configReader.ParseConfig() 120 | if err != nil { 121 | l.WithError(err).Error("Failed to reload config") 122 | 123 | return 124 | } 125 | *cfg = *newConfig 126 | }, func(error) {}); err != nil { 127 | return nil, errwrap.Wrap(err, "failed to watch config") 128 | } 129 | 130 | return cfg, nil 131 | } 132 | 133 | func newFiber(l log.Interface, cfg *config.Config) *fiber.App { 134 | s := fiber.New(fiber.Config{ 135 | DisableStartupMessage: true, 136 | ErrorHandler: api.FiberErrorHandler(l, cfg), 137 | }) 138 | 139 | // TODO: move to config variable or smth but make this line shorter 140 | // nolint 141 | logFormat := "[${time}] ${status} |${green}${method}${white}| ${path} ↑${bytesSent} bytes ↓${bytesReceived} bytes ${reqHeader:Authorization}\n" 142 | 143 | s.Use(fiberLogger.New(fiberLogger.Config{ 144 | Format: logFormat, 145 | })) 146 | 147 | return s 148 | } 149 | 150 | func formatStartup(address string, port int) string { 151 | listenText := color.HiMagentaString(fmt.Sprintf("Listening on %s:%d", address, port)) 152 | display := logger.Indent( 153 | log.InfoLevel, 154 | startupMessage, 155 | &listenText, 156 | ) 157 | versionString := color.GreenString(build.Version) 158 | gitString := color.GreenString( 159 | fmt.Sprintf("%.7s", build.GitCommit), 160 | ) 161 | 162 | return fmt.Sprintf(display, versionString, gitString) 163 | } 164 | 165 | func tryMakeKeyManager(privKeyPath string, pubKeyPath string) (key.Manager, error) { 166 | keyManager, err := key.NewEd25519KeyManagerFromFile(privKeyPath, pubKeyPath) 167 | if err == nil { 168 | return keyManager, nil 169 | } 170 | 171 | if !os.IsNotExist(err) { 172 | return nil, errwrap.Wrap(err, "unknown error creating key manager") 173 | } 174 | 175 | if err := key.WriteEd25519KeysToFile(privKeyPath, pubKeyPath); err != nil { 176 | return nil, fmt.Errorf("failed to save keys: %w", err) 177 | } 178 | 179 | keyManager, err = key.NewEd25519KeyManagerFromFile(privKeyPath, pubKeyPath) 180 | 181 | return keyManager, errwrap.Wrap(err, "failed to make key manager") 182 | } 183 | -------------------------------------------------------------------------------- /gen/profile/v1/profile_hrpc_client.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package profilev1 8 | 9 | import ( 10 | bytes "bytes" 11 | context "context" 12 | proto "google.golang.org/protobuf/proto" 13 | ioutil "io/ioutil" 14 | http "net/http" 15 | httptest "net/http/httptest" 16 | ) 17 | 18 | type ProfileServiceClient interface { 19 | // Gets a user's profile. 20 | GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) 21 | // Updates the user's profile. 22 | UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) 23 | // Gets app data for a user (this can be used to store user preferences which 24 | // is synchronized across devices). 25 | GetAppData(context.Context, *GetAppDataRequest) (*GetAppDataResponse, error) 26 | // Sets the app data for a user. 27 | SetAppData(context.Context, *SetAppDataRequest) (*SetAppDataResponse, error) 28 | } 29 | 30 | type HTTPProfileServiceClient struct { 31 | Client http.Client 32 | BaseURL string 33 | } 34 | 35 | func (client *HTTPProfileServiceClient) GetProfile(req *GetProfileRequest) (*GetProfileResponse, error) { 36 | data, marshalErr := proto.Marshal(req) 37 | if marshalErr != nil { 38 | return nil, marshalErr 39 | } 40 | reader := bytes.NewReader(data) 41 | resp, err := client.Client.Post(client.BaseURL+"/protocol.profile.v1.ProfileService.GetProfile/", "application/hrpc", reader) 42 | if err != nil { 43 | return nil, err 44 | } 45 | body, err := ioutil.ReadAll(resp.Body) 46 | if err != nil { 47 | return nil, err 48 | } 49 | ret := &GetProfileResponse{} 50 | unmarshalErr := proto.Unmarshal(body, ret) 51 | if unmarshalErr != nil { 52 | return nil, unmarshalErr 53 | } 54 | return ret, nil 55 | } 56 | func (client *HTTPProfileServiceClient) UpdateProfile(req *UpdateProfileRequest) (*UpdateProfileResponse, error) { 57 | data, marshalErr := proto.Marshal(req) 58 | if marshalErr != nil { 59 | return nil, marshalErr 60 | } 61 | reader := bytes.NewReader(data) 62 | resp, err := client.Client.Post(client.BaseURL+"/protocol.profile.v1.ProfileService.UpdateProfile/", "application/hrpc", reader) 63 | if err != nil { 64 | return nil, err 65 | } 66 | body, err := ioutil.ReadAll(resp.Body) 67 | if err != nil { 68 | return nil, err 69 | } 70 | ret := &UpdateProfileResponse{} 71 | unmarshalErr := proto.Unmarshal(body, ret) 72 | if unmarshalErr != nil { 73 | return nil, unmarshalErr 74 | } 75 | return ret, nil 76 | } 77 | func (client *HTTPProfileServiceClient) GetAppData(req *GetAppDataRequest) (*GetAppDataResponse, error) { 78 | data, marshalErr := proto.Marshal(req) 79 | if marshalErr != nil { 80 | return nil, marshalErr 81 | } 82 | reader := bytes.NewReader(data) 83 | resp, err := client.Client.Post(client.BaseURL+"/protocol.profile.v1.ProfileService.GetAppData/", "application/hrpc", reader) 84 | if err != nil { 85 | return nil, err 86 | } 87 | body, err := ioutil.ReadAll(resp.Body) 88 | if err != nil { 89 | return nil, err 90 | } 91 | ret := &GetAppDataResponse{} 92 | unmarshalErr := proto.Unmarshal(body, ret) 93 | if unmarshalErr != nil { 94 | return nil, unmarshalErr 95 | } 96 | return ret, nil 97 | } 98 | func (client *HTTPProfileServiceClient) SetAppData(req *SetAppDataRequest) (*SetAppDataResponse, error) { 99 | data, marshalErr := proto.Marshal(req) 100 | if marshalErr != nil { 101 | return nil, marshalErr 102 | } 103 | reader := bytes.NewReader(data) 104 | resp, err := client.Client.Post(client.BaseURL+"/protocol.profile.v1.ProfileService.SetAppData/", "application/hrpc", reader) 105 | if err != nil { 106 | return nil, err 107 | } 108 | body, err := ioutil.ReadAll(resp.Body) 109 | if err != nil { 110 | return nil, err 111 | } 112 | ret := &SetAppDataResponse{} 113 | unmarshalErr := proto.Unmarshal(body, ret) 114 | if unmarshalErr != nil { 115 | return nil, unmarshalErr 116 | } 117 | return ret, nil 118 | } 119 | 120 | type HTTPTestProfileServiceClient struct { 121 | Client interface { 122 | Test(*http.Request, ...int) (*http.Response, error) 123 | } 124 | } 125 | 126 | func (client *HTTPTestProfileServiceClient) GetProfile(req *GetProfileRequest) (*GetProfileResponse, error) { 127 | data, marshalErr := proto.Marshal(req) 128 | if marshalErr != nil { 129 | return nil, marshalErr 130 | } 131 | reader := bytes.NewReader(data) 132 | testreq := httptest.NewRequest("POST", "/protocol.profile.v1.ProfileService.GetProfile/", reader) 133 | resp, err := client.Client.Test(testreq) 134 | if err != nil { 135 | return nil, err 136 | } 137 | body, err := ioutil.ReadAll(resp.Body) 138 | if err != nil { 139 | return nil, err 140 | } 141 | ret := &GetProfileResponse{} 142 | unmarshalErr := proto.Unmarshal(body, ret) 143 | if unmarshalErr != nil { 144 | return nil, unmarshalErr 145 | } 146 | return ret, nil 147 | } 148 | func (client *HTTPTestProfileServiceClient) UpdateProfile(req *UpdateProfileRequest) (*UpdateProfileResponse, error) { 149 | data, marshalErr := proto.Marshal(req) 150 | if marshalErr != nil { 151 | return nil, marshalErr 152 | } 153 | reader := bytes.NewReader(data) 154 | testreq := httptest.NewRequest("POST", "/protocol.profile.v1.ProfileService.UpdateProfile/", reader) 155 | resp, err := client.Client.Test(testreq) 156 | if err != nil { 157 | return nil, err 158 | } 159 | body, err := ioutil.ReadAll(resp.Body) 160 | if err != nil { 161 | return nil, err 162 | } 163 | ret := &UpdateProfileResponse{} 164 | unmarshalErr := proto.Unmarshal(body, ret) 165 | if unmarshalErr != nil { 166 | return nil, unmarshalErr 167 | } 168 | return ret, nil 169 | } 170 | func (client *HTTPTestProfileServiceClient) GetAppData(req *GetAppDataRequest) (*GetAppDataResponse, error) { 171 | data, marshalErr := proto.Marshal(req) 172 | if marshalErr != nil { 173 | return nil, marshalErr 174 | } 175 | reader := bytes.NewReader(data) 176 | testreq := httptest.NewRequest("POST", "/protocol.profile.v1.ProfileService.GetAppData/", reader) 177 | resp, err := client.Client.Test(testreq) 178 | if err != nil { 179 | return nil, err 180 | } 181 | body, err := ioutil.ReadAll(resp.Body) 182 | if err != nil { 183 | return nil, err 184 | } 185 | ret := &GetAppDataResponse{} 186 | unmarshalErr := proto.Unmarshal(body, ret) 187 | if unmarshalErr != nil { 188 | return nil, unmarshalErr 189 | } 190 | return ret, nil 191 | } 192 | func (client *HTTPTestProfileServiceClient) SetAppData(req *SetAppDataRequest) (*SetAppDataResponse, error) { 193 | data, marshalErr := proto.Marshal(req) 194 | if marshalErr != nil { 195 | return nil, marshalErr 196 | } 197 | reader := bytes.NewReader(data) 198 | testreq := httptest.NewRequest("POST", "/protocol.profile.v1.ProfileService.SetAppData/", reader) 199 | resp, err := client.Client.Test(testreq) 200 | if err != nil { 201 | return nil, err 202 | } 203 | body, err := ioutil.ReadAll(resp.Body) 204 | if err != nil { 205 | return nil, err 206 | } 207 | ret := &SetAppDataResponse{} 208 | unmarshalErr := proto.Unmarshal(body, ret) 209 | if unmarshalErr != nil { 210 | return nil, unmarshalErr 211 | } 212 | return ret, nil 213 | } 214 | -------------------------------------------------------------------------------- /LICENSES/CC0-1.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /api/authv1/auth.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 Danil Korennykh 2 | // 3 | // SPDX-License-Identifier: AGPL-3.0-or-later 4 | 5 | package authv1impl 6 | 7 | import ( 8 | "context" 9 | 10 | "github.com/harmony-development/legato/api" 11 | "github.com/harmony-development/legato/config" 12 | "github.com/harmony-development/legato/db/ephemeral" 13 | "github.com/harmony-development/legato/db/persist" 14 | dynamicauth "github.com/harmony-development/legato/dynamic_auth" 15 | "github.com/harmony-development/legato/errwrap" 16 | authv1 "github.com/harmony-development/legato/gen/auth/v1" 17 | "github.com/harmony-development/legato/id" 18 | "github.com/harmony-development/legato/key" 19 | "github.com/thanhpk/randstr" 20 | "golang.org/x/crypto/bcrypt" 21 | ) 22 | 23 | type formHandlerFunc = func( 24 | c context.Context, 25 | submission *authv1.NextStepRequest_Form, 26 | r *authv1.NextStepRequest, 27 | ) ( 28 | *authv1.AuthStep, 29 | error, 30 | ) 31 | 32 | type AuthV1 struct { 33 | authv1.DefaultAuthService 34 | keyManager key.Manager 35 | eph ephemeral.Database 36 | persist persist.Database 37 | cfg *config.Config 38 | idGen id.Generator 39 | steps map[string]dynamicauth.Step 40 | formHandlers map[string]formHandlerFunc 41 | } 42 | 43 | func toStepMap(steps ...dynamicauth.Step) map[string]dynamicauth.Step { 44 | ret := map[string]dynamicauth.Step{} 45 | for _, step := range steps { 46 | ret[step.ID()] = step 47 | } 48 | 49 | return ret 50 | } 51 | 52 | func New( 53 | keyManager key.Manager, 54 | eph ephemeral.Database, 55 | persist persist.Database, 56 | idGen id.Generator, 57 | cfg *config.Config, 58 | ) *AuthV1 { 59 | a := &AuthV1{ 60 | keyManager: keyManager, 61 | eph: eph, 62 | persist: persist, 63 | cfg: cfg, 64 | idGen: idGen, 65 | steps: toStepMap( 66 | initialStep, 67 | loginStep, 68 | registerStep, 69 | otherOptionsStep, 70 | resetPasswordStep, 71 | ), 72 | } 73 | 74 | a.formHandlers = map[string]formHandlerFunc{ 75 | loginStep.ID(): a.loginFormHandler, 76 | registerStep.ID(): a.registerHandler, 77 | } 78 | 79 | return a 80 | } 81 | 82 | // Key responds with the homeserver's public key. 83 | func (v1 *AuthV1) Key(context.Context, *authv1.KeyRequest) (*authv1.KeyResponse, error) { 84 | return &authv1.KeyResponse{ 85 | Key: v1.keyManager.GetPublicKey(), 86 | }, nil 87 | } 88 | 89 | func (v1 *AuthV1) BeginAuth(c context.Context, r *authv1.BeginAuthRequest) (*authv1.BeginAuthResponse, error) { 90 | sessionID := randstr.Hex(v1.cfg.AuthIDLength) 91 | if err := v1.eph.SetStep(c, sessionID, initialStep.ID()); err != nil { 92 | return nil, errwrap.Wrap(err, "failed to set step") 93 | } 94 | 95 | return &authv1.BeginAuthResponse{ 96 | AuthId: sessionID, 97 | }, nil 98 | } 99 | 100 | // NextStep handles dyhnamic auth steps. 101 | func (v1 *AuthV1) NextStep(ctx context.Context, r *authv1.NextStepRequest) (*authv1.NextStepResponse, error) { 102 | // the ID of the step the user is on 103 | currentStepID, err := v1.eph.GetCurrentStep(ctx, r.AuthId) 104 | if err != nil { 105 | return nil, api.NewError(api.ErrorBadAuthID) 106 | } 107 | 108 | res, err := v1.handleStep(ctx, v1.steps[currentStepID], r) 109 | 110 | return &authv1.NextStepResponse{ 111 | Step: res, 112 | }, err 113 | } 114 | 115 | func (v1 *AuthV1) handleStep( 116 | ctx context.Context, 117 | currentStep dynamicauth.Step, 118 | r *authv1.NextStepRequest, 119 | ) ( 120 | *authv1.AuthStep, 121 | error, 122 | ) { 123 | switch currentStep := currentStep.(type) { 124 | case *dynamicauth.ChoiceStep: 125 | return v1.choiceHandler(ctx, currentStep, r) 126 | case *dynamicauth.FormStep: 127 | formSubmission := r.GetForm() 128 | if formSubmission == nil { 129 | return currentStep.ToProtoV1(), nil 130 | } 131 | 132 | if err := currentStep.ValidateFormV1(formSubmission); err != nil { 133 | return nil, api.NewError(api.ErrorBadFormData) 134 | } 135 | 136 | return v1.formHandlers[currentStep.ID()](ctx, formSubmission, r) 137 | default: 138 | return nil, errwrap.Wrap(api.NewError(api.ErrorBadStep), "invalid auth step") 139 | } 140 | } 141 | 142 | // choiceHandler contains logic related to any choice step. 143 | func (v1 *AuthV1) choiceHandler( 144 | ctx context.Context, 145 | choiceStep *dynamicauth.ChoiceStep, 146 | r *authv1.NextStepRequest, 147 | ) ( 148 | *authv1.AuthStep, 149 | error, 150 | ) { 151 | c := r.GetChoice() 152 | if c == nil { 153 | return choiceStep.ToProtoV1(), nil 154 | } 155 | 156 | if !choiceStep.HasOption(c.Choice) { 157 | return nil, api.NewError(api.ErrorBadChoice) 158 | } 159 | 160 | if err := v1.eph.SetStep(ctx, r.AuthId, c.Choice); err != nil { 161 | return nil, api.NewError(api.ErrorInternalServerError) 162 | } 163 | 164 | nextStep := v1.steps[c.Choice] 165 | 166 | return nextStep.ToProtoV1(), nil 167 | } 168 | 169 | // loginFormHandler handles the login form step. 170 | func (v1 *AuthV1) loginFormHandler( 171 | c context.Context, 172 | submission *authv1.NextStepRequest_Form, 173 | r *authv1.NextStepRequest, 174 | ) ( 175 | *authv1.AuthStep, 176 | error, 177 | ) { 178 | email := submission.Fields[0].GetString_() 179 | provided := submission.Fields[1].GetBytes() 180 | 181 | user, local, err := v1.persist.Users().GetLocalByEmail(c, email) 182 | if err != nil { 183 | return nil, api.NewError(api.ErrorBadCredentials) 184 | } 185 | 186 | if err := bcrypt.CompareHashAndPassword(local.Password, provided); err != nil { 187 | // intentionally generic error to give less information to the user 188 | return nil, api.NewError(api.ErrorBadCredentials) 189 | } 190 | 191 | // login succeessful 192 | session, err := v1.finishAuth(c, r.AuthId, user.ID) 193 | if err != nil { 194 | return nil, err 195 | } 196 | 197 | return &authv1.AuthStep{ 198 | Step: &authv1.AuthStep_Session{ 199 | Session: session, 200 | }, 201 | }, nil 202 | } 203 | 204 | // registerHandler handles the register form step. 205 | func (v1 *AuthV1) registerHandler( 206 | c context.Context, 207 | submission *authv1.NextStepRequest_Form, 208 | r *authv1.NextStepRequest, 209 | ) ( 210 | *authv1.AuthStep, 211 | error, 212 | ) { 213 | email := submission.Fields[0].GetString_() 214 | username := submission.Fields[1].GetString_() 215 | password := submission.Fields[2].GetBytes() 216 | 217 | id, err := v1.idGen.NextID() 218 | if err != nil { 219 | return nil, errwrap.Wrap(err, "unable to generate new user ID") 220 | } 221 | 222 | pass, err := bcrypt.GenerateFromPassword(password, bcrypt.DefaultCost) 223 | if err != nil { 224 | return nil, api.NewError(api.ErrorInternalServerError) 225 | } 226 | 227 | if err := v1.persist.Users().Add(c, persist.UserInformation{ 228 | ID: id, 229 | Username: username, 230 | }, persist.LocalUserInformation{ 231 | Email: email, 232 | Password: pass, 233 | }); err != nil { 234 | return nil, errwrap.Wrap(err, "failed to add user") 235 | } 236 | 237 | // login succeessful 238 | session, err := v1.finishAuth(c, r.AuthId, id) 239 | if err != nil { 240 | return nil, err 241 | } 242 | 243 | return &authv1.AuthStep{ 244 | Step: &authv1.AuthStep_Session{ 245 | Session: session, 246 | }, 247 | }, nil 248 | } 249 | 250 | func (v1 *AuthV1) finishAuth(c context.Context, authID string, userID uint64) (*authv1.Session, error) { 251 | sessionID := randstr.Hex(v1.cfg.AuthIDLength) 252 | 253 | if err := v1.persist.Sessions().Add(c, sessionID, userID); err != nil { 254 | return nil, errwrap.Wrap(err, "failed to add session") 255 | } 256 | 257 | if err := v1.eph.DeleteAuthID(c, authID); err != nil { 258 | return nil, errwrap.Wrap(err, "failed to delete auth ID") 259 | } 260 | 261 | return &authv1.Session{ 262 | UserId: userID, 263 | SessionToken: sessionID, 264 | }, nil 265 | } 266 | -------------------------------------------------------------------------------- /gen/profile/v1/profile.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go. DO NOT EDIT. 6 | // versions: 7 | // protoc-gen-go v1.27.1 8 | // protoc v3.17.3 9 | // source: profile/v1/profile.proto 10 | 11 | package profilev1 12 | 13 | import ( 14 | _ "github.com/harmony-development/legato/gen/harmonytypes/v1" 15 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 16 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 17 | reflect "reflect" 18 | ) 19 | 20 | const ( 21 | // Verify that this generated code is sufficiently up-to-date. 22 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 23 | // Verify that runtime/protoimpl is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 25 | ) 26 | 27 | var File_profile_v1_profile_proto protoreflect.FileDescriptor 28 | 29 | var file_profile_v1_profile_proto_rawDesc = []byte{ 30 | 0x0a, 0x18, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x72, 0x6f, 31 | 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x70, 0x72, 0x6f, 0x74, 32 | 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 33 | 0x1b, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x76, 0x31, 34 | 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x70, 0x72, 35 | 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 36 | 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xa7, 0x03, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 37 | 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x50, 0x72, 38 | 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 39 | 0x2e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 40 | 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 41 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 42 | 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 43 | 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 0x08, 0x01, 0x12, 0x68, 0x0a, 44 | 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x29, 45 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 46 | 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 47 | 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 48 | 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 49 | 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 50 | 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x41, 0x70, 51 | 0x70, 0x44, 0x61, 0x74, 0x61, 0x12, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 52 | 0x2e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 53 | 0x70, 0x70, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 54 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 55 | 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x70, 0x70, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 56 | 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 0x08, 0x01, 0x12, 0x5f, 0x0a, 57 | 0x0a, 0x53, 0x65, 0x74, 0x41, 0x70, 0x70, 0x44, 0x61, 0x74, 0x61, 0x12, 0x26, 0x2e, 0x70, 0x72, 58 | 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 59 | 0x31, 0x2e, 0x53, 0x65, 0x74, 0x41, 0x70, 0x70, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 60 | 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 61 | 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x41, 0x70, 0x70, 62 | 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xd5, 63 | 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 64 | 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x50, 0x72, 0x6f, 0x66, 65 | 0x69, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 66 | 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2d, 0x64, 67 | 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x6c, 0x65, 0x67, 0x61, 0x74, 68 | 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x76, 0x31, 69 | 0x3b, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x50, 0x50, 0x58, 70 | 0xaa, 0x02, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x66, 71 | 0x69, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 72 | 0x6c, 0x5c, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1f, 0x50, 73 | 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5c, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x5c, 74 | 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 75 | 0x15, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x3a, 0x3a, 0x50, 0x72, 0x6f, 0x66, 0x69, 76 | 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 77 | } 78 | 79 | var file_profile_v1_profile_proto_goTypes = []interface{}{ 80 | (*GetProfileRequest)(nil), // 0: protocol.profile.v1.GetProfileRequest 81 | (*UpdateProfileRequest)(nil), // 1: protocol.profile.v1.UpdateProfileRequest 82 | (*GetAppDataRequest)(nil), // 2: protocol.profile.v1.GetAppDataRequest 83 | (*SetAppDataRequest)(nil), // 3: protocol.profile.v1.SetAppDataRequest 84 | (*GetProfileResponse)(nil), // 4: protocol.profile.v1.GetProfileResponse 85 | (*UpdateProfileResponse)(nil), // 5: protocol.profile.v1.UpdateProfileResponse 86 | (*GetAppDataResponse)(nil), // 6: protocol.profile.v1.GetAppDataResponse 87 | (*SetAppDataResponse)(nil), // 7: protocol.profile.v1.SetAppDataResponse 88 | } 89 | var file_profile_v1_profile_proto_depIdxs = []int32{ 90 | 0, // 0: protocol.profile.v1.ProfileService.GetProfile:input_type -> protocol.profile.v1.GetProfileRequest 91 | 1, // 1: protocol.profile.v1.ProfileService.UpdateProfile:input_type -> protocol.profile.v1.UpdateProfileRequest 92 | 2, // 2: protocol.profile.v1.ProfileService.GetAppData:input_type -> protocol.profile.v1.GetAppDataRequest 93 | 3, // 3: protocol.profile.v1.ProfileService.SetAppData:input_type -> protocol.profile.v1.SetAppDataRequest 94 | 4, // 4: protocol.profile.v1.ProfileService.GetProfile:output_type -> protocol.profile.v1.GetProfileResponse 95 | 5, // 5: protocol.profile.v1.ProfileService.UpdateProfile:output_type -> protocol.profile.v1.UpdateProfileResponse 96 | 6, // 6: protocol.profile.v1.ProfileService.GetAppData:output_type -> protocol.profile.v1.GetAppDataResponse 97 | 7, // 7: protocol.profile.v1.ProfileService.SetAppData:output_type -> protocol.profile.v1.SetAppDataResponse 98 | 4, // [4:8] is the sub-list for method output_type 99 | 0, // [0:4] is the sub-list for method input_type 100 | 0, // [0:0] is the sub-list for extension type_name 101 | 0, // [0:0] is the sub-list for extension extendee 102 | 0, // [0:0] is the sub-list for field type_name 103 | } 104 | 105 | func init() { file_profile_v1_profile_proto_init() } 106 | func file_profile_v1_profile_proto_init() { 107 | if File_profile_v1_profile_proto != nil { 108 | return 109 | } 110 | file_profile_v1_types_proto_init() 111 | type x struct{} 112 | out := protoimpl.TypeBuilder{ 113 | File: protoimpl.DescBuilder{ 114 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 115 | RawDescriptor: file_profile_v1_profile_proto_rawDesc, 116 | NumEnums: 0, 117 | NumMessages: 0, 118 | NumExtensions: 0, 119 | NumServices: 1, 120 | }, 121 | GoTypes: file_profile_v1_profile_proto_goTypes, 122 | DependencyIndexes: file_profile_v1_profile_proto_depIdxs, 123 | }.Build() 124 | File_profile_v1_profile_proto = out.File 125 | file_profile_v1_profile_proto_rawDesc = nil 126 | file_profile_v1_profile_proto_goTypes = nil 127 | file_profile_v1_profile_proto_depIdxs = nil 128 | } 129 | -------------------------------------------------------------------------------- /gen/auth/v1/auth_hrpc_client.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package authv1 8 | 9 | import ( 10 | bytes "bytes" 11 | context "context" 12 | errors "errors" 13 | proto "google.golang.org/protobuf/proto" 14 | ioutil "io/ioutil" 15 | http "net/http" 16 | httptest "net/http/httptest" 17 | ) 18 | 19 | type AuthServiceClient interface { 20 | // Federate with a foreignserver, obtaining a token 21 | // you can use to call LoginFederated on it 22 | Federate(context.Context, *FederateRequest) (*FederateResponse, error) 23 | // Present a token to a foreignserver from a Federate call 24 | // on your homeserver in order to login 25 | LoginFederated(context.Context, *LoginFederatedRequest) (*LoginFederatedResponse, error) 26 | // Returns the public key of this server 27 | Key(context.Context, *KeyRequest) (*KeyResponse, error) 28 | // Begins an authentication session 29 | BeginAuth(context.Context, *BeginAuthRequest) (*BeginAuthResponse, error) 30 | // Goes to the next step of the authentication session, 31 | // possibly presenting user input 32 | NextStep(context.Context, *NextStepRequest) (*NextStepResponse, error) 33 | // Goes to the previous step of the authentication session 34 | // if possible 35 | StepBack(context.Context, *StepBackRequest) (*StepBackResponse, error) 36 | // Consume the steps of an authentication session 37 | // as a stream 38 | StreamSteps(context.Context, *StreamStepsRequest) (chan *StreamStepsResponse, error) 39 | // Check whether or not you're logged in and the session is valid 40 | CheckLoggedIn(context.Context, *CheckLoggedInRequest) (*CheckLoggedInResponse, error) 41 | } 42 | 43 | type HTTPAuthServiceClient struct { 44 | Client http.Client 45 | BaseURL string 46 | } 47 | 48 | func (client *HTTPAuthServiceClient) Federate(req *FederateRequest) (*FederateResponse, error) { 49 | data, marshalErr := proto.Marshal(req) 50 | if marshalErr != nil { 51 | return nil, marshalErr 52 | } 53 | reader := bytes.NewReader(data) 54 | resp, err := client.Client.Post(client.BaseURL+"/protocol.auth.v1.AuthService.Federate/", "application/hrpc", reader) 55 | if err != nil { 56 | return nil, err 57 | } 58 | body, err := ioutil.ReadAll(resp.Body) 59 | if err != nil { 60 | return nil, err 61 | } 62 | ret := &FederateResponse{} 63 | unmarshalErr := proto.Unmarshal(body, ret) 64 | if unmarshalErr != nil { 65 | return nil, unmarshalErr 66 | } 67 | return ret, nil 68 | } 69 | func (client *HTTPAuthServiceClient) LoginFederated(req *LoginFederatedRequest) (*LoginFederatedResponse, error) { 70 | data, marshalErr := proto.Marshal(req) 71 | if marshalErr != nil { 72 | return nil, marshalErr 73 | } 74 | reader := bytes.NewReader(data) 75 | resp, err := client.Client.Post(client.BaseURL+"/protocol.auth.v1.AuthService.LoginFederated/", "application/hrpc", reader) 76 | if err != nil { 77 | return nil, err 78 | } 79 | body, err := ioutil.ReadAll(resp.Body) 80 | if err != nil { 81 | return nil, err 82 | } 83 | ret := &LoginFederatedResponse{} 84 | unmarshalErr := proto.Unmarshal(body, ret) 85 | if unmarshalErr != nil { 86 | return nil, unmarshalErr 87 | } 88 | return ret, nil 89 | } 90 | func (client *HTTPAuthServiceClient) Key(req *KeyRequest) (*KeyResponse, error) { 91 | data, marshalErr := proto.Marshal(req) 92 | if marshalErr != nil { 93 | return nil, marshalErr 94 | } 95 | reader := bytes.NewReader(data) 96 | resp, err := client.Client.Post(client.BaseURL+"/protocol.auth.v1.AuthService.Key/", "application/hrpc", reader) 97 | if err != nil { 98 | return nil, err 99 | } 100 | body, err := ioutil.ReadAll(resp.Body) 101 | if err != nil { 102 | return nil, err 103 | } 104 | ret := &KeyResponse{} 105 | unmarshalErr := proto.Unmarshal(body, ret) 106 | if unmarshalErr != nil { 107 | return nil, unmarshalErr 108 | } 109 | return ret, nil 110 | } 111 | func (client *HTTPAuthServiceClient) BeginAuth(req *BeginAuthRequest) (*BeginAuthResponse, error) { 112 | data, marshalErr := proto.Marshal(req) 113 | if marshalErr != nil { 114 | return nil, marshalErr 115 | } 116 | reader := bytes.NewReader(data) 117 | resp, err := client.Client.Post(client.BaseURL+"/protocol.auth.v1.AuthService.BeginAuth/", "application/hrpc", reader) 118 | if err != nil { 119 | return nil, err 120 | } 121 | body, err := ioutil.ReadAll(resp.Body) 122 | if err != nil { 123 | return nil, err 124 | } 125 | ret := &BeginAuthResponse{} 126 | unmarshalErr := proto.Unmarshal(body, ret) 127 | if unmarshalErr != nil { 128 | return nil, unmarshalErr 129 | } 130 | return ret, nil 131 | } 132 | func (client *HTTPAuthServiceClient) NextStep(req *NextStepRequest) (*NextStepResponse, error) { 133 | data, marshalErr := proto.Marshal(req) 134 | if marshalErr != nil { 135 | return nil, marshalErr 136 | } 137 | reader := bytes.NewReader(data) 138 | resp, err := client.Client.Post(client.BaseURL+"/protocol.auth.v1.AuthService.NextStep/", "application/hrpc", reader) 139 | if err != nil { 140 | return nil, err 141 | } 142 | body, err := ioutil.ReadAll(resp.Body) 143 | if err != nil { 144 | return nil, err 145 | } 146 | ret := &NextStepResponse{} 147 | unmarshalErr := proto.Unmarshal(body, ret) 148 | if unmarshalErr != nil { 149 | return nil, unmarshalErr 150 | } 151 | return ret, nil 152 | } 153 | func (client *HTTPAuthServiceClient) StepBack(req *StepBackRequest) (*StepBackResponse, error) { 154 | data, marshalErr := proto.Marshal(req) 155 | if marshalErr != nil { 156 | return nil, marshalErr 157 | } 158 | reader := bytes.NewReader(data) 159 | resp, err := client.Client.Post(client.BaseURL+"/protocol.auth.v1.AuthService.StepBack/", "application/hrpc", reader) 160 | if err != nil { 161 | return nil, err 162 | } 163 | body, err := ioutil.ReadAll(resp.Body) 164 | if err != nil { 165 | return nil, err 166 | } 167 | ret := &StepBackResponse{} 168 | unmarshalErr := proto.Unmarshal(body, ret) 169 | if unmarshalErr != nil { 170 | return nil, unmarshalErr 171 | } 172 | return ret, nil 173 | } 174 | func (client *HTTPAuthServiceClient) StreamSteps(req *StreamStepsRequest) (chan *StreamStepsResponse, error) { 175 | return nil, errors.New("unimplemented") 176 | } 177 | func (client *HTTPAuthServiceClient) CheckLoggedIn(req *CheckLoggedInRequest) (*CheckLoggedInResponse, error) { 178 | data, marshalErr := proto.Marshal(req) 179 | if marshalErr != nil { 180 | return nil, marshalErr 181 | } 182 | reader := bytes.NewReader(data) 183 | resp, err := client.Client.Post(client.BaseURL+"/protocol.auth.v1.AuthService.CheckLoggedIn/", "application/hrpc", reader) 184 | if err != nil { 185 | return nil, err 186 | } 187 | body, err := ioutil.ReadAll(resp.Body) 188 | if err != nil { 189 | return nil, err 190 | } 191 | ret := &CheckLoggedInResponse{} 192 | unmarshalErr := proto.Unmarshal(body, ret) 193 | if unmarshalErr != nil { 194 | return nil, unmarshalErr 195 | } 196 | return ret, nil 197 | } 198 | 199 | type HTTPTestAuthServiceClient struct { 200 | Client interface { 201 | Test(*http.Request, ...int) (*http.Response, error) 202 | } 203 | } 204 | 205 | func (client *HTTPTestAuthServiceClient) Federate(req *FederateRequest) (*FederateResponse, error) { 206 | data, marshalErr := proto.Marshal(req) 207 | if marshalErr != nil { 208 | return nil, marshalErr 209 | } 210 | reader := bytes.NewReader(data) 211 | testreq := httptest.NewRequest("POST", "/protocol.auth.v1.AuthService.Federate/", reader) 212 | resp, err := client.Client.Test(testreq) 213 | if err != nil { 214 | return nil, err 215 | } 216 | body, err := ioutil.ReadAll(resp.Body) 217 | if err != nil { 218 | return nil, err 219 | } 220 | ret := &FederateResponse{} 221 | unmarshalErr := proto.Unmarshal(body, ret) 222 | if unmarshalErr != nil { 223 | return nil, unmarshalErr 224 | } 225 | return ret, nil 226 | } 227 | func (client *HTTPTestAuthServiceClient) LoginFederated(req *LoginFederatedRequest) (*LoginFederatedResponse, error) { 228 | data, marshalErr := proto.Marshal(req) 229 | if marshalErr != nil { 230 | return nil, marshalErr 231 | } 232 | reader := bytes.NewReader(data) 233 | testreq := httptest.NewRequest("POST", "/protocol.auth.v1.AuthService.LoginFederated/", reader) 234 | resp, err := client.Client.Test(testreq) 235 | if err != nil { 236 | return nil, err 237 | } 238 | body, err := ioutil.ReadAll(resp.Body) 239 | if err != nil { 240 | return nil, err 241 | } 242 | ret := &LoginFederatedResponse{} 243 | unmarshalErr := proto.Unmarshal(body, ret) 244 | if unmarshalErr != nil { 245 | return nil, unmarshalErr 246 | } 247 | return ret, nil 248 | } 249 | func (client *HTTPTestAuthServiceClient) Key(req *KeyRequest) (*KeyResponse, error) { 250 | data, marshalErr := proto.Marshal(req) 251 | if marshalErr != nil { 252 | return nil, marshalErr 253 | } 254 | reader := bytes.NewReader(data) 255 | testreq := httptest.NewRequest("POST", "/protocol.auth.v1.AuthService.Key/", reader) 256 | resp, err := client.Client.Test(testreq) 257 | if err != nil { 258 | return nil, err 259 | } 260 | body, err := ioutil.ReadAll(resp.Body) 261 | if err != nil { 262 | return nil, err 263 | } 264 | ret := &KeyResponse{} 265 | unmarshalErr := proto.Unmarshal(body, ret) 266 | if unmarshalErr != nil { 267 | return nil, unmarshalErr 268 | } 269 | return ret, nil 270 | } 271 | func (client *HTTPTestAuthServiceClient) BeginAuth(req *BeginAuthRequest) (*BeginAuthResponse, error) { 272 | data, marshalErr := proto.Marshal(req) 273 | if marshalErr != nil { 274 | return nil, marshalErr 275 | } 276 | reader := bytes.NewReader(data) 277 | testreq := httptest.NewRequest("POST", "/protocol.auth.v1.AuthService.BeginAuth/", reader) 278 | resp, err := client.Client.Test(testreq) 279 | if err != nil { 280 | return nil, err 281 | } 282 | body, err := ioutil.ReadAll(resp.Body) 283 | if err != nil { 284 | return nil, err 285 | } 286 | ret := &BeginAuthResponse{} 287 | unmarshalErr := proto.Unmarshal(body, ret) 288 | if unmarshalErr != nil { 289 | return nil, unmarshalErr 290 | } 291 | return ret, nil 292 | } 293 | func (client *HTTPTestAuthServiceClient) NextStep(req *NextStepRequest) (*NextStepResponse, error) { 294 | data, marshalErr := proto.Marshal(req) 295 | if marshalErr != nil { 296 | return nil, marshalErr 297 | } 298 | reader := bytes.NewReader(data) 299 | testreq := httptest.NewRequest("POST", "/protocol.auth.v1.AuthService.NextStep/", reader) 300 | resp, err := client.Client.Test(testreq) 301 | if err != nil { 302 | return nil, err 303 | } 304 | body, err := ioutil.ReadAll(resp.Body) 305 | if err != nil { 306 | return nil, err 307 | } 308 | ret := &NextStepResponse{} 309 | unmarshalErr := proto.Unmarshal(body, ret) 310 | if unmarshalErr != nil { 311 | return nil, unmarshalErr 312 | } 313 | return ret, nil 314 | } 315 | func (client *HTTPTestAuthServiceClient) StepBack(req *StepBackRequest) (*StepBackResponse, error) { 316 | data, marshalErr := proto.Marshal(req) 317 | if marshalErr != nil { 318 | return nil, marshalErr 319 | } 320 | reader := bytes.NewReader(data) 321 | testreq := httptest.NewRequest("POST", "/protocol.auth.v1.AuthService.StepBack/", reader) 322 | resp, err := client.Client.Test(testreq) 323 | if err != nil { 324 | return nil, err 325 | } 326 | body, err := ioutil.ReadAll(resp.Body) 327 | if err != nil { 328 | return nil, err 329 | } 330 | ret := &StepBackResponse{} 331 | unmarshalErr := proto.Unmarshal(body, ret) 332 | if unmarshalErr != nil { 333 | return nil, unmarshalErr 334 | } 335 | return ret, nil 336 | } 337 | func (client *HTTPTestAuthServiceClient) StreamSteps(req *StreamStepsRequest) (chan *StreamStepsResponse, error) { 338 | return nil, errors.New("unimplemented") 339 | } 340 | func (client *HTTPTestAuthServiceClient) CheckLoggedIn(req *CheckLoggedInRequest) (*CheckLoggedInResponse, error) { 341 | data, marshalErr := proto.Marshal(req) 342 | if marshalErr != nil { 343 | return nil, marshalErr 344 | } 345 | reader := bytes.NewReader(data) 346 | testreq := httptest.NewRequest("POST", "/protocol.auth.v1.AuthService.CheckLoggedIn/", reader) 347 | resp, err := client.Client.Test(testreq) 348 | if err != nil { 349 | return nil, err 350 | } 351 | body, err := ioutil.ReadAll(resp.Body) 352 | if err != nil { 353 | return nil, err 354 | } 355 | ret := &CheckLoggedInResponse{} 356 | unmarshalErr := proto.Unmarshal(body, ret) 357 | if unmarshalErr != nil { 358 | return nil, unmarshalErr 359 | } 360 | return ret, nil 361 | } 362 | -------------------------------------------------------------------------------- /gen/emote/v1/emote.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go. DO NOT EDIT. 6 | // versions: 7 | // protoc-gen-go v1.27.1 8 | // protoc v3.17.3 9 | // source: emote/v1/emote.proto 10 | 11 | package emotev1 12 | 13 | import ( 14 | _ "github.com/harmony-development/legato/gen/harmonytypes/v1" 15 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 16 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 17 | reflect "reflect" 18 | ) 19 | 20 | const ( 21 | // Verify that this generated code is sufficiently up-to-date. 22 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 23 | // Verify that runtime/protoimpl is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 25 | ) 26 | 27 | var File_emote_v1_emote_proto protoreflect.FileDescriptor 28 | 29 | var file_emote_v1_emote_proto_rawDesc = []byte{ 30 | 0x0a, 0x14, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x6d, 0x6f, 0x74, 0x65, 31 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 32 | 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1b, 0x68, 0x61, 0x72, 0x6d, 0x6f, 33 | 0x6e, 0x79, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 34 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x76, 0x31, 35 | 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x9f, 0x07, 0x0a, 36 | 0x0c, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6f, 0x0a, 37 | 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 38 | 0x12, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 39 | 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6d, 0x6f, 0x74, 0x65, 40 | 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x70, 0x72, 41 | 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 42 | 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 43 | 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 0x08, 0x01, 0x12, 0x69, 44 | 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x73, 0x12, 45 | 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 46 | 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 47 | 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 48 | 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 49 | 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 50 | 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 0x08, 0x01, 0x12, 0x78, 0x0a, 0x12, 0x47, 0x65, 0x74, 51 | 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x73, 0x12, 52 | 0x2c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 53 | 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 54 | 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 55 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 56 | 0x31, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x45, 0x6d, 57 | 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 58 | 0x02, 0x08, 0x01, 0x12, 0x6c, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x54, 59 | 0x6f, 0x50, 0x61, 0x63, 0x6b, 0x12, 0x28, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 60 | 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x45, 0x6d, 0x6f, 61 | 0x74, 0x65, 0x54, 0x6f, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 62 | 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 63 | 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x54, 0x6f, 0x50, 0x61, 64 | 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 0x08, 65 | 0x01, 0x12, 0x6f, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x6d, 0x6f, 0x74, 0x65, 66 | 0x50, 0x61, 0x63, 0x6b, 0x12, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 67 | 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 68 | 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 69 | 0x2a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 70 | 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 71 | 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 72 | 0x08, 0x01, 0x12, 0x7b, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x45, 0x6d, 0x6f, 0x74, 73 | 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x50, 0x61, 0x63, 0x6b, 0x12, 0x2d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 74 | 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 75 | 0x6c, 0x65, 0x74, 0x65, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x50, 0x61, 0x63, 76 | 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 77 | 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 78 | 0x65, 0x74, 0x65, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x50, 0x61, 0x63, 0x6b, 79 | 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 0x08, 0x01, 0x12, 80 | 0x6f, 0x0a, 0x0f, 0x44, 0x65, 0x71, 0x75, 0x69, 0x70, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 81 | 0x63, 0x6b, 0x12, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 82 | 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x71, 0x75, 0x69, 0x70, 0x45, 0x6d, 0x6f, 83 | 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 84 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 85 | 0x31, 0x2e, 0x44, 0x65, 0x71, 0x75, 0x69, 0x70, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 86 | 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 0x08, 0x01, 87 | 0x12, 0x6c, 0x0a, 0x0e, 0x45, 0x71, 0x75, 0x69, 0x70, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 88 | 0x63, 0x6b, 0x12, 0x28, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 89 | 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x71, 0x75, 0x69, 0x70, 0x45, 0x6d, 0x6f, 0x74, 90 | 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, 91 | 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 92 | 0x2e, 0x45, 0x71, 0x75, 0x69, 0x70, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 93 | 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 0x08, 0x01, 0x42, 0xc5, 94 | 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 95 | 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x50, 96 | 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 97 | 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2d, 0x64, 0x65, 0x76, 0x65, 0x6c, 98 | 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x2f, 0x67, 0x65, 99 | 0x6e, 0x2f, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x65, 0x6d, 0x6f, 0x74, 0x65, 100 | 0x76, 0x31, 0xa2, 0x02, 0x03, 0x50, 0x45, 0x58, 0xaa, 0x02, 0x11, 0x50, 0x72, 0x6f, 0x74, 0x6f, 101 | 0x63, 0x6f, 0x6c, 0x2e, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x11, 0x50, 102 | 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5c, 0x45, 0x6d, 0x6f, 0x74, 0x65, 0x5c, 0x56, 0x31, 103 | 0xe2, 0x02, 0x1d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5c, 0x45, 0x6d, 0x6f, 0x74, 104 | 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 105 | 0xea, 0x02, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x3a, 0x3a, 0x45, 0x6d, 0x6f, 106 | 0x74, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 107 | } 108 | 109 | var file_emote_v1_emote_proto_goTypes = []interface{}{ 110 | (*CreateEmotePackRequest)(nil), // 0: protocol.emote.v1.CreateEmotePackRequest 111 | (*GetEmotePacksRequest)(nil), // 1: protocol.emote.v1.GetEmotePacksRequest 112 | (*GetEmotePackEmotesRequest)(nil), // 2: protocol.emote.v1.GetEmotePackEmotesRequest 113 | (*AddEmoteToPackRequest)(nil), // 3: protocol.emote.v1.AddEmoteToPackRequest 114 | (*DeleteEmotePackRequest)(nil), // 4: protocol.emote.v1.DeleteEmotePackRequest 115 | (*DeleteEmoteFromPackRequest)(nil), // 5: protocol.emote.v1.DeleteEmoteFromPackRequest 116 | (*DequipEmotePackRequest)(nil), // 6: protocol.emote.v1.DequipEmotePackRequest 117 | (*EquipEmotePackRequest)(nil), // 7: protocol.emote.v1.EquipEmotePackRequest 118 | (*CreateEmotePackResponse)(nil), // 8: protocol.emote.v1.CreateEmotePackResponse 119 | (*GetEmotePacksResponse)(nil), // 9: protocol.emote.v1.GetEmotePacksResponse 120 | (*GetEmotePackEmotesResponse)(nil), // 10: protocol.emote.v1.GetEmotePackEmotesResponse 121 | (*AddEmoteToPackResponse)(nil), // 11: protocol.emote.v1.AddEmoteToPackResponse 122 | (*DeleteEmotePackResponse)(nil), // 12: protocol.emote.v1.DeleteEmotePackResponse 123 | (*DeleteEmoteFromPackResponse)(nil), // 13: protocol.emote.v1.DeleteEmoteFromPackResponse 124 | (*DequipEmotePackResponse)(nil), // 14: protocol.emote.v1.DequipEmotePackResponse 125 | (*EquipEmotePackResponse)(nil), // 15: protocol.emote.v1.EquipEmotePackResponse 126 | } 127 | var file_emote_v1_emote_proto_depIdxs = []int32{ 128 | 0, // 0: protocol.emote.v1.EmoteService.CreateEmotePack:input_type -> protocol.emote.v1.CreateEmotePackRequest 129 | 1, // 1: protocol.emote.v1.EmoteService.GetEmotePacks:input_type -> protocol.emote.v1.GetEmotePacksRequest 130 | 2, // 2: protocol.emote.v1.EmoteService.GetEmotePackEmotes:input_type -> protocol.emote.v1.GetEmotePackEmotesRequest 131 | 3, // 3: protocol.emote.v1.EmoteService.AddEmoteToPack:input_type -> protocol.emote.v1.AddEmoteToPackRequest 132 | 4, // 4: protocol.emote.v1.EmoteService.DeleteEmotePack:input_type -> protocol.emote.v1.DeleteEmotePackRequest 133 | 5, // 5: protocol.emote.v1.EmoteService.DeleteEmoteFromPack:input_type -> protocol.emote.v1.DeleteEmoteFromPackRequest 134 | 6, // 6: protocol.emote.v1.EmoteService.DequipEmotePack:input_type -> protocol.emote.v1.DequipEmotePackRequest 135 | 7, // 7: protocol.emote.v1.EmoteService.EquipEmotePack:input_type -> protocol.emote.v1.EquipEmotePackRequest 136 | 8, // 8: protocol.emote.v1.EmoteService.CreateEmotePack:output_type -> protocol.emote.v1.CreateEmotePackResponse 137 | 9, // 9: protocol.emote.v1.EmoteService.GetEmotePacks:output_type -> protocol.emote.v1.GetEmotePacksResponse 138 | 10, // 10: protocol.emote.v1.EmoteService.GetEmotePackEmotes:output_type -> protocol.emote.v1.GetEmotePackEmotesResponse 139 | 11, // 11: protocol.emote.v1.EmoteService.AddEmoteToPack:output_type -> protocol.emote.v1.AddEmoteToPackResponse 140 | 12, // 12: protocol.emote.v1.EmoteService.DeleteEmotePack:output_type -> protocol.emote.v1.DeleteEmotePackResponse 141 | 13, // 13: protocol.emote.v1.EmoteService.DeleteEmoteFromPack:output_type -> protocol.emote.v1.DeleteEmoteFromPackResponse 142 | 14, // 14: protocol.emote.v1.EmoteService.DequipEmotePack:output_type -> protocol.emote.v1.DequipEmotePackResponse 143 | 15, // 15: protocol.emote.v1.EmoteService.EquipEmotePack:output_type -> protocol.emote.v1.EquipEmotePackResponse 144 | 8, // [8:16] is the sub-list for method output_type 145 | 0, // [0:8] is the sub-list for method input_type 146 | 0, // [0:0] is the sub-list for extension type_name 147 | 0, // [0:0] is the sub-list for extension extendee 148 | 0, // [0:0] is the sub-list for field type_name 149 | } 150 | 151 | func init() { file_emote_v1_emote_proto_init() } 152 | func file_emote_v1_emote_proto_init() { 153 | if File_emote_v1_emote_proto != nil { 154 | return 155 | } 156 | file_emote_v1_types_proto_init() 157 | type x struct{} 158 | out := protoimpl.TypeBuilder{ 159 | File: protoimpl.DescBuilder{ 160 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 161 | RawDescriptor: file_emote_v1_emote_proto_rawDesc, 162 | NumEnums: 0, 163 | NumMessages: 0, 164 | NumExtensions: 0, 165 | NumServices: 1, 166 | }, 167 | GoTypes: file_emote_v1_emote_proto_goTypes, 168 | DependencyIndexes: file_emote_v1_emote_proto_depIdxs, 169 | }.Build() 170 | File_emote_v1_emote_proto = out.File 171 | file_emote_v1_emote_proto_rawDesc = nil 172 | file_emote_v1_emote_proto_goTypes = nil 173 | file_emote_v1_emote_proto_depIdxs = nil 174 | } 175 | -------------------------------------------------------------------------------- /gen/profile/v1/stream.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go. DO NOT EDIT. 6 | // versions: 7 | // protoc-gen-go v1.27.1 8 | // protoc v3.17.3 9 | // source: profile/v1/stream.proto 10 | 11 | package profilev1 12 | 13 | import ( 14 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 15 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 16 | reflect "reflect" 17 | sync "sync" 18 | ) 19 | 20 | const ( 21 | // Verify that this generated code is sufficiently up-to-date. 22 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 23 | // Verify that runtime/protoimpl is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 25 | ) 26 | 27 | // Event sent when a user's profile is updated. 28 | // 29 | // Servers should sent this event only to users that can "see" (eg. they are 30 | // in the same guild) the user this event was triggered by. 31 | type ProfileUpdated struct { 32 | state protoimpl.MessageState 33 | sizeCache protoimpl.SizeCache 34 | unknownFields protoimpl.UnknownFields 35 | 36 | // User ID of the user that had it's profile updated. 37 | UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` 38 | // New username for this user. 39 | NewUsername *string `protobuf:"bytes,2,opt,name=new_username,json=newUsername,proto3,oneof" json:"new_username,omitempty"` 40 | // New avatar for this user. 41 | NewAvatar *string `protobuf:"bytes,3,opt,name=new_avatar,json=newAvatar,proto3,oneof" json:"new_avatar,omitempty"` 42 | // New status for this user. 43 | NewStatus *UserStatus `protobuf:"varint,4,opt,name=new_status,json=newStatus,proto3,enum=protocol.profile.v1.UserStatus,oneof" json:"new_status,omitempty"` 44 | // New is bot or not for this user. 45 | NewIsBot *bool `protobuf:"varint,5,opt,name=new_is_bot,json=newIsBot,proto3,oneof" json:"new_is_bot,omitempty"` 46 | } 47 | 48 | func (x *ProfileUpdated) Reset() { 49 | *x = ProfileUpdated{} 50 | if protoimpl.UnsafeEnabled { 51 | mi := &file_profile_v1_stream_proto_msgTypes[0] 52 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 53 | ms.StoreMessageInfo(mi) 54 | } 55 | } 56 | 57 | func (x *ProfileUpdated) String() string { 58 | return protoimpl.X.MessageStringOf(x) 59 | } 60 | 61 | func (*ProfileUpdated) ProtoMessage() {} 62 | 63 | func (x *ProfileUpdated) ProtoReflect() protoreflect.Message { 64 | mi := &file_profile_v1_stream_proto_msgTypes[0] 65 | if protoimpl.UnsafeEnabled && x != nil { 66 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 67 | if ms.LoadMessageInfo() == nil { 68 | ms.StoreMessageInfo(mi) 69 | } 70 | return ms 71 | } 72 | return mi.MessageOf(x) 73 | } 74 | 75 | // Deprecated: Use ProfileUpdated.ProtoReflect.Descriptor instead. 76 | func (*ProfileUpdated) Descriptor() ([]byte, []int) { 77 | return file_profile_v1_stream_proto_rawDescGZIP(), []int{0} 78 | } 79 | 80 | func (x *ProfileUpdated) GetUserId() uint64 { 81 | if x != nil { 82 | return x.UserId 83 | } 84 | return 0 85 | } 86 | 87 | func (x *ProfileUpdated) GetNewUsername() string { 88 | if x != nil && x.NewUsername != nil { 89 | return *x.NewUsername 90 | } 91 | return "" 92 | } 93 | 94 | func (x *ProfileUpdated) GetNewAvatar() string { 95 | if x != nil && x.NewAvatar != nil { 96 | return *x.NewAvatar 97 | } 98 | return "" 99 | } 100 | 101 | func (x *ProfileUpdated) GetNewStatus() UserStatus { 102 | if x != nil && x.NewStatus != nil { 103 | return *x.NewStatus 104 | } 105 | return UserStatus_USER_STATUS_OFFLINE_UNSPECIFIED 106 | } 107 | 108 | func (x *ProfileUpdated) GetNewIsBot() bool { 109 | if x != nil && x.NewIsBot != nil { 110 | return *x.NewIsBot 111 | } 112 | return false 113 | } 114 | 115 | // Describes an emote service event. 116 | type StreamEvent struct { 117 | state protoimpl.MessageState 118 | sizeCache protoimpl.SizeCache 119 | unknownFields protoimpl.UnknownFields 120 | 121 | // The event type. 122 | // 123 | // Types that are assignable to Event: 124 | // *StreamEvent_ProfileUpdated 125 | Event isStreamEvent_Event `protobuf_oneof:"event"` 126 | } 127 | 128 | func (x *StreamEvent) Reset() { 129 | *x = StreamEvent{} 130 | if protoimpl.UnsafeEnabled { 131 | mi := &file_profile_v1_stream_proto_msgTypes[1] 132 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 133 | ms.StoreMessageInfo(mi) 134 | } 135 | } 136 | 137 | func (x *StreamEvent) String() string { 138 | return protoimpl.X.MessageStringOf(x) 139 | } 140 | 141 | func (*StreamEvent) ProtoMessage() {} 142 | 143 | func (x *StreamEvent) ProtoReflect() protoreflect.Message { 144 | mi := &file_profile_v1_stream_proto_msgTypes[1] 145 | if protoimpl.UnsafeEnabled && x != nil { 146 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 147 | if ms.LoadMessageInfo() == nil { 148 | ms.StoreMessageInfo(mi) 149 | } 150 | return ms 151 | } 152 | return mi.MessageOf(x) 153 | } 154 | 155 | // Deprecated: Use StreamEvent.ProtoReflect.Descriptor instead. 156 | func (*StreamEvent) Descriptor() ([]byte, []int) { 157 | return file_profile_v1_stream_proto_rawDescGZIP(), []int{1} 158 | } 159 | 160 | func (m *StreamEvent) GetEvent() isStreamEvent_Event { 161 | if m != nil { 162 | return m.Event 163 | } 164 | return nil 165 | } 166 | 167 | func (x *StreamEvent) GetProfileUpdated() *ProfileUpdated { 168 | if x, ok := x.GetEvent().(*StreamEvent_ProfileUpdated); ok { 169 | return x.ProfileUpdated 170 | } 171 | return nil 172 | } 173 | 174 | type isStreamEvent_Event interface { 175 | isStreamEvent_Event() 176 | } 177 | 178 | type StreamEvent_ProfileUpdated struct { 179 | // Send the profile updated event. 180 | ProfileUpdated *ProfileUpdated `protobuf:"bytes,14,opt,name=profile_updated,json=profileUpdated,proto3,oneof"` 181 | } 182 | 183 | func (*StreamEvent_ProfileUpdated) isStreamEvent_Event() {} 184 | 185 | var File_profile_v1_stream_proto protoreflect.FileDescriptor 186 | 187 | var file_profile_v1_stream_proto_rawDesc = []byte{ 188 | 0x0a, 0x17, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x72, 189 | 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 190 | 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x16, 191 | 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 192 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9b, 0x02, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x66, 0x69, 193 | 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 194 | 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 195 | 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0c, 0x6e, 0x65, 0x77, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 196 | 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x6e, 0x65, 0x77, 0x55, 197 | 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x22, 0x0a, 0x0a, 0x6e, 0x65, 198 | 0x77, 0x5f, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 199 | 0x52, 0x09, 0x6e, 0x65, 0x77, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x88, 0x01, 0x01, 0x12, 0x43, 200 | 0x0a, 0x0a, 0x6e, 0x65, 0x77, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 201 | 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 202 | 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 203 | 0x74, 0x75, 0x73, 0x48, 0x02, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 204 | 0x88, 0x01, 0x01, 0x12, 0x21, 0x0a, 0x0a, 0x6e, 0x65, 0x77, 0x5f, 0x69, 0x73, 0x5f, 0x62, 0x6f, 205 | 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x48, 0x03, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x49, 0x73, 206 | 0x42, 0x6f, 0x74, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x6e, 0x65, 0x77, 0x5f, 0x75, 207 | 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x6e, 0x65, 0x77, 0x5f, 208 | 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x6e, 0x65, 0x77, 0x5f, 0x73, 209 | 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x6e, 0x65, 0x77, 0x5f, 0x69, 0x73, 210 | 0x5f, 0x62, 0x6f, 0x74, 0x22, 0x66, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76, 211 | 0x65, 0x6e, 0x74, 0x12, 0x4e, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x75, 212 | 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x70, 213 | 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 214 | 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 215 | 0x64, 0x48, 0x00, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 216 | 0x74, 0x65, 0x64, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x42, 0xd4, 0x01, 0x0a, 217 | 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 218 | 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 219 | 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 220 | 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2d, 0x64, 0x65, 0x76, 0x65, 221 | 0x6c, 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x2f, 0x67, 222 | 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x70, 0x72, 223 | 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x50, 0x50, 0x58, 0xaa, 0x02, 0x13, 224 | 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 225 | 0x2e, 0x56, 0x31, 0xca, 0x02, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5c, 0x50, 226 | 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1f, 0x50, 0x72, 0x6f, 0x74, 227 | 0x6f, 0x63, 0x6f, 0x6c, 0x5c, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 228 | 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x50, 0x72, 229 | 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x3a, 0x3a, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x3a, 230 | 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 231 | } 232 | 233 | var ( 234 | file_profile_v1_stream_proto_rawDescOnce sync.Once 235 | file_profile_v1_stream_proto_rawDescData = file_profile_v1_stream_proto_rawDesc 236 | ) 237 | 238 | func file_profile_v1_stream_proto_rawDescGZIP() []byte { 239 | file_profile_v1_stream_proto_rawDescOnce.Do(func() { 240 | file_profile_v1_stream_proto_rawDescData = protoimpl.X.CompressGZIP(file_profile_v1_stream_proto_rawDescData) 241 | }) 242 | return file_profile_v1_stream_proto_rawDescData 243 | } 244 | 245 | var file_profile_v1_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 246 | var file_profile_v1_stream_proto_goTypes = []interface{}{ 247 | (*ProfileUpdated)(nil), // 0: protocol.profile.v1.ProfileUpdated 248 | (*StreamEvent)(nil), // 1: protocol.profile.v1.StreamEvent 249 | (UserStatus)(0), // 2: protocol.profile.v1.UserStatus 250 | } 251 | var file_profile_v1_stream_proto_depIdxs = []int32{ 252 | 2, // 0: protocol.profile.v1.ProfileUpdated.new_status:type_name -> protocol.profile.v1.UserStatus 253 | 0, // 1: protocol.profile.v1.StreamEvent.profile_updated:type_name -> protocol.profile.v1.ProfileUpdated 254 | 2, // [2:2] is the sub-list for method output_type 255 | 2, // [2:2] is the sub-list for method input_type 256 | 2, // [2:2] is the sub-list for extension type_name 257 | 2, // [2:2] is the sub-list for extension extendee 258 | 0, // [0:2] is the sub-list for field type_name 259 | } 260 | 261 | func init() { file_profile_v1_stream_proto_init() } 262 | func file_profile_v1_stream_proto_init() { 263 | if File_profile_v1_stream_proto != nil { 264 | return 265 | } 266 | file_profile_v1_types_proto_init() 267 | if !protoimpl.UnsafeEnabled { 268 | file_profile_v1_stream_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 269 | switch v := v.(*ProfileUpdated); i { 270 | case 0: 271 | return &v.state 272 | case 1: 273 | return &v.sizeCache 274 | case 2: 275 | return &v.unknownFields 276 | default: 277 | return nil 278 | } 279 | } 280 | file_profile_v1_stream_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 281 | switch v := v.(*StreamEvent); i { 282 | case 0: 283 | return &v.state 284 | case 1: 285 | return &v.sizeCache 286 | case 2: 287 | return &v.unknownFields 288 | default: 289 | return nil 290 | } 291 | } 292 | } 293 | file_profile_v1_stream_proto_msgTypes[0].OneofWrappers = []interface{}{} 294 | file_profile_v1_stream_proto_msgTypes[1].OneofWrappers = []interface{}{ 295 | (*StreamEvent_ProfileUpdated)(nil), 296 | } 297 | type x struct{} 298 | out := protoimpl.TypeBuilder{ 299 | File: protoimpl.DescBuilder{ 300 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 301 | RawDescriptor: file_profile_v1_stream_proto_rawDesc, 302 | NumEnums: 0, 303 | NumMessages: 2, 304 | NumExtensions: 0, 305 | NumServices: 0, 306 | }, 307 | GoTypes: file_profile_v1_stream_proto_goTypes, 308 | DependencyIndexes: file_profile_v1_stream_proto_depIdxs, 309 | MessageInfos: file_profile_v1_stream_proto_msgTypes, 310 | }.Build() 311 | File_profile_v1_stream_proto = out.File 312 | file_profile_v1_stream_proto_rawDesc = nil 313 | file_profile_v1_stream_proto_goTypes = nil 314 | file_profile_v1_stream_proto_depIdxs = nil 315 | } 316 | -------------------------------------------------------------------------------- /gen/emote/v1/emote_hrpc_client.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go-hrpc. DO NOT EDIT. 6 | 7 | package emotev1 8 | 9 | import ( 10 | bytes "bytes" 11 | context "context" 12 | proto "google.golang.org/protobuf/proto" 13 | ioutil "io/ioutil" 14 | http "net/http" 15 | httptest "net/http/httptest" 16 | ) 17 | 18 | type EmoteServiceClient interface { 19 | // Endpoint to create an emote pack. 20 | CreateEmotePack(context.Context, *CreateEmotePackRequest) (*CreateEmotePackResponse, error) 21 | // Endpoint to get the emote packs you have equipped. 22 | GetEmotePacks(context.Context, *GetEmotePacksRequest) (*GetEmotePacksResponse, error) 23 | // Endpoint to get the emotes in an emote pack. 24 | GetEmotePackEmotes(context.Context, *GetEmotePackEmotesRequest) (*GetEmotePackEmotesResponse, error) 25 | // Endpoint to add an emote to an emote pack that you own. 26 | AddEmoteToPack(context.Context, *AddEmoteToPackRequest) (*AddEmoteToPackResponse, error) 27 | // Endpoint to delete an emote pack that you own. 28 | DeleteEmotePack(context.Context, *DeleteEmotePackRequest) (*DeleteEmotePackResponse, error) 29 | // Endpoint to delete an emote from an emote pack. 30 | DeleteEmoteFromPack(context.Context, *DeleteEmoteFromPackRequest) (*DeleteEmoteFromPackResponse, error) 31 | // Endpoint to dequip an emote pack that you have equipped. 32 | DequipEmotePack(context.Context, *DequipEmotePackRequest) (*DequipEmotePackResponse, error) 33 | // Endpoint to equip an emote pack. 34 | EquipEmotePack(context.Context, *EquipEmotePackRequest) (*EquipEmotePackResponse, error) 35 | } 36 | 37 | type HTTPEmoteServiceClient struct { 38 | Client http.Client 39 | BaseURL string 40 | } 41 | 42 | func (client *HTTPEmoteServiceClient) CreateEmotePack(req *CreateEmotePackRequest) (*CreateEmotePackResponse, error) { 43 | data, marshalErr := proto.Marshal(req) 44 | if marshalErr != nil { 45 | return nil, marshalErr 46 | } 47 | reader := bytes.NewReader(data) 48 | resp, err := client.Client.Post(client.BaseURL+"/protocol.emote.v1.EmoteService.CreateEmotePack/", "application/hrpc", reader) 49 | if err != nil { 50 | return nil, err 51 | } 52 | body, err := ioutil.ReadAll(resp.Body) 53 | if err != nil { 54 | return nil, err 55 | } 56 | ret := &CreateEmotePackResponse{} 57 | unmarshalErr := proto.Unmarshal(body, ret) 58 | if unmarshalErr != nil { 59 | return nil, unmarshalErr 60 | } 61 | return ret, nil 62 | } 63 | func (client *HTTPEmoteServiceClient) GetEmotePacks(req *GetEmotePacksRequest) (*GetEmotePacksResponse, error) { 64 | data, marshalErr := proto.Marshal(req) 65 | if marshalErr != nil { 66 | return nil, marshalErr 67 | } 68 | reader := bytes.NewReader(data) 69 | resp, err := client.Client.Post(client.BaseURL+"/protocol.emote.v1.EmoteService.GetEmotePacks/", "application/hrpc", reader) 70 | if err != nil { 71 | return nil, err 72 | } 73 | body, err := ioutil.ReadAll(resp.Body) 74 | if err != nil { 75 | return nil, err 76 | } 77 | ret := &GetEmotePacksResponse{} 78 | unmarshalErr := proto.Unmarshal(body, ret) 79 | if unmarshalErr != nil { 80 | return nil, unmarshalErr 81 | } 82 | return ret, nil 83 | } 84 | func (client *HTTPEmoteServiceClient) GetEmotePackEmotes(req *GetEmotePackEmotesRequest) (*GetEmotePackEmotesResponse, error) { 85 | data, marshalErr := proto.Marshal(req) 86 | if marshalErr != nil { 87 | return nil, marshalErr 88 | } 89 | reader := bytes.NewReader(data) 90 | resp, err := client.Client.Post(client.BaseURL+"/protocol.emote.v1.EmoteService.GetEmotePackEmotes/", "application/hrpc", reader) 91 | if err != nil { 92 | return nil, err 93 | } 94 | body, err := ioutil.ReadAll(resp.Body) 95 | if err != nil { 96 | return nil, err 97 | } 98 | ret := &GetEmotePackEmotesResponse{} 99 | unmarshalErr := proto.Unmarshal(body, ret) 100 | if unmarshalErr != nil { 101 | return nil, unmarshalErr 102 | } 103 | return ret, nil 104 | } 105 | func (client *HTTPEmoteServiceClient) AddEmoteToPack(req *AddEmoteToPackRequest) (*AddEmoteToPackResponse, error) { 106 | data, marshalErr := proto.Marshal(req) 107 | if marshalErr != nil { 108 | return nil, marshalErr 109 | } 110 | reader := bytes.NewReader(data) 111 | resp, err := client.Client.Post(client.BaseURL+"/protocol.emote.v1.EmoteService.AddEmoteToPack/", "application/hrpc", reader) 112 | if err != nil { 113 | return nil, err 114 | } 115 | body, err := ioutil.ReadAll(resp.Body) 116 | if err != nil { 117 | return nil, err 118 | } 119 | ret := &AddEmoteToPackResponse{} 120 | unmarshalErr := proto.Unmarshal(body, ret) 121 | if unmarshalErr != nil { 122 | return nil, unmarshalErr 123 | } 124 | return ret, nil 125 | } 126 | func (client *HTTPEmoteServiceClient) DeleteEmotePack(req *DeleteEmotePackRequest) (*DeleteEmotePackResponse, error) { 127 | data, marshalErr := proto.Marshal(req) 128 | if marshalErr != nil { 129 | return nil, marshalErr 130 | } 131 | reader := bytes.NewReader(data) 132 | resp, err := client.Client.Post(client.BaseURL+"/protocol.emote.v1.EmoteService.DeleteEmotePack/", "application/hrpc", reader) 133 | if err != nil { 134 | return nil, err 135 | } 136 | body, err := ioutil.ReadAll(resp.Body) 137 | if err != nil { 138 | return nil, err 139 | } 140 | ret := &DeleteEmotePackResponse{} 141 | unmarshalErr := proto.Unmarshal(body, ret) 142 | if unmarshalErr != nil { 143 | return nil, unmarshalErr 144 | } 145 | return ret, nil 146 | } 147 | func (client *HTTPEmoteServiceClient) DeleteEmoteFromPack(req *DeleteEmoteFromPackRequest) (*DeleteEmoteFromPackResponse, error) { 148 | data, marshalErr := proto.Marshal(req) 149 | if marshalErr != nil { 150 | return nil, marshalErr 151 | } 152 | reader := bytes.NewReader(data) 153 | resp, err := client.Client.Post(client.BaseURL+"/protocol.emote.v1.EmoteService.DeleteEmoteFromPack/", "application/hrpc", reader) 154 | if err != nil { 155 | return nil, err 156 | } 157 | body, err := ioutil.ReadAll(resp.Body) 158 | if err != nil { 159 | return nil, err 160 | } 161 | ret := &DeleteEmoteFromPackResponse{} 162 | unmarshalErr := proto.Unmarshal(body, ret) 163 | if unmarshalErr != nil { 164 | return nil, unmarshalErr 165 | } 166 | return ret, nil 167 | } 168 | func (client *HTTPEmoteServiceClient) DequipEmotePack(req *DequipEmotePackRequest) (*DequipEmotePackResponse, error) { 169 | data, marshalErr := proto.Marshal(req) 170 | if marshalErr != nil { 171 | return nil, marshalErr 172 | } 173 | reader := bytes.NewReader(data) 174 | resp, err := client.Client.Post(client.BaseURL+"/protocol.emote.v1.EmoteService.DequipEmotePack/", "application/hrpc", reader) 175 | if err != nil { 176 | return nil, err 177 | } 178 | body, err := ioutil.ReadAll(resp.Body) 179 | if err != nil { 180 | return nil, err 181 | } 182 | ret := &DequipEmotePackResponse{} 183 | unmarshalErr := proto.Unmarshal(body, ret) 184 | if unmarshalErr != nil { 185 | return nil, unmarshalErr 186 | } 187 | return ret, nil 188 | } 189 | func (client *HTTPEmoteServiceClient) EquipEmotePack(req *EquipEmotePackRequest) (*EquipEmotePackResponse, error) { 190 | data, marshalErr := proto.Marshal(req) 191 | if marshalErr != nil { 192 | return nil, marshalErr 193 | } 194 | reader := bytes.NewReader(data) 195 | resp, err := client.Client.Post(client.BaseURL+"/protocol.emote.v1.EmoteService.EquipEmotePack/", "application/hrpc", reader) 196 | if err != nil { 197 | return nil, err 198 | } 199 | body, err := ioutil.ReadAll(resp.Body) 200 | if err != nil { 201 | return nil, err 202 | } 203 | ret := &EquipEmotePackResponse{} 204 | unmarshalErr := proto.Unmarshal(body, ret) 205 | if unmarshalErr != nil { 206 | return nil, unmarshalErr 207 | } 208 | return ret, nil 209 | } 210 | 211 | type HTTPTestEmoteServiceClient struct { 212 | Client interface { 213 | Test(*http.Request, ...int) (*http.Response, error) 214 | } 215 | } 216 | 217 | func (client *HTTPTestEmoteServiceClient) CreateEmotePack(req *CreateEmotePackRequest) (*CreateEmotePackResponse, error) { 218 | data, marshalErr := proto.Marshal(req) 219 | if marshalErr != nil { 220 | return nil, marshalErr 221 | } 222 | reader := bytes.NewReader(data) 223 | testreq := httptest.NewRequest("POST", "/protocol.emote.v1.EmoteService.CreateEmotePack/", reader) 224 | resp, err := client.Client.Test(testreq) 225 | if err != nil { 226 | return nil, err 227 | } 228 | body, err := ioutil.ReadAll(resp.Body) 229 | if err != nil { 230 | return nil, err 231 | } 232 | ret := &CreateEmotePackResponse{} 233 | unmarshalErr := proto.Unmarshal(body, ret) 234 | if unmarshalErr != nil { 235 | return nil, unmarshalErr 236 | } 237 | return ret, nil 238 | } 239 | func (client *HTTPTestEmoteServiceClient) GetEmotePacks(req *GetEmotePacksRequest) (*GetEmotePacksResponse, error) { 240 | data, marshalErr := proto.Marshal(req) 241 | if marshalErr != nil { 242 | return nil, marshalErr 243 | } 244 | reader := bytes.NewReader(data) 245 | testreq := httptest.NewRequest("POST", "/protocol.emote.v1.EmoteService.GetEmotePacks/", reader) 246 | resp, err := client.Client.Test(testreq) 247 | if err != nil { 248 | return nil, err 249 | } 250 | body, err := ioutil.ReadAll(resp.Body) 251 | if err != nil { 252 | return nil, err 253 | } 254 | ret := &GetEmotePacksResponse{} 255 | unmarshalErr := proto.Unmarshal(body, ret) 256 | if unmarshalErr != nil { 257 | return nil, unmarshalErr 258 | } 259 | return ret, nil 260 | } 261 | func (client *HTTPTestEmoteServiceClient) GetEmotePackEmotes(req *GetEmotePackEmotesRequest) (*GetEmotePackEmotesResponse, error) { 262 | data, marshalErr := proto.Marshal(req) 263 | if marshalErr != nil { 264 | return nil, marshalErr 265 | } 266 | reader := bytes.NewReader(data) 267 | testreq := httptest.NewRequest("POST", "/protocol.emote.v1.EmoteService.GetEmotePackEmotes/", reader) 268 | resp, err := client.Client.Test(testreq) 269 | if err != nil { 270 | return nil, err 271 | } 272 | body, err := ioutil.ReadAll(resp.Body) 273 | if err != nil { 274 | return nil, err 275 | } 276 | ret := &GetEmotePackEmotesResponse{} 277 | unmarshalErr := proto.Unmarshal(body, ret) 278 | if unmarshalErr != nil { 279 | return nil, unmarshalErr 280 | } 281 | return ret, nil 282 | } 283 | func (client *HTTPTestEmoteServiceClient) AddEmoteToPack(req *AddEmoteToPackRequest) (*AddEmoteToPackResponse, error) { 284 | data, marshalErr := proto.Marshal(req) 285 | if marshalErr != nil { 286 | return nil, marshalErr 287 | } 288 | reader := bytes.NewReader(data) 289 | testreq := httptest.NewRequest("POST", "/protocol.emote.v1.EmoteService.AddEmoteToPack/", reader) 290 | resp, err := client.Client.Test(testreq) 291 | if err != nil { 292 | return nil, err 293 | } 294 | body, err := ioutil.ReadAll(resp.Body) 295 | if err != nil { 296 | return nil, err 297 | } 298 | ret := &AddEmoteToPackResponse{} 299 | unmarshalErr := proto.Unmarshal(body, ret) 300 | if unmarshalErr != nil { 301 | return nil, unmarshalErr 302 | } 303 | return ret, nil 304 | } 305 | func (client *HTTPTestEmoteServiceClient) DeleteEmotePack(req *DeleteEmotePackRequest) (*DeleteEmotePackResponse, error) { 306 | data, marshalErr := proto.Marshal(req) 307 | if marshalErr != nil { 308 | return nil, marshalErr 309 | } 310 | reader := bytes.NewReader(data) 311 | testreq := httptest.NewRequest("POST", "/protocol.emote.v1.EmoteService.DeleteEmotePack/", reader) 312 | resp, err := client.Client.Test(testreq) 313 | if err != nil { 314 | return nil, err 315 | } 316 | body, err := ioutil.ReadAll(resp.Body) 317 | if err != nil { 318 | return nil, err 319 | } 320 | ret := &DeleteEmotePackResponse{} 321 | unmarshalErr := proto.Unmarshal(body, ret) 322 | if unmarshalErr != nil { 323 | return nil, unmarshalErr 324 | } 325 | return ret, nil 326 | } 327 | func (client *HTTPTestEmoteServiceClient) DeleteEmoteFromPack(req *DeleteEmoteFromPackRequest) (*DeleteEmoteFromPackResponse, error) { 328 | data, marshalErr := proto.Marshal(req) 329 | if marshalErr != nil { 330 | return nil, marshalErr 331 | } 332 | reader := bytes.NewReader(data) 333 | testreq := httptest.NewRequest("POST", "/protocol.emote.v1.EmoteService.DeleteEmoteFromPack/", reader) 334 | resp, err := client.Client.Test(testreq) 335 | if err != nil { 336 | return nil, err 337 | } 338 | body, err := ioutil.ReadAll(resp.Body) 339 | if err != nil { 340 | return nil, err 341 | } 342 | ret := &DeleteEmoteFromPackResponse{} 343 | unmarshalErr := proto.Unmarshal(body, ret) 344 | if unmarshalErr != nil { 345 | return nil, unmarshalErr 346 | } 347 | return ret, nil 348 | } 349 | func (client *HTTPTestEmoteServiceClient) DequipEmotePack(req *DequipEmotePackRequest) (*DequipEmotePackResponse, error) { 350 | data, marshalErr := proto.Marshal(req) 351 | if marshalErr != nil { 352 | return nil, marshalErr 353 | } 354 | reader := bytes.NewReader(data) 355 | testreq := httptest.NewRequest("POST", "/protocol.emote.v1.EmoteService.DequipEmotePack/", reader) 356 | resp, err := client.Client.Test(testreq) 357 | if err != nil { 358 | return nil, err 359 | } 360 | body, err := ioutil.ReadAll(resp.Body) 361 | if err != nil { 362 | return nil, err 363 | } 364 | ret := &DequipEmotePackResponse{} 365 | unmarshalErr := proto.Unmarshal(body, ret) 366 | if unmarshalErr != nil { 367 | return nil, unmarshalErr 368 | } 369 | return ret, nil 370 | } 371 | func (client *HTTPTestEmoteServiceClient) EquipEmotePack(req *EquipEmotePackRequest) (*EquipEmotePackResponse, error) { 372 | data, marshalErr := proto.Marshal(req) 373 | if marshalErr != nil { 374 | return nil, marshalErr 375 | } 376 | reader := bytes.NewReader(data) 377 | testreq := httptest.NewRequest("POST", "/protocol.emote.v1.EmoteService.EquipEmotePack/", reader) 378 | resp, err := client.Client.Test(testreq) 379 | if err != nil { 380 | return nil, err 381 | } 382 | body, err := ioutil.ReadAll(resp.Body) 383 | if err != nil { 384 | return nil, err 385 | } 386 | ret := &EquipEmotePackResponse{} 387 | unmarshalErr := proto.Unmarshal(body, ret) 388 | if unmarshalErr != nil { 389 | return nil, unmarshalErr 390 | } 391 | return ret, nil 392 | } 393 | -------------------------------------------------------------------------------- /gen/batch/v1/batch.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go. DO NOT EDIT. 6 | // versions: 7 | // protoc-gen-go v1.27.1 8 | // protoc v3.17.3 9 | // source: batch/v1/batch.proto 10 | 11 | package batchv1 12 | 13 | import ( 14 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 15 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 16 | reflect "reflect" 17 | sync "sync" 18 | ) 19 | 20 | const ( 21 | // Verify that this generated code is sufficiently up-to-date. 22 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 23 | // Verify that runtime/protoimpl is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 25 | ) 26 | 27 | // AnyRequest is a generic message supporting any unary request. 28 | type AnyRequest struct { 29 | state protoimpl.MessageState 30 | sizeCache protoimpl.SizeCache 31 | unknownFields protoimpl.UnknownFields 32 | 33 | // The endpoint to which the request is being sent. 34 | Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"` 35 | // The request data. 36 | Request []byte `protobuf:"bytes,2,opt,name=request,proto3" json:"request,omitempty"` 37 | } 38 | 39 | func (x *AnyRequest) Reset() { 40 | *x = AnyRequest{} 41 | if protoimpl.UnsafeEnabled { 42 | mi := &file_batch_v1_batch_proto_msgTypes[0] 43 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 44 | ms.StoreMessageInfo(mi) 45 | } 46 | } 47 | 48 | func (x *AnyRequest) String() string { 49 | return protoimpl.X.MessageStringOf(x) 50 | } 51 | 52 | func (*AnyRequest) ProtoMessage() {} 53 | 54 | func (x *AnyRequest) ProtoReflect() protoreflect.Message { 55 | mi := &file_batch_v1_batch_proto_msgTypes[0] 56 | if protoimpl.UnsafeEnabled && x != nil { 57 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 58 | if ms.LoadMessageInfo() == nil { 59 | ms.StoreMessageInfo(mi) 60 | } 61 | return ms 62 | } 63 | return mi.MessageOf(x) 64 | } 65 | 66 | // Deprecated: Use AnyRequest.ProtoReflect.Descriptor instead. 67 | func (*AnyRequest) Descriptor() ([]byte, []int) { 68 | return file_batch_v1_batch_proto_rawDescGZIP(), []int{0} 69 | } 70 | 71 | func (x *AnyRequest) GetEndpoint() string { 72 | if x != nil { 73 | return x.Endpoint 74 | } 75 | return "" 76 | } 77 | 78 | func (x *AnyRequest) GetRequest() []byte { 79 | if x != nil { 80 | return x.Request 81 | } 82 | return nil 83 | } 84 | 85 | // Used in `Batch` endpoint. 86 | type BatchRequest struct { 87 | state protoimpl.MessageState 88 | sizeCache protoimpl.SizeCache 89 | unknownFields protoimpl.UnknownFields 90 | 91 | // The list of requests to be executed in the batch. 92 | Requests []*AnyRequest `protobuf:"bytes,1,rep,name=requests,proto3" json:"requests,omitempty"` 93 | } 94 | 95 | func (x *BatchRequest) Reset() { 96 | *x = BatchRequest{} 97 | if protoimpl.UnsafeEnabled { 98 | mi := &file_batch_v1_batch_proto_msgTypes[1] 99 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 100 | ms.StoreMessageInfo(mi) 101 | } 102 | } 103 | 104 | func (x *BatchRequest) String() string { 105 | return protoimpl.X.MessageStringOf(x) 106 | } 107 | 108 | func (*BatchRequest) ProtoMessage() {} 109 | 110 | func (x *BatchRequest) ProtoReflect() protoreflect.Message { 111 | mi := &file_batch_v1_batch_proto_msgTypes[1] 112 | if protoimpl.UnsafeEnabled && x != nil { 113 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 114 | if ms.LoadMessageInfo() == nil { 115 | ms.StoreMessageInfo(mi) 116 | } 117 | return ms 118 | } 119 | return mi.MessageOf(x) 120 | } 121 | 122 | // Deprecated: Use BatchRequest.ProtoReflect.Descriptor instead. 123 | func (*BatchRequest) Descriptor() ([]byte, []int) { 124 | return file_batch_v1_batch_proto_rawDescGZIP(), []int{1} 125 | } 126 | 127 | func (x *BatchRequest) GetRequests() []*AnyRequest { 128 | if x != nil { 129 | return x.Requests 130 | } 131 | return nil 132 | } 133 | 134 | // Used in `Batch` endpoint. 135 | type BatchResponse struct { 136 | state protoimpl.MessageState 137 | sizeCache protoimpl.SizeCache 138 | unknownFields protoimpl.UnknownFields 139 | 140 | // The list of responses to the requests. 141 | Responses [][]byte `protobuf:"bytes,1,rep,name=responses,proto3" json:"responses,omitempty"` 142 | } 143 | 144 | func (x *BatchResponse) Reset() { 145 | *x = BatchResponse{} 146 | if protoimpl.UnsafeEnabled { 147 | mi := &file_batch_v1_batch_proto_msgTypes[2] 148 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 149 | ms.StoreMessageInfo(mi) 150 | } 151 | } 152 | 153 | func (x *BatchResponse) String() string { 154 | return protoimpl.X.MessageStringOf(x) 155 | } 156 | 157 | func (*BatchResponse) ProtoMessage() {} 158 | 159 | func (x *BatchResponse) ProtoReflect() protoreflect.Message { 160 | mi := &file_batch_v1_batch_proto_msgTypes[2] 161 | if protoimpl.UnsafeEnabled && x != nil { 162 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 163 | if ms.LoadMessageInfo() == nil { 164 | ms.StoreMessageInfo(mi) 165 | } 166 | return ms 167 | } 168 | return mi.MessageOf(x) 169 | } 170 | 171 | // Deprecated: Use BatchResponse.ProtoReflect.Descriptor instead. 172 | func (*BatchResponse) Descriptor() ([]byte, []int) { 173 | return file_batch_v1_batch_proto_rawDescGZIP(), []int{2} 174 | } 175 | 176 | func (x *BatchResponse) GetResponses() [][]byte { 177 | if x != nil { 178 | return x.Responses 179 | } 180 | return nil 181 | } 182 | 183 | // Used in `BatchSame` endpoint. 184 | type BatchSameRequest struct { 185 | state protoimpl.MessageState 186 | sizeCache protoimpl.SizeCache 187 | unknownFields protoimpl.UnknownFields 188 | 189 | // The endpoint to call for all requests. 190 | Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"` 191 | // The list of requests to be executed in the batch. 192 | Requests [][]byte `protobuf:"bytes,2,rep,name=requests,proto3" json:"requests,omitempty"` 193 | } 194 | 195 | func (x *BatchSameRequest) Reset() { 196 | *x = BatchSameRequest{} 197 | if protoimpl.UnsafeEnabled { 198 | mi := &file_batch_v1_batch_proto_msgTypes[3] 199 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 200 | ms.StoreMessageInfo(mi) 201 | } 202 | } 203 | 204 | func (x *BatchSameRequest) String() string { 205 | return protoimpl.X.MessageStringOf(x) 206 | } 207 | 208 | func (*BatchSameRequest) ProtoMessage() {} 209 | 210 | func (x *BatchSameRequest) ProtoReflect() protoreflect.Message { 211 | mi := &file_batch_v1_batch_proto_msgTypes[3] 212 | if protoimpl.UnsafeEnabled && x != nil { 213 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 214 | if ms.LoadMessageInfo() == nil { 215 | ms.StoreMessageInfo(mi) 216 | } 217 | return ms 218 | } 219 | return mi.MessageOf(x) 220 | } 221 | 222 | // Deprecated: Use BatchSameRequest.ProtoReflect.Descriptor instead. 223 | func (*BatchSameRequest) Descriptor() ([]byte, []int) { 224 | return file_batch_v1_batch_proto_rawDescGZIP(), []int{3} 225 | } 226 | 227 | func (x *BatchSameRequest) GetEndpoint() string { 228 | if x != nil { 229 | return x.Endpoint 230 | } 231 | return "" 232 | } 233 | 234 | func (x *BatchSameRequest) GetRequests() [][]byte { 235 | if x != nil { 236 | return x.Requests 237 | } 238 | return nil 239 | } 240 | 241 | // Used in `BatchSame` endpoint. 242 | type BatchSameResponse struct { 243 | state protoimpl.MessageState 244 | sizeCache protoimpl.SizeCache 245 | unknownFields protoimpl.UnknownFields 246 | 247 | // The list of responses to the requests. 248 | Responses [][]byte `protobuf:"bytes,1,rep,name=responses,proto3" json:"responses,omitempty"` 249 | } 250 | 251 | func (x *BatchSameResponse) Reset() { 252 | *x = BatchSameResponse{} 253 | if protoimpl.UnsafeEnabled { 254 | mi := &file_batch_v1_batch_proto_msgTypes[4] 255 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 256 | ms.StoreMessageInfo(mi) 257 | } 258 | } 259 | 260 | func (x *BatchSameResponse) String() string { 261 | return protoimpl.X.MessageStringOf(x) 262 | } 263 | 264 | func (*BatchSameResponse) ProtoMessage() {} 265 | 266 | func (x *BatchSameResponse) ProtoReflect() protoreflect.Message { 267 | mi := &file_batch_v1_batch_proto_msgTypes[4] 268 | if protoimpl.UnsafeEnabled && x != nil { 269 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 270 | if ms.LoadMessageInfo() == nil { 271 | ms.StoreMessageInfo(mi) 272 | } 273 | return ms 274 | } 275 | return mi.MessageOf(x) 276 | } 277 | 278 | // Deprecated: Use BatchSameResponse.ProtoReflect.Descriptor instead. 279 | func (*BatchSameResponse) Descriptor() ([]byte, []int) { 280 | return file_batch_v1_batch_proto_rawDescGZIP(), []int{4} 281 | } 282 | 283 | func (x *BatchSameResponse) GetResponses() [][]byte { 284 | if x != nil { 285 | return x.Responses 286 | } 287 | return nil 288 | } 289 | 290 | var File_batch_v1_batch_proto protoreflect.FileDescriptor 291 | 292 | var file_batch_v1_batch_proto_rawDesc = []byte{ 293 | 0x0a, 0x14, 0x62, 0x61, 0x74, 0x63, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x61, 0x74, 0x63, 0x68, 294 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 295 | 0x2e, 0x62, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x22, 0x42, 0x0a, 0x0a, 0x41, 0x6e, 0x79, 296 | 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 297 | 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 298 | 0x69, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 299 | 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x49, 0x0a, 300 | 0x0c, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x39, 0x0a, 301 | 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 302 | 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x62, 0x61, 0x74, 0x63, 0x68, 303 | 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x08, 304 | 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x22, 0x2d, 0x0a, 0x0d, 0x42, 0x61, 0x74, 0x63, 305 | 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x73, 306 | 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x72, 0x65, 307 | 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0x4a, 0x0a, 0x10, 0x42, 0x61, 0x74, 0x63, 0x68, 308 | 0x53, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 309 | 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 310 | 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 311 | 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 312 | 0x73, 0x74, 0x73, 0x22, 0x31, 0x0a, 0x11, 0x42, 0x61, 0x74, 0x63, 0x68, 0x53, 0x61, 0x6d, 0x65, 313 | 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 314 | 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x72, 0x65, 0x73, 315 | 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x32, 0xb6, 0x01, 0x0a, 0x0c, 0x42, 0x61, 0x74, 0x63, 0x68, 316 | 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4c, 0x0a, 0x05, 0x42, 0x61, 0x74, 0x63, 0x68, 317 | 0x12, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x62, 0x61, 0x74, 0x63, 318 | 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 319 | 0x74, 0x1a, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x62, 0x61, 0x74, 320 | 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 321 | 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x09, 0x42, 0x61, 0x74, 0x63, 0x68, 0x53, 0x61, 322 | 0x6d, 0x65, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x62, 0x61, 323 | 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x53, 0x61, 0x6d, 0x65, 324 | 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 325 | 0x6f, 0x6c, 0x2e, 0x62, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x61, 0x74, 0x63, 326 | 0x68, 0x53, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 327 | 0xc5, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 328 | 0x2e, 0x62, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x42, 0x61, 0x74, 0x63, 0x68, 329 | 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 330 | 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2d, 0x64, 0x65, 0x76, 0x65, 331 | 0x6c, 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x2f, 0x67, 332 | 0x65, 0x6e, 0x2f, 0x62, 0x61, 0x74, 0x63, 0x68, 0x2f, 0x76, 0x31, 0x3b, 0x62, 0x61, 0x74, 0x63, 333 | 0x68, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x50, 0x42, 0x58, 0xaa, 0x02, 0x11, 0x50, 0x72, 0x6f, 0x74, 334 | 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x11, 335 | 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5c, 0x42, 0x61, 0x74, 0x63, 0x68, 0x5c, 0x56, 336 | 0x31, 0xe2, 0x02, 0x1d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5c, 0x42, 0x61, 0x74, 337 | 0x63, 0x68, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 338 | 0x61, 0xea, 0x02, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x3a, 0x3a, 0x42, 0x61, 339 | 0x74, 0x63, 0x68, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 340 | } 341 | 342 | var ( 343 | file_batch_v1_batch_proto_rawDescOnce sync.Once 344 | file_batch_v1_batch_proto_rawDescData = file_batch_v1_batch_proto_rawDesc 345 | ) 346 | 347 | func file_batch_v1_batch_proto_rawDescGZIP() []byte { 348 | file_batch_v1_batch_proto_rawDescOnce.Do(func() { 349 | file_batch_v1_batch_proto_rawDescData = protoimpl.X.CompressGZIP(file_batch_v1_batch_proto_rawDescData) 350 | }) 351 | return file_batch_v1_batch_proto_rawDescData 352 | } 353 | 354 | var file_batch_v1_batch_proto_msgTypes = make([]protoimpl.MessageInfo, 5) 355 | var file_batch_v1_batch_proto_goTypes = []interface{}{ 356 | (*AnyRequest)(nil), // 0: protocol.batch.v1.AnyRequest 357 | (*BatchRequest)(nil), // 1: protocol.batch.v1.BatchRequest 358 | (*BatchResponse)(nil), // 2: protocol.batch.v1.BatchResponse 359 | (*BatchSameRequest)(nil), // 3: protocol.batch.v1.BatchSameRequest 360 | (*BatchSameResponse)(nil), // 4: protocol.batch.v1.BatchSameResponse 361 | } 362 | var file_batch_v1_batch_proto_depIdxs = []int32{ 363 | 0, // 0: protocol.batch.v1.BatchRequest.requests:type_name -> protocol.batch.v1.AnyRequest 364 | 1, // 1: protocol.batch.v1.BatchService.Batch:input_type -> protocol.batch.v1.BatchRequest 365 | 3, // 2: protocol.batch.v1.BatchService.BatchSame:input_type -> protocol.batch.v1.BatchSameRequest 366 | 2, // 3: protocol.batch.v1.BatchService.Batch:output_type -> protocol.batch.v1.BatchResponse 367 | 4, // 4: protocol.batch.v1.BatchService.BatchSame:output_type -> protocol.batch.v1.BatchSameResponse 368 | 3, // [3:5] is the sub-list for method output_type 369 | 1, // [1:3] is the sub-list for method input_type 370 | 1, // [1:1] is the sub-list for extension type_name 371 | 1, // [1:1] is the sub-list for extension extendee 372 | 0, // [0:1] is the sub-list for field type_name 373 | } 374 | 375 | func init() { file_batch_v1_batch_proto_init() } 376 | func file_batch_v1_batch_proto_init() { 377 | if File_batch_v1_batch_proto != nil { 378 | return 379 | } 380 | if !protoimpl.UnsafeEnabled { 381 | file_batch_v1_batch_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 382 | switch v := v.(*AnyRequest); i { 383 | case 0: 384 | return &v.state 385 | case 1: 386 | return &v.sizeCache 387 | case 2: 388 | return &v.unknownFields 389 | default: 390 | return nil 391 | } 392 | } 393 | file_batch_v1_batch_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 394 | switch v := v.(*BatchRequest); i { 395 | case 0: 396 | return &v.state 397 | case 1: 398 | return &v.sizeCache 399 | case 2: 400 | return &v.unknownFields 401 | default: 402 | return nil 403 | } 404 | } 405 | file_batch_v1_batch_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 406 | switch v := v.(*BatchResponse); i { 407 | case 0: 408 | return &v.state 409 | case 1: 410 | return &v.sizeCache 411 | case 2: 412 | return &v.unknownFields 413 | default: 414 | return nil 415 | } 416 | } 417 | file_batch_v1_batch_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 418 | switch v := v.(*BatchSameRequest); i { 419 | case 0: 420 | return &v.state 421 | case 1: 422 | return &v.sizeCache 423 | case 2: 424 | return &v.unknownFields 425 | default: 426 | return nil 427 | } 428 | } 429 | file_batch_v1_batch_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 430 | switch v := v.(*BatchSameResponse); i { 431 | case 0: 432 | return &v.state 433 | case 1: 434 | return &v.sizeCache 435 | case 2: 436 | return &v.unknownFields 437 | default: 438 | return nil 439 | } 440 | } 441 | } 442 | type x struct{} 443 | out := protoimpl.TypeBuilder{ 444 | File: protoimpl.DescBuilder{ 445 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 446 | RawDescriptor: file_batch_v1_batch_proto_rawDesc, 447 | NumEnums: 0, 448 | NumMessages: 5, 449 | NumExtensions: 0, 450 | NumServices: 1, 451 | }, 452 | GoTypes: file_batch_v1_batch_proto_goTypes, 453 | DependencyIndexes: file_batch_v1_batch_proto_depIdxs, 454 | MessageInfos: file_batch_v1_batch_proto_msgTypes, 455 | }.Build() 456 | File_batch_v1_batch_proto = out.File 457 | file_batch_v1_batch_proto_rawDesc = nil 458 | file_batch_v1_batch_proto_goTypes = nil 459 | file_batch_v1_batch_proto_depIdxs = nil 460 | } 461 | -------------------------------------------------------------------------------- /gen/voice/v1/voice.pb.go: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2021 None 2 | // 3 | // SPDX-License-Identifier: CC0-1.0 4 | 5 | // Code generated by protoc-gen-go. DO NOT EDIT. 6 | // versions: 7 | // protoc-gen-go v1.27.1 8 | // protoc v3.17.3 9 | // source: voice/v1/voice.proto 10 | 11 | package voicev1 12 | 13 | import ( 14 | _ "github.com/harmony-development/legato/gen/harmonytypes/v1" 15 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 16 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 17 | emptypb "google.golang.org/protobuf/types/known/emptypb" 18 | reflect "reflect" 19 | sync "sync" 20 | ) 21 | 22 | const ( 23 | // Verify that this generated code is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 25 | // Verify that runtime/protoimpl is sufficiently up-to-date. 26 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 27 | ) 28 | 29 | // A signal object. 30 | type Signal struct { 31 | state protoimpl.MessageState 32 | sizeCache protoimpl.SizeCache 33 | unknownFields protoimpl.UnknownFields 34 | 35 | // The event kind of this signal. 36 | // 37 | // Types that are assignable to Event: 38 | // *Signal_IceCandidate 39 | // *Signal_RenegotiationNeeded 40 | Event isSignal_Event `protobuf_oneof:"event"` 41 | } 42 | 43 | func (x *Signal) Reset() { 44 | *x = Signal{} 45 | if protoimpl.UnsafeEnabled { 46 | mi := &file_voice_v1_voice_proto_msgTypes[0] 47 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 48 | ms.StoreMessageInfo(mi) 49 | } 50 | } 51 | 52 | func (x *Signal) String() string { 53 | return protoimpl.X.MessageStringOf(x) 54 | } 55 | 56 | func (*Signal) ProtoMessage() {} 57 | 58 | func (x *Signal) ProtoReflect() protoreflect.Message { 59 | mi := &file_voice_v1_voice_proto_msgTypes[0] 60 | if protoimpl.UnsafeEnabled && x != nil { 61 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 62 | if ms.LoadMessageInfo() == nil { 63 | ms.StoreMessageInfo(mi) 64 | } 65 | return ms 66 | } 67 | return mi.MessageOf(x) 68 | } 69 | 70 | // Deprecated: Use Signal.ProtoReflect.Descriptor instead. 71 | func (*Signal) Descriptor() ([]byte, []int) { 72 | return file_voice_v1_voice_proto_rawDescGZIP(), []int{0} 73 | } 74 | 75 | func (m *Signal) GetEvent() isSignal_Event { 76 | if m != nil { 77 | return m.Event 78 | } 79 | return nil 80 | } 81 | 82 | func (x *Signal) GetIceCandidate() string { 83 | if x, ok := x.GetEvent().(*Signal_IceCandidate); ok { 84 | return x.IceCandidate 85 | } 86 | return "" 87 | } 88 | 89 | func (x *Signal) GetRenegotiationNeeded() *emptypb.Empty { 90 | if x, ok := x.GetEvent().(*Signal_RenegotiationNeeded); ok { 91 | return x.RenegotiationNeeded 92 | } 93 | return nil 94 | } 95 | 96 | type isSignal_Event interface { 97 | isSignal_Event() 98 | } 99 | 100 | type Signal_IceCandidate struct { 101 | // WebRTC ICE candidate event. 102 | IceCandidate string `protobuf:"bytes,1,opt,name=ice_candidate,json=iceCandidate,proto3,oneof"` 103 | } 104 | 105 | type Signal_RenegotiationNeeded struct { 106 | // Event sent when a renegotiation is needed in the WebRTC connection. 107 | RenegotiationNeeded *emptypb.Empty `protobuf:"bytes,2,opt,name=renegotiation_needed,json=renegotiationNeeded,proto3,oneof"` 108 | } 109 | 110 | func (*Signal_IceCandidate) isSignal_Event() {} 111 | 112 | func (*Signal_RenegotiationNeeded) isSignal_Event() {} 113 | 114 | // Used in `Connect` endpoint. 115 | type ConnectRequest struct { 116 | state protoimpl.MessageState 117 | sizeCache protoimpl.SizeCache 118 | unknownFields protoimpl.UnknownFields 119 | 120 | // Guild ID of the guild where the channel is. 121 | GuildId uint64 `protobuf:"varint,1,opt,name=guild_id,json=guildId,proto3" json:"guild_id,omitempty"` 122 | // Channel ID of the voice channel to connect. 123 | ChannelId uint64 `protobuf:"varint,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` 124 | // WebRTC Connection offer. 125 | Offer string `protobuf:"bytes,3,opt,name=offer,proto3" json:"offer,omitempty"` 126 | } 127 | 128 | func (x *ConnectRequest) Reset() { 129 | *x = ConnectRequest{} 130 | if protoimpl.UnsafeEnabled { 131 | mi := &file_voice_v1_voice_proto_msgTypes[1] 132 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 133 | ms.StoreMessageInfo(mi) 134 | } 135 | } 136 | 137 | func (x *ConnectRequest) String() string { 138 | return protoimpl.X.MessageStringOf(x) 139 | } 140 | 141 | func (*ConnectRequest) ProtoMessage() {} 142 | 143 | func (x *ConnectRequest) ProtoReflect() protoreflect.Message { 144 | mi := &file_voice_v1_voice_proto_msgTypes[1] 145 | if protoimpl.UnsafeEnabled && x != nil { 146 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 147 | if ms.LoadMessageInfo() == nil { 148 | ms.StoreMessageInfo(mi) 149 | } 150 | return ms 151 | } 152 | return mi.MessageOf(x) 153 | } 154 | 155 | // Deprecated: Use ConnectRequest.ProtoReflect.Descriptor instead. 156 | func (*ConnectRequest) Descriptor() ([]byte, []int) { 157 | return file_voice_v1_voice_proto_rawDescGZIP(), []int{1} 158 | } 159 | 160 | func (x *ConnectRequest) GetGuildId() uint64 { 161 | if x != nil { 162 | return x.GuildId 163 | } 164 | return 0 165 | } 166 | 167 | func (x *ConnectRequest) GetChannelId() uint64 { 168 | if x != nil { 169 | return x.ChannelId 170 | } 171 | return 0 172 | } 173 | 174 | func (x *ConnectRequest) GetOffer() string { 175 | if x != nil { 176 | return x.Offer 177 | } 178 | return "" 179 | } 180 | 181 | // Used in `Connect` endpoint. 182 | type ConnectResponse struct { 183 | state protoimpl.MessageState 184 | sizeCache protoimpl.SizeCache 185 | unknownFields protoimpl.UnknownFields 186 | 187 | // WebRTC Connection answer. 188 | Answer string `protobuf:"bytes,1,opt,name=answer,proto3" json:"answer,omitempty"` 189 | } 190 | 191 | func (x *ConnectResponse) Reset() { 192 | *x = ConnectResponse{} 193 | if protoimpl.UnsafeEnabled { 194 | mi := &file_voice_v1_voice_proto_msgTypes[2] 195 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 196 | ms.StoreMessageInfo(mi) 197 | } 198 | } 199 | 200 | func (x *ConnectResponse) String() string { 201 | return protoimpl.X.MessageStringOf(x) 202 | } 203 | 204 | func (*ConnectResponse) ProtoMessage() {} 205 | 206 | func (x *ConnectResponse) ProtoReflect() protoreflect.Message { 207 | mi := &file_voice_v1_voice_proto_msgTypes[2] 208 | if protoimpl.UnsafeEnabled && x != nil { 209 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 210 | if ms.LoadMessageInfo() == nil { 211 | ms.StoreMessageInfo(mi) 212 | } 213 | return ms 214 | } 215 | return mi.MessageOf(x) 216 | } 217 | 218 | // Deprecated: Use ConnectResponse.ProtoReflect.Descriptor instead. 219 | func (*ConnectResponse) Descriptor() ([]byte, []int) { 220 | return file_voice_v1_voice_proto_rawDescGZIP(), []int{2} 221 | } 222 | 223 | func (x *ConnectResponse) GetAnswer() string { 224 | if x != nil { 225 | return x.Answer 226 | } 227 | return "" 228 | } 229 | 230 | // Used in `StreamState` endpoint. 231 | type StreamStateRequest struct { 232 | state protoimpl.MessageState 233 | sizeCache protoimpl.SizeCache 234 | unknownFields protoimpl.UnknownFields 235 | 236 | // Guild ID of the guild where the channel is. 237 | GuildId uint64 `protobuf:"varint,1,opt,name=guild_id,json=guildId,proto3" json:"guild_id,omitempty"` 238 | // Channel ID of the voice channel to stream states for. 239 | ChannelId uint64 `protobuf:"varint,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` 240 | } 241 | 242 | func (x *StreamStateRequest) Reset() { 243 | *x = StreamStateRequest{} 244 | if protoimpl.UnsafeEnabled { 245 | mi := &file_voice_v1_voice_proto_msgTypes[3] 246 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 247 | ms.StoreMessageInfo(mi) 248 | } 249 | } 250 | 251 | func (x *StreamStateRequest) String() string { 252 | return protoimpl.X.MessageStringOf(x) 253 | } 254 | 255 | func (*StreamStateRequest) ProtoMessage() {} 256 | 257 | func (x *StreamStateRequest) ProtoReflect() protoreflect.Message { 258 | mi := &file_voice_v1_voice_proto_msgTypes[3] 259 | if protoimpl.UnsafeEnabled && x != nil { 260 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 261 | if ms.LoadMessageInfo() == nil { 262 | ms.StoreMessageInfo(mi) 263 | } 264 | return ms 265 | } 266 | return mi.MessageOf(x) 267 | } 268 | 269 | // Deprecated: Use StreamStateRequest.ProtoReflect.Descriptor instead. 270 | func (*StreamStateRequest) Descriptor() ([]byte, []int) { 271 | return file_voice_v1_voice_proto_rawDescGZIP(), []int{3} 272 | } 273 | 274 | func (x *StreamStateRequest) GetGuildId() uint64 { 275 | if x != nil { 276 | return x.GuildId 277 | } 278 | return 0 279 | } 280 | 281 | func (x *StreamStateRequest) GetChannelId() uint64 { 282 | if x != nil { 283 | return x.ChannelId 284 | } 285 | return 0 286 | } 287 | 288 | // Used in `StreamState` endpoint. 289 | type StreamStateResponse struct { 290 | state protoimpl.MessageState 291 | sizeCache protoimpl.SizeCache 292 | unknownFields protoimpl.UnknownFields 293 | 294 | // The signal event. 295 | Signal *Signal `protobuf:"bytes,1,opt,name=signal,proto3" json:"signal,omitempty"` 296 | } 297 | 298 | func (x *StreamStateResponse) Reset() { 299 | *x = StreamStateResponse{} 300 | if protoimpl.UnsafeEnabled { 301 | mi := &file_voice_v1_voice_proto_msgTypes[4] 302 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 303 | ms.StoreMessageInfo(mi) 304 | } 305 | } 306 | 307 | func (x *StreamStateResponse) String() string { 308 | return protoimpl.X.MessageStringOf(x) 309 | } 310 | 311 | func (*StreamStateResponse) ProtoMessage() {} 312 | 313 | func (x *StreamStateResponse) ProtoReflect() protoreflect.Message { 314 | mi := &file_voice_v1_voice_proto_msgTypes[4] 315 | if protoimpl.UnsafeEnabled && x != nil { 316 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 317 | if ms.LoadMessageInfo() == nil { 318 | ms.StoreMessageInfo(mi) 319 | } 320 | return ms 321 | } 322 | return mi.MessageOf(x) 323 | } 324 | 325 | // Deprecated: Use StreamStateResponse.ProtoReflect.Descriptor instead. 326 | func (*StreamStateResponse) Descriptor() ([]byte, []int) { 327 | return file_voice_v1_voice_proto_rawDescGZIP(), []int{4} 328 | } 329 | 330 | func (x *StreamStateResponse) GetSignal() *Signal { 331 | if x != nil { 332 | return x.Signal 333 | } 334 | return nil 335 | } 336 | 337 | var File_voice_v1_voice_proto protoreflect.FileDescriptor 338 | 339 | var file_voice_v1_voice_proto_rawDesc = []byte{ 340 | 0x0a, 0x14, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x6f, 0x69, 0x63, 0x65, 341 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 342 | 0x2e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 343 | 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 344 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x74, 345 | 0x79, 0x70, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 346 | 0x6f, 0x74, 0x6f, 0x22, 0x85, 0x01, 0x0a, 0x06, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x12, 0x25, 347 | 0x0a, 0x0d, 0x69, 0x63, 0x65, 0x5f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x18, 348 | 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c, 0x69, 0x63, 0x65, 0x43, 0x61, 0x6e, 0x64, 349 | 0x69, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x14, 0x72, 0x65, 0x6e, 0x65, 0x67, 0x6f, 0x74, 350 | 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x65, 0x65, 0x64, 0x65, 0x64, 0x18, 0x02, 0x20, 351 | 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 352 | 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x48, 0x00, 0x52, 0x13, 0x72, 353 | 0x65, 0x6e, 0x65, 0x67, 0x6f, 0x74, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x65, 0x65, 0x64, 354 | 0x65, 0x64, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x60, 0x0a, 0x0e, 0x43, 355 | 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 356 | 0x08, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 357 | 0x07, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x6e, 358 | 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x63, 0x68, 359 | 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x66, 0x66, 0x65, 0x72, 360 | 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x22, 0x29, 0x0a, 361 | 0x0f, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 362 | 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 363 | 0x52, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x22, 0x4e, 0x0a, 0x12, 0x53, 0x74, 0x72, 0x65, 364 | 0x61, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 365 | 0x0a, 0x08, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 366 | 0x52, 0x07, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x68, 0x61, 367 | 0x6e, 0x6e, 0x65, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x63, 368 | 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x64, 0x22, 0x48, 0x0a, 0x13, 0x53, 0x74, 0x72, 0x65, 369 | 0x61, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 370 | 0x31, 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 371 | 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x76, 0x6f, 0x69, 0x63, 0x65, 372 | 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x52, 0x06, 0x73, 0x69, 0x67, 0x6e, 373 | 0x61, 0x6c, 0x32, 0xce, 0x01, 0x0a, 0x0c, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 374 | 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x21, 375 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x2e, 376 | 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 377 | 0x74, 0x1a, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x76, 0x6f, 0x69, 378 | 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 379 | 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 0x08, 0x01, 0x12, 0x65, 0x0a, 0x0b, 380 | 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x25, 0x2e, 0x70, 0x72, 381 | 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 382 | 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 383 | 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x76, 0x6f, 384 | 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x74, 0x61, 385 | 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x05, 0x9a, 0x44, 0x02, 0x08, 386 | 0x01, 0x30, 0x01, 0x42, 0xc5, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 387 | 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x56, 388 | 0x6f, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, 0x74, 389 | 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x2d, 390 | 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x6c, 0x65, 0x67, 0x61, 391 | 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x3b, 392 | 0x76, 0x6f, 0x69, 0x63, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x50, 0x56, 0x58, 0xaa, 0x02, 0x11, 393 | 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x2e, 0x56, 394 | 0x31, 0xca, 0x02, 0x11, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5c, 0x56, 0x6f, 0x69, 395 | 0x63, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 396 | 0x5c, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 397 | 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 398 | 0x3a, 0x3a, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 399 | 0x74, 0x6f, 0x33, 400 | } 401 | 402 | var ( 403 | file_voice_v1_voice_proto_rawDescOnce sync.Once 404 | file_voice_v1_voice_proto_rawDescData = file_voice_v1_voice_proto_rawDesc 405 | ) 406 | 407 | func file_voice_v1_voice_proto_rawDescGZIP() []byte { 408 | file_voice_v1_voice_proto_rawDescOnce.Do(func() { 409 | file_voice_v1_voice_proto_rawDescData = protoimpl.X.CompressGZIP(file_voice_v1_voice_proto_rawDescData) 410 | }) 411 | return file_voice_v1_voice_proto_rawDescData 412 | } 413 | 414 | var file_voice_v1_voice_proto_msgTypes = make([]protoimpl.MessageInfo, 5) 415 | var file_voice_v1_voice_proto_goTypes = []interface{}{ 416 | (*Signal)(nil), // 0: protocol.voice.v1.Signal 417 | (*ConnectRequest)(nil), // 1: protocol.voice.v1.ConnectRequest 418 | (*ConnectResponse)(nil), // 2: protocol.voice.v1.ConnectResponse 419 | (*StreamStateRequest)(nil), // 3: protocol.voice.v1.StreamStateRequest 420 | (*StreamStateResponse)(nil), // 4: protocol.voice.v1.StreamStateResponse 421 | (*emptypb.Empty)(nil), // 5: google.protobuf.Empty 422 | } 423 | var file_voice_v1_voice_proto_depIdxs = []int32{ 424 | 5, // 0: protocol.voice.v1.Signal.renegotiation_needed:type_name -> google.protobuf.Empty 425 | 0, // 1: protocol.voice.v1.StreamStateResponse.signal:type_name -> protocol.voice.v1.Signal 426 | 1, // 2: protocol.voice.v1.VoiceService.Connect:input_type -> protocol.voice.v1.ConnectRequest 427 | 3, // 3: protocol.voice.v1.VoiceService.StreamState:input_type -> protocol.voice.v1.StreamStateRequest 428 | 2, // 4: protocol.voice.v1.VoiceService.Connect:output_type -> protocol.voice.v1.ConnectResponse 429 | 4, // 5: protocol.voice.v1.VoiceService.StreamState:output_type -> protocol.voice.v1.StreamStateResponse 430 | 4, // [4:6] is the sub-list for method output_type 431 | 2, // [2:4] is the sub-list for method input_type 432 | 2, // [2:2] is the sub-list for extension type_name 433 | 2, // [2:2] is the sub-list for extension extendee 434 | 0, // [0:2] is the sub-list for field type_name 435 | } 436 | 437 | func init() { file_voice_v1_voice_proto_init() } 438 | func file_voice_v1_voice_proto_init() { 439 | if File_voice_v1_voice_proto != nil { 440 | return 441 | } 442 | if !protoimpl.UnsafeEnabled { 443 | file_voice_v1_voice_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 444 | switch v := v.(*Signal); i { 445 | case 0: 446 | return &v.state 447 | case 1: 448 | return &v.sizeCache 449 | case 2: 450 | return &v.unknownFields 451 | default: 452 | return nil 453 | } 454 | } 455 | file_voice_v1_voice_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 456 | switch v := v.(*ConnectRequest); i { 457 | case 0: 458 | return &v.state 459 | case 1: 460 | return &v.sizeCache 461 | case 2: 462 | return &v.unknownFields 463 | default: 464 | return nil 465 | } 466 | } 467 | file_voice_v1_voice_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 468 | switch v := v.(*ConnectResponse); i { 469 | case 0: 470 | return &v.state 471 | case 1: 472 | return &v.sizeCache 473 | case 2: 474 | return &v.unknownFields 475 | default: 476 | return nil 477 | } 478 | } 479 | file_voice_v1_voice_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 480 | switch v := v.(*StreamStateRequest); i { 481 | case 0: 482 | return &v.state 483 | case 1: 484 | return &v.sizeCache 485 | case 2: 486 | return &v.unknownFields 487 | default: 488 | return nil 489 | } 490 | } 491 | file_voice_v1_voice_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 492 | switch v := v.(*StreamStateResponse); i { 493 | case 0: 494 | return &v.state 495 | case 1: 496 | return &v.sizeCache 497 | case 2: 498 | return &v.unknownFields 499 | default: 500 | return nil 501 | } 502 | } 503 | } 504 | file_voice_v1_voice_proto_msgTypes[0].OneofWrappers = []interface{}{ 505 | (*Signal_IceCandidate)(nil), 506 | (*Signal_RenegotiationNeeded)(nil), 507 | } 508 | type x struct{} 509 | out := protoimpl.TypeBuilder{ 510 | File: protoimpl.DescBuilder{ 511 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 512 | RawDescriptor: file_voice_v1_voice_proto_rawDesc, 513 | NumEnums: 0, 514 | NumMessages: 5, 515 | NumExtensions: 0, 516 | NumServices: 1, 517 | }, 518 | GoTypes: file_voice_v1_voice_proto_goTypes, 519 | DependencyIndexes: file_voice_v1_voice_proto_depIdxs, 520 | MessageInfos: file_voice_v1_voice_proto_msgTypes, 521 | }.Build() 522 | File_voice_v1_voice_proto = out.File 523 | file_voice_v1_voice_proto_rawDesc = nil 524 | file_voice_v1_voice_proto_goTypes = nil 525 | file_voice_v1_voice_proto_depIdxs = nil 526 | } 527 | --------------------------------------------------------------------------------