@twin.org/rights-management-plugins 0.0.3-next.4
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/es/dataAccessHandlers/examplePolicyRequester.js +82 -0
- package/dist/es/dataAccessHandlers/examplePolicyRequester.js.map +1 -0
- package/dist/es/index.js +22 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IExampleDataAccessHandlerConstructorOptions.js +4 -0
- package/dist/es/models/IExampleDataAccessHandlerConstructorOptions.js.map +1 -0
- package/dist/es/models/IExamplePolicyArbiterConstructorOptions.js +4 -0
- package/dist/es/models/IExamplePolicyArbiterConstructorOptions.js.map +1 -0
- package/dist/es/models/IExamplePolicyEnforcementProcessorConstructorOptions.js +4 -0
- package/dist/es/models/IExamplePolicyEnforcementProcessorConstructorOptions.js.map +1 -0
- package/dist/es/models/IExamplePolicyNegotiatorConstructorOptions.js +4 -0
- package/dist/es/models/IExamplePolicyNegotiatorConstructorOptions.js.map +1 -0
- package/dist/es/models/IExamplePolicyRequesterConstructorOptions.js +4 -0
- package/dist/es/models/IExamplePolicyRequesterConstructorOptions.js.map +1 -0
- package/dist/es/models/IIdentityPolicyInformationSourceConstructorOptions.js +4 -0
- package/dist/es/models/IIdentityPolicyInformationSourceConstructorOptions.js.map +1 -0
- package/dist/es/models/ILoggingPolicyExecutionActionConfig.js +2 -0
- package/dist/es/models/ILoggingPolicyExecutionActionConfig.js.map +1 -0
- package/dist/es/models/ILoggingPolicyExecutionActionConstructorOptions.js +2 -0
- package/dist/es/models/ILoggingPolicyExecutionActionConstructorOptions.js.map +1 -0
- package/dist/es/models/IStaticPolicyInformationSource.js +2 -0
- package/dist/es/models/IStaticPolicyInformationSource.js.map +1 -0
- package/dist/es/models/IStaticPolicyInformationSourceConfig.js +2 -0
- package/dist/es/models/IStaticPolicyInformationSourceConfig.js.map +1 -0
- package/dist/es/models/IStaticPolicyInformationSourceConstructorOptions.js +2 -0
- package/dist/es/models/IStaticPolicyInformationSourceConstructorOptions.js.map +1 -0
- package/dist/es/policyArbiters/examplePolicyArbiter.js +50 -0
- package/dist/es/policyArbiters/examplePolicyArbiter.js.map +1 -0
- package/dist/es/policyEnforcementProcessor/examplePolicyEnforcementProcessor.js +42 -0
- package/dist/es/policyEnforcementProcessor/examplePolicyEnforcementProcessor.js.map +1 -0
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js +117 -0
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js.map +1 -0
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js +79 -0
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js.map +1 -0
- package/dist/es/policyInformationSources/staticPolicyInformationSource.js +94 -0
- package/dist/es/policyInformationSources/staticPolicyInformationSource.js.map +1 -0
- package/dist/es/policyNegotiators/examplePolicyNegotiator.js +61 -0
- package/dist/es/policyNegotiators/examplePolicyNegotiator.js.map +1 -0
- package/dist/es/policyRequesters/examplePolicyRequester.js +69 -0
- package/dist/es/policyRequesters/examplePolicyRequester.js.map +1 -0
- package/dist/types/dataAccessHandlers/examplePolicyRequester.d.ts +68 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/models/IExampleDataAccessHandlerConstructorOptions.d.ts +10 -0
- package/dist/types/models/IExamplePolicyArbiterConstructorOptions.d.ts +10 -0
- package/dist/types/models/IExamplePolicyEnforcementProcessorConstructorOptions.d.ts +10 -0
- package/dist/types/models/IExamplePolicyNegotiatorConstructorOptions.d.ts +10 -0
- package/dist/types/models/IExamplePolicyRequesterConstructorOptions.d.ts +10 -0
- package/dist/types/models/IIdentityPolicyInformationSourceConstructorOptions.d.ts +15 -0
- package/dist/types/models/ILoggingPolicyExecutionActionConfig.d.ts +25 -0
- package/dist/types/models/ILoggingPolicyExecutionActionConstructorOptions.d.ts +15 -0
- package/dist/types/models/IStaticPolicyInformationSource.d.ts +20 -0
- package/dist/types/models/IStaticPolicyInformationSourceConfig.d.ts +10 -0
- package/dist/types/models/IStaticPolicyInformationSourceConstructorOptions.d.ts +15 -0
- package/dist/types/policyArbiters/examplePolicyArbiter.d.ts +36 -0
- package/dist/types/policyEnforcementProcessor/examplePolicyEnforcementProcessor.d.ts +29 -0
- package/dist/types/policyExecutionActions/loggingPolicyExecutionAction.d.ts +49 -0
- package/dist/types/policyInformationSources/identityPolicyInformationSource.d.ts +32 -0
- package/dist/types/policyInformationSources/staticPolicyInformationSource.d.ts +38 -0
- package/dist/types/policyNegotiators/examplePolicyNegotiator.d.ts +45 -0
- package/dist/types/policyRequesters/examplePolicyRequester.d.ts +53 -0
- package/docs/changelog.md +17 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/ExampleDataAccessHandler.md +243 -0
- package/docs/reference/classes/ExamplePolicyArbiter.md +121 -0
- package/docs/reference/classes/ExamplePolicyEnforcementProcessor.md +101 -0
- package/docs/reference/classes/ExamplePolicyNegotiator.md +143 -0
- package/docs/reference/classes/ExamplePolicyRequester.md +187 -0
- package/docs/reference/classes/IdentityPolicyInformationSource.md +103 -0
- package/docs/reference/classes/LoggingPolicyExecutionAction.md +127 -0
- package/docs/reference/classes/StaticPolicyInformationSource.md +123 -0
- package/docs/reference/index.md +26 -0
- package/docs/reference/interfaces/IExampleDataAccessHandlerConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IExamplePolicyArbiterConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IExamplePolicyEnforcementProcessorConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IExamplePolicyNegotiatorConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IExamplePolicyRequesterConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IIdentityPolicyInformationSourceConstructorOptions.md +31 -0
- package/docs/reference/interfaces/ILoggingPolicyExecutionActionConfig.md +53 -0
- package/docs/reference/interfaces/ILoggingPolicyExecutionActionConstructorOptions.md +25 -0
- package/docs/reference/interfaces/IStaticPolicyInformationSource.md +28 -0
- package/docs/reference/interfaces/IStaticPolicyInformationSourceConfig.md +11 -0
- package/docs/reference/interfaces/IStaticPolicyInformationSourceConstructorOptions.md +25 -0
- package/locales/en.json +20 -0
- package/package.json +57 -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 Plugins
|
|
2
|
+
|
|
3
|
+
Rights Management plugin implementations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
npm install @twin.org/rights-management-plugins
|
|
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,82 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ComponentFactory } from "@twin.org/core";
|
|
4
|
+
/**
|
|
5
|
+
* Example Data Access Handler.
|
|
6
|
+
*/
|
|
7
|
+
export class ExampleDataAccessHandler {
|
|
8
|
+
/**
|
|
9
|
+
* The class name of the Example Data Access Handler.
|
|
10
|
+
*/
|
|
11
|
+
static CLASS_NAME = "ExampleDataAccessHandler";
|
|
12
|
+
/**
|
|
13
|
+
* The logging component.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
_logging;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new instance of ExampleDataAccessHandler.
|
|
19
|
+
* @param options The options for the example policy Requester.
|
|
20
|
+
*/
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this._logging = ComponentFactory.get(options?.loggingComponentType ?? "logging");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns the class name of the component.
|
|
26
|
+
* @returns The class name of the component.
|
|
27
|
+
*/
|
|
28
|
+
className() {
|
|
29
|
+
return ExampleDataAccessHandler.CLASS_NAME;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The asset types supported by this handler.
|
|
33
|
+
* @returns The supported asset types.
|
|
34
|
+
*/
|
|
35
|
+
supportedAssetTypes() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create an item.
|
|
40
|
+
* @param assetType The type of the item to create.
|
|
41
|
+
* @param item The item to create.
|
|
42
|
+
* @returns The id of the item created, for some items this is supplied in the `item`.
|
|
43
|
+
*/
|
|
44
|
+
async create(assetType, item) {
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get an item.
|
|
49
|
+
* @param assetType The type of the item to retrieve.
|
|
50
|
+
* @param id The ID of the item to retrieve.
|
|
51
|
+
* @returns The item retrieved if the policies allow it.
|
|
52
|
+
*/
|
|
53
|
+
async get(assetType, id) {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Update an item.
|
|
58
|
+
* @param assetType The type of the item to update.
|
|
59
|
+
* @param item The item to update.
|
|
60
|
+
* @returns Nothing.
|
|
61
|
+
*/
|
|
62
|
+
async update(assetType, item) { }
|
|
63
|
+
/**
|
|
64
|
+
* Remove an item.
|
|
65
|
+
* @param assetType The type of the item to remove.
|
|
66
|
+
* @param id The id of the item to remove.
|
|
67
|
+
* @returns Nothing.
|
|
68
|
+
*/
|
|
69
|
+
async remove(assetType, id) { }
|
|
70
|
+
/**
|
|
71
|
+
* Query for items.
|
|
72
|
+
* @param assetType The type of the item to query.
|
|
73
|
+
* @param conditions The conditions to apply to the query.
|
|
74
|
+
* @param cursor The cursor for pagination.
|
|
75
|
+
* @param options Additional options which might be supported by the handler.
|
|
76
|
+
* @returns The items matching the query and cursor if there are more items.
|
|
77
|
+
*/
|
|
78
|
+
async query(assetType, conditions, cursor, options) {
|
|
79
|
+
return { items: [] };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=examplePolicyRequester.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examplePolicyRequester.js","sourceRoot":"","sources":["../../../src/dataAccessHandlers/examplePolicyRequester.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAQlD;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACpC;;OAEG;IACI,MAAM,CAAU,UAAU,8BAA8C;IAE/E;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAAqD;QAChE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,wBAAwB,CAAC,UAAU,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACI,mBAAmB;QACzB,OAAO,EAAE,CAAC;IACX,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,SAAiB,EAAE,IAAuB;QAC7D,OAAO,EAAE,CAAC;IACX,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,CAAC,SAAiB,EAAE,EAAU;QAC7C,OAAO,EAAE,CAAC;IACX,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,SAAiB,EAAE,IAAuB,IAAkB,CAAC;IAEjF;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,SAAiB,EAAE,EAAU,IAAkB,CAAC;IAEpE;;;;;;;OAOG;IACI,KAAK,CAAC,KAAK,CACjB,SAAiB,EACjB,UAA0D,EAC1D,MAA0B,EAC1B,OAA4B;QAK5B,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACtB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type { EntityCondition } from \"@twin.org/entity\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IDataAccessHandler } from \"@twin.org/rights-management-models\";\nimport type { IExampleDataAccessHandlerConstructorOptions } from \"../models/IExampleDataAccessHandlerConstructorOptions.js\";\n\n/**\n * Example Data Access Handler.\n */\nexport class ExampleDataAccessHandler implements IDataAccessHandler {\n\t/**\n\t * The class name of the Example Data Access Handler.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ExampleDataAccessHandler>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging: ILoggingComponent;\n\n\t/**\n\t * Create a new instance of ExampleDataAccessHandler.\n\t * @param options The options for the example policy Requester.\n\t */\n\tconstructor(options?: IExampleDataAccessHandlerConstructorOptions) {\n\t\tthis._logging = ComponentFactory.get<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn ExampleDataAccessHandler.CLASS_NAME;\n\t}\n\n\t/**\n\t * The asset types supported by this handler.\n\t * @returns The supported asset types.\n\t */\n\tpublic supportedAssetTypes(): string[] {\n\t\treturn [];\n\t}\n\n\t/**\n\t * Create an item.\n\t * @param assetType The type of the item to create.\n\t * @param item The item to create.\n\t * @returns The id of the item created, for some items this is supplied in the `item`.\n\t */\n\tpublic async create(assetType: string, item: IJsonLdNodeObject): Promise<string> {\n\t\treturn \"\";\n\t}\n\n\t/**\n\t * Get an item.\n\t * @param assetType The type of the item to retrieve.\n\t * @param id The ID of the item to retrieve.\n\t * @returns The item retrieved if the policies allow it.\n\t */\n\tpublic async get(assetType: string, id: string): Promise<IJsonLdNodeObject> {\n\t\treturn {};\n\t}\n\n\t/**\n\t * Update an item.\n\t * @param assetType The type of the item to update.\n\t * @param item The item to update.\n\t * @returns Nothing.\n\t */\n\tpublic async update(assetType: string, item: IJsonLdNodeObject): Promise<void> {}\n\n\t/**\n\t * Remove an item.\n\t * @param assetType The type of the item to remove.\n\t * @param id The id of the item to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(assetType: string, id: string): Promise<void> {}\n\n\t/**\n\t * Query for items.\n\t * @param assetType The type of the item to query.\n\t * @param conditions The conditions to apply to the query.\n\t * @param cursor The cursor for pagination.\n\t * @param options Additional options which might be supported by the handler.\n\t * @returns The items matching the query and cursor if there are more items.\n\t */\n\tpublic async query(\n\t\tassetType: string,\n\t\tconditions: EntityCondition<IJsonLdNodeObject> | undefined,\n\t\tcursor: string | undefined,\n\t\toptions: unknown | undefined\n\t): Promise<{\n\t\titems: IJsonLdNodeObject[];\n\t\tcursor?: string;\n\t}> {\n\t\treturn { items: [] };\n\t}\n}\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
export * from "./dataAccessHandlers/examplePolicyRequester.js";
|
|
4
|
+
export * from "./models/IExampleDataAccessHandlerConstructorOptions.js";
|
|
5
|
+
export * from "./models/IExamplePolicyArbiterConstructorOptions.js";
|
|
6
|
+
export * from "./models/IExamplePolicyEnforcementProcessorConstructorOptions.js";
|
|
7
|
+
export * from "./models/IExamplePolicyNegotiatorConstructorOptions.js";
|
|
8
|
+
export * from "./models/IExamplePolicyRequesterConstructorOptions.js";
|
|
9
|
+
export * from "./models/IIdentityPolicyInformationSourceConstructorOptions.js";
|
|
10
|
+
export * from "./models/ILoggingPolicyExecutionActionConfig.js";
|
|
11
|
+
export * from "./models/ILoggingPolicyExecutionActionConstructorOptions.js";
|
|
12
|
+
export * from "./models/IStaticPolicyInformationSource.js";
|
|
13
|
+
export * from "./models/IStaticPolicyInformationSourceConfig.js";
|
|
14
|
+
export * from "./models/IStaticPolicyInformationSourceConstructorOptions.js";
|
|
15
|
+
export * from "./policyArbiters/examplePolicyArbiter.js";
|
|
16
|
+
export * from "./policyEnforcementProcessor/examplePolicyEnforcementProcessor.js";
|
|
17
|
+
export * from "./policyExecutionActions/loggingPolicyExecutionAction.js";
|
|
18
|
+
export * from "./policyInformationSources/identityPolicyInformationSource.js";
|
|
19
|
+
export * from "./policyInformationSources/staticPolicyInformationSource.js";
|
|
20
|
+
export * from "./policyNegotiators/examplePolicyNegotiator.js";
|
|
21
|
+
export * from "./policyRequesters/examplePolicyRequester.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,yDAAyD,CAAC;AACxE,cAAc,qDAAqD,CAAC;AACpE,cAAc,kEAAkE,CAAC;AACjF,cAAc,wDAAwD,CAAC;AACvE,cAAc,uDAAuD,CAAC;AACtE,cAAc,gEAAgE,CAAC;AAC/E,cAAc,iDAAiD,CAAC;AAChE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kDAAkD,CAAC;AACjE,cAAc,8DAA8D,CAAC;AAC7E,cAAc,0CAA0C,CAAC;AACzD,cAAc,mEAAmE,CAAC;AAClF,cAAc,0DAA0D,CAAC;AACzE,cAAc,+DAA+D,CAAC;AAC9E,cAAc,6DAA6D,CAAC;AAC5E,cAAc,gDAAgD,CAAC;AAC/D,cAAc,8CAA8C,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./dataAccessHandlers/examplePolicyRequester.js\";\nexport * from \"./models/IExampleDataAccessHandlerConstructorOptions.js\";\nexport * from \"./models/IExamplePolicyArbiterConstructorOptions.js\";\nexport * from \"./models/IExamplePolicyEnforcementProcessorConstructorOptions.js\";\nexport * from \"./models/IExamplePolicyNegotiatorConstructorOptions.js\";\nexport * from \"./models/IExamplePolicyRequesterConstructorOptions.js\";\nexport * from \"./models/IIdentityPolicyInformationSourceConstructorOptions.js\";\nexport * from \"./models/ILoggingPolicyExecutionActionConfig.js\";\nexport * from \"./models/ILoggingPolicyExecutionActionConstructorOptions.js\";\nexport * from \"./models/IStaticPolicyInformationSource.js\";\nexport * from \"./models/IStaticPolicyInformationSourceConfig.js\";\nexport * from \"./models/IStaticPolicyInformationSourceConstructorOptions.js\";\nexport * from \"./policyArbiters/examplePolicyArbiter.js\";\nexport * from \"./policyEnforcementProcessor/examplePolicyEnforcementProcessor.js\";\nexport * from \"./policyExecutionActions/loggingPolicyExecutionAction.js\";\nexport * from \"./policyInformationSources/identityPolicyInformationSource.js\";\nexport * from \"./policyInformationSources/staticPolicyInformationSource.js\";\nexport * from \"./policyNegotiators/examplePolicyNegotiator.js\";\nexport * from \"./policyRequesters/examplePolicyRequester.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IExampleDataAccessHandlerConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IExampleDataAccessHandlerConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Options for the Example Data Access Handler.\n */\nexport interface IExampleDataAccessHandlerConstructorOptions {\n\t/**\n\t * The logging component for data access handler.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IExamplePolicyArbiterConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IExamplePolicyArbiterConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Options for the Example Policy Arbiter.\n */\nexport interface IExamplePolicyArbiterConstructorOptions {\n\t/**\n\t * The logging component for policy arbiter.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IExamplePolicyEnforcementProcessorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IExamplePolicyEnforcementProcessorConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Options for the Example Policy Enforcement Processor.\n */\nexport interface IExamplePolicyEnforcementProcessorConstructorOptions {\n\t/**\n\t * The logging component for policy enforcement processor.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IExamplePolicyNegotiatorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IExamplePolicyNegotiatorConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Options for the Example Policy Negotiator.\n */\nexport interface IExamplePolicyNegotiatorConstructorOptions {\n\t/**\n\t * The logging component for policy negotiator.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IExamplePolicyRequesterConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IExamplePolicyRequesterConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Options for the Example Policy Requester.\n */\nexport interface IExamplePolicyRequesterConstructorOptions {\n\t/**\n\t * The logging component for policy requester.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IIdentityPolicyInformationSourceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IIdentityPolicyInformationSourceConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Options for the Identity Policy Information Source Component.\n */\nexport interface IIdentityPolicyInformationSourceConstructorOptions {\n\t/**\n\t * The logging component for logging policy source.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * The component for resolving identities.\n\t * @default identity-resolver\n\t */\n\tidentityResolverComponentType?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ILoggingPolicyExecutionActionConfig.js","sourceRoot":"","sources":["../../../src/models/ILoggingPolicyExecutionActionConfig.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { PolicyDecisionStage } from \"@twin.org/rights-management-models\";\n\n/**\n * Options for the Logging Policy Execution Action Component.\n */\nexport interface ILoggingPolicyExecutionActionConfig {\n\t/**\n\t * The policy decision stages to log, if undefined defaults to all.\n\t */\n\tstages?: PolicyDecisionStage[];\n\n\t/**\n\t * Whether to include the data in the log.\n\t * @default false\n\t */\n\tincludeData?: boolean;\n\n\t/**\n\t * Whether to include the policies in the log.\n\t * @default false\n\t */\n\tincludePolicies?: boolean;\n\n\t/**\n\t * Whether to include the decisions in the log.\n\t * @default false\n\t */\n\tincludeDecisions?: boolean;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ILoggingPolicyExecutionActionConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/ILoggingPolicyExecutionActionConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ILoggingPolicyExecutionActionConfig } from \"./ILoggingPolicyExecutionActionConfig.js\";\n\n/**\n * Options for the Logging Policy Execution Action.\n */\nexport interface ILoggingPolicyExecutionActionConstructorOptions {\n\t/**\n\t * The logging component for logging policy execution.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * The configuration for the logging policy execution.\n\t */\n\tconfig?: ILoggingPolicyExecutionActionConfig;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IStaticPolicyInformationSource.js","sourceRoot":"","sources":["../../../src/models/IStaticPolicyInformationSource.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type {\n\tIPolicyLocator,\n\tPolicyInformationAccessMode\n} from \"@twin.org/rights-management-models\";\n\n/**\n * Configuration for the Static Policy Information Source Component.\n */\nexport interface IStaticPolicyInformationSource {\n\t/**\n\t * Is the information public, if so it will be shared with negotiation requests.\n\t */\n\taccessMode: PolicyInformationAccessMode;\n\n\t/**\n\t * Information is only provided for the specified locator combination.\n\t * If undefined is provided matches all resources.\n\t */\n\tmatchLocators?: IPolicyLocator[];\n\n\t/**\n\t * The objects containing the information.\n\t */\n\tobjects: IJsonLdNodeObject[];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IStaticPolicyInformationSourceConfig.js","sourceRoot":"","sources":["../../../src/models/IStaticPolicyInformationSourceConfig.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IStaticPolicyInformationSource } from \"./IStaticPolicyInformationSource.js\";\n\n/**\n * Configuration for the Static Policy Information Source Component.\n */\nexport interface IStaticPolicyInformationSourceConfig {\n\t/**\n\t * The information to return from the PIP.\n\t */\n\tinformation?: IStaticPolicyInformationSource[];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IStaticPolicyInformationSourceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IStaticPolicyInformationSourceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IStaticPolicyInformationSourceConfig } from \"./IStaticPolicyInformationSourceConfig.js\";\n\n/**\n * Options for the Static Policy Information Source Component.\n */\nexport interface IStaticPolicyInformationSourceConstructorOptions {\n\t/**\n\t * The logging component for logging policy source.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * The configuration.\n\t */\n\tconfig?: IStaticPolicyInformationSourceConfig;\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ComponentFactory } from "@twin.org/core";
|
|
4
|
+
/**
|
|
5
|
+
* Example Policy Arbiter.
|
|
6
|
+
*/
|
|
7
|
+
export class ExamplePolicyArbiter {
|
|
8
|
+
/**
|
|
9
|
+
* The class name of the Example Policy Arbiter.
|
|
10
|
+
*/
|
|
11
|
+
static CLASS_NAME = "ExamplePolicyArbiter";
|
|
12
|
+
/**
|
|
13
|
+
* The logging component.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
_logging;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new instance of ExamplePolicyArbiter.
|
|
19
|
+
* @param options The options for the example policy arbiter.
|
|
20
|
+
*/
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this._logging = ComponentFactory.get(options?.loggingComponentType ?? "logging");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns the class name of the component.
|
|
26
|
+
* @returns The class name of the component.
|
|
27
|
+
*/
|
|
28
|
+
className() {
|
|
29
|
+
return ExamplePolicyArbiter.CLASS_NAME;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The policies supported by this arbiter.
|
|
33
|
+
* @returns The supported policies, if empty can be used for all.
|
|
34
|
+
*/
|
|
35
|
+
supportedPolicies() {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Makes decisions regarding policy access to data.
|
|
40
|
+
* @param locator The locator to find relevant policies.
|
|
41
|
+
* @param information Information provided by the requester to determine if a policy can be created.
|
|
42
|
+
* @param policies The policies that apply to the data.
|
|
43
|
+
* @param data The data to make a decision on.
|
|
44
|
+
* @returns The decisions about access to the data.
|
|
45
|
+
*/
|
|
46
|
+
async decide(locator, information, policies, data) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=examplePolicyArbiter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examplePolicyArbiter.js","sourceRoot":"","sources":["../../../src/policyArbiters/examplePolicyArbiter.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAYlD;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAChC;;OAEG;IACI,MAAM,CAAU,UAAU,0BAA0C;IAE3E;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAAiD;QAC5D,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,oBAAoB,CAAC,UAAU,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,iBAAiB;QACvB,OAAO,EAAE,CAAC;IACX,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,MAAM,CAClB,OAAuB,EACvB,WAAgC,EAChC,QAAwB,EACxB,IAAQ;QAER,OAAO,EAAE,CAAC;IACX,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type {\n\tIPolicyArbiter,\n\tIPolicyDecision,\n\tIPolicyInformation,\n\tIPolicyLocator\n} from \"@twin.org/rights-management-models\";\nimport type { IOdrlPolicy } from \"@twin.org/standards-w3c-odrl\";\nimport type { IExamplePolicyArbiterConstructorOptions } from \"../models/IExamplePolicyArbiterConstructorOptions.js\";\n\n/**\n * Example Policy Arbiter.\n */\nexport class ExamplePolicyArbiter implements IPolicyArbiter {\n\t/**\n\t * The class name of the Example Policy Arbiter.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ExamplePolicyArbiter>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging: ILoggingComponent;\n\n\t/**\n\t * Create a new instance of ExamplePolicyArbiter.\n\t * @param options The options for the example policy arbiter.\n\t */\n\tconstructor(options?: IExamplePolicyArbiterConstructorOptions) {\n\t\tthis._logging = ComponentFactory.get<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn ExamplePolicyArbiter.CLASS_NAME;\n\t}\n\n\t/**\n\t * The policies supported by this arbiter.\n\t * @returns The supported policies, if empty can be used for all.\n\t */\n\tpublic supportedPolicies(): IPolicyLocator[] {\n\t\treturn [];\n\t}\n\n\t/**\n\t * Makes decisions regarding policy access to data.\n\t * @param locator The locator to find relevant policies.\n\t * @param information Information provided by the requester to determine if a policy can be created.\n\t * @param policies The policies that apply to the data.\n\t * @param data The data to make a decision on.\n\t * @returns The decisions about access to the data.\n\t */\n\tpublic async decide<D = unknown>(\n\t\tlocator: IPolicyLocator,\n\t\tinformation?: IPolicyInformation,\n\t\tpolicies?: IOdrlPolicy[],\n\t\tdata?: D\n\t): Promise<IPolicyDecision[]> {\n\t\treturn [];\n\t}\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ComponentFactory } from "@twin.org/core";
|
|
4
|
+
/**
|
|
5
|
+
* Example Policy Enforcement Processor.
|
|
6
|
+
*/
|
|
7
|
+
export class ExamplePolicyEnforcementProcessor {
|
|
8
|
+
/**
|
|
9
|
+
* The class name of the Example Policy Enforcement Processor.
|
|
10
|
+
*/
|
|
11
|
+
static CLASS_NAME = "ExamplePolicyEnforcementProcessor";
|
|
12
|
+
/**
|
|
13
|
+
* The logging component.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
_logging;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new instance of ExamplePolicyEnforcementProcessor.
|
|
19
|
+
* @param options The options for the example policy enforcement processor.
|
|
20
|
+
*/
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this._logging = ComponentFactory.get(options?.loggingComponentType ?? "logging");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns the class name of the component.
|
|
26
|
+
* @returns The class name of the component.
|
|
27
|
+
*/
|
|
28
|
+
className() {
|
|
29
|
+
return ExamplePolicyEnforcementProcessor.CLASS_NAME;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Process the response from the policy decision point.
|
|
33
|
+
* @param locator The locator to find relevant policies.
|
|
34
|
+
* @param decisions The decisions made by the policy decision point.
|
|
35
|
+
* @param data The data to process.
|
|
36
|
+
* @returns The data after processing.
|
|
37
|
+
*/
|
|
38
|
+
async process(locator, decisions, data) {
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=examplePolicyEnforcementProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examplePolicyEnforcementProcessor.js","sourceRoot":"","sources":["../../../src/policyEnforcementProcessor/examplePolicyEnforcementProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAUlD;;GAEG;AACH,MAAM,OAAO,iCAAiC;IAC7C;;OAEG;IACI,MAAM,CAAU,UAAU,uCAAuD;IAExF;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAA8D;QACzE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,iCAAiC,CAAC,UAAU,CAAC;IACrD,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,OAAO,CACnB,OAAuB,EACvB,SAA4B,EAC5B,IAAQ;QAER,OAAO,IAAoB,CAAC;IAC7B,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type {\n\tIPolicyDecision,\n\tIPolicyEnforcementProcessor,\n\tIPolicyLocator\n} from \"@twin.org/rights-management-models\";\nimport type { IExamplePolicyEnforcementProcessorConstructorOptions } from \"../models/IExamplePolicyEnforcementProcessorConstructorOptions.js\";\n\n/**\n * Example Policy Enforcement Processor.\n */\nexport class ExamplePolicyEnforcementProcessor implements IPolicyEnforcementProcessor {\n\t/**\n\t * The class name of the Example Policy Enforcement Processor.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ExamplePolicyEnforcementProcessor>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging: ILoggingComponent;\n\n\t/**\n\t * Create a new instance of ExamplePolicyEnforcementProcessor.\n\t * @param options The options for the example policy enforcement processor.\n\t */\n\tconstructor(options?: IExamplePolicyEnforcementProcessorConstructorOptions) {\n\t\tthis._logging = ComponentFactory.get<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn ExamplePolicyEnforcementProcessor.CLASS_NAME;\n\t}\n\n\t/**\n\t * Process the response from the policy decision point.\n\t * @param locator The locator to find relevant policies.\n\t * @param decisions The decisions made by the policy decision point.\n\t * @param data The data to process.\n\t * @returns The data after processing.\n\t */\n\tpublic async process<D = unknown, R = D>(\n\t\tlocator: IPolicyLocator,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata?: D\n\t): Promise<R> {\n\t\treturn data as unknown as R;\n\t}\n}\n"]}
|