@twin.org/rights-management-pep-service 0.0.2-next.10
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.
- package/LICENSE +201 -0
- package/README.md +21 -0
- package/dist/cjs/index.cjs +139 -0
- package/dist/esm/index.mjs +137 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/models/IPolicyEnforcementPointServiceConfig.d.ts +13 -0
- package/dist/types/models/IPolicyEnforcementPointServiceConstructorOptions.d.ts +20 -0
- package/dist/types/policyEnforcementPointService.d.ts +36 -0
- package/docs/changelog.md +194 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/PolicyEnforcementPointService.md +139 -0
- package/docs/reference/index.md +10 -0
- package/docs/reference/interfaces/IPolicyEnforcementPointServiceConfig.md +19 -0
- package/docs/reference/interfaces/IPolicyEnforcementPointServiceConstructorOptions.md +39 -0
- package/locales/en.json +15 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2024 IOTA Stiftung.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# TWIN Rights Management Policy Enforcement Point Service
|
|
2
|
+
|
|
3
|
+
Policy enforcement point implementation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
npm install @twin.org/rights-management-pep-service
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
Usage of the APIs is shown in the examples [docs/examples.md](docs/examples.md)
|
|
14
|
+
|
|
15
|
+
## Reference
|
|
16
|
+
|
|
17
|
+
Detailed reference documentation for the API can be found in [docs/reference/index.md](docs/reference/index.md)
|
|
18
|
+
|
|
19
|
+
## Changelog
|
|
20
|
+
|
|
21
|
+
The changes between each version can be found in [docs/changelog.md](docs/changelog.md)
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@twin.org/core');
|
|
4
|
+
var rightsManagementModels = require('@twin.org/rights-management-models');
|
|
5
|
+
|
|
6
|
+
// Copyright 2024 IOTA Stiftung.
|
|
7
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
8
|
+
/**
|
|
9
|
+
* Class implementation of Policy Enforcement Point Component.
|
|
10
|
+
*/
|
|
11
|
+
class PolicyEnforcementPointService {
|
|
12
|
+
/**
|
|
13
|
+
* The class name of the Policy Enforcement Point Service.
|
|
14
|
+
*/
|
|
15
|
+
CLASS_NAME = "PolicyEnforcementPointService";
|
|
16
|
+
/**
|
|
17
|
+
* The logging component.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
_logging;
|
|
21
|
+
/**
|
|
22
|
+
* The policy decision point component.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
_policyDecisionPointComponent;
|
|
26
|
+
/**
|
|
27
|
+
* These processors can be registered to handle data after decision is made.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
_processors;
|
|
31
|
+
/**
|
|
32
|
+
* Create a new instance of PolicyEnforcementPointService (PEP).
|
|
33
|
+
* @param options The options for the component.
|
|
34
|
+
*/
|
|
35
|
+
constructor(options) {
|
|
36
|
+
this._logging = core.ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
|
|
37
|
+
this._policyDecisionPointComponent = core.ComponentFactory.get(options?.policyDecisionPointComponentType ?? "policy-decision-point");
|
|
38
|
+
this._processors = options?.config?.processors ?? [];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Process the data using Policy Decision Point (PDP) and return the manipulated data.
|
|
42
|
+
* @param locator The locator to find relevant policies.
|
|
43
|
+
* @param data The data to process.
|
|
44
|
+
* @returns The manipulated data with any policies applied.
|
|
45
|
+
*/
|
|
46
|
+
async intercept(locator, data) {
|
|
47
|
+
core.Guards.objectValue(this.CLASS_NAME, "locator", locator);
|
|
48
|
+
this._logging?.log({
|
|
49
|
+
level: "info",
|
|
50
|
+
source: this.CLASS_NAME,
|
|
51
|
+
ts: Date.now(),
|
|
52
|
+
message: "intercepting",
|
|
53
|
+
data: {
|
|
54
|
+
locator: rightsManagementModels.LocatorHelper.toString(locator)
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const decisions = await this._policyDecisionPointComponent.evaluate(locator, data);
|
|
58
|
+
let processedData = core.ObjectHelper.clone(data);
|
|
59
|
+
for (const { processorId, processor } of this._processors) {
|
|
60
|
+
try {
|
|
61
|
+
this._logging?.log({
|
|
62
|
+
level: "info",
|
|
63
|
+
source: this.CLASS_NAME,
|
|
64
|
+
ts: Date.now(),
|
|
65
|
+
message: "processing",
|
|
66
|
+
data: {
|
|
67
|
+
locator: rightsManagementModels.LocatorHelper.toString(locator),
|
|
68
|
+
processorId
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
processedData = await processor.process(locator, decisions, processedData);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
this._logging?.log({
|
|
75
|
+
level: "error",
|
|
76
|
+
source: this.CLASS_NAME,
|
|
77
|
+
ts: Date.now(),
|
|
78
|
+
message: "processingFailed",
|
|
79
|
+
data: {
|
|
80
|
+
processorId,
|
|
81
|
+
locator: rightsManagementModels.LocatorHelper.toString(locator)
|
|
82
|
+
},
|
|
83
|
+
error: core.BaseError.fromError(error)
|
|
84
|
+
});
|
|
85
|
+
throw new core.GeneralError(this.CLASS_NAME, "processingFailed", { processorId, locator: rightsManagementModels.LocatorHelper.toString(locator) }, error);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return processedData;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Register a processor to use for handling data.
|
|
92
|
+
* @param processorId The id of the processor to register.
|
|
93
|
+
* @param processor The processor to register.
|
|
94
|
+
* @returns Nothing.
|
|
95
|
+
*/
|
|
96
|
+
async registerProcessor(processorId, processor) {
|
|
97
|
+
core.Guards.stringValue(this.CLASS_NAME, "processorId", processorId);
|
|
98
|
+
core.Guards.objectValue(this.CLASS_NAME, "processor", processor);
|
|
99
|
+
const currentIndex = this._processors.findIndex(p => p.processorId === processorId);
|
|
100
|
+
if (currentIndex !== -1) {
|
|
101
|
+
this._processors[currentIndex].processor = processor;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this._processors.push({ processorId, processor });
|
|
105
|
+
}
|
|
106
|
+
this._logging?.log({
|
|
107
|
+
level: "info",
|
|
108
|
+
source: this.CLASS_NAME,
|
|
109
|
+
ts: Date.now(),
|
|
110
|
+
message: "registeredProcessor",
|
|
111
|
+
data: {
|
|
112
|
+
processorId
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Unregister a processor from the handling.
|
|
118
|
+
* @param processorId The id of the processor to unregister.
|
|
119
|
+
* @returns Nothing.
|
|
120
|
+
*/
|
|
121
|
+
async unregisterProcessor(processorId) {
|
|
122
|
+
core.Guards.stringValue(this.CLASS_NAME, "processorId", processorId);
|
|
123
|
+
const currentIndex = this._processors.findIndex(p => p.processorId === processorId);
|
|
124
|
+
if (currentIndex !== -1) {
|
|
125
|
+
this._processors.splice(currentIndex, 1);
|
|
126
|
+
}
|
|
127
|
+
this._logging?.log({
|
|
128
|
+
level: "info",
|
|
129
|
+
source: this.CLASS_NAME,
|
|
130
|
+
ts: Date.now(),
|
|
131
|
+
message: "unregisteredProcessor",
|
|
132
|
+
data: {
|
|
133
|
+
processorId
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
exports.PolicyEnforcementPointService = PolicyEnforcementPointService;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { ComponentFactory, Guards, ObjectHelper, BaseError, GeneralError } from '@twin.org/core';
|
|
2
|
+
import { LocatorHelper } from '@twin.org/rights-management-models';
|
|
3
|
+
|
|
4
|
+
// Copyright 2024 IOTA Stiftung.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
6
|
+
/**
|
|
7
|
+
* Class implementation of Policy Enforcement Point Component.
|
|
8
|
+
*/
|
|
9
|
+
class PolicyEnforcementPointService {
|
|
10
|
+
/**
|
|
11
|
+
* The class name of the Policy Enforcement Point Service.
|
|
12
|
+
*/
|
|
13
|
+
CLASS_NAME = "PolicyEnforcementPointService";
|
|
14
|
+
/**
|
|
15
|
+
* The logging component.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
_logging;
|
|
19
|
+
/**
|
|
20
|
+
* The policy decision point component.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
_policyDecisionPointComponent;
|
|
24
|
+
/**
|
|
25
|
+
* These processors can be registered to handle data after decision is made.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
_processors;
|
|
29
|
+
/**
|
|
30
|
+
* Create a new instance of PolicyEnforcementPointService (PEP).
|
|
31
|
+
* @param options The options for the component.
|
|
32
|
+
*/
|
|
33
|
+
constructor(options) {
|
|
34
|
+
this._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
|
|
35
|
+
this._policyDecisionPointComponent = ComponentFactory.get(options?.policyDecisionPointComponentType ?? "policy-decision-point");
|
|
36
|
+
this._processors = options?.config?.processors ?? [];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Process the data using Policy Decision Point (PDP) and return the manipulated data.
|
|
40
|
+
* @param locator The locator to find relevant policies.
|
|
41
|
+
* @param data The data to process.
|
|
42
|
+
* @returns The manipulated data with any policies applied.
|
|
43
|
+
*/
|
|
44
|
+
async intercept(locator, data) {
|
|
45
|
+
Guards.objectValue(this.CLASS_NAME, "locator", locator);
|
|
46
|
+
this._logging?.log({
|
|
47
|
+
level: "info",
|
|
48
|
+
source: this.CLASS_NAME,
|
|
49
|
+
ts: Date.now(),
|
|
50
|
+
message: "intercepting",
|
|
51
|
+
data: {
|
|
52
|
+
locator: LocatorHelper.toString(locator)
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const decisions = await this._policyDecisionPointComponent.evaluate(locator, data);
|
|
56
|
+
let processedData = ObjectHelper.clone(data);
|
|
57
|
+
for (const { processorId, processor } of this._processors) {
|
|
58
|
+
try {
|
|
59
|
+
this._logging?.log({
|
|
60
|
+
level: "info",
|
|
61
|
+
source: this.CLASS_NAME,
|
|
62
|
+
ts: Date.now(),
|
|
63
|
+
message: "processing",
|
|
64
|
+
data: {
|
|
65
|
+
locator: LocatorHelper.toString(locator),
|
|
66
|
+
processorId
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
processedData = await processor.process(locator, decisions, processedData);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
this._logging?.log({
|
|
73
|
+
level: "error",
|
|
74
|
+
source: this.CLASS_NAME,
|
|
75
|
+
ts: Date.now(),
|
|
76
|
+
message: "processingFailed",
|
|
77
|
+
data: {
|
|
78
|
+
processorId,
|
|
79
|
+
locator: LocatorHelper.toString(locator)
|
|
80
|
+
},
|
|
81
|
+
error: BaseError.fromError(error)
|
|
82
|
+
});
|
|
83
|
+
throw new GeneralError(this.CLASS_NAME, "processingFailed", { processorId, locator: LocatorHelper.toString(locator) }, error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return processedData;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Register a processor to use for handling data.
|
|
90
|
+
* @param processorId The id of the processor to register.
|
|
91
|
+
* @param processor The processor to register.
|
|
92
|
+
* @returns Nothing.
|
|
93
|
+
*/
|
|
94
|
+
async registerProcessor(processorId, processor) {
|
|
95
|
+
Guards.stringValue(this.CLASS_NAME, "processorId", processorId);
|
|
96
|
+
Guards.objectValue(this.CLASS_NAME, "processor", processor);
|
|
97
|
+
const currentIndex = this._processors.findIndex(p => p.processorId === processorId);
|
|
98
|
+
if (currentIndex !== -1) {
|
|
99
|
+
this._processors[currentIndex].processor = processor;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this._processors.push({ processorId, processor });
|
|
103
|
+
}
|
|
104
|
+
this._logging?.log({
|
|
105
|
+
level: "info",
|
|
106
|
+
source: this.CLASS_NAME,
|
|
107
|
+
ts: Date.now(),
|
|
108
|
+
message: "registeredProcessor",
|
|
109
|
+
data: {
|
|
110
|
+
processorId
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Unregister a processor from the handling.
|
|
116
|
+
* @param processorId The id of the processor to unregister.
|
|
117
|
+
* @returns Nothing.
|
|
118
|
+
*/
|
|
119
|
+
async unregisterProcessor(processorId) {
|
|
120
|
+
Guards.stringValue(this.CLASS_NAME, "processorId", processorId);
|
|
121
|
+
const currentIndex = this._processors.findIndex(p => p.processorId === processorId);
|
|
122
|
+
if (currentIndex !== -1) {
|
|
123
|
+
this._processors.splice(currentIndex, 1);
|
|
124
|
+
}
|
|
125
|
+
this._logging?.log({
|
|
126
|
+
level: "info",
|
|
127
|
+
source: this.CLASS_NAME,
|
|
128
|
+
ts: Date.now(),
|
|
129
|
+
message: "unregisteredProcessor",
|
|
130
|
+
data: {
|
|
131
|
+
processorId
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { PolicyEnforcementPointService };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IPolicyEnforcementProcessor } from "@twin.org/rights-management-models";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the Policy Enforcement Point Component.
|
|
4
|
+
*/
|
|
5
|
+
export interface IPolicyEnforcementPointServiceConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Initial processors to register with the PEP.
|
|
8
|
+
*/
|
|
9
|
+
processors?: {
|
|
10
|
+
processorId: string;
|
|
11
|
+
processor: IPolicyEnforcementProcessor;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IPolicyEnforcementPointServiceConfig } from "./IPolicyEnforcementPointServiceConfig";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the Policy Enforcement Point Component.
|
|
4
|
+
*/
|
|
5
|
+
export interface IPolicyEnforcementPointServiceConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The logging component for logging policy enforcement.
|
|
8
|
+
* @default logging
|
|
9
|
+
*/
|
|
10
|
+
loggingComponentType?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The type of the policy decision point component.
|
|
13
|
+
* @default policy-decision-point
|
|
14
|
+
*/
|
|
15
|
+
policyDecisionPointComponentType?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The configuration for the Policy Enforcement Point Service.
|
|
18
|
+
*/
|
|
19
|
+
config?: IPolicyEnforcementPointServiceConfig;
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type IPolicyEnforcementPointComponent, type IPolicyEnforcementProcessor, type IPolicyLocator } from "@twin.org/rights-management-models";
|
|
2
|
+
import type { IPolicyEnforcementPointServiceConstructorOptions } from "./models/IPolicyEnforcementPointServiceConstructorOptions";
|
|
3
|
+
/**
|
|
4
|
+
* Class implementation of Policy Enforcement Point Component.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PolicyEnforcementPointService implements IPolicyEnforcementPointComponent {
|
|
7
|
+
/**
|
|
8
|
+
* The class name of the Policy Enforcement Point Service.
|
|
9
|
+
*/
|
|
10
|
+
readonly CLASS_NAME: string;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new instance of PolicyEnforcementPointService (PEP).
|
|
13
|
+
* @param options The options for the component.
|
|
14
|
+
*/
|
|
15
|
+
constructor(options?: IPolicyEnforcementPointServiceConstructorOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Process the data using Policy Decision Point (PDP) and return the manipulated data.
|
|
18
|
+
* @param locator The locator to find relevant policies.
|
|
19
|
+
* @param data The data to process.
|
|
20
|
+
* @returns The manipulated data with any policies applied.
|
|
21
|
+
*/
|
|
22
|
+
intercept<D = unknown, R = D>(locator: IPolicyLocator, data?: D): Promise<R>;
|
|
23
|
+
/**
|
|
24
|
+
* Register a processor to use for handling data.
|
|
25
|
+
* @param processorId The id of the processor to register.
|
|
26
|
+
* @param processor The processor to register.
|
|
27
|
+
* @returns Nothing.
|
|
28
|
+
*/
|
|
29
|
+
registerProcessor(processorId: string, processor: IPolicyEnforcementProcessor): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Unregister a processor from the handling.
|
|
32
|
+
* @param processorId The id of the processor to unregister.
|
|
33
|
+
* @returns Nothing.
|
|
34
|
+
*/
|
|
35
|
+
unregisterProcessor(processorId: string): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.2-next.10](https://github.com/twinfoundation/rights-management/compare/rights-management-pep-service-v0.0.2-next.9...rights-management-pep-service-v0.0.2-next.10) (2025-09-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add DAP (Data Access Point) ([#40](https://github.com/twinfoundation/rights-management/issues/40)) ([f3e684b](https://github.com/twinfoundation/rights-management/commit/f3e684ba1f9a934394c64635f393fbb6709ff480))
|
|
9
|
+
* international dataspaces contract negotiation ([#41](https://github.com/twinfoundation/rights-management/issues/41)) ([41ed515](https://github.com/twinfoundation/rights-management/commit/41ed5154d6cef48bc99db3158dbde6ec88523a0b))
|
|
10
|
+
* pdp add ([#39](https://github.com/twinfoundation/rights-management/issues/39)) ([68b9a8a](https://github.com/twinfoundation/rights-management/commit/68b9a8a7a3cf2902f9eecb590ca3316c6b1671f0))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* update method signature ([24e6f36](https://github.com/twinfoundation/rights-management/commit/24e6f3664d860eb3baa6fb368894ffd998e4c1df))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Dependencies
|
|
19
|
+
|
|
20
|
+
* The following workspace dependencies were updated
|
|
21
|
+
* dependencies
|
|
22
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.9 to 0.0.2-next.10
|
|
23
|
+
* devDependencies
|
|
24
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.9 to 0.0.2-next.10
|
|
25
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.2-next.9 to 0.0.2-next.10
|
|
26
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.2-next.9 to 0.0.2-next.10
|
|
27
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.2-next.9 to 0.0.2-next.10
|
|
28
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.2-next.9 to 0.0.2-next.10
|
|
29
|
+
|
|
30
|
+
## [0.0.2-next.9](https://github.com/twinfoundation/rights-management/compare/rights-management-pep-service-v0.0.2-next.8...rights-management-pep-service-v0.0.2-next.9) (2025-09-08)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* add JSON-LD types for negotiation ([6be61f8](https://github.com/twinfoundation/rights-management/commit/6be61f890537cb9d22d4fad90092b858de2c9c2d))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Dependencies
|
|
39
|
+
|
|
40
|
+
* The following workspace dependencies were updated
|
|
41
|
+
* dependencies
|
|
42
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
43
|
+
* devDependencies
|
|
44
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
45
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
46
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
47
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
48
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
49
|
+
|
|
50
|
+
## [0.0.2-next.8](https://github.com/twinfoundation/rights-management/compare/rights-management-pep-service-v0.0.2-next.7...rights-management-pep-service-v0.0.2-next.8) (2025-09-05)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Miscellaneous Chores
|
|
54
|
+
|
|
55
|
+
* **rights-management-pep-service:** Synchronize repo versions
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Dependencies
|
|
59
|
+
|
|
60
|
+
* The following workspace dependencies were updated
|
|
61
|
+
* dependencies
|
|
62
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
63
|
+
* devDependencies
|
|
64
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
65
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
66
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
67
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
68
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
69
|
+
|
|
70
|
+
## [0.0.2-next.7](https://github.com/twinfoundation/rights-management/compare/rights-management-pep-service-v0.0.2-next.6...rights-management-pep-service-v0.0.2-next.7) (2025-09-05)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Features
|
|
74
|
+
|
|
75
|
+
* separate pep constructor config ([32dd4af](https://github.com/twinfoundation/rights-management/commit/32dd4afb7b01c48d595c8226299207882a3954c8))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### Dependencies
|
|
79
|
+
|
|
80
|
+
* The following workspace dependencies were updated
|
|
81
|
+
* dependencies
|
|
82
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.6 to 0.0.2-next.7
|
|
83
|
+
* devDependencies
|
|
84
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.6 to 0.0.2-next.7
|
|
85
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.2-next.6 to 0.0.2-next.7
|
|
86
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.2-next.6 to 0.0.2-next.7
|
|
87
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.2-next.6 to 0.0.2-next.7
|
|
88
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.2-next.6 to 0.0.2-next.7
|
|
89
|
+
|
|
90
|
+
## [0.0.2-next.6](https://github.com/twinfoundation/rights-management/compare/rights-management-pep-service-v0.0.2-next.5...rights-management-pep-service-v0.0.2-next.6) (2025-09-05)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
### Features
|
|
94
|
+
|
|
95
|
+
* separate rest routes ([538b86b](https://github.com/twinfoundation/rights-management/commit/538b86be26b46711279101aa01fec119419d8149))
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### Dependencies
|
|
99
|
+
|
|
100
|
+
* The following workspace dependencies were updated
|
|
101
|
+
* dependencies
|
|
102
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.5 to 0.0.2-next.6
|
|
103
|
+
* devDependencies
|
|
104
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.5 to 0.0.2-next.6
|
|
105
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.2-next.5 to 0.0.2-next.6
|
|
106
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.2-next.5 to 0.0.2-next.6
|
|
107
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.2-next.5 to 0.0.2-next.6
|
|
108
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.2-next.5 to 0.0.2-next.6
|
|
109
|
+
|
|
110
|
+
## [0.0.2-next.5](https://github.com/twinfoundation/rights-management/compare/rights-management-pep-service-v0.0.2-next.4...rights-management-pep-service-v0.0.2-next.5) (2025-09-05)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
### Features
|
|
114
|
+
|
|
115
|
+
* add PEP ([#31](https://github.com/twinfoundation/rights-management/issues/31)) ([34c7c29](https://github.com/twinfoundation/rights-management/commit/34c7c2965e5c0c2be24460628f83cdae0aa7f0d6))
|
|
116
|
+
* add policy negotiation point PNP, PNAP and PNRP ([#32](https://github.com/twinfoundation/rights-management/issues/32)) ([90f0659](https://github.com/twinfoundation/rights-management/commit/90f06593a1126df3c2f4ca23cf95a08260fd6415))
|
|
117
|
+
* introduce context for additional environment input ([e1d0392](https://github.com/twinfoundation/rights-management/commit/e1d0392622e5a018b695644f423c5b23cc40d3b7))
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
### Dependencies
|
|
121
|
+
|
|
122
|
+
* The following workspace dependencies were updated
|
|
123
|
+
* dependencies
|
|
124
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.4 to 0.0.2-next.5
|
|
125
|
+
* devDependencies
|
|
126
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.4 to 0.0.2-next.5
|
|
127
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.2-next.4 to 0.0.2-next.5
|
|
128
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.2-next.4 to 0.0.2-next.5
|
|
129
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.2-next.4 to 0.0.2-next.5
|
|
130
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.2-next.4 to 0.0.2-next.5
|
|
131
|
+
|
|
132
|
+
## [0.0.2-next.4](https://github.com/twinfoundation/rights-management/compare/rights-management-pep-service-v0.0.2-next.3...rights-management-pep-service-v0.0.2-next.4) (2025-08-29)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### Features
|
|
136
|
+
|
|
137
|
+
* eslint migration to flat config ([dfb15f6](https://github.com/twinfoundation/rights-management/commit/dfb15f6574477d837d623a65501a6bb983ce938d))
|
|
138
|
+
* improve constructor option naming ([c89a7e8](https://github.com/twinfoundation/rights-management/commit/c89a7e8df43a5017ac5cf84b549f5a26cc41e089))
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
### Dependencies
|
|
142
|
+
|
|
143
|
+
* The following workspace dependencies were updated
|
|
144
|
+
* dependencies
|
|
145
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
146
|
+
* devDependencies
|
|
147
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
148
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
149
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
150
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
151
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
152
|
+
|
|
153
|
+
## [0.0.2-next.3](https://github.com/twinfoundation/rights-management/compare/rights-management-pep-service-v0.0.2-next.2...rights-management-pep-service-v0.0.2-next.3) (2025-08-29)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
### Features
|
|
157
|
+
|
|
158
|
+
* eslint migration to flat config ([23a0c08](https://github.com/twinfoundation/rights-management/commit/23a0c085e7fc2e522c8d85d325dc5844b9c3fd8e))
|
|
159
|
+
* policy execution point ([#26](https://github.com/twinfoundation/rights-management/issues/26)) ([d930f10](https://github.com/twinfoundation/rights-management/commit/d930f104006a0d815cdf222b87d11d749351fb84))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
### Dependencies
|
|
163
|
+
|
|
164
|
+
* The following workspace dependencies were updated
|
|
165
|
+
* dependencies
|
|
166
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
167
|
+
* devDependencies
|
|
168
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
169
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
170
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
171
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
172
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
173
|
+
|
|
174
|
+
## [0.0.2-next.2](https://github.com/twinfoundation/rights-management/compare/rights-management-pep-service-v0.0.2-next.1...rights-management-pep-service-v0.0.2-next.2) (2025-08-22)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
### Features
|
|
178
|
+
|
|
179
|
+
* add scaffold for other services ([de25f34](https://github.com/twinfoundation/rights-management/commit/de25f34c40fb65b6d73df98965ea4e368019da84))
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
### Dependencies
|
|
183
|
+
|
|
184
|
+
* The following workspace dependencies were updated
|
|
185
|
+
* dependencies
|
|
186
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
187
|
+
* devDependencies
|
|
188
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
189
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
190
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
191
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
192
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
193
|
+
|
|
194
|
+
## @twin.org/rights-management-pep-service - Changelog
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @twin.org/rights-management-pep-service - Examples
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Class: PolicyEnforcementPointService
|
|
2
|
+
|
|
3
|
+
Class implementation of Policy Enforcement Point Component.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IPolicyEnforcementPointComponent`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new PolicyEnforcementPointService**(`options?`): `PolicyEnforcementPointService`
|
|
14
|
+
|
|
15
|
+
Create a new instance of PolicyEnforcementPointService (PEP).
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### options?
|
|
20
|
+
|
|
21
|
+
[`IPolicyEnforcementPointServiceConstructorOptions`](../interfaces/IPolicyEnforcementPointServiceConstructorOptions.md)
|
|
22
|
+
|
|
23
|
+
The options for the component.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`PolicyEnforcementPointService`
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
### CLASS\_NAME
|
|
32
|
+
|
|
33
|
+
> `readonly` **CLASS\_NAME**: `string`
|
|
34
|
+
|
|
35
|
+
The class name of the Policy Enforcement Point Service.
|
|
36
|
+
|
|
37
|
+
#### Implementation of
|
|
38
|
+
|
|
39
|
+
`IPolicyEnforcementPointComponent.CLASS_NAME`
|
|
40
|
+
|
|
41
|
+
## Methods
|
|
42
|
+
|
|
43
|
+
### intercept()
|
|
44
|
+
|
|
45
|
+
> **intercept**\<`D`, `R`\>(`locator`, `data?`): `Promise`\<`R`\>
|
|
46
|
+
|
|
47
|
+
Process the data using Policy Decision Point (PDP) and return the manipulated data.
|
|
48
|
+
|
|
49
|
+
#### Type Parameters
|
|
50
|
+
|
|
51
|
+
##### D
|
|
52
|
+
|
|
53
|
+
`D` = `unknown`
|
|
54
|
+
|
|
55
|
+
##### R
|
|
56
|
+
|
|
57
|
+
`R` = `D`
|
|
58
|
+
|
|
59
|
+
#### Parameters
|
|
60
|
+
|
|
61
|
+
##### locator
|
|
62
|
+
|
|
63
|
+
`IPolicyLocator`
|
|
64
|
+
|
|
65
|
+
The locator to find relevant policies.
|
|
66
|
+
|
|
67
|
+
##### data?
|
|
68
|
+
|
|
69
|
+
`D`
|
|
70
|
+
|
|
71
|
+
The data to process.
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
`Promise`\<`R`\>
|
|
76
|
+
|
|
77
|
+
The manipulated data with any policies applied.
|
|
78
|
+
|
|
79
|
+
#### Implementation of
|
|
80
|
+
|
|
81
|
+
`IPolicyEnforcementPointComponent.intercept`
|
|
82
|
+
|
|
83
|
+
***
|
|
84
|
+
|
|
85
|
+
### registerProcessor()
|
|
86
|
+
|
|
87
|
+
> **registerProcessor**(`processorId`, `processor`): `Promise`\<`void`\>
|
|
88
|
+
|
|
89
|
+
Register a processor to use for handling data.
|
|
90
|
+
|
|
91
|
+
#### Parameters
|
|
92
|
+
|
|
93
|
+
##### processorId
|
|
94
|
+
|
|
95
|
+
`string`
|
|
96
|
+
|
|
97
|
+
The id of the processor to register.
|
|
98
|
+
|
|
99
|
+
##### processor
|
|
100
|
+
|
|
101
|
+
`IPolicyEnforcementProcessor`
|
|
102
|
+
|
|
103
|
+
The processor to register.
|
|
104
|
+
|
|
105
|
+
#### Returns
|
|
106
|
+
|
|
107
|
+
`Promise`\<`void`\>
|
|
108
|
+
|
|
109
|
+
Nothing.
|
|
110
|
+
|
|
111
|
+
#### Implementation of
|
|
112
|
+
|
|
113
|
+
`IPolicyEnforcementPointComponent.registerProcessor`
|
|
114
|
+
|
|
115
|
+
***
|
|
116
|
+
|
|
117
|
+
### unregisterProcessor()
|
|
118
|
+
|
|
119
|
+
> **unregisterProcessor**(`processorId`): `Promise`\<`void`\>
|
|
120
|
+
|
|
121
|
+
Unregister a processor from the handling.
|
|
122
|
+
|
|
123
|
+
#### Parameters
|
|
124
|
+
|
|
125
|
+
##### processorId
|
|
126
|
+
|
|
127
|
+
`string`
|
|
128
|
+
|
|
129
|
+
The id of the processor to unregister.
|
|
130
|
+
|
|
131
|
+
#### Returns
|
|
132
|
+
|
|
133
|
+
`Promise`\<`void`\>
|
|
134
|
+
|
|
135
|
+
Nothing.
|
|
136
|
+
|
|
137
|
+
#### Implementation of
|
|
138
|
+
|
|
139
|
+
`IPolicyEnforcementPointComponent.unregisterProcessor`
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @twin.org/rights-management-pep-service
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
- [PolicyEnforcementPointService](classes/PolicyEnforcementPointService.md)
|
|
6
|
+
|
|
7
|
+
## Interfaces
|
|
8
|
+
|
|
9
|
+
- [IPolicyEnforcementPointServiceConfig](interfaces/IPolicyEnforcementPointServiceConfig.md)
|
|
10
|
+
- [IPolicyEnforcementPointServiceConstructorOptions](interfaces/IPolicyEnforcementPointServiceConstructorOptions.md)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Interface: IPolicyEnforcementPointServiceConfig
|
|
2
|
+
|
|
3
|
+
Options for the Policy Enforcement Point Component.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### processors?
|
|
8
|
+
|
|
9
|
+
> `optional` **processors**: `object`[]
|
|
10
|
+
|
|
11
|
+
Initial processors to register with the PEP.
|
|
12
|
+
|
|
13
|
+
#### processorId
|
|
14
|
+
|
|
15
|
+
> **processorId**: `string`
|
|
16
|
+
|
|
17
|
+
#### processor
|
|
18
|
+
|
|
19
|
+
> **processor**: `IPolicyEnforcementProcessor`
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Interface: IPolicyEnforcementPointServiceConstructorOptions
|
|
2
|
+
|
|
3
|
+
Options for the Policy Enforcement Point Component.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### loggingComponentType?
|
|
8
|
+
|
|
9
|
+
> `optional` **loggingComponentType**: `string`
|
|
10
|
+
|
|
11
|
+
The logging component for logging policy enforcement.
|
|
12
|
+
|
|
13
|
+
#### Default
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
logging
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### policyDecisionPointComponentType?
|
|
22
|
+
|
|
23
|
+
> `optional` **policyDecisionPointComponentType**: `string`
|
|
24
|
+
|
|
25
|
+
The type of the policy decision point component.
|
|
26
|
+
|
|
27
|
+
#### Default
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
policy-decision-point
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
***
|
|
34
|
+
|
|
35
|
+
### config?
|
|
36
|
+
|
|
37
|
+
> `optional` **config**: [`IPolicyEnforcementPointServiceConfig`](IPolicyEnforcementPointServiceConfig.md)
|
|
38
|
+
|
|
39
|
+
The configuration for the Policy Enforcement Point Service.
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"error": {
|
|
3
|
+
"policyEnforcementPointService": {
|
|
4
|
+
"processingFailed": "Failed to process information using processor with id: \"{processorId}\", locator: \"{locator}\""
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
"info": {
|
|
8
|
+
"policyEnforcementPointService": {
|
|
9
|
+
"registeredProcessor": "Processor registered with id: \"{processorId}\"",
|
|
10
|
+
"unregisteredProcessor": "Processor unregistered with id: \"{processorId}\"",
|
|
11
|
+
"processing": "Processing information using processor with id: \"{processorId}\", locator: \"{locator}\"",
|
|
12
|
+
"intercepting": "Intercepting information for locator: \"{locator}\""
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@twin.org/rights-management-pep-service",
|
|
3
|
+
"version": "0.0.2-next.10",
|
|
4
|
+
"description": "Policy enforcement point implementation",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/twinfoundation/rights-management.git",
|
|
8
|
+
"directory": "packages/rights-management-pep-service"
|
|
9
|
+
},
|
|
10
|
+
"author": "martyn.janes@iota.org",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20.0.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@twin.org/core": "next",
|
|
18
|
+
"@twin.org/logging-models": "next",
|
|
19
|
+
"@twin.org/nameof": "next",
|
|
20
|
+
"@twin.org/rights-management-models": "0.0.2-next.10"
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/cjs/index.cjs",
|
|
23
|
+
"module": "./dist/esm/index.mjs",
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/types/index.d.ts",
|
|
28
|
+
"require": "./dist/cjs/index.cjs",
|
|
29
|
+
"import": "./dist/esm/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./locales/*.json": "./locales/*.json"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist/cjs",
|
|
35
|
+
"dist/esm",
|
|
36
|
+
"dist/types",
|
|
37
|
+
"locales",
|
|
38
|
+
"docs"
|
|
39
|
+
]
|
|
40
|
+
}
|