mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
feat: Implement service worker for IPFS vault
This commit is contained in:
+11
-14
@@ -15,9 +15,9 @@ import (
|
||||
"github.com/labstack/echo/v4"
|
||||
promise "github.com/nlepage/go-js-promise"
|
||||
|
||||
"github.com/onsonr/sonr/cmd/motr/state"
|
||||
"github.com/onsonr/sonr/internal/session"
|
||||
"github.com/onsonr/sonr/pkg/nebula/router"
|
||||
"github.com/onsonr/sonr/pkg/nebula/routes"
|
||||
"github.com/onsonr/sonr/pkg/nebula/worker"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -30,21 +30,18 @@ func main() {
|
||||
|
||||
func registerState(e *echo.Echo) {
|
||||
g := e.Group("state")
|
||||
g.POST("/login/:identifier", state.HandleCredentialAssertion)
|
||||
// g.GET("/discovery", state.GetDiscovery)
|
||||
g.GET("/jwks", state.GetJWKS)
|
||||
g.GET("/token", state.GetToken)
|
||||
g.POST("/:origin/grant/:subject", state.GrantAuthorization)
|
||||
g.POST("/register/:subject", state.HandleCredentialCreation)
|
||||
g.POST("/register/:subject/check", state.CheckSubjectIsValid)
|
||||
g.POST("/login/:identifier", worker.HandleCredentialAssertion)
|
||||
g.GET("/jwks", worker.GetJWKS)
|
||||
g.GET("/token", worker.GetToken)
|
||||
g.POST("/:origin/grant/:subject", worker.GrantAuthorization)
|
||||
g.POST("/register/:subject", worker.HandleCredentialCreation)
|
||||
g.POST("/register/:subject/check", worker.CheckSubjectIsValid)
|
||||
}
|
||||
|
||||
func registerViews(e *echo.Echo) {
|
||||
e.GET("/home", router.Home)
|
||||
e.GET("/login", router.Login)
|
||||
e.GET("/register", router.Register)
|
||||
e.GET("/profile", router.Profile)
|
||||
e.GET("/authorize", router.Authorize)
|
||||
e.GET("/home", routes.Home)
|
||||
e.GET("/login", routes.LoginStart)
|
||||
e.GET("/register", routes.RegisterStart)
|
||||
}
|
||||
|
||||
// Serve serves HTTP requests using handler or http.DefaultServeMux if handler is nil.
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-webauthn/webauthn/protocol"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func CheckSubjectIsValid(e echo.Context) error {
|
||||
credentialID := e.FormValue("credentialID")
|
||||
return e.JSON(200, credentialID)
|
||||
}
|
||||
|
||||
func HandleCredentialAssertion(e echo.Context) error {
|
||||
return e.JSON(200, "HandleCredentialAssertion")
|
||||
}
|
||||
|
||||
func HandleCredentialCreation(e echo.Context) error {
|
||||
// Get the serialized credential data from the form
|
||||
credentialDataJSON := e.FormValue("credentialData")
|
||||
|
||||
// Deserialize the JSON into a temporary struct
|
||||
var ccr protocol.CredentialCreationResponse
|
||||
err := json.Unmarshal([]byte(credentialDataJSON), &ccr)
|
||||
if err != nil {
|
||||
return e.JSON(500, err.Error())
|
||||
}
|
||||
//
|
||||
// // Parse the CredentialCreationResponse
|
||||
// parsedData, err := ccr.Parse()
|
||||
// if err != nil {
|
||||
// return e.JSON(500, err.Error())
|
||||
// }
|
||||
//
|
||||
// // Create the Credential
|
||||
// // credential := orm.NewCredential(parsedData, e.Request().Host, "")
|
||||
//
|
||||
// // Set additional fields
|
||||
// credential.Controller = "" // Set this to the appropriate controller value
|
||||
return e.JSON(200, fmt.Sprintf("REGISTER: %s", string(ccr.ID)))
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package state
|
||||
@@ -1,23 +0,0 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func GrantAuthorization(e echo.Context) error {
|
||||
// Implement authorization endpoint using passkey authentication
|
||||
// Store session data in cache
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetJWKS(e echo.Context) error {
|
||||
// Implement token endpoint
|
||||
// Use cached session data for validation
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetToken(e echo.Context) error {
|
||||
// Implement token endpoint
|
||||
// Use cached session data for validation
|
||||
return nil
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package state
|
||||
Reference in New Issue
Block a user