updated as per the review comments

This commit is contained in:
MohitKatare-protean
2025-03-30 19:13:02 +05:30
parent 244a7be7c1
commit f0e39e34e7
35 changed files with 1605 additions and 124 deletions

View File

@@ -6,18 +6,10 @@ import (
"github.com/beckn/beckn-onix/pkg/model"
)
type Keyset struct {
UniqueKeyID string
SigningPrivate string
SigningPublic string
EncrPrivate string
EncrPublic string
}
// KeyManager defines the interface for key management operations/methods.
type KeyManager interface {
GenerateKeyPairs() (*Keyset, error)
StorePrivateKeys(ctx context.Context, keyID string, keys *Keyset) error
GenerateKeyPairs() (*model.Keyset, error)
StorePrivateKeys(ctx context.Context, keyID string, keys *model.Keyset) error
SigningPrivateKey(ctx context.Context, keyID string) (string, string, error)
EncrPrivateKey(ctx context.Context, keyID string) (string, string, error)
SigningPublicKey(ctx context.Context, subscriberID, uniqueKeyID string) (string, error)
@@ -29,7 +21,3 @@ type KeyManager interface {
type KeyManagerProvider interface {
New(context.Context, Cache, RegistryLookup, map[string]string) (KeyManager, func() error, error)
}
type RegistryLookup interface {
Lookup(ctx context.Context, req *model.Subscription) ([]model.Subscription, error)
}

View File

@@ -5,12 +5,10 @@ import "context"
// Publisher defines the general publisher interface for messaging plugins.
type Publisher interface {
// Publish sends a message (as a byte slice) using the underlying messaging system.
Publish(ctx context.Context, msg []byte) error
Close() error // Important for releasing resources.
Publish(context.Context, string, []byte) error
}
type PublisherProvider interface {
// New initializes a new publisher instance with the given configuration.
New(ctx context.Context, config map[string]string) (Publisher, error)
New(ctx context.Context, config map[string]string) (Publisher, func(), error)
}

View File

@@ -0,0 +1,11 @@
package definition
import (
"context"
"github.com/beckn/beckn-onix/pkg/model"
)
type RegistryLookup interface {
Lookup(ctx context.Context, req *model.Subscription) ([]model.Subscription, error)
}

View File

@@ -3,14 +3,9 @@ package definition
import (
"context"
"net/url"
)
// Route defines the structure for the Route returned.
type Route struct {
TargetType string // "url" or "msgq" or "bap" or "bpp"
PublisherID string // For message queues
URL *url.URL // For API calls
}
"github.com/beckn/beckn-onix/pkg/model"
)
// RouterProvider initializes the a new Router instance with the given config.
type RouterProvider interface {
@@ -20,5 +15,5 @@ type RouterProvider interface {
// Router defines the interface for routing requests.
type Router interface {
// Route determines the routing destination based on the request context.
Route(ctx context.Context, url *url.URL, body []byte) (*Route, error)
Route(ctx context.Context, url *url.URL, body []byte) (*model.Route, error)
}

View File

@@ -8,7 +8,6 @@ type Signer interface {
// The signature is created with the given timestamps: createdAt (signature creation time)
// and expiresAt (signature expiration time).
Sign(ctx context.Context, body []byte, privateKeyBase64 string, createdAt, expiresAt int64) (string, error)
Close() error // Close for releasing resources
}
// SignerProvider initializes a new signer instance with the given config.
@@ -16,9 +15,3 @@ type SignerProvider interface {
// New creates a new signer instance based on the provided config.
New(ctx context.Context, config map[string]string) (Signer, func() error, error)
}
// PrivateKeyManager is the interface for key management plugin.
type PrivateKeyManager interface {
// PrivateKey retrieves the private key for the given subscriberID and keyID.
PrivateKey(ctx context.Context, subscriberID string, keyID string) (string, error)
}

View File

@@ -0,0 +1,15 @@
package definition
import "context"
// SignValidator defines the method for verifying signatures.
type SignValidator interface {
// Validate checks the validity of the signature for the given body.
Validate(ctx context.Context, body []byte, header string, publicKeyBase64 string) error
}
// SignValidatorProvider initializes a new Verifier instance with the given config.
type SignValidatorProvider interface {
// New creates a new Verifier instance based on the provided config.
New(ctx context.Context, config map[string]string) (SignValidator, func() error, error)
}