dediregistry

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 9 Imported by: 0

README

DeDi Registry Plugin

A Beckn-ONIX registry type plugin for integrating with DeDi registry services. Implements the RegistryLookup interface to provide participant information and public keys.

Overview

The DeDi Registry plugin enables Beckn-ONIX to lookup DeDi registries for participant records, converting DeDi API responses to standard Beckn Subscription format for seamless integration with existing registry infrastructure.

Features

  • RegistryLookup Interface: Implements standard Beckn registry interface
  • DeDi API Integration: GET requests to DeDi registry endpoints with Bearer authentication
  • Data Conversion: Converts DeDi responses to Beckn Subscription format
  • HTTP Retry Logic: Built-in retry mechanism using retryablehttp client
  • Timeout Control: Configurable request timeouts

Configuration

plugins:
  dediRegistry:
    id: dediregistry
    config:
      baseURL: "https://dedi-registry.example.com"
      apiKey: "your-api-key"
      namespaceID: "beckn-network"
      registryName: "participants"
      recordName: "participant-id"
      timeout: "30"  # seconds
Configuration Parameters
Parameter Required Description Default
baseURL Yes DeDi registry API base URL -
apiKey Yes API key for authentication -
namespaceID Yes DeDi namespace identifier -
registryName Yes Registry name to query -
recordName Yes Record name/identifier -
timeout No Request timeout in seconds 30

Usage

In Module Configuration
modules:
  - name: bapTxnReceiver
    handler:
      plugins:
        dediRegistry:
          id: dediregistry
          config:
            baseURL: "https://dedi-registry.example.com"
            apiKey: "your-api-key"
            namespaceID: "beckn-network"
            registryName: "participants"
            recordName: "participant-id"
In Code
// Load DeDi registry plugin
dediRegistry, err := manager.Registry(ctx, &plugin.Config{
    ID: "dediregistry",
    Config: map[string]string{
        "baseURL": "https://dedi-registry.example.com",
        "apiKey": "your-api-key",
        "namespaceID": "beckn-network",
        "registryName": "participants",
        "recordName": "participant-id",
    },
})

// Or use specific method
dediRegistry, err := manager.DeDiRegistry(ctx, config)

// Lookup participant (returns Beckn Subscription format)
subscription := &model.Subscription{}
results, err := dediRegistry.Lookup(ctx, subscription)
if err != nil {
    return err
}

// Extract public key from first result
if len(results) > 0 {
    publicKey := results[0].SigningPublicKey
    subscriberID := results[0].SubscriberID
}

API Response Structure

The plugin expects DeDi registry responses in this format:

{
  "message": "success",
  "data": {
    "namespace": "beckn",
    "schema": {
      "entity_name": "participant.example.com",
      "entity_url": "https://participant.example.com",
      "publicKey": "base64-encoded-public-key",
      "keyType": "ed25519",
      "keyFormat": "base64"
    },
    "state": "active",
    "created_at": "2023-01-01T00:00:00Z",
    "updated_at": "2023-01-01T00:00:00Z"
  }
}
Converted to Beckn Format

The plugin converts this to standard Beckn Subscription format:

{
  "subscriber_id": "participant.example.com",
  "url": "https://participant.example.com",
  "signing_public_key": "base64-encoded-public-key",
  "status": "active",
  "created": "2023-01-01T00:00:00Z",
  "updated": "2023-01-01T00:00:00Z"
}

Testing

Run plugin tests:

go test ./pkg/plugin/implementation/dediregistry -v

Dependencies

  • github.com/hashicorp/go-retryablehttp: HTTP client with retry logic
  • Standard Go libraries for HTTP and JSON handling

Integration Notes

  • Registry Type Plugin: Implements RegistryLookup interface, not a separate plugin category
  • Interchangeable: Can be used alongside or instead of standard registry plugin
  • Manager Integration: Available via manager.Registry() or manager.DeDiRegistry() methods
  • Data Conversion: Automatically converts DeDi format to Beckn Subscription format
  • Interface Compliance: Implements RegistryLookup interface with Lookup() method only
  • Build Integration: Included in build-plugins.sh script, compiles to dediregistry.so

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BaseURL      string `yaml:"baseURL" json:"baseURL"`
	ApiKey       string `yaml:"apiKey" json:"apiKey"`
	NamespaceID  string `yaml:"namespaceID" json:"namespaceID"`
	RegistryName string `yaml:"registryName" json:"registryName"`
	RecordName   string `yaml:"recordName" json:"recordName"`
	Timeout      int    `yaml:"timeout" json:"timeout"`
}

Config holds configuration parameters for the DeDi registry client.

type DeDiRegistryClient

type DeDiRegistryClient struct {
	// contains filtered or unexported fields
}

DeDiRegistryClient encapsulates the logic for calling the DeDi registry endpoints.

func New

func New(ctx context.Context, cfg *Config) (*DeDiRegistryClient, func() error, error)

New creates a new instance of DeDiRegistryClient.

func (*DeDiRegistryClient) Lookup

Lookup implements RegistryLookup interface - calls the DeDi lookup endpoint and returns Subscription.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL