diff --git a/internal/types/exec.go b/internal/types/exec.go new file mode 100644 index 0000000..5136279 --- /dev/null +++ b/internal/types/exec.go @@ -0,0 +1,16 @@ +package types + +import "encoding/json" + +// ExecInput represents the input for the exec function +type ExecInput struct { + Filter string `json:"filter"` // GitHub-style filter: "resource:accounts action:sign" + Token string `json:"token"` // UCAN token for authorization +} + +// ExecOutput represents the output of the exec function +type ExecOutput struct { + Success bool `json:"success"` + Result json.RawMessage `json:"result,omitempty"` + Error string `json:"error,omitempty"` +} diff --git a/internal/types/filters.go b/internal/types/filters.go new file mode 100644 index 0000000..4315ef0 --- /dev/null +++ b/internal/types/filters.go @@ -0,0 +1,9 @@ +// Package types contains the types used by the enclave. +package types + +// FilterParams parsed from GitHub-style filter syntax +type FilterParams struct { + Resource string + Action string + Subject string +} diff --git a/internal/types/generate.go b/internal/types/generate.go new file mode 100644 index 0000000..9cd550c --- /dev/null +++ b/internal/types/generate.go @@ -0,0 +1,12 @@ +package types + +// GenerateInput represents the input for the generate function +type GenerateInput struct { + Credential string `json:"credential"` // Base64-encoded PublicKeyCredential +} + +// GenerateOutput represents the output of the generate function +type GenerateOutput struct { + DID string `json:"did"` + Database []byte `json:"database"` +} diff --git a/internal/types/load.go b/internal/types/load.go new file mode 100644 index 0000000..dabe148 --- /dev/null +++ b/internal/types/load.go @@ -0,0 +1,13 @@ +package types + +// LoadInput represents the input for the load function +type LoadInput struct { + Database []byte `json:"database"` +} + +// LoadOutput represents the output of the load function +type LoadOutput struct { + Success bool `json:"success"` + DID string `json:"did,omitempty"` + Error string `json:"error,omitempty"` +} diff --git a/internal/types/ping.go b/internal/types/ping.go new file mode 100644 index 0000000..fd3fca2 --- /dev/null +++ b/internal/types/ping.go @@ -0,0 +1,11 @@ +package types + +type PingInput struct { + Message string `json:"message"` +} + +type PingOutput struct { + Success bool `json:"success"` + Message string `json:"message"` + Echo string `json:"echo"` +} diff --git a/internal/types/query.go b/internal/types/query.go new file mode 100644 index 0000000..00b0f42 --- /dev/null +++ b/internal/types/query.go @@ -0,0 +1,46 @@ +package types + +// QueryInput represents the input for the query function +type QueryInput struct { + DID string `json:"did"` +} + +// QueryOutput represents the output of the query function +type QueryOutput struct { + DID string `json:"did"` + Controller string `json:"controller"` + VerificationMethods []VerificationMethod `json:"verification_methods"` + Accounts []Account `json:"accounts"` + Credentials []Credential `json:"credentials"` +} + +// VerificationMethod represents a DID verification method +type VerificationMethod struct { + ID string `json:"id"` + Type string `json:"type"` + Controller string `json:"controller"` + PublicKey string `json:"public_key"` + Purpose string `json:"purpose"` +} + +// Account represents a derived blockchain account +type Account struct { + Address string `json:"address"` + ChainID string `json:"chain_id"` + CoinType int `json:"coin_type"` + AccountIndex int `json:"account_index"` + AddressIndex int `json:"address_index"` + Label string `json:"label"` + IsDefault bool `json:"is_default"` +} + +// Credential represents a WebAuthn credential +type Credential struct { + CredentialID string `json:"credential_id"` + DeviceName string `json:"device_name"` + DeviceType string `json:"device_type"` + Authenticator string `json:"authenticator"` + Transports []string `json:"transports"` + CreatedAt string `json:"created_at"` + LastUsed string `json:"last_used"` +}