GithubHelp home page GithubHelp logo

hederaconsensusservice's Introduction

ent-key-mgr

Description

The server directory houses a Nest.js server constructed to operate using the gRPC (Google Remote Procedure Call) transport protocol. Within this server, there are two applications: api-gateway and keymanager.

The api-gateway application functions as the entry point for all incoming HTTP traffic within our application ecosystem. Its primary role is to act as a reverse proxy, forwarding these incoming HTTP requests to the keymanager microservice utilizing the gRPC transport protocol.

The keymanager microservice is responsible for managing cryptographic keys within our application. It serves as the host for the key management application, handling operations related to key generation, storage, retrieval, and any other cryptographic functions required by our application.

In addition to the applications, there is a common library present in the server directory. This library houses shared or common assets and functionality utilized by both api-gateway and keymanager. Among the assets in the common library is the keymanager.ts file, which is generated from the protobuf (protocol buffer) definition file. Protocol buffers are a language-agnostic data serialization format used for efficiently encoding and decoding structured data, making it an excellent choice for inter-service communication in microservices architectures.

Installation

$ pnpm install

Running the app

$ cd server
# watch mode
$ pnpm run start:dev api-gateway
# open another terminal
$ pnpm run start:dev keymanager

# After running two servers, you can test the APIs using the following methods.

Using curl

graph TD
    subgraph "api-gateway"
        A[HTTP Request] -->|gRPC Request| B[keys.controller.ts]
        B[keys.controller.ts] -->|gRPC Request| C[keys.service.ts]
        C[keys.service.ts] -->|gRPC Request| D["KeyManager Service"]
        D["KeyManager Service"] -->|gRPC Response| C[keys.service.ts]
        C[keys.service.ts] -->|gRPC Response| B[keys.controller.ts]
        B[keys.controller.ts] -->|HTTP Response| A[HTTP Client]
    end

    subgraph "keymanager"
        E["KeyManager Service"] -->|gRPC Request| F[keys.controller.ts]
        F[keys.controller.ts] -->|gRPC Request| G[keys.service.ts]
        G[keys.service.ts] -->|gRPC Response| F[keys.controller.ts]
        F[keys.controller.ts] -->|gRPC Response| E["KeyManager Service"]
    end

To test the APIs implemented in the Nest.js application using curl, follow these steps. Ensure that api-gateway application is running at the appropriate address and port (e.g., http://localhost:3000).

1. Create a Key

Use curl to create a new key with the Create Key endpoint:

curl -X POST http://localhost:3000/keys -H "Content-Type: application/json" -d '{
  "keyName": "myKey",
  "keyAlgo": 2
}'

Expected Result: If successful, you should receive a JSON response indicating success. An error message will be returned if the key name already exists or if the key algorithm is unsupported.

2. Delete a Key

Use curl to delete a key with the Delete Key endpoint:

curl -X DELETE http://localhost:3000/keys/myKey

Expected Result: If successful, you should receive a JSON response indicating success. An error message will be returned if the key name is not found.

3. Get the Secret (Private Key) for a Key

curl http://localhost:3000/keys/myKey/secret

Expected Result: If successful, you should receive a JSON response containing the private key for the specified key name. An error message will be returned if the key name is not found.

3. List the keys

curl http://localhost:3000/keys

Expected Result: You should receive a JSON response containing an array of key names currently stored in memory.

License

Nest is MIT licensed.

hederaconsensusservice's People

Contributors

alapanmondal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.