feature/1110 abstract connected wallet operations (#1166)

- **refactor: refactor DID module types and move to controller package**
- **refactor: move controller creation and resolution logic to keeper**
- **refactor: update imports to reflect controller package move**
- **refactor: update protobuf definitions for DID module**
- **docs: update proto README to reflect changes**
- **refactor: move hway to gateway, update node modules, and refactor
pkl generation**
- **build: update pkl-gen task to use new pkl file paths**
- **refactor: refactor DWN WASM build and deployment process**
- **refactor: refactor DID controller implementation to use
account-based storage**
- **refactor: move DID controller interface to base file and update
implementation**
- **chore: migrate to google protobuf**
- **feat: Add v0.52.0 Interfaces for Acc Abstraction**
- **refactor: replace public_key with public_key_hex in Assertion
message**
- **refactor: remove unused PubKey, JSONWebKey, and RawKey message types
and related code**
This commit is contained in:
Prad Nukala
2024-11-18 19:04:10 -05:00
committed by GitHub
parent 01cb37e82e
commit bf94277b0f
190 changed files with 9345 additions and 14038 deletions
+1
View File
@@ -0,0 +1 @@
# Common
+68
View File
@@ -0,0 +1,68 @@
package ctx
import (
"github.com/go-webauthn/webauthn/protocol"
"github.com/labstack/echo/v4"
"github.com/segmentio/ksuid"
)
// CookieKey is a type alias for string.
type CookieKey string
const (
// CookieKeySessionID is the key for the session ID cookie.
CookieKeySessionID CookieKey = "session.id"
// CookieKeySessionChal is the key for the session challenge cookie.
CookieKeySessionChal CookieKey = "session.chal"
// CookieKeySonrAddr is the key for the Sonr address cookie.
CookieKeySonrAddr CookieKey = "sonr.addr"
// CookieKeySonrDID is the key for the Sonr DID cookie.
CookieKeySonrDID CookieKey = "sonr.did"
// CookieKeyVaultCID is the key for the Vault CID cookie.
CookieKeyVaultCID CookieKey = "vault.cid"
// CookieKeyVaultSchema is the key for the Vault schema cookie.
CookieKeyVaultSchema CookieKey = "vault.schema"
)
// String returns the string representation of the CookieKey.
func (c CookieKey) String() string {
return string(c)
}
// GetSessionID returns the session ID from the cookies.
func GetSessionID(c echo.Context) string {
// Attempt to read the session ID from the "session" cookie
sessionID, err := ReadCookie(c, CookieKeySessionID)
if err != nil {
// Generate a new KSUID if the session cookie is missing or invalid
WriteCookie(c, CookieKeySessionID, ksuid.New().String())
}
return sessionID
}
// GetSessionChallenge returns the session challenge from the cookies.
func GetSessionChallenge(c echo.Context) (*protocol.URLEncodedBase64, error) {
// TODO: Implement a way to regenerate the challenge if it is invalid.
chal := new(protocol.URLEncodedBase64)
// Attempt to read the session challenge from the "session" cookie
sessionChal, err := ReadCookie(c, CookieKeySessionChal)
if err != nil {
// Generate a new challenge if the session cookie is missing or invalid
ch, errb := protocol.CreateChallenge()
if errb != nil {
return nil, err
}
WriteCookie(c, CookieKeySessionChal, ch.String())
return &ch, nil
}
err = chal.UnmarshalJSON([]byte(sessionChal))
if err != nil {
return nil, err
}
return chal, nil
}
+90
View File
@@ -0,0 +1,90 @@
package ctx
import (
"encoding/json"
"net/http"
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/motr/config"
)
// ╭───────────────────────────────────────────────────────────╮
// │ DWNContext struct methods │
// ╰───────────────────────────────────────────────────────────╯
// DWNContext is the context for DWN endpoints.
type DWNContext struct {
echo.Context
// Defaults
id string // Generated ksuid http cookie; Initialized on first request
}
// HasAuthorization returns true if the request has an Authorization header.
func (s *DWNContext) HasAuthorization() bool {
v := ReadHeader(s.Context, HeaderAuthorization)
return v != ""
}
// ID returns the ksuid http cookie.
func (s *DWNContext) ID() string {
return s.id
}
// Address returns the sonr address from the cookies.
func (s *DWNContext) Address() string {
v, err := ReadCookie(s.Context, CookieKeySonrAddr)
if err != nil {
return ""
}
return v
}
// IPFSGatewayURL returns the IPFS gateway URL from the headers.
func (s *DWNContext) IPFSGatewayURL() string {
return ReadHeader(s.Context, HeaderIPFSGatewayURL)
}
// ChainID returns the chain ID from the headers.
func (s *DWNContext) ChainID() string {
return ReadHeader(s.Context, HeaderSonrChainID)
}
// Schema returns the vault schema from the cookies.
func (s *DWNContext) Schema() *config.Schema {
v, err := ReadCookie(s.Context, CookieKeyVaultSchema)
if err != nil {
return nil
}
var schema config.Schema
err = json.Unmarshal([]byte(v), &schema)
if err != nil {
return nil
}
return &schema
}
// GetDWNContext returns the DWNContext from the echo context.
func GetDWNContext(c echo.Context) (*DWNContext, error) {
ctx, ok := c.(*DWNContext)
if !ok {
return nil, echo.NewHTTPError(http.StatusInternalServerError, "DWN Context not found")
}
return ctx, nil
}
// HighwaySessionMiddleware establishes a Session Cookie.
func DWNSessionMiddleware(config *config.Config) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
sessionID := GetSessionID(c)
injectConfig(c, config)
cc := &DWNContext{
Context: c,
id: sessionID,
}
return next(cc)
}
}
}
+45
View File
@@ -0,0 +1,45 @@
package ctx
import (
"net/http"
"github.com/labstack/echo/v4"
)
// ╭───────────────────────────────────────────────────────────╮
// │ HwayContext struct methods │
// ╰───────────────────────────────────────────────────────────╯
// HwayContext is the context for Highway endpoints.
type HwayContext struct {
echo.Context
// Defaults
id string // Generated ksuid http cookie; Initialized on first request
}
// ID returns the ksuid http cookie
func (s *HwayContext) ID() string {
return s.id
}
// GetHwayContext returns the HwayContext from the echo context.
func GetHWAYContext(c echo.Context) (*HwayContext, error) {
ctx, ok := c.(*HwayContext)
if !ok {
return nil, echo.NewHTTPError(http.StatusInternalServerError, "Highway Context not found")
}
return ctx, nil
}
// HighwaySessionMiddleware establishes a Session Cookie.
func HighwaySessionMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
sessionID := GetSessionID(c)
cc := &HwayContext{
Context: c,
id: sessionID,
}
return next(cc)
}
}
+38
View File
@@ -0,0 +1,38 @@
package ctx
import (
"encoding/json"
"github.com/labstack/echo/v4"
dwngen "github.com/onsonr/sonr/pkg/motr/config"
)
type HeaderKey string
const (
HeaderAuthorization HeaderKey = "Authorization"
HeaderIPFSGatewayURL HeaderKey = "X-IPFS-Gateway"
HeaderSonrChainID HeaderKey = "X-Sonr-ChainID"
HeaderSonrKeyshare HeaderKey = "X-Sonr-Keyshare"
)
func (h HeaderKey) String() string {
return string(h)
}
func injectConfig(c echo.Context, config *dwngen.Config) {
WriteHeader(c, HeaderIPFSGatewayURL, config.IpfsGatewayUrl)
WriteHeader(c, HeaderSonrChainID, config.SonrChainId)
WriteHeader(c, HeaderSonrKeyshare, config.MotrKeyshare)
WriteCookie(c, CookieKeySonrAddr, config.MotrAddress)
schemaBz, err := json.Marshal(config.VaultSchema)
if err != nil {
c.Logger().Error(err)
return
}
WriteCookie(c, CookieKeyVaultSchema, string(schemaBz))
}
+35
View File
@@ -0,0 +1,35 @@
package ctx
// ╭───────────────────────────────────────────────────────────╮
// │ Request Headers │
// ╰───────────────────────────────────────────────────────────╯
type RequestHeaders struct {
CacheControl *string `header:"Cache-Control"`
DeviceMemory *string `header:"Device-Memory"`
From *string `header:"From"`
Host *string `header:"Host"`
Referer *string `header:"Referer"`
UserAgent *string `header:"User-Agent"`
ViewportWidth *string `header:"Viewport-Width"`
Width *string `header:"Width"`
// HTMX Specific
HXBoosted *string `header:"HX-Boosted"`
HXCurrentURL *string `header:"HX-Current-URL"`
HXHistoryRestoreRequest *string `header:"HX-History-Restore-Request"`
HXPrompt *string `header:"HX-Prompt"`
HXRequest *string `header:"HX-Request"`
HXTarget *string `header:"HX-Target"`
HXTriggerName *string `header:"HX-Trigger-Name"`
HXTrigger *string `header:"HX-Trigger"`
}
type ProtectedRequestHeaders struct {
Authorization *string `header:"Authorization"`
Forwarded *string `header:"Forwarded"`
Link *string `header:"Link"`
PermissionsPolicy *string `header:"Permissions-Policy"`
ProxyAuthorization *string `header:"Proxy-Authorization"`
WWWAuthenticate *string `header:"WWW-Authenticate"`
}
+38
View File
@@ -0,0 +1,38 @@
package ctx
import "github.com/go-webauthn/webauthn/protocol"
type WebBytes = protocol.URLEncodedBase64
// ╭───────────────────────────────────────────────────────────╮
// │ Response Headers │
// ╰───────────────────────────────────────────────────────────╯
type ResponseHeaders struct {
// HTMX Specific
HXLocation *string `header:"HX-Location"`
HXPushURL *string `header:"HX-Push-Url"`
HXRedirect *string `header:"HX-Redirect"`
HXRefresh *string `header:"HX-Refresh"`
HXReplaceURL *string `header:"HX-Replace-Url"`
HXReswap *string `header:"HX-Reswap"`
HXRetarget *string `header:"HX-Retarget"`
HXReselect *string `header:"HX-Reselect"`
HXTrigger *string `header:"HX-Trigger"`
HXTriggerAfterSettle *string `header:"HX-Trigger-After-Settle"`
HXTriggerAfterSwap *string `header:"HX-Trigger-After-Swap"`
}
type ProtectedResponseHeaders struct {
AcceptCH *string `header:"Accept-CH"`
AccessControlAllowCredentials *string `header:"Access-Control-Allow-Credentials"`
AccessControlAllowHeaders *string `header:"Access-Control-Allow-Headers"`
AccessControlAllowMethods *string `header:"Access-Control-Allow-Methods"`
AccessControlExposeHeaders *string `header:"Access-Control-Expose-Headers"`
AccessControlRequestHeaders *string `header:"Access-Control-Request-Headers"`
ContentSecurityPolicy *string `header:"Content-Security-Policy"`
CrossOriginEmbedderPolicy *string `header:"Cross-Origin-Embedder-Policy"`
PermissionsPolicy *string `header:"Permissions-Policy"`
ProxyAuthorization *string `header:"Proxy-Authorization"`
WWWAuthenticate *string `header:"WWW-Authenticate"`
}
+73
View File
@@ -0,0 +1,73 @@
package ctx
import (
"bytes"
"net/http"
"time"
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
)
// ╭───────────────────────────────────────────────────────────╮
// │ Template Rendering │
// ╰───────────────────────────────────────────────────────────╯
func RenderTempl(c echo.Context, cmp templ.Component) error {
// Create a buffer to store the rendered HTML
buf := &bytes.Buffer{}
// Render the component to the buffer
err := cmp.Render(c.Request().Context(), buf)
if err != nil {
return err
}
// Set the content type
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
// Write the buffered content to the response
_, err = c.Response().Write(buf.Bytes())
return err
}
// ╭──────────────────────────────────────────────────────────╮
// │ Cookie Management │
// ╰──────────────────────────────────────────────────────────╯
func ReadCookie(c echo.Context, key CookieKey) (string, error) {
cookie, err := c.Cookie(key.String())
if err != nil {
// Cookie not found or other error
return "", err
}
if cookie == nil || cookie.Value == "" {
// Cookie is empty
return "", http.ErrNoCookie
}
return cookie.Value, nil
}
func WriteCookie(c echo.Context, key CookieKey, value string) error {
cookie := &http.Cookie{
Name: key.String(),
Value: value,
Expires: time.Now().Add(24 * time.Hour),
HttpOnly: true,
Path: "/",
// Add Secure and SameSite attributes as needed
}
c.SetCookie(cookie)
return nil
}
// ╭────────────────────────────────────────────────────────╮
// │ HTTP Headers │
// ╰────────────────────────────────────────────────────────╯
func WriteHeader(c echo.Context, key HeaderKey, value string) {
c.Response().Header().Set(key.String(), value)
}
func ReadHeader(c echo.Context, key HeaderKey) string {
return c.Response().Header().Get(key.String())
}
+64
View File
@@ -0,0 +1,64 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc (unknown)
// source: common/v1/ipfs.proto
package commonv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
var File_common_v1_ipfs_proto protoreflect.FileDescriptor
var file_common_v1_ipfs_proto_rawDesc = []byte{
0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x70, 0x66, 0x73,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76,
0x31, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f,
0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x3b, 0x63, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_common_v1_ipfs_proto_goTypes = []interface{}{}
var file_common_v1_ipfs_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_common_v1_ipfs_proto_init() }
func file_common_v1_ipfs_proto_init() {
if File_common_v1_ipfs_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_common_v1_ipfs_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_common_v1_ipfs_proto_goTypes,
DependencyIndexes: file_common_v1_ipfs_proto_depIdxs,
}.Build()
File_common_v1_ipfs_proto = out.File
file_common_v1_ipfs_proto_rawDesc = nil
file_common_v1_ipfs_proto_goTypes = nil
file_common_v1_ipfs_proto_depIdxs = nil
}
+377
View File
@@ -0,0 +1,377 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc (unknown)
// source: common/v1/keys.proto
package commonv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// PubKey defines a public key for a did
type PubKey struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
KeyType string `protobuf:"bytes,2,opt,name=key_type,json=keyType,proto3" json:"key_type,omitempty"`
RawKey *RawKey `protobuf:"bytes,3,opt,name=raw_key,json=rawKey,proto3" json:"raw_key,omitempty"`
Jwk *JSONWebKey `protobuf:"bytes,4,opt,name=jwk,proto3" json:"jwk,omitempty"`
}
func (x *PubKey) Reset() {
*x = PubKey{}
if protoimpl.UnsafeEnabled {
mi := &file_common_v1_keys_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PubKey) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PubKey) ProtoMessage() {}
func (x *PubKey) ProtoReflect() protoreflect.Message {
mi := &file_common_v1_keys_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PubKey.ProtoReflect.Descriptor instead.
func (*PubKey) Descriptor() ([]byte, []int) {
return file_common_v1_keys_proto_rawDescGZIP(), []int{0}
}
func (x *PubKey) GetRole() string {
if x != nil {
return x.Role
}
return ""
}
func (x *PubKey) GetKeyType() string {
if x != nil {
return x.KeyType
}
return ""
}
func (x *PubKey) GetRawKey() *RawKey {
if x != nil {
return x.RawKey
}
return nil
}
func (x *PubKey) GetJwk() *JSONWebKey {
if x != nil {
return x.Jwk
}
return nil
}
// JWK represents a JSON Web Key
type JSONWebKey struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Kty string `protobuf:"bytes,1,opt,name=kty,proto3" json:"kty,omitempty"` // Key Type
Crv string `protobuf:"bytes,2,opt,name=crv,proto3" json:"crv,omitempty"` // Curve (for EC and OKP keys)
X string `protobuf:"bytes,3,opt,name=x,proto3" json:"x,omitempty"` // X coordinate (for EC and OKP keys)
Y string `protobuf:"bytes,4,opt,name=y,proto3" json:"y,omitempty"` // Y coordinate (for EC keys)
N string `protobuf:"bytes,5,opt,name=n,proto3" json:"n,omitempty"` // Modulus (for RSA keys)
E string `protobuf:"bytes,6,opt,name=e,proto3" json:"e,omitempty"` // Exponent (for RSA keys)
}
func (x *JSONWebKey) Reset() {
*x = JSONWebKey{}
if protoimpl.UnsafeEnabled {
mi := &file_common_v1_keys_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *JSONWebKey) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*JSONWebKey) ProtoMessage() {}
func (x *JSONWebKey) ProtoReflect() protoreflect.Message {
mi := &file_common_v1_keys_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use JSONWebKey.ProtoReflect.Descriptor instead.
func (*JSONWebKey) Descriptor() ([]byte, []int) {
return file_common_v1_keys_proto_rawDescGZIP(), []int{1}
}
func (x *JSONWebKey) GetKty() string {
if x != nil {
return x.Kty
}
return ""
}
func (x *JSONWebKey) GetCrv() string {
if x != nil {
return x.Crv
}
return ""
}
func (x *JSONWebKey) GetX() string {
if x != nil {
return x.X
}
return ""
}
func (x *JSONWebKey) GetY() string {
if x != nil {
return x.Y
}
return ""
}
func (x *JSONWebKey) GetN() string {
if x != nil {
return x.N
}
return ""
}
func (x *JSONWebKey) GetE() string {
if x != nil {
return x.E
}
return ""
}
type RawKey struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Algorithm string `protobuf:"bytes,1,opt,name=algorithm,proto3" json:"algorithm,omitempty"`
Encoding string `protobuf:"bytes,2,opt,name=encoding,proto3" json:"encoding,omitempty"`
Curve string `protobuf:"bytes,3,opt,name=curve,proto3" json:"curve,omitempty"`
Key []byte `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"`
}
func (x *RawKey) Reset() {
*x = RawKey{}
if protoimpl.UnsafeEnabled {
mi := &file_common_v1_keys_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RawKey) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RawKey) ProtoMessage() {}
func (x *RawKey) ProtoReflect() protoreflect.Message {
mi := &file_common_v1_keys_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RawKey.ProtoReflect.Descriptor instead.
func (*RawKey) Descriptor() ([]byte, []int) {
return file_common_v1_keys_proto_rawDescGZIP(), []int{2}
}
func (x *RawKey) GetAlgorithm() string {
if x != nil {
return x.Algorithm
}
return ""
}
func (x *RawKey) GetEncoding() string {
if x != nil {
return x.Encoding
}
return ""
}
func (x *RawKey) GetCurve() string {
if x != nil {
return x.Curve
}
return ""
}
func (x *RawKey) GetKey() []byte {
if x != nil {
return x.Key
}
return nil
}
var File_common_v1_keys_proto protoreflect.FileDescriptor
var file_common_v1_keys_proto_rawDesc = []byte{
0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x6b, 0x65, 0x79, 0x73,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76,
0x31, 0x22, 0x8c, 0x01, 0x0a, 0x06, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04,
0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65,
0x12, 0x19, 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x72,
0x61, 0x77, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63,
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x61, 0x77, 0x4b, 0x65, 0x79, 0x52,
0x06, 0x72, 0x61, 0x77, 0x4b, 0x65, 0x79, 0x12, 0x27, 0x0a, 0x03, 0x6a, 0x77, 0x6b, 0x18, 0x04,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31,
0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x57, 0x65, 0x62, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6a, 0x77, 0x6b,
0x22, 0x68, 0x0a, 0x0a, 0x4a, 0x53, 0x4f, 0x4e, 0x57, 0x65, 0x62, 0x4b, 0x65, 0x79, 0x12, 0x10,
0x0a, 0x03, 0x6b, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x74, 0x79,
0x12, 0x10, 0x0a, 0x03, 0x63, 0x72, 0x76, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63,
0x72, 0x76, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x78,
0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x79, 0x12, 0x0c,
0x0a, 0x01, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x6e, 0x12, 0x0c, 0x0a, 0x01,
0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x65, 0x22, 0x6a, 0x0a, 0x06, 0x52, 0x61,
0x77, 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68,
0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74,
0x68, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x14,
0x0a, 0x05, 0x63, 0x75, 0x72, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63,
0x75, 0x72, 0x76, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28,
0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72,
0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x74, 0x79, 0x70, 0x65,
0x73, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
file_common_v1_keys_proto_rawDescOnce sync.Once
file_common_v1_keys_proto_rawDescData = file_common_v1_keys_proto_rawDesc
)
func file_common_v1_keys_proto_rawDescGZIP() []byte {
file_common_v1_keys_proto_rawDescOnce.Do(func() {
file_common_v1_keys_proto_rawDescData = protoimpl.X.CompressGZIP(file_common_v1_keys_proto_rawDescData)
})
return file_common_v1_keys_proto_rawDescData
}
var file_common_v1_keys_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_common_v1_keys_proto_goTypes = []interface{}{
(*PubKey)(nil), // 0: common.v1.PubKey
(*JSONWebKey)(nil), // 1: common.v1.JSONWebKey
(*RawKey)(nil), // 2: common.v1.RawKey
}
var file_common_v1_keys_proto_depIdxs = []int32{
2, // 0: common.v1.PubKey.raw_key:type_name -> common.v1.RawKey
1, // 1: common.v1.PubKey.jwk:type_name -> common.v1.JSONWebKey
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_common_v1_keys_proto_init() }
func file_common_v1_keys_proto_init() {
if File_common_v1_keys_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_common_v1_keys_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PubKey); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_common_v1_keys_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*JSONWebKey); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_common_v1_keys_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RawKey); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_common_v1_keys_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_common_v1_keys_proto_goTypes,
DependencyIndexes: file_common_v1_keys_proto_depIdxs,
MessageInfos: file_common_v1_keys_proto_msgTypes,
}.Build()
File_common_v1_keys_proto = out.File
file_common_v1_keys_proto_rawDesc = nil
file_common_v1_keys_proto_goTypes = nil
file_common_v1_keys_proto_depIdxs = nil
}
+215
View File
@@ -0,0 +1,215 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc (unknown)
// source: common/v1/uri.proto
package commonv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type URI_URIProtocol int32
const (
URI_HTTPS URI_URIProtocol = 0
URI_IPFS URI_URIProtocol = 1
URI_IPNS URI_URIProtocol = 2
URI_DID URI_URIProtocol = 3
)
// Enum value maps for URI_URIProtocol.
var (
URI_URIProtocol_name = map[int32]string{
0: "HTTPS",
1: "IPFS",
2: "IPNS",
3: "DID",
}
URI_URIProtocol_value = map[string]int32{
"HTTPS": 0,
"IPFS": 1,
"IPNS": 2,
"DID": 3,
}
)
func (x URI_URIProtocol) Enum() *URI_URIProtocol {
p := new(URI_URIProtocol)
*p = x
return p
}
func (x URI_URIProtocol) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (URI_URIProtocol) Descriptor() protoreflect.EnumDescriptor {
return file_common_v1_uri_proto_enumTypes[0].Descriptor()
}
func (URI_URIProtocol) Type() protoreflect.EnumType {
return &file_common_v1_uri_proto_enumTypes[0]
}
func (x URI_URIProtocol) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use URI_URIProtocol.Descriptor instead.
func (URI_URIProtocol) EnumDescriptor() ([]byte, []int) {
return file_common_v1_uri_proto_rawDescGZIP(), []int{0, 0}
}
type URI struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Protocol URI_URIProtocol `protobuf:"varint,1,opt,name=protocol,proto3,enum=common.v1.URI_URIProtocol" json:"protocol,omitempty"`
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}
func (x *URI) Reset() {
*x = URI{}
if protoimpl.UnsafeEnabled {
mi := &file_common_v1_uri_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *URI) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*URI) ProtoMessage() {}
func (x *URI) ProtoReflect() protoreflect.Message {
mi := &file_common_v1_uri_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use URI.ProtoReflect.Descriptor instead.
func (*URI) Descriptor() ([]byte, []int) {
return file_common_v1_uri_proto_rawDescGZIP(), []int{0}
}
func (x *URI) GetProtocol() URI_URIProtocol {
if x != nil {
return x.Protocol
}
return URI_HTTPS
}
func (x *URI) GetValue() string {
if x != nil {
return x.Value
}
return ""
}
var File_common_v1_uri_proto protoreflect.FileDescriptor
var file_common_v1_uri_proto_rawDesc = []byte{
0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x72, 0x69, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31,
0x22, 0x8a, 0x01, 0x0a, 0x03, 0x55, 0x52, 0x49, 0x12, 0x36, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x52, 0x49, 0x2e, 0x55, 0x52, 0x49, 0x50, 0x72,
0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c,
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x35, 0x0a, 0x0b, 0x55, 0x52, 0x49, 0x50, 0x72, 0x6f,
0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x09, 0x0a, 0x05, 0x48, 0x54, 0x54, 0x50, 0x53, 0x10, 0x00,
0x12, 0x08, 0x0a, 0x04, 0x49, 0x50, 0x46, 0x53, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x50,
0x4e, 0x53, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x49, 0x44, 0x10, 0x03, 0x42, 0x32, 0x5a,
0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f,
0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x76,
0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_common_v1_uri_proto_rawDescOnce sync.Once
file_common_v1_uri_proto_rawDescData = file_common_v1_uri_proto_rawDesc
)
func file_common_v1_uri_proto_rawDescGZIP() []byte {
file_common_v1_uri_proto_rawDescOnce.Do(func() {
file_common_v1_uri_proto_rawDescData = protoimpl.X.CompressGZIP(file_common_v1_uri_proto_rawDescData)
})
return file_common_v1_uri_proto_rawDescData
}
var file_common_v1_uri_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_common_v1_uri_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_common_v1_uri_proto_goTypes = []interface{}{
(URI_URIProtocol)(0), // 0: common.v1.URI.URIProtocol
(*URI)(nil), // 1: common.v1.URI
}
var file_common_v1_uri_proto_depIdxs = []int32{
0, // 0: common.v1.URI.protocol:type_name -> common.v1.URI.URIProtocol
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_common_v1_uri_proto_init() }
func file_common_v1_uri_proto_init() {
if File_common_v1_uri_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_common_v1_uri_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*URI); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_common_v1_uri_proto_rawDesc,
NumEnums: 1,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_common_v1_uri_proto_goTypes,
DependencyIndexes: file_common_v1_uri_proto_depIdxs,
EnumInfos: file_common_v1_uri_proto_enumTypes,
MessageInfos: file_common_v1_uri_proto_msgTypes,
}.Build()
File_common_v1_uri_proto = out.File
file_common_v1_uri_proto_rawDesc = nil
file_common_v1_uri_proto_goTypes = nil
file_common_v1_uri_proto_depIdxs = nil
}