refactor: move vault package internal components to root

This commit is contained in:
Prad Nukala
2024-12-09 18:31:12 -05:00
parent 0ff4299061
commit 67432d3fdf
17 changed files with 2 additions and 2 deletions
+51
View File
@@ -0,0 +1,51 @@
package session
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/common"
)
// HTTPContext is the context for HTTP endpoints.
type HTTPContext struct {
echo.Context
role common.PeerRole
id string
chal string
bn string
bv string
}
// initHTTPContext loads the headers from the request.
func initHTTPContext(c echo.Context) *HTTPContext {
if c == nil {
return &HTTPContext{}
}
id, chal := extractPeerInfo(c)
bn, bv := extractBrowserInfo(c)
cc := &HTTPContext{
Context: c,
role: common.PeerRole(common.ReadCookieUnsafe(c, common.SessionRole)),
id: id,
chal: chal,
bn: bn,
bv: bv,
}
// Set the session data in both contexts
return cc
}
func (s *HTTPContext) ID() string {
return s.id
}
func (s *HTTPContext) BrowserName() string {
return s.bn
}
func (s *HTTPContext) BrowserVersion() string {
return s.bv
}