@twin.org/rights-management-models 0.0.3-next.9 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/README.md +11 -3
  2. package/dist/es/factories/policyObligationEnforcerFactory.js +9 -0
  3. package/dist/es/factories/policyObligationEnforcerFactory.js.map +1 -0
  4. package/dist/es/index.js +19 -19
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/es/models/IRightsManagementAgreement.js +2 -0
  7. package/dist/es/models/IRightsManagementAgreement.js.map +1 -0
  8. package/dist/es/models/IRightsManagementInformation.js +4 -0
  9. package/dist/es/models/IRightsManagementInformation.js.map +1 -0
  10. package/dist/es/models/IRightsManagementOffer.js +2 -0
  11. package/dist/es/models/IRightsManagementOffer.js.map +1 -0
  12. package/dist/es/models/IRightsManagementPolicy.js +2 -0
  13. package/dist/es/models/IRightsManagementPolicy.js.map +1 -0
  14. package/dist/es/models/IRightsManagementPolicyMetadata.js +4 -0
  15. package/dist/es/models/IRightsManagementPolicyMetadata.js.map +1 -0
  16. package/dist/es/models/IRightsManagementPolicyTrust.js +2 -0
  17. package/dist/es/models/IRightsManagementPolicyTrust.js.map +1 -0
  18. package/dist/es/models/IRightsManagementSet.js +2 -0
  19. package/dist/es/models/IRightsManagementSet.js.map +1 -0
  20. package/dist/es/models/api/pap/IPapCreateRequest.js.map +1 -1
  21. package/dist/es/models/api/pap/IPapGetAgreementRequest.js +4 -0
  22. package/dist/es/models/api/pap/IPapGetAgreementRequest.js.map +1 -0
  23. package/dist/es/models/api/pap/IPapGetAgreementResponse.js +2 -0
  24. package/dist/es/models/api/pap/IPapGetAgreementResponse.js.map +1 -0
  25. package/dist/es/models/api/pap/IPapGetOfferRequest.js +4 -0
  26. package/dist/es/models/api/pap/IPapGetOfferRequest.js.map +1 -0
  27. package/dist/es/models/api/pap/IPapGetOfferResponse.js +2 -0
  28. package/dist/es/models/api/pap/IPapGetOfferResponse.js.map +1 -0
  29. package/dist/es/models/api/pap/IPapGetResponse.js.map +1 -1
  30. package/dist/es/models/{IPolicyLocator.js → api/pap/IPapGetSetRequest.js} +1 -1
  31. package/dist/es/models/api/pap/IPapGetSetRequest.js.map +1 -0
  32. package/dist/es/models/api/pap/IPapGetSetResponse.js +2 -0
  33. package/dist/es/models/api/pap/IPapGetSetResponse.js.map +1 -0
  34. package/dist/es/models/api/pap/IPapQueryRequest.js.map +1 -1
  35. package/dist/es/models/api/pap/IPapQueryResponse.js.map +1 -1
  36. package/dist/es/models/api/pap/IPapUpdateRequest.js.map +1 -1
  37. package/dist/es/models/api/pnap/IPnapCreateRequest.js +4 -0
  38. package/dist/es/models/api/pnap/IPnapCreateRequest.js.map +1 -0
  39. package/dist/es/models/api/pnap/IPnapQueryResponse.js.map +1 -1
  40. package/dist/es/models/odrlProfiles.js +21 -0
  41. package/dist/es/models/odrlProfiles.js.map +1 -0
  42. package/dist/es/models/pap/IPolicyAdministrationPointComponent.js.map +1 -1
  43. package/dist/es/models/pap/IPolicyLocator.js +2 -0
  44. package/dist/es/models/pap/IPolicyLocator.js.map +1 -0
  45. package/dist/es/models/pdp/IPolicyArbiter.js.map +1 -1
  46. package/dist/es/models/pdp/IPolicyDecision.js.map +1 -1
  47. package/dist/es/models/pdp/IPolicyDecisionPointComponent.js.map +1 -1
  48. package/dist/es/models/pdp/IPolicyObligationEnforcer.js +2 -0
  49. package/dist/es/models/pdp/IPolicyObligationEnforcer.js.map +1 -0
  50. package/dist/es/models/pdp/policyDecision.js +7 -3
  51. package/dist/es/models/pdp/policyDecision.js.map +1 -1
  52. package/dist/es/models/pep/IPolicyEnforcementPointComponent.js.map +1 -1
  53. package/dist/es/models/pep/IPolicyEnforcementProcessor.js.map +1 -1
  54. package/dist/es/models/pip/IPolicyInformationPointComponent.js.map +1 -1
  55. package/dist/es/models/pip/IPolicyInformationSource.js.map +1 -1
  56. package/dist/es/models/pmp/IPolicyManagementPointComponent.js.map +1 -1
  57. package/dist/es/models/pnp/IPolicyNegotiation.js.map +1 -1
  58. package/dist/es/models/pnp/IPolicyNegotiationAdminPointComponent.js.map +1 -1
  59. package/dist/es/models/pnp/IPolicyNegotiationPointComponent.js.map +1 -1
  60. package/dist/es/models/pnp/IPolicyNegotiator.js.map +1 -1
  61. package/dist/es/models/pnp/IPolicyRequester.js.map +1 -1
  62. package/dist/es/models/policyMetadataContext.js +17 -0
  63. package/dist/es/models/policyMetadataContext.js.map +1 -0
  64. package/dist/es/models/pxp/IPolicyExecutionAction.js.map +1 -1
  65. package/dist/es/models/pxp/IPolicyExecutionPointComponent.js.map +1 -1
  66. package/dist/es/utils/odrlPolicyHelper.js +212 -85
  67. package/dist/es/utils/odrlPolicyHelper.js.map +1 -1
  68. package/dist/types/factories/policyObligationEnforcerFactory.d.ts +6 -0
  69. package/dist/types/index.d.ts +19 -19
  70. package/dist/types/models/IRightsManagementAgreement.d.ts +8 -0
  71. package/dist/types/models/IRightsManagementInformation.d.ts +8 -0
  72. package/dist/types/models/IRightsManagementOffer.d.ts +8 -0
  73. package/dist/types/models/IRightsManagementPolicy.d.ts +8 -0
  74. package/dist/types/models/IRightsManagementPolicyMetadata.d.ts +13 -0
  75. package/dist/types/models/IRightsManagementPolicyTrust.d.ts +12 -0
  76. package/dist/types/models/IRightsManagementSet.d.ts +8 -0
  77. package/dist/types/models/api/pap/IPapCreateRequest.d.ts +4 -5
  78. package/dist/types/models/api/pap/IPapGetAgreementRequest.d.ts +14 -0
  79. package/dist/types/models/api/pap/IPapGetAgreementResponse.d.ts +10 -0
  80. package/dist/types/models/api/pap/IPapGetOfferRequest.d.ts +14 -0
  81. package/dist/types/models/api/pap/IPapGetOfferResponse.d.ts +10 -0
  82. package/dist/types/models/api/pap/IPapGetResponse.d.ts +2 -2
  83. package/dist/types/models/api/pap/IPapGetSetRequest.d.ts +14 -0
  84. package/dist/types/models/api/pap/IPapGetSetResponse.d.ts +10 -0
  85. package/dist/types/models/api/pap/IPapQueryRequest.d.ts +16 -0
  86. package/dist/types/models/api/pap/IPapQueryResponse.d.ts +9 -11
  87. package/dist/types/models/api/pap/IPapUpdateRequest.d.ts +2 -2
  88. package/dist/types/models/api/pnap/IPnapCreateRequest.d.ts +14 -0
  89. package/dist/types/models/api/pnap/IPnapQueryResponse.d.ts +8 -10
  90. package/dist/types/models/odrlProfiles.d.ts +21 -0
  91. package/dist/types/models/pap/IPolicyAdministrationPointComponent.d.ts +32 -10
  92. package/dist/types/models/pap/IPolicyLocator.d.ts +26 -0
  93. package/dist/types/models/pdp/IPolicyArbiter.d.ts +8 -12
  94. package/dist/types/models/pdp/IPolicyDecision.d.ts +6 -2
  95. package/dist/types/models/pdp/IPolicyDecisionPointComponent.d.ts +9 -3
  96. package/dist/types/models/pdp/IPolicyObligationEnforcer.d.ts +19 -0
  97. package/dist/types/models/pdp/policyDecision.d.ts +6 -2
  98. package/dist/types/models/pep/IPolicyEnforcementPointComponent.d.ts +34 -3
  99. package/dist/types/models/pep/IPolicyEnforcementProcessor.d.ts +5 -3
  100. package/dist/types/models/pip/IPolicyInformationPointComponent.d.ts +7 -7
  101. package/dist/types/models/pip/IPolicyInformationSource.d.ts +6 -6
  102. package/dist/types/models/pmp/IPolicyManagementPointComponent.d.ts +5 -6
  103. package/dist/types/models/pnp/IPolicyNegotiation.d.ts +21 -9
  104. package/dist/types/models/pnp/IPolicyNegotiationAdminPointComponent.d.ts +10 -3
  105. package/dist/types/models/pnp/IPolicyNegotiationPointComponent.d.ts +17 -13
  106. package/dist/types/models/pnp/IPolicyNegotiator.d.ts +8 -6
  107. package/dist/types/models/pnp/IPolicyRequester.d.ts +6 -10
  108. package/dist/types/models/policyMetadataContext.d.ts +14 -0
  109. package/dist/types/models/pxp/IPolicyExecutionAction.d.ts +6 -6
  110. package/dist/types/models/pxp/IPolicyExecutionPointComponent.d.ts +7 -7
  111. package/dist/types/utils/odrlPolicyHelper.d.ts +69 -37
  112. package/docs/changelog.md +895 -137
  113. package/docs/examples.md +81 -1
  114. package/docs/reference/classes/OdrlPolicyHelper.md +136 -85
  115. package/docs/reference/index.md +20 -19
  116. package/docs/reference/interfaces/IPapCreateRequest.md +3 -9
  117. package/docs/reference/interfaces/IPapGetAgreementRequest.md +17 -0
  118. package/docs/reference/interfaces/IPapGetAgreementResponse.md +11 -0
  119. package/docs/reference/interfaces/IPapGetOfferRequest.md +17 -0
  120. package/docs/reference/interfaces/IPapGetOfferResponse.md +11 -0
  121. package/docs/reference/interfaces/IPapGetRequest.md +1 -1
  122. package/docs/reference/interfaces/IPapGetResponse.md +2 -2
  123. package/docs/reference/interfaces/IPapGetSetRequest.md +17 -0
  124. package/docs/reference/interfaces/IPapGetSetResponse.md +11 -0
  125. package/docs/reference/interfaces/IPapQueryRequest.md +29 -5
  126. package/docs/reference/interfaces/IPapQueryResponse.md +9 -9
  127. package/docs/reference/interfaces/IPapRemoveRequest.md +1 -1
  128. package/docs/reference/interfaces/IPapUpdateRequest.md +3 -3
  129. package/docs/reference/interfaces/IPnapCreateRequest.md +17 -0
  130. package/docs/reference/interfaces/IPnapGetRequest.md +1 -1
  131. package/docs/reference/interfaces/IPnapGetResponse.md +1 -1
  132. package/docs/reference/interfaces/IPnapQueryRequest.md +4 -4
  133. package/docs/reference/interfaces/IPnapQueryResponse.md +9 -9
  134. package/docs/reference/interfaces/IPnapRemoveRequest.md +1 -1
  135. package/docs/reference/interfaces/IPnapSetRequest.md +2 -2
  136. package/docs/reference/interfaces/IPnpAgreementRequest.md +5 -5
  137. package/docs/reference/interfaces/IPnpAgreementVerificationRequest.md +5 -5
  138. package/docs/reference/interfaces/IPnpContractNegotiationResponse.md +5 -5
  139. package/docs/reference/interfaces/IPnpContractResponse.md +6 -6
  140. package/docs/reference/interfaces/IPnpEventRequest.md +5 -5
  141. package/docs/reference/interfaces/IPnpNegotiateRequest.md +7 -7
  142. package/docs/reference/interfaces/IPnpNegotiationGetRequest.md +4 -4
  143. package/docs/reference/interfaces/IPnpOfferRequest.md +7 -7
  144. package/docs/reference/interfaces/IPnpTerminateRequest.md +5 -5
  145. package/docs/reference/interfaces/IPolicyAdministrationPointComponent.md +86 -14
  146. package/docs/reference/interfaces/IPolicyArbiter.md +14 -27
  147. package/docs/reference/interfaces/IPolicyDecision.md +12 -4
  148. package/docs/reference/interfaces/IPolicyDecisionPointComponent.md +15 -5
  149. package/docs/reference/interfaces/IPolicyEnforcementPointComponent.md +124 -4
  150. package/docs/reference/interfaces/IPolicyEnforcementProcessor.md +11 -5
  151. package/docs/reference/interfaces/IPolicyExecutionAction.md +18 -18
  152. package/docs/reference/interfaces/IPolicyExecutionPointComponent.md +18 -18
  153. package/docs/reference/interfaces/IPolicyInformationPointComponent.md +13 -13
  154. package/docs/reference/interfaces/IPolicyInformationSource.md +12 -12
  155. package/docs/reference/interfaces/IPolicyLocator.md +20 -16
  156. package/docs/reference/interfaces/IPolicyManagementPointComponent.md +5 -17
  157. package/docs/reference/interfaces/IPolicyNegotiation.md +54 -81
  158. package/docs/reference/interfaces/IPolicyNegotiationAdminPointComponent.md +32 -6
  159. package/docs/reference/interfaces/IPolicyNegotiationPointComponent.md +58 -50
  160. package/docs/reference/interfaces/IPolicyNegotiator.md +17 -11
  161. package/docs/reference/interfaces/IPolicyObligationEnforcer.md +59 -0
  162. package/docs/reference/interfaces/IPolicyRequester.md +8 -22
  163. package/docs/reference/interfaces/IRightsManagementAgreement.md +47 -0
  164. package/docs/reference/interfaces/IRightsManagementInformation.md +9 -0
  165. package/docs/reference/interfaces/IRightsManagementOffer.md +47 -0
  166. package/docs/reference/interfaces/IRightsManagementPolicy.md +47 -0
  167. package/docs/reference/interfaces/IRightsManagementPolicyMetadata.md +26 -0
  168. package/docs/reference/interfaces/IRightsManagementPolicyTrust.md +22 -0
  169. package/docs/reference/interfaces/IRightsManagementSet.md +47 -0
  170. package/docs/reference/type-aliases/OdrlProfiles.md +5 -0
  171. package/docs/reference/variables/OdrlProfiles.md +23 -0
  172. package/docs/reference/variables/POLICY_METADATA_CONTEXT.md +20 -0
  173. package/docs/reference/variables/PolicyDecision.md +10 -4
  174. package/docs/reference/variables/PolicyDecisionStage.md +2 -2
  175. package/docs/reference/variables/PolicyInformationAccessMode.md +3 -3
  176. package/docs/reference/variables/PolicyObligationEnforcerFactory.md +5 -0
  177. package/docs/reference/variables/RightsManagementContexts.md +3 -3
  178. package/docs/reference/variables/RightsManagementNamespaces.md +2 -2
  179. package/docs/reference/variables/RightsManagementTypes.md +4 -4
  180. package/locales/en.json +8 -1
  181. package/package.json +15 -14
  182. package/dist/es/factories/dataAccessHandlerFactory.js +0 -9
  183. package/dist/es/factories/dataAccessHandlerFactory.js.map +0 -1
  184. package/dist/es/models/IPolicyLocator.js.map +0 -1
  185. package/dist/es/models/api/dap/IDapCreateRequest.js +0 -2
  186. package/dist/es/models/api/dap/IDapCreateRequest.js.map +0 -1
  187. package/dist/es/models/api/dap/IDapGetRequest.js +0 -2
  188. package/dist/es/models/api/dap/IDapGetRequest.js.map +0 -1
  189. package/dist/es/models/api/dap/IDapGetResponse.js +0 -2
  190. package/dist/es/models/api/dap/IDapGetResponse.js.map +0 -1
  191. package/dist/es/models/api/dap/IDapQueryRequest.js +0 -2
  192. package/dist/es/models/api/dap/IDapQueryRequest.js.map +0 -1
  193. package/dist/es/models/api/dap/IDapQueryResponse.js +0 -2
  194. package/dist/es/models/api/dap/IDapQueryResponse.js.map +0 -1
  195. package/dist/es/models/api/dap/IDapRemoveRequest.js +0 -2
  196. package/dist/es/models/api/dap/IDapRemoveRequest.js.map +0 -1
  197. package/dist/es/models/api/dap/IDapUpdateRequest.js +0 -2
  198. package/dist/es/models/api/dap/IDapUpdateRequest.js.map +0 -1
  199. package/dist/es/models/dap/IDataAccessHandler.js +0 -2
  200. package/dist/es/models/dap/IDataAccessHandler.js.map +0 -1
  201. package/dist/es/models/dap/IDataAccessPointComponent.js +0 -2
  202. package/dist/es/models/dap/IDataAccessPointComponent.js.map +0 -1
  203. package/dist/es/models/dap/IDataAccessRequestPointComponent.js +0 -2
  204. package/dist/es/models/dap/IDataAccessRequestPointComponent.js.map +0 -1
  205. package/dist/es/models/dap/jsonLd/IDataAccessQuery.js +0 -2
  206. package/dist/es/models/dap/jsonLd/IDataAccessQuery.js.map +0 -1
  207. package/dist/es/models/dap/jsonLd/IDataAccessQueryResponse.js +0 -2
  208. package/dist/es/models/dap/jsonLd/IDataAccessQueryResponse.js.map +0 -1
  209. package/dist/es/models/dap/jsonLd/IDataAccessRequest.js +0 -2
  210. package/dist/es/models/dap/jsonLd/IDataAccessRequest.js.map +0 -1
  211. package/dist/es/models/dap/jsonLd/IDataAccessRequestWithObject.js +0 -2
  212. package/dist/es/models/dap/jsonLd/IDataAccessRequestWithObject.js.map +0 -1
  213. package/dist/es/models/pip/IPolicyInformation.js +0 -2
  214. package/dist/es/models/pip/IPolicyInformation.js.map +0 -1
  215. package/dist/es/models/pip/IPolicyInformationItems.js +0 -2
  216. package/dist/es/models/pip/IPolicyInformationItems.js.map +0 -1
  217. package/dist/es/utils/locatorHelper.js +0 -56
  218. package/dist/es/utils/locatorHelper.js.map +0 -1
  219. package/dist/types/factories/dataAccessHandlerFactory.d.ts +0 -6
  220. package/dist/types/models/IPolicyLocator.d.ts +0 -21
  221. package/dist/types/models/api/dap/IDapCreateRequest.d.ts +0 -27
  222. package/dist/types/models/api/dap/IDapGetRequest.d.ts +0 -26
  223. package/dist/types/models/api/dap/IDapGetResponse.d.ts +0 -17
  224. package/dist/types/models/api/dap/IDapQueryRequest.d.ts +0 -27
  225. package/dist/types/models/api/dap/IDapQueryResponse.d.ts +0 -17
  226. package/dist/types/models/api/dap/IDapRemoveRequest.d.ts +0 -26
  227. package/dist/types/models/api/dap/IDapUpdateRequest.d.ts +0 -31
  228. package/dist/types/models/dap/IDataAccessHandler.d.ts +0 -53
  229. package/dist/types/models/dap/IDataAccessPointComponent.d.ts +0 -56
  230. package/dist/types/models/dap/IDataAccessRequestPointComponent.d.ts +0 -54
  231. package/dist/types/models/dap/jsonLd/IDataAccessQuery.d.ts +0 -33
  232. package/dist/types/models/dap/jsonLd/IDataAccessQueryResponse.d.ts +0 -24
  233. package/dist/types/models/dap/jsonLd/IDataAccessRequest.d.ts +0 -23
  234. package/dist/types/models/dap/jsonLd/IDataAccessRequestWithObject.d.ts +0 -24
  235. package/dist/types/models/pip/IPolicyInformation.d.ts +0 -7
  236. package/dist/types/models/pip/IPolicyInformationItems.d.ts +0 -5
  237. package/dist/types/utils/locatorHelper.d.ts +0 -26
  238. package/docs/reference/classes/LocatorHelper.md +0 -91
  239. package/docs/reference/interfaces/IDapCreateRequest.md +0 -41
  240. package/docs/reference/interfaces/IDapGetRequest.md +0 -39
  241. package/docs/reference/interfaces/IDapGetResponse.md +0 -23
  242. package/docs/reference/interfaces/IDapQueryRequest.md +0 -41
  243. package/docs/reference/interfaces/IDapQueryResponse.md +0 -23
  244. package/docs/reference/interfaces/IDapRemoveRequest.md +0 -39
  245. package/docs/reference/interfaces/IDapUpdateRequest.md +0 -47
  246. package/docs/reference/interfaces/IDataAccessHandler.md +0 -173
  247. package/docs/reference/interfaces/IDataAccessPointComponent.md +0 -192
  248. package/docs/reference/interfaces/IDataAccessQuery.md +0 -51
  249. package/docs/reference/interfaces/IDataAccessQueryResponse.md +0 -35
  250. package/docs/reference/interfaces/IDataAccessRequest.md +0 -35
  251. package/docs/reference/interfaces/IDataAccessRequestPointComponent.md +0 -190
  252. package/docs/reference/interfaces/IDataAccessRequestWithObject.md +0 -35
  253. package/docs/reference/interfaces/IPolicyInformation.md +0 -7
  254. package/docs/reference/type-aliases/IPolicyInformationItems.md +0 -5
  255. package/docs/reference/variables/DataAccessHandlerFactory.md +0 -5
@@ -1 +1 @@
1
- {"version":3,"file":"IPolicyNegotiationAdminPointComponent.js","sourceRoot":"","sources":["../../../../src/models/pnp/IPolicyNegotiationAdminPointComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { DataspaceProtocolContractNegotiationStateType } from \"@twin.org/standards-dataspace-protocol\";\nimport type { IPolicyNegotiation } from \"./IPolicyNegotiation.js\";\n\n/**\n * Interface describing a Policy Negotiation Admin Point (PNAP) contract.\n * Components performs administration tasks on the policy negotiations.\n * https://eclipse-dataspace-protocol-base.github.io/DataspaceProtocol/2025-1/#negotiation-protocol\n */\nexport interface IPolicyNegotiationAdminPointComponent extends IComponent {\n\t/**\n\t * Retrieves a policy negotiation.\n\t * @param id The ID of the policy to retrieve the negotiation for.\n\t * @returns The policy negotiation.\n\t */\n\tget(id: string): Promise<IPolicyNegotiation>;\n\n\t/**\n\t * Sets a policy negotiation.\n\t * @param negotiation The updated policy negotiation.\n\t * @returns Nothing.\n\t */\n\tset(negotiation: IPolicyNegotiation): Promise<void>;\n\n\t/**\n\t * Cancels an ongoing negotiation for a resource.\n\t * @param policyId The ID of the policy to cancel.\n\t * @returns Nothing.\n\t */\n\tremove(policyId: string): Promise<void>;\n\n\t/**\n\t * Get a list of the negotiations.\n\t * @param status The state of the negotiations to retrieve.\n\t * @param cursor The cursor to use for pagination.\n\t * @returns A list of negotiations and cursor if there are more entries.\n\t */\n\tquery(\n\t\tstatus?: DataspaceProtocolContractNegotiationStateType,\n\t\tcursor?: string\n\t): Promise<{ items: IPolicyNegotiation[]; cursor?: string }>;\n}\n"]}
1
+ {"version":3,"file":"IPolicyNegotiationAdminPointComponent.js","sourceRoot":"","sources":["../../../../src/models/pnp/IPolicyNegotiationAdminPointComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { DataspaceProtocolContractNegotiationStateType } from \"@twin.org/standards-dataspace-protocol\";\nimport type { IPolicyNegotiation } from \"./IPolicyNegotiation.js\";\n\n/**\n * Interface describing a Policy Negotiation Admin Point (PNAP) contract.\n * Components performs administration tasks on the policy negotiations.\n * @see https://eclipse-dataspace-protocol-base.github.io/DataspaceProtocol/2025-1/#negotiation-protocol\n */\nexport interface IPolicyNegotiationAdminPointComponent extends IComponent {\n\t/**\n\t * Pre-registers a consumer-side negotiation entry.\n\t * id must be the consumer's chosen consumerPid — it becomes the primary key used by offerFromProvider().\n\t * @param id The consumer-side negotiation identifier.\n\t * @returns The negotiation id (same as the caller-supplied id).\n\t */\n\tcreate(id: string): Promise<string>;\n\n\t/**\n\t * Retrieves a policy negotiation.\n\t * @param id The ID of the policy to retrieve the negotiation for.\n\t * @returns The policy negotiation.\n\t */\n\tget(id: string): Promise<IPolicyNegotiation>;\n\n\t/**\n\t * Sets a policy negotiation.\n\t * @param negotiation The updated policy negotiation.\n\t * @returns A promise that resolves when the negotiation has been stored.\n\t */\n\tset(negotiation: IPolicyNegotiation): Promise<void>;\n\n\t/**\n\t * Cancels an ongoing negotiation for a resource.\n\t * @param policyId The ID of the policy to cancel.\n\t * @returns A promise that resolves when the negotiation has been removed.\n\t */\n\tremove(policyId: string): Promise<void>;\n\n\t/**\n\t * Get a list of the negotiations.\n\t * @param status The state of the negotiations to retrieve.\n\t * @param cursor The cursor to use for pagination.\n\t * @returns A list of negotiations and cursor if there are more entries.\n\t */\n\tquery(\n\t\tstatus?: DataspaceProtocolContractNegotiationStateType,\n\t\tcursor?: string\n\t): Promise<{ items: IPolicyNegotiation[]; cursor?: string }>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IPolicyNegotiationPointComponent.js","sourceRoot":"","sources":["../../../../src/models/pnp/IPolicyNegotiationPointComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type {\n\tIDataspaceProtocolContractAgreementMessage,\n\tIDataspaceProtocolContractAgreementVerificationMessage,\n\tIDataspaceProtocolContractNegotiation,\n\tIDataspaceProtocolContractNegotiationError,\n\tIDataspaceProtocolContractNegotiationEventMessage,\n\tIDataspaceProtocolContractNegotiationTerminationMessage,\n\tIDataspaceProtocolContractOfferMessage,\n\tIDataspaceProtocolContractRequestMessage\n} from \"@twin.org/standards-dataspace-protocol\";\n\n/**\n * Interface describing a Policy Negotiation Point (PNP) contract.\n * When receiving a request from another component, the PNP will negotiate the terms\n * of the request and determine the appropriate policies to create.\n * https://eclipse-dataspace-protocol-base.github.io/DataspaceProtocol/2025-1/#negotiation-protocol\n */\nexport interface IPolicyNegotiationPointComponent extends IComponent {\n\t/**\n\t * Get the current state of the negotiation.\n\t * @param id The id of the negotiation to retrieve.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The current state of the negotiation or an error.\n\t */\n\tgetNegotiation(\n\t\tid: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiation | IDataspaceProtocolContractNegotiationError>;\n\n\t/**\n\t * Send a request to a provider.\n\t * @param url The url of the provider to send the request to.\n\t * @param requesterId The id of the requester to use for the request, will use the registered requester to provide update.\n\t * @param odrlOfferId The id of the offer to request.\n\t * @param publicOrigin The public origin url of this PNP service.\n\t * @returns The negotiation id.\n\t */\n\tsendRequestToProvider(\n\t\turl: string,\n\t\trequesterId: string,\n\t\todrlOfferId: string,\n\t\tpublicOrigin: string\n\t): Promise<string>;\n\n\t/**\n\t * Processes an incoming request on a provider from a consumer.\n\t * @param message The negotiation request.\n\t * @param publicOrigin The public origin url of this PNP service.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The current state of the contract negotiation or an error.\n\t */\n\trequestFromConsumer(\n\t\tmessage: IDataspaceProtocolContractRequestMessage,\n\t\tpublicOrigin: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiation | IDataspaceProtocolContractNegotiationError>;\n\n\t/**\n\t * An offer has been received by a consumer.\n\t * @param message The offer being received by the consumer.\n\t * @param publicOrigin The public origin url of this PNP service.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The current state of the contract negotiation or an error.\n\t */\n\tofferFromProvider(\n\t\tmessage: IDataspaceProtocolContractOfferMessage,\n\t\tpublicOrigin: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiation | IDataspaceProtocolContractNegotiationError>;\n\n\t/**\n\t * An agreement has been received by a consumer.\n\t * @param message The agreement message to send.\n\t * @param publicOrigin The public origin url of this PNP service.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The error if there is one.\n\t */\n\tagreementFromProvider(\n\t\tmessage: IDataspaceProtocolContractAgreementMessage,\n\t\tpublicOrigin: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiationError | undefined>;\n\n\t/**\n\t * An agreement verification has been received by a provider.\n\t * @param message The agreement verification message to send.\n\t * @param publicOrigin The public origin url of this PNP service.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The error if there is one.\n\t */\n\tagreementVerificationFromConsumer(\n\t\tmessage: IDataspaceProtocolContractAgreementVerificationMessage,\n\t\tpublicOrigin: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiationError | undefined>;\n\n\t/**\n\t * An event has been received by the provider or consumer.\n\t * @param message The event message to send.\n\t * @param destination The destination is provider or consumer.\n\t * @param publicOrigin The public origin url of this PNP service.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The error if there is one.\n\t */\n\tevent(\n\t\tmessage: IDataspaceProtocolContractNegotiationEventMessage,\n\t\tdestination: \"provider\" | \"consumer\",\n\t\tpublicOrigin: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiationError | undefined>;\n\n\t/**\n\t * A termination message has been received by the provider or consumer.\n\t * @param message The termination message to send.\n\t * @param destination The destination is provider or consumer.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The error if there is one.\n\t */\n\tterminate(\n\t\tmessage: IDataspaceProtocolContractNegotiationTerminationMessage,\n\t\tdestination: \"provider\" | \"consumer\",\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiationError | undefined>;\n}\n"]}
1
+ {"version":3,"file":"IPolicyNegotiationPointComponent.js","sourceRoot":"","sources":["../../../../src/models/pnp/IPolicyNegotiationPointComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type {\n\tIDataspaceProtocolContractAgreementMessage,\n\tIDataspaceProtocolContractAgreementVerificationMessage,\n\tIDataspaceProtocolContractNegotiation,\n\tIDataspaceProtocolContractNegotiationError,\n\tIDataspaceProtocolContractNegotiationEventMessage,\n\tIDataspaceProtocolContractNegotiationTerminationMessage,\n\tIDataspaceProtocolContractOfferMessage,\n\tIDataspaceProtocolContractRequestMessage\n} from \"@twin.org/standards-dataspace-protocol\";\n\n/**\n * Interface describing a Policy Negotiation Point (PNP) contract.\n * When receiving a request from another component, the PNP will negotiate the terms\n * of the request and determine the appropriate policies to create.\n * @see https://eclipse-dataspace-protocol-base.github.io/DataspaceProtocol/2025-1/#negotiation-protocol\n */\nexport interface IPolicyNegotiationPointComponent extends IComponent {\n\t/**\n\t * Get the current state of the negotiation.\n\t * @param id The id of the negotiation to retrieve.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The current state of the negotiation or an error.\n\t */\n\tgetNegotiation(\n\t\tid: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiation | IDataspaceProtocolContractNegotiationError>;\n\n\t/**\n\t * Send a request to a provider.\n\t * @param url The url of the provider to send the request to.\n\t * @param requesterType The type of the requester to use for the request, will use the registered requester to provide update.\n\t * @param odrlOfferId The id of the offer to request.\n\t * @param publicOrigin The public origin url of this PNP service.\n\t * @returns The negotiation id.\n\t */\n\tsendRequestToProvider(\n\t\turl: string,\n\t\trequesterType: string,\n\t\todrlOfferId: string,\n\t\tpublicOrigin: string\n\t): Promise<string>;\n\n\t/**\n\t * Processes an incoming request on a provider from a consumer.\n\t * @param message The negotiation request.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The current state of the contract negotiation or an error.\n\t */\n\trequestFromConsumer(\n\t\tmessage: IDataspaceProtocolContractRequestMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiation | IDataspaceProtocolContractNegotiationError>;\n\n\t/**\n\t * An offer has been received by a consumer.\n\t * @param message The offer being received by the consumer.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The current state of the contract negotiation or an error.\n\t */\n\tofferFromProvider(\n\t\tmessage: IDataspaceProtocolContractOfferMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiation | IDataspaceProtocolContractNegotiationError>;\n\n\t/**\n\t * An agreement has been received by a consumer.\n\t * @param message The agreement message to send.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The error if there is one.\n\t */\n\tagreementFromProvider(\n\t\tmessage: IDataspaceProtocolContractAgreementMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiationError | undefined>;\n\n\t/**\n\t * An agreement verification has been received by a provider.\n\t * @param message The agreement verification message to send.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The error if there is one.\n\t */\n\tagreementVerificationFromConsumer(\n\t\tmessage: IDataspaceProtocolContractAgreementVerificationMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiationError | undefined>;\n\n\t/**\n\t * An event has been received by the provider or consumer.\n\t * @param message The event message to send.\n\t * @param destination The destination is provider or consumer.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The error if there is one.\n\t */\n\tevent(\n\t\tmessage: IDataspaceProtocolContractNegotiationEventMessage,\n\t\tdestination: \"provider\" | \"consumer\",\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiationError | undefined>;\n\n\t/**\n\t * A termination message has been received by the provider or consumer.\n\t * @param message The termination message to send.\n\t * @param destination The destination is provider or consumer.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The error if there is one.\n\t */\n\tterminate(\n\t\tmessage: IDataspaceProtocolContractNegotiationTerminationMessage,\n\t\tdestination: \"provider\" | \"consumer\",\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiationError | undefined>;\n\n\t/**\n\t * Send a terminate message to a consumer at the given callback address.\n\t * Used by stall cleanup to notify consumers that their negotiation has been terminated.\n\t * @param callbackAddress The consumer callback URL to send the termination to.\n\t * @param providerPid The provider negotiation id.\n\t * @param consumerPid The consumer negotiation id.\n\t * @returns Resolves when the terminate message has been sent.\n\t */\n\tsendTerminateToConsumer(\n\t\tcallbackAddress: string,\n\t\tproviderPid: string,\n\t\tconsumerPid: string\n\t): Promise<void>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IPolicyNegotiator.js","sourceRoot":"","sources":["../../../../src/models/pnp/IPolicyNegotiator.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { IOdrlAgreement, IOdrlOffer } from \"@twin.org/standards-w3c-odrl\";\nimport type { IPolicyInformation } from \"../pip/IPolicyInformation.js\";\n\n/**\n * Interface describing a Policy Negotiator.\n */\nexport interface IPolicyNegotiator extends IComponent {\n\t/**\n\t * Determines if the negotiator supports the given offer.\n\t * @param offer The offer to check.\n\t * @returns Sets the supports flag if it can be offered, and the interventionRequired flag if manual agreement is needed.\n\t */\n\tsupportsOffer(offer: IOdrlOffer): boolean;\n\n\t/**\n\t * Handle the offer.\n\t * @param offer The offer to check.\n\t * @param information Information provided by the requester to determine if a policy can be created.\n\t * @returns Sets the accepted flag if it can be offered, and the interventionRequired flag if manual agreement is needed.\n\t */\n\thandleOffer(\n\t\toffer: IOdrlOffer,\n\t\tinformation?: IPolicyInformation\n\t): Promise<{\n\t\taccepted: boolean;\n\t\tinterventionRequired: boolean;\n\t}>;\n\n\t/**\n\t * Create an agreement based on the offer.\n\t * @param offer The offer to create the agreement from.\n\t * @param information Information provided by the requester to aid in the creation of the agreement.\n\t * @returns The agreement created from the offer or undefined if an agreement could not be created.\n\t */\n\tcreateAgreement(\n\t\toffer: IOdrlOffer,\n\t\tinformation?: IPolicyInformation\n\t): Promise<IOdrlAgreement | undefined>;\n}\n"]}
1
+ {"version":3,"file":"IPolicyNegotiator.js","sourceRoot":"","sources":["../../../../src/models/pnp/IPolicyNegotiator.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type {\n\tIDataspaceProtocolAgreement,\n\tIDataspaceProtocolOffer\n} from \"@twin.org/standards-dataspace-protocol\";\nimport type { IOdrlParty } from \"@twin.org/standards-w3c-odrl\";\nimport type { IRightsManagementInformation } from \"../IRightsManagementInformation.js\";\n\n/**\n * Interface describing a Policy Negotiator.\n */\nexport interface IPolicyNegotiator extends IComponent {\n\t/**\n\t * Determines if the negotiator supports the given offer.\n\t * @param offer The offer to check.\n\t * @returns True if the negotiator supports the given offer.\n\t */\n\tsupportsOffer(offer: IDataspaceProtocolOffer): boolean;\n\n\t/**\n\t * Handle the offer.\n\t * @param offer The offer to check.\n\t * @param information Information provided by the requester to determine if a policy can be created.\n\t * @returns Sets the accepted flag if it can be offered, and the interventionRequired flag if manual agreement is needed.\n\t */\n\thandleOffer(\n\t\toffer: IDataspaceProtocolOffer,\n\t\tinformation?: IRightsManagementInformation\n\t): Promise<{\n\t\taccepted: boolean;\n\t\tinterventionRequired: boolean;\n\t}>;\n\n\t/**\n\t * Create an agreement based on the offer.\n\t * @param offer The offer to create the agreement from.\n\t * @param assignee The assignee of the agreement.\n\t * @param information Information provided by the requester to aid in the creation of the agreement.\n\t * @returns The agreement created from the offer or undefined if an agreement could not be created.\n\t */\n\tcreateAgreement(\n\t\toffer: IDataspaceProtocolOffer,\n\t\tassignee: string | IOdrlParty,\n\t\tinformation?: IRightsManagementInformation\n\t): Promise<IDataspaceProtocolAgreement | undefined>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IPolicyRequester.js","sourceRoot":"","sources":["../../../../src/models/pnp/IPolicyRequester.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { IOdrlAgreement, IOdrlOffer } from \"@twin.org/standards-w3c-odrl\";\n\n/**\n * Interface describing a Policy Requester.\n */\nexport interface IPolicyRequester extends IComponent {\n\t/**\n\t * The unique id of the requester.\n\t * @returns The requester id.\n\t */\n\trequesterId(): string;\n\n\t/**\n\t * A policy has been offered by a provider, let the requester know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @param offer The offer sent by the provider.\n\t * @returns True if the offer was accepted, false otherwise.\n\t */\n\toffer(negotiationId: string, offer: IOdrlOffer): Promise<boolean>;\n\n\t/**\n\t * A policy agreement has been sent by a provider, let the requester know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @param agreement The agreement sent by the provider.\n\t * @returns True if the agreement was accepted, false otherwise.\n\t */\n\tagreement(negotiationId: string, agreement: IOdrlAgreement): Promise<boolean>;\n\n\t/**\n\t * A policy finalisation has been sent by a provider, let the requester know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @returns Nothing.\n\t */\n\tfinalised(negotiationId: string): Promise<void>;\n\n\t/**\n\t * A policy termination has been sent by a provider, let the requester know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @returns Nothing.\n\t */\n\tterminated(negotiationId: string): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"IPolicyRequester.js","sourceRoot":"","sources":["../../../../src/models/pnp/IPolicyRequester.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { JsonLdObjectWithOptionalContext } from \"@twin.org/data-json-ld\";\nimport type {\n\tIDataspaceProtocolAgreement,\n\tIDataspaceProtocolOffer\n} from \"@twin.org/standards-dataspace-protocol\";\n\n/**\n * Interface describing a Policy Requester.\n */\nexport interface IPolicyRequester extends IComponent {\n\t/**\n\t * A policy has been offered by a provider, let the requester know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @param offer The offer sent by the provider.\n\t * @returns True if the offer was accepted, false otherwise.\n\t */\n\toffer(\n\t\tnegotiationId: string,\n\t\toffer: JsonLdObjectWithOptionalContext<IDataspaceProtocolOffer>\n\t): Promise<boolean>;\n\n\t/**\n\t * A policy agreement has been sent by a provider, let the requester know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @param agreement The agreement sent by the provider.\n\t * @returns True if the agreement was accepted, false otherwise.\n\t */\n\tagreement(\n\t\tnegotiationId: string,\n\t\tagreement: JsonLdObjectWithOptionalContext<IDataspaceProtocolAgreement>\n\t): Promise<boolean>;\n\n\t/**\n\t * A policy finalisation has been sent by a provider, let the requester know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @returns A promise that resolves when the finalisation has been processed.\n\t */\n\tfinalised(negotiationId: string): Promise<void>;\n\n\t/**\n\t * A policy termination has been sent by a provider, let the requester know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @returns A promise that resolves when the termination has been processed.\n\t */\n\tterminated(negotiationId: string): Promise<void>;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ /**
4
+ * Minimal inline JSON-LD context for PAP-managed schema.org policy metadata terms.
5
+ * Avoids importing the full schema.org vocabulary, which collides with ODRL terms such as Offer and target.
6
+ */
7
+ export const POLICY_METADATA_CONTEXT = {
8
+ /**
9
+ * schema.org dateCreated term IRI.
10
+ */
11
+ dateCreated: "https://schema.org/dateCreated",
12
+ /**
13
+ * schema.org dateModified term IRI.
14
+ */
15
+ dateModified: "https://schema.org/dateModified"
16
+ };
17
+ //# sourceMappingURL=policyMetadataContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policyMetadataContext.js","sourceRoot":"","sources":["../../../src/models/policyMetadataContext.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC;;OAEG;IACH,WAAW,EAAE,gCAAgC;IAC7C;;OAEG;IACH,YAAY,EAAE,iCAAiC;CACtC,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Minimal inline JSON-LD context for PAP-managed schema.org policy metadata terms.\n * Avoids importing the full schema.org vocabulary, which collides with ODRL terms such as Offer and target.\n */\nexport const POLICY_METADATA_CONTEXT = {\n\t/**\n\t * schema.org dateCreated term IRI.\n\t */\n\tdateCreated: \"https://schema.org/dateCreated\",\n\t/**\n\t * schema.org dateModified term IRI.\n\t */\n\tdateModified: \"https://schema.org/dateModified\"\n} as const;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IPolicyExecutionAction.js","sourceRoot":"","sources":["../../../../src/models/pxp/IPolicyExecutionAction.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { IOdrlPolicy } from \"@twin.org/standards-w3c-odrl\";\nimport type { IPolicyLocator } from \"../IPolicyLocator.js\";\nimport type { IPolicyDecision } from \"../pdp/IPolicyDecision.js\";\nimport type { PolicyDecisionStage } from \"../pdp/policyDecisionStage.js\";\n\n/**\n * Interface for policy execution actions.\n */\nexport interface IPolicyExecutionAction extends IComponent {\n\t/**\n\t * Which stages should the action be executed at.\n\t * @returns List of stages.\n\t */\n\tsupportedStages(): PolicyDecisionStage[];\n\n\t/**\n\t * Execute function type for policy actions.\n\t * @param stage The stage of the policy decision.\n\t * @param locator The locator to find relevant policies.\n\t * @param policies The policies that apply to the data.\n\t * @param decisions The decisions made by the PDP.\n\t * @param data The data to process.\n\t * @returns A promise that resolves when the action is complete.\n\t */\n\texecute<D = unknown>(\n\t\tstage: PolicyDecisionStage,\n\t\tlocator: IPolicyLocator,\n\t\tpolicies?: IOdrlPolicy[],\n\t\tdecisions?: IPolicyDecision[],\n\t\tdata?: D\n\t): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"IPolicyExecutionAction.js","sourceRoot":"","sources":["../../../../src/models/pxp/IPolicyExecutionAction.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { OdrlActionType } from \"@twin.org/standards-w3c-odrl\";\nimport type { IRightsManagementPolicy } from \"../IRightsManagementPolicy.js\";\nimport type { IPolicyDecision } from \"../pdp/IPolicyDecision.js\";\nimport type { PolicyDecisionStage } from \"../pdp/policyDecisionStage.js\";\n\n/**\n * Interface for policy execution actions.\n */\nexport interface IPolicyExecutionAction extends IComponent {\n\t/**\n\t * Which stages should the action be executed at.\n\t * @returns List of stages.\n\t */\n\tsupportedStages(): PolicyDecisionStage[];\n\n\t/**\n\t * Execute function type for policy actions.\n\t * @param policy The policy that applied to the data.\n\t * @param decisions The decisions made by the PDP.\n\t * @param data The data to process.\n\t * @param action The action that was evaluated.\n\t * @param stage The stage of the policy decision.\n\t * @returns A promise that resolves when the action is complete.\n\t */\n\texecute<D = unknown>(\n\t\tpolicy: IRightsManagementPolicy,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata: D | undefined,\n\t\taction: OdrlActionType | string | undefined,\n\t\tstage: PolicyDecisionStage\n\t): Promise<void>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IPolicyExecutionPointComponent.js","sourceRoot":"","sources":["../../../../src/models/pxp/IPolicyExecutionPointComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { IOdrlPolicy } from \"@twin.org/standards-w3c-odrl\";\nimport type { IPolicyLocator } from \"../IPolicyLocator.js\";\nimport type { IPolicyDecision } from \"../pdp/IPolicyDecision.js\";\nimport type { PolicyDecisionStage } from \"../pdp/policyDecisionStage.js\";\n\n/**\n * Interface describing a Policy Execution Point (PXP) contract.\n * When a decision is made by the Policy Decision Point (PDP),\n * the Policy Execution Point (PXP) will execute any\n * registered actions based on the decision.\n */\nexport interface IPolicyExecutionPointComponent extends IComponent {\n\t/**\n\t * Execute actions based on the PDP's decisions.\n\t * @param stage The stage at which the PXP is executed in the PDP.\n\t * @param locator The locator to find relevant policies.\n\t * @param policies The policies that apply to the data.\n\t * @param decisions The decisions made by the PDP.\n\t * @param data The data used in the decision by the PDP.\n\t * @returns Nothing.\n\t */\n\texecuteActions<D = unknown>(\n\t\tstage: PolicyDecisionStage,\n\t\tlocator: IPolicyLocator,\n\t\tpolicies?: IOdrlPolicy[],\n\t\tdecisions?: IPolicyDecision[],\n\t\tdata?: D\n\t): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"IPolicyExecutionPointComponent.js","sourceRoot":"","sources":["../../../../src/models/pxp/IPolicyExecutionPointComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { OdrlActionType } from \"@twin.org/standards-w3c-odrl\";\nimport type { IRightsManagementPolicy } from \"../IRightsManagementPolicy.js\";\nimport type { IPolicyDecision } from \"../pdp/IPolicyDecision.js\";\nimport type { PolicyDecisionStage } from \"../pdp/policyDecisionStage.js\";\n\n/**\n * Interface describing a Policy Execution Point (PXP) contract.\n * When a decision is made by the Policy Decision Point (PDP),\n * the Policy Execution Point (PXP) will execute any\n * registered actions based on the decision.\n */\nexport interface IPolicyExecutionPointComponent extends IComponent {\n\t/**\n\t * Execute actions based on the PDP's decisions.\n\t * @param policy The policy that applied to the data.\n\t * @param decisions The decisions made by the PDP.\n\t * @param data The data used in the decision by the PDP.\n\t * @param action The action that was evaluated.\n\t * @param stage The stage at which the PXP is executed in the PDP.\n\t * @returns A promise that resolves when all registered actions have been executed.\n\t */\n\texecuteActions<D = unknown>(\n\t\tpolicy: IRightsManagementPolicy,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata: D | undefined,\n\t\taction: OdrlActionType | string | undefined,\n\t\tstage: PolicyDecisionStage\n\t): Promise<void>;\n}\n"]}
@@ -1,120 +1,247 @@
1
- // Copyright 2025 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- import { Is } from "@twin.org/core";
1
+ import { ArrayHelper, GeneralError, Guards, Is, ObjectHelper } from "@twin.org/core";
4
2
  /**
5
3
  * Helper methods for Odrl Policies.
6
4
  */
7
5
  export class OdrlPolicyHelper {
8
6
  /**
9
- * Find the expiration date of the policy.
10
- * @param policy The policy to check.
11
- * @param assetType The type of the asset, if undefined will match any asset type.
12
- * @param action The action to check, if undefined will match any action.
13
- * @returns The expiration date of the policy, or undefined if not found.
7
+ * The class name of the Policy Administration Point Service.
14
8
  */
15
- static findExpirationDate(policy, assetType, action) {
16
- if (Is.arrayValue(policy.permission)) {
17
- for (const permission of policy.permission) {
18
- const matchesPermission = OdrlPolicyHelper.matchTargetAndAction(permission.target, permission.action, {
19
- assetType,
20
- action
21
- });
22
- if (matchesPermission && Is.arrayValue(permission.constraint)) {
23
- for (const constraint of permission.constraint) {
24
- if (constraint.leftOperand === "dateTime" &&
25
- constraint.operator === "lteq" &&
26
- Is.dateTimeString(constraint.rightOperand)) {
27
- return constraint.rightOperand;
9
+ static CLASS_NAME = "OdrlPolicyHelper";
10
+ /**
11
+ * Get the UID of an ODRL policy or related object if available.
12
+ * @param object The ODRL policy or related object to get the UID from.
13
+ * @returns The UID of the object if available, otherwise undefined.
14
+ */
15
+ static getUid(object) {
16
+ return ObjectHelper.extractProperty(object, ["@id", "id", "uid"], false);
17
+ }
18
+ /**
19
+ * Get the type of an ODRL policy or related object if available.
20
+ * @param object The ODRL policy or related object to get the type from.
21
+ * @returns The type of the object if available, otherwise undefined.
22
+ */
23
+ static getType(object) {
24
+ return ObjectHelper.extractProperty(object, ["@type", "type"], false);
25
+ }
26
+ /**
27
+ * Extract assignee identity from policy.
28
+ * @param policy The policy to extract the assignee from.
29
+ * @returns Assignee id.
30
+ * @throws GeneralError if assignee is missing or invalid.
31
+ */
32
+ static extractAssigneeIdentity(policy) {
33
+ if (Is.empty(policy.assignee)) {
34
+ throw new GeneralError(OdrlPolicyHelper.CLASS_NAME, "policyMissingAssignee", {
35
+ policyType: OdrlPolicyHelper.getType(policy) ?? "",
36
+ policyId: OdrlPolicyHelper.getUid(policy) ?? ""
37
+ });
38
+ }
39
+ const assignees = ArrayHelper.fromObjectOrArray(policy.assignee);
40
+ const assigneeIds = [];
41
+ for (const assignee of assignees) {
42
+ const assigneeId = Is.string(assignee) ? assignee : OdrlPolicyHelper.getUid(assignee);
43
+ Guards.stringValue(OdrlPolicyHelper.CLASS_NAME, "assigneeId", assigneeId);
44
+ assigneeIds.push(assigneeId);
45
+ }
46
+ return assigneeIds.length <= 1 ? assigneeIds[0] : assigneeIds;
47
+ }
48
+ /**
49
+ * Extract assigner identity from policy.
50
+ * @param policy The policy to extract the assigner from.
51
+ * @returns Assigner id.
52
+ * @throws GeneralError if assigner is missing or invalid.
53
+ */
54
+ static extractAssignerIdentity(policy) {
55
+ if (Is.empty(policy.assigner)) {
56
+ throw new GeneralError(OdrlPolicyHelper.CLASS_NAME, "policyMissingAssigner", {
57
+ policyType: OdrlPolicyHelper.getType(policy) ?? "",
58
+ policyId: OdrlPolicyHelper.getUid(policy) ?? ""
59
+ });
60
+ }
61
+ const assigners = ArrayHelper.fromObjectOrArray(policy.assigner);
62
+ const assignerIds = [];
63
+ for (const assigner of assigners) {
64
+ const assignerId = Is.string(assigner) ? assigner : OdrlPolicyHelper.getUid(assigner);
65
+ Guards.stringValue(OdrlPolicyHelper.CLASS_NAME, "assignerId", assignerId);
66
+ assignerIds.push(assignerId);
67
+ }
68
+ return assignerIds.length <= 1 ? assignerIds[0] : assignerIds;
69
+ }
70
+ /**
71
+ * Normalize party value(s) into identifier strings when possible.
72
+ * Handles single parties or arrays of parties by returning all discovered identifiers.
73
+ * @param party The party to normalize.
74
+ * @returns The party identifiers, or undefined when not available.
75
+ */
76
+ static getPartyIds(party) {
77
+ const ids = [];
78
+ if (Is.empty(party)) {
79
+ return ids;
80
+ }
81
+ if (Is.stringValue(party)) {
82
+ ids.push(party);
83
+ return ids;
84
+ }
85
+ if (Is.arrayValue(party)) {
86
+ for (const item of party) {
87
+ const childIds = OdrlPolicyHelper.getPartyIds(item);
88
+ if (!Is.empty(childIds)) {
89
+ for (const childId of childIds) {
90
+ if (!ids.includes(childId)) {
91
+ ids.push(childId);
28
92
  }
29
93
  }
30
94
  }
31
95
  }
96
+ return ids;
32
97
  }
98
+ if (Is.object(party)) {
99
+ const uid = OdrlPolicyHelper.getUid(party);
100
+ if (Is.stringValue(uid) && !ids.includes(uid)) {
101
+ ids.push(uid);
102
+ }
103
+ }
104
+ return ids;
33
105
  }
34
106
  /**
35
- * Match the target to the requested asset type.
36
- * @param target The target to match.
37
- * @param matchAssetType The asset type to match.
38
- * @param matchResourceId The resource id to match.
39
- * @returns True if the target is empty, the target matches the requested asset, false otherwise.
107
+ * Get the dataset targets from policy.
108
+ * @param policy The policy to extract the dataset targets from.
109
+ * @returns Top-level targets (deduped).
40
110
  */
41
- static matchAsset(target, matchAssetType, matchResourceId) {
42
- if (Is.empty(target) || Is.empty(matchAssetType)) {
43
- return true;
44
- }
45
- if (Is.arrayValue(target)) {
46
- return target.some(t => OdrlPolicyHelper.matchAsset(t, matchAssetType));
111
+ static getDatasetTargets(policy) {
112
+ const targetIds = [];
113
+ const policyTargets = ArrayHelper.fromObjectOrArray(policy.target ?? []);
114
+ for (const target of policyTargets) {
115
+ OdrlPolicyHelper.collectTarget(target, targetIds);
47
116
  }
48
- if (Is.stringValue(target)) {
49
- return target === matchAssetType;
50
- }
51
- // TODO: This currently only handles the simple case of matching a single asset type.
52
- // we need further processing if the target is more complex.
53
- // we also need to support the resource id matching.
54
- return false;
117
+ return Array.from(new Set(targetIds));
55
118
  }
56
119
  /**
57
- * Match the action to the asset type.
58
- * @param action The action to match.
59
- * @param matchAction The action to match.
60
- * @returns True if the action is empty, the action matches the asset type, false otherwise.
120
+ * Get targets from policy.
121
+ * Walks both the policy-level target field and the target field on every
122
+ * permission, prohibition, and obligation rule so that policies that store
123
+ * their target exclusively on a rule are correctly indexed for query().
124
+ * @param policy The policy to extract the targets from.
125
+ * @returns Targets.
61
126
  */
62
- static matchAction(action, matchAction) {
63
- if (Is.empty(action) || Is.empty(matchAction)) {
64
- return true;
127
+ static getTargets(policy) {
128
+ const targetIds = OdrlPolicyHelper.getDatasetTargets(policy);
129
+ const rules = OdrlPolicyHelper.collectRules(policy);
130
+ for (const rule of rules) {
131
+ const ruleTargets = ArrayHelper.fromObjectOrArray(rule.target ?? []);
132
+ for (const target of ruleTargets) {
133
+ OdrlPolicyHelper.collectTarget(target, targetIds);
134
+ }
65
135
  }
66
- if (Is.arrayValue(action)) {
67
- return action.some(a => OdrlPolicyHelper.matchAction(a, matchAction));
136
+ return Array.from(new Set(targetIds));
137
+ }
138
+ /**
139
+ * Get actions from policy.
140
+ * Walks both the policy-level action field and the action field on every
141
+ * permission, prohibition, and obligation rule so that policies that store
142
+ * their action exclusively on a rule are correctly indexed for query().
143
+ * @param policy The policy to extract the actions from.
144
+ * @returns Actions.
145
+ */
146
+ static getActions(policy) {
147
+ const actions = [];
148
+ const policyActions = ArrayHelper.fromObjectOrArray(policy.action ?? []);
149
+ for (const action of policyActions) {
150
+ OdrlPolicyHelper.collectAction(action, actions);
68
151
  }
69
- if (Is.stringValue(action)) {
70
- return action === matchAction;
152
+ const rules = OdrlPolicyHelper.collectRules(policy);
153
+ for (const rule of rules) {
154
+ const ruleActions = ArrayHelper.fromObjectOrArray(rule.action ?? []);
155
+ for (const action of ruleActions) {
156
+ OdrlPolicyHelper.collectAction(action, actions);
157
+ }
71
158
  }
72
- // TODO: This currently only handles the simple case of matching a single action type.
73
- // we need further processing if the action is more complex.
74
- return false;
159
+ return Array.from(new Set(actions));
75
160
  }
76
161
  /**
77
- * Match the assignee.
78
- * @param assignee The assignee to match.
79
- * @param matchAssignee The assignee to match.
80
- * @returns True if the assignee is empty, the assignee matches the asset type, false otherwise.
162
+ * Does the policy match.
163
+ * @param policy The policy to try and match.
164
+ * @param options The matching options.
165
+ * @param options.assignee The assignee to match.
166
+ * @param options.assigner The assigner to match.
167
+ * @param options.target The target to match.
168
+ * @param options.action The action to match.
169
+ * @returns True if the policy matches.
81
170
  */
82
- static matchAssignee(assignee, matchAssignee) {
83
- if (Is.empty(assignee) || Is.empty(matchAssignee)) {
84
- return true;
171
+ static matchPolicy(policy, options) {
172
+ if (Is.empty(policy)) {
173
+ return false;
174
+ }
175
+ if (Is.stringValue(options.assignee)) {
176
+ const assigneeIds = OdrlPolicyHelper.getPartyIds(policy.assignee);
177
+ if (!assigneeIds.includes(options.assignee)) {
178
+ return false;
179
+ }
180
+ }
181
+ if (Is.stringValue(options.assigner)) {
182
+ const assignerIds = OdrlPolicyHelper.getPartyIds(policy.assigner);
183
+ if (!assignerIds.includes(options.assigner)) {
184
+ return false;
185
+ }
186
+ }
187
+ if (Is.stringValue(options.target)) {
188
+ const targets = OdrlPolicyHelper.getTargets(policy);
189
+ if (!targets.includes(options.target)) {
190
+ return false;
191
+ }
85
192
  }
86
- if (Is.stringValue(assignee)) {
87
- return assignee === matchAssignee;
193
+ if (Is.stringValue(options.action)) {
194
+ const actions = OdrlPolicyHelper.getActions(policy);
195
+ if (!actions.includes(options.action)) {
196
+ return false;
197
+ }
88
198
  }
89
- // TODO: This currently only handles the simple case of matching a single assignee.
90
- // we need further processing if the assignee is more complex.
91
- return false;
199
+ return true;
92
200
  }
93
201
  /**
94
- * Match the target and action to the requested asset type and action.
95
- * @param target The target to match.
96
- * @param action The action to match.
97
- * @param locator The locator to match resource id if provided.
98
- * @returns True if the target and action match the requested asset type and action, false otherwise.
202
+ * Collect all rule objects (permission, prohibition, obligation) from a policy.
203
+ * @param policy The policy to collect rules from.
204
+ * @returns Flattened array of all rules.
205
+ * @internal
99
206
  */
100
- static matchTargetAndAction(target, action, locator) {
101
- const assetTypeMatch = OdrlPolicyHelper.matchAsset(target, locator?.assetType, locator?.resourceId);
102
- const actionMatch = OdrlPolicyHelper.matchAction(action, locator?.action);
103
- return assetTypeMatch && actionMatch;
207
+ static collectRules(policy) {
208
+ const rules = [];
209
+ rules.push(...ArrayHelper.fromObjectOrArray(policy.permission ?? []), ...ArrayHelper.fromObjectOrArray(policy.prohibition ?? []), ...ArrayHelper.fromObjectOrArray(policy.obligation ?? []));
210
+ return rules;
104
211
  }
105
212
  /**
106
- * Match the complete locator.
107
- * @param assignee The assignee to match.
108
- * @param target The target to match.
109
- * @param action The action to match.
110
- * @param locator The locator to match resource id if provided.
111
- * @returns True if the complete locator matches, false otherwise.
213
+ * Extract a target string from a target value and push it to the accumulator.
214
+ * @param target The target value to extract from.
215
+ * @param accumulator The array to push the target string into.
216
+ * @internal
112
217
  */
113
- static matchLocator(assignee, target, action, locator) {
114
- const assetTypeMatch = OdrlPolicyHelper.matchAsset(target, locator?.assetType, locator?.resourceId);
115
- const assigneeMatch = OdrlPolicyHelper.matchAssignee(assignee, locator?.assignee);
116
- const actionMatch = OdrlPolicyHelper.matchAction(action, locator?.action);
117
- return assetTypeMatch && assigneeMatch && actionMatch;
218
+ static collectTarget(target, accumulator) {
219
+ if (Is.object(target)) {
220
+ const uid = OdrlPolicyHelper.getUid(target);
221
+ if (Is.stringValue(uid)) {
222
+ accumulator.push(uid);
223
+ }
224
+ }
225
+ else if (Is.stringValue(target)) {
226
+ accumulator.push(target);
227
+ }
228
+ }
229
+ /**
230
+ * Extract an action string from an action value and push it to the accumulator.
231
+ * @param action The action value to extract from.
232
+ * @param accumulator The array to push the action string into.
233
+ * @internal
234
+ */
235
+ static collectAction(action, accumulator) {
236
+ if (Is.object(action)) {
237
+ const uid = OdrlPolicyHelper.getUid(action);
238
+ if (Is.stringValue(uid)) {
239
+ accumulator.push(uid);
240
+ }
241
+ }
242
+ else if (Is.stringValue(action)) {
243
+ accumulator.push(action);
244
+ }
118
245
  }
119
246
  }
120
247
  //# sourceMappingURL=odrlPolicyHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"odrlPolicyHelper.js","sourceRoot":"","sources":["../../../src/utils/odrlPolicyHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAIpC;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC5B;;;;;;OAMG;IACI,MAAM,CAAC,kBAAkB,CAC/B,MAAmB,EACnB,SAAkB,EAClB,MAAe;QAEf,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YACtC,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC5C,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,oBAAoB,CAC9D,UAAU,CAAC,MAAM,EACjB,UAAU,CAAC,MAAM,EACjB;oBACC,SAAS;oBACT,MAAM;iBACN,CACD,CAAC;gBACF,IAAI,iBAAiB,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC/D,KAAK,MAAM,UAAU,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;wBAChD,IACC,UAAU,CAAC,WAAW,KAAK,UAAU;4BACrC,UAAU,CAAC,QAAQ,KAAK,MAAM;4BAC9B,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,YAAY,CAAC,EACzC,CAAC;4BACF,OAAO,UAAU,CAAC,YAAsB,CAAC;wBA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-License-Identifier: Apache-2.0.\nimport { Is } from \"@twin.org/core\";\nimport type { IOdrlPolicy } from \"@twin.org/standards-w3c-odrl\";\nimport type { IPolicyLocator } from \"../models/IPolicyLocator.js\";\n\n/**\n * Helper methods for Odrl Policies.\n */\nexport class OdrlPolicyHelper {\n\t/**\n\t * Find the expiration date of the policy.\n\t * @param policy The policy to check.\n\t * @param assetType The type of the asset, if undefined will match any asset type.\n\t * @param action The action to check, if undefined will match any action.\n\t * @returns The expiration date of the policy, or undefined if not found.\n\t */\n\tpublic static findExpirationDate(\n\t\tpolicy: IOdrlPolicy,\n\t\tassetType?: string,\n\t\taction?: string\n\t): string | undefined {\n\t\tif (Is.arrayValue(policy.permission)) {\n\t\t\tfor (const permission of policy.permission) {\n\t\t\t\tconst matchesPermission = OdrlPolicyHelper.matchTargetAndAction(\n\t\t\t\t\tpermission.target,\n\t\t\t\t\tpermission.action,\n\t\t\t\t\t{\n\t\t\t\t\t\tassetType,\n\t\t\t\t\t\taction\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tif (matchesPermission && Is.arrayValue(permission.constraint)) {\n\t\t\t\t\tfor (const constraint of permission.constraint) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tconstraint.leftOperand === \"dateTime\" &&\n\t\t\t\t\t\t\tconstraint.operator === \"lteq\" &&\n\t\t\t\t\t\t\tIs.dateTimeString(constraint.rightOperand)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn constraint.rightOperand as string;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Match the target to the requested asset type.\n\t * @param target The target to match.\n\t * @param matchAssetType The asset type to match.\n\t * @param matchResourceId The resource id to match.\n\t * @returns True if the target is empty, the target matches the requested asset, false otherwise.\n\t */\n\tpublic static matchAsset(\n\t\ttarget?: IOdrlPolicy[\"target\"],\n\t\tmatchAssetType?: string,\n\t\tmatchResourceId?: string\n\t): boolean {\n\t\tif (Is.empty(target) || Is.empty(matchAssetType)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (Is.arrayValue(target)) {\n\t\t\treturn target.some(t => OdrlPolicyHelper.matchAsset(t, matchAssetType));\n\t\t}\n\n\t\tif (Is.stringValue(target)) {\n\t\t\treturn target === matchAssetType;\n\t\t}\n\n\t\t// TODO: This currently only handles the simple case of matching a single asset type.\n\t\t// we need further processing if the target is more complex.\n\t\t// we also need to support the resource id matching.\n\t\treturn false;\n\t}\n\n\t/**\n\t * Match the action to the asset type.\n\t * @param action The action to match.\n\t * @param matchAction The action to match.\n\t * @returns True if the action is empty, the action matches the asset type, false otherwise.\n\t */\n\tpublic static matchAction(action?: IOdrlPolicy[\"action\"], matchAction?: string): boolean {\n\t\tif (Is.empty(action) || Is.empty(matchAction)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (Is.arrayValue(action)) {\n\t\t\treturn action.some(a => OdrlPolicyHelper.matchAction(a, matchAction));\n\t\t}\n\n\t\tif (Is.stringValue(action)) {\n\t\t\treturn action === matchAction;\n\t\t}\n\n\t\t// TODO: This currently only handles the simple case of matching a single action type.\n\t\t// we need further processing if the action is more complex.\n\t\treturn false;\n\t}\n\n\t/**\n\t * Match the assignee.\n\t * @param assignee The assignee to match.\n\t * @param matchAssignee The assignee to match.\n\t * @returns True if the assignee is empty, the assignee matches the asset type, false otherwise.\n\t */\n\tpublic static matchAssignee(assignee?: IOdrlPolicy[\"assignee\"], matchAssignee?: string): boolean {\n\t\tif (Is.empty(assignee) || Is.empty(matchAssignee)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (Is.stringValue(assignee)) {\n\t\t\treturn assignee === matchAssignee;\n\t\t}\n\n\t\t// TODO: This currently only handles the simple case of matching a single assignee.\n\t\t// we need further processing if the assignee is more complex.\n\t\treturn false;\n\t}\n\n\t/**\n\t * Match the target and action to the requested asset type and action.\n\t * @param target The target to match.\n\t * @param action The action to match.\n\t * @param locator The locator to match resource id if provided.\n\t * @returns True if the target and action match the requested asset type and action, false otherwise.\n\t */\n\tpublic static matchTargetAndAction(\n\t\ttarget?: IOdrlPolicy[\"target\"],\n\t\taction?: IOdrlPolicy[\"action\"],\n\t\tlocator?: Omit<IPolicyLocator, \"assignee\">\n\t): boolean {\n\t\tconst assetTypeMatch = OdrlPolicyHelper.matchAsset(\n\t\t\ttarget,\n\t\t\tlocator?.assetType,\n\t\t\tlocator?.resourceId\n\t\t);\n\t\tconst actionMatch = OdrlPolicyHelper.matchAction(action, locator?.action);\n\t\treturn assetTypeMatch && actionMatch;\n\t}\n\n\t/**\n\t * Match the complete locator.\n\t * @param assignee The assignee to match.\n\t * @param target The target to match.\n\t * @param action The action to match.\n\t * @param locator The locator to match resource id if provided.\n\t * @returns True if the complete locator matches, false otherwise.\n\t */\n\tpublic static matchLocator(\n\t\tassignee?: IOdrlPolicy[\"assignee\"],\n\t\ttarget?: IOdrlPolicy[\"target\"],\n\t\taction?: IOdrlPolicy[\"action\"],\n\t\tlocator?: IPolicyLocator\n\t): boolean {\n\t\tconst assetTypeMatch = OdrlPolicyHelper.matchAsset(\n\t\t\ttarget,\n\t\t\tlocator?.assetType,\n\t\t\tlocator?.resourceId\n\t\t);\n\t\tconst assigneeMatch = OdrlPolicyHelper.matchAssignee(assignee, locator?.assignee);\n\t\tconst actionMatch = OdrlPolicyHelper.matchAction(action, locator?.action);\n\t\treturn assetTypeMatch && assigneeMatch && actionMatch;\n\t}\n}\n"]}
1
+ {"version":3,"file":"odrlPolicyHelper.js","sourceRoot":"","sources":["../../../src/utils/odrlPolicyHelper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAiBrF;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC5B;;OAEG;IACI,MAAM,CAAU,UAAU,sBAAsC;IAEvE;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,MAA0B;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C,MAAM,CAAC,CAAC;YAC5C,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvB,CAAC;QACF,CAAC;aAAM,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ObjectOrArray } from \"@twin.org/core\";\nimport { ArrayHelper, GeneralError, Guards, Is, ObjectHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IDataspaceProtocolPolicy } from \"@twin.org/standards-dataspace-protocol\";\nimport type {\n\tIOdrlAction,\n\tIOdrlAsset,\n\tIOdrlAssetCollection,\n\tIOdrlDuty,\n\tIOdrlParty,\n\tIOdrlPartyCollection,\n\tIOdrlPermission,\n\tIOdrlProhibition,\n\tIOdrlRule,\n\tOdrlActionType\n} from \"@twin.org/standards-w3c-odrl\";\nimport type { IRightsManagementPolicy } from \"../models/IRightsManagementPolicy.js\";\n\n/**\n * Helper methods for Odrl Policies.\n */\nexport class OdrlPolicyHelper {\n\t/**\n\t * The class name of the Policy Administration Point Service.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<OdrlPolicyHelper>();\n\n\t/**\n\t * Get the UID of an ODRL policy or related object if available.\n\t * @param object The ODRL policy or related object to get the UID from.\n\t * @returns The UID of the object if available, otherwise undefined.\n\t */\n\tpublic static getUid(object: object | undefined): string | undefined {\n\t\treturn ObjectHelper.extractProperty<string>(object, [\"@id\", \"id\", \"uid\"], false);\n\t}\n\n\t/**\n\t * Get the type of an ODRL policy or related object if available.\n\t * @param object The ODRL policy or related object to get the type from.\n\t * @returns The type of the object if available, otherwise undefined.\n\t */\n\tpublic static getType(object: object | undefined): string | undefined {\n\t\treturn ObjectHelper.extractProperty<string>(object, [\"@type\", \"type\"], false);\n\t}\n\n\t/**\n\t * Extract assignee identity from policy.\n\t * @param policy The policy to extract the assignee from.\n\t * @returns Assignee id.\n\t * @throws GeneralError if assignee is missing or invalid.\n\t */\n\tpublic static extractAssigneeIdentity(policy: IDataspaceProtocolPolicy): ObjectOrArray<string> {\n\t\tif (Is.empty(policy.assignee)) {\n\t\t\tthrow new GeneralError(OdrlPolicyHelper.CLASS_NAME, \"policyMissingAssignee\", {\n\t\t\t\tpolicyType: OdrlPolicyHelper.getType(policy) ?? \"\",\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\"\n\t\t\t});\n\t\t}\n\n\t\tconst assignees = ArrayHelper.fromObjectOrArray(policy.assignee);\n\t\tconst assigneeIds: string[] = [];\n\t\tfor (const assignee of assignees) {\n\t\t\tconst assigneeId = Is.string(assignee) ? assignee : OdrlPolicyHelper.getUid(assignee);\n\t\t\tGuards.stringValue(OdrlPolicyHelper.CLASS_NAME, nameof(assigneeId), assigneeId);\n\t\t\tassigneeIds.push(assigneeId);\n\t\t}\n\n\t\treturn assigneeIds.length <= 1 ? assigneeIds[0] : assigneeIds;\n\t}\n\n\t/**\n\t * Extract assigner identity from policy.\n\t * @param policy The policy to extract the assigner from.\n\t * @returns Assigner id.\n\t * @throws GeneralError if assigner is missing or invalid.\n\t */\n\tpublic static extractAssignerIdentity(policy: IDataspaceProtocolPolicy): ObjectOrArray<string> {\n\t\tif (Is.empty(policy.assigner)) {\n\t\t\tthrow new GeneralError(OdrlPolicyHelper.CLASS_NAME, \"policyMissingAssigner\", {\n\t\t\t\tpolicyType: OdrlPolicyHelper.getType(policy) ?? \"\",\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\"\n\t\t\t});\n\t\t}\n\n\t\tconst assigners = ArrayHelper.fromObjectOrArray(policy.assigner);\n\t\tconst assignerIds: string[] = [];\n\n\t\tfor (const assigner of assigners) {\n\t\t\tconst assignerId = Is.string(assigner) ? assigner : OdrlPolicyHelper.getUid(assigner);\n\t\t\tGuards.stringValue(OdrlPolicyHelper.CLASS_NAME, nameof(assignerId), assignerId);\n\t\t\tassignerIds.push(assignerId);\n\t\t}\n\n\t\treturn assignerIds.length <= 1 ? assignerIds[0] : assignerIds;\n\t}\n\n\t/**\n\t * Normalize party value(s) into identifier strings when possible.\n\t * Handles single parties or arrays of parties by returning all discovered identifiers.\n\t * @param party The party to normalize.\n\t * @returns The party identifiers, or undefined when not available.\n\t */\n\tpublic static getPartyIds(\n\t\tparty?:\n\t\t\t| string\n\t\t\t| IOdrlParty\n\t\t\t| IOdrlPartyCollection\n\t\t\t| (string | IOdrlParty | IOdrlPartyCollection)[]\n\t): string[] {\n\t\tconst ids: string[] = [];\n\n\t\tif (Is.empty(party)) {\n\t\t\treturn ids;\n\t\t}\n\n\t\tif (Is.stringValue(party)) {\n\t\t\tids.push(party);\n\t\t\treturn ids;\n\t\t}\n\n\t\tif (Is.arrayValue(party)) {\n\t\t\tfor (const item of party) {\n\t\t\t\tconst childIds = OdrlPolicyHelper.getPartyIds(item);\n\t\t\t\tif (!Is.empty(childIds)) {\n\t\t\t\t\tfor (const childId of childIds) {\n\t\t\t\t\t\tif (!ids.includes(childId)) {\n\t\t\t\t\t\t\tids.push(childId);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ids;\n\t\t}\n\n\t\tif (Is.object<IOdrlParty>(party)) {\n\t\t\tconst uid = OdrlPolicyHelper.getUid(party);\n\t\t\tif (Is.stringValue(uid) && !ids.includes(uid)) {\n\t\t\t\tids.push(uid);\n\t\t\t}\n\t\t}\n\n\t\treturn ids;\n\t}\n\n\t/**\n\t * Get the dataset targets from policy.\n\t * @param policy The policy to extract the dataset targets from.\n\t * @returns Top-level targets (deduped).\n\t */\n\tpublic static getDatasetTargets(policy: IRightsManagementPolicy): string[] {\n\t\tconst targetIds: string[] = [];\n\n\t\tconst policyTargets = ArrayHelper.fromObjectOrArray<IOdrlAsset | IOdrlAssetCollection | string>(\n\t\t\tpolicy.target ?? []\n\t\t);\n\t\tfor (const target of policyTargets) {\n\t\t\tOdrlPolicyHelper.collectTarget(target, targetIds);\n\t\t}\n\n\t\treturn Array.from(new Set(targetIds));\n\t}\n\n\t/**\n\t * Get targets from policy.\n\t * Walks both the policy-level target field and the target field on every\n\t * permission, prohibition, and obligation rule so that policies that store\n\t * their target exclusively on a rule are correctly indexed for query().\n\t * @param policy The policy to extract the targets from.\n\t * @returns Targets.\n\t */\n\tpublic static getTargets(policy: IRightsManagementPolicy): string[] {\n\t\tconst targetIds: string[] = OdrlPolicyHelper.getDatasetTargets(policy);\n\n\t\tconst rules = OdrlPolicyHelper.collectRules(policy);\n\t\tfor (const rule of rules) {\n\t\t\tconst ruleTargets = ArrayHelper.fromObjectOrArray<IOdrlAsset | IOdrlAssetCollection | string>(\n\t\t\t\trule.target ?? []\n\t\t\t);\n\t\t\tfor (const target of ruleTargets) {\n\t\t\t\tOdrlPolicyHelper.collectTarget(target, targetIds);\n\t\t\t}\n\t\t}\n\n\t\treturn Array.from(new Set(targetIds));\n\t}\n\n\t/**\n\t * Get actions from policy.\n\t * Walks both the policy-level action field and the action field on every\n\t * permission, prohibition, and obligation rule so that policies that store\n\t * their action exclusively on a rule are correctly indexed for query().\n\t * @param policy The policy to extract the actions from.\n\t * @returns Actions.\n\t */\n\tpublic static getActions(policy: IRightsManagementPolicy): string[] {\n\t\tconst actions: string[] = [];\n\n\t\tconst policyActions = ArrayHelper.fromObjectOrArray<OdrlActionType | string | IOdrlAction>(\n\t\t\tpolicy.action ?? []\n\t\t);\n\t\tfor (const action of policyActions) {\n\t\t\tOdrlPolicyHelper.collectAction(action, actions);\n\t\t}\n\n\t\tconst rules = OdrlPolicyHelper.collectRules(policy);\n\t\tfor (const rule of rules) {\n\t\t\tconst ruleActions = ArrayHelper.fromObjectOrArray<OdrlActionType | string | IOdrlAction>(\n\t\t\t\trule.action ?? []\n\t\t\t);\n\t\t\tfor (const action of ruleActions) {\n\t\t\t\tOdrlPolicyHelper.collectAction(action, actions);\n\t\t\t}\n\t\t}\n\n\t\treturn Array.from(new Set(actions));\n\t}\n\n\t/**\n\t * Does the policy match.\n\t * @param policy The policy to try and match.\n\t * @param options The matching options.\n\t * @param options.assignee The assignee to match.\n\t * @param options.assigner The assigner to match.\n\t * @param options.target The target to match.\n\t * @param options.action The action to match.\n\t * @returns True if the policy matches.\n\t */\n\tpublic static matchPolicy(\n\t\tpolicy: IRightsManagementPolicy | undefined,\n\t\toptions: {\n\t\t\tassignee?: string;\n\t\t\tassigner?: string;\n\t\t\ttarget?: string;\n\t\t\taction?: string;\n\t\t}\n\t): boolean {\n\t\tif (Is.empty(policy)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (Is.stringValue(options.assignee)) {\n\t\t\tconst assigneeIds = OdrlPolicyHelper.getPartyIds(policy.assignee);\n\t\t\tif (!assigneeIds.includes(options.assignee)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tif (Is.stringValue(options.assigner)) {\n\t\t\tconst assignerIds = OdrlPolicyHelper.getPartyIds(policy.assigner);\n\t\t\tif (!assignerIds.includes(options.assigner)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tif (Is.stringValue(options.target)) {\n\t\t\tconst targets = OdrlPolicyHelper.getTargets(policy);\n\t\t\tif (!targets.includes(options.target)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tif (Is.stringValue(options.action)) {\n\t\t\tconst actions = OdrlPolicyHelper.getActions(policy);\n\t\t\tif (!actions.includes(options.action)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Collect all rule objects (permission, prohibition, obligation) from a policy.\n\t * @param policy The policy to collect rules from.\n\t * @returns Flattened array of all rules.\n\t * @internal\n\t */\n\tprivate static collectRules(policy: IRightsManagementPolicy): IOdrlRule[] {\n\t\tconst rules: IOdrlRule[] = [];\n\t\trules.push(\n\t\t\t...ArrayHelper.fromObjectOrArray<IOdrlPermission>(policy.permission ?? []),\n\t\t\t...ArrayHelper.fromObjectOrArray<IOdrlProhibition>(policy.prohibition ?? []),\n\t\t\t...ArrayHelper.fromObjectOrArray<IOdrlDuty>(policy.obligation ?? [])\n\t\t);\n\t\treturn rules;\n\t}\n\n\t/**\n\t * Extract a target string from a target value and push it to the accumulator.\n\t * @param target The target value to extract from.\n\t * @param accumulator The array to push the target string into.\n\t * @internal\n\t */\n\tprivate static collectTarget(\n\t\ttarget: IOdrlAsset | IOdrlAssetCollection | string,\n\t\taccumulator: string[]\n\t): void {\n\t\tif (Is.object<IOdrlAsset>(target)) {\n\t\t\tconst uid = OdrlPolicyHelper.getUid(target);\n\t\t\tif (Is.stringValue(uid)) {\n\t\t\t\taccumulator.push(uid);\n\t\t\t}\n\t\t} else if (Is.stringValue(target)) {\n\t\t\taccumulator.push(target);\n\t\t}\n\t}\n\n\t/**\n\t * Extract an action string from an action value and push it to the accumulator.\n\t * @param action The action value to extract from.\n\t * @param accumulator The array to push the action string into.\n\t * @internal\n\t */\n\tprivate static collectAction(\n\t\taction: OdrlActionType | string | IOdrlAction,\n\t\taccumulator: string[]\n\t): void {\n\t\tif (Is.object<IOdrlAction>(action)) {\n\t\t\tconst uid = OdrlPolicyHelper.getUid(action);\n\t\t\tif (Is.stringValue(uid)) {\n\t\t\t\taccumulator.push(uid);\n\t\t\t}\n\t\t} else if (Is.stringValue(action)) {\n\t\t\taccumulator.push(action);\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { Factory } from "@twin.org/core";
2
+ import type { IPolicyObligationEnforcer } from "../models/pdp/IPolicyObligationEnforcer.js";
3
+ /**
4
+ * Factory for managing policy obligation enforcer registration and retrieval.
5
+ */
6
+ export declare const PolicyObligationEnforcerFactory: Factory<IPolicyObligationEnforcer>;
@@ -1,24 +1,24 @@
1
- export * from "./factories/dataAccessHandlerFactory.js";
2
1
  export * from "./factories/policyArbiterFactory.js";
3
2
  export * from "./factories/policyEnforcementProcessorFactory.js";
4
3
  export * from "./factories/policyExecutionActionFactory.js";
5
4
  export * from "./factories/policyInformationSourceFactory.js";
6
5
  export * from "./factories/policyNegotiatorFactory.js";
6
+ export * from "./factories/policyObligationEnforcerFactory.js";
7
7
  export * from "./factories/policyRequesterFactory.js";
8
- export * from "./models/api/dap/IDapCreateRequest.js";
9
- export * from "./models/api/dap/IDapGetRequest.js";
10
- export * from "./models/api/dap/IDapGetResponse.js";
11
- export * from "./models/api/dap/IDapQueryRequest.js";
12
- export * from "./models/api/dap/IDapQueryResponse.js";
13
- export * from "./models/api/dap/IDapRemoveRequest.js";
14
- export * from "./models/api/dap/IDapUpdateRequest.js";
15
8
  export * from "./models/api/pap/IPapCreateRequest.js";
9
+ export * from "./models/api/pap/IPapGetAgreementRequest.js";
10
+ export * from "./models/api/pap/IPapGetAgreementResponse.js";
11
+ export * from "./models/api/pap/IPapGetOfferRequest.js";
12
+ export * from "./models/api/pap/IPapGetOfferResponse.js";
16
13
  export * from "./models/api/pap/IPapGetRequest.js";
17
14
  export * from "./models/api/pap/IPapGetResponse.js";
15
+ export * from "./models/api/pap/IPapGetSetRequest.js";
16
+ export * from "./models/api/pap/IPapGetSetResponse.js";
18
17
  export * from "./models/api/pap/IPapQueryRequest.js";
19
18
  export * from "./models/api/pap/IPapQueryResponse.js";
20
19
  export * from "./models/api/pap/IPapRemoveRequest.js";
21
20
  export * from "./models/api/pap/IPapUpdateRequest.js";
21
+ export * from "./models/api/pnap/IPnapCreateRequest.js";
22
22
  export * from "./models/api/pnap/IPnapGetRequest.js";
23
23
  export * from "./models/api/pnap/IPnapGetResponse.js";
24
24
  export * from "./models/api/pnap/IPnapQueryRequest.js";
@@ -34,24 +34,24 @@ export * from "./models/api/pnp/IPnpNegotiateRequest.js";
34
34
  export * from "./models/api/pnp/IPnpNegotiationGetRequest.js";
35
35
  export * from "./models/api/pnp/IPnpOfferRequest.js";
36
36
  export * from "./models/api/pnp/IPnpTerminateRequest.js";
37
- export * from "./models/dap/IDataAccessHandler.js";
38
- export * from "./models/dap/IDataAccessPointComponent.js";
39
- export * from "./models/dap/IDataAccessRequestPointComponent.js";
40
- export * from "./models/dap/jsonLd/IDataAccessQuery.js";
41
- export * from "./models/dap/jsonLd/IDataAccessQueryResponse.js";
42
- export * from "./models/dap/jsonLd/IDataAccessRequest.js";
43
- export * from "./models/dap/jsonLd/IDataAccessRequestWithObject.js";
44
- export * from "./models/IPolicyLocator.js";
37
+ export * from "./models/IRightsManagementAgreement.js";
38
+ export * from "./models/IRightsManagementInformation.js";
39
+ export * from "./models/IRightsManagementOffer.js";
40
+ export * from "./models/IRightsManagementPolicy.js";
41
+ export * from "./models/IRightsManagementPolicyMetadata.js";
42
+ export * from "./models/IRightsManagementPolicyTrust.js";
43
+ export * from "./models/IRightsManagementSet.js";
44
+ export * from "./models/odrlProfiles.js";
45
45
  export * from "./models/pap/IPolicyAdministrationPointComponent.js";
46
+ export * from "./models/pap/IPolicyLocator.js";
46
47
  export * from "./models/pdp/IPolicyArbiter.js";
47
48
  export * from "./models/pdp/IPolicyDecision.js";
48
49
  export * from "./models/pdp/IPolicyDecisionPointComponent.js";
50
+ export * from "./models/pdp/IPolicyObligationEnforcer.js";
49
51
  export * from "./models/pdp/policyDecision.js";
50
52
  export * from "./models/pdp/policyDecisionStage.js";
51
53
  export * from "./models/pep/IPolicyEnforcementPointComponent.js";
52
54
  export * from "./models/pep/IPolicyEnforcementProcessor.js";
53
- export * from "./models/pip/IPolicyInformation.js";
54
- export * from "./models/pip/IPolicyInformationItems.js";
55
55
  export * from "./models/pip/IPolicyInformationPointComponent.js";
56
56
  export * from "./models/pip/IPolicyInformationSource.js";
57
57
  export * from "./models/pip/policyInformationAccessMode.js";
@@ -61,10 +61,10 @@ export * from "./models/pnp/IPolicyNegotiationAdminPointComponent.js";
61
61
  export * from "./models/pnp/IPolicyNegotiationPointComponent.js";
62
62
  export * from "./models/pnp/IPolicyNegotiator.js";
63
63
  export * from "./models/pnp/IPolicyRequester.js";
64
+ export * from "./models/policyMetadataContext.js";
64
65
  export * from "./models/pxp/IPolicyExecutionAction.js";
65
66
  export * from "./models/pxp/IPolicyExecutionPointComponent.js";
66
67
  export * from "./models/rightsManagementContexts.js";
67
68
  export * from "./models/rightsManagementNamespaces.js";
68
69
  export * from "./models/rightsManagementTypes.js";
69
- export * from "./utils/locatorHelper.js";
70
70
  export * from "./utils/odrlPolicyHelper.js";
@@ -0,0 +1,8 @@
1
+ import type { IDataspaceProtocolAgreement } from "@twin.org/standards-dataspace-protocol";
2
+ import type { IRightsManagementPolicyMetadata } from "./IRightsManagementPolicyMetadata.js";
3
+ import type { IRightsManagementPolicyTrust } from "./IRightsManagementPolicyTrust.js";
4
+ /**
5
+ * Agreement policy returned by PAP, including optional PAP-managed lifecycle metadata.
6
+ */
7
+ export interface IRightsManagementAgreement extends IDataspaceProtocolAgreement, IRightsManagementPolicyMetadata, IRightsManagementPolicyTrust {
8
+ }