mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 10:21:40 +00:00
feature/implement wss routes (#1196)
* feat(database): create schema for hway and motr * fix(gateway): correct naming inconsistencies in handlers * build: update schema file to be compatible with postgresql syntax * fix: update schema to be compatible with PostgreSQL syntax * chore: update query_hway.sql to follow sqlc syntax * ```text refactor: update query_hway.sql for PostgreSQL and sqlc ``` * feat: add vaults table to store encrypted data * refactor: Update vaults table schema for sqlc compatibility * chore(deps): Upgrade dependencies and add pgx/v5 * refactor(Makefile): move sqlc generate to internal/models * docs(foundations): remove outdated pages * chore(build): add Taskfile for build tasks * refactor(embed): move embed files to internal package * docs: add documentation for Cosmos SDK ORM
This commit is contained in:
@@ -6,11 +6,10 @@ import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/crypto/mpc"
|
||||
"github.com/onsonr/sonr/internal/context"
|
||||
"github.com/onsonr/sonr/pkg/gateway/types"
|
||||
"lukechampine.com/blake3"
|
||||
)
|
||||
|
||||
func Spawn(c echo.Context) (types.CreatePasskeyParams, error) {
|
||||
func Spawn(c echo.Context) (CreatePasskeyParams, error) {
|
||||
cc := c.(*GatewayContext)
|
||||
block := fmt.Sprintf("%d", CurrentBlock(c))
|
||||
handle := GetHandle(c)
|
||||
@@ -19,15 +18,15 @@ func Spawn(c echo.Context) (types.CreatePasskeyParams, error) {
|
||||
sid := GetSessionID(c)
|
||||
nonce, err := calcNonce(sid)
|
||||
if err != nil {
|
||||
return types.DefaultCreatePasskeyParams(), err
|
||||
return defaultCreatePasskeyParams(), err
|
||||
}
|
||||
encl, err := mpc.GenEnclave(nonce)
|
||||
if err != nil {
|
||||
return types.DefaultCreatePasskeyParams(), err
|
||||
return defaultCreatePasskeyParams(), err
|
||||
}
|
||||
cc.stagedEnclaves[sid] = encl
|
||||
context.WriteCookie(c, context.SonrAddress, encl.Address())
|
||||
return types.CreatePasskeyParams{
|
||||
return CreatePasskeyParams{
|
||||
Address: encl.Address(),
|
||||
Handle: handle,
|
||||
Name: origin,
|
||||
@@ -36,8 +35,8 @@ func Spawn(c echo.Context) (types.CreatePasskeyParams, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func Claim() (types.CreatePasskeyParams, error) {
|
||||
return types.CreatePasskeyParams{}, nil
|
||||
func Claim() (CreatePasskeyParams, error) {
|
||||
return CreatePasskeyParams{}, nil
|
||||
}
|
||||
|
||||
// Uses blake3 to hash the sessionID to generate a nonce of length 12 bytes
|
||||
@@ -55,3 +54,27 @@ func calcNonce(sessionID string) ([]byte, error) {
|
||||
}
|
||||
return nonce, nil
|
||||
}
|
||||
|
||||
// ╭───────────────────────────────────────────────────────────╮
|
||||
// │ Create Passkey (/register/passkey) │
|
||||
// ╰───────────────────────────────────────────────────────────╯
|
||||
|
||||
// defaultCreatePasskeyParams returns a default CreatePasskeyParams
|
||||
func defaultCreatePasskeyParams() CreatePasskeyParams {
|
||||
return CreatePasskeyParams{
|
||||
Address: "",
|
||||
Handle: "",
|
||||
Name: "",
|
||||
Challenge: "",
|
||||
CreationBlock: "",
|
||||
}
|
||||
}
|
||||
|
||||
// CreatePasskeyParams represents the parameters for creating a passkey
|
||||
type CreatePasskeyParams struct {
|
||||
Address string
|
||||
Handle string
|
||||
Name string
|
||||
Challenge string
|
||||
CreationBlock string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user