Welcome to the KrediConnect project. This repository contains a server application for interacting with the Web5 platform to issue, configure, and manage customer credentials on a Decentralized Web Node (DWN). It also allows secure communication and verification of customer credentials.
- Overview
- Getting Started
- Key Files and Modules
- API Endpoints
- Usage Instructions
- Error Handling
- Contributing
KrediConnect is a Web5 server designed to issue Known Customer Credentials (KCCs), a form of Verifiable Credential that simplifies the Know Your Customer (KYC) process for users of the tbDEX protocol. These KCCs enable users to access regulated financial services offered by Participating Financial Institutions (PFIs), with secure data transfer and verification handled through customer DWNs (Decentralized Web Nodes).
- Node.js (version 18+)
- NPM or Yarn
- Web5 and Google cloud Free DWN configurations
-
Clone the repository:
git clone https://github.com/yourusername/kredi-connect.git cd kredi-connect
-
Install dependencies:
npm install
-
Run the server:
npm run start
The server will start at http://localhost:3000
.
- Core logic for connecting and registering with Web5, configuring protocols, generating credentials, and communicating with DWN.
- Functions:
connectToWeb5
: Establishes a connection with Web5, registers the DID, and retrieves bearer details.configureProtocol
: Sets up the required protocol configuration on DWN.generateCredential
: Creates a verifiable credential in JSON Web Token (JWT) format.sendToCustomerDWN
: Sends the verifiable credential to a customer’s DWN.readRecord
: Reads and retrieves records stored in DWN.
- Express-based server configuration with endpoints to interact with the Web5 and DWN systems.
- Routes:
POST /credentials
: Issues a verifiable credential to a customer.GET /records
: Fetches all records from DWN.GET /records/:recordId
: Retrieves a specific record by ID.
protocol.js
: Defines the DWN protocol settings.authorizationToDWN.js
: Manages authorization logic for DWN.loading.js
: Manages loading states for asynchronous processes.did.js
: Provides DID configurations for various entities.
Generates a verifiable credential for a customer based on the request payload.
- Response: Returns the signed credential in JWT format.
- Error: 500 on failure with an error message.
Fetches all available records from DWN.
- Response: JSON object containing a list of all records.
- Error: 500 on failure with an error message.
Retrieves a specific record using the provided recordId
.
example : http://localhost:3000/records/bafyreidtnd52fyekrt2s3q4yibh5bxwtpg4y2bkgivhxymxesgyezevyie
- Response: Returns the jwt of the specified record, wich is a KCC.
- Error: 404 if the record is not found, 500 on internal error.
- Initialize Web5 Connection: The
initialize
function inserver.js
automatically connects to Web5 and configures the protocol on startup. - Issue Credentials:
- Use the
/credentials
endpoint to generate and send a verifiable credential to a customer.
- Use the
- Retrieve Records:
- Use
/records
to list all stored records or/records/:recordId
to retrieve specific records.
- Use
- Each function is wrapped in
try-catch
blocks to handle errors. - Errors are logged to the console and appropriate HTTP status codes and messages are sent to the client.
- If the Web5 connection fails during startup, the server will log the error and terminate.
Contributions are welcome! Please follow these guidelines:
- Fork the repository.
- Create a feature branch.
- Submit a pull request with a detailed description of the changes.
This project is LICENSE under the MIT License.
For questions or support, please contact the maintainers.