mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
refactor: Update credential handling to use protocol.CredentialDescriptor
This commit is contained in:
committed by
Prad Nukala (aider)
parent
60cede383a
commit
d030dbcfde
@@ -41,19 +41,9 @@ func HandleRegisterStart(c echo.Context) error {
|
|||||||
return response.TemplEcho(c, register.LinkCredentialView(dat))
|
return response.TemplEcho(c, register.LinkCredentialView(dat))
|
||||||
}
|
}
|
||||||
|
|
||||||
type Credential struct {
|
|
||||||
ID string `json:"id"`
|
|
||||||
RawID []int `json:"rawId"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Response struct {
|
|
||||||
AttestationObject []int `json:"attestationObject"`
|
|
||||||
ClientDataJSON []int `json:"clientDataJSON"`
|
|
||||||
} `json:"response"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func HandleRegisterFinish(c echo.Context) error {
|
func HandleRegisterFinish(c echo.Context) error {
|
||||||
credB64 := c.FormValue("credential")
|
credB64 := c.FormValue("credential")
|
||||||
|
|
||||||
// Decode base64 credential
|
// Decode base64 credential
|
||||||
credJSON, err := base64.StdEncoding.DecodeString(credB64)
|
credJSON, err := base64.StdEncoding.DecodeString(credB64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -61,17 +51,14 @@ func HandleRegisterFinish(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal credential
|
// Unmarshal credential
|
||||||
var cred Credential
|
var cred protocol.CredentialDescriptor
|
||||||
if err := json.Unmarshal(credJSON, &cred); err != nil {
|
if err := json.Unmarshal(credJSON, &cred); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusBadRequest, "invalid credential format")
|
return echo.NewHTTPError(http.StatusBadRequest, "invalid credential format")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log credential details
|
// Log credential details
|
||||||
fmt.Printf("Credential ID: %s\n", cred.ID)
|
fmt.Printf("Credential ID: %s\n", cred.CredentialID)
|
||||||
fmt.Printf("Credential Type: %s\n", cred.Type)
|
fmt.Printf("Credential Type: %s\n", cred.Type)
|
||||||
fmt.Printf("Raw ID Length: %d\n", len(cred.RawID))
|
|
||||||
fmt.Printf("Attestation Object Length: %d\n", len(cred.Response.AttestationObject))
|
|
||||||
fmt.Printf("Client Data Length: %d\n", len(cred.Response.ClientDataJSON))
|
|
||||||
|
|
||||||
return response.TemplEcho(c, register.LoadingVaultView())
|
return response.TemplEcho(c, register.LoadingVaultView())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user