@twin.org/rights-management-plugins 0.0.3-next.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/es/index.js +21 -0
  4. package/dist/es/index.js.map +1 -0
  5. package/dist/es/models/IExampleDataAccessHandlerConstructorOptions.js +4 -0
  6. package/dist/es/models/IExampleDataAccessHandlerConstructorOptions.js.map +1 -0
  7. package/dist/es/models/IExamplePolicyArbiterConstructorOptions.js +4 -0
  8. package/dist/es/models/IExamplePolicyArbiterConstructorOptions.js.map +1 -0
  9. package/dist/es/models/IExamplePolicyEnforcementProcessorConstructorOptions.js +4 -0
  10. package/dist/es/models/IExamplePolicyEnforcementProcessorConstructorOptions.js.map +1 -0
  11. package/dist/es/models/IExamplePolicyNegotiatorConstructorOptions.js +4 -0
  12. package/dist/es/models/IExamplePolicyNegotiatorConstructorOptions.js.map +1 -0
  13. package/dist/es/models/IExamplePolicyRequesterConstructorOptions.js +4 -0
  14. package/dist/es/models/IExamplePolicyRequesterConstructorOptions.js.map +1 -0
  15. package/dist/es/models/IIdentityPolicyInformationSourceConstructorOptions.js +4 -0
  16. package/dist/es/models/IIdentityPolicyInformationSourceConstructorOptions.js.map +1 -0
  17. package/dist/es/models/ILoggingPolicyExecutionActionConfig.js +2 -0
  18. package/dist/es/models/ILoggingPolicyExecutionActionConfig.js.map +1 -0
  19. package/dist/es/models/ILoggingPolicyExecutionActionConstructorOptions.js +2 -0
  20. package/dist/es/models/ILoggingPolicyExecutionActionConstructorOptions.js.map +1 -0
  21. package/dist/es/models/IStaticPolicyInformationSource.js +2 -0
  22. package/dist/es/models/IStaticPolicyInformationSource.js.map +1 -0
  23. package/dist/es/models/IStaticPolicyInformationSourceConfig.js +2 -0
  24. package/dist/es/models/IStaticPolicyInformationSourceConfig.js.map +1 -0
  25. package/dist/es/models/IStaticPolicyInformationSourceConstructorOptions.js +2 -0
  26. package/dist/es/models/IStaticPolicyInformationSourceConstructorOptions.js.map +1 -0
  27. package/dist/es/policyArbiters/examplePolicyArbiter.js +50 -0
  28. package/dist/es/policyArbiters/examplePolicyArbiter.js.map +1 -0
  29. package/dist/es/policyEnforcementProcessor/examplePolicyEnforcementProcessor.js +42 -0
  30. package/dist/es/policyEnforcementProcessor/examplePolicyEnforcementProcessor.js.map +1 -0
  31. package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js +117 -0
  32. package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js.map +1 -0
  33. package/dist/es/policyInformationSources/identityPolicyInformationSource.js +79 -0
  34. package/dist/es/policyInformationSources/identityPolicyInformationSource.js.map +1 -0
  35. package/dist/es/policyInformationSources/staticPolicyInformationSource.js +94 -0
  36. package/dist/es/policyInformationSources/staticPolicyInformationSource.js.map +1 -0
  37. package/dist/es/policyNegotiators/examplePolicyNegotiator.js +61 -0
  38. package/dist/es/policyNegotiators/examplePolicyNegotiator.js.map +1 -0
  39. package/dist/es/policyRequesters/examplePolicyRequester.js +69 -0
  40. package/dist/es/policyRequesters/examplePolicyRequester.js.map +1 -0
  41. package/dist/types/index.d.ts +18 -0
  42. package/dist/types/models/IExampleDataAccessHandlerConstructorOptions.d.ts +10 -0
  43. package/dist/types/models/IExamplePolicyArbiterConstructorOptions.d.ts +10 -0
  44. package/dist/types/models/IExamplePolicyEnforcementProcessorConstructorOptions.d.ts +10 -0
  45. package/dist/types/models/IExamplePolicyNegotiatorConstructorOptions.d.ts +10 -0
  46. package/dist/types/models/IExamplePolicyRequesterConstructorOptions.d.ts +10 -0
  47. package/dist/types/models/IIdentityPolicyInformationSourceConstructorOptions.d.ts +15 -0
  48. package/dist/types/models/ILoggingPolicyExecutionActionConfig.d.ts +25 -0
  49. package/dist/types/models/ILoggingPolicyExecutionActionConstructorOptions.d.ts +15 -0
  50. package/dist/types/models/IStaticPolicyInformationSource.d.ts +20 -0
  51. package/dist/types/models/IStaticPolicyInformationSourceConfig.d.ts +10 -0
  52. package/dist/types/models/IStaticPolicyInformationSourceConstructorOptions.d.ts +15 -0
  53. package/dist/types/policyArbiters/examplePolicyArbiter.d.ts +36 -0
  54. package/dist/types/policyEnforcementProcessor/examplePolicyEnforcementProcessor.d.ts +29 -0
  55. package/dist/types/policyExecutionActions/loggingPolicyExecutionAction.d.ts +49 -0
  56. package/dist/types/policyInformationSources/identityPolicyInformationSource.d.ts +32 -0
  57. package/dist/types/policyInformationSources/staticPolicyInformationSource.d.ts +38 -0
  58. package/dist/types/policyNegotiators/examplePolicyNegotiator.d.ts +45 -0
  59. package/dist/types/policyRequesters/examplePolicyRequester.d.ts +53 -0
  60. package/docs/changelog.md +102 -0
  61. package/docs/examples.md +1 -0
  62. package/docs/reference/classes/ExamplePolicyArbiter.md +121 -0
  63. package/docs/reference/classes/ExamplePolicyEnforcementProcessor.md +101 -0
  64. package/docs/reference/classes/ExamplePolicyNegotiator.md +143 -0
  65. package/docs/reference/classes/ExamplePolicyRequester.md +187 -0
  66. package/docs/reference/classes/IdentityPolicyInformationSource.md +103 -0
  67. package/docs/reference/classes/LoggingPolicyExecutionAction.md +127 -0
  68. package/docs/reference/classes/StaticPolicyInformationSource.md +123 -0
  69. package/docs/reference/index.md +25 -0
  70. package/docs/reference/interfaces/IExampleDataAccessHandlerConstructorOptions.md +17 -0
  71. package/docs/reference/interfaces/IExamplePolicyArbiterConstructorOptions.md +17 -0
  72. package/docs/reference/interfaces/IExamplePolicyEnforcementProcessorConstructorOptions.md +17 -0
  73. package/docs/reference/interfaces/IExamplePolicyNegotiatorConstructorOptions.md +17 -0
  74. package/docs/reference/interfaces/IExamplePolicyRequesterConstructorOptions.md +17 -0
  75. package/docs/reference/interfaces/IIdentityPolicyInformationSourceConstructorOptions.md +31 -0
  76. package/docs/reference/interfaces/ILoggingPolicyExecutionActionConfig.md +53 -0
  77. package/docs/reference/interfaces/ILoggingPolicyExecutionActionConstructorOptions.md +25 -0
  78. package/docs/reference/interfaces/IStaticPolicyInformationSource.md +28 -0
  79. package/docs/reference/interfaces/IStaticPolicyInformationSourceConfig.md +11 -0
  80. package/docs/reference/interfaces/IStaticPolicyInformationSourceConstructorOptions.md +25 -0
  81. package/locales/en.json +20 -0
  82. package/package.json +57 -0
@@ -0,0 +1,79 @@
1
+ // Copyright 2025 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseError, ComponentFactory, Guards } from "@twin.org/core";
4
+ import { LocatorHelper, PolicyInformationAccessMode } from "@twin.org/rights-management-models";
5
+ /**
6
+ * Policy information source which retrieves the identity information.
7
+ */
8
+ export class IdentityPolicyInformationSource {
9
+ /**
10
+ * The class name of the Identity Policy Information Source.
11
+ */
12
+ static CLASS_NAME = "IdentityPolicyInformationSource";
13
+ /**
14
+ * The logging component.
15
+ * @internal
16
+ */
17
+ _logging;
18
+ /**
19
+ * The identity resolver component.
20
+ * @internal
21
+ */
22
+ _identityResolver;
23
+ /**
24
+ * Create a new instance of IdentityPolicyInformationSource.
25
+ * @param options The options for the logging policy source.
26
+ */
27
+ constructor(options) {
28
+ this._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
29
+ this._identityResolver = ComponentFactory.get(options?.identityResolverComponentType ?? "identity-resolver");
30
+ }
31
+ /**
32
+ * Returns the class name of the component.
33
+ * @returns The class name of the component.
34
+ */
35
+ className() {
36
+ return IdentityPolicyInformationSource.CLASS_NAME;
37
+ }
38
+ /**
39
+ * Retrieve information from the sources.
40
+ * @param locator The locator to find relevant policies.
41
+ * @param accessMode The access mode to use for the retrieval.
42
+ * @param policies The policies that apply to the data.
43
+ * @param data The data to process.
44
+ * @returns The objects containing relevant information or undefined if nothing relevant is found.
45
+ */
46
+ async retrieve(locator, accessMode, policies, data) {
47
+ Guards.objectValue(IdentityPolicyInformationSource.CLASS_NAME, "locator", locator);
48
+ Guards.arrayOneOf(IdentityPolicyInformationSource.CLASS_NAME, "accessMode", accessMode, Object.values(PolicyInformationAccessMode));
49
+ Guards.stringValue(IdentityPolicyInformationSource.CLASS_NAME, "locator.assignee", locator.assignee);
50
+ const information = [];
51
+ try {
52
+ await this._logging?.log({
53
+ level: "info",
54
+ source: IdentityPolicyInformationSource.CLASS_NAME,
55
+ ts: Date.now(),
56
+ message: "identityRetrieving",
57
+ data: {
58
+ locator: LocatorHelper.toString(locator)
59
+ }
60
+ });
61
+ const idDoc = await this._identityResolver.identityResolve(locator.assignee);
62
+ information.push(idDoc);
63
+ }
64
+ catch (err) {
65
+ await this._logging?.log({
66
+ level: "error",
67
+ source: IdentityPolicyInformationSource.CLASS_NAME,
68
+ ts: Date.now(),
69
+ message: "identityRetrievalFailed",
70
+ data: {
71
+ locator: LocatorHelper.toString(locator)
72
+ },
73
+ error: BaseError.fromError(err)
74
+ });
75
+ }
76
+ return information;
77
+ }
78
+ }
79
+ //# sourceMappingURL=identityPolicyInformationSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityPolicyInformationSource.js","sourceRoot":"","sources":["../../../src/policyInformationSources/identityPolicyInformationSource.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAKrE,OAAO,EAGN,aAAa,EACb,2BAA2B,EAC3B,MAAM,oCAAoC,CAAC;AAI5C;;GAEG;AACH,MAAM,OAAO,+BAA+B;IAC3C;;OAEG;IACI,MAAM,CAAU,UAAU,qCAAqD;IAEtF;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,iBAAiB,CAA6B;IAE/D;;;OAGG;IACH,YAAY,OAA4D;QACvE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAC3C,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,CAC5C,OAAO,EAAE,6BAA6B,IAAI,mBAAmB,CAC7D,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,+BAA+B,CAAC,UAAU,CAAC;IACnD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,QAAQ,CACpB,OAAuB,EACvB,UAAuC,EACvC,QAAuB,EACvB,IAAQ;QAER,MAAM,CAAC,WAAW,CACjB,+BAA+B,CAAC,UAAU,aAE1C,OAAO,CACP,CAAC;QACF,MAAM,CAAC,UAAU,CAChB,+BAA+B,CAAC,UAAU,gBAE1C,UAAU,EACV,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAC1C,CAAC;QACF,MAAM,CAAC,WAAW,CACjB,+BAA+B,CAAC,UAAU,sBAE1C,OAAO,CAAC,QAAQ,CAChB,CAAC;QAEF,MAAM,WAAW,GAAwB,EAAE,CAAC;QAE5C,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;gBACxB,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,+BAA+B,CAAC,UAAU;gBAClD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,oBAAoB;gBAC7B,IAAI,EAAE;oBACL,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC;iBACxC;aACD,CAAC,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC7E,WAAW,CAAC,IAAI,CAAC,KAAqC,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;gBACxB,KAAK,EAAE,OAAO;gBACd,MAAM,EAAE,+BAA+B,CAAC,UAAU;gBAClD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,yBAAyB;gBAClC,IAAI,EAAE;oBACL,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC;iBACxC;gBACD,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC;aAC/B,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,WAAW,CAAC;IACpB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, ComponentFactory, Guards } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type { IIdentityResolverComponent } from \"@twin.org/identity-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\ttype IPolicyInformationSource,\n\ttype IPolicyLocator,\n\tLocatorHelper,\n\tPolicyInformationAccessMode\n} from \"@twin.org/rights-management-models\";\nimport type { IOdrlPolicy } from \"@twin.org/standards-w3c-odrl\";\nimport type { IIdentityPolicyInformationSourceConstructorOptions } from \"../models/IIdentityPolicyInformationSourceConstructorOptions.js\";\n\n/**\n * Policy information source which retrieves the identity information.\n */\nexport class IdentityPolicyInformationSource implements IPolicyInformationSource {\n\t/**\n\t * The class name of the Identity Policy Information Source.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityPolicyInformationSource>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * The identity resolver component.\n\t * @internal\n\t */\n\tprivate readonly _identityResolver: IIdentityResolverComponent;\n\n\t/**\n\t * Create a new instance of IdentityPolicyInformationSource.\n\t * @param options The options for the logging policy source.\n\t */\n\tconstructor(options?: IIdentityPolicyInformationSourceConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\t\tthis._identityResolver = ComponentFactory.get(\n\t\t\toptions?.identityResolverComponentType ?? \"identity-resolver\"\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 IdentityPolicyInformationSource.CLASS_NAME;\n\t}\n\n\t/**\n\t * Retrieve information from the sources.\n\t * @param locator The locator to find relevant policies.\n\t * @param accessMode The access mode to use for the retrieval.\n\t * @param policies The policies that apply to the data.\n\t * @param data The data to process.\n\t * @returns The objects containing relevant information or undefined if nothing relevant is found.\n\t */\n\tpublic async retrieve<D = unknown>(\n\t\tlocator: IPolicyLocator,\n\t\taccessMode: PolicyInformationAccessMode,\n\t\tpolicies: IOdrlPolicy[],\n\t\tdata?: D\n\t): Promise<IJsonLdNodeObject[] | undefined> {\n\t\tGuards.objectValue<IPolicyLocator>(\n\t\t\tIdentityPolicyInformationSource.CLASS_NAME,\n\t\t\tnameof(locator),\n\t\t\tlocator\n\t\t);\n\t\tGuards.arrayOneOf(\n\t\t\tIdentityPolicyInformationSource.CLASS_NAME,\n\t\t\tnameof(accessMode),\n\t\t\taccessMode,\n\t\t\tObject.values(PolicyInformationAccessMode)\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tIdentityPolicyInformationSource.CLASS_NAME,\n\t\t\tnameof(locator.assignee),\n\t\t\tlocator.assignee\n\t\t);\n\n\t\tconst information: IJsonLdNodeObject[] = [];\n\n\t\ttry {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: IdentityPolicyInformationSource.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"identityRetrieving\",\n\t\t\t\tdata: {\n\t\t\t\t\tlocator: LocatorHelper.toString(locator)\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst idDoc = await this._identityResolver.identityResolve(locator.assignee);\n\t\t\tinformation.push(idDoc as unknown as IJsonLdNodeObject);\n\t\t} catch (err) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tsource: IdentityPolicyInformationSource.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"identityRetrievalFailed\",\n\t\t\t\tdata: {\n\t\t\t\t\tlocator: LocatorHelper.toString(locator)\n\t\t\t\t},\n\t\t\t\terror: BaseError.fromError(err)\n\t\t\t});\n\t\t}\n\n\t\treturn information;\n\t}\n}\n"]}
@@ -0,0 +1,94 @@
1
+ // Copyright 2025 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { ComponentFactory, Guards, Is } from "@twin.org/core";
4
+ import { LocatorHelper, PolicyInformationAccessMode } from "@twin.org/rights-management-models";
5
+ /**
6
+ * Policy information source which retrieves static information.
7
+ */
8
+ export class StaticPolicyInformationSource {
9
+ /**
10
+ * The class name of the Static Policy Information Source.
11
+ */
12
+ static CLASS_NAME = "StaticPolicyInformationSource";
13
+ /**
14
+ * The logging component.
15
+ * @internal
16
+ */
17
+ _logging;
18
+ /**
19
+ * The information sources.
20
+ * @internal
21
+ */
22
+ _information;
23
+ /**
24
+ * Create a new instance of StaticPolicyInformationSource.
25
+ * @param options The options for the logging policy source.
26
+ */
27
+ constructor(options) {
28
+ this._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
29
+ this._information = options?.config?.information ?? [];
30
+ }
31
+ /**
32
+ * Returns the class name of the component.
33
+ * @returns The class name of the component.
34
+ */
35
+ className() {
36
+ return StaticPolicyInformationSource.CLASS_NAME;
37
+ }
38
+ /**
39
+ * Retrieve information from the sources.
40
+ * @param locator The locator to find relevant policies.
41
+ * @param accessMode The access mode to use for the retrieval.
42
+ * @param policies The policies that apply to the data.
43
+ * @param data The data to process.
44
+ * @returns The objects containing relevant information or undefined if nothing relevant is found.
45
+ */
46
+ async retrieve(locator, accessMode, policies, data) {
47
+ Guards.objectValue(StaticPolicyInformationSource.CLASS_NAME, "locator", locator);
48
+ Guards.arrayOneOf(StaticPolicyInformationSource.CLASS_NAME, "accessMode", accessMode, Object.values(PolicyInformationAccessMode));
49
+ Guards.stringValue(StaticPolicyInformationSource.CLASS_NAME, "locator.assignee", locator.assignee);
50
+ const information = [];
51
+ await this._logging?.log({
52
+ level: "info",
53
+ source: StaticPolicyInformationSource.CLASS_NAME,
54
+ ts: Date.now(),
55
+ message: "staticRetrieving",
56
+ data: {
57
+ locator: LocatorHelper.toString(locator),
58
+ accessMode
59
+ }
60
+ });
61
+ for (const info of this._information) {
62
+ if (info.accessMode === accessMode ||
63
+ accessMode === PolicyInformationAccessMode.Any ||
64
+ info.accessMode === PolicyInformationAccessMode.Any) {
65
+ if (!Is.arrayValue(info.matchLocators) ||
66
+ !Is.empty(LocatorHelper.findMatchingLocator(info.matchLocators, locator))) {
67
+ information.push(...info.objects);
68
+ }
69
+ }
70
+ }
71
+ await this._logging?.log({
72
+ level: "info",
73
+ source: StaticPolicyInformationSource.CLASS_NAME,
74
+ ts: Date.now(),
75
+ message: "staticRetrieved",
76
+ data: {
77
+ locator: LocatorHelper.toString(locator),
78
+ accessMode,
79
+ itemCount: information.length
80
+ }
81
+ });
82
+ return information.length > 0 ? information : undefined;
83
+ }
84
+ /**
85
+ * Add static policy information.
86
+ * @param info The static policy information to add.
87
+ */
88
+ addInformation(info) {
89
+ Guards.arrayOneOf(StaticPolicyInformationSource.CLASS_NAME, "info.accessMode", info.accessMode, Object.values(PolicyInformationAccessMode));
90
+ Guards.arrayValue(StaticPolicyInformationSource.CLASS_NAME, "info.objects", info.objects);
91
+ this._information.push(info);
92
+ }
93
+ }
94
+ //# sourceMappingURL=staticPolicyInformationSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staticPolicyInformationSource.js","sourceRoot":"","sources":["../../../src/policyInformationSources/staticPolicyInformationSource.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards, Is } 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\tLocatorHelper,\n\tPolicyInformationAccessMode,\n\ttype IPolicyInformationSource,\n\ttype IPolicyLocator\n} from \"@twin.org/rights-management-models\";\nimport type { IOdrlPolicy } from \"@twin.org/standards-w3c-odrl\";\nimport type { IStaticPolicyInformationSource } from \"../models/IStaticPolicyInformationSource.js\";\nimport type { IStaticPolicyInformationSourceConstructorOptions } from \"../models/IStaticPolicyInformationSourceConstructorOptions.js\";\n\n/**\n * Policy information source which retrieves static information.\n */\nexport class StaticPolicyInformationSource implements IPolicyInformationSource {\n\t/**\n\t * The class name of the Static Policy Information Source.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<StaticPolicyInformationSource>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * The information sources.\n\t * @internal\n\t */\n\tprivate readonly _information: IStaticPolicyInformationSource[];\n\n\t/**\n\t * Create a new instance of StaticPolicyInformationSource.\n\t * @param options The options for the logging policy source.\n\t */\n\tconstructor(options?: IStaticPolicyInformationSourceConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\t\tthis._information = options?.config?.information ?? [];\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 StaticPolicyInformationSource.CLASS_NAME;\n\t}\n\n\t/**\n\t * Retrieve information from the sources.\n\t * @param locator The locator to find relevant policies.\n\t * @param accessMode The access mode to use for the retrieval.\n\t * @param policies The policies that apply to the data.\n\t * @param data The data to process.\n\t * @returns The objects containing relevant information or undefined if nothing relevant is found.\n\t */\n\tpublic async retrieve<D = unknown>(\n\t\tlocator: IPolicyLocator,\n\t\taccessMode: PolicyInformationAccessMode,\n\t\tpolicies: IOdrlPolicy[],\n\t\tdata?: D\n\t): Promise<IJsonLdNodeObject[] | undefined> {\n\t\tGuards.objectValue<IPolicyLocator>(\n\t\t\tStaticPolicyInformationSource.CLASS_NAME,\n\t\t\tnameof(locator),\n\t\t\tlocator\n\t\t);\n\t\tGuards.arrayOneOf(\n\t\t\tStaticPolicyInformationSource.CLASS_NAME,\n\t\t\tnameof(accessMode),\n\t\t\taccessMode,\n\t\t\tObject.values(PolicyInformationAccessMode)\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tStaticPolicyInformationSource.CLASS_NAME,\n\t\t\tnameof(locator.assignee),\n\t\t\tlocator.assignee\n\t\t);\n\n\t\tconst information: IJsonLdNodeObject[] = [];\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: StaticPolicyInformationSource.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"staticRetrieving\",\n\t\t\tdata: {\n\t\t\t\tlocator: LocatorHelper.toString(locator),\n\t\t\t\taccessMode\n\t\t\t}\n\t\t});\n\n\t\tfor (const info of this._information) {\n\t\t\tif (\n\t\t\t\tinfo.accessMode === accessMode ||\n\t\t\t\taccessMode === PolicyInformationAccessMode.Any ||\n\t\t\t\tinfo.accessMode === PolicyInformationAccessMode.Any\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\t!Is.arrayValue(info.matchLocators) ||\n\t\t\t\t\t!Is.empty(LocatorHelper.findMatchingLocator(info.matchLocators, locator))\n\t\t\t\t) {\n\t\t\t\t\tinformation.push(...info.objects);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: StaticPolicyInformationSource.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"staticRetrieved\",\n\t\t\tdata: {\n\t\t\t\tlocator: LocatorHelper.toString(locator),\n\t\t\t\taccessMode,\n\t\t\t\titemCount: information.length\n\t\t\t}\n\t\t});\n\n\t\treturn information.length > 0 ? information : undefined;\n\t}\n\n\t/**\n\t * Add static policy information.\n\t * @param info The static policy information to add.\n\t */\n\tpublic addInformation(info: IStaticPolicyInformationSource): void {\n\t\tGuards.arrayOneOf<string>(\n\t\t\tStaticPolicyInformationSource.CLASS_NAME,\n\t\t\tnameof(info.accessMode),\n\t\t\tinfo.accessMode,\n\t\t\tObject.values(PolicyInformationAccessMode)\n\t\t);\n\t\tGuards.arrayValue<IJsonLdNodeObject>(\n\t\t\tStaticPolicyInformationSource.CLASS_NAME,\n\t\t\tnameof(info.objects),\n\t\t\tinfo.objects\n\t\t);\n\t\tthis._information.push(info);\n\t}\n}\n"]}
@@ -0,0 +1,61 @@
1
+ // Copyright 2025 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { ComponentFactory } from "@twin.org/core";
4
+ /**
5
+ * Example Policy Negotiator.
6
+ */
7
+ export class ExamplePolicyNegotiator {
8
+ /**
9
+ * The class name of the Example Policy Negotiator.
10
+ */
11
+ static CLASS_NAME = "ExamplePolicyNegotiator";
12
+ /**
13
+ * The logging component.
14
+ * @internal
15
+ */
16
+ _logging;
17
+ /**
18
+ * Create a new instance of ExamplePolicyNegotiator.
19
+ * @param options The options for the example policy negotiator.
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 ExamplePolicyNegotiator.CLASS_NAME;
30
+ }
31
+ /**
32
+ * Determines if the negotiator supports the given offer.
33
+ * @param offer The offer to check.
34
+ * @returns Sets the supports flag if it can be offered, and the interventionRequired flag if manual agreement is needed.
35
+ */
36
+ supportsOffer(offer) {
37
+ return true;
38
+ }
39
+ /**
40
+ * Handle the offer.
41
+ * @param offer The offer to check.
42
+ * @param information Information provided by the requester to determine if a policy can be created.
43
+ * @returns Sets the accepted flag if it can be offered, and the interventionRequired flag if manual agreement is needed.
44
+ */
45
+ async handleOffer(offer, information) {
46
+ return {
47
+ accepted: true,
48
+ interventionRequired: false
49
+ };
50
+ }
51
+ /**
52
+ * Create an agreement based on the offer.
53
+ * @param offer The offer to create the agreement from.
54
+ * @param information Information provided by the requester to aid in the creation of the agreement.
55
+ * @returns The agreement created from the offer or undefined if an agreement could not be created.
56
+ */
57
+ async createAgreement(offer, information) {
58
+ return undefined;
59
+ }
60
+ }
61
+ //# sourceMappingURL=examplePolicyNegotiator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examplePolicyNegotiator.js","sourceRoot":"","sources":["../../../src/policyNegotiators/examplePolicyNegotiator.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlD;;GAEG;AACH,MAAM,OAAO,uBAAuB;IACnC;;OAEG;IACI,MAAM,CAAU,UAAU,6BAA6C;IAE9E;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAAoD;QAC/D,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,uBAAuB,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,KAAiB;QACrC,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,WAAW,CACvB,KAAiB,EACjB,WAAgC;QAKhC,OAAO;YACN,QAAQ,EAAE,IAAI;YACd,oBAAoB,EAAE,KAAK;SAC3B,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,eAAe,CAC3B,KAAiB,EACjB,WAAgC;QAEhC,OAAO,SAAS,CAAC;IAClB,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 { IPolicyInformation, IPolicyNegotiator } from \"@twin.org/rights-management-models\";\nimport type { IOdrlAgreement, IOdrlOffer } from \"@twin.org/standards-w3c-odrl\";\nimport type { IExamplePolicyNegotiatorConstructorOptions } from \"../models/IExamplePolicyNegotiatorConstructorOptions.js\";\n\n/**\n * Example Policy Negotiator.\n */\nexport class ExamplePolicyNegotiator implements IPolicyNegotiator {\n\t/**\n\t * The class name of the Example Policy Negotiator.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ExamplePolicyNegotiator>();\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 ExamplePolicyNegotiator.\n\t * @param options The options for the example policy negotiator.\n\t */\n\tconstructor(options?: IExamplePolicyNegotiatorConstructorOptions) {\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 ExamplePolicyNegotiator.CLASS_NAME;\n\t}\n\n\t/**\n\t * Determines if the negotiator supports the given offer.\n\t * @param offer The offer to check.\n\t * @returns Sets the supports flag if it can be offered, and the interventionRequired flag if manual agreement is needed.\n\t */\n\tpublic supportsOffer(offer: IOdrlOffer): boolean {\n\t\treturn true;\n\t}\n\n\t/**\n\t * Handle the offer.\n\t * @param offer The offer to check.\n\t * @param information Information provided by the requester to determine if a policy can be created.\n\t * @returns Sets the accepted flag if it can be offered, and the interventionRequired flag if manual agreement is needed.\n\t */\n\tpublic async handleOffer(\n\t\toffer: IOdrlOffer,\n\t\tinformation?: IPolicyInformation\n\t): Promise<{\n\t\taccepted: boolean;\n\t\tinterventionRequired: boolean;\n\t}> {\n\t\treturn {\n\t\t\taccepted: true,\n\t\t\tinterventionRequired: false\n\t\t};\n\t}\n\n\t/**\n\t * Create an agreement based on the offer.\n\t * @param offer The offer to create the agreement from.\n\t * @param information Information provided by the requester to aid in the creation of the agreement.\n\t * @returns The agreement created from the offer or undefined if an agreement could not be created.\n\t */\n\tpublic async createAgreement(\n\t\toffer: IOdrlOffer,\n\t\tinformation?: IPolicyInformation\n\t): Promise<IOdrlAgreement | undefined> {\n\t\treturn undefined;\n\t}\n}\n"]}
@@ -0,0 +1,69 @@
1
+ // Copyright 2025 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { ComponentFactory } from "@twin.org/core";
4
+ /**
5
+ * Example Policy Requester.
6
+ */
7
+ export class ExamplePolicyRequester {
8
+ /**
9
+ * The class name of the Example Policy Requester.
10
+ */
11
+ static CLASS_NAME = "ExamplePolicyRequester";
12
+ /**
13
+ * The logging component.
14
+ * @internal
15
+ */
16
+ _logging;
17
+ /**
18
+ * Create a new instance of ExamplePolicyRequester.
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 ExamplePolicyRequester.CLASS_NAME;
30
+ }
31
+ /**
32
+ * The unique id of the requester.
33
+ * @returns The requester id.
34
+ */
35
+ requesterId() {
36
+ return "";
37
+ }
38
+ /**
39
+ * A policy has been offered by a provider, let the requester know about it.
40
+ * @param negotiationId The id of the negotiation.
41
+ * @param offer The offer sent by the provider.
42
+ * @returns True if the offer was accepted, false otherwise.
43
+ */
44
+ async offer(negotiationId, offer) {
45
+ return true;
46
+ }
47
+ /**
48
+ * A policy agreement has been sent by a provider, let the requester know about it.
49
+ * @param negotiationId The id of the negotiation.
50
+ * @param agreement The agreement sent by the provider.
51
+ * @returns True if the agreement was accepted, false otherwise.
52
+ */
53
+ async agreement(negotiationId, agreement) {
54
+ return true;
55
+ }
56
+ /**
57
+ * A policy finalisation has been sent by a provider, let the requester know about it.
58
+ * @param negotiationId The id of the negotiation.
59
+ * @returns Nothing.
60
+ */
61
+ async finalised(negotiationId) { }
62
+ /**
63
+ * A policy termination has been sent by a provider, let the requester know about it.
64
+ * @param negotiationId The id of the negotiation.
65
+ * @returns Nothing.
66
+ */
67
+ async terminated(negotiationId) { }
68
+ }
69
+ //# sourceMappingURL=examplePolicyRequester.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examplePolicyRequester.js","sourceRoot":"","sources":["../../../src/policyRequesters/examplePolicyRequester.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAClC;;OAEG;IACI,MAAM,CAAU,UAAU,4BAA4C;IAE7E;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAAmD;QAC9D,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,sBAAsB,CAAC,UAAU,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACI,WAAW;QACjB,OAAO,EAAE,CAAC;IACX,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAK,CAAC,aAAqB,EAAE,KAAiB;QAC1D,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAC,aAAqB,EAAE,SAAyB;QACtE,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,SAAS,CAAC,aAAqB,IAAkB,CAAC;IAE/D;;;;OAIG;IACI,KAAK,CAAC,UAAU,CAAC,aAAqB,IAAkB,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 { IPolicyRequester } from \"@twin.org/rights-management-models\";\nimport type { IOdrlAgreement, IOdrlOffer } from \"@twin.org/standards-w3c-odrl\";\nimport type { IExamplePolicyRequesterConstructorOptions } from \"../models/IExamplePolicyRequesterConstructorOptions.js\";\n\n/**\n * Example Policy Requester.\n */\nexport class ExamplePolicyRequester implements IPolicyRequester {\n\t/**\n\t * The class name of the Example Policy Requester.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<ExamplePolicyRequester>();\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 ExamplePolicyRequester.\n\t * @param options The options for the example policy Requester.\n\t */\n\tconstructor(options?: IExamplePolicyRequesterConstructorOptions) {\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 ExamplePolicyRequester.CLASS_NAME;\n\t}\n\n\t/**\n\t * The unique id of the requester.\n\t * @returns The requester id.\n\t */\n\tpublic requesterId(): string {\n\t\treturn \"\";\n\t}\n\n\t/**\n\t * A policy has been offered by a provider, let the requester 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: IOdrlOffer): Promise<boolean> {\n\t\treturn true;\n\t}\n\n\t/**\n\t * A policy agreement has been sent by a provider, let the requester 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(negotiationId: string, agreement: IOdrlAgreement): Promise<boolean> {\n\t\treturn true;\n\t}\n\n\t/**\n\t * A policy finalisation has been sent by a provider, let the requester 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\n\t/**\n\t * A policy termination has been sent by a provider, let the requester 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}\n"]}
@@ -0,0 +1,18 @@
1
+ export * from "./models/IExampleDataAccessHandlerConstructorOptions.js";
2
+ export * from "./models/IExamplePolicyArbiterConstructorOptions.js";
3
+ export * from "./models/IExamplePolicyEnforcementProcessorConstructorOptions.js";
4
+ export * from "./models/IExamplePolicyNegotiatorConstructorOptions.js";
5
+ export * from "./models/IExamplePolicyRequesterConstructorOptions.js";
6
+ export * from "./models/IIdentityPolicyInformationSourceConstructorOptions.js";
7
+ export * from "./models/ILoggingPolicyExecutionActionConfig.js";
8
+ export * from "./models/ILoggingPolicyExecutionActionConstructorOptions.js";
9
+ export * from "./models/IStaticPolicyInformationSource.js";
10
+ export * from "./models/IStaticPolicyInformationSourceConfig.js";
11
+ export * from "./models/IStaticPolicyInformationSourceConstructorOptions.js";
12
+ export * from "./policyArbiters/examplePolicyArbiter.js";
13
+ export * from "./policyEnforcementProcessor/examplePolicyEnforcementProcessor.js";
14
+ export * from "./policyExecutionActions/loggingPolicyExecutionAction.js";
15
+ export * from "./policyInformationSources/identityPolicyInformationSource.js";
16
+ export * from "./policyInformationSources/staticPolicyInformationSource.js";
17
+ export * from "./policyNegotiators/examplePolicyNegotiator.js";
18
+ export * from "./policyRequesters/examplePolicyRequester.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Options for the Example Data Access Handler.
3
+ */
4
+ export interface IExampleDataAccessHandlerConstructorOptions {
5
+ /**
6
+ * The logging component for data access handler.
7
+ * @default logging
8
+ */
9
+ loggingComponentType?: string;
10
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Options for the Example Policy Arbiter.
3
+ */
4
+ export interface IExamplePolicyArbiterConstructorOptions {
5
+ /**
6
+ * The logging component for policy arbiter.
7
+ * @default logging
8
+ */
9
+ loggingComponentType?: string;
10
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Options for the Example Policy Enforcement Processor.
3
+ */
4
+ export interface IExamplePolicyEnforcementProcessorConstructorOptions {
5
+ /**
6
+ * The logging component for policy enforcement processor.
7
+ * @default logging
8
+ */
9
+ loggingComponentType?: string;
10
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Options for the Example Policy Negotiator.
3
+ */
4
+ export interface IExamplePolicyNegotiatorConstructorOptions {
5
+ /**
6
+ * The logging component for policy negotiator.
7
+ * @default logging
8
+ */
9
+ loggingComponentType?: string;
10
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Options for the Example Policy Requester.
3
+ */
4
+ export interface IExamplePolicyRequesterConstructorOptions {
5
+ /**
6
+ * The logging component for policy requester.
7
+ * @default logging
8
+ */
9
+ loggingComponentType?: string;
10
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Options for the Identity Policy Information Source Component.
3
+ */
4
+ export interface IIdentityPolicyInformationSourceConstructorOptions {
5
+ /**
6
+ * The logging component for logging policy source.
7
+ * @default logging
8
+ */
9
+ loggingComponentType?: string;
10
+ /**
11
+ * The component for resolving identities.
12
+ * @default identity-resolver
13
+ */
14
+ identityResolverComponentType?: string;
15
+ }
@@ -0,0 +1,25 @@
1
+ import type { PolicyDecisionStage } from "@twin.org/rights-management-models";
2
+ /**
3
+ * Options for the Logging Policy Execution Action Component.
4
+ */
5
+ export interface ILoggingPolicyExecutionActionConfig {
6
+ /**
7
+ * The policy decision stages to log, if undefined defaults to all.
8
+ */
9
+ stages?: PolicyDecisionStage[];
10
+ /**
11
+ * Whether to include the data in the log.
12
+ * @default false
13
+ */
14
+ includeData?: boolean;
15
+ /**
16
+ * Whether to include the policies in the log.
17
+ * @default false
18
+ */
19
+ includePolicies?: boolean;
20
+ /**
21
+ * Whether to include the decisions in the log.
22
+ * @default false
23
+ */
24
+ includeDecisions?: boolean;
25
+ }
@@ -0,0 +1,15 @@
1
+ import type { ILoggingPolicyExecutionActionConfig } from "./ILoggingPolicyExecutionActionConfig.js";
2
+ /**
3
+ * Options for the Logging Policy Execution Action.
4
+ */
5
+ export interface ILoggingPolicyExecutionActionConstructorOptions {
6
+ /**
7
+ * The logging component for logging policy execution.
8
+ * @default logging
9
+ */
10
+ loggingComponentType?: string;
11
+ /**
12
+ * The configuration for the logging policy execution.
13
+ */
14
+ config?: ILoggingPolicyExecutionActionConfig;
15
+ }
@@ -0,0 +1,20 @@
1
+ import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
+ import type { IPolicyLocator, PolicyInformationAccessMode } from "@twin.org/rights-management-models";
3
+ /**
4
+ * Configuration for the Static Policy Information Source Component.
5
+ */
6
+ export interface IStaticPolicyInformationSource {
7
+ /**
8
+ * Is the information public, if so it will be shared with negotiation requests.
9
+ */
10
+ accessMode: PolicyInformationAccessMode;
11
+ /**
12
+ * Information is only provided for the specified locator combination.
13
+ * If undefined is provided matches all resources.
14
+ */
15
+ matchLocators?: IPolicyLocator[];
16
+ /**
17
+ * The objects containing the information.
18
+ */
19
+ objects: IJsonLdNodeObject[];
20
+ }
@@ -0,0 +1,10 @@
1
+ import type { IStaticPolicyInformationSource } from "./IStaticPolicyInformationSource.js";
2
+ /**
3
+ * Configuration for the Static Policy Information Source Component.
4
+ */
5
+ export interface IStaticPolicyInformationSourceConfig {
6
+ /**
7
+ * The information to return from the PIP.
8
+ */
9
+ information?: IStaticPolicyInformationSource[];
10
+ }
@@ -0,0 +1,15 @@
1
+ import type { IStaticPolicyInformationSourceConfig } from "./IStaticPolicyInformationSourceConfig.js";
2
+ /**
3
+ * Options for the Static Policy Information Source Component.
4
+ */
5
+ export interface IStaticPolicyInformationSourceConstructorOptions {
6
+ /**
7
+ * The logging component for logging policy source.
8
+ * @default logging
9
+ */
10
+ loggingComponentType?: string;
11
+ /**
12
+ * The configuration.
13
+ */
14
+ config?: IStaticPolicyInformationSourceConfig;
15
+ }
@@ -0,0 +1,36 @@
1
+ import type { IPolicyArbiter, IPolicyDecision, IPolicyInformation, IPolicyLocator } from "@twin.org/rights-management-models";
2
+ import type { IOdrlPolicy } from "@twin.org/standards-w3c-odrl";
3
+ import type { IExamplePolicyArbiterConstructorOptions } from "../models/IExamplePolicyArbiterConstructorOptions.js";
4
+ /**
5
+ * Example Policy Arbiter.
6
+ */
7
+ export declare class ExamplePolicyArbiter implements IPolicyArbiter {
8
+ /**
9
+ * The class name of the Example Policy Arbiter.
10
+ */
11
+ static readonly CLASS_NAME: string;
12
+ /**
13
+ * Create a new instance of ExamplePolicyArbiter.
14
+ * @param options The options for the example policy arbiter.
15
+ */
16
+ constructor(options?: IExamplePolicyArbiterConstructorOptions);
17
+ /**
18
+ * Returns the class name of the component.
19
+ * @returns The class name of the component.
20
+ */
21
+ className(): string;
22
+ /**
23
+ * The policies supported by this arbiter.
24
+ * @returns The supported policies, if empty can be used for all.
25
+ */
26
+ supportedPolicies(): IPolicyLocator[];
27
+ /**
28
+ * Makes decisions regarding policy access to data.
29
+ * @param locator The locator to find relevant policies.
30
+ * @param information Information provided by the requester to determine if a policy can be created.
31
+ * @param policies The policies that apply to the data.
32
+ * @param data The data to make a decision on.
33
+ * @returns The decisions about access to the data.
34
+ */
35
+ decide<D = unknown>(locator: IPolicyLocator, information?: IPolicyInformation, policies?: IOdrlPolicy[], data?: D): Promise<IPolicyDecision[]>;
36
+ }
@@ -0,0 +1,29 @@
1
+ import type { IPolicyDecision, IPolicyEnforcementProcessor, IPolicyLocator } from "@twin.org/rights-management-models";
2
+ import type { IExamplePolicyEnforcementProcessorConstructorOptions } from "../models/IExamplePolicyEnforcementProcessorConstructorOptions.js";
3
+ /**
4
+ * Example Policy Enforcement Processor.
5
+ */
6
+ export declare class ExamplePolicyEnforcementProcessor implements IPolicyEnforcementProcessor {
7
+ /**
8
+ * The class name of the Example Policy Enforcement Processor.
9
+ */
10
+ static readonly CLASS_NAME: string;
11
+ /**
12
+ * Create a new instance of ExamplePolicyEnforcementProcessor.
13
+ * @param options The options for the example policy enforcement processor.
14
+ */
15
+ constructor(options?: IExamplePolicyEnforcementProcessorConstructorOptions);
16
+ /**
17
+ * Returns the class name of the component.
18
+ * @returns The class name of the component.
19
+ */
20
+ className(): string;
21
+ /**
22
+ * Process the response from the policy decision point.
23
+ * @param locator The locator to find relevant policies.
24
+ * @param decisions The decisions made by the policy decision point.
25
+ * @param data The data to process.
26
+ * @returns The data after processing.
27
+ */
28
+ process<D = unknown, R = D>(locator: IPolicyLocator, decisions: IPolicyDecision[], data?: D): Promise<R>;
29
+ }