### Example Policy Requester Options Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/interfaces/IExamplePolicyRequesterConstructorOptions.md Provides details on the options available for configuring the Example Policy Requester, including logging settings. ```APIDOC ## Interface IExamplePolicyRequesterConstructorOptions ### Description Options for the Example Policy Requester. ### Properties #### loggingComponentType? (string) - Optional The logging component for policy requester. ##### Default ```ts logging ``` ``` -------------------------------- ### Verify Project Setup with Full Build (Shell) Source: https://github.com/twinfoundation/rights-management/blob/next/CONTRIBUTING.md Command to perform a full build of the project, including cleaning, compiling, testing, packaging, and generating documentation. This verifies the initial setup. ```shell npm run dist ``` -------------------------------- ### Example Data Access Handler Constructor Options Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/interfaces/IExampleDataAccessHandlerConstructorOptions.md Provides details on the options available for configuring the Example Data Access Handler, specifically the logging component type. ```APIDOC ## Interface: IExampleDataAccessHandlerConstructorOptions ### Description Options for the Example Data Access Handler. ### Properties #### loggingComponentType? (string) - Optional The logging component for data access handler. ##### Default `logging` ``` -------------------------------- ### PolicyNegotiationAdminPointService Start Method Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-pnp-service/docs/reference/classes/PolicyNegotiationAdminPointService.md Starts the PolicyNegotiationAdminPointService component, typically during node initialization. It can optionally accept a node logging component type. ```typescript async start(nodeLoggingComponentType?: string): Promise ``` -------------------------------- ### Clone Repository and Install Dependencies (Shell) Source: https://github.com/twinfoundation/rights-management/blob/next/CONTRIBUTING.md Steps to clone the project repository and install necessary npm dependencies. This is a prerequisite for setting up the development environment. ```shell git clone https://github.com/twinfoundation/.git cd npm install ``` -------------------------------- ### Install TWIN Rights Management REST Client (npm) Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-rest-client/README.md This snippet shows how to install the @twin.org/rights-management-rest-client package using npm. This is the primary method for adding the client to your Node.js project. ```shell npm install @twin.org/rights-management-rest-client ``` -------------------------------- ### Install TWIN Rights Management Service using npm Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-service/README.md This snippet shows how to install the TWIN Rights Management Service package using npm. It is a prerequisite for using the service in your project. ```shell npm install @twin.org/rights-management-service ``` -------------------------------- ### Install TWIN Rights Management Packages Source: https://context7.com/twinfoundation/rights-management/llms.txt Installs core packages for rights management functionality, including models, service implementations, a unified service with REST endpoints, a REST client, and plugins. Uses npm for package management. ```bash # Install models and type definitions npm install @twin.org/rights-management-models # Install service implementations npm install @twin.org/rights-management-pap-service npm install @twin.org/rights-management-pdp-service npm install @twin.org/rights-management-pep-service npm install @twin.org/rights-management-pip-service npm install @twin.org/rights-management-pmp-service npm install @twin.org/rights-management-pxp-service npm install @twin.org/rights-management-pnp-service # Install unified service with REST endpoints npm install @twin.org/rights-management-service # Install REST client for remote connections npm install @twin.org/rights-management-rest-client # Install plugin implementations npm install @twin.org/rights-management-plugins ``` -------------------------------- ### PEP Inline Authorization Example (TypeScript) Source: https://github.com/twinfoundation/rights-management/blob/next/docs/architecture.md Demonstrates how to use the Policy Enforcement Point (PEP) to perform inline authorization checks for data accessibility without providing input data. It returns a boolean indicating access status. ```typescript const response = await pep.intercept({ locator: { assetType: 'aig:AuditableItemGraphVertex', action: 'use' } }); const isAllowed = Coerce.boolean(response); console.log('Access is allowed', isAllowed); ``` -------------------------------- ### Conventional Commit Message Examples (Shell) Source: https://github.com/twinfoundation/rights-management/blob/next/CONTRIBUTING.md Examples of correctly formatted commit messages following conventional commit standards for various types like feat, fix, and docs. These messages help in automating changelog generation and version bumping. ```shell # Good commit messages git commit -m "feat: add JWT token validation" git commit -m "fix: prevent endless loop in data lookup" git commit -m "docs: update installation instructions" # Bad commit messages (avoid these) git commit -m "fix stuff" git commit -m "WIP" git commit -m "changes" ``` -------------------------------- ### PEP Data Transformation Example (TypeScript) Source: https://github.com/twinfoundation/rights-management/blob/next/docs/architecture.md Shows how to use the Policy Enforcement Point (PEP) to transform JSON-LD data based on policy rules. The PEP receives the data and returns a processed version, potentially redacted or augmented. ```typescript const processedAigDocument = await pep.intercept({ locator: { assetType: 'aig:AuditableItemGraphVertex', action: 'read' }, data: aigDocument }); ``` -------------------------------- ### Install TWIN Rights Management PEP Service using npm Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-pep-service/README.md Installs the TWIN Rights Management Policy Enforcement Point Service package using npm. This is the primary method for integrating the service into your project. ```shell npm install @twin.org/rights-management-pep-service ``` -------------------------------- ### Get Negotiation State (cURL) Source: https://context7.com/twinfoundation/rights-management/llms.txt Retrieves the current state of a contract negotiation. This is done by sending a GET request to the specific negotiation endpoint, identified by the provider's PID. The response includes the negotiation's current state. ```bash curl -X GET "https://provider.example.com/rights-management/negotiations/urn:contract-negotiation:provider-456" -H "Accept: application/ld+json" -H "Authorization: Bearer " ``` -------------------------------- ### ExamplePolicyNegotiator Class Name (TypeScript) Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyNegotiator.md Retrieves the static class name of the Example Policy Negotiator. This is a common utility method for identifying component types. ```typescript ExamplePolicyNegotiator.CLASS_NAME ``` -------------------------------- ### Get Negotiation State Source: https://context7.com/twinfoundation/rights-management/llms.txt Retrieves the current state of a contract negotiation between a provider and a consumer. ```APIDOC ## GET /rights-management/negotiations/{providerPid} ### Description Retrieves the current state of a contract negotiation identified by the provider's unique identifier. ### Method GET ### Endpoint `/rights-management/negotiations/{providerPid}` ### Parameters #### Path Parameters - **providerPid** (string) - Required - The unique identifier for the provider in the contract negotiation. #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET "https://provider.example.com/rights-management/negotiations/urn:contract-negotiation:provider-456" \ -H "Accept: application/ld+json" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **@type** (string) - The type of the resource, expected to be `dspace:ContractNegotiation`. - **dspace:state** (string) - The current state of the contract negotiation (e.g., "REQUESTED", "OFFERED"). #### Response Example ```json { "@type": "dspace:ContractNegotiation", "dspace:state": "OFFERED" } ``` ``` -------------------------------- ### REST API for Policy Negotiation (Bash) Source: https://context7.com/twinfoundation/rights-management/llms.txt Implements REST endpoints for the IDS Contract Negotiation protocol, facilitating bilateral agreements between provider and consumer nodes. This example shows initiating a contract negotiation request from a consumer to a provider using JSON-LD format and JWT authentication. ```bash # Initiate a contract negotiation request (Consumer to Provider) curl -X POST "https://provider.example.com/rights-management/negotiations/request" \ -H "Content-Type: application/ld+json" \ -H "Accept: application/ld+json" \ -H "Authorization: Bearer " \ -d '{ "@context": ["https://w3id.org/dspace/2024/1/context.json"], "@type": "dspace:ContractRequestMessage", "dspace:consumerPid": "urn:contract-negotiation:consumer-123", "dspace:offer": { "@context": "http://www.w3.org/ns/odrl.jsonld", "@type": "odrl:Offer", "uid": "urn:offer-1", "assigner": "did:example:provider-node" }, "dspace:callbackAddress": "https://consumer.example.com/rights-management" }' # Response: 201 Created # { ``` -------------------------------- ### ExamplePolicyRequester Constructor Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyRequester.md Creates a new instance of ExamplePolicyRequester. Accepts optional configuration options. ```APIDOC ## Constructor ExamplePolicyRequester ### Description Create a new instance of ExamplePolicyRequester. ### Method `new` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **options?** (`IExamplePolicyRequesterConstructorOptions`) - Optional - The options for the example policy Requester. ### Request Example ```json { "options": { "someOption": "value" } } ``` ### Response #### Success Response (200) * **ExamplePolicyRequester** - The newly created instance of ExamplePolicyRequester. #### Response Example ```json { "instance": "ExamplePolicyRequester object" } ``` ``` -------------------------------- ### ExamplePolicyEnforcementProcessor Constructor Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyEnforcementProcessor.md Creates a new instance of the ExamplePolicyEnforcementProcessor. ```APIDOC ## Constructor ExamplePolicyEnforcementProcessor ### Description Create a new instance of ExamplePolicyEnforcementProcessor. ### Method `new` ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### options? - **options** (`IExamplePolicyEnforcementProcessorConstructorOptions`) - Optional - The options for the example policy enforcement processor. ### Returns - **ExamplePolicyEnforcementProcessor** - A new instance of ExamplePolicyEnforcementProcessor. ### Request Example ```json { "options": { /* ... constructor options ... */ } } ``` ### Response #### Success Response (Instance) - **ExamplePolicyEnforcementProcessor** - The newly created instance. #### Response Example ```json { "instance": "ExamplePolicyEnforcementProcessor" } ``` ``` -------------------------------- ### ExamplePolicyArbiter Constructor Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyArbiter.md Creates a new instance of ExamplePolicyArbiter with optional configuration options. ```APIDOC ## new ExamplePolicyArbiter(options?) ### Description Create a new instance of ExamplePolicyArbiter. ### Method CONSTRUCTOR ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "options": { "someOption": "value" } } ``` ### Response #### Success Response (200) Returns an instance of `ExamplePolicyArbiter`. #### Response Example ```json { "instance": "ExamplePolicyArbiter" } ``` ``` -------------------------------- ### ExamplePolicyRequester Methods Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyRequester.md Documentation for the methods available on the ExamplePolicyRequester class. ```APIDOC ## Methods ### className() #### Description Returns the class name of the component. #### Method `className` #### Endpoint N/A (Instance method) #### Parameters None #### Request Example ```javascript const instance = new ExamplePolicyRequester(); const className = instance.className(); console.log(className); // Output: "ExamplePolicyRequester" ``` #### Response * **string** - The class name of the component. ### requesterId() #### Description The unique id of the requester. #### Method `requesterId` #### Endpoint N/A (Instance method) #### Parameters None #### Request Example ```javascript const instance = new ExamplePolicyRequester(); const id = instance.requesterId(); console.log(id); // Output: "unique-requester-id" ``` #### Response * **string** - The requester id. ### offer() #### Description A policy has been offered by a provider, let the requester know about it. #### Method `offer` #### Endpoint N/A (Instance method) #### Parameters * **negotiationId** (`string`) - Required - The id of the negotiation. * **offer** (`IOdrlOffer`) - Required - The offer sent by the provider. #### Request Example ```javascript const instance = new ExamplePolicyRequester(); const negotiationId = "negotiation-123"; const offer = { /* IOdrlOffer object */ }; const accepted = await instance.offer(negotiationId, offer); console.log(accepted); // Output: true or false ``` #### Response * **Promise** - True if the offer was accepted, false otherwise. ### agreement() #### Description A policy agreement has been sent by a provider, let the requester know about it. #### Method `agreement` #### Endpoint N/A (Instance method) #### Parameters * **negotiationId** (`string`) - Required - The id of the negotiation. * **agreement** (`IOdrlAgreement`) - Required - The agreement sent by the provider. #### Request Example ```javascript const instance = new ExamplePolicyRequester(); const negotiationId = "negotiation-123"; const agreement = { /* IOdrlAgreement object */ }; const accepted = await instance.agreement(negotiationId, agreement); console.log(accepted); // Output: true or false ``` #### Response * **Promise** - True if the agreement was accepted, false otherwise. ### finalised() #### Description A policy finalisation has been sent by a provider, let the requester know about it. #### Method `finalised` #### Endpoint N/A (Instance method) #### Parameters * **negotiationId** (`string`) - Required - The id of the negotiation. #### Request Example ```javascript const instance = new ExamplePolicyRequester(); const negotiationId = "negotiation-123"; await instance.finalised(negotiationId); console.log("Finalised"); ``` #### Response * **Promise** - Nothing. ### terminated() #### Description A policy termination has been sent by a provider, let the requester know about it. #### Method `terminated` #### Endpoint N/A (Instance method) #### Parameters * **negotiationId** (`string`) - Required - The id of the negotiation. #### Request Example ```javascript const instance = new ExamplePolicyRequester(); const negotiationId = "negotiation-123"; await instance.terminated(negotiationId); console.log("Terminated"); ``` #### Response * **Promise** - Nothing. ``` -------------------------------- ### ExamplePolicyEnforcementProcessor.process() Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyEnforcementProcessor.md Process the response from the policy decision point. ```APIDOC ## Method process() ### Description Process the response from the policy decision point. ### Method `process` ### Endpoint N/A (Class Method) ### Type Parameters - **D**: `unknown` - The type of the data being processed. - **R**: `D` - The type of the result after processing. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **locator** (`IPolicyLocator`) - Required - The locator to find relevant policies. - **decisions** (`IPolicyDecision[]`) - Required - The decisions made by the policy decision point. - **data?** (`D`) - Optional - The data to process. ### Returns - **Promise** - The data after processing. ### Request Example ```json { "method": "process", "params": { "locator": { /* ... IPolicyLocator object ... */ }, "decisions": [ /* ... IPolicyDecision objects ... */ ], "data": { /* ... data of type D ... */ } } } ``` ### Response #### Success Response (200) - **R** - The data after processing. #### Response Example ```json { "processedData": { /* ... data of type R ... */ } } ``` ``` -------------------------------- ### ExamplePolicyEnforcementProcessor.className() Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyEnforcementProcessor.md Returns the class name of the component. ```APIDOC ## Method className() ### Description Returns the class name of the component. ### Method `className` ### Endpoint N/A (Class Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Returns - **string** - The class name of the component. ### Request Example ```json { "method": "className()" } ``` ### Response #### Success Response (200) - **string** - The class name of the component. #### Response Example ```json { "className": "ExamplePolicyEnforcementProcessor" } ``` ``` -------------------------------- ### ExamplePolicyArbiter Methods Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyArbiter.md Documentation for the methods of the ExamplePolicyArbiter class. ```APIDOC ## className() ### Description Returns the class name of the component. ### Method GET ### Endpoint N/A (instance method) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **className** (string) - The class name of the component. #### Response Example ```json { "className": "ExamplePolicyArbiter" } ``` ``` ```APIDOC ## supportedPolicies() ### Description Gets the policies supported by this arbiter. If empty, it can be used for all policies. ### Method GET ### Endpoint N/A (instance method) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **supportedPolicies** (IPolicyLocator[]) - An array of supported policy locators. #### Response Example ```json { "supportedPolicies": [ { "policyId": "policy-123", "version": "1.0.0" } ] } ``` ``` ```APIDOC ## decide(locator, information?, policies?, data?) ### Description Makes decisions regarding policy access to data. ### Method POST ### Endpoint N/A (instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **locator** (IPolicyLocator) - Required - The locator to find relevant policies. - **information** (IPolicyInformation) - Optional - Information provided by the requester to determine if a policy can be created. - **policies** (IOdrlPolicy[]) - Optional - The policies that apply to the data. - **data** (D) - Optional - The data to make a decision on. ### Request Example ```json { "locator": { "policyId": "policy-123", "version": "1.0.0" }, "information": { "requester": "user-abc" }, "policies": [ { "policyId": "policy-456" } ], "data": { "content": "some data" } } ``` ### Response #### Success Response (200) - **decisions** (IPolicyDecision[]) - An array of decisions about access to the data. #### Response Example ```json { "decisions": [ { "policyId": "policy-123", "decision": "allow" } ] } ``` ``` -------------------------------- ### Get Negotiation State Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-pnp-service/docs/reference/classes/PolicyNegotiationPointService.md Retrieves the current state of a contract negotiation using its ID. ```APIDOC ## GET /negotiations/{id} ### Description Get the current state of the negotiation. ### Method GET ### Endpoint `/negotiations/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The id of the negotiation to retrieve. #### Query Parameters - **trustPayload** (unknown) - Required - Trust payload to verify the requesters identity. #### Request Body None ### Request Example ```json { "trustPayload": { ... } } ``` ### Response #### Success Response (200) - **negotiationState** (`IDataspaceProtocolContractNegotiation` | `IDataspaceProtocolContractNegotiationError`) - The current state of the negotiation or an error. #### Response Example ```json { "negotiationState": { ... } } ``` ``` -------------------------------- ### GET /twinfoundation/rights-management/negotiations/{id} Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-models/docs/reference/interfaces/IPnpNegotiationGetRequest.md Retrieves the details of a specific contract negotiation using its unique identifier. ```APIDOC ## GET /twinfoundation/rights-management/negotiations/{id} ### Description Retrieves the details of a specific contract negotiation using its unique identifier. ### Method GET ### Endpoint /twinfoundation/rights-management/negotiations/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The identifier of the contract negotiation to be retrieved. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **headers** (object) - The headers which can be used to determine the response data type. - **accept** (string, optional) - Specifies the desired response data type, either "application/ld+json" or "application/json". - **authorization** (string, optional) - The authorization token for accessing the API. #### Response Example { "headers": { "accept": "application/json", "authorization": "Bearer YOUR_ACCESS_TOKEN" } } ``` -------------------------------- ### Create and Match Policy Locators with TypeScript Source: https://context7.com/twinfoundation/rights-management/llms.txt Demonstrates how to use the LocatorHelper class to convert policy locator objects into string representations and to find matching locators from a list. It handles exact and wildcard matching scenarios. ```typescript import { LocatorHelper } from "@twin.org/rights-management-models"; import type { IPolicyLocator } from "@twin.org/rights-management-models"; // Create a locator const locator: IPolicyLocator = { assetType: "data:SensorReading", action: "read", assignee: "did:example:user-123", resourceId: "urn:sensor:temp-001" }; // Convert locator to string representation const locatorString = LocatorHelper.toString(locator); console.log(locatorString); // Output: "assetType=data:SensorReading, action=read, assignee=did:example:user-123, resourceId=urn:sensor:temp-001" // Find matching locator from a list const supportedLocators: IPolicyLocator[] = [ { assetType: "data:SensorReading" }, { assetType: "data:Document", action: "read" }, { assetType: "data:UserProfile" } ]; const requestLocator: IPolicyLocator = { assetType: "data:SensorReading", action: "read", assignee: "did:example:user" }; const match = LocatorHelper.findMatchingLocator(supportedLocators, requestLocator); console.log("Match found:", match); // Output: Match found: { assetType: "data:SensorReading" } // Wildcard matching - empty or undefined fields match any value const wildcardLocator: IPolicyLocator = { assetType: "data:SensorReading" // action and assignee undefined = matches any }; const specificRequest: IPolicyLocator = { assetType: "data:SensorReading", action: "write", assignee: "did:example:admin" }; const wildcardMatch = LocatorHelper.findMatchingLocator([wildcardLocator], specificRequest); console.log("Wildcard match:", wildcardMatch !== undefined); // Output: Wildcard match: true ``` -------------------------------- ### Register and Use PIP with TypeScript Source: https://context7.com/twinfoundation/rights-management/llms.txt Demonstrates how to register a static information source and use the Policy Information Point (PIP) service to retrieve contextual facts. It covers registering sources, initializing the PIP service, and retrieving public or all available facts based on access mode. ```typescript import { PolicyInformationPointService } from "@twin.org/rights-management-pip-service"; import { PolicyInformationSourceFactory, PolicyInformationAccessMode } from "@twin.org/rights-management-models"; import { StaticPolicyInformationSource } from "@twin.org/rights-management-plugins"; // Register a static information source const staticSource = new StaticPolicyInformationSource({ config: { information: [ { accessMode: PolicyInformationAccessMode.Public, matchLocators: [{ assetType: "data:UserProfile" }], objects: [ { "@context": "https://schema.org/", "@type": "Organization", "@id": "urn:org:twin-foundation", name: "TWIN Foundation", trustLevel: "verified" } ] }, { accessMode: PolicyInformationAccessMode.Private, matchLocators: [{ assignee: "did:example:internal-user" }], objects: [ { "@type": "InternalContext", clearanceLevel: "high", department: "engineering" } ] } ] } }); PolicyInformationSourceFactory.register("static-source", () => staticSource); // Initialize PIP service const pipService = new PolicyInformationPointService({ loggingComponentType: "logging" }); // Retrieve information for PDP decision making const information = await pipService.retrieve( { assetType: "data:UserProfile", assignee: "did:example:consumer" }, PolicyInformationAccessMode.Public, // Only public facts for external negotiation [], // policies { userId: "user-123" } // request data ); console.log("Retrieved information items:", information.items?.length); console.log("Public facts:", information.items); // For internal PDP evaluation, use Any mode to get all facts const allInformation = await pipService.retrieve( { assetType: "data:UserProfile", assignee: "did:example:internal-user" }, PolicyInformationAccessMode.Any, [], { userId: "internal-user-456" } ); console.log("All information items:", allInformation.items); ``` -------------------------------- ### IPapGetRequest - Get Policy Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-models/docs/reference/interfaces/IPapGetRequest.md Retrieves a policy using its unique identifier. This endpoint is part of the Rights Management API. ```APIDOC ## GET /twinfoundation/rights-management/policies/{id} ### Description Retrieves a specific policy based on its ID. ### Method GET ### Endpoint /twinfoundation/rights-management/policies/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the policy to retrieve. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **policy** (object) - The retrieved policy object. - **id** (string) - The unique identifier of the policy. - **name** (string) - The name of the policy. - **rules** (array) - A list of rules associated with the policy. #### Response Example ```json { "policy": { "id": "policy-123", "name": "Default Access Policy", "rules": [ { "action": "allow", "resource": "/data/*", "subject": "user:admin" } ] } } ``` ``` -------------------------------- ### PolicyNegotiationAdminPointService Get Method Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-pnp-service/docs/reference/classes/PolicyNegotiationAdminPointService.md Retrieves a specific policy negotiation by its unique ID. This method is asynchronous and returns a Promise that resolves to an IPolicyNegotiation object. ```typescript async get(id: string): Promise ``` -------------------------------- ### Register and Use PXP with TypeScript Source: https://context7.com/twinfoundation/rights-management/llms.txt Illustrates how to register a logging execution action and utilize the Policy Execution Point (PXP) service for pre and post-evaluation interception. It covers registering actions, initializing the PXP service, and executing actions before and after PDP evaluation. ```typescript import { PolicyExecutionPointService } from "@twin.org/rights-management-pxp-service"; import { PolicyExecutionActionFactory, PolicyDecisionStage } from "@twin.org/rights-management-models"; import { LoggingPolicyExecutionAction } from "@twin.org/rights-management-plugins"; // Register a logging execution action const loggingAction = new LoggingPolicyExecutionAction({ loggingComponentType: "logging", config: { logLevel: "info", includeData: false // Don't log sensitive data } }); PolicyExecutionActionFactory.register("logging-action", () => loggingAction); // Initialize PXP service const pxpService = new PolicyExecutionPointService({ loggingComponentType: "logging" }); // Execute actions before PDP evaluation await pxpService.executeActions( PolicyDecisionStage.Before, { assetType: "data:Document", action: "read" }, [], // policies (not yet evaluated) [], // decisions (empty before evaluation) { documentId: "doc-123" } // request data ); // After PDP makes decisions, execute post-evaluation actions const decisions = [ { target: "urn:document:123", decision: "Granted" } ]; await pxpService.executeActions( PolicyDecisionStage.After, { assetType: "data:Document", action: "read" }, [{ "@type": "Set", uid: "policy-1", permission: [] }], // evaluated policies decisions, { documentId: "doc-123" } ); // Actions can emit telemetry, schedule obligations, or send enforcement hints ``` -------------------------------- ### Get Negotiation State Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-models/docs/reference/interfaces/IPolicyNegotiationPointComponent.md Retrieves the current state of a contract negotiation using its ID. It also accepts a trust payload for verifying the requester's identity. ```APIDOC ## GET /negotiation/{id} ### Description Get the current state of the negotiation. ### Method GET ### Endpoint `/negotiation/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The id of the negotiation to retrieve. #### Query Parameters - **trustPayload** (unknown) - Required - Trust payload to verify the requesters identity. ### Response #### Success Response (200) - **IDataspaceProtocolContractNegotiation** | **IDataspaceProtocolContractNegotiationError** - The current state of the negotiation or an error. #### Response Example ```json { "status": "in-progress", "id": "negotiation-id-123" } ``` ``` -------------------------------- ### PNP Get Negotiation Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-service/docs/reference/functions/pnpGetNegotiation.md Retrieves negotiation details using the pnpGetNegotiation function. This endpoint requires the HTTP request context, component name, and negotiation request details. ```APIDOC ## POST /twinfoundation/rights-management/negotiation ### Description Retrieves negotiation details using the pnpGetNegotiation function. This endpoint requires the HTTP request context, component name, and negotiation request details. ### Method POST ### Endpoint /twinfoundation/rights-management/negotiation ### Parameters #### Request Body - **httpRequestContext** (IHttpRequestContext) - Required - The request context for the API. - **componentName** (string) - Required - The name of the component to use in the routes. - **request** (IPnpNegotiationGetRequest) - Required - The negotiation request object. ### Request Example ```json { "httpRequestContext": { ... }, "componentName": "exampleComponent", "request": { ... } } ``` ### Response #### Success Response (200) - **IPnpContractNegotiationResponse** - The response object with additional http response properties. #### Response Example ```json { "negotiationDetails": { ... }, "status": "success" } ``` ``` -------------------------------- ### ExamplePolicyNegotiator.handleOffer() Method (TypeScript) Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyNegotiator.md Handles an offer, determining if it can be accepted and if manual intervention is required. It returns a promise with acceptance and intervention status. ```typescript handleOffer(offer: IOdrlOffer, information?: IPolicyInformation): Promise<{ accepted: boolean; interventionRequired: boolean; }> ``` -------------------------------- ### PNAP Get Policy Negotiation Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-service/docs/reference/functions/pnapGet.md Retrieves a policy negotiation using the pnapGet function. This function requires the HTTP request context, component name, and a request object. ```APIDOC ## GET /twinfoundation/rights-management/pnap ### Description Retrieves a policy negotiation by providing the HTTP request context, component name, and a specific request object. ### Method GET ### Endpoint /twinfoundation/rights-management/pnap ### Parameters #### Query Parameters - **componentName** (string) - Required - The name of the component to use in the routes. - **request** (IPnapGetRequest) - Required - The request object containing details for retrieving the policy negotiation. ### Request Example ```json { "componentName": "exampleComponent", "request": { "policyId": "policy123" } } ``` ### Response #### Success Response (200) - **policyNegotiation** (IPnapGetResponse) - The response object containing the policy negotiation details. #### Response Example ```json { "policyNegotiation": { "negotiationId": "negotiationABC", "status": "approved", "terms": { "duration": "1 year" } } } ``` ``` -------------------------------- ### StaticPolicyInformationSource Constructor Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/StaticPolicyInformationSource.md Creates a new instance of the StaticPolicyInformationSource class. ```APIDOC ## new StaticPolicyInformationSource ### Description Create a new instance of StaticPolicyInformationSource. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "No request body for constructor" } ``` ### Response #### Success Response (200) - **instance** (StaticPolicyInformationSource) - A new instance of StaticPolicyInformationSource. #### Response Example ```json { "example": "Instance of StaticPolicyInformationSource" } ``` ``` -------------------------------- ### LocatorHelper Constructor Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-models/docs/reference/classes/LocatorHelper.md Initializes a new instance of the LocatorHelper class. ```APIDOC ## new LocatorHelper() ### Description Initializes a new instance of the LocatorHelper class. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters None ### Request Example ```json // No request body for constructor ``` ### Response #### Success Response (200) - **instance** (`LocatorHelper`) - A new instance of LocatorHelper. #### Response Example ```json { "instance": "LocatorHelper" } ``` ``` -------------------------------- ### ExamplePolicyNegotiator Constructor (TypeScript) Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyNegotiator.md Creates a new instance of the ExamplePolicyNegotiator. It accepts optional constructor options that configure the negotiator. ```typescript new ExamplePolicyNegotiator(options?) ``` -------------------------------- ### Create Feature Branch from 'next' (Shell) Source: https://github.com/twinfoundation/rights-management/blob/next/CONTRIBUTING.md Workflow for creating a new feature branch based on the latest 'next' branch. This ensures development starts from the most up-to-date code. ```shell git checkout next git pull origin next git checkout -b feat/your-feature-name ``` -------------------------------- ### ExamplePolicyArbiter Properties Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyArbiter.md Documentation for the properties of the ExamplePolicyArbiter class. ```APIDOC ## CLASS_NAME ### Description The class name of the Example Policy Arbiter. ### Method GET ### Endpoint N/A (static property) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **CLASS_NAME** (string) - The static class name. #### Response Example ```json { "CLASS_NAME": "ExamplePolicyArbiter" } ``` ``` -------------------------------- ### Run Repository-Level Development Commands (Shell) Source: https://github.com/twinfoundation/rights-management/blob/next/CONTRIBUTING.md Common development commands available at the root of the repository for formatting, linting, and performing a full build. ```shell # Format code with Prettier npm run format # Run ESLint checks npm run lint # Perform a complete build npm run dist ``` -------------------------------- ### ExamplePolicyNegotiator.supportsOffer() Method (TypeScript) Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyNegotiator.md Determines if the negotiator can support a given offer. It takes an IOdrlOffer as input and returns a boolean indicating support. ```typescript supportsOffer(offer: IOdrlOffer): boolean ``` -------------------------------- ### Policy Negotiation Point Service Constructor Options Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-pnp-service/docs/reference/interfaces/IPolicyNegotiationPointServiceConstructorOptions.md This section details the properties available for configuring the Policy Negotiation Point Service constructor. ```APIDOC ## Policy Negotiation Point Service Constructor Options ### Description Options for the Policy Negotiation Point Component. ### Properties #### `loggingComponentType` (string, optional) The logging component for logging policy negotiation. **Default:** `logging` #### `policyNegotiationAdministrationPointComponentType` (string, optional) The type of the policy negotiation administration point component. **Default:** `policy-negotiation-admin-point` #### `policyAdministrationPointComponentType` (string, optional) The type of the policy administration point component. **Default:** `policy-administration-point` #### `policyInformationPointComponentType` (string, optional) The type of the policy information point component. **Default:** `policy-information-point` #### `trustComponentType` (string, optional) The type of the trust component. **Default:** `trust` #### `config` (IPolicyNegotiationPointServiceConfig) Configuration options for the policy negotiation point service. **Required** ``` -------------------------------- ### Schema Initialization API Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-pnp-service/docs/reference/functions/initSchema.md Initializes the schema for the rights management policy negotiation point. ```APIDOC ## POST /twinfoundation/rights-management/initSchema ### Description Initializes the schema for the rights management policy negotiation point. ### Method POST ### Endpoint /twinfoundation/rights-management/initSchema ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "No request body needed for schema initialization." } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Schema initialized successfully." } ``` ``` -------------------------------- ### StaticPolicyInformationSource.addInformation() Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/StaticPolicyInformationSource.md Add static policy information to the source. ```APIDOC ## addInformation() ### Description Add static policy information. ### Method POST ### Endpoint /addInformation ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **info** (IStaticPolicyInformationSource) - Required - The static policy information to add. ### Request Example ```json { "info": { "@id": "policyInfoId", "@type": "PolicyInfoType", "someProperty": "someValue" } } ``` ### Response #### Success Response (200) - **void** - This method does not return a value. #### Response Example ```json { "example": "No response body" } ``` ``` -------------------------------- ### PolicyNegotiationPointService Constructor Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-pnp-service/docs/reference/classes/PolicyNegotiationPointService.md Creates a new instance of the PolicyNegotiationPointService. ```APIDOC ## new PolicyNegotiationPointService(options) ### Description Create a new instance of PolicyNegotiationPointService (PNP). ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "options": { ... } } ``` ### Response #### Success Response (200) Returns an instance of `PolicyNegotiationPointService`. #### Response Example ```json { "instance": "PolicyNegotiationPointService" } ``` ``` -------------------------------- ### IdentityPolicyInformationSource Constructor Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/IdentityPolicyInformationSource.md Creates a new instance of the IdentityPolicyInformationSource class. It accepts optional configuration options. ```APIDOC ## new IdentityPolicyInformationSource ### Description Create a new instance of IdentityPolicyInformationSource. ### Method CONSTRUCTOR ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "options?": "IIdentityPolicyInformationSourceConstructorOptions" } ``` ### Response #### Success Response (200) `IdentityPolicyInformationSource` #### Response Example ```json { "instance": "IdentityPolicyInformationSource" } ``` ``` -------------------------------- ### Prepare Release GitHub Action (YAML) Source: https://github.com/twinfoundation/rights-management/blob/next/CONTRIBUTING.md Configuration for the 'Prepare Release' GitHub Action, used for both prerelease and production versioning. This action handles version bumping and changelog updates. ```yaml # Example configuration for Prepare Release GitHub Action # This is a conceptual representation, actual action inputs may vary. # ... jobs: prepare_release: runs-on: ubuntu-latest steps: - name: Prepare Release uses: twinfoundation/rights-management/.github/workflows/prepare-release.yml@main with: # semver type: 'prerelease', 'major', 'minor', or 'patch' semver_type: "prerelease" # or "major", "minor", "patch" # ... other inputs ``` -------------------------------- ### LocatorHelper.matches(locator1, locator2) Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-models/docs/reference/classes/LocatorHelper.md Compares two policy locators to determine if they are identical. ```APIDOC ## LocatorHelper.matches(locator1, locator2) ### Description Compares two policy locators to determine if they are identical. ### Method POST ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **locator1** (`IPolicyLocator`) - Required - The first policy locator. - **locator2** (`IPolicyLocator`) - Required - The second policy locator. ### Request Example ```json { "locator1": { "type": "policy", "id": "policy-123" }, "locator2": { "type": "policy", "id": "policy-123" } } ``` ### Response #### Success Response (200) - **match** (`boolean`) - True if the locators match, false otherwise. #### Response Example ```json { "match": true } ``` ``` -------------------------------- ### Versions Prepare GitHub Action (YAML) Source: https://github.com/twinfoundation/rights-management/blob/next/CONTRIBUTING.md Configuration for the 'Versions Prepare' GitHub Action, used to update branch versions and create PRs for merging between development and production branches. ```yaml # Example configuration for Versions Prepare GitHub Action # This is a conceptual representation, actual action inputs may vary. # ... jobs: versions_prepare: runs-on: ubuntu-latest steps: - name: Prepare Versions uses: twinfoundation/rights-management/.github/workflows/versions-prepare.yml@main with: # target branch: 'main' or 'next' target_branch: "main" # or "next" # ... other inputs ``` -------------------------------- ### StaticPolicyInformationSource.retrieve() Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/StaticPolicyInformationSource.md Retrieve information from the sources based on the provided locator, access mode, and policies. ```APIDOC ## retrieve() ### Description Retrieve information from the sources. ### Method POST ### Endpoint /retrieve ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **locator** (IPolicyLocator) - Required - The locator to find relevant policies. - **accessMode** (PolicyInformationAccessMode) - Required - The access mode to use for the retrieval. - **policies** (IOdrlPolicy[]) - Required - The policies that apply to the data. - **data?** (D) - Optional - The data to process. ### Request Example ```json { "locator": { ... }, "accessMode": "someMode", "policies": [ { ... } ], "data": "someData" } ``` ### Response #### Success Response (200) - **result** (IJsonLdNodeObject[] | undefined) - The objects containing relevant information or undefined if nothing relevant is found. #### Response Example ```json { "example": [ { "@id": "someId", "@type": "someType" }, { "@id": "anotherId", "@type": "anotherType" } ] } ``` ``` -------------------------------- ### ExamplePolicyNegotiator.createAgreement() Method (TypeScript) Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-plugins/docs/reference/classes/ExamplePolicyNegotiator.md Creates an agreement based on a given offer and optional policy information. It returns a promise that resolves to an IOdrlAgreement or undefined. ```typescript createAgreement(offer: IOdrlOffer, information?: IPolicyInformation): Promise ``` -------------------------------- ### Query Manual Policy Negotiations Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-models/docs/reference/interfaces/IPnapQueryRequest.md Allows querying manual policy negotiations with optional state and pagination parameters. ```APIDOC ## GET /twinfoundation/rights-management/query ### Description Retrieves manual policy negotiations based on provided query parameters. ### Method GET ### Endpoint /twinfoundation/rights-management/query ### Parameters #### Query Parameters - **state** (DataspaceProtocolContractNegotiationStateType) - Optional - The state of the policy negotiations. - **cursor** (string) - Optional - The cursor for pagination. ### Request Example ```json { "state": "REQUESTED", "cursor": "some_cursor_string" } ``` ### Response #### Success Response (200) - **negotiations** (array) - A list of policy negotiation objects. - **state** (DataspaceProtocolContractNegotiationStateType) - The state of the negotiation. - **cursor** (string) - The cursor for the next page of results. #### Response Example ```json { "negotiations": [ { "state": "AGREED", "cursor": "another_cursor_string" } ] } ``` ``` -------------------------------- ### Process Provider Offer Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-pnp-service/docs/reference/classes/PolicyNegotiationPointService.md Handles an incoming contract offer from a provider to a consumer. ```APIDOC ## POST /provider/offer ### Description An offer has been received by a consumer. ### Method POST ### Endpoint `/provider/offer` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **message** (`IDataspaceProtocolContractOfferMessage`) - Required - The offer being received by the consumer. - **publicOrigin** (string) - Required - The public origin url of this PNP service. - **trustPayload** (unknown) - Required - Trust payload to verify the requesters identity. ### Request Example ```json { "message": { ... }, "publicOrigin": "http://pnp.com/origin", "trustPayload": { ... } } ``` ### Response #### Success Response (200) - **negotiationState** (`IDataspaceProtocolContractNegotiation` | `IDataspaceProtocolContractNegotiationError`) - The current state of the contract negotiation or an error. #### Response Example ```json { "negotiationState": { ... } } ``` ``` -------------------------------- ### PolicyNegotiationAdminPointService Constructor Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-pnp-service/docs/reference/classes/PolicyNegotiationAdminPointService.md Creates a new instance of the PolicyNegotiationAdminPointService. It accepts optional configuration options for the component. ```typescript new PolicyNegotiationAdminPointService(options?) ``` -------------------------------- ### PolicyEnforcementPointService Constructor Source: https://github.com/twinfoundation/rights-management/blob/next/packages/rights-management-pep-service/docs/reference/classes/PolicyEnforcementPointService.md Creates a new instance of the PolicyEnforcementPointService. It accepts optional constructor options for configuration. ```typescript new PolicyEnforcementPointService(options?) ```