The Consent/Contracts Agent is a comprehensive library designed to seamlessly integrate with the contract-manager and consent-manager. It offers a range of features, including the automatic creation and management of profiles, automation of processes, personalized recommendations, and the ability to set and manage profile preferences. Additionally, the agent provides a robust routing system to facilitate the efficient flow of these functionalities.
See the design document here.
- Consent Profile Management: Enables profiles for users in the consent-manager.
- Contract Profile Management: Enables profiles for contract-manager.
- Contract Negotiation Management: Enables organizations to define default rules and conditions for negotiation.
Here’s an example of a JSON configuration:
{
"source": "profiles",
"url": "mongodb://localhost:27017",
"dbName": "contract_consent_agent_db",
"watchChanges": false,
"hostsProfiles": true,
"existingDataCheck": true
}
See more here
To build le library you can use
npm run build
The contract/consent agent is a library, so you can't run it, but it's purpose it's to be installed and use in the contract-manager and consent-manager
- Install the contract-consent-agent
npm install https://gitpkg.now.sh/Prometheus-X-association/contract-consent-agent/contract-agent?VERSION
-
Create the config file and add your information (documentation)
-
Initialise the library at your main.ts
import express, { json as expressJson } from "express";
import { loadRoutes } from "./routes";
import path from "path";
import fs from "fs";
// Simulation
import { Agent, ConsentAgent } from "contract-agent";
export const startServer = async () => {
const app = express();
const port = testPort || process.env.PORT || 3000;
//Consent Agent exemple setup
const configFilePath = path.resolve(
__dirname,
agentConfigPath ?? "../consent-agent.config.json"
);
if (fs.existsSync(configFilePath)) {
Agent.setConfigPath(
agentConfigPath ?? "../consent-agent.config.json",
__filename
);
Agent.setProfilesHost("profiles");
await ConsentAgent.retrieveService();
}
loadRoutes(app);
// Start the server
const server = app.listen(port, () => {
//eslint-disable-next-line
console.log(`Consent manager running on: http://localhost:${port}`);
});
return { server, app }; // For tests
};
- Add the needed router into your project router
//router.ts
import { Application, Request, Response } from "express";
// Routes
import consentRouter from "./consent";
import { ConsentAgentRouter } from "contract-agent";
const API_PREFIX = process.env.API_PREFIX;
export const loadRoutes = (app: Application) => {
app.get("/health", (req: Request, res: Response) => {
res.json({ status: "OK" });
});
app.use(API_PREFIX + "/consents", consentRouter);
app.use(API_PREFIX + "/", verifyUserJWT, ConsentAgentRouter);
};
- Individuals can manage their consent preferences effectively.
- Organizations can streamline the negotiation process for data sharing agreements.
- Automatic recommendations for services based on consent profiles and contract profiles.
The API for the Consent/Contracts Negotiating Agent is documented using Swagger. You can find the API routes and their descriptions in the swagger.json
file located in the contract-agent/docs
directory.
You can use the following command to generate the swagger.json
npm run swagger
- Get data exchanges recommendations:
GET /profile/{profileId}/recommendations/consent
- Set Preferences:
POST /profile/{profileId}/preferences
- Get Preferences:
GET /profile/{profileId}/preferences
- Negotiate Contract:
POST /negotiation/contract/negotiate
Send the following requests to the designated endpoints:
- Data Format Standards: JSON-LD, ISO 3166-1 alpha-2, ISO 8601, ODRL
The architecture consists of several key components:
- Contract Agent: Manages contract profiles of organizations and facilitates contract negotiations.
- Consent Agent: Manages consent preferences of individuals and automates responses to consent requests.
The agent logs operations, errors, and warnings to facilitate troubleshooting and debugging. It also imposes limits and usage constraints to ensure efficient operation.
The testing strategy includes unit tests, integration tests, and UI tests to ensure the correctness and reliability of functionalities.
pnpm report-cca-contract
pnpm report-cca-consent
pnpm test
See more here for instructions.
The Consent/Contracts Negotiating Agent enhances data usage and sharing agreements management, ensuring compliance with policies and streamlining processes for individuals and organizations.
This project is licensed under the MIT License.
Contributions are welcome! Please submit a pull request or open an issue for any enhancements or bug fixes.
For more information, please contact the project maintainers.