@twin.org/rights-management-models 0.0.2-next.3 → 0.0.2-next.5

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 (88) hide show
  1. package/dist/cjs/index.cjs +137 -12
  2. package/dist/esm/index.mjs +135 -12
  3. package/dist/types/index.d.ts +32 -11
  4. package/dist/types/models/IPolicyAdministrationPointComponent.d.ts +3 -1
  5. package/dist/types/models/IPolicyContext.d.ts +13 -0
  6. package/dist/types/models/IPolicyDecisionPointComponent.d.ts +3 -3
  7. package/dist/types/models/IPolicyEnforcementPointComponent.d.ts +17 -3
  8. package/dist/types/models/IPolicyEnforcementProcessor.d.ts +17 -0
  9. package/dist/types/models/IPolicyExecutionAction.d.ts +4 -4
  10. package/dist/types/models/IPolicyExecutionPointComponent.d.ts +3 -3
  11. package/dist/types/models/IPolicyInformationPointComponent.d.ts +5 -3
  12. package/dist/types/models/IPolicyInformationSource.d.ts +5 -3
  13. package/dist/types/models/IPolicyManagementPointComponent.d.ts +3 -3
  14. package/dist/types/models/IPolicyNegotiation.d.ts +50 -0
  15. package/dist/types/models/IPolicyNegotiationAdminPointComponent.d.ts +37 -0
  16. package/dist/types/models/IPolicyNegotiationPointComponent.d.ts +55 -0
  17. package/dist/types/models/IPolicyNegotiationRequestPointComponent.d.ts +31 -0
  18. package/dist/types/models/IPolicyNegotiator.d.ts +32 -0
  19. package/dist/types/models/IPolicyState.d.ts +22 -0
  20. package/dist/types/models/IRightsManagementComponent.d.ts +68 -4
  21. package/dist/types/models/api/policyAdministrationPoint/{IPapCreateRequest.d.ts → pap/IPapCreateRequest.d.ts} +3 -1
  22. package/dist/types/models/api/policyAdministrationPoint/{IPepInterceptRequest.d.ts → pep/IPepInterceptRequest.d.ts} +7 -1
  23. package/dist/types/models/api/policyAdministrationPoint/pnap/IPnapGetRequest.d.ts +14 -0
  24. package/dist/types/models/api/policyAdministrationPoint/pnap/IPnapGetResponse.d.ts +10 -0
  25. package/dist/types/models/api/policyAdministrationPoint/pnap/IPnapQueryRequest.d.ts +18 -0
  26. package/dist/types/models/api/policyAdministrationPoint/pnap/IPnapQueryResponse.d.ts +19 -0
  27. package/dist/types/models/api/policyAdministrationPoint/pnap/IPnapRemoveRequest.d.ts +14 -0
  28. package/dist/types/models/api/policyAdministrationPoint/pnap/IPnapSetRequest.d.ts +19 -0
  29. package/dist/types/models/api/policyAdministrationPoint/pnp/IPnpNegotiateRequest.d.ts +39 -0
  30. package/dist/types/models/api/policyAdministrationPoint/pnp/IPnpNegotiateResponse.d.ts +10 -0
  31. package/dist/types/models/api/policyAdministrationPoint/pnp/IPnpNegotiationCancelRequest.d.ts +28 -0
  32. package/dist/types/models/api/policyAdministrationPoint/pnp/IPnpNegotiationStateRequest.d.ts +28 -0
  33. package/dist/types/models/api/policyAdministrationPoint/pnp/IPnpNegotiationStateResponse.d.ts +10 -0
  34. package/dist/types/models/policyInformationAccessMode.d.ts +21 -0
  35. package/dist/types/models/policyNegotiationStatus.d.ts +21 -0
  36. package/dist/types/models/rightsManagementNamespaces.d.ts +13 -0
  37. package/dist/types/utils/odrlPolicyHelper.d.ts +37 -0
  38. package/docs/changelog.md +18 -0
  39. package/docs/reference/classes/OdrlPolicyHelper.md +143 -0
  40. package/docs/reference/index.md +29 -2
  41. package/docs/reference/interfaces/IPapCreateRequest.md +7 -1
  42. package/docs/reference/interfaces/IPepInterceptRequest.md +10 -2
  43. package/docs/reference/interfaces/IPnapGetRequest.md +17 -0
  44. package/docs/reference/interfaces/IPnapGetResponse.md +11 -0
  45. package/docs/reference/interfaces/IPnapQueryRequest.md +23 -0
  46. package/docs/reference/interfaces/IPnapQueryResponse.md +23 -0
  47. package/docs/reference/interfaces/IPnapRemoveRequest.md +17 -0
  48. package/docs/reference/interfaces/IPnapSetRequest.md +25 -0
  49. package/docs/reference/interfaces/IPnpNegotiateRequest.md +51 -0
  50. package/docs/reference/interfaces/IPnpNegotiateResponse.md +11 -0
  51. package/docs/reference/interfaces/IPnpNegotiationCancelRequest.md +37 -0
  52. package/docs/reference/interfaces/IPnpNegotiationStateRequest.md +37 -0
  53. package/docs/reference/interfaces/IPnpNegotiationStateResponse.md +11 -0
  54. package/docs/reference/interfaces/IPolicyAdministrationPointComponent.md +1 -1
  55. package/docs/reference/interfaces/IPolicyContext.md +19 -0
  56. package/docs/reference/interfaces/IPolicyDecisionPointComponent.md +13 -15
  57. package/docs/reference/interfaces/IPolicyEnforcementPointComponent.md +64 -12
  58. package/docs/reference/interfaces/IPolicyEnforcementProcessor.md +63 -0
  59. package/docs/reference/interfaces/IPolicyExecutionAction.md +23 -19
  60. package/docs/reference/interfaces/IPolicyExecutionPointComponent.md +17 -13
  61. package/docs/reference/interfaces/IPolicyInformationPointComponent.md +20 -10
  62. package/docs/reference/interfaces/IPolicyInformationSource.md +20 -10
  63. package/docs/reference/interfaces/IPolicyManagementPointComponent.md +13 -15
  64. package/docs/reference/interfaces/IPolicyNegotiation.md +87 -0
  65. package/docs/reference/interfaces/IPolicyNegotiationAdminPointComponent.md +102 -0
  66. package/docs/reference/interfaces/IPolicyNegotiationPointComponent.md +185 -0
  67. package/docs/reference/interfaces/IPolicyNegotiationRequestPointComponent.md +104 -0
  68. package/docs/reference/interfaces/IPolicyNegotiator.md +89 -0
  69. package/docs/reference/interfaces/IPolicyState.md +35 -0
  70. package/docs/reference/interfaces/IRightsManagementComponent.md +229 -11
  71. package/docs/reference/type-aliases/PolicyInformationAccessMode.md +5 -0
  72. package/docs/reference/type-aliases/PolicyNegotiationStatus.md +5 -0
  73. package/docs/reference/type-aliases/RightsManagementNamespaces.md +5 -0
  74. package/docs/reference/variables/PolicyInformationAccessMode.md +25 -0
  75. package/docs/reference/variables/PolicyNegotiationStatus.md +25 -0
  76. package/docs/reference/variables/RightsManagementNamespaces.md +13 -0
  77. package/package.json +2 -1
  78. package/dist/types/factories/policyExecutionActionFactory.d.ts +0 -6
  79. package/dist/types/factories/policyInformationSourceFactory.d.ts +0 -6
  80. package/docs/reference/variables/PolicyExecutionActionFactory.md +0 -5
  81. package/docs/reference/variables/PolicyInformationSourceFactory.md +0 -5
  82. /package/dist/types/models/api/policyAdministrationPoint/{IPapQueryRequest.d.ts → pap/IPapQueryRequest.d.ts} +0 -0
  83. /package/dist/types/models/api/policyAdministrationPoint/{IPapQueryResponse.d.ts → pap/IPapQueryResponse.d.ts} +0 -0
  84. /package/dist/types/models/api/policyAdministrationPoint/{IPapRemoveRequest.d.ts → pap/IPapRemoveRequest.d.ts} +0 -0
  85. /package/dist/types/models/api/policyAdministrationPoint/{IPapRetrieveRequest.d.ts → pap/IPapRetrieveRequest.d.ts} +0 -0
  86. /package/dist/types/models/api/policyAdministrationPoint/{IPapRetrieveResponse.d.ts → pap/IPapRetrieveResponse.d.ts} +0 -0
  87. /package/dist/types/models/api/policyAdministrationPoint/{IPapUpdateRequest.d.ts → pap/IPapUpdateRequest.d.ts} +0 -0
  88. /package/dist/types/models/api/policyAdministrationPoint/{IPepInterceptResponse.d.ts → pep/IPepInterceptResponse.d.ts} +0 -0
@@ -5,36 +5,161 @@ var core = require('@twin.org/core');
5
5
  // Copyright 2024 IOTA Stiftung.
6
6
  // SPDX-License-Identifier: Apache-2.0.
7
7
  /**
8
- * Factory for creating policy execution actions.
8
+ * The stage at which a PXP is executed in the PDP.
9
9
  */
10
10
  // eslint-disable-next-line @typescript-eslint/naming-convention
11
- const PolicyExecutionActionFactory = core.Factory.createFactory("policy-execution", true);
11
+ const PolicyDecisionStage = {
12
+ /**
13
+ * Before Decision.
14
+ */
15
+ Before: "before",
16
+ /**
17
+ * After Decision.
18
+ */
19
+ After: "after"
20
+ };
12
21
 
13
22
  // Copyright 2024 IOTA Stiftung.
14
23
  // SPDX-License-Identifier: Apache-2.0.
15
24
  /**
16
- * Factory for creating policy information sources.
25
+ * The mode that can be used to retrieve information from PIP sources.
17
26
  */
18
27
  // eslint-disable-next-line @typescript-eslint/naming-convention
19
- const PolicyInformationSourceFactory = core.Factory.createFactory("policy-information", true);
28
+ const PolicyInformationAccessMode = {
29
+ /**
30
+ * Public.
31
+ */
32
+ Public: "public",
33
+ /**
34
+ * Private.
35
+ */
36
+ Private: "private",
37
+ /**
38
+ * Any.
39
+ */
40
+ Any: "any"
41
+ };
20
42
 
21
43
  // Copyright 2024 IOTA Stiftung.
22
44
  // SPDX-License-Identifier: Apache-2.0.
23
45
  /**
24
- * The stage at which a PXP is executed in the PDP.
46
+ * The status of the negotiation in the Policy Negotiation Point (PNP).
25
47
  */
26
48
  // eslint-disable-next-line @typescript-eslint/naming-convention
27
- const PolicyDecisionStage = {
49
+ const PolicyNegotiationStatus = {
28
50
  /**
29
- * Before Decision.
51
+ * Manual - manual approval is required.
30
52
  */
31
- Before: "before",
53
+ Manual: "manual",
32
54
  /**
33
- * After Decision.
55
+ * Approved - the negotiation has been approved.
34
56
  */
35
- After: "after"
57
+ Approved: "approved",
58
+ /**
59
+ * Rejected - the negotiation has been rejected.
60
+ */
61
+ Rejected: "rejected"
62
+ };
63
+
64
+ // Copyright 2024 IOTA Stiftung.
65
+ // SPDX-License-Identifier: Apache-2.0.
66
+ /**
67
+ * The namespaces for rights management.
68
+ */
69
+ // eslint-disable-next-line @typescript-eslint/naming-convention
70
+ const RightsManagementNamespaces = {
71
+ /**
72
+ * Policy.
73
+ */
74
+ Policy: "policy"
36
75
  };
37
76
 
77
+ // Copyright 2024 IOTA Stiftung.
78
+ // SPDX-License-Identifier: Apache-2.0.
79
+ /**
80
+ * Helper methods for Odrl Policies.
81
+ */
82
+ class OdrlPolicyHelper {
83
+ /**
84
+ * Find the expiration date of the policy.
85
+ * @param policy The policy to check.
86
+ * @param assetType The type of the asset, if undefined will match any asset type.
87
+ * @param action The action to check, if undefined will match any action.
88
+ * @returns The expiration date of the policy, or undefined if not found.
89
+ */
90
+ static findExpirationDate(policy, assetType, action) {
91
+ if (core.Is.arrayValue(policy.permission)) {
92
+ for (const permission of policy.permission) {
93
+ const matchesPermission = OdrlPolicyHelper.matchTargetAndAction(permission.target, permission.action, assetType, action);
94
+ if (matchesPermission && core.Is.arrayValue(permission.constraint)) {
95
+ for (const constraint of permission.constraint) {
96
+ if (constraint.leftOperand === "dateTime" &&
97
+ constraint.operator === "lteq" &&
98
+ core.Is.dateTimeString(constraint.rightOperand)) {
99
+ return constraint.rightOperand;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
105
+ }
106
+ /**
107
+ * Match the target to the requested asset type.
108
+ * @param target The target to match.
109
+ * @param matchAssetType The asset type to match.
110
+ * @returns True if the target is empty, the target matches the requested asset, false otherwise.
111
+ */
112
+ static matchAsset(target, matchAssetType) {
113
+ if (core.Is.empty(target) || core.Is.empty(matchAssetType)) {
114
+ return true;
115
+ }
116
+ if (core.Is.arrayValue(target)) {
117
+ return target.some(t => OdrlPolicyHelper.matchAsset(t, matchAssetType));
118
+ }
119
+ if (core.Is.stringValue(target)) {
120
+ return target === matchAssetType;
121
+ }
122
+ // TODO: This currently only handles the simple case of matching a single asset type.
123
+ // we need further processing if the target is more complex.
124
+ return false;
125
+ }
126
+ /**
127
+ * Match the action to the asset type.
128
+ * @param action The action to match.
129
+ * @param matchAction The action to match.
130
+ * @returns True if the action is empty, the action matches the asset type, false otherwise.
131
+ */
132
+ static matchAction(action, matchAction) {
133
+ if (core.Is.empty(action) || core.Is.empty(matchAction)) {
134
+ return true;
135
+ }
136
+ if (core.Is.arrayValue(action)) {
137
+ return action.some(a => OdrlPolicyHelper.matchAction(a, matchAction));
138
+ }
139
+ if (core.Is.stringValue(action)) {
140
+ return action === matchAction;
141
+ }
142
+ // TODO: This currently only handles the simple case of matching a single action type.
143
+ // we need further processing if the action is more complex.
144
+ return false;
145
+ }
146
+ /**
147
+ * Match the target and action to the requested asset type and action.
148
+ * @param target The target to match.
149
+ * @param action The action to match.
150
+ * @param matchAssetType The asset type to match.
151
+ * @param matchAction The action to match.
152
+ * @returns True if the target and action match the requested asset type and action, false otherwise.
153
+ */
154
+ static matchTargetAndAction(target, action, matchAssetType, matchAction) {
155
+ const assetTypeMatch = OdrlPolicyHelper.matchAsset(target, matchAssetType);
156
+ const actionMatch = OdrlPolicyHelper.matchAction(action, matchAction);
157
+ return assetTypeMatch && actionMatch;
158
+ }
159
+ }
160
+
161
+ exports.OdrlPolicyHelper = OdrlPolicyHelper;
38
162
  exports.PolicyDecisionStage = PolicyDecisionStage;
39
- exports.PolicyExecutionActionFactory = PolicyExecutionActionFactory;
40
- exports.PolicyInformationSourceFactory = PolicyInformationSourceFactory;
163
+ exports.PolicyInformationAccessMode = PolicyInformationAccessMode;
164
+ exports.PolicyNegotiationStatus = PolicyNegotiationStatus;
165
+ exports.RightsManagementNamespaces = RightsManagementNamespaces;
@@ -1,36 +1,159 @@
1
- import { Factory } from '@twin.org/core';
1
+ import { Is } from '@twin.org/core';
2
2
 
3
3
  // Copyright 2024 IOTA Stiftung.
4
4
  // SPDX-License-Identifier: Apache-2.0.
5
5
  /**
6
- * Factory for creating policy execution actions.
6
+ * The stage at which a PXP is executed in the PDP.
7
7
  */
8
8
  // eslint-disable-next-line @typescript-eslint/naming-convention
9
- const PolicyExecutionActionFactory = Factory.createFactory("policy-execution", true);
9
+ const PolicyDecisionStage = {
10
+ /**
11
+ * Before Decision.
12
+ */
13
+ Before: "before",
14
+ /**
15
+ * After Decision.
16
+ */
17
+ After: "after"
18
+ };
10
19
 
11
20
  // Copyright 2024 IOTA Stiftung.
12
21
  // SPDX-License-Identifier: Apache-2.0.
13
22
  /**
14
- * Factory for creating policy information sources.
23
+ * The mode that can be used to retrieve information from PIP sources.
15
24
  */
16
25
  // eslint-disable-next-line @typescript-eslint/naming-convention
17
- const PolicyInformationSourceFactory = Factory.createFactory("policy-information", true);
26
+ const PolicyInformationAccessMode = {
27
+ /**
28
+ * Public.
29
+ */
30
+ Public: "public",
31
+ /**
32
+ * Private.
33
+ */
34
+ Private: "private",
35
+ /**
36
+ * Any.
37
+ */
38
+ Any: "any"
39
+ };
18
40
 
19
41
  // Copyright 2024 IOTA Stiftung.
20
42
  // SPDX-License-Identifier: Apache-2.0.
21
43
  /**
22
- * The stage at which a PXP is executed in the PDP.
44
+ * The status of the negotiation in the Policy Negotiation Point (PNP).
23
45
  */
24
46
  // eslint-disable-next-line @typescript-eslint/naming-convention
25
- const PolicyDecisionStage = {
47
+ const PolicyNegotiationStatus = {
26
48
  /**
27
- * Before Decision.
49
+ * Manual - manual approval is required.
28
50
  */
29
- Before: "before",
51
+ Manual: "manual",
30
52
  /**
31
- * After Decision.
53
+ * Approved - the negotiation has been approved.
32
54
  */
33
- After: "after"
55
+ Approved: "approved",
56
+ /**
57
+ * Rejected - the negotiation has been rejected.
58
+ */
59
+ Rejected: "rejected"
60
+ };
61
+
62
+ // Copyright 2024 IOTA Stiftung.
63
+ // SPDX-License-Identifier: Apache-2.0.
64
+ /**
65
+ * The namespaces for rights management.
66
+ */
67
+ // eslint-disable-next-line @typescript-eslint/naming-convention
68
+ const RightsManagementNamespaces = {
69
+ /**
70
+ * Policy.
71
+ */
72
+ Policy: "policy"
34
73
  };
35
74
 
36
- export { PolicyDecisionStage, PolicyExecutionActionFactory, PolicyInformationSourceFactory };
75
+ // Copyright 2024 IOTA Stiftung.
76
+ // SPDX-License-Identifier: Apache-2.0.
77
+ /**
78
+ * Helper methods for Odrl Policies.
79
+ */
80
+ class OdrlPolicyHelper {
81
+ /**
82
+ * Find the expiration date of the policy.
83
+ * @param policy The policy to check.
84
+ * @param assetType The type of the asset, if undefined will match any asset type.
85
+ * @param action The action to check, if undefined will match any action.
86
+ * @returns The expiration date of the policy, or undefined if not found.
87
+ */
88
+ static findExpirationDate(policy, assetType, action) {
89
+ if (Is.arrayValue(policy.permission)) {
90
+ for (const permission of policy.permission) {
91
+ const matchesPermission = OdrlPolicyHelper.matchTargetAndAction(permission.target, permission.action, assetType, action);
92
+ if (matchesPermission && Is.arrayValue(permission.constraint)) {
93
+ for (const constraint of permission.constraint) {
94
+ if (constraint.leftOperand === "dateTime" &&
95
+ constraint.operator === "lteq" &&
96
+ Is.dateTimeString(constraint.rightOperand)) {
97
+ return constraint.rightOperand;
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+ /**
105
+ * Match the target to the requested asset type.
106
+ * @param target The target to match.
107
+ * @param matchAssetType The asset type to match.
108
+ * @returns True if the target is empty, the target matches the requested asset, false otherwise.
109
+ */
110
+ static matchAsset(target, matchAssetType) {
111
+ if (Is.empty(target) || Is.empty(matchAssetType)) {
112
+ return true;
113
+ }
114
+ if (Is.arrayValue(target)) {
115
+ return target.some(t => OdrlPolicyHelper.matchAsset(t, matchAssetType));
116
+ }
117
+ if (Is.stringValue(target)) {
118
+ return target === matchAssetType;
119
+ }
120
+ // TODO: This currently only handles the simple case of matching a single asset type.
121
+ // we need further processing if the target is more complex.
122
+ return false;
123
+ }
124
+ /**
125
+ * Match the action to the asset type.
126
+ * @param action The action to match.
127
+ * @param matchAction The action to match.
128
+ * @returns True if the action is empty, the action matches the asset type, false otherwise.
129
+ */
130
+ static matchAction(action, matchAction) {
131
+ if (Is.empty(action) || Is.empty(matchAction)) {
132
+ return true;
133
+ }
134
+ if (Is.arrayValue(action)) {
135
+ return action.some(a => OdrlPolicyHelper.matchAction(a, matchAction));
136
+ }
137
+ if (Is.stringValue(action)) {
138
+ return action === matchAction;
139
+ }
140
+ // TODO: This currently only handles the simple case of matching a single action type.
141
+ // we need further processing if the action is more complex.
142
+ return false;
143
+ }
144
+ /**
145
+ * Match the target and action to the requested asset type and action.
146
+ * @param target The target to match.
147
+ * @param action The action to match.
148
+ * @param matchAssetType The asset type to match.
149
+ * @param matchAction The action to match.
150
+ * @returns True if the target and action match the requested asset type and action, false otherwise.
151
+ */
152
+ static matchTargetAndAction(target, action, matchAssetType, matchAction) {
153
+ const assetTypeMatch = OdrlPolicyHelper.matchAsset(target, matchAssetType);
154
+ const actionMatch = OdrlPolicyHelper.matchAction(action, matchAction);
155
+ return assetTypeMatch && actionMatch;
156
+ }
157
+ }
158
+
159
+ export { OdrlPolicyHelper, PolicyDecisionStage, PolicyInformationAccessMode, PolicyNegotiationStatus, RightsManagementNamespaces };
@@ -1,21 +1,42 @@
1
- export * from "./factories/policyExecutionActionFactory";
2
- export * from "./factories/policyInformationSourceFactory";
3
- export * from "./models/api/policyAdministrationPoint/IPapCreateRequest";
4
- export * from "./models/api/policyAdministrationPoint/IPapQueryRequest";
5
- export * from "./models/api/policyAdministrationPoint/IPapQueryResponse";
6
- export * from "./models/api/policyAdministrationPoint/IPapRemoveRequest";
7
- export * from "./models/api/policyAdministrationPoint/IPapRetrieveRequest";
8
- export * from "./models/api/policyAdministrationPoint/IPapRetrieveResponse";
9
- export * from "./models/api/policyAdministrationPoint/IPapUpdateRequest";
10
- export * from "./models/api/policyAdministrationPoint/IPepInterceptRequest";
11
- export * from "./models/api/policyAdministrationPoint/IPepInterceptResponse";
1
+ export * from "./models/api/policyAdministrationPoint/pap/IPapCreateRequest";
2
+ export * from "./models/api/policyAdministrationPoint/pap/IPapQueryRequest";
3
+ export * from "./models/api/policyAdministrationPoint/pap/IPapQueryResponse";
4
+ export * from "./models/api/policyAdministrationPoint/pap/IPapRemoveRequest";
5
+ export * from "./models/api/policyAdministrationPoint/pap/IPapRetrieveRequest";
6
+ export * from "./models/api/policyAdministrationPoint/pap/IPapRetrieveResponse";
7
+ export * from "./models/api/policyAdministrationPoint/pap/IPapUpdateRequest";
8
+ export * from "./models/api/policyAdministrationPoint/pep/IPepInterceptRequest";
9
+ export * from "./models/api/policyAdministrationPoint/pep/IPepInterceptResponse";
10
+ export * from "./models/api/policyAdministrationPoint/pnap/IPnapGetRequest";
11
+ export * from "./models/api/policyAdministrationPoint/pnap/IPnapGetResponse";
12
+ export * from "./models/api/policyAdministrationPoint/pnap/IPnapQueryRequest";
13
+ export * from "./models/api/policyAdministrationPoint/pnap/IPnapQueryResponse";
14
+ export * from "./models/api/policyAdministrationPoint/pnap/IPnapRemoveRequest";
15
+ export * from "./models/api/policyAdministrationPoint/pnap/IPnapSetRequest";
16
+ export * from "./models/api/policyAdministrationPoint/pnp/IPnpNegotiateRequest";
17
+ export * from "./models/api/policyAdministrationPoint/pnp/IPnpNegotiateResponse";
18
+ export * from "./models/api/policyAdministrationPoint/pnp/IPnpNegotiationCancelRequest";
19
+ export * from "./models/api/policyAdministrationPoint/pnp/IPnpNegotiationStateRequest";
20
+ export * from "./models/api/policyAdministrationPoint/pnp/IPnpNegotiationStateResponse";
12
21
  export * from "./models/IPolicyAdministrationPointComponent";
22
+ export * from "./models/IPolicyContext";
13
23
  export * from "./models/IPolicyDecisionPointComponent";
14
24
  export * from "./models/IPolicyEnforcementPointComponent";
25
+ export * from "./models/IPolicyEnforcementProcessor";
15
26
  export * from "./models/IPolicyExecutionAction";
16
27
  export * from "./models/IPolicyExecutionPointComponent";
17
28
  export * from "./models/IPolicyInformationPointComponent";
18
29
  export * from "./models/IPolicyInformationSource";
19
30
  export * from "./models/IPolicyManagementPointComponent";
31
+ export * from "./models/IPolicyNegotiation";
32
+ export * from "./models/IPolicyNegotiationAdminPointComponent";
33
+ export * from "./models/IPolicyNegotiationPointComponent";
34
+ export * from "./models/IPolicyNegotiationRequestPointComponent";
35
+ export * from "./models/IPolicyNegotiator";
36
+ export * from "./models/IPolicyState";
20
37
  export * from "./models/IRightsManagementComponent";
21
38
  export * from "./models/policyDecisionStage";
39
+ export * from "./models/policyInformationAccessMode";
40
+ export * from "./models/policyNegotiationStatus";
41
+ export * from "./models/rightsManagementNamespaces";
42
+ export * from "./utils/odrlPolicyHelper";
@@ -10,7 +10,9 @@ export interface IPolicyAdministrationPointComponent extends IComponent {
10
10
  * @param policy The policy to create (uid will be auto-generated).
11
11
  * @returns The UID of the created policy.
12
12
  */
13
- create(policy: Omit<IOdrlPolicy, "uid">): Promise<string>;
13
+ create(policy: Omit<IOdrlPolicy, "uid"> & {
14
+ uid?: string;
15
+ }): Promise<string>;
14
16
  /**
15
17
  * Update an existing policy.
16
18
  * @param policy The policy to update (must include uid).
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Context information to be used when making a policy decision.
3
+ */
4
+ export interface IPolicyContext {
5
+ /**
6
+ * The user identity to use in the decision making.
7
+ */
8
+ userIdentity?: string;
9
+ /**
10
+ * The node identity to use in the decision making.
11
+ */
12
+ nodeIdentity?: string;
13
+ }
@@ -1,5 +1,6 @@
1
1
  import type { IComponent } from "@twin.org/core";
2
2
  import type { IOdrlPolicy } from "@twin.org/standards-w3c-odrl";
3
+ import type { IPolicyContext } from "./IPolicyContext";
3
4
  /**
4
5
  * Interface describing a Policy Decision Point (PDP) contract.
5
6
  * Decides if a party can be granted access to a resource, will retrieve policies
@@ -15,11 +16,10 @@ export interface IPolicyDecisionPointComponent extends IComponent {
15
16
  * Executes any actions on the Policy Execution Point (PXP) when the decision is made.
16
17
  * @param assetType The type of asset being processed.
17
18
  * @param action The action being performed on the asset.
19
+ * @param context The context information to use in the decision making.
18
20
  * @param data The data to make a decision on.
19
- * @param userIdentity The user identity to use in the decision making.
20
- * @param nodeIdentity The node identity to use in the decision making.
21
21
  * @returns Returns the policy decisions which apply to the data so that the PEP
22
22
  * can manipulate the data accordingly.
23
23
  */
24
- evaluate<T = unknown>(assetType: string, action: string, data: T | undefined, userIdentity: string, nodeIdentity: string): Promise<IOdrlPolicy[]>;
24
+ evaluate<C extends IPolicyContext = IPolicyContext, D = unknown>(assetType: string, action: string, context: C | undefined, data: D | undefined): Promise<IOdrlPolicy[]>;
25
25
  }
@@ -1,4 +1,6 @@
1
1
  import type { IComponent } from "@twin.org/core";
2
+ import type { IPolicyContext } from "./IPolicyContext";
3
+ import type { IPolicyEnforcementProcessor } from "./IPolicyEnforcementProcessor";
2
4
  /**
3
5
  * Interface describing a Policy Enforcement Point (PEP) contract.
4
6
  * Intercepts data and uses the Policy Decision Point (PDP) to make decisions on
@@ -10,10 +12,22 @@ export interface IPolicyEnforcementPointComponent extends IComponent {
10
12
  * Process the data using Policy Decision Point (PDP) and return the manipulated data.
11
13
  * @param assetType The type of asset being processed.
12
14
  * @param action The action being performed on the asset.
15
+ * @param context The context information to use in the decision making.
13
16
  * @param data The data to process.
14
- * @param userIdentity The user identity to use in the decision making.
15
- * @param nodeIdentity The node identity to use in the decision making.
16
17
  * @returns The manipulated data with any policies applied.
17
18
  */
18
- intercept<T = unknown>(assetType: string, action: string, data: T | undefined, userIdentity: string | undefined, nodeIdentity: string | undefined): Promise<T | undefined>;
19
+ intercept<C extends IPolicyContext = IPolicyContext, D = unknown, R = unknown>(assetType: string, action: string, context: C | undefined, data: D | undefined): Promise<R | undefined>;
20
+ /**
21
+ * Register a processor to use for handling data.
22
+ * @param processorId The id of the processor to register.
23
+ * @param processor The processor to register.
24
+ * @returns Nothing.
25
+ */
26
+ registerProcessor(processorId: string, processor: IPolicyEnforcementProcessor): Promise<void>;
27
+ /**
28
+ * Unregister a processor from the handling.
29
+ * @param processorId The id of the processor to unregister.
30
+ * @returns Nothing.
31
+ */
32
+ unregisterProcessor(processorId: string): Promise<void>;
19
33
  }
@@ -0,0 +1,17 @@
1
+ import type { IOdrlPolicy } from "@twin.org/standards-w3c-odrl";
2
+ import type { IPolicyContext } from "./IPolicyContext";
3
+ /**
4
+ * Interface for policy enforcement processors.
5
+ */
6
+ export interface IPolicyEnforcementProcessor {
7
+ /**
8
+ * Process the response from the policy decision point.
9
+ * @param assetType The type of asset being processed.
10
+ * @param action The action being performed on the asset.
11
+ * @param context The context information to use in the decision making.
12
+ * @param data The data to process.
13
+ * @param policies The policies that apply to the data.
14
+ * @returns The data after processing.
15
+ */
16
+ process<C extends IPolicyContext = IPolicyContext, D = unknown, R = unknown>(assetType: string, action: string, context: C | undefined, data: D | undefined, policies: IOdrlPolicy[]): Promise<R | undefined>;
17
+ }
@@ -1,4 +1,5 @@
1
1
  import type { IOdrlPolicy } from "@twin.org/standards-w3c-odrl";
2
+ import type { IPolicyContext } from "./IPolicyContext";
2
3
  import type { PolicyDecisionStage } from "./policyDecisionStage";
3
4
  /**
4
5
  * Interface for policy execution actions.
@@ -6,14 +7,13 @@ import type { PolicyDecisionStage } from "./policyDecisionStage";
6
7
  export interface IPolicyExecutionAction {
7
8
  /**
8
9
  * Execute function type for policy actions.
10
+ * @param stage The stage of the policy decision.
9
11
  * @param assetType The type of asset being processed.
10
12
  * @param action The action being performed on the asset.
13
+ * @param context The context information to use in the decision making.
11
14
  * @param data The data to process.
12
- * @param userIdentity The user identity to use in the decision making.
13
- * @param nodeIdentity The node identity to use in the decision making.
14
15
  * @param policies The policies that apply to the data.
15
- * @param stage The stage of the policy decision.
16
16
  * @returns A promise that resolves when the action is complete.
17
17
  */
18
- execute(assetType: string, action: string, data: unknown, userIdentity: string, nodeIdentity: string, policies: IOdrlPolicy[], stage: PolicyDecisionStage): Promise<void>;
18
+ execute<C extends IPolicyContext = IPolicyContext, D = unknown>(stage: PolicyDecisionStage, assetType: string, action: string, context: C | undefined, data: D | undefined, policies: IOdrlPolicy[]): Promise<void>;
19
19
  }
@@ -1,5 +1,6 @@
1
1
  import type { IComponent } from "@twin.org/core";
2
2
  import type { IOdrlPolicy } from "@twin.org/standards-w3c-odrl";
3
+ import type { IPolicyContext } from "./IPolicyContext";
3
4
  import type { IPolicyExecutionAction } from "./IPolicyExecutionAction";
4
5
  import type { PolicyDecisionStage } from "./policyDecisionStage";
5
6
  /**
@@ -14,13 +15,12 @@ export interface IPolicyExecutionPointComponent extends IComponent {
14
15
  * @param stage The stage at which the PXP is executed in the PDP.
15
16
  * @param assetType The type of asset being processed.
16
17
  * @param action The action being performed on the asset.
18
+ * @param context The context information to use in the decision making.
17
19
  * @param data The data used in the decision by the PDP.
18
- * @param userIdentity The user identity to use in the decision making.
19
- * @param nodeIdentity The node identity to use in the decision making.
20
20
  * @param policies The policies that apply to the data.
21
21
  * @returns Nothing.
22
22
  */
23
- executeActions(stage: PolicyDecisionStage, assetType: string, action: string, data: unknown, userIdentity: string, nodeIdentity: string, policies: IOdrlPolicy[]): Promise<void>;
23
+ executeActions<C extends IPolicyContext = IPolicyContext, D = unknown>(stage: PolicyDecisionStage, assetType: string, action: string, context: C | undefined, data: D | undefined, policies: IOdrlPolicy[]): Promise<void>;
24
24
  /**
25
25
  * Register an action to be executed.
26
26
  * @param actionId The id of the action to register.
@@ -1,7 +1,9 @@
1
1
  import type { IComponent } from "@twin.org/core";
2
2
  import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
3
3
  import type { IOdrlPolicy } from "@twin.org/standards-w3c-odrl";
4
+ import type { IPolicyContext } from "./IPolicyContext";
4
5
  import type { IPolicyInformationSource } from "./IPolicyInformationSource";
6
+ import type { PolicyInformationAccessMode } from "./policyInformationAccessMode";
5
7
  /**
6
8
  * Interface describing a Policy Information Point (PEP) contract.
7
9
  * Provides additional information to the Policy Decision Point (PDP) when
@@ -12,13 +14,13 @@ export interface IPolicyInformationPointComponent extends IComponent {
12
14
  * Retrieve additional information which is relevant in the PDP decision making.
13
15
  * @param assetType The type of asset being processed.
14
16
  * @param action The action being performed on the asset.
17
+ * @param accessMode The access mode to use for the retrieval.
18
+ * @param context The context information to use in the decision making.
15
19
  * @param data The data to get any additional information for.
16
- * @param userIdentity The user identity to get additional information for.
17
- * @param nodeIdentity The node identity to get additional information for.
18
20
  * @param policies The policies that apply to the data.
19
21
  * @returns Returns additional information based on the data and identities.
20
22
  */
21
- retrieve(assetType: string, action: string, data: unknown, userIdentity: string, nodeIdentity: string, policies: IOdrlPolicy[]): Promise<{
23
+ retrieve<C extends IPolicyContext = IPolicyContext, D = unknown>(assetType: string, action: string, accessMode: PolicyInformationAccessMode, context: C | undefined, data: D | undefined, policies: IOdrlPolicy[]): Promise<{
22
24
  [source: string]: IJsonLdNodeObject[];
23
25
  }>;
24
26
  /**
@@ -1,5 +1,7 @@
1
1
  import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
2
  import type { IOdrlPolicy } from "@twin.org/standards-w3c-odrl";
3
+ import type { IPolicyContext } from "./IPolicyContext";
4
+ import type { PolicyInformationAccessMode } from "./policyInformationAccessMode";
3
5
  /**
4
6
  * Interface for policy information sources.
5
7
  */
@@ -8,11 +10,11 @@ export interface IPolicyInformationSource {
8
10
  * Retrieve information from the sources.
9
11
  * @param assetType The type of asset being processed.
10
12
  * @param action The action being performed on the asset.
13
+ * @param accessMode The access mode to use for the retrieval.
14
+ * @param context The context information to use in the decision making.
11
15
  * @param data The data to process.
12
- * @param userIdentity The user identity to use in the decision making.
13
- * @param nodeIdentity The node identity to use in the decision making.
14
16
  * @param policies The policies that apply to the data.
15
17
  * @returns The objects containing relevant information or undefined if nothing relevant is found.
16
18
  */
17
- retrieve(assetType: string, action: string, data: unknown, userIdentity: string, nodeIdentity: string, policies: IOdrlPolicy[]): Promise<IJsonLdNodeObject[] | undefined>;
19
+ retrieve<C extends IPolicyContext = IPolicyContext, D = unknown>(assetType: string, action: string, accessMode: PolicyInformationAccessMode, context: C | undefined, data: D | undefined, policies: IOdrlPolicy[]): Promise<IJsonLdNodeObject[] | undefined>;
18
20
  }
@@ -1,5 +1,6 @@
1
1
  import type { IComponent } from "@twin.org/core";
2
2
  import type { IOdrlPolicy } from "@twin.org/standards-w3c-odrl";
3
+ import type { IPolicyContext } from "./IPolicyContext";
3
4
  /**
4
5
  * Interface describing a Policy Management Point (PMP) contract.
5
6
  * Provide the policies to the Policy Decision Point (PDP) based on the data and identities.
@@ -9,10 +10,9 @@ export interface IPolicyManagementPointComponent extends IComponent {
9
10
  * Get the policies from a PAP based on the data and identities.
10
11
  * @param assetType The type of asset being processed.
11
12
  * @param action The action being performed on the asset.
13
+ * @param context The context information to use in the decision making.
12
14
  * @param data The data to retrieve the policies for.
13
- * @param userIdentity The user identity to retrieve the policies for.
14
- * @param nodeIdentity The node identity to retrieve the policies for.
15
15
  * @returns Returns the policies which apply to the data and identities so that the PDP can make a decision.
16
16
  */
17
- retrieve<T = unknown>(assetType: string, action: string, data: T | undefined, userIdentity: string, nodeIdentity: string): Promise<IOdrlPolicy[]>;
17
+ retrieve<C extends IPolicyContext = IPolicyContext, D = unknown>(assetType: string, action: string, context: C | undefined, data: D | undefined): Promise<IOdrlPolicy[]>;
18
18
  }