@twin.org/rights-management-plugins 0.0.3-next.4 → 0.0.3-next.41
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 +18 -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/ILoggingPolicyExecutionActionConfig.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/policyArbiters/defaultPolicyArbiter.js +1657 -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 +146 -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 +76 -0
- package/dist/es/policyExecutionActions/automationPolicyExecutionAction.js.map +1 -0
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js +16 -15
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js.map +1 -1
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js +43 -31
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js.map +1 -1
- package/dist/es/policyInformationSources/staticPolicyInformationSource.js +17 -15
- 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 +18 -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 +20 -0
- package/dist/types/models/{IExamplePolicyEnforcementProcessorConstructorOptions.d.ts → IDefaultPolicyEnforcementProcessorConstructorOptions.d.ts} +2 -2
- package/dist/types/models/ILoggingPolicyExecutionActionConfig.d.ts +2 -2
- package/dist/types/models/{IExamplePolicyArbiterConstructorOptions.d.ts → IPassThroughPolicyArbiterConstructorOptions.d.ts} +2 -2
- package/dist/types/models/IPassThroughPolicyEnforcementProcessorConstructorOptions.d.ts +10 -0
- package/dist/types/models/{IExamplePolicyNegotiatorConstructorOptions.d.ts → IPassThroughPolicyNegotiatorConstructorOptions.d.ts} +2 -2
- package/dist/types/models/IPassThroughPolicyObligationEnforcerConstructorOptions.d.ts +10 -0
- package/dist/types/models/{IExamplePolicyRequesterConstructorOptions.d.ts → IPassThroughPolicyRequesterConstructorOptions.d.ts} +2 -2
- package/dist/types/models/IStaticPolicyInformationSource.d.ts +10 -4
- package/dist/types/policyArbiters/defaultPolicyArbiter.d.ts +41 -0
- package/dist/types/policyArbiters/passThroughPolicyArbiter.d.ts +35 -0
- package/dist/types/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.d.ts +40 -0
- package/dist/types/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.d.ts +32 -0
- package/dist/types/policyExecutionActions/automationPolicyExecutionAction.d.ts +49 -0
- package/dist/types/policyExecutionActions/loggingPolicyExecutionAction.d.ts +8 -8
- package/dist/types/policyInformationSources/identityPolicyInformationSource.d.ts +8 -6
- package/dist/types/policyInformationSources/staticPolicyInformationSource.d.ts +7 -5
- package/dist/types/policyNegotiators/passThroughPolicyNegotiator.d.ts +52 -0
- package/dist/types/policyObligationEnforcers/passThroughPolicyObligationEnforcer.d.ts +35 -0
- package/dist/types/policyRequesters/{examplePolicyRequester.d.ts → passThroughPolicyRequester.d.ts} +15 -20
- package/docs/changelog.md +835 -3
- package/docs/examples.md +295 -1
- package/docs/reference/classes/AutomationPolicyExecutionAction.md +143 -0
- package/docs/reference/classes/DefaultPolicyArbiter.md +111 -0
- package/docs/reference/classes/DefaultPolicyEnforcementProcessor.md +107 -0
- package/docs/reference/classes/IdentityPolicyInformationSource.md +14 -14
- package/docs/reference/classes/LoggingPolicyExecutionAction.md +20 -20
- package/docs/reference/classes/PassThroughPolicyArbiter.md +101 -0
- package/docs/reference/classes/PassThroughPolicyEnforcementProcessor.md +107 -0
- package/docs/reference/classes/{ExamplePolicyNegotiator.md → PassThroughPolicyNegotiator.md} +24 -22
- package/docs/reference/classes/PassThroughPolicyObligationEnforcer.md +107 -0
- package/docs/reference/classes/{ExamplePolicyRequester.md → PassThroughPolicyRequester.md} +20 -38
- package/docs/reference/classes/StaticPolicyInformationSource.md +15 -15
- package/docs/reference/index.md +18 -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 +39 -0
- package/docs/reference/interfaces/IDefaultPolicyEnforcementProcessorConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IIdentityPolicyInformationSourceConstructorOptions.md +4 -4
- package/docs/reference/interfaces/ILoggingPolicyExecutionActionConfig.md +9 -9
- package/docs/reference/interfaces/ILoggingPolicyExecutionActionConstructorOptions.md +4 -4
- package/docs/reference/interfaces/IPassThroughPolicyArbiterConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IPassThroughPolicyEnforcementProcessorConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IPassThroughPolicyNegotiatorConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IPassThroughPolicyObligationEnforcerConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IPassThroughPolicyRequesterConstructorOptions.md +17 -0
- package/docs/reference/interfaces/IStaticPolicyInformationSource.md +25 -6
- package/docs/reference/interfaces/IStaticPolicyInformationSourceConfig.md +2 -2
- package/docs/reference/interfaces/IStaticPolicyInformationSourceConstructorOptions.md +4 -4
- package/locales/en.json +58 -6
- package/package.json +7 -5
- 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/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/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
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ComponentFactory, Guards } from "@twin.org/core";
|
|
4
|
+
import { OdrlPolicyHelper } from "@twin.org/rights-management-models";
|
|
5
|
+
/**
|
|
6
|
+
* Pass Through Policy Obligation Enforcer.
|
|
7
|
+
*/
|
|
8
|
+
export class PassThroughPolicyObligationEnforcer {
|
|
9
|
+
/**
|
|
10
|
+
* The class name of the Pass Through Policy Obligation Enforcer.
|
|
11
|
+
*/
|
|
12
|
+
static CLASS_NAME = "PassThroughPolicyObligationEnforcer";
|
|
13
|
+
/**
|
|
14
|
+
* The logging component.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
_logging;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of Pass Through Policy Obligation Enforcer.
|
|
20
|
+
* @param options The options for the pass through policy obligation enforcer.
|
|
21
|
+
*/
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this._logging = ComponentFactory.get(options?.loggingComponentType ?? "logging");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the class name of the component.
|
|
27
|
+
* @returns The class name of the component.
|
|
28
|
+
*/
|
|
29
|
+
className() {
|
|
30
|
+
return PassThroughPolicyObligationEnforcer.CLASS_NAME;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Enforces obligations regarding policy access to data.
|
|
34
|
+
* @param policy The policy to evaluate.
|
|
35
|
+
* @param duty The duty to enforce.
|
|
36
|
+
* @param information Information provided by the requester to determine if a policy can be created.
|
|
37
|
+
* @param data The data to make a decision on.
|
|
38
|
+
* @param action Optional action to make a decision on, if not provided, the enforcer will evaluate all actions in the duty.
|
|
39
|
+
* @returns Whether the obligations were successfully enforced.
|
|
40
|
+
*/
|
|
41
|
+
async enforce(policy, duty, information, data, action) {
|
|
42
|
+
Guards.object(PassThroughPolicyObligationEnforcer.CLASS_NAME, "policy", policy);
|
|
43
|
+
Guards.object(PassThroughPolicyObligationEnforcer.CLASS_NAME, "duty", duty);
|
|
44
|
+
await this._logging.log({
|
|
45
|
+
level: "info",
|
|
46
|
+
source: PassThroughPolicyObligationEnforcer.CLASS_NAME,
|
|
47
|
+
ts: Date.now(),
|
|
48
|
+
message: "enforcingDuty",
|
|
49
|
+
data: {
|
|
50
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? ""
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=passThroughPolicyObligationEnforcer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passThroughPolicyObligationEnforcer.js","sourceRoot":"","sources":["../../../src/policyObligationEnforcers/passThroughPolicyObligationEnforcer.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI1D,OAAO,EACN,gBAAgB,EAGhB,MAAM,oCAAoC,CAAC;AAI5C;;GAEG;AACH,MAAM,OAAO,mCAAmC;IAC/C;;OAEG;IACI,MAAM,CAAU,UAAU,yCAAyD;IAE1F;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAAgE;QAC3E,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,mCAAmC,CAAC,UAAU,CAAC;IACvD,CAAC;IAED;;;;;;;;OAQG;IACI,KAAK,CAAC,OAAO,CACnB,MAA+B,EAC/B,IAAe,EACf,WAAiD,EACjD,IAAQ,EACR,MAAgC;QAEhC,MAAM,CAAC,MAAM,CACZ,mCAAmC,CAAC,UAAU,YAE9C,MAAM,CACN,CAAC;QACF,MAAM,CAAC,MAAM,CAAY,mCAAmC,CAAC,UAAU,UAAgB,IAAI,CAAC,CAAC;QAE7F,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,mCAAmC,CAAC,UAAU;YACtD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE;gBACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;aAC/C;SACD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACb,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\ttype IPolicyObligationEnforcer,\n\ttype IRightsManagementPolicy\n} from \"@twin.org/rights-management-models\";\nimport type { OdrlActionType, IOdrlDuty } from \"@twin.org/standards-w3c-odrl\";\nimport type { IPassThroughPolicyObligationEnforcerConstructorOptions } from \"../models/IPassThroughPolicyObligationEnforcerConstructorOptions.js\";\n\n/**\n * Pass Through Policy Obligation Enforcer.\n */\nexport class PassThroughPolicyObligationEnforcer implements IPolicyObligationEnforcer {\n\t/**\n\t * The class name of the Pass Through Policy Obligation Enforcer.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<PassThroughPolicyObligationEnforcer>();\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 Pass Through Policy Obligation Enforcer.\n\t * @param options The options for the pass through policy obligation enforcer.\n\t */\n\tconstructor(options?: IPassThroughPolicyObligationEnforcerConstructorOptions) {\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 PassThroughPolicyObligationEnforcer.CLASS_NAME;\n\t}\n\n\t/**\n\t * Enforces obligations regarding policy access to data.\n\t * @param policy The policy to evaluate.\n\t * @param duty The duty to enforce.\n\t * @param information Information provided by the requester to determine if a policy can be created.\n\t * @param data The data to make a decision on.\n\t * @param action Optional action to make a decision on, if not provided, the enforcer will evaluate all actions in the duty.\n\t * @returns Whether the obligations were successfully enforced.\n\t */\n\tpublic async enforce<D = unknown>(\n\t\tpolicy: IRightsManagementPolicy,\n\t\tduty: IOdrlDuty,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: D,\n\t\taction?: OdrlActionType | string\n\t): Promise<boolean> {\n\t\tGuards.object<IRightsManagementPolicy>(\n\t\t\tPassThroughPolicyObligationEnforcer.CLASS_NAME,\n\t\t\tnameof(policy),\n\t\t\tpolicy\n\t\t);\n\t\tGuards.object<IOdrlDuty>(PassThroughPolicyObligationEnforcer.CLASS_NAME, nameof(duty), duty);\n\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyObligationEnforcer.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"enforcingDuty\",\n\t\t\tdata: {\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ComponentFactory } from "@twin.org/core";
|
|
4
|
+
import { OdrlPolicyHelper } from "@twin.org/rights-management-models";
|
|
5
|
+
/**
|
|
6
|
+
* Pass Through Policy Requester.
|
|
7
|
+
*/
|
|
8
|
+
export class PassThroughPolicyRequester {
|
|
9
|
+
/**
|
|
10
|
+
* The class name of the Pass Through Policy Requester.
|
|
11
|
+
*/
|
|
12
|
+
static CLASS_NAME = "PassThroughPolicyRequester";
|
|
13
|
+
/**
|
|
14
|
+
* The logging component.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
_logging;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of PassThroughPolicyRequester.
|
|
20
|
+
* @param options The options for the pass through policy Requester.
|
|
21
|
+
*/
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this._logging = ComponentFactory.get(options?.loggingComponentType ?? "logging");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the class name of the component.
|
|
27
|
+
* @returns The class name of the component.
|
|
28
|
+
*/
|
|
29
|
+
className() {
|
|
30
|
+
return PassThroughPolicyRequester.CLASS_NAME;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A policy has been offered by a provider, let the request handler know about it.
|
|
34
|
+
* @param negotiationId The id of the negotiation.
|
|
35
|
+
* @param offer The offer sent by the provider.
|
|
36
|
+
* @returns True if the offer was accepted, false otherwise.
|
|
37
|
+
*/
|
|
38
|
+
async offer(negotiationId, offer) {
|
|
39
|
+
await this._logging.log({
|
|
40
|
+
level: "info",
|
|
41
|
+
source: PassThroughPolicyRequester.CLASS_NAME,
|
|
42
|
+
ts: Date.now(),
|
|
43
|
+
message: "offer",
|
|
44
|
+
data: {
|
|
45
|
+
negotiationId,
|
|
46
|
+
offerId: OdrlPolicyHelper.getUid(offer) ?? ""
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A policy agreement has been sent by a provider, let the request handler know about it.
|
|
53
|
+
* @param negotiationId The id of the negotiation.
|
|
54
|
+
* @param agreement The agreement sent by the provider.
|
|
55
|
+
* @returns True if the agreement was accepted, false otherwise.
|
|
56
|
+
*/
|
|
57
|
+
async agreement(negotiationId, agreement) {
|
|
58
|
+
await this._logging.log({
|
|
59
|
+
level: "info",
|
|
60
|
+
source: PassThroughPolicyRequester.CLASS_NAME,
|
|
61
|
+
ts: Date.now(),
|
|
62
|
+
message: "agreement",
|
|
63
|
+
data: {
|
|
64
|
+
negotiationId,
|
|
65
|
+
agreementId: OdrlPolicyHelper.getUid(agreement) ?? ""
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A policy finalisation has been sent by a provider, let the request handler know about it.
|
|
72
|
+
* @param negotiationId The id of the negotiation.
|
|
73
|
+
* @returns Nothing.
|
|
74
|
+
*/
|
|
75
|
+
async finalised(negotiationId) {
|
|
76
|
+
await this._logging.log({
|
|
77
|
+
level: "info",
|
|
78
|
+
source: PassThroughPolicyRequester.CLASS_NAME,
|
|
79
|
+
ts: Date.now(),
|
|
80
|
+
message: "finalised",
|
|
81
|
+
data: {
|
|
82
|
+
negotiationId
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A policy termination has been sent by a provider, let the request handler know about it.
|
|
88
|
+
* @param negotiationId The id of the negotiation.
|
|
89
|
+
* @returns Nothing.
|
|
90
|
+
*/
|
|
91
|
+
async terminated(negotiationId) {
|
|
92
|
+
await this._logging.log({
|
|
93
|
+
level: "info",
|
|
94
|
+
source: PassThroughPolicyRequester.CLASS_NAME,
|
|
95
|
+
ts: Date.now(),
|
|
96
|
+
message: "terminated",
|
|
97
|
+
data: {
|
|
98
|
+
negotiationId
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=passThroughPolicyRequester.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passThroughPolicyRequester.js","sourceRoot":"","sources":["../../../src/policyRequesters/passThroughPolicyRequester.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAyB,MAAM,oCAAoC,CAAC;AAO7F;;GAEG;AACH,MAAM,OAAO,0BAA0B;IACtC;;OAEG;IACI,MAAM,CAAU,UAAU,gCAAgD;IAEjF;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAAuD;QAClE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,0BAA0B,CAAC,UAAU,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAK,CAAC,aAAqB,EAAE,KAA8B;QACvE,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,0BAA0B,CAAC,UAAU;YAC7C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE;gBACL,aAAa;gBACb,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;aAC7C;SACD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CACrB,aAAqB,EACrB,SAAsC;QAEtC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,0BAA0B,CAAC,UAAU;YAC7C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,WAAW;YACpB,IAAI,EAAE;gBACL,aAAa;gBACb,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;aACrD;SACD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,SAAS,CAAC,aAAqB;QAC3C,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,0BAA0B,CAAC,UAAU;YAC7C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,WAAW;YACpB,IAAI,EAAE;gBACL,aAAa;aACb;SACD,CAAC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,UAAU,CAAC,aAAqB;QAC5C,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,0BAA0B,CAAC,UAAU;YAC7C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,YAAY;YACrB,IAAI,EAAE;gBACL,aAAa;aACb;SACD,CAAC,CAAC;IACJ,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 { OdrlPolicyHelper, type IPolicyRequester } from \"@twin.org/rights-management-models\";\nimport type {\n\tIDataspaceProtocolAgreement,\n\tIDataspaceProtocolOffer\n} from \"@twin.org/standards-dataspace-protocol\";\nimport type { IPassThroughPolicyRequesterConstructorOptions } from \"../models/IPassThroughPolicyRequesterConstructorOptions.js\";\n\n/**\n * Pass Through Policy Requester.\n */\nexport class PassThroughPolicyRequester implements IPolicyRequester {\n\t/**\n\t * The class name of the Pass Through Policy Requester.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<PassThroughPolicyRequester>();\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 PassThroughPolicyRequester.\n\t * @param options The options for the pass through policy Requester.\n\t */\n\tconstructor(options?: IPassThroughPolicyRequesterConstructorOptions) {\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 PassThroughPolicyRequester.CLASS_NAME;\n\t}\n\n\t/**\n\t * A policy has been offered by a provider, let the request handler know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @param offer The offer sent by the provider.\n\t * @returns True if the offer was accepted, false otherwise.\n\t */\n\tpublic async offer(negotiationId: string, offer: IDataspaceProtocolOffer): Promise<boolean> {\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyRequester.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"offer\",\n\t\t\tdata: {\n\t\t\t\tnegotiationId,\n\t\t\t\tofferId: OdrlPolicyHelper.getUid(offer) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * A policy agreement has been sent by a provider, let the request handler know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @param agreement The agreement sent by the provider.\n\t * @returns True if the agreement was accepted, false otherwise.\n\t */\n\tpublic async agreement(\n\t\tnegotiationId: string,\n\t\tagreement: IDataspaceProtocolAgreement\n\t): Promise<boolean> {\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyRequester.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"agreement\",\n\t\t\tdata: {\n\t\t\t\tnegotiationId,\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * A policy finalisation has been sent by a provider, let the request handler know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @returns Nothing.\n\t */\n\tpublic async finalised(negotiationId: string): Promise<void> {\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyRequester.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"finalised\",\n\t\t\tdata: {\n\t\t\t\tnegotiationId\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * A policy termination has been sent by a provider, let the request handler know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @returns Nothing.\n\t */\n\tpublic async terminated(negotiationId: string): Promise<void> {\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyRequester.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"terminated\",\n\t\t\tdata: {\n\t\t\t\tnegotiationId\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./models/
|
|
3
|
-
export * from "./models/
|
|
4
|
-
export * from "./models/
|
|
5
|
-
export * from "./models/
|
|
6
|
-
export * from "./models/IExamplePolicyRequesterConstructorOptions.js";
|
|
1
|
+
export * from "./models/IAutomationPolicyExecutionActionConfig.js";
|
|
2
|
+
export * from "./models/IAutomationPolicyExecutionActionConstructorOptions.js";
|
|
3
|
+
export * from "./models/IDefaultPolicyArbiterConfig.js";
|
|
4
|
+
export * from "./models/IDefaultPolicyArbiterConstructorOptions.js";
|
|
5
|
+
export * from "./models/IDefaultPolicyEnforcementProcessorConstructorOptions.js";
|
|
7
6
|
export * from "./models/IIdentityPolicyInformationSourceConstructorOptions.js";
|
|
8
7
|
export * from "./models/ILoggingPolicyExecutionActionConfig.js";
|
|
9
8
|
export * from "./models/ILoggingPolicyExecutionActionConstructorOptions.js";
|
|
9
|
+
export * from "./models/IPassThroughPolicyArbiterConstructorOptions.js";
|
|
10
|
+
export * from "./models/IPassThroughPolicyEnforcementProcessorConstructorOptions.js";
|
|
11
|
+
export * from "./models/IPassThroughPolicyNegotiatorConstructorOptions.js";
|
|
12
|
+
export * from "./models/IPassThroughPolicyObligationEnforcerConstructorOptions.js";
|
|
13
|
+
export * from "./models/IPassThroughPolicyRequesterConstructorOptions.js";
|
|
10
14
|
export * from "./models/IStaticPolicyInformationSource.js";
|
|
11
15
|
export * from "./models/IStaticPolicyInformationSourceConfig.js";
|
|
12
16
|
export * from "./models/IStaticPolicyInformationSourceConstructorOptions.js";
|
|
13
|
-
export * from "./policyArbiters/
|
|
14
|
-
export * from "./
|
|
17
|
+
export * from "./policyArbiters/defaultPolicyArbiter.js";
|
|
18
|
+
export * from "./policyArbiters/passThroughPolicyArbiter.js";
|
|
19
|
+
export * from "./policyEnforcementProcessor/defaultPolicyEnforcementProcessor.js";
|
|
20
|
+
export * from "./policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.js";
|
|
21
|
+
export * from "./policyExecutionActions/automationPolicyExecutionAction.js";
|
|
15
22
|
export * from "./policyExecutionActions/loggingPolicyExecutionAction.js";
|
|
16
23
|
export * from "./policyInformationSources/identityPolicyInformationSource.js";
|
|
17
24
|
export * from "./policyInformationSources/staticPolicyInformationSource.js";
|
|
18
|
-
export * from "./policyNegotiators/
|
|
19
|
-
export * from "./
|
|
25
|
+
export * from "./policyNegotiators/passThroughPolicyNegotiator.js";
|
|
26
|
+
export * from "./policyObligationEnforcers/passThroughPolicyObligationEnforcer.js";
|
|
27
|
+
export * from "./policyRequesters/passThroughPolicyRequester.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for the Automation Policy Execution Action Component.
|
|
3
|
+
*/
|
|
4
|
+
export interface IAutomationPolicyExecutionActionConfig {
|
|
5
|
+
/**
|
|
6
|
+
* The policy decision stages to trigger the automation actions, if undefined defaults to "inform".
|
|
7
|
+
*/
|
|
8
|
+
triggerActions?: string[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IAutomationPolicyExecutionActionConfig } from "./IAutomationPolicyExecutionActionConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the Automation Policy Execution Action.
|
|
4
|
+
*/
|
|
5
|
+
export interface IAutomationPolicyExecutionActionConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The automation component for executing automation policies.
|
|
8
|
+
* @default automation
|
|
9
|
+
*/
|
|
10
|
+
automationComponentType?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The configuration for the automation policy execution.
|
|
13
|
+
*/
|
|
14
|
+
config?: IAutomationPolicyExecutionActionConfig;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IDefaultPolicyArbiterConfig } from "./IDefaultPolicyArbiterConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the Default Policy Arbiter.
|
|
4
|
+
*/
|
|
5
|
+
export interface IDefaultPolicyArbiterConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The logging component for policy arbiter.
|
|
8
|
+
* @default logging
|
|
9
|
+
*/
|
|
10
|
+
loggingComponentType?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The policy administration point component for retrieving inherited policies.
|
|
13
|
+
* @default policy-administration-point
|
|
14
|
+
*/
|
|
15
|
+
policyAdministrationPointComponentType?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The configuration options for the default policy arbiter.
|
|
18
|
+
*/
|
|
19
|
+
config?: IDefaultPolicyArbiterConfig;
|
|
20
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Options for the
|
|
2
|
+
* Options for the Default Policy Enforcement Processor.
|
|
3
3
|
*/
|
|
4
|
-
export interface
|
|
4
|
+
export interface IDefaultPolicyEnforcementProcessorConstructorOptions {
|
|
5
5
|
/**
|
|
6
6
|
* The logging component for policy enforcement processor.
|
|
7
7
|
* @default logging
|
|
@@ -13,10 +13,10 @@ export interface ILoggingPolicyExecutionActionConfig {
|
|
|
13
13
|
*/
|
|
14
14
|
includeData?: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* Whether to include the
|
|
16
|
+
* Whether to include the policy in the log.
|
|
17
17
|
* @default false
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
includePolicy?: boolean;
|
|
20
20
|
/**
|
|
21
21
|
* Whether to include the decisions in the log.
|
|
22
22
|
* @default false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Options for the
|
|
2
|
+
* Options for the Pass Through Policy Arbiter.
|
|
3
3
|
*/
|
|
4
|
-
export interface
|
|
4
|
+
export interface IPassThroughPolicyArbiterConstructorOptions {
|
|
5
5
|
/**
|
|
6
6
|
* The logging component for policy arbiter.
|
|
7
7
|
* @default logging
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for the Pass Through Policy Enforcement Processor.
|
|
3
|
+
*/
|
|
4
|
+
export interface IPassThroughPolicyEnforcementProcessorConstructorOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The logging component for policy enforcement processor.
|
|
7
|
+
* @default logging
|
|
8
|
+
*/
|
|
9
|
+
loggingComponentType?: string;
|
|
10
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Options for the
|
|
2
|
+
* Options for the Pass Through Policy Negotiator.
|
|
3
3
|
*/
|
|
4
|
-
export interface
|
|
4
|
+
export interface IPassThroughPolicyNegotiatorConstructorOptions {
|
|
5
5
|
/**
|
|
6
6
|
* The logging component for policy negotiator.
|
|
7
7
|
* @default logging
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for the Pass Through Policy Obligation Enforcer.
|
|
3
|
+
*/
|
|
4
|
+
export interface IPassThroughPolicyObligationEnforcerConstructorOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The logging component for the policy obligation enforcer.
|
|
7
|
+
* @default logging
|
|
8
|
+
*/
|
|
9
|
+
loggingComponentType?: string;
|
|
10
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Options for the
|
|
2
|
+
* Options for the Pass Through Policy Requester.
|
|
3
3
|
*/
|
|
4
|
-
export interface
|
|
4
|
+
export interface IPassThroughPolicyRequesterConstructorOptions {
|
|
5
5
|
/**
|
|
6
6
|
* The logging component for policy requester.
|
|
7
7
|
* @default logging
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PolicyInformationAccessMode } from "@twin.org/rights-management-models";
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for the Static Policy Information Source Component.
|
|
5
5
|
*/
|
|
@@ -10,11 +10,17 @@ export interface IStaticPolicyInformationSource {
|
|
|
10
10
|
accessMode: PolicyInformationAccessMode;
|
|
11
11
|
/**
|
|
12
12
|
* Information is only provided for the specified locator combination.
|
|
13
|
-
* If undefined is provided matches all resources.
|
|
14
13
|
*/
|
|
15
|
-
matchLocators?:
|
|
14
|
+
matchLocators?: {
|
|
15
|
+
assignee?: string;
|
|
16
|
+
assigner?: string;
|
|
17
|
+
target?: string;
|
|
18
|
+
action?: string;
|
|
19
|
+
}[];
|
|
16
20
|
/**
|
|
17
21
|
* The objects containing the information.
|
|
18
22
|
*/
|
|
19
|
-
objects:
|
|
23
|
+
objects: {
|
|
24
|
+
[id: string]: IJsonLdNodeObject;
|
|
25
|
+
};
|
|
20
26
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
+
import { type IPolicyArbiter, type IPolicyDecision } from "@twin.org/rights-management-models";
|
|
3
|
+
import type { IDataspaceProtocolAgreement } from "@twin.org/standards-dataspace-protocol";
|
|
4
|
+
import { type OdrlActionType } from "@twin.org/standards-w3c-odrl";
|
|
5
|
+
import type { IDefaultPolicyArbiterConstructorOptions } from "../models/IDefaultPolicyArbiterConstructorOptions.js";
|
|
6
|
+
/**
|
|
7
|
+
* Default Policy Arbiter.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DefaultPolicyArbiter implements IPolicyArbiter {
|
|
10
|
+
/**
|
|
11
|
+
* The class name of the Default Policy Arbiter.
|
|
12
|
+
*/
|
|
13
|
+
static readonly CLASS_NAME: string;
|
|
14
|
+
/**
|
|
15
|
+
* ODRL profiles whose custom vocabulary this arbiter understands and supports.
|
|
16
|
+
* Any policy declaring a profile not in this set will be rejected.
|
|
17
|
+
* Add a new entry here when support for an additional profile is implemented.
|
|
18
|
+
*/
|
|
19
|
+
static readonly SUPPORTED_PROFILES: ReadonlySet<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new instance of DefaultPolicyArbiter.
|
|
22
|
+
* @param options The options for the default policy arbiter.
|
|
23
|
+
*/
|
|
24
|
+
constructor(options?: IDefaultPolicyArbiterConstructorOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Returns the class name of the component.
|
|
27
|
+
* @returns The class name of the component.
|
|
28
|
+
*/
|
|
29
|
+
className(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Makes decisions regarding policy access to data.
|
|
32
|
+
* @param agreement The agreement to evaluate.
|
|
33
|
+
* @param information Information provided by the requester to determine if a policy can be created.
|
|
34
|
+
* @param data The data to make a decision on.
|
|
35
|
+
* @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
36
|
+
* @returns The decisions about access to the data.
|
|
37
|
+
*/
|
|
38
|
+
decide<D = unknown>(agreement: IDataspaceProtocolAgreement, information?: {
|
|
39
|
+
[id: string]: IJsonLdNodeObject;
|
|
40
|
+
}, data?: D, action?: OdrlActionType | string): Promise<IPolicyDecision[]>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
+
import { type IPolicyArbiter, type IPolicyDecision } from "@twin.org/rights-management-models";
|
|
3
|
+
import type { IDataspaceProtocolAgreement } from "@twin.org/standards-dataspace-protocol";
|
|
4
|
+
import type { OdrlActionType } from "@twin.org/standards-w3c-odrl";
|
|
5
|
+
import type { IPassThroughPolicyArbiterConstructorOptions } from "../models/IPassThroughPolicyArbiterConstructorOptions.js";
|
|
6
|
+
/**
|
|
7
|
+
* Pass Through Policy Arbiter.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PassThroughPolicyArbiter implements IPolicyArbiter {
|
|
10
|
+
/**
|
|
11
|
+
* The class name of the Pass Through Policy Arbiter.
|
|
12
|
+
*/
|
|
13
|
+
static readonly CLASS_NAME: string;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new instance of PassThroughPolicyArbiter.
|
|
16
|
+
* @param options The options for the pass through policy arbiter.
|
|
17
|
+
*/
|
|
18
|
+
constructor(options?: IPassThroughPolicyArbiterConstructorOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Returns the class name of the component.
|
|
21
|
+
* @returns The class name of the component.
|
|
22
|
+
*/
|
|
23
|
+
className(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Makes decisions regarding policy access to data.
|
|
26
|
+
* @param agreement The agreement to evaluate.
|
|
27
|
+
* @param information Information provided by the requester to determine if a policy can be created.
|
|
28
|
+
* @param data The data to make a decision on.
|
|
29
|
+
* @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
30
|
+
* @returns The decisions about access to the data.
|
|
31
|
+
*/
|
|
32
|
+
decide<D = unknown>(agreement: IDataspaceProtocolAgreement, information?: {
|
|
33
|
+
[id: string]: IJsonLdNodeObject;
|
|
34
|
+
}, data?: D, action?: OdrlActionType | string): Promise<IPolicyDecision[]>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type IPolicyDecision, type IPolicyEnforcementProcessor } from "@twin.org/rights-management-models";
|
|
2
|
+
import type { IDataspaceProtocolAgreement } from "@twin.org/standards-dataspace-protocol";
|
|
3
|
+
import type { OdrlActionType } from "@twin.org/standards-w3c-odrl";
|
|
4
|
+
import type { IDefaultPolicyEnforcementProcessorConstructorOptions } from "../models/IDefaultPolicyEnforcementProcessorConstructorOptions.js";
|
|
5
|
+
/**
|
|
6
|
+
* Default Policy Enforcement Processor.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DefaultPolicyEnforcementProcessor implements IPolicyEnforcementProcessor {
|
|
9
|
+
/**
|
|
10
|
+
* The class name of the Default Policy Enforcement Processor.
|
|
11
|
+
*/
|
|
12
|
+
static readonly CLASS_NAME: string;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new instance of DefaultPolicyEnforcementProcessor.
|
|
15
|
+
* @param options The options for the default policy enforcement processor.
|
|
16
|
+
*/
|
|
17
|
+
constructor(options?: IDefaultPolicyEnforcementProcessorConstructorOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Returns the class name of the component.
|
|
20
|
+
* @returns The class name of the component.
|
|
21
|
+
*/
|
|
22
|
+
className(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Process the response from the policy decision point.
|
|
25
|
+
* @param agreement The agreement to process.
|
|
26
|
+
* @param decisions The decisions made by the policy decision point.
|
|
27
|
+
* @param data The data to process.
|
|
28
|
+
* @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
29
|
+
* @returns The data after processing.
|
|
30
|
+
*/
|
|
31
|
+
process<D = unknown, R = D>(agreement: IDataspaceProtocolAgreement, decisions: IPolicyDecision[], data?: D, action?: OdrlActionType | string): Promise<R>;
|
|
32
|
+
/**
|
|
33
|
+
* Process a single policy decision.
|
|
34
|
+
* @param sourceObject The data to process.
|
|
35
|
+
* @param outputObject The currently processed object.
|
|
36
|
+
* @param policyDecision The policy decision to process.
|
|
37
|
+
* @throws GeneralError When replaceValue is missing or invalid.
|
|
38
|
+
*/
|
|
39
|
+
private processDecision;
|
|
40
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type IPolicyDecision, type IPolicyEnforcementProcessor } from "@twin.org/rights-management-models";
|
|
2
|
+
import type { IDataspaceProtocolAgreement } from "@twin.org/standards-dataspace-protocol";
|
|
3
|
+
import type { OdrlActionType } from "@twin.org/standards-w3c-odrl";
|
|
4
|
+
import type { IPassThroughPolicyEnforcementProcessorConstructorOptions } from "../models/IPassThroughPolicyEnforcementProcessorConstructorOptions.js";
|
|
5
|
+
/**
|
|
6
|
+
* Pass Through Policy Enforcement Processor.
|
|
7
|
+
*/
|
|
8
|
+
export declare class PassThroughPolicyEnforcementProcessor implements IPolicyEnforcementProcessor {
|
|
9
|
+
/**
|
|
10
|
+
* The class name of the Pass Through Policy Enforcement Processor.
|
|
11
|
+
*/
|
|
12
|
+
static readonly CLASS_NAME: string;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new instance of PassThroughPolicyEnforcementProcessor.
|
|
15
|
+
* @param options The options for the pass through policy enforcement processor.
|
|
16
|
+
*/
|
|
17
|
+
constructor(options?: IPassThroughPolicyEnforcementProcessorConstructorOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Returns the class name of the component.
|
|
20
|
+
* @returns The class name of the component.
|
|
21
|
+
*/
|
|
22
|
+
className(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Process the response from the policy decision point.
|
|
25
|
+
* @param agreement The agreement to process.
|
|
26
|
+
* @param decisions The decisions made by the policy decision point.
|
|
27
|
+
* @param data The data to process.
|
|
28
|
+
* @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
29
|
+
* @returns The data after processing.
|
|
30
|
+
*/
|
|
31
|
+
process<D = unknown, R = D>(agreement: IDataspaceProtocolAgreement, decisions: IPolicyDecision[], data?: D, action?: OdrlActionType | string): Promise<R>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type IPolicyDecision, type IPolicyExecutionAction, type IRightsManagementPolicy, PolicyDecisionStage } from "@twin.org/rights-management-models";
|
|
2
|
+
import { OdrlActionType } from "@twin.org/standards-w3c-odrl";
|
|
3
|
+
import type { IAutomationPolicyExecutionActionConstructorOptions } from "../models/IAutomationPolicyExecutionActionConstructorOptions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Automation Policy Execution Action to execute automation policies.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AutomationPolicyExecutionAction implements IPolicyExecutionAction {
|
|
8
|
+
/**
|
|
9
|
+
* The class name of the Automation Policy Execution Action.
|
|
10
|
+
*/
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
|
+
/**
|
|
13
|
+
* The before automation trigger name.
|
|
14
|
+
*/
|
|
15
|
+
static readonly BEFORE_TRIGGER_NAME: string;
|
|
16
|
+
/**
|
|
17
|
+
* The after automation trigger name.
|
|
18
|
+
*/
|
|
19
|
+
static readonly AFTER_TRIGGER_NAME: string;
|
|
20
|
+
/**
|
|
21
|
+
* The policy decision stages to trigger the automation actions, if undefined defaults to "inform".
|
|
22
|
+
*/
|
|
23
|
+
private readonly _triggerActions;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new instance of AutomationPolicyExecutionAction.
|
|
26
|
+
* @param options The options for the automation policy execution action.
|
|
27
|
+
*/
|
|
28
|
+
constructor(options?: IAutomationPolicyExecutionActionConstructorOptions);
|
|
29
|
+
/**
|
|
30
|
+
* Returns the class name of the component.
|
|
31
|
+
* @returns The class name of the component.
|
|
32
|
+
*/
|
|
33
|
+
className(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Which stages should the action be executed at.
|
|
36
|
+
* @returns List of stages.
|
|
37
|
+
*/
|
|
38
|
+
supportedStages(): PolicyDecisionStage[];
|
|
39
|
+
/**
|
|
40
|
+
* Execute function type for policy actions.
|
|
41
|
+
* @param policy The policy that applied to the data.
|
|
42
|
+
* @param decisions The decisions made by the PDP.
|
|
43
|
+
* @param data The data to process.
|
|
44
|
+
* @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
45
|
+
* @param stage The stage of the policy decision.
|
|
46
|
+
* @returns A promise that resolves when the action is complete.
|
|
47
|
+
*/
|
|
48
|
+
execute<D = unknown>(policy: IRightsManagementPolicy, decisions: IPolicyDecision[], data: D | undefined, action: OdrlActionType | string | undefined, stage: PolicyDecisionStage): Promise<void>;
|
|
49
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type IPolicyDecision, type IPolicyExecutionAction, type
|
|
2
|
-
import type {
|
|
1
|
+
import { type IPolicyDecision, type IPolicyExecutionAction, type IRightsManagementPolicy, PolicyDecisionStage } from "@twin.org/rights-management-models";
|
|
2
|
+
import type { OdrlActionType } from "@twin.org/standards-w3c-odrl";
|
|
3
3
|
import type { ILoggingPolicyExecutionActionConstructorOptions } from "../models/ILoggingPolicyExecutionActionConstructorOptions.js";
|
|
4
4
|
/**
|
|
5
5
|
* Logging Policy Execution Action to send decisions to logging.
|
|
@@ -14,9 +14,9 @@ export declare class LoggingPolicyExecutionAction implements IPolicyExecutionAct
|
|
|
14
14
|
*/
|
|
15
15
|
private readonly _includeData;
|
|
16
16
|
/**
|
|
17
|
-
* Whether to include the
|
|
17
|
+
* Whether to include the policy in the log.
|
|
18
18
|
*/
|
|
19
|
-
private readonly
|
|
19
|
+
private readonly _includePolicy;
|
|
20
20
|
/**
|
|
21
21
|
* Whether to include the decisions in the log.
|
|
22
22
|
*/
|
|
@@ -38,12 +38,12 @@ export declare class LoggingPolicyExecutionAction implements IPolicyExecutionAct
|
|
|
38
38
|
supportedStages(): PolicyDecisionStage[];
|
|
39
39
|
/**
|
|
40
40
|
* Execute function type for policy actions.
|
|
41
|
-
* @param
|
|
42
|
-
* @param locator The locator to find relevant policies.
|
|
43
|
-
* @param policies The policies that apply to the data.
|
|
41
|
+
* @param policy The policy that applied to the data.
|
|
44
42
|
* @param decisions The decisions made by the PDP.
|
|
45
43
|
* @param data The data to process.
|
|
44
|
+
* @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
45
|
+
* @param stage The stage of the policy decision.
|
|
46
46
|
* @returns A promise that resolves when the action is complete.
|
|
47
47
|
*/
|
|
48
|
-
execute<D = unknown>(
|
|
48
|
+
execute<D = unknown>(policy: IRightsManagementPolicy, decisions: IPolicyDecision[], data: D | undefined, action: OdrlActionType | string | undefined, stage: PolicyDecisionStage): Promise<void>;
|
|
49
49
|
}
|