Documentation
¶
Index ¶
- type Cache
- type CacheProvider
- type Decrypter
- type DecrypterProvider
- type Encrypter
- type EncrypterProvider
- type KeyManager
- type KeyManagerProvider
- type ManifestLoader
- type ManifestLoaderProvider
- type MiddlewareProvider
- type OtelSetupMetricsProvider
- type PayloadEntry
- type PayloadStore
- type PayloadStoreProvider
- type PolicyChecker
- type PolicyCheckerProvider
- type Publisher
- type PublisherProvider
- type RegistryLookup
- type RegistryLookupProvider
- type RegistryMetadataLookup
- type ResponseStep
- type Router
- type RouterProvider
- type SchemaValidator
- type SchemaValidatorProvider
- type SignValidator
- type SignValidatorProvider
- type Signer
- type SignerProvider
- type Step
- type StepProvider
- type TransportWrapper
- type TransportWrapperProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Get retrieves a value from the cache based on the given key.
Get(ctx context.Context, key string) (string, error)
// Set stores a value in the cache with the given key and TTL (time-to-live) in seconds.
Set(ctx context.Context, key, value string, ttl time.Duration) error
// Delete removes a value from the cache based on the given key.
Delete(ctx context.Context, key string) error
// Clear removes all values from the cache.
Clear(ctx context.Context) error
}
Cache defines the general cache interface for caching plugins.
type CacheProvider ¶
type CacheProvider interface {
// New initializes a new cache instance with the given configuration.
New(ctx context.Context, config map[string]string) (Cache, func() error, error)
}
CacheProvider interface defines the contract for managing cache instances.
type Decrypter ¶
type Decrypter interface {
// Decrypt decrypts the given body using the provided privateKeyBase64 and publicKeyBase64.
Decrypt(ctx context.Context, encryptedData string, privateKeyBase64, publicKeyBase64 string) (string, error)
}
Decrypter defines the methods for decryption.
type DecrypterProvider ¶
type DecrypterProvider interface {
// New creates a new decrypter instance based on the provided config.
New(ctx context.Context, config map[string]string) (Decrypter, func() error, error)
}
DecrypterProvider initializes a new decrypter instance with the given config.
type Encrypter ¶
type Encrypter interface {
// Encrypt encrypts the given body using the provided privateKeyBase64 and publicKeyBase64.
Encrypt(ctx context.Context, data string, privateKeyBase64, publicKeyBase64 string) (string, error)
}
Encrypter defines the methods for encryption.
type EncrypterProvider ¶
type EncrypterProvider interface {
// New creates a new encrypter instance based on the provided config.
New(ctx context.Context, config map[string]string) (Encrypter, func() error, error)
}
EncrypterProvider initializes a new encrypter instance with the given config.
type KeyManager ¶
type KeyManager interface {
GenerateKeyset() (*model.Keyset, error)
InsertKeyset(ctx context.Context, keyID string, keyset *model.Keyset) error
Keyset(ctx context.Context, keyID string) (*model.Keyset, error)
LookupNPKeys(ctx context.Context, subscriberID, uniqueKeyID string) (signingPublicKey string, encrPublicKey string, err error)
DeleteKeyset(ctx context.Context, keyID string) error
}
KeyManager defines the interface for key management operations/methods.
type KeyManagerProvider ¶
type KeyManagerProvider interface {
New(context.Context, RegistryLookup, map[string]string) (KeyManager, func() error, error)
}
KeyManagerProvider initializes a new signer instance.
type ManifestLoader ¶ added in v1.6.0
type ManifestLoader interface {
GetByNetworkID(ctx context.Context, networkID string) (*model.ManifestDocument, error)
GetByMetadata(ctx context.Context, metadata model.ManifestMetadata) (*model.ManifestDocument, error)
}
ManifestLoader fetches, verifies, caches, and returns manifest content.
type ManifestLoaderProvider ¶ added in v1.6.0
type ManifestLoaderProvider interface {
New(context.Context, Cache, RegistryMetadataLookup, map[string]string) (ManifestLoader, func() error, error)
}
ManifestLoaderProvider initializes a manifest loader instance with its dependencies.
type MiddlewareProvider ¶
type OtelSetupMetricsProvider ¶ added in v1.3.0
type OtelSetupMetricsProvider interface {
// New initializes a new telemetry provider instance with the given configuration.
New(ctx context.Context, config map[string]string) (*telemetry.Provider, func() error, error)
}
OtelSetupMetricsProvider encapsulates initialization of OpenTelemetry metrics providers. Implementations wire exporters and return a Provider that the core application can manage.
type PayloadEntry ¶ added in v1.7.0
type PayloadEntry struct {
MessageID string
TransactionID string
NetworkID string
Action string
SubscriberID string
Role model.Role
RequestBody []byte // nil when StoreBody: false
Signature string // raw Authorization header; empty when StoreSignature: false
StoredAt time.Time
ExpiresAt time.Time
}
PayloadEntry is a single stored record for one BECKN message.
type PayloadStore ¶ added in v1.7.0
type PayloadStore interface {
// Store persists an entry built from the incoming request's StepContext.
Store(ctx *model.StepContext) error
// GetByTransactionID returns all entries for a transaction in StoredAt ascending order.
// Returns nil (not an error) if the transaction is unknown or expired.
GetByTransactionID(ctx context.Context, transactionID string) ([]PayloadEntry, error)
// GetByMessageID returns the entry for the given message ID scoped to an action.
// Returns nil (not an error) if not found or if the action does not match.
GetByMessageID(ctx context.Context, messageID, action string) (*PayloadEntry, error)
// Exists is an O(1) check for dedup / replay protection.
Exists(ctx context.Context, messageID string) (bool, error)
}
PayloadStore persists and retrieves payload entries indexed by message and transaction IDs.
type PayloadStoreProvider ¶ added in v1.7.0
type PayloadStoreProvider interface {
New(ctx context.Context, cache Cache, namespace string, cfg map[string]string) (PayloadStore, func() error, error)
}
PayloadStoreProvider is the plugin constructor interface.
type PolicyChecker ¶ added in v1.5.0
type PolicyChecker interface {
CheckPolicy(ctx *model.StepContext) error
}
PolicyChecker interface for policy checking on incoming messages.
type PolicyCheckerProvider ¶ added in v1.5.0
type PolicyCheckerProvider interface {
New(ctx context.Context, manifestLoader ManifestLoader, config map[string]string) (PolicyChecker, func(), error)
}
PolicyCheckerProvider interface for creating policy checkers.
type Publisher ¶
type Publisher interface {
// Publish sends a message (as a byte slice) using the underlying messaging system.
Publish(context.Context, string, []byte) error
}
Publisher defines the general publisher interface for messaging plugins.
type PublisherProvider ¶
type PublisherProvider interface {
// New initializes a new publisher instance with the given configuration.
New(ctx context.Context, config map[string]string) (Publisher, func() error, error)
}
PublisherProvider is the interface for creating new Publisher instances.
type RegistryLookup ¶
type RegistryLookup interface {
// looks up Registry entry to obtain public keys to validate signature of the incoming message
Lookup(ctx context.Context, req *model.Subscription) ([]model.Subscription, error)
}
type RegistryLookupProvider ¶
type RegistryLookupProvider interface {
New(context.Context, Cache, map[string]string) (RegistryLookup, func() error, error)
}
RegistryLookupProvider initializes a new registry lookup instance.
type RegistryMetadataLookup ¶ added in v1.6.0
type RegistryMetadataLookup interface {
LookupRegistry(ctx context.Context, namespaceIdentifier, registryName string) (*model.RegistryMetadata, error)
}
RegistryMetadataLookup fetches registry-level metadata without addressing a specific record.
type ResponseStep ¶ added in v1.7.0
type ResponseStep interface {
RunOnResponse(ctx *model.StepContext, rctx *model.ResponseStepContext) error
}
ResponseStep is executed after all inbound Steps succeed, before the synchronous ACK is written back to the caller.
rctx is nil on the publisher path (ONIX writes the ACK itself); on the URL-routing path rctx carries the pre-read upstream response body, headers, and status code. Header is a shared reference — mutations (e.g. writing a Signature header) are forwarded by ReverseProxy without explicit write-back.
type Router ¶
type Router interface {
// Route determines the routing destination based on the request context.
Route(ctx context.Context, url *url.URL, body []byte) (*model.Route, error)
}
Router defines the interface for routing requests.
type RouterProvider ¶
type RouterProvider interface {
New(ctx context.Context, config map[string]string) (Router, func() error, error)
}
RouterProvider initializes the a new Router instance with the given config.
type SchemaValidator ¶
type SchemaValidator interface {
Validate(ctx context.Context, url *url.URL, payload []byte) error
}
SchemaValidator interface for schema validation.
type SchemaValidatorProvider ¶
type SchemaValidatorProvider interface {
New(ctx context.Context, config map[string]string) (SchemaValidator, func() error, error)
}
SchemaValidatorProvider interface for creating validators.
type SignValidator ¶
type SignValidator interface {
// Validate verifies the 3-line signing string for inbound requests.
// The request body is available as ctx.Body.
// checkIdentity controls whether the signer's subscriber ID (from keyId) is
// matched against the caller identity declared in the request body context.
// Pass true for subscriber Authorization headers, false for gateway headers.
Validate(ctx *model.StepContext, header string, publicKeyBase64 string, checkIdentity bool) error
// ValidateAck verifies a Beckn v2.0.0 AckSignature per NFH-004 §3.4.
// The four-line signing string is:
// (created): <ts>
// (expires): <ts>
// digest: BLAKE-512=<base64(blake2b512(body))>
// request-signature: <outboundAuthSignature>
// outboundAuthSignature is the raw Base64 signature value from the original
// outbound Authorization header's signature="..." attribute. If empty the
// fourth line is omitted (matches the ackSigner signing-string construction).
// body is passed explicitly because different call sites hash different bodies:
// solicited callback bodies differ from synchronous ACK response bodies.
// checkIdentity: true for solicited callbacks (step.go), false for ACK responses (responsestep.go).
ValidateAck(ctx *model.StepContext, body []byte, signatureHeader, outboundAuthSignature, publicKeyBase64 string, checkIdentity bool) error
}
SignValidator defines the method for verifying signatures.
type SignValidatorProvider ¶
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)
}
SignValidatorProvider initializes a new Verifier instance with the given config.
type Signer ¶
type Signer interface {
// Sign generates a signature for the given body and privateKeyBase64.
// 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)
// SignAck generates a signature for a synchronous Ack response using the
// NFH-004 §3.4 four-line signing string:
// (created): <ts>
// (expires): <ts>
// digest: BLAKE-512=<base64(blake2b512(ackBody))>
// request-signature: <requestSignature>
// requestSignature is the raw Base64 value from the inbound Authorization
// header's signature="..." attribute. If empty the fourth line is omitted.
SignAck(ctx context.Context, ackBody []byte, requestSignature, privateKeyBase64 string, createdAt, expiresAt int64) (string, error)
}
Signer defines the method for signing.
type SignerProvider ¶
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)
}
SignerProvider initializes a new signer instance with the given config.
type Step ¶
type Step interface {
Run(ctx *model.StepContext) error
}
Step is executed on the inbound request as part of the processing pipeline.
type StepProvider ¶
type TransportWrapper ¶ added in v1.3.0
type TransportWrapper interface {
// Wrap takes a base transport and returns a new transport that wraps it.
Wrap(base http.RoundTripper) http.RoundTripper
}
TransportWrapper is a plugin that wraps an http.RoundTripper, allowing modification of outbound requests (like adding auth).
type TransportWrapperProvider ¶ added in v1.3.0
type TransportWrapperProvider interface {
New(ctx context.Context, config map[string]any) (TransportWrapper, func(), error)
}
TransportWrapperProvider defines the factory for a TransportWrapper.