@twin.org/rights-management-plugins 0.0.3-next.9 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist/es/index.js +20 -10
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IAutomationPolicyExecutionActionConfig.js +4 -0
- package/dist/es/models/IAutomationPolicyExecutionActionConfig.js.map +1 -0
- package/dist/es/models/IAutomationPolicyExecutionActionConstructorOptions.js +2 -0
- package/dist/es/models/IAutomationPolicyExecutionActionConstructorOptions.js.map +1 -0
- package/dist/es/models/{IExamplePolicyArbiterConstructorOptions.js → IDefaultPolicyArbiterConfig.js} +1 -1
- package/dist/es/models/IDefaultPolicyArbiterConfig.js.map +1 -0
- package/dist/es/models/{IExamplePolicyRequesterConstructorOptions.js → IDefaultPolicyArbiterConstructorOptions.js} +1 -1
- package/dist/es/models/IDefaultPolicyArbiterConstructorOptions.js.map +1 -0
- package/dist/es/models/{IExamplePolicyEnforcementProcessorConstructorOptions.js → IDefaultPolicyEnforcementProcessorConstructorOptions.js} +1 -1
- package/dist/es/models/IDefaultPolicyEnforcementProcessorConstructorOptions.js.map +1 -0
- package/dist/es/models/IIdentityPolicyInformationSourceConstructorOptions.js.map +1 -1
- package/dist/es/models/IIdentityProfilePolicyInformationSourceConstructorOptions.js +4 -0
- package/dist/es/models/IIdentityProfilePolicyInformationSourceConstructorOptions.js.map +1 -0
- package/dist/es/models/ILoggingPolicyExecutionActionConfig.js.map +1 -1
- package/dist/es/models/ILoggingPolicyExecutionActionConstructorOptions.js.map +1 -1
- package/dist/es/models/{IExampleDataAccessHandlerConstructorOptions.js → IPassThroughPolicyArbiterConstructorOptions.js} +1 -1
- package/dist/es/models/IPassThroughPolicyArbiterConstructorOptions.js.map +1 -0
- package/dist/es/models/IPassThroughPolicyEnforcementProcessorConstructorOptions.js +4 -0
- package/dist/es/models/IPassThroughPolicyEnforcementProcessorConstructorOptions.js.map +1 -0
- package/dist/es/models/IPassThroughPolicyNegotiatorConstructorOptions.js +4 -0
- package/dist/es/models/IPassThroughPolicyNegotiatorConstructorOptions.js.map +1 -0
- package/dist/es/models/IPassThroughPolicyObligationEnforcerConstructorOptions.js +4 -0
- package/dist/es/models/IPassThroughPolicyObligationEnforcerConstructorOptions.js.map +1 -0
- package/dist/es/models/{IExamplePolicyNegotiatorConstructorOptions.js → IPassThroughPolicyRequesterConstructorOptions.js} +1 -1
- package/dist/es/models/IPassThroughPolicyRequesterConstructorOptions.js.map +1 -0
- package/dist/es/models/IStaticPolicyInformationSource.js.map +1 -1
- package/dist/es/models/IStaticPolicyInformationSourceConstructorOptions.js.map +1 -1
- package/dist/es/policyArbiters/defaultPolicyArbiter.js +1790 -0
- package/dist/es/policyArbiters/defaultPolicyArbiter.js.map +1 -0
- package/dist/es/policyArbiters/passThroughPolicyArbiter.js +59 -0
- package/dist/es/policyArbiters/passThroughPolicyArbiter.js.map +1 -0
- package/dist/es/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.js +147 -0
- package/dist/es/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.js.map +1 -0
- package/dist/es/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.js +54 -0
- package/dist/es/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.js.map +1 -0
- package/dist/es/policyExecutionActions/automationPolicyExecutionAction.js +77 -0
- package/dist/es/policyExecutionActions/automationPolicyExecutionAction.js.map +1 -0
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js +22 -18
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js.map +1 -1
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js +44 -32
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js.map +1 -1
- package/dist/es/policyInformationSources/identityProfilePolicyInformationSource.js +112 -0
- package/dist/es/policyInformationSources/identityProfilePolicyInformationSource.js.map +1 -0
- package/dist/es/policyInformationSources/staticPolicyInformationSource.js +18 -16
- package/dist/es/policyInformationSources/staticPolicyInformationSource.js.map +1 -1
- package/dist/es/policyNegotiators/passThroughPolicyNegotiator.js +88 -0
- package/dist/es/policyNegotiators/passThroughPolicyNegotiator.js.map +1 -0
- package/dist/es/policyObligationEnforcers/passThroughPolicyObligationEnforcer.js +56 -0
- package/dist/es/policyObligationEnforcers/passThroughPolicyObligationEnforcer.js.map +1 -0
- package/dist/es/policyRequesters/passThroughPolicyRequester.js +103 -0
- package/dist/es/policyRequesters/passThroughPolicyRequester.js.map +1 -0
- package/dist/types/index.d.ts +20 -10
- package/dist/types/models/IAutomationPolicyExecutionActionConfig.d.ts +9 -0
- package/dist/types/models/IAutomationPolicyExecutionActionConstructorOptions.d.ts +15 -0
- package/dist/types/models/IDefaultPolicyArbiterConfig.d.ts +10 -0
- package/dist/types/models/IDefaultPolicyArbiterConstructorOptions.d.ts +19 -0
- package/dist/types/models/IDefaultPolicyEnforcementProcessorConstructorOptions.d.ts +9 -0
- package/dist/types/models/IIdentityPolicyInformationSourceConstructorOptions.d.ts +0 -1
- package/dist/types/models/IIdentityProfilePolicyInformationSourceConstructorOptions.d.ts +14 -0
- package/dist/types/models/ILoggingPolicyExecutionActionConfig.d.ts +2 -2
- package/dist/types/models/ILoggingPolicyExecutionActionConstructorOptions.d.ts +0 -1
- package/dist/types/models/IPassThroughPolicyArbiterConstructorOptions.d.ts +9 -0
- package/dist/types/models/IPassThroughPolicyEnforcementProcessorConstructorOptions.d.ts +9 -0
- package/dist/types/models/IPassThroughPolicyNegotiatorConstructorOptions.d.ts +9 -0
- package/dist/types/models/IPassThroughPolicyObligationEnforcerConstructorOptions.d.ts +9 -0
- package/dist/types/models/IPassThroughPolicyRequesterConstructorOptions.d.ts +9 -0
- package/dist/types/models/IStaticPolicyInformationSource.d.ts +8 -5
- package/dist/types/models/IStaticPolicyInformationSourceConstructorOptions.d.ts +0 -1
- package/dist/types/policyArbiters/defaultPolicyArbiter.d.ts +38 -0
- package/dist/types/policyArbiters/passThroughPolicyArbiter.d.ts +32 -0
- package/dist/types/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.d.ts +32 -0
- package/dist/types/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.d.ts +32 -0
- package/dist/types/policyExecutionActions/automationPolicyExecutionAction.d.ts +45 -0
- package/dist/types/policyExecutionActions/loggingPolicyExecutionAction.d.ts +6 -18
- package/dist/types/policyInformationSources/identityPolicyInformationSource.d.ts +5 -6
- package/dist/types/policyInformationSources/identityProfilePolicyInformationSource.d.ts +31 -0
- package/dist/types/policyInformationSources/staticPolicyInformationSource.d.ts +5 -6
- package/dist/types/policyNegotiators/passThroughPolicyNegotiator.d.ts +47 -0
- package/dist/types/policyObligationEnforcers/passThroughPolicyObligationEnforcer.d.ts +32 -0
- package/dist/types/policyRequesters/passThroughPolicyRequester.d.ts +48 -0
- package/docs/changelog.md +1230 -10
- package/docs/examples.md +295 -1
- package/docs/reference/classes/AutomationPolicyExecutionAction.md +143 -0
- package/docs/reference/classes/DefaultPolicyArbiter.md +113 -0
- package/docs/reference/classes/DefaultPolicyEnforcementProcessor.md +107 -0
- package/docs/reference/classes/IdentityPolicyInformationSource.md +14 -14
- package/docs/reference/classes/IdentityProfilePolicyInformationSource.md +103 -0
- package/docs/reference/classes/LoggingPolicyExecutionAction.md +20 -20
- package/docs/reference/classes/PassThroughPolicyArbiter.md +103 -0
- package/docs/reference/classes/PassThroughPolicyEnforcementProcessor.md +107 -0
- package/docs/reference/classes/{ExamplePolicyNegotiator.md → PassThroughPolicyNegotiator.md} +27 -21
- package/docs/reference/classes/PassThroughPolicyObligationEnforcer.md +109 -0
- package/docs/reference/classes/{ExamplePolicyRequester.md → PassThroughPolicyRequester.md} +22 -40
- package/docs/reference/classes/StaticPolicyInformationSource.md +15 -15
- package/docs/reference/index.md +20 -10
- package/docs/reference/interfaces/IAutomationPolicyExecutionActionConfig.md +11 -0
- package/docs/reference/interfaces/IAutomationPolicyExecutionActionConstructorOptions.md +25 -0
- package/docs/reference/interfaces/IDefaultPolicyArbiterConfig.md +17 -0
- package/docs/reference/interfaces/IDefaultPolicyArbiterConstructorOptions.md +33 -0
- package/docs/reference/interfaces/IDefaultPolicyEnforcementProcessorConstructorOptions.md +11 -0
- package/docs/reference/interfaces/IIdentityPolicyInformationSourceConstructorOptions.md +4 -10
- package/docs/reference/interfaces/IIdentityProfilePolicyInformationSourceConstructorOptions.md +25 -0
- package/docs/reference/interfaces/ILoggingPolicyExecutionActionConfig.md +9 -9
- package/docs/reference/interfaces/ILoggingPolicyExecutionActionConstructorOptions.md +4 -10
- package/docs/reference/interfaces/IPassThroughPolicyArbiterConstructorOptions.md +11 -0
- package/docs/reference/interfaces/IPassThroughPolicyEnforcementProcessorConstructorOptions.md +11 -0
- package/docs/reference/interfaces/IPassThroughPolicyNegotiatorConstructorOptions.md +11 -0
- package/docs/reference/interfaces/IPassThroughPolicyObligationEnforcerConstructorOptions.md +11 -0
- package/docs/reference/interfaces/IPassThroughPolicyRequesterConstructorOptions.md +11 -0
- package/docs/reference/interfaces/IStaticPolicyInformationSource.md +21 -6
- package/docs/reference/interfaces/IStaticPolicyInformationSourceConfig.md +2 -2
- package/docs/reference/interfaces/IStaticPolicyInformationSourceConstructorOptions.md +4 -10
- package/locales/en.json +65 -6
- package/package.json +14 -11
- package/dist/es/dataAccessHandlers/examplePolicyRequester.js +0 -82
- package/dist/es/dataAccessHandlers/examplePolicyRequester.js.map +0 -1
- package/dist/es/models/IExampleDataAccessHandlerConstructorOptions.js.map +0 -1
- package/dist/es/models/IExamplePolicyArbiterConstructorOptions.js.map +0 -1
- package/dist/es/models/IExamplePolicyEnforcementProcessorConstructorOptions.js.map +0 -1
- package/dist/es/models/IExamplePolicyNegotiatorConstructorOptions.js.map +0 -1
- package/dist/es/models/IExamplePolicyRequesterConstructorOptions.js.map +0 -1
- package/dist/es/policyArbiters/examplePolicyArbiter.js +0 -50
- package/dist/es/policyArbiters/examplePolicyArbiter.js.map +0 -1
- package/dist/es/policyEnforcementProcessor/examplePolicyEnforcementProcessor.js +0 -42
- package/dist/es/policyEnforcementProcessor/examplePolicyEnforcementProcessor.js.map +0 -1
- package/dist/es/policyNegotiators/examplePolicyNegotiator.js +0 -61
- package/dist/es/policyNegotiators/examplePolicyNegotiator.js.map +0 -1
- package/dist/es/policyRequesters/examplePolicyRequester.js +0 -69
- package/dist/es/policyRequesters/examplePolicyRequester.js.map +0 -1
- package/dist/types/dataAccessHandlers/examplePolicyRequester.d.ts +0 -68
- package/dist/types/models/IExampleDataAccessHandlerConstructorOptions.d.ts +0 -10
- package/dist/types/models/IExamplePolicyArbiterConstructorOptions.d.ts +0 -10
- package/dist/types/models/IExamplePolicyEnforcementProcessorConstructorOptions.d.ts +0 -10
- package/dist/types/models/IExamplePolicyNegotiatorConstructorOptions.d.ts +0 -10
- package/dist/types/models/IExamplePolicyRequesterConstructorOptions.d.ts +0 -10
- package/dist/types/policyArbiters/examplePolicyArbiter.d.ts +0 -36
- package/dist/types/policyEnforcementProcessor/examplePolicyEnforcementProcessor.d.ts +0 -29
- package/dist/types/policyNegotiators/examplePolicyNegotiator.d.ts +0 -45
- package/dist/types/policyRequesters/examplePolicyRequester.d.ts +0 -53
- package/docs/reference/classes/ExampleDataAccessHandler.md +0 -243
- package/docs/reference/classes/ExamplePolicyArbiter.md +0 -121
- package/docs/reference/classes/ExamplePolicyEnforcementProcessor.md +0 -101
- package/docs/reference/interfaces/IExampleDataAccessHandlerConstructorOptions.md +0 -17
- package/docs/reference/interfaces/IExamplePolicyArbiterConstructorOptions.md +0 -17
- package/docs/reference/interfaces/IExamplePolicyEnforcementProcessorConstructorOptions.md +0 -17
- package/docs/reference/interfaces/IExamplePolicyNegotiatorConstructorOptions.md +0 -17
- package/docs/reference/interfaces/IExamplePolicyRequesterConstructorOptions.md +0 -17
package/docs/examples.md
CHANGED
|
@@ -1 +1,295 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Rights Management Plugins Examples
|
|
2
|
+
|
|
3
|
+
These examples show how to wire default and pass-through plugins so negotiation, information retrieval, enforcement, and execution behaviours stay predictable.
|
|
4
|
+
|
|
5
|
+
## PassThroughPolicyRequester
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { PassThroughPolicyRequester } from '@twin.org/rights-management-plugins';
|
|
9
|
+
import { PolicyType } from '@twin.org/standards-w3c-odrl';
|
|
10
|
+
|
|
11
|
+
const requester = new PassThroughPolicyRequester();
|
|
12
|
+
|
|
13
|
+
const offerAccepted = await requester.offer('neg-1', {
|
|
14
|
+
'@id': 'urn:rights-management:offer-1',
|
|
15
|
+
'@type': PolicyType.Offer,
|
|
16
|
+
assigner: 'did:example:provider'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const agreementAccepted = await requester.agreement('neg-1', {
|
|
20
|
+
'@id': 'urn:rights-management:agreement-1',
|
|
21
|
+
'@type': PolicyType.Agreement,
|
|
22
|
+
assigner: 'did:example:provider',
|
|
23
|
+
assignee: 'did:example:consumer'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await requester.finalised('neg-1');
|
|
27
|
+
await requester.terminated('neg-1');
|
|
28
|
+
|
|
29
|
+
console.log(requester.className()); // PassThroughPolicyRequester
|
|
30
|
+
console.log(offerAccepted); // true
|
|
31
|
+
console.log(agreementAccepted); // true
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## PassThroughPolicyNegotiator
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { PassThroughPolicyNegotiator } from '@twin.org/rights-management-plugins';
|
|
38
|
+
import { PolicyType } from '@twin.org/standards-w3c-odrl';
|
|
39
|
+
|
|
40
|
+
const negotiator = new PassThroughPolicyNegotiator();
|
|
41
|
+
|
|
42
|
+
const offer = {
|
|
43
|
+
'@id': 'urn:rights-management:offer-1',
|
|
44
|
+
'@type': PolicyType.Offer,
|
|
45
|
+
assigner: 'did:example:provider'
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const supported = negotiator.supportsOffer(offer);
|
|
49
|
+
const handled = await negotiator.handleOffer(offer, {
|
|
50
|
+
'did:example:consumer': {
|
|
51
|
+
'@id': 'did:example:consumer'
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const agreement = await negotiator.createAgreement(offer, 'did:example:consumer', {
|
|
55
|
+
'did:example:consumer': {
|
|
56
|
+
'@id': 'did:example:consumer'
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
console.log(negotiator.className()); // PassThroughPolicyNegotiator
|
|
61
|
+
console.log(supported); // true
|
|
62
|
+
console.log(handled.accepted); // true
|
|
63
|
+
console.log(agreement?.['@type']); // Agreement
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## LoggingPolicyExecutionAction
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { LoggingPolicyExecutionAction } from '@twin.org/rights-management-plugins';
|
|
70
|
+
import { PolicyDecision, PolicyDecisionStage } from '@twin.org/rights-management-models';
|
|
71
|
+
import { PolicyType } from '@twin.org/standards-w3c-odrl';
|
|
72
|
+
|
|
73
|
+
const action = new LoggingPolicyExecutionAction({
|
|
74
|
+
config: {
|
|
75
|
+
stages: [PolicyDecisionStage.Before, PolicyDecisionStage.After],
|
|
76
|
+
includeData: true,
|
|
77
|
+
includePolicy: false,
|
|
78
|
+
includeDecisions: true
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
await action.execute(
|
|
83
|
+
{
|
|
84
|
+
'@id': 'urn:rights-management:agreement-1',
|
|
85
|
+
'@type': PolicyType.Agreement,
|
|
86
|
+
assigner: 'did:example:provider',
|
|
87
|
+
assignee: 'did:example:consumer'
|
|
88
|
+
},
|
|
89
|
+
[{ target: '$.asset', decision: PolicyDecision.Granted }],
|
|
90
|
+
{ asset: 'dataset-1' },
|
|
91
|
+
'use',
|
|
92
|
+
PolicyDecisionStage.Before
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
console.log(action.className()); // LoggingPolicyExecutionAction
|
|
96
|
+
console.log(action.supportedStages()); // [ 'before', 'after' ]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## StaticPolicyInformationSource
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { PolicyInformationAccessMode } from '@twin.org/rights-management-models';
|
|
103
|
+
import { StaticPolicyInformationSource } from '@twin.org/rights-management-plugins';
|
|
104
|
+
|
|
105
|
+
const source = new StaticPolicyInformationSource({
|
|
106
|
+
config: {
|
|
107
|
+
information: [
|
|
108
|
+
{
|
|
109
|
+
accessMode: PolicyInformationAccessMode.Any,
|
|
110
|
+
objects: {
|
|
111
|
+
'did:example:consumer': {
|
|
112
|
+
'@id': 'did:example:consumer'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
source.addInformation({
|
|
121
|
+
accessMode: PolicyInformationAccessMode.Public,
|
|
122
|
+
objects: {
|
|
123
|
+
'urn:asset:dataset-1': {
|
|
124
|
+
'@id': 'urn:asset:dataset-1'
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
matchLocators: [
|
|
128
|
+
{
|
|
129
|
+
target: 'urn:asset:dataset-1'
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const result = await source.retrieve(
|
|
135
|
+
{
|
|
136
|
+
'@id': 'urn:rights-management:agreement-1',
|
|
137
|
+
'@type': 'Agreement',
|
|
138
|
+
target: 'urn:asset:dataset-1'
|
|
139
|
+
},
|
|
140
|
+
PolicyInformationAccessMode.Public,
|
|
141
|
+
{ requestId: 'request-1' },
|
|
142
|
+
'use'
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
console.log(source.className()); // StaticPolicyInformationSource
|
|
146
|
+
console.log(Object.keys(result ?? {}).length); // 2
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## DefaultPolicyArbiter
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { DefaultPolicyArbiter } from '@twin.org/rights-management-plugins';
|
|
153
|
+
import { PolicyType } from '@twin.org/standards-w3c-odrl';
|
|
154
|
+
|
|
155
|
+
const arbiter = new DefaultPolicyArbiter();
|
|
156
|
+
|
|
157
|
+
const decisions = await arbiter.decide(
|
|
158
|
+
{
|
|
159
|
+
'@id': 'urn:rights-management:agreement-1',
|
|
160
|
+
'@type': PolicyType.Agreement,
|
|
161
|
+
assigner: 'did:example:provider',
|
|
162
|
+
assignee: 'did:example:consumer',
|
|
163
|
+
permission: [
|
|
164
|
+
{
|
|
165
|
+
target: 'urn:asset:dataset-1',
|
|
166
|
+
action: 'use'
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
{},
|
|
171
|
+
{ asset: 'dataset-1' },
|
|
172
|
+
'use'
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
console.log(arbiter.className()); // DefaultPolicyArbiter
|
|
176
|
+
console.log(decisions[0].decision); // granted
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## PassThroughPolicyArbiter
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import { PassThroughPolicyArbiter } from '@twin.org/rights-management-plugins';
|
|
183
|
+
import { PolicyType } from '@twin.org/standards-w3c-odrl';
|
|
184
|
+
|
|
185
|
+
const arbiter = new PassThroughPolicyArbiter();
|
|
186
|
+
|
|
187
|
+
const decisions = await arbiter.decide(
|
|
188
|
+
{
|
|
189
|
+
'@id': 'urn:rights-management:agreement-2',
|
|
190
|
+
'@type': PolicyType.Agreement,
|
|
191
|
+
assigner: 'did:example:provider',
|
|
192
|
+
assignee: 'did:example:consumer'
|
|
193
|
+
},
|
|
194
|
+
{},
|
|
195
|
+
{ asset: 'dataset-2' },
|
|
196
|
+
'read'
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
console.log(arbiter.className()); // PassThroughPolicyArbiter
|
|
200
|
+
console.log(decisions[0].decision); // granted
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## DefaultPolicyEnforcementProcessor
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import { PolicyDecision } from '@twin.org/rights-management-models';
|
|
207
|
+
import { DefaultPolicyEnforcementProcessor } from '@twin.org/rights-management-plugins';
|
|
208
|
+
import { PolicyType } from '@twin.org/standards-w3c-odrl';
|
|
209
|
+
|
|
210
|
+
const processor = new DefaultPolicyEnforcementProcessor();
|
|
211
|
+
|
|
212
|
+
const processed = await processor.process(
|
|
213
|
+
{
|
|
214
|
+
'@id': 'urn:rights-management:agreement-1',
|
|
215
|
+
'@type': PolicyType.Agreement
|
|
216
|
+
},
|
|
217
|
+
[{ target: '$.asset', decision: PolicyDecision.Granted }],
|
|
218
|
+
{ asset: 'dataset-1', hidden: 'no' },
|
|
219
|
+
'use'
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
console.log(processor.className()); // DefaultPolicyEnforcementProcessor
|
|
223
|
+
console.log(processed); // { asset: 'dataset-1' }
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## PassThroughPolicyEnforcementProcessor
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
import { PassThroughPolicyEnforcementProcessor } from '@twin.org/rights-management-plugins';
|
|
230
|
+
import { PolicyType } from '@twin.org/standards-w3c-odrl';
|
|
231
|
+
|
|
232
|
+
const processor = new PassThroughPolicyEnforcementProcessor();
|
|
233
|
+
|
|
234
|
+
const result = await processor.process(
|
|
235
|
+
{
|
|
236
|
+
'@id': 'urn:rights-management:agreement-1',
|
|
237
|
+
'@type': PolicyType.Agreement
|
|
238
|
+
},
|
|
239
|
+
[],
|
|
240
|
+
{ asset: 'dataset-1' },
|
|
241
|
+
'use'
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
console.log(processor.className()); // PassThroughPolicyEnforcementProcessor
|
|
245
|
+
console.log(result); // { asset: 'dataset-1' }
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## IdentityPolicyInformationSource
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import { PolicyInformationAccessMode } from '@twin.org/rights-management-models';
|
|
252
|
+
import { IdentityPolicyInformationSource } from '@twin.org/rights-management-plugins';
|
|
253
|
+
|
|
254
|
+
const source = new IdentityPolicyInformationSource();
|
|
255
|
+
|
|
256
|
+
const info = await source.retrieve(
|
|
257
|
+
{
|
|
258
|
+
'@id': 'urn:rights-management:agreement-1',
|
|
259
|
+
'@type': 'Agreement',
|
|
260
|
+
assigner: 'did:example:provider',
|
|
261
|
+
assignee: 'did:example:consumer'
|
|
262
|
+
},
|
|
263
|
+
PolicyInformationAccessMode.Any,
|
|
264
|
+
{ requestId: 'request-2' },
|
|
265
|
+
'use'
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
console.log(source.className()); // IdentityPolicyInformationSource
|
|
269
|
+
console.log(Object.keys(info ?? {}).length); // 2
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## PassThroughPolicyObligationEnforcer
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
import { PassThroughPolicyObligationEnforcer } from '@twin.org/rights-management-plugins';
|
|
276
|
+
import { PolicyType } from '@twin.org/standards-w3c-odrl';
|
|
277
|
+
|
|
278
|
+
const enforcer = new PassThroughPolicyObligationEnforcer();
|
|
279
|
+
|
|
280
|
+
const enforced = await enforcer.enforce(
|
|
281
|
+
{
|
|
282
|
+
'@id': 'urn:rights-management:agreement-1',
|
|
283
|
+
'@type': PolicyType.Agreement
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
action: 'use'
|
|
287
|
+
},
|
|
288
|
+
{},
|
|
289
|
+
{ requestId: 'request-3' },
|
|
290
|
+
'use'
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
console.log(enforcer.className()); // PassThroughPolicyObligationEnforcer
|
|
294
|
+
console.log(enforced); // true
|
|
295
|
+
```
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Class: AutomationPolicyExecutionAction
|
|
2
|
+
|
|
3
|
+
Automation Policy Execution Action to execute automation policies.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IPolicyExecutionAction`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new AutomationPolicyExecutionAction**(`options?`): `AutomationPolicyExecutionAction`
|
|
14
|
+
|
|
15
|
+
Create a new instance of AutomationPolicyExecutionAction.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### options?
|
|
20
|
+
|
|
21
|
+
[`IAutomationPolicyExecutionActionConstructorOptions`](../interfaces/IAutomationPolicyExecutionActionConstructorOptions.md)
|
|
22
|
+
|
|
23
|
+
The options for the automation policy execution action.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`AutomationPolicyExecutionAction`
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
### CLASS\_NAME {#class_name}
|
|
32
|
+
|
|
33
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
34
|
+
|
|
35
|
+
The class name of the Automation Policy Execution Action.
|
|
36
|
+
|
|
37
|
+
***
|
|
38
|
+
|
|
39
|
+
### BEFORE\_TRIGGER\_NAME {#before_trigger_name}
|
|
40
|
+
|
|
41
|
+
> `readonly` `static` **BEFORE\_TRIGGER\_NAME**: `string` = `"rights-management:pxp:before"`
|
|
42
|
+
|
|
43
|
+
The before automation trigger name.
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
### AFTER\_TRIGGER\_NAME {#after_trigger_name}
|
|
48
|
+
|
|
49
|
+
> `readonly` `static` **AFTER\_TRIGGER\_NAME**: `string` = `"rights-management:pxp:after"`
|
|
50
|
+
|
|
51
|
+
The after automation trigger name.
|
|
52
|
+
|
|
53
|
+
## Methods
|
|
54
|
+
|
|
55
|
+
### className() {#classname}
|
|
56
|
+
|
|
57
|
+
> **className**(): `string`
|
|
58
|
+
|
|
59
|
+
Returns the class name of the component.
|
|
60
|
+
|
|
61
|
+
#### Returns
|
|
62
|
+
|
|
63
|
+
`string`
|
|
64
|
+
|
|
65
|
+
The class name of the component.
|
|
66
|
+
|
|
67
|
+
#### Implementation of
|
|
68
|
+
|
|
69
|
+
`IPolicyExecutionAction.className`
|
|
70
|
+
|
|
71
|
+
***
|
|
72
|
+
|
|
73
|
+
### supportedStages() {#supportedstages}
|
|
74
|
+
|
|
75
|
+
> **supportedStages**(): `PolicyDecisionStage`[]
|
|
76
|
+
|
|
77
|
+
Which stages should the action be executed at.
|
|
78
|
+
|
|
79
|
+
#### Returns
|
|
80
|
+
|
|
81
|
+
`PolicyDecisionStage`[]
|
|
82
|
+
|
|
83
|
+
List of stages.
|
|
84
|
+
|
|
85
|
+
#### Implementation of
|
|
86
|
+
|
|
87
|
+
`IPolicyExecutionAction.supportedStages`
|
|
88
|
+
|
|
89
|
+
***
|
|
90
|
+
|
|
91
|
+
### execute() {#execute}
|
|
92
|
+
|
|
93
|
+
> **execute**\<`D`\>(`policy`, `decisions`, `data`, `action`, `stage`): `Promise`\<`void`\>
|
|
94
|
+
|
|
95
|
+
Execute function type for policy actions.
|
|
96
|
+
|
|
97
|
+
#### Type Parameters
|
|
98
|
+
|
|
99
|
+
##### D
|
|
100
|
+
|
|
101
|
+
`D` = `unknown`
|
|
102
|
+
|
|
103
|
+
#### Parameters
|
|
104
|
+
|
|
105
|
+
##### policy
|
|
106
|
+
|
|
107
|
+
`IRightsManagementPolicy`
|
|
108
|
+
|
|
109
|
+
The policy that applied to the data.
|
|
110
|
+
|
|
111
|
+
##### decisions
|
|
112
|
+
|
|
113
|
+
`IPolicyDecision`[]
|
|
114
|
+
|
|
115
|
+
The decisions made by the PDP.
|
|
116
|
+
|
|
117
|
+
##### data
|
|
118
|
+
|
|
119
|
+
`D` \| `undefined`
|
|
120
|
+
|
|
121
|
+
The data to process.
|
|
122
|
+
|
|
123
|
+
##### action
|
|
124
|
+
|
|
125
|
+
`string` \| `undefined`
|
|
126
|
+
|
|
127
|
+
Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
128
|
+
|
|
129
|
+
##### stage
|
|
130
|
+
|
|
131
|
+
`PolicyDecisionStage`
|
|
132
|
+
|
|
133
|
+
The stage of the policy decision.
|
|
134
|
+
|
|
135
|
+
#### Returns
|
|
136
|
+
|
|
137
|
+
`Promise`\<`void`\>
|
|
138
|
+
|
|
139
|
+
A promise that resolves when the action is complete.
|
|
140
|
+
|
|
141
|
+
#### Implementation of
|
|
142
|
+
|
|
143
|
+
`IPolicyExecutionAction.execute`
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Class: DefaultPolicyArbiter
|
|
2
|
+
|
|
3
|
+
Default Policy Arbiter.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IPolicyArbiter`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new DefaultPolicyArbiter**(`options?`): `DefaultPolicyArbiter`
|
|
14
|
+
|
|
15
|
+
Create a new instance of DefaultPolicyArbiter.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### options?
|
|
20
|
+
|
|
21
|
+
[`IDefaultPolicyArbiterConstructorOptions`](../interfaces/IDefaultPolicyArbiterConstructorOptions.md)
|
|
22
|
+
|
|
23
|
+
The options for the default policy arbiter.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`DefaultPolicyArbiter`
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
### CLASS\_NAME {#class_name}
|
|
32
|
+
|
|
33
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
34
|
+
|
|
35
|
+
The class name of the Default Policy Arbiter.
|
|
36
|
+
|
|
37
|
+
***
|
|
38
|
+
|
|
39
|
+
### SUPPORTED\_PROFILES {#supported_profiles}
|
|
40
|
+
|
|
41
|
+
> `readonly` `static` **SUPPORTED\_PROFILES**: `ReadonlySet`\<`string`\>
|
|
42
|
+
|
|
43
|
+
ODRL profiles whose custom vocabulary this arbiter understands and supports.
|
|
44
|
+
Any policy declaring a profile not in this set will be rejected.
|
|
45
|
+
Add a new entry here when support for an additional profile is implemented.
|
|
46
|
+
|
|
47
|
+
## Methods
|
|
48
|
+
|
|
49
|
+
### className() {#classname}
|
|
50
|
+
|
|
51
|
+
> **className**(): `string`
|
|
52
|
+
|
|
53
|
+
Returns the class name of the component.
|
|
54
|
+
|
|
55
|
+
#### Returns
|
|
56
|
+
|
|
57
|
+
`string`
|
|
58
|
+
|
|
59
|
+
The class name of the component.
|
|
60
|
+
|
|
61
|
+
#### Implementation of
|
|
62
|
+
|
|
63
|
+
`IPolicyArbiter.className`
|
|
64
|
+
|
|
65
|
+
***
|
|
66
|
+
|
|
67
|
+
### decide() {#decide}
|
|
68
|
+
|
|
69
|
+
> **decide**\<`D`\>(`agreement`, `information?`, `data?`, `action?`): `Promise`\<`IPolicyDecision`[]\>
|
|
70
|
+
|
|
71
|
+
Makes decisions regarding policy access to data.
|
|
72
|
+
|
|
73
|
+
#### Type Parameters
|
|
74
|
+
|
|
75
|
+
##### D
|
|
76
|
+
|
|
77
|
+
`D` = `unknown`
|
|
78
|
+
|
|
79
|
+
#### Parameters
|
|
80
|
+
|
|
81
|
+
##### agreement
|
|
82
|
+
|
|
83
|
+
`IDataspaceProtocolAgreement`
|
|
84
|
+
|
|
85
|
+
The agreement to evaluate.
|
|
86
|
+
|
|
87
|
+
##### information?
|
|
88
|
+
|
|
89
|
+
`IRightsManagementInformation`
|
|
90
|
+
|
|
91
|
+
Information provided by the requester to determine if a policy can be created.
|
|
92
|
+
|
|
93
|
+
##### data?
|
|
94
|
+
|
|
95
|
+
`D`
|
|
96
|
+
|
|
97
|
+
The data to make a decision on.
|
|
98
|
+
|
|
99
|
+
##### action?
|
|
100
|
+
|
|
101
|
+
`string`
|
|
102
|
+
|
|
103
|
+
Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
104
|
+
|
|
105
|
+
#### Returns
|
|
106
|
+
|
|
107
|
+
`Promise`\<`IPolicyDecision`[]\>
|
|
108
|
+
|
|
109
|
+
The decisions about access to the data.
|
|
110
|
+
|
|
111
|
+
#### Implementation of
|
|
112
|
+
|
|
113
|
+
`IPolicyArbiter.decide`
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Class: DefaultPolicyEnforcementProcessor
|
|
2
|
+
|
|
3
|
+
Default Policy Enforcement Processor.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IPolicyEnforcementProcessor`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new DefaultPolicyEnforcementProcessor**(`options?`): `DefaultPolicyEnforcementProcessor`
|
|
14
|
+
|
|
15
|
+
Create a new instance of DefaultPolicyEnforcementProcessor.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### options?
|
|
20
|
+
|
|
21
|
+
[`IDefaultPolicyEnforcementProcessorConstructorOptions`](../interfaces/IDefaultPolicyEnforcementProcessorConstructorOptions.md)
|
|
22
|
+
|
|
23
|
+
The options for the default policy enforcement processor.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`DefaultPolicyEnforcementProcessor`
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
### CLASS\_NAME {#class_name}
|
|
32
|
+
|
|
33
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
34
|
+
|
|
35
|
+
The class name of the Default Policy Enforcement Processor.
|
|
36
|
+
|
|
37
|
+
## Methods
|
|
38
|
+
|
|
39
|
+
### className() {#classname}
|
|
40
|
+
|
|
41
|
+
> **className**(): `string`
|
|
42
|
+
|
|
43
|
+
Returns the class name of the component.
|
|
44
|
+
|
|
45
|
+
#### Returns
|
|
46
|
+
|
|
47
|
+
`string`
|
|
48
|
+
|
|
49
|
+
The class name of the component.
|
|
50
|
+
|
|
51
|
+
#### Implementation of
|
|
52
|
+
|
|
53
|
+
`IPolicyEnforcementProcessor.className`
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### process() {#process}
|
|
58
|
+
|
|
59
|
+
> **process**\<`D`, `R`\>(`agreement`, `decisions`, `data?`, `action?`): `Promise`\<`R`\>
|
|
60
|
+
|
|
61
|
+
Process the response from the policy decision point.
|
|
62
|
+
|
|
63
|
+
#### Type Parameters
|
|
64
|
+
|
|
65
|
+
##### D
|
|
66
|
+
|
|
67
|
+
`D` = `unknown`
|
|
68
|
+
|
|
69
|
+
##### R
|
|
70
|
+
|
|
71
|
+
`R` = `D`
|
|
72
|
+
|
|
73
|
+
#### Parameters
|
|
74
|
+
|
|
75
|
+
##### agreement
|
|
76
|
+
|
|
77
|
+
`IDataspaceProtocolAgreement`
|
|
78
|
+
|
|
79
|
+
The agreement to process.
|
|
80
|
+
|
|
81
|
+
##### decisions
|
|
82
|
+
|
|
83
|
+
`IPolicyDecision`[]
|
|
84
|
+
|
|
85
|
+
The decisions made by the policy decision point.
|
|
86
|
+
|
|
87
|
+
##### data?
|
|
88
|
+
|
|
89
|
+
`D`
|
|
90
|
+
|
|
91
|
+
The data to process.
|
|
92
|
+
|
|
93
|
+
##### action?
|
|
94
|
+
|
|
95
|
+
`string`
|
|
96
|
+
|
|
97
|
+
Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
98
|
+
|
|
99
|
+
#### Returns
|
|
100
|
+
|
|
101
|
+
`Promise`\<`R`\>
|
|
102
|
+
|
|
103
|
+
The data after processing.
|
|
104
|
+
|
|
105
|
+
#### Implementation of
|
|
106
|
+
|
|
107
|
+
`IPolicyEnforcementProcessor.process`
|