Socket
Book a DemoInstallSign in
Socket

@bajerm/cactus-verifier-client

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bajerm/cactus-verifier-client

Verifier cactus client library to communicate with validators through socket.io

latest
Source
npmnpm
Version
1.1.3-u1
Version published
Maintainers
1
Created
Source

@hyperledger/cactus-verifier-client

Summary

This package provides Verifier and VerifierFactory components that can be used to communicate with compatible Cactus ledger connectors (validators) through single, unified interface.

Supported ledger connectors

validatorTypecactus ledger connector plugin
BESU_1X
BESU_2X
cactus-plugin-ledger-connector-besu
QUORUM_2Xcactus-test-plugin-ledger-connector-quorum
CORDA_4Xcactus-plugin-ledger-connector-corda
IROHA_1Xcactus-plugin-ledger-connector-iroha
legacy-socketiocactus-plugin-ledger-connector-fabric-socketio
cactus-plugin-ledger-connector-go-ethereum-socketio
cactus-plugin-ledger-connector-sawtooth-socketio

VerifierFactory

  • Used to create single verifier per ledger based on pre-defined configuration.
  • See verifier-factory.test.ts for unit tests.

Usage

import {
  VerifierFactory,
  VerifierFactoryConfig,
} from "@hyperledger/cactus-verifier-client";

// Create VerifierFactory configuration that should describe all validators we want to connect to.
// This can be read from a file or typed manually, the config is a superset of cactus-cmd-socketio-server ledger plugin config.
const ledgerPluginInfo: VerifierFactoryConfig = [
    {
        validatorID: "some_legacy_connector",    // required
        validatorType: "legacy-socketio",        // required - see table above for supported validator types
        validatorURL: "https://localhost:9999",  // legacy-socketio specific config
        validatorKeyPath: "./keysUr7d10R.crt",   // legacy-socketio specific config
        ledgerInfo: {                            // optional
            ledgerAbstract: "My legacy Ledger",
        },
        apiInfo: [],                             // optional
    },
    {
        validatorID: "besu_openapi_connector", // required
        validatorType: "BESU_2X",              // required - see table above for supported validator types
        basePath: "https://localhost:9999",    // besu specific config
    },
];

// Instantiate single VerifierFactory from given config in your Bussiness Logic Plugin.
const verifierFactory = new VerifierFactory(ledgerPluginInfo);

// Get ApiClient to validator with ID "myBesuValidatorId"
// Second argument will determine type of returned Verifier (BesuApiClient in this case)
const myBesu: Verifier<BesuApiClient> = sut.getVerifier("myBesuValidatorId", "BESU_1X"))

// Second argument can be ignored for backward-compatibility
// It will return Verifier<(union of all supported ApiClients)>
const client: Verifier<any> = sut.getVerifier(validatorId);

Verifier

Construction

// Use VerifierFactory to get an instance of ledger connector Verifier
const myBesu: Verifier<BesuApiClient> = sut.getVerifier("myBesuValidatorId", "BESU_1X"))

// Or create it manually from ledger ApiClient
const besuApiClientOptions = new BesuApiClientOptions({
    basePath: "https://localhost:9999",
});
const apiClient = new BesuApiClient(besuApiClientOptions);
const myBesu: Verifier<BesuApiClient> = new Verifier("besu_openapi_connector", apiClient, "info");

Interface

export interface IVerifier {
  // Immediately sends request to the validator, doesn't report any error or responses.
  sendAsyncRequest(
    contract: Record<string, unknown>,
    method: Record<string, unknown>,
    args: Record<string, unknown>,
  ): Promise<void>;

  // Sends request to be executed on the ledger, watches and reports any error and the response from a ledger.
  sendSyncRequest(
    contract: Record<string, unknown>,
    method: Record<string, unknown>,
    args: Record<string, unknown>,
  ): Promise<any>;

  // Start monitoring for new events / blocks from underlying ledger.
  startMonitor(
    id: string,
    options: Record<string, unknown>,
    eventListener: IVerifierEventListener,
  ): void;

  // Stops the monitor for specified app, removes it's subscription from internal storage.
  stopMonitor(id?: string): void;
}

Keywords

Hyperledger

FAQs

Package last updated on 26 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts