feat: Add auth flow (#146)

This adds a simple way to incorporate a centralized authentication flow.

The idea is to have the user, API and SSH (for machine authentication)
all in one place using `openauthjs` + `SST`

We also have a database now :)

> We are using InstantDB as it allows us to authenticate a use with just
the email. Plus it is super simple simple to use _of course after the
initial fumbles trying to design the db and relationships_
This commit is contained in:
Wanjohi
2025-01-04 00:02:28 +03:00
committed by GitHub
parent 33895974a7
commit fc5a755408
136 changed files with 3512 additions and 1914 deletions

58
packages/cli/main.go Normal file
View File

@@ -0,0 +1,58 @@
package main
import (
"context"
"nestrilabs/cli/internal/session"
"github.com/charmbracelet/log"
)
func main() {
// err := cmd.Execute()
// if err != nil {
// log.Error("Error running the cmd command", "err", err)
// }
ctx := context.Background()
config := &session.SessionConfig{
Room: "victortest",
Resolution: "1920x1080",
Framerate: "60",
RelayURL: "https://relay.dathorse.com",
Params: "--verbose=true --video-codec=h264 --video-bitrate=4000 --video-bitrate-max=6000 --gpu-card-path=/dev/dri/card1",
GamePath: "/path/to/your/game",
}
sess, err := session.NewSession(config)
if err != nil {
log.Error("Failed to create session", "err", err)
}
// Start the session
if err := sess.Start(ctx); err != nil {
log.Error("Failed to start session", "err", err)
}
// Check if it's running
if sess.IsRunning() {
log.Info("Session is running with container ID", "containerId", sess.GetContainerID())
}
env, err := sess.GetEnvironment(ctx)
if err != nil {
log.Printf("Failed to get environment: %v", err)
} else {
for key, value := range env {
log.Info("Found this environment variables", key, value)
}
}
// Let it run for a while
// time.Sleep(time.Second * 50)
// Stop the session
if err := sess.Stop(ctx); err != nil {
log.Error("Failed to stop session", "err", err)
}
}