@twin.org/rights-management-plugins 0.0.3-next.26 → 0.0.3-next.28
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/dist/es/policyArbiters/defaultPolicyArbiter.js +60 -6
- package/dist/es/policyArbiters/defaultPolicyArbiter.js.map +1 -1
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js.map +1 -1
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js.map +1 -1
- package/dist/es/policyInformationSources/staticPolicyInformationSource.js.map +1 -1
- package/dist/es/policyObligationEnforcers/passThroughPolicyObligationEnforcer.js.map +1 -1
- package/dist/types/policyArbiters/defaultPolicyArbiter.d.ts +6 -0
- package/dist/types/policyExecutionActions/loggingPolicyExecutionAction.d.ts +2 -3
- package/dist/types/policyInformationSources/identityPolicyInformationSource.d.ts +2 -3
- package/dist/types/policyInformationSources/staticPolicyInformationSource.d.ts +2 -3
- package/dist/types/policyObligationEnforcers/passThroughPolicyObligationEnforcer.d.ts +2 -3
- package/docs/changelog.md +44 -0
- package/docs/examples.md +29 -0
- package/docs/reference/classes/DefaultPolicyArbiter.md +10 -0
- package/docs/reference/classes/IdentityPolicyInformationSource.md +1 -1
- package/docs/reference/classes/LoggingPolicyExecutionAction.md +1 -1
- package/docs/reference/classes/PassThroughPolicyObligationEnforcer.md +1 -1
- package/docs/reference/classes/StaticPolicyInformationSource.md +1 -1
- package/locales/en.json +2 -1
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Copyright 2025 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
-
import { ArrayHelper, Coerce, ComponentFactory, GeneralError, Guards, Is, ObjectHelper } from "@twin.org/core";
|
|
3
|
+
import { ArrayHelper, Coerce, ComponentFactory, GeneralError, Guards, Is, ObjectHelper, StringHelper } from "@twin.org/core";
|
|
4
4
|
import { JsonPathHelper } from "@twin.org/data-json-path";
|
|
5
|
-
import { OdrlPolicyHelper, PolicyDecision, PolicyObligationEnforcerFactory } from "@twin.org/rights-management-models";
|
|
5
|
+
import { OdrlPolicyHelper, OdrlProfiles, PolicyDecision, PolicyObligationEnforcerFactory } from "@twin.org/rights-management-models";
|
|
6
6
|
import { OdrlConflictStrategyType, OdrlLogicalConstraintType, OdrlOperatorType, OdrlTypes } from "@twin.org/standards-w3c-odrl";
|
|
7
7
|
/**
|
|
8
8
|
* Default Policy Arbiter.
|
|
@@ -12,6 +12,12 @@ export class DefaultPolicyArbiter {
|
|
|
12
12
|
* The class name of the Default Policy Arbiter.
|
|
13
13
|
*/
|
|
14
14
|
static CLASS_NAME = "DefaultPolicyArbiter";
|
|
15
|
+
/**
|
|
16
|
+
* ODRL profiles whose custom vocabulary this arbiter understands and supports.
|
|
17
|
+
* Any policy declaring a profile not in this set will be rejected.
|
|
18
|
+
* Add a new entry here when support for an additional profile is implemented.
|
|
19
|
+
*/
|
|
20
|
+
static SUPPORTED_PROFILES = new Set([OdrlProfiles.Twin]);
|
|
15
21
|
/**
|
|
16
22
|
* Default maximum inheritance depth.
|
|
17
23
|
* @internal
|
|
@@ -58,6 +64,26 @@ export class DefaultPolicyArbiter {
|
|
|
58
64
|
Coerce.integer(options?.config?.maxInheritanceDepth) ??
|
|
59
65
|
DefaultPolicyArbiter._DEFAULT_MAX_INHERITANCE_DEPTH;
|
|
60
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Normalises a profile IRI for comparison against the supported-profiles allowlist.
|
|
69
|
+
* Per RFC 3986: scheme and host are case-insensitive (the URL constructor folds them to
|
|
70
|
+
* lowercase automatically); a trailing slash on the terminal path segment is treated as
|
|
71
|
+
* equivalent to its absence; repeated slashes in the path are collapsed to a single slash.
|
|
72
|
+
* Non-URL strings are returned unchanged.
|
|
73
|
+
* @param iri The IRI to normalise.
|
|
74
|
+
* @returns The normalised IRI.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
static normalizeProfileIri(iri) {
|
|
78
|
+
try {
|
|
79
|
+
const url = new URL(iri);
|
|
80
|
+
const pathname = url.pathname.replace(/\/+/g, "/");
|
|
81
|
+
return `${url.protocol}//${url.host}${StringHelper.trimTrailingSlashes(pathname)}`;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return iri;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
61
87
|
/**
|
|
62
88
|
* Returns the class name of the component.
|
|
63
89
|
* @returns The class name of the component.
|
|
@@ -77,10 +103,29 @@ export class DefaultPolicyArbiter {
|
|
|
77
103
|
Guards.object(DefaultPolicyArbiter.CLASS_NAME, "agreement", agreement);
|
|
78
104
|
// ODRL policy profiles extend the vocabulary with additional semantics (e.g. custom
|
|
79
105
|
// operators, left operands). Without profile-aware evaluation logic the arbiter
|
|
80
|
-
// cannot guarantee correctness, so any policy that declares
|
|
81
|
-
|
|
106
|
+
// cannot guarantee correctness, so any policy that declares an unknown profile is
|
|
107
|
+
// rejected. The TWIN platform profile is explicitly supported.
|
|
108
|
+
//
|
|
109
|
+
// Empty-string profile values (e.g. from over-eager schema defaults or serialization
|
|
110
|
+
// round-trips) are treated as "no profile declared" and filtered out before comparison.
|
|
111
|
+
//
|
|
112
|
+
// Profile IRIs are normalized before lookup: scheme and host are case-folded to
|
|
113
|
+
// lowercase and a trailing slash on the last path segment is stripped. This accepts
|
|
114
|
+
// common IRI variants (HTTPS://, uppercase host, trailing slash) instead of silently
|
|
115
|
+
// rejecting valid policies authored by IRI-aware tooling.
|
|
116
|
+
//
|
|
117
|
+
// `every` (conjunction) is intentional: a policy declaring ["TWIN", "unknown"] is
|
|
118
|
+
// rejected — the arbiter refuses to evaluate rules from a profile whose semantics it
|
|
119
|
+
// does not understand, even if other declared profiles are known.
|
|
120
|
+
const declaredProfiles = ArrayHelper.fromObjectOrArray(agreement.profile ?? [])
|
|
121
|
+
.filter(p => Is.stringValue(p))
|
|
122
|
+
.map(p => DefaultPolicyArbiter.normalizeProfileIri(p));
|
|
123
|
+
if (Is.arrayValue(declaredProfiles) &&
|
|
124
|
+
!declaredProfiles.every(p => DefaultPolicyArbiter.SUPPORTED_PROFILES.has(p))) {
|
|
125
|
+
const unsupportedProfile = declaredProfiles.find(p => !DefaultPolicyArbiter.SUPPORTED_PROFILES.has(p));
|
|
82
126
|
throw new GeneralError(DefaultPolicyArbiter.CLASS_NAME, "policyProfileNotSupported", {
|
|
83
|
-
policyId: OdrlPolicyHelper.getUid(agreement) ?? ""
|
|
127
|
+
policyId: OdrlPolicyHelper.getUid(agreement) ?? "",
|
|
128
|
+
unsupportedProfile
|
|
84
129
|
});
|
|
85
130
|
}
|
|
86
131
|
await this._logging.log({
|
|
@@ -359,8 +404,17 @@ export class DefaultPolicyArbiter {
|
|
|
359
404
|
const mergedPermissions = ArrayHelper.fromObjectOrArray(policy.permission ?? []).map(permission => this.applyPolicyDefaultsToRule(policy, permission));
|
|
360
405
|
const mergedProhibitions = ArrayHelper.fromObjectOrArray(policy.prohibition ?? []).map(prohibition => this.applyPolicyDefaultsToRule(policy, prohibition));
|
|
361
406
|
const mergedObligations = ArrayHelper.fromObjectOrArray(policy.obligation ?? []).map(obligation => this.applyPolicyDefaultsToRule(policy, obligation));
|
|
362
|
-
// Merge rules from each inherited policy
|
|
407
|
+
// Merge rules from each inherited policy, applying the same profile guard as the
|
|
408
|
+
// top-level policy. A parent that declares an unsupported profile may carry rules
|
|
409
|
+
// whose semantics the arbiter cannot guarantee, so it is rejected.
|
|
363
410
|
for (const inheritedPolicy of inheritedPolicies) {
|
|
411
|
+
const inheritedProfiles = ArrayHelper.fromObjectOrArray(inheritedPolicy.profile ?? [])
|
|
412
|
+
.filter(p => Is.stringValue(p))
|
|
413
|
+
.map(p => DefaultPolicyArbiter.normalizeProfileIri(p));
|
|
414
|
+
if (Is.arrayValue(inheritedProfiles) &&
|
|
415
|
+
!inheritedProfiles.every(p => DefaultPolicyArbiter.SUPPORTED_PROFILES.has(p))) {
|
|
416
|
+
throw new GeneralError(DefaultPolicyArbiter.CLASS_NAME, "inheritedPolicyProfileNotSupported", { policyId: OdrlPolicyHelper.getUid(inheritedPolicy) ?? "" });
|
|
417
|
+
}
|
|
364
418
|
if (Is.stringValue(inheritedPolicy.conflict)) {
|
|
365
419
|
conflictStrategies.add(inheritedPolicy.conflict);
|
|
366
420
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultPolicyArbiter.js","sourceRoot":"","sources":["../../../src/policyArbiters/defaultPolicyArbiter.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,MAAM,EACN,EAAE,EACF,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,+BAA+B,EAI/B,MAAM,oCAAoC,CAAC;AAK5C,OAAO,EAEN,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,SAAS,EAaT,MAAM,8BAA8B,CAAC;AAGtC;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAChC;;OAEG;IACI,MAAM,CAAU,UAAU,0BAA0C;IAE3E;;;OAGG;IACK,MAAM,CAAU,8BAA8B,GAAG,EAAE,CAAC;IAE5D;;;OAGG;IACK,MAAM,CAAU,uBAAuB,GAAG,OAAO,CAAC;IAE1D;;;OAGG;IACK,MAAM,CAAU,qBAAqB,GAAG,UAAU,CAAC;IAE3D;;;OAGG;IACK,MAAM,CAAU,wBAAwB,GAAG,aAAa,CAAC;IAEjE;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACc,0BAA0B,CAAsC;IAEjF;;;OAGG;IACc,oBAAoB,CAAS;IAE9C;;;OAGG;IACH,YAAY,OAAiD;QAC5D,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,I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,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACpE,4BAA4B;YAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tArrayHelper,\n\tCoerce,\n\tComponentFactory,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tObjectHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { JsonPathHelper } from \"@twin.org/data-json-path\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\tPolicyDecision,\n\tPolicyObligationEnforcerFactory,\n\ttype IPolicyAdministrationPointComponent,\n\ttype IPolicyArbiter,\n\ttype IPolicyDecision\n} from \"@twin.org/rights-management-models\";\nimport type {\n\tIDataspaceProtocolAgreement,\n\tIDataspaceProtocolPolicy\n} from \"@twin.org/standards-dataspace-protocol\";\nimport {\n\ttype IOdrlAssetCollection,\n\tOdrlConflictStrategyType,\n\tOdrlLogicalConstraintType,\n\tOdrlOperatorType,\n\tOdrlTypes,\n\ttype IOdrlAction,\n\ttype IOdrlAsset,\n\ttype IOdrlConstraint,\n\ttype IOdrlDuty,\n\ttype IOdrlLogicalConstraint,\n\ttype IOdrlLogicalConstraintOperand,\n\ttype IOdrlParty,\n\ttype IOdrlPartyCollection,\n\ttype IOdrlPermission,\n\ttype IOdrlProhibition,\n\ttype IOdrlRule,\n\ttype OdrlActionType\n} from \"@twin.org/standards-w3c-odrl\";\nimport type { IDefaultPolicyArbiterConstructorOptions } from \"../models/IDefaultPolicyArbiterConstructorOptions.js\";\n\n/**\n * Default Policy Arbiter.\n */\nexport class DefaultPolicyArbiter implements IPolicyArbiter {\n\t/**\n\t * The class name of the Default Policy Arbiter.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DefaultPolicyArbiter>();\n\n\t/**\n\t * Default maximum inheritance depth.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_MAX_INHERITANCE_DEPTH = 10;\n\n\t/**\n\t * TWIN prefix operations.\n\t * @internal\n\t */\n\tprivate static readonly _TWIN_PREFIX_OPERATIONS = \"twin:\";\n\n\t/**\n\t * TWIN prefix JSONPath.\n\t * @internal\n\t */\n\tprivate static readonly _TWIN_PREFIX_JSONPATH = \"jsonpath\";\n\n\t/**\n\t * TWIN prefix information.\n\t * @internal\n\t */\n\tprivate static readonly _TWIN_PREFIX_INFORMATION = \"information\";\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging: ILoggingComponent;\n\n\t/**\n\t * The policy administration point component.\n\t * @internal\n\t */\n\tprivate readonly _policyAdministrationPoint: IPolicyAdministrationPointComponent;\n\n\t/**\n\t * The maximum depth to traverse when resolving inherited policies.\n\t * @internal\n\t */\n\tprivate readonly _maxInheritanceDepth: number;\n\n\t/**\n\t * Create a new instance of DefaultPolicyArbiter.\n\t * @param options The options for the default policy arbiter.\n\t */\n\tconstructor(options?: IDefaultPolicyArbiterConstructorOptions) {\n\t\tthis._logging = ComponentFactory.get<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\n\t\tthis._policyAdministrationPoint = ComponentFactory.get<IPolicyAdministrationPointComponent>(\n\t\t\toptions?.policyAdministrationPointComponentType ?? \"policy-administration-point\"\n\t\t);\n\n\t\tthis._maxInheritanceDepth =\n\t\t\tCoerce.integer(options?.config?.maxInheritanceDepth) ??\n\t\t\tDefaultPolicyArbiter._DEFAULT_MAX_INHERITANCE_DEPTH;\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 DefaultPolicyArbiter.CLASS_NAME;\n\t}\n\n\t/**\n\t * Makes decisions regarding policy access to data.\n\t * @param agreement The agreement to evaluate.\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 arbiter will evaluate all actions in the agreement.\n\t * @returns The decisions about access to the data.\n\t */\n\tpublic async decide<D = unknown>(\n\t\tagreement: IDataspaceProtocolAgreement,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: D,\n\t\taction?: OdrlActionType | string\n\t): Promise<IPolicyDecision[]> {\n\t\tGuards.object<IDataspaceProtocolAgreement>(\n\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\n\t\t// ODRL policy profiles extend the vocabulary with additional semantics (e.g. custom\n\t\t// operators, left operands). Without profile-aware evaluation logic the arbiter\n\t\t// cannot guarantee correctness, so any policy that declares a profile is rejected.\n\t\tif (Is.notEmpty(agreement.profile)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"policyProfileNotSupported\", {\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t});\n\t\t}\n\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DefaultPolicyArbiter.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"decidingPolicy\",\n\t\t\tdata: {\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\t// Resolve and merge inherited policies.\n\t\tconst mergedPolicy = await this.mergeInheritedPolicies(agreement);\n\t\tconst expandedPolicy = this.expandCompactPolicyRules(mergedPolicy);\n\t\tconst dataSources = {\n\t\t\t[`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}`]:\n\t\t\t\tdata,\n\t\t\t[`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_INFORMATION}`]:\n\t\t\t\tinformation\n\t\t};\n\n\t\t// Extract agreement parties once for use in rule evaluation\n\t\tconst agreementAssigner = OdrlPolicyHelper.getPartyIds(agreement.assigner);\n\t\tconst agreementAssignee = OdrlPolicyHelper.getPartyIds(agreement.assignee);\n\t\tconst obligationsFulfilled = await this.evaluatePolicyObligations(\n\t\t\tagreementAssigner,\n\t\t\tagreementAssignee,\n\t\t\texpandedPolicy,\n\t\t\tdataSources\n\t\t);\n\n\t\t// ODRL-style rule evaluation grouped by decision target:\n\t\t// - Permission rules authorize if ANY applicable permission on the same target matches.\n\t\t// - Default to denied when no permission applies on a target (closed-world for access control).\n\t\t// - Conflict strategy controls how applicable permissions/prohibitions are resolved per target.\n\t\tconst targetStates: {\n\t\t\t[target: string]: {\n\t\t\t\tpermissionApplies: boolean;\n\t\t\t\tprohibitionApplies: boolean;\n\t\t\t};\n\t\t} = Object.create(null) as {\n\t\t\t[target: string]: {\n\t\t\t\tpermissionApplies: boolean;\n\t\t\t\tprohibitionApplies: boolean;\n\t\t\t};\n\t\t};\n\n\t\tconst permissions = ArrayHelper.fromObjectOrArray(expandedPolicy.permission ?? []);\n\t\tfor (const permission of permissions) {\n\t\t\tconst decisionTargets = this.resolveRuleDecisionTargets(permission, dataSources);\n\t\t\tfor (const decisionTarget of decisionTargets) {\n\t\t\t\tconst state = this.getOrCreateTargetState(targetStates, decisionTarget.target);\n\t\t\t\tif (\n\t\t\t\t\tawait this.evaluatePermission(\n\t\t\t\t\t\tagreementAssigner,\n\t\t\t\t\t\tagreementAssignee,\n\t\t\t\t\t\texpandedPolicy,\n\t\t\t\t\t\tpermission,\n\t\t\t\t\t\tdecisionTarget.refinements,\n\t\t\t\t\t\tdataSources,\n\t\t\t\t\t\taction,\n\t\t\t\t\t\tdecisionTarget.target\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tstate.permissionApplies = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst prohibitions = ArrayHelper.fromObjectOrArray<IOdrlProhibition>(\n\t\t\texpandedPolicy.prohibition ?? []\n\t\t);\n\t\tfor (const prohibition of prohibitions) {\n\t\t\tconst decisionTargets = this.resolveRuleDecisionTargets(prohibition, dataSources);\n\t\t\tfor (const decisionTarget of decisionTargets) {\n\t\t\t\tif (\n\t\t\t\t\tawait this.evaluateProhibition(\n\t\t\t\t\t\texpandedPolicy,\n\t\t\t\t\t\tagreementAssigner,\n\t\t\t\t\t\tagreementAssignee,\n\t\t\t\t\t\tprohibition,\n\t\t\t\t\t\tdecisionTarget.refinements,\n\t\t\t\t\t\tdataSources,\n\t\t\t\t\t\taction,\n\t\t\t\t\t\tdecisionTarget.target\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tconst state = this.getOrCreateTargetState(targetStates, decisionTarget.target);\n\t\t\t\t\tstate.prohibitionApplies = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst conflictStrategy = expandedPolicy.conflict ?? OdrlConflictStrategyType.Invalid;\n\t\tif (Object.keys(targetStates).length === 0) {\n\t\t\t// Closed-world fallback when the policy has no rules at all.\n\t\t\treturn [{ decision: PolicyDecision.Denied, target: \"$\" }];\n\t\t}\n\n\t\tconst decisions: IPolicyDecision[] = [];\n\t\tfor (const [target, state] of Object.entries(targetStates)) {\n\t\t\tlet decision: PolicyDecision;\n\t\t\tif (state.permissionApplies && state.prohibitionApplies) {\n\t\t\t\tswitch (conflictStrategy) {\n\t\t\t\t\tcase OdrlConflictStrategyType.Perm:\n\t\t\t\t\t\tdecision = PolicyDecision.Granted;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase OdrlConflictStrategyType.Prohibit:\n\t\t\t\t\tcase OdrlConflictStrategyType.Invalid:\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tdecision = PolicyDecision.Denied;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdecision = state.permissionApplies ? PolicyDecision.Granted : PolicyDecision.Denied;\n\t\t\t}\n\n\t\t\tif (!obligationsFulfilled) {\n\t\t\t\tdecision = PolicyDecision.Denied;\n\t\t\t}\n\n\t\t\tdecisions.push({\n\t\t\t\tdecision,\n\t\t\t\ttarget\n\t\t\t});\n\t\t}\n\n\t\treturn decisions;\n\t}\n\n\t/**\n\t * Expand compact/compound policy rule forms into atomic rules.\n\t * ODRL 2.7 allows compact forms where rule properties can be arrays.\n\t * Evaluation in this arbiter is performed on expanded atomic rules.\n\t * @param policy The policy to expand.\n\t * @returns A policy with expanded rule arrays.\n\t * @internal\n\t */\n\tprivate expandCompactPolicyRules(policy: IDataspaceProtocolPolicy): IDataspaceProtocolPolicy {\n\t\tconst expandedPermissions = this.expandRules(\n\t\t\tArrayHelper.fromObjectOrArray<IOdrlPermission>(policy.permission ?? [])\n\t\t);\n\t\tconst expandedProhibitions = this.expandRules(\n\t\t\tArrayHelper.fromObjectOrArray<IOdrlProhibition>(policy.prohibition ?? [])\n\t\t);\n\t\tconst expandedObligations = this.expandRules(\n\t\t\tArrayHelper.fromObjectOrArray<IOdrlDuty>(policy.obligation ?? [])\n\t\t);\n\n\t\treturn {\n\t\t\t...policy,\n\t\t\tpermission: expandedPermissions.length > 0 ? expandedPermissions : undefined,\n\t\t\tprohibition: expandedProhibitions.length > 0 ? expandedProhibitions : undefined,\n\t\t\tobligation: expandedObligations.length > 0 ? expandedObligations : undefined\n\t\t};\n\t}\n\n\t/**\n\t * Expand a rule list into atomic rules.\n\t * @param rules The rules to expand.\n\t * @returns Expanded atomic rules.\n\t * @internal\n\t */\n\tprivate expandRules<T extends IOdrlRule>(rules: T[]): T[] {\n\t\tconst expanded: T[] = [];\n\t\tfor (const rule of rules) {\n\t\t\texpanded.push(...this.expandRule(rule));\n\t\t}\n\n\t\treturn expanded;\n\t}\n\n\t/**\n\t * Expand a single compact/compound rule into atomic rules.\n\t * @param rule The rule to expand.\n\t * @returns Expanded atomic rules.\n\t * @internal\n\t */\n\tprivate expandRule<T extends IOdrlRule>(rule: T): T[] {\n\t\tconst targets = this.normalizeRuleField<NonNullable<IOdrlRule[\"target\"]>>(rule.target);\n\t\tconst actions = this.normalizeRuleField<NonNullable<IOdrlRule[\"action\"]>>(rule.action);\n\t\tconst assigners = this.normalizeRuleField<NonNullable<IOdrlRule[\"assigner\"]>>(rule.assigner);\n\t\tconst assignees = this.normalizeRuleField<NonNullable<IOdrlRule[\"assignee\"]>>(rule.assignee);\n\n\t\tconst expanded: T[] = [];\n\t\tfor (const target of targets) {\n\t\t\tfor (const action of actions) {\n\t\t\t\tfor (const assigner of assigners) {\n\t\t\t\t\tfor (const assignee of assignees) {\n\t\t\t\t\t\tconst atomicRule = { ...rule };\n\t\t\t\t\t\tatomicRule.target = target;\n\t\t\t\t\t\tatomicRule.action = action;\n\t\t\t\t\t\tatomicRule.assigner = assigner;\n\t\t\t\t\t\tatomicRule.assignee = assignee;\n\t\t\t\t\t\texpanded.push(atomicRule);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn expanded;\n\t}\n\n\t/**\n\t * Normalize a potentially compact rule field into an array for expansion.\n\t * @param value The field value.\n\t * @returns Normalized values (or a single undefined when not provided).\n\t * @internal\n\t */\n\tprivate normalizeRuleField<T>(value: T | undefined): (T | undefined)[] {\n\t\tif (Is.undefined(value)) {\n\t\t\treturn [undefined];\n\t\t}\n\n\t\tconst values = ArrayHelper.fromObjectOrArray(value);\n\t\treturn values.length > 0 ? values : [undefined];\n\t}\n\n\t/**\n\t * Get an existing target state or create an initial state if it doesn't exist.\n\t * @param targetStates The dictionary of target states.\n\t * @param target The target key.\n\t * @returns The target state.\n\t * @internal\n\t */\n\tprivate getOrCreateTargetState(\n\t\ttargetStates: {\n\t\t\t[target: string]: {\n\t\t\t\tpermissionApplies: boolean;\n\t\t\t\tprohibitionApplies: boolean;\n\t\t\t};\n\t\t},\n\t\ttarget: string\n\t): {\n\t\tpermissionApplies: boolean;\n\t\tprohibitionApplies: boolean;\n\t} {\n\t\tlet state = targetStates[target];\n\t\tif (Is.undefined(state)) {\n\t\t\tstate = {\n\t\t\t\tpermissionApplies: false,\n\t\t\t\tprohibitionApplies: false\n\t\t\t};\n\t\t\ttargetStates[target] = state;\n\t\t}\n\n\t\treturn state;\n\t}\n\n\t/**\n\t * Evaluate whether a prohibition applies.\n\t * @param policy The policy containing the prohibition.\n\t * @param agreementAssigner The assigner ID from the agreement.\n\t * @param agreementAssignee The assignee ID from the agreement.\n\t * @param prohibition The prohibition to evaluate.\n\t * @param targetRefinements Additional constraints from target refinement.\n\t * @param dataSources The operand lookup sources.\n\t * @param action Optional action to check against the prohibition's applicable actions.\n\t * @returns True if the prohibition applies.\n\t * @internal\n\t */\n\tprivate async evaluateProhibition(\n\t\tpolicy: IDataspaceProtocolPolicy,\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tprohibition: IOdrlProhibition,\n\t\ttargetRefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[],\n\t\tdataSources: { [prefix: string]: unknown },\n\t\taction?: OdrlActionType | string,\n\t\tdecisionTarget?: string\n\t): Promise<boolean> {\n\t\tif (\n\t\t\t!this.isRuleApplicableToParties(\n\t\t\t\tprohibition,\n\t\t\t\tagreementAssigner,\n\t\t\t\tagreementAssignee,\n\t\t\t\tdataSources\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check if the prohibition's action(s) match the requested action\n\t\tif (!this.isActionApplicable(prohibition.action, action, dataSources)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// ODRL semantics: a rule without constraints is unconditional.\n\t\tconst constraints = [\n\t\t\t...ArrayHelper.fromObjectOrArray(prohibition.constraint ?? []),\n\t\t\t...targetRefinements\n\t\t];\n\t\tif (\n\t\t\tconstraints.length > 0 &&\n\t\t\t!constraints.every(c => this.evaluateConstraint(c, dataSources))\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst prohibitionTargetLookup = this.tryResolveTargetDataSource(\n\t\t\tthis.buildRuleDataContextTargetId(\n\t\t\t\tthis.getRuleDataContextTargetId(prohibition.target),\n\t\t\t\tdecisionTarget\n\t\t\t),\n\t\t\tdataSources,\n\t\t\ttrue\n\t\t);\n\t\tconst ruleDataContext = prohibitionTargetLookup.value;\n\n\t\tconst remedies = ArrayHelper.fromObjectOrArray<IOdrlDuty>(prohibition.remedy ?? []);\n\t\tif (remedies.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tfor (const remedy of remedies) {\n\t\t\tif (!(await this.enforceDuty(policy, remedy, dataSources, ruleDataContext))) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// Remedies satisfied: prohibition is treated as no longer infringed.\n\t\treturn false;\n\t}\n\n\t/**\n\t * Evaluate all policy-level obligations.\n\t * @param agreementAssigner The assigner ID from the agreement.\n\t * @param agreementAssignee The assignee ID from the agreement.\n\t * @param policy The policy containing obligations.\n\t * @param dataSources The operand lookup sources.\n\t * @returns True if all applicable obligations are fulfilled.\n\t * @internal\n\t */\n\tprivate async evaluatePolicyObligations(\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tpolicy: IDataspaceProtocolPolicy,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): Promise<boolean> {\n\t\tconst obligations = ArrayHelper.fromObjectOrArray<IOdrlDuty>(policy.obligation ?? []);\n\t\tfor (const obligation of obligations) {\n\t\t\tif (\n\t\t\t\t!(await this.evaluateObligation(\n\t\t\t\t\tagreementAssigner,\n\t\t\t\t\tagreementAssignee,\n\t\t\t\t\tpolicy,\n\t\t\t\t\tobligation,\n\t\t\t\t\tdataSources\n\t\t\t\t))\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Evaluate whether a policy-level obligation is fulfilled.\n\t * @param agreementAssigner The assigner ID from the agreement.\n\t * @param agreementAssignee The assignee ID from the agreement.\n\t * @param policy The policy containing the obligation.\n\t * @param obligation The obligation to evaluate.\n\t * @param dataSources The operand lookup sources.\n\t * @returns True if the obligation is not applicable or is fulfilled.\n\t * @internal\n\t */\n\tprivate async evaluateObligation(\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tpolicy: IDataspaceProtocolPolicy,\n\t\tobligation: IOdrlDuty,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): Promise<boolean> {\n\t\tif (\n\t\t\t!this.isRuleApplicableToParties(obligation, agreementAssigner, agreementAssignee, dataSources)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst { refinements } = this.resolveRuleTarget(obligation, dataSources);\n\t\tconst obligationTargetLookup = this.tryResolveTargetDataSource(\n\t\t\tthis.getTargetId(obligation.target),\n\t\t\tdataSources,\n\t\t\ttrue\n\t\t);\n\t\tconst ruleDataContext = obligationTargetLookup.value;\n\t\tconst constraints = [\n\t\t\t...ArrayHelper.fromObjectOrArray(obligation.constraint ?? []),\n\t\t\t...refinements\n\t\t];\n\n\t\tif (\n\t\t\tconstraints.length > 0 &&\n\t\t\t!constraints.every(c => this.evaluateConstraint(c, dataSources))\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn this.enforceDuty(policy, obligation, dataSources, ruleDataContext);\n\t}\n\n\t/**\n\t * Merge inherited policies into the current policy.\n\t * Inherited policies' permissions, prohibitions, and obligations are combined with the current policy's rules.\n\t * @param policy The policy to evaluate.\n\t * @returns A new policy with merged rules from all ancestors.\n\t * @internal\n\t */\n\tprivate async mergeInheritedPolicies(\n\t\tpolicy: IDataspaceProtocolPolicy\n\t): Promise<IDataspaceProtocolPolicy> {\n\t\tconst visitedPolicyIds: string[] = [];\n\t\tvisitedPolicyIds.push(OdrlPolicyHelper.getUid(policy) ?? \"\");\n\t\tconst inheritedPolicies = await this.resolveInheritedPolicies(policy, visitedPolicyIds, 0);\n\t\tconst conflictStrategies = new Set<OdrlConflictStrategyType>();\n\t\tif (Is.stringValue(policy.conflict)) {\n\t\t\tconflictStrategies.add(policy.conflict);\n\t\t}\n\n\t\t// Start with copies of the current policy's rules\n\t\tconst mergedPermissions: IOdrlPermission[] = ArrayHelper.fromObjectOrArray(\n\t\t\tpolicy.permission ?? []\n\t\t).map(permission => this.applyPolicyDefaultsToRule(policy, permission));\n\n\t\tconst mergedProhibitions: IOdrlProhibition[] = ArrayHelper.fromObjectOrArray(\n\t\t\tpolicy.prohibition ?? []\n\t\t).map(prohibition => this.applyPolicyDefaultsToRule(policy, prohibition));\n\n\t\tconst mergedObligations: IOdrlDuty[] = ArrayHelper.fromObjectOrArray(\n\t\t\tpolicy.obligation ?? []\n\t\t).map(obligation => this.applyPolicyDefaultsToRule(policy, obligation));\n\n\t\t// Merge rules from each inherited policy\n\t\tfor (const inheritedPolicy of inheritedPolicies) {\n\t\t\tif (Is.stringValue(inheritedPolicy.conflict)) {\n\t\t\t\tconflictStrategies.add(inheritedPolicy.conflict);\n\t\t\t}\n\t\t\tconst inheritedPermissions = ArrayHelper.fromObjectOrArray(inheritedPolicy.permission ?? []);\n\t\t\tif (inheritedPermissions.length > 0) {\n\t\t\t\tmergedPermissions.push(\n\t\t\t\t\t...inheritedPermissions.map(permission =>\n\t\t\t\t\t\tthis.applyPolicyDefaultsToRule(inheritedPolicy, permission)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst inheritedProhibitions = ArrayHelper.fromObjectOrArray(\n\t\t\t\tinheritedPolicy.prohibition ?? []\n\t\t\t);\n\t\t\tif (inheritedProhibitions.length > 0) {\n\t\t\t\tmergedProhibitions.push(\n\t\t\t\t\t...inheritedProhibitions.map(prohibition =>\n\t\t\t\t\t\tthis.applyPolicyDefaultsToRule(inheritedPolicy, prohibition)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst inheritedObligations = ArrayHelper.fromObjectOrArray(inheritedPolicy.obligation ?? []);\n\t\t\tif (inheritedObligations.length > 0) {\n\t\t\t\tmergedObligations.push(\n\t\t\t\t\t...inheritedObligations.map(obligation =>\n\t\t\t\t\t\tthis.applyPolicyDefaultsToRule(inheritedPolicy, obligation)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tlet mergedConflict: OdrlConflictStrategyType | undefined;\n\t\tif (conflictStrategies.size === 1) {\n\t\t\tmergedConflict = Array.from(conflictStrategies)[0];\n\t\t} else if (conflictStrategies.size > 1) {\n\t\t\tmergedConflict = OdrlConflictStrategyType.Invalid;\n\t\t}\n\n\t\t// Return a new policy with merged rules\n\t\treturn {\n\t\t\t...policy,\n\t\t\tconflict: mergedConflict,\n\t\t\tpermission: mergedPermissions.length > 0 ? mergedPermissions : undefined,\n\t\t\tprohibition: mergedProhibitions.length > 0 ? mergedProhibitions : undefined,\n\t\t\tobligation: mergedObligations.length > 0 ? mergedObligations : undefined\n\t\t};\n\t}\n\n\t/**\n\t * Resolve inherited policies by their UIDs from the Policy Administration Point.\n\t * Policies can inherit from other policies via the inheritFrom property.\n\t * @param policy The policy that may have inheritFrom references.\n\t * @param visitedPolicyIds Array of policy UIDs already visited in this inheritance chain.\n\t * @returns Array of inherited policies fetched from the PAP.\n\t * @internal\n\t */\n\tprivate async resolveInheritedPolicies(\n\t\tpolicy: IDataspaceProtocolPolicy,\n\t\tvisitedPolicyIds: string[],\n\t\tcurrentDepth: number\n\t): Promise<IDataspaceProtocolPolicy[]> {\n\t\tconst inheritedPolicies: IDataspaceProtocolPolicy[] = [];\n\n\t\t// If policy has no inheritFrom, return empty array\n\t\tif (Is.empty(policy.inheritFrom)) {\n\t\t\treturn inheritedPolicies;\n\t\t}\n\n\t\tconst inheritFromIds = ArrayHelper.fromObjectOrArray<string>(policy.inheritFrom) ?? [];\n\n\t\tfor (const inheritFromId of inheritFromIds) {\n\t\t\tconst nextDepth = currentDepth + 1;\n\t\t\tif (nextDepth > this._maxInheritanceDepth) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"maxInheritanceDepthExceeded\", {\n\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\tinheritFromId,\n\t\t\t\t\tmaxInheritanceDepth: this._maxInheritanceDepth\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Check for circular inheritance\n\t\t\tif (visitedPolicyIds.includes(inheritFromId)) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"circularInheritanceDetected\", {\n\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\tinheritFromId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Fetch the inherited policy from the PAP\n\t\t\tconst inheritedPolicy = await this._policyAdministrationPoint.get(inheritFromId);\n\t\t\tif (Is.empty(inheritedPolicy)) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"inheritedPolicyNotFound\", {\n\t\t\t\t\tinheritFromId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Mark this policy as visited\n\t\t\tvisitedPolicyIds.push(inheritFromId);\n\n\t\t\tinheritedPolicies.push(inheritedPolicy);\n\n\t\t\t// Recursively resolve inherited policies of the parent\n\t\t\tconst grandparentPolicies = await this.resolveInheritedPolicies(\n\t\t\t\tinheritedPolicy,\n\t\t\t\tvisitedPolicyIds,\n\t\t\t\tnextDepth\n\t\t\t);\n\t\t\tinheritedPolicies.push(...grandparentPolicies);\n\t\t}\n\n\t\treturn inheritedPolicies;\n\t}\n\n\t/**\n\t * Apply policy-level default values (assigner, assignee, target, action) to rules that don't override them.\n\t * @param policy The policy providing defaults.\n\t * @param rule The rule to apply defaults to.\n\t * @returns The rule with policy-level defaults applied.\n\t * @internal\n\t */\n\tprivate applyPolicyDefaultsToRule<T extends IOdrlRule>(\n\t\tpolicy: IDataspaceProtocolPolicy,\n\t\trule: T\n\t): T {\n\t\tconst assigner = Is.empty(rule.assigner) ? policy.assigner : rule.assigner;\n\t\tconst assignee = Is.empty(rule.assignee) ? policy.assignee : rule.assignee;\n\t\tconst target = Is.empty(rule.target) ? policy.target : rule.target;\n\t\tconst action = Is.empty(rule.action) ? policy.action : rule.action;\n\n\t\tconst assignerIds = OdrlPolicyHelper.getPartyIds(assigner);\n\t\tconst ruleAssignerIds = OdrlPolicyHelper.getPartyIds(rule.assigner);\n\t\tconst assigneeIds = OdrlPolicyHelper.getPartyIds(assignee);\n\t\tconst ruleAssigneeIds = OdrlPolicyHelper.getPartyIds(rule.assignee);\n\n\t\tlet assignerEqual = false;\n\t\tif (Is.empty(assignerIds) && Is.empty(ruleAssignerIds)) {\n\t\t\tassignerEqual = true;\n\t\t} else if (!Is.empty(assignerIds) && !Is.empty(ruleAssignerIds)) {\n\t\t\tassignerEqual =\n\t\t\t\tassignerIds.length === ruleAssignerIds.length &&\n\t\t\t\tassignerIds.every(id => ruleAssignerIds.includes(id));\n\t\t}\n\n\t\tlet assigneeEqual = false;\n\t\tif (Is.empty(assigneeIds) && Is.empty(ruleAssigneeIds)) {\n\t\t\tassigneeEqual = true;\n\t\t} else if (!Is.empty(assigneeIds) && !Is.empty(ruleAssigneeIds)) {\n\t\t\tassigneeEqual =\n\t\t\t\tassigneeIds.length === ruleAssigneeIds.length &&\n\t\t\t\tassigneeIds.every(id => ruleAssigneeIds.includes(id));\n\t\t}\n\n\t\tconst targetEqual = target === rule.target;\n\t\tconst actionEqual = action === rule.action;\n\n\t\tif (assignerEqual && assigneeEqual && targetEqual && actionEqual) {\n\t\t\treturn rule;\n\t\t}\n\n\t\treturn {\n\t\t\t...rule,\n\t\t\tassigner,\n\t\t\tassignee,\n\t\t\ttarget,\n\t\t\taction\n\t\t};\n\t}\n\n\t/**\n\t * Determine whether a rule applies to the agreement parties based on assigner/assignee.\n\t * @param rule The rule to evaluate.\n\t * @param agreementAssigner The assigner ID from the agreement.\n\t * @param agreementAssignee The assignee ID from the agreement.\n\t * @returns True if the rule is applicable to the agreement parties.\n\t * @internal\n\t */\n\tprivate isRuleApplicableToParties(\n\t\trule: IOdrlRule,\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): boolean {\n\t\tconst assignerContext = this.resolveRulePartyContext(rule.assigner);\n\t\tconst assigneeContext = this.resolveRulePartyContext(rule.assignee);\n\n\t\tif (!this.isPartyApplicable(assignerContext.partyIds, agreementAssigner)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (\n\t\t\tassignerContext.refinements.length > 0 &&\n\t\t\t!assignerContext.refinements.every(c => this.evaluateConstraint(c, dataSources))\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!this.isPartyApplicable(assigneeContext.partyIds, agreementAssignee)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (\n\t\t\tassigneeContext.refinements.length > 0 &&\n\t\t\t!assigneeContext.refinements.every(c => this.evaluateConstraint(c, dataSources))\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Resolve rule party identifiers and refinements.\n\t * PartyCollection source values are currently not supported for party matching.\n\t * @param party The rule party value.\n\t * @returns Resolved party identifiers and refinement constraints.\n\t * @throws GeneralError if PartyCollection source has a value.\n\t * @internal\n\t */\n\tprivate resolveRulePartyContext(party: IOdrlRule[\"assigner\"] | IOdrlRule[\"assignee\"]): {\n\t\tpartyIds: string[];\n\t\trefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t} {\n\t\tconst partyIds: string[] = [];\n\t\tconst refinements: (IOdrlConstraint | IOdrlLogicalConstraint)[] = [];\n\n\t\tconst parties = ArrayHelper.fromObjectOrArray(party ?? []);\n\t\tfor (const partyEntry of parties) {\n\t\t\tif (Is.stringValue(partyEntry)) {\n\t\t\t\tpartyIds.push(partyEntry);\n\t\t\t} else if (Is.object<IOdrlParty>(partyEntry)) {\n\t\t\t\t// Guard against unsupported ODRL party properties\n\t\t\t\tif (Is.notEmpty(partyEntry.assignerOf)) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"partyAssignerOfNotSupported\");\n\t\t\t\t}\n\t\t\t\tif (Is.notEmpty(partyEntry.assigneeOf)) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"partyAssigneeOfNotSupported\");\n\t\t\t\t}\n\t\t\t\tif (Is.notEmpty(partyEntry.partOf)) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"partyPartOfNotSupported\");\n\t\t\t\t}\n\n\t\t\t\tif (OdrlPolicyHelper.getType(partyEntry) === OdrlTypes.PartyCollection) {\n\t\t\t\t\tconst partyCollectionEntry = partyEntry as IOdrlPartyCollection;\n\t\t\t\t\tif (Is.stringValue(partyCollectionEntry.source)) {\n\t\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\t\t\t\t\t\"partyCollectionSourceNotSupported\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsource: partyCollectionEntry.source ?? \"\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\trefinements.push(...ArrayHelper.fromObjectOrArray(partyCollectionEntry.refinement ?? []));\n\t\t\t\t} else {\n\t\t\t\t\tconst partyId = OdrlPolicyHelper.getUid(partyEntry);\n\t\t\t\t\tif (Is.stringValue(partyId)) {\n\t\t\t\t\t\tpartyIds.push(partyId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tpartyIds,\n\t\t\trefinements\n\t\t};\n\t}\n\n\t/**\n\t * Determine whether a rule party constraint applies to the agreement parties.\n\t * Rule party is treated as a constraint: if specified, it must match at least one agreement party.\n\t * @param rulePartyIds The party ids specified on the rule (if any).\n\t * @param agreementPartyIds The party ids extracted from the agreement.\n\t * @returns True if the rule party constraint is satisfied.\n\t * @internal\n\t */\n\tprivate isPartyApplicable(\n\t\trulePartyIds: string[] | undefined,\n\t\tagreementPartyIds: string[] | undefined\n\t): boolean {\n\t\t// No party specified on rule means it applies to any agreement party.\n\t\tif (Is.empty(rulePartyIds)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Rule specifies party/parties, but agreement doesn't provide any.\n\t\tif (Is.empty(agreementPartyIds)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const rulePartyId of rulePartyIds) {\n\t\t\tif (agreementPartyIds.includes(rulePartyId)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Determine whether a rule's action(s) match the requested action.\n\t * Supports exact match, includedIn hierarchy, and implies relationships.\n\t * If no action is specified in the rule, it applies to all actions (action-agnostic).\n\t * If an action is specified in the rule and a specific action is requested, they must match.\n\t * If an action is specified in the rule but no specific action is requested, the rule applies (general evaluation).\n\t * @param ruleActions The actions defined in the rule (can be string, object, or array).\n\t * @param requestedAction The action being requested (optional).\n\t * @returns True if the rule's action(s) apply.\n\t * @internal\n\t */\n\tprivate isActionApplicable(\n\t\truleActions: IOdrlRule[\"action\"],\n\t\trequestedAction: OdrlActionType | string | undefined,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): boolean {\n\t\t// If the rule has no action specified, it applies to all actions\n\t\tif (Is.empty(ruleActions)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If the rule has actions but no specific action is requested,\n\t\t// the rule applies (we're evaluating permissions in general)\n\t\tif (Is.empty(requestedAction)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst requestedActionId = Is.string(requestedAction)\n\t\t\t? requestedAction\n\t\t\t: OdrlPolicyHelper.getUid(requestedAction);\n\n\t\tif (!Is.stringValue(requestedActionId)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst ruleActionArray = ArrayHelper.fromObjectOrArray(ruleActions) ?? [];\n\n\t\tfor (const ruleAction of ruleActionArray) {\n\t\t\tif (this.ruleActionCoversRequested(ruleAction, requestedActionId, dataSources)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Determine whether a single rule action covers a requested action.\n\t * Covers exact match plus ODRL action hierarchy semantics.\n\t * - includedIn: the rule action is a sub-action of a broader parent.\n\t * A rule naming the narrower action also covers requests for the parent.\n\t * E.g. rule action \"print\" with includedIn \"reproduce\" covers a request for \"reproduce\".\n\t * - implies: the rule action entails another action.\n\t * A rule granting action X also covers action Y when X implies Y.\n\t * E.g. rule action \"distribute\" implying \"reproduce\" covers a request for \"reproduce\".\n\t * @param ruleAction The action specified in the rule.\n\t * @param requestedActionId The requested action identifier.\n\t * @returns True if the rule action covers the requested action.\n\t * @internal\n\t */\n\tprivate ruleActionCoversRequested(\n\t\truleAction: OdrlActionType | string | IOdrlAction,\n\t\trequestedActionId: string,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): boolean {\n\t\t// Extract the rule action ID — support both @id and rdf:value forms\n\t\tlet ruleActionId: string | undefined;\n\t\tif (Is.string(ruleAction)) {\n\t\t\truleActionId = ruleAction;\n\t\t} else if (Is.object<IOdrlAction>(ruleAction)) {\n\t\t\truleActionId = ruleAction[\"rdf:value\"]?.[\"@id\"] ?? OdrlPolicyHelper.getUid(ruleAction);\n\t\t}\n\n\t\t// Determine whether this rule action covers the requested action via any semantic path.\n\t\tlet covers = false;\n\n\t\tif (Is.stringValue(ruleActionId) && ruleActionId === requestedActionId) {\n\t\t\t// Exact match\n\t\t\tcovers = true;\n\t\t} else if (Is.object<IOdrlAction>(ruleAction)) {\n\t\t\t// includedIn: rule action A includedIn B means A is a sub-type of B.\n\t\t\t// A rule that names the narrower action A with includedIn B also covers requests for B.\n\t\t\tif (Is.stringValue(ruleAction.includedIn) && ruleAction.includedIn === requestedActionId) {\n\t\t\t\tcovers = true;\n\t\t\t}\n\n\t\t\t// implies: rule action A implies B means exercising A also entails B.\n\t\t\t// A rule granting A therefore also grants each implied action.\n\t\t\tif (!covers && (ruleAction.implies ?? []).includes(requestedActionId as OdrlActionType)) {\n\t\t\t\tcovers = true;\n\t\t\t}\n\t\t}\n\n\t\tif (!covers) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// If the action specifies refinements, all must be satisfied for the action to apply.\n\t\t// Refinements constrain the manner in which the action is exercised (e.g. print count <= 5).\n\t\tif (Is.object<IOdrlAction>(ruleAction) && Is.notEmpty(ruleAction.refinement)) {\n\t\t\tconst refinements = ArrayHelper.fromObjectOrArray<IOdrlConstraint | IOdrlLogicalConstraint>(\n\t\t\t\truleAction.refinement ?? []\n\t\t\t);\n\t\t\treturn refinements.every((refinement: IOdrlConstraint | IOdrlLogicalConstraint) =>\n\t\t\t\tthis.evaluateConstraint(refinement, dataSources)\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Apply a permission and create decisions based on that information.\n\t * @param agreementAssigner The assigner ID from the agreement.\n\t * @param agreementAssignee The assignee ID from the agreement.\n\t * @param policy The policy containing the permission.\n\t * @param permission The permission to apply.\n\t * @param targetRefinements Additional constraints from target refinement.\n\t * @param dataSources The operand lookup sources.\n\t * @returns True if the permission applies.\n\t * @internal\n\t */\n\tprivate async evaluatePermission(\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tpolicy: IDataspaceProtocolPolicy,\n\t\tpermission: IOdrlPermission,\n\t\ttargetRefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[],\n\t\tdataSources: { [prefix: string]: unknown },\n\t\taction?: OdrlActionType | string,\n\t\tdecisionTarget?: string\n\t): Promise<boolean> {\n\t\tif (\n\t\t\t!this.isRuleApplicableToParties(permission, agreementAssigner, agreementAssignee, dataSources)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check if the permission's action(s) match the requested action\n\t\tif (!this.isActionApplicable(permission.action, action, dataSources)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// ODRL semantics: a Permission without constraints is unconditional.\n\t\tconst constraints = [\n\t\t\t...ArrayHelper.fromObjectOrArray(permission.constraint ?? []),\n\t\t\t...targetRefinements\n\t\t];\n\t\tconst permissionTargetLookup = this.tryResolveTargetDataSource(\n\t\t\tthis.buildRuleDataContextTargetId(\n\t\t\t\tthis.getRuleDataContextTargetId(permission.target),\n\t\t\t\tdecisionTarget\n\t\t\t),\n\t\t\tdataSources,\n\t\t\ttrue\n\t\t);\n\t\tconst ruleDataContext = permissionTargetLookup.value;\n\t\tif (constraints.length === 0) {\n\t\t\treturn this.enforcePermissionDuties(policy, permission, dataSources, ruleDataContext);\n\t\t}\n\n\t\t// All constraints must be satisfied for the permission to apply.\n\t\tconst constraintsSatisfied = constraints.every(c => this.evaluateConstraint(c, dataSources));\n\n\t\tif (!constraintsSatisfied) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.enforcePermissionDuties(policy, permission, dataSources, ruleDataContext);\n\t}\n\n\t/**\n\t * Enforce duties attached to a permission.\n\t * @param policy The policy being evaluated.\n\t * @param permission The permission being evaluated.\n\t * @param dataSources The operand lookup sources.\n\t * @param ruleDataContext The target-scoped data context passed to enforcers.\n\t * @returns True if all duties are enforced or none are present.\n\t * @internal\n\t */\n\tprivate async enforcePermissionDuties(\n\t\tpolicy: IDataspaceProtocolPolicy,\n\t\tpermission: IOdrlPermission,\n\t\tdataSources: { [prefix: string]: unknown },\n\t\truleDataContext?: unknown\n\t): Promise<boolean> {\n\t\tconst duties = ArrayHelper.fromObjectOrArray(permission.duty ?? []);\n\t\tif (duties.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tfor (const duty of duties) {\n\t\t\tconst enforced = await this.enforceDuty(policy, duty, dataSources, ruleDataContext);\n\t\t\tif (!enforced) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Enforce a single duty using registered obligation enforcers.\n\t * @param policy The policy being evaluated.\n\t * @param duty The duty to enforce.\n\t * @param dataSources The operand lookup sources.\n\t * @param ruleDataContext The target-scoped data context passed to enforcers.\n\t * @returns True if any enforcer succeeds.\n\t * @internal\n\t */\n\tprivate async enforceDuty(\n\t\tpolicy: IDataspaceProtocolPolicy,\n\t\tduty: IOdrlDuty,\n\t\tdataSources: { [prefix: string]: unknown },\n\t\truleDataContext?: unknown\n\t): Promise<boolean> {\n\t\tconst enforcerNames = PolicyObligationEnforcerFactory.names();\n\t\tconst information = dataSources[\n\t\t\t`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_INFORMATION}`\n\t\t] as { [id: string]: IJsonLdNodeObject } | undefined;\n\n\t\tif (enforcerNames.length === 0) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"noObligationEnforcersRegistered\");\n\t\t}\n\n\t\tfor (const enforcerName of enforcerNames) {\n\t\t\tconst enforcer = PolicyObligationEnforcerFactory.get(enforcerName);\n\t\t\tif (await enforcer.enforce(policy, duty, information, ruleDataContext)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tconst consequences = ArrayHelper.fromObjectOrArray<IOdrlDuty>(duty.consequence ?? []);\n\t\tif (consequences.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const consequence of consequences) {\n\t\t\tif (!(await this.enforceDuty(policy, consequence, dataSources, ruleDataContext))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Resolve a target string to a matching datasource prefix and remaining target value.\n\t * @param targetId The target identifier to resolve.\n\t * @param dataSources The available lookup sources.\n\t * @param resolveValue True to resolve an item from the target path/key.\n\t * @returns The matching prefix, source, remaining target and optional resolved value.\n\t * @internal\n\t */\n\tprivate tryResolveTargetDataSource(\n\t\ttargetId: string | undefined,\n\t\tdataSources: { [prefix: string]: unknown },\n\t\tresolveValue: boolean = false\n\t): { prefix: string; source: unknown; target: string; value?: unknown } {\n\t\t// If there is no target id, default to the entire \"twin:jsonpath\" datasource\n\t\tif (Is.empty(targetId)) {\n\t\t\treturn {\n\t\t\t\tprefix: `${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}`,\n\t\t\t\tsource:\n\t\t\t\t\tdataSources[\n\t\t\t\t\t\t`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}`\n\t\t\t\t\t],\n\t\t\t\ttarget: \"$\",\n\t\t\t\tvalue:\n\t\t\t\t\tdataSources[\n\t\t\t\t\t\t`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}`\n\t\t\t\t\t]\n\t\t\t};\n\t\t}\n\n\t\t// Otherwise lookup the target id prefix in the datasources and return the remaining suffix as the target path/key\n\t\tconst prefixes = Object.keys(dataSources).sort((a, b) => b.length - a.length);\n\t\tfor (const prefix of prefixes) {\n\t\t\tif (targetId.startsWith(`${prefix}:`)) {\n\t\t\t\tconst source = dataSources[prefix];\n\t\t\t\tconst target = targetId.slice(prefix.length + 1);\n\n\t\t\t\tif (!target.startsWith(\"$\")) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"ruleTargetNotSupported\", {\n\t\t\t\t\t\ttarget: targetId\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (!resolveValue) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tprefix,\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\ttarget\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst matches = JsonPathHelper.query(target, source);\n\t\t\t\tif (matches.length === 0) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"ruleTargetNotSupported\", {\n\t\t\t\t\t\ttarget: targetId\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tprefix,\n\t\t\t\t\tsource,\n\t\t\t\t\ttarget,\n\t\t\t\t\tvalue: matches.length === 1 ? matches[0].value : matches.map(m => m.value)\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"ruleTargetNotSupported\", {\n\t\t\ttarget: targetId\n\t\t});\n\t}\n\n\t/**\n\t * Extract the target id from the permission.\n\t * @param target The permission target.\n\t * @returns The information key, or undefined when the target is not an information reference.\n\t * @internal\n\t */\n\tprivate getTargetId(target: IOdrlRule[\"target\"]): string | undefined {\n\t\tif (Is.undefined(target)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (Is.array(target) && target.length > 1) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"multipleTargetsNotSupported\");\n\t\t}\n\n\t\tconst arr = ArrayHelper.fromObjectOrArray(target ?? []);\n\t\tif (arr.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn Is.string(arr[0]) ? arr[0] : OdrlPolicyHelper.getUid(arr[0]);\n\t}\n\n\t/**\n\t * Resolve the target identifier used for rule data context lookup.\n\t * For AssetCollection targets the `source` property is used because the collection has no `uid`.\n\t * Falls back to `getTargetId` for all other target forms.\n\t * @param target The rule target field value.\n\t * @returns The prefixed target string for data context resolution.\n\t * @internal\n\t */\n\tprivate getRuleDataContextTargetId(target: IOdrlRule[\"target\"]): string | undefined {\n\t\tconst arr = ArrayHelper.fromObjectOrArray(target ?? []);\n\t\tif (arr.length === 1) {\n\t\t\tconst firstTarget = arr[0];\n\t\t\tif (\n\t\t\t\tIs.object<IOdrlAssetCollection>(firstTarget) &&\n\t\t\t\tOdrlPolicyHelper.getType(firstTarget) === OdrlTypes.AssetCollection &&\n\t\t\t\tIs.stringValue(firstTarget.source)\n\t\t\t) {\n\t\t\t\treturn firstTarget.source;\n\t\t\t}\n\t\t}\n\t\treturn this.getTargetId(target);\n\t}\n\n\t/**\n\t * Build a concrete prefixed target id for rule data-context lookup.\n\t * @param baseTargetId The original prefixed target id from the rule.\n\t * @param decisionTarget The concrete decision JSONPath target.\n\t * @returns The concrete prefixed target id.\n\t * @internal\n\t */\n\tprivate buildRuleDataContextTargetId(\n\t\tbaseTargetId: string | undefined,\n\t\tdecisionTarget: string | undefined\n\t): string | undefined {\n\t\tif (!Is.stringValue(decisionTarget) || decisionTarget === \"$\") {\n\t\t\treturn baseTargetId;\n\t\t}\n\n\t\tif (!Is.stringValue(baseTargetId)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst pathStartIndex = baseTargetId.indexOf(\":$\");\n\t\tif (pathStartIndex < 0) {\n\t\t\treturn baseTargetId;\n\t\t}\n\n\t\treturn `${baseTargetId.slice(0, pathStartIndex)}:${decisionTarget}`;\n\t}\n\n\t/**\n\t * Resolve a rule target into a policy-decision JSONPath target and extracted refinements.\n\t * For AssetCollection targets, `source` is treated as the decision target and `refinement`\n\t * constraints are applied as additional rule constraints.\n\t * @param rule The rule to resolve the target for.\n\t * @returns The decision target and target refinements.\n\t * @throws GeneralError if target is invalid or unsupported.\n\t * @internal\n\t */\n\tprivate resolveRuleTarget(\n\t\trule: IOdrlRule,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): {\n\t\ttarget: string;\n\t\trefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t} {\n\t\tconst arr = ArrayHelper.fromObjectOrArray(rule.target ?? []);\n\t\tif (arr.length === 0) {\n\t\t\treturn {\n\t\t\t\ttarget: \"$\",\n\t\t\t\trefinements: []\n\t\t\t};\n\t\t}\n\n\t\tif (arr.length > 1) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"multipleTargetsNotSupported\");\n\t\t}\n\n\t\tconst firstTarget = arr[0];\n\n\t\tif (Is.object<IOdrlAsset>(firstTarget)) {\n\t\t\t// Guard against unsupported ODRL asset properties\n\t\t\tif (Is.notEmpty(firstTarget.hasPolicy)) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"assetHasPolicyNotSupported\");\n\t\t\t}\n\t\t\tif (Is.notEmpty(firstTarget.partOf)) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"assetPartOfNotSupported\");\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tIs.object<IOdrlAssetCollection>(firstTarget) &&\n\t\t\t\tOdrlPolicyHelper.getType(firstTarget) === OdrlTypes.AssetCollection\n\t\t\t) {\n\t\t\t\tif (!Is.stringValue(firstTarget.source)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\t\t\t\t\"assetCollectionSourceNotSupported\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsource: firstTarget.source ?? \"\"\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tlet sourceLookup: { prefix: string; source: unknown; target: string; value?: unknown };\n\t\t\t\ttry {\n\t\t\t\t\tsourceLookup = this.tryResolveTargetDataSource(firstTarget.source, dataSources);\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\t\t\t\t\"assetCollectionSourceNotSupported\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsource: firstTarget.source\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\ttarget: sourceLookup.target,\n\t\t\t\t\trefinements: ArrayHelper.fromObjectOrArray(firstTarget.refinement ?? [])\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst targetId = Is.string(firstTarget) ? firstTarget : OdrlPolicyHelper.getUid(firstTarget);\n\t\tif (!Is.stringValue(targetId)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"ruleTargetNotSupported\", {\n\t\t\t\ttarget: \"\"\n\t\t\t});\n\t\t}\n\n\t\tconst targetLookup = this.tryResolveTargetDataSource(targetId, dataSources);\n\n\t\treturn {\n\t\t\ttarget: targetLookup.target,\n\t\t\trefinements: []\n\t\t};\n\t}\n\n\t/**\n\t * Resolve decision targets for a rule.\n\t * AssetCollection wildcard targets with refinements are expanded to per-item targets.\n\t * @param rule The rule being evaluated.\n\t * @param dataSources The operand lookup sources.\n\t * @returns The decision targets and scoped refinements.\n\t * @internal\n\t */\n\tprivate resolveRuleDecisionTargets(\n\t\trule: IOdrlRule,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): {\n\t\ttarget: string;\n\t\trefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t}[] {\n\t\tconst resolvedTarget = this.resolveRuleTarget(rule, dataSources);\n\n\t\tif (!this.shouldExpandToPerItemTargets(rule, resolvedTarget)) {\n\t\t\treturn [resolvedTarget];\n\t\t}\n\n\t\tconst sourceLookup = this.tryResolveTargetDataSource(\n\t\t\tthis.getRuleDataContextTargetId(rule.target),\n\t\t\tdataSources\n\t\t);\n\t\tconst matches = JsonPathHelper.query(sourceLookup.target, sourceLookup.source);\n\t\tif (matches.length === 0) {\n\t\t\treturn [resolvedTarget];\n\t\t}\n\n\t\treturn matches.map(match => {\n\t\t\tconst itemTarget = this.normalizeDecisionTargetPath(match.path ?? resolvedTarget.target);\n\t\t\treturn {\n\t\t\t\ttarget: itemTarget,\n\t\t\t\trefinements: resolvedTarget.refinements.map(refinement =>\n\t\t\t\t\tthis.rewriteRefinementForDecisionTarget(refinement, resolvedTarget.target, itemTarget)\n\t\t\t\t)\n\t\t\t};\n\t\t});\n\t}\n\n\t/**\n\t * Determine if a rule should be expanded to per-item targets.\n\t * @param rule The rule.\n\t * @param resolvedTarget The resolved target details.\n\t * @returns True if the rule should emit per-item decisions.\n\t * @internal\n\t */\n\tprivate shouldExpandToPerItemTargets(\n\t\trule: IOdrlRule,\n\t\tresolvedTarget: {\n\t\t\ttarget: string;\n\t\t\trefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t\t}\n\t): boolean {\n\t\tif (resolvedTarget.refinements.length === 0 || !resolvedTarget.target.includes(\"[*]\")) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst targets = ArrayHelper.fromObjectOrArray(rule.target ?? []);\n\t\tif (targets.length !== 1 || !Is.object<IOdrlAssetCollection>(targets[0])) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn OdrlPolicyHelper.getType(targets[0]) === OdrlTypes.AssetCollection;\n\t}\n\n\t/**\n\t * Rewrite a refinement so wildcard paths are scoped to a concrete item target.\n\t * @param refinement The refinement to rewrite.\n\t * @param sourceTarget The wildcard source target.\n\t * @param itemTarget The concrete item target.\n\t * @returns The rewritten refinement.\n\t * @internal\n\t */\n\tprivate rewriteRefinementForDecisionTarget(\n\t\trefinement: IOdrlConstraint | IOdrlLogicalConstraint,\n\t\tsourceTarget: string,\n\t\titemTarget: string\n\t): IOdrlConstraint | IOdrlLogicalConstraint {\n\t\tconst logicalConstraint = this.getLogicalConstraintOperands(refinement);\n\t\tif (logicalConstraint) {\n\t\t\treturn {\n\t\t\t\t...refinement,\n\t\t\t\t[logicalConstraint.operator]: logicalConstraint.constraints.map(item =>\n\t\t\t\t\tthis.rewriteRefinementForDecisionTarget(item, sourceTarget, itemTarget)\n\t\t\t\t)\n\t\t\t} as IOdrlLogicalConstraint;\n\t\t}\n\n\t\tconst regularConstraint = refinement as IOdrlConstraint;\n\t\treturn {\n\t\t\t...regularConstraint,\n\t\t\tleftOperand: this.rewriteOperandForDecisionTarget(\n\t\t\t\tregularConstraint.leftOperand,\n\t\t\t\tsourceTarget,\n\t\t\t\titemTarget\n\t\t\t) as IOdrlConstraint[\"leftOperand\"],\n\t\t\trightOperand: this.rewriteOperandForDecisionTarget(\n\t\t\t\tregularConstraint.rightOperand,\n\t\t\t\tsourceTarget,\n\t\t\t\titemTarget\n\t\t\t)\n\t\t};\n\t}\n\n\t/**\n\t * Rewrite JSONPath-based operands from wildcard source to concrete item target.\n\t * @param operand The operand to rewrite.\n\t * @param sourceTarget The wildcard source target.\n\t * @param itemTarget The concrete item target.\n\t * @returns The rewritten operand.\n\t * @internal\n\t */\n\tprivate rewriteOperandForDecisionTarget(\n\t\toperand: IOdrlConstraint[\"leftOperand\"] | IOdrlConstraint[\"rightOperand\"] | string,\n\t\tsourceTarget: string,\n\t\titemTarget: string\n\t): IOdrlConstraint[\"leftOperand\"] | IOdrlConstraint[\"rightOperand\"] | string {\n\t\tif (Is.stringValue(operand)) {\n\t\t\tconst prefix = `${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}:`;\n\t\t\tif (operand.startsWith(prefix)) {\n\t\t\t\tconst valuePath = operand.slice(prefix.length);\n\t\t\t\treturn `${prefix}${this.rewriteWildcardPath(valuePath, sourceTarget, itemTarget)}`;\n\t\t\t}\n\t\t\treturn operand;\n\t\t}\n\n\t\tif (Is.object<{ \"@type\": unknown; \"@value\": unknown }>(operand)) {\n\t\t\tconst typedOperand = { ...operand };\n\t\t\tif (\n\t\t\t\ttypedOperand[\"@type\"] ===\n\t\t\t\t\t`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}` &&\n\t\t\t\tIs.stringValue(typedOperand[\"@value\"])\n\t\t\t) {\n\t\t\t\ttypedOperand[\"@value\"] = this.rewriteWildcardPath(\n\t\t\t\t\ttypedOperand[\"@value\"],\n\t\t\t\t\tsourceTarget,\n\t\t\t\t\titemTarget\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn typedOperand;\n\t\t}\n\n\t\treturn operand;\n\t}\n\n\t/**\n\t * Rewrite wildcard source JSONPath segments to a concrete item JSONPath.\n\t * @param valuePath The operand path.\n\t * @param sourceTarget The wildcard source path.\n\t * @param itemTarget The concrete item path.\n\t * @returns The rewritten path.\n\t * @internal\n\t */\n\tprivate rewriteWildcardPath(valuePath: string, sourceTarget: string, itemTarget: string): string {\n\t\tif (!sourceTarget.includes(\"[*]\") || !valuePath.includes(\"[*]\")) {\n\t\t\treturn valuePath;\n\t\t}\n\n\t\tif (valuePath.startsWith(sourceTarget)) {\n\t\t\treturn `${itemTarget}${valuePath.slice(sourceTarget.length)}`;\n\t\t}\n\n\t\treturn valuePath;\n\t}\n\n\t/**\n\t * Normalize JSONPath strings to dot notation for stable decision targets.\n\t * @param path The JSONPath to normalize.\n\t * @returns The normalized path.\n\t * @internal\n\t */\n\tprivate normalizeDecisionTargetPath(path: string): string {\n\t\treturn path.replace(/\\['([^']+)']/g, \".$1\");\n\t}\n\n\t/**\n\t * Evaluate a single ODRL constraint against the available context.\n\t * Supports logical constraint composition through nested refinements.\n\t * @param constraint The constraint to evaluate.\n\t * @param dataSources The operand lookup sources.\n\t * @returns True if the constraint is satisfied.\n\t * @internal\n\t */\n\tprivate evaluateConstraint(\n\t\tconstraint: IOdrlConstraint | IOdrlLogicalConstraint,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): boolean {\n\t\tconst logicalConstraint = this.getLogicalConstraintOperands(constraint);\n\t\tif (logicalConstraint) {\n\t\t\treturn this.evaluateLogicalConstraint(logicalConstraint, dataSources);\n\t\t}\n\n\t\t// Must be a regular constraint beyond this point\n\t\tconst regularConstraint = constraint as IOdrlConstraint;\n\n\t\t// rightOperandReference is not supported — it requires an external IRI lookup that\n\t\t// is outside the scope of the local evaluation engine.\n\t\tif (Is.notEmpty(regularConstraint.rightOperandReference)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"rightOperandReferenceNotSupported\");\n\t\t}\n\n\t\t// dataType specifies how the rightOperand value should be coerced before comparison.\n\t\t// Without dataType-aware coercion logic the comparison may produce incorrect results.\n\t\tif (Is.notEmpty(regularConstraint.dataType)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"constraintDataTypeNotSupported\");\n\t\t}\n\n\t\t// unit specifies the measurement unit for the right operand (e.g. currency, length).\n\t\t// Unit-aware comparison is not implemented.\n\t\tif (Is.notEmpty(regularConstraint.unit)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"constraintUnitNotSupported\");\n\t\t}\n\n\t\t// status represents a state-based evaluation operand (e.g. odrl:policyUsage).\n\t\t// State-based evaluation is not implemented.\n\t\tif (Is.notEmpty(regularConstraint.status)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"constraintStatusNotSupported\");\n\t\t}\n\n\t\t// Evaluate the main constraint condition\n\t\tconst leftValue = this.calculateOperandValue(regularConstraint.leftOperand, dataSources);\n\t\tconst rightValue = this.calculateOperandValue(regularConstraint.rightOperand, dataSources);\n\t\tconst mainSatisfied = this.evaluateOperator(regularConstraint.operator, leftValue, rightValue);\n\n\t\t// If main constraint is not satisfied, the overall constraint fails\n\t\treturn mainSatisfied;\n\t}\n\n\t/**\n\t * Extract logical constraint operands when present.\n\t * @param constraint The constraint to inspect.\n\t * @returns The logical operator and its operands, or undefined when not logical.\n\t * @throws GeneralError if logical constraint operands are not unique.\n\t * @internal\n\t */\n\tprivate getLogicalConstraintOperands(constraint: IOdrlConstraint | IOdrlLogicalConstraint):\n\t\t| {\n\t\t\t\toperator: OdrlLogicalConstraintType;\n\t\t\t\tconstraints: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t\t }\n\t\t| undefined {\n\t\tconst logicalConstraint = constraint as IOdrlLogicalConstraint;\n\t\tconst operators: OdrlLogicalConstraintType[] = Object.values(OdrlLogicalConstraintType);\n\t\tfor (const operator of operators) {\n\t\t\tconst value = logicalConstraint[operator];\n\t\t\tif (!Is.undefined(value)) {\n\t\t\t\tconst constraints = this.normalizeLogicalConstraintOperands(value);\n\t\t\t\tthis.validateLogicalConstraintOperandUniqueness(constraints, operator);\n\t\t\t\treturn {\n\t\t\t\t\toperator,\n\t\t\t\t\tconstraints\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Normalize logical constraint operands into a constraint array.\n\t * Handles both IOdrlConstraint and IOdrlLogicalConstraint types.\n\t * @param raw The raw operand value.\n\t * @returns The constraint array.\n\t * @internal\n\t */\n\tprivate normalizeLogicalConstraintOperands(\n\t\traw: unknown\n\t): (IOdrlConstraint | IOdrlLogicalConstraint)[] {\n\t\tlet normalized = raw;\n\t\tif (\n\t\t\tIs.object<IOdrlLogicalConstraintOperand>(normalized) &&\n\t\t\t!Is.undefined(normalized[\"@list\"])\n\t\t) {\n\t\t\tnormalized = normalized[\"@list\"];\n\t\t}\n\n\t\treturn (ArrayHelper.fromObjectOrArray(normalized) ?? [])\n\t\t\t.filter(item => Is.object(item))\n\t\t\t.map(item => item as IOdrlConstraint | IOdrlLogicalConstraint);\n\t}\n\n\t/**\n\t * Validate that all operands in a logical constraint are unique.\n\t * ODRL spec 2.5.2 requires that all operand values MUST be unique Constraint instances.\n\t * Uniqueness is checked by uid property and id property.\n\t * @param constraints The constraint operands to validate.\n\t * @param operator The logical operator type (for error messaging).\n\t * @throws GeneralError if duplicate constraints are found.\n\t * @internal\n\t */\n\tprivate validateLogicalConstraintOperandUniqueness(\n\t\tconstraints: (IOdrlConstraint | IOdrlLogicalConstraint)[],\n\t\toperator: OdrlLogicalConstraintType\n\t): void {\n\t\tconst seenIdentifiers = new Set<string>();\n\n\t\tfor (let i = 0; i < constraints.length; i++) {\n\t\t\tconst constraint = constraints[i];\n\t\t\tconst identifier = OdrlPolicyHelper.getUid(constraint);\n\n\t\t\t// If we have an identifier, check for duplicates\n\t\t\tif (Is.stringValue(identifier)) {\n\t\t\t\tif (seenIdentifiers.has(identifier)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\t\t\t\t\"logicalConstraintOperandNotUnique\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toperator,\n\t\t\t\t\t\t\tidentifier,\n\t\t\t\t\t\t\tindex: i\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tseenIdentifiers.add(identifier);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Evaluate a logical constraint operator against its operands.\n\t * @param logicalConstraint The operator and operand list.\n\t * @param dataSources The operand lookup sources.\n\t * @returns True if the logical constraint is satisfied.\n\t * @internal\n\t */\n\tprivate evaluateLogicalConstraint(\n\t\tlogicalConstraint: {\n\t\t\toperator: OdrlLogicalConstraintType;\n\t\t\tconstraints: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t\t},\n\t\tdataSources: { [prefix: string]: unknown }\n\t): boolean {\n\t\tconst { operator, constraints } = logicalConstraint;\n\t\tif (constraints.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tswitch (operator) {\n\t\t\tcase OdrlLogicalConstraintType.And:\n\t\t\t\treturn constraints.every(item => this.evaluateConstraint(item, dataSources));\n\t\t\tcase OdrlLogicalConstraintType.AndSequence: {\n\t\t\t\tfor (const item of constraints) {\n\t\t\t\t\tif (!this.evaluateConstraint(item, dataSources)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tcase OdrlLogicalConstraintType.Or:\n\t\t\t\treturn constraints.some(item => this.evaluateConstraint(item, dataSources));\n\t\t\tcase OdrlLogicalConstraintType.Xone: {\n\t\t\t\tlet satisfied = 0;\n\t\t\t\tfor (const item of constraints) {\n\t\t\t\t\tif (this.evaluateConstraint(item, dataSources)) {\n\t\t\t\t\t\tsatisfied += 1;\n\t\t\t\t\t\tif (satisfied > 1) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn satisfied === 1;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Resolve a prefixed operand to its source object and JSONPath expression.\n\t * Prefix matching is dictionary-driven so additional operand namespaces can be\n\t * added in one place by extending the lookup sources map.\n\t * @param operandTypeOrValue The string operand value or typed operand namespace.\n\t * @param operandValue The JSONPath expression.\n\t * @param dataSources The available lookup sources.\n\t * @returns The resolved source and JSONPath, or undefined when not namespaced.\n\t * @throws GeneralError if a twin: prefixed operand doesn't resolve to any available datasource key.\n\t * @internal\n\t */\n\tprivate tryResolveOperandLookup(\n\t\toperandTypeOrValue: string,\n\t\toperandValue: unknown,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): { source: unknown; jsonPath: string } | undefined {\n\t\tlet lookupTargetId: string | undefined;\n\n\t\tif (dataSources[operandTypeOrValue]) {\n\t\t\tif (!Is.stringValue(operandValue)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tlookupTargetId = `${operandTypeOrValue}:${operandValue}`;\n\t\t} else if (operandTypeOrValue.includes(\":\")) {\n\t\t\tlookupTargetId = operandTypeOrValue;\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Delegate prefixed path matching to shared datasource resolver\n\t\tif (operandTypeOrValue.startsWith(DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS)) {\n\t\t\tconst resolved = this.tryResolveTargetDataSource(lookupTargetId, dataSources);\n\t\t\treturn {\n\t\t\t\tsource: resolved.source,\n\t\t\t\tjsonPath: resolved.target\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Calculate an operand value.\n\t * @param operand The operand.\n\t * @param dataSources The available prefixed operand sources.\n\t * @returns The resolved operand value.\n\t * @internal\n\t */\n\tprivate calculateOperandValue(\n\t\toperand: IOdrlConstraint[\"leftOperand\"] | IOdrlConstraint[\"rightOperand\"] | string,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): unknown {\n\t\t// Treat prefixed operands as selectors against a namespaced source dictionary.\n\t\t// Examples: twin:jsonpath:$.field, twin:information:$.credentials.level\n\t\tlet jsonPath: string | undefined;\n\t\tlet operandRoot: unknown;\n\t\tif (Is.stringValue(operand)) {\n\t\t\tconst lookup = this.tryResolveOperandLookup(operand, operand, dataSources);\n\t\t\tif (lookup) {\n\t\t\t\tjsonPath = lookup.jsonPath;\n\t\t\t\toperandRoot = lookup.source;\n\t\t\t}\n\t\t} else if (Is.object<{ \"@type\": unknown; \"@value\": unknown }>(operand)) {\n\t\t\t// Is this an object { \"@value\": \"18\", \"@type\": \"xsd:integer\" } ?\n\t\t\tconst value = operand[\"@value\"];\n\t\t\tconst type = operand[\"@type\"];\n\t\t\tif (Is.stringValue(type)) {\n\t\t\t\tconst lookup = this.tryResolveOperandLookup(type, value, dataSources);\n\t\t\t\tif (lookup) {\n\t\t\t\t\tjsonPath = lookup.jsonPath;\n\t\t\t\t\toperandRoot = lookup.source;\n\t\t\t\t} else {\n\t\t\t\t\tconst xsdValue = this.coerceXsdType(value, type);\n\t\t\t\t\tif (!Is.undefined(xsdValue)) {\n\t\t\t\t\t\treturn xsdValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// We have a JSON Path to resolve\n\t\tif (Is.stringValue(jsonPath)) {\n\t\t\tconst jsonPaths = JsonPathHelper.query(jsonPath, operandRoot);\n\t\t\tif (jsonPaths.length === 0) {\n\t\t\t\t// No matches\n\t\t\t\treturn undefined;\n\t\t\t} else if (jsonPaths.length === 1) {\n\t\t\t\t// Single match - return the value directly\n\t\t\t\treturn jsonPaths[0].value;\n\t\t\t}\n\n\t\t\t// Multiple matches - return array of values\n\t\t\treturn jsonPaths.map(p => p.value);\n\t\t}\n\n\t\t// Not JSON Path or object value so return as is\n\t\treturn operand;\n\t}\n\n\t/**\n\t * Evaluate an ODRL operator against resolved operands.\n\t * @param operator The operator.\n\t * @param left The resolved left operand.\n\t * @param right The resolved right operand.\n\t * @returns True if the comparison is satisfied.\n\t * @internal\n\t */\n\tprivate evaluateOperator(operator: OdrlOperatorType, left: unknown, right: unknown): boolean {\n\t\t// Handle array/collection left values (e.g. JSONPath returning multiple matches).\n\t\tconst leftValues = ArrayHelper.fromObjectOrArray(left ?? []);\n\n\t\tswitch (operator) {\n\t\t\tcase OdrlOperatorType.Eq:\n\t\t\t\treturn leftValues.some(v => ObjectHelper.equal(v, right, false));\n\t\t\tcase OdrlOperatorType.Neq:\n\t\t\t\treturn leftValues.every(v => !ObjectHelper.equal(v, right, false));\n\t\t\tcase OdrlOperatorType.Gt:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a > b));\n\t\t\tcase OdrlOperatorType.Gteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a >= b));\n\t\t\tcase OdrlOperatorType.Lt:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a < b));\n\t\t\tcase OdrlOperatorType.Lteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a <= b));\n\t\t\tcase OdrlOperatorType.IsAnyOf: {\n\t\t\t\treturn leftValues.some(v => {\n\t\t\t\t\tconst stringValue =\n\t\t\t\t\t\ttypeof v === \"string\" || typeof v === \"number\" || typeof v === \"boolean\"\n\t\t\t\t\t\t\t? String(v)\n\t\t\t\t\t\t\t: JSON.stringify(v);\n\t\t\t\t\treturn (ArrayHelper.fromObjectOrArray(right) ?? []).includes(stringValue);\n\t\t\t\t});\n\t\t\t}\n\t\t\tcase OdrlOperatorType.IsAllOf: {\n\t\t\t\treturn ObjectHelper.equal(leftValues, ArrayHelper.fromObjectOrArray(right) ?? [], false);\n\t\t\t}\n\t\t\tcase OdrlOperatorType.IsNoneOf: {\n\t\t\t\treturn leftValues.every(v => !(ArrayHelper.fromObjectOrArray(right) ?? []).includes(v));\n\t\t\t}\n\t\t\tcase OdrlOperatorType.LocTimeEq:\n\t\t\t\treturn leftValues.some(v => ObjectHelper.equal(v, right, false));\n\t\t\tcase OdrlOperatorType.LocTimeGteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a >= b));\n\t\t\tcase OdrlOperatorType.IsA:\n\t\t\tcase OdrlOperatorType.HasPart:\n\t\t\tcase OdrlOperatorType.IsPartOf:\n\t\t\t\t// For now, treat these as simple equality/ordering semantics where meaningful.\n\t\t\t\t// Profiles can introduce richer semantics via additional arbiters.\n\t\t\t\treturn leftValues.some(v => ObjectHelper.equal(v, right, false));\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Compare values with numeric/date/string coercion.\n\t * @param left The left value.\n\t * @param right The right value.\n\t * @param compare Comparison operator.\n\t * @returns True if ordered comparison passes.\n\t * @internal\n\t */\n\tprivate compareOrdered(\n\t\tleft: unknown,\n\t\tright: unknown,\n\t\tcompare: (a: number, b: number) => boolean\n\t): boolean {\n\t\tconst leftNum = Coerce.number(left);\n\t\tconst rightNum = Coerce.number(right);\n\t\tif (!Is.undefined(leftNum) && !Is.undefined(rightNum)) {\n\t\t\treturn compare(leftNum, rightNum);\n\t\t}\n\t\tconst leftDate = Coerce.dateTime(left);\n\t\tconst rightDate = Coerce.dateTime(right);\n\t\tif (!Is.undefined(leftDate) && !Is.undefined(rightDate)) {\n\t\t\treturn compare(leftDate.getTime(), rightDate.getTime());\n\t\t}\n\n\t\t// Only use string ordering when both operands are actual strings.\n\t\t// Avoid coercing other types into strings, as that can cause\n\t\t// unintended comparisons like 18 >= \"$.minAge\" evaluating to true.\n\t\tif (Is.string(left) && Is.string(right)) {\n\t\t\treturn compare(left.localeCompare(right), 0);\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Coerce a value to a specific XSD type.\n\t * @param value The value to coerce.\n\t * @param type The XSD type.\n\t * @returns The coerced value, or undefined when coercion is not possible.\n\t * @internal\n\t */\n\tprivate coerceXsdType(value: unknown, type: string): unknown {\n\t\tif (\n\t\t\t[\n\t\t\t\t\"xsd:string\",\n\t\t\t\t\"xsd:normalizedString\",\n\t\t\t\t\"xsd:token\",\n\t\t\t\t\"xsd:anyURI\",\n\t\t\t\t\"xsd:QName\",\n\t\t\t\t\"xsd:NOTATION\"\n\t\t\t].includes(type)\n\t\t) {\n\t\t\t// Handle standard xsd types\n\t\t\treturn Coerce.string(value);\n\t\t} else if (\n\t\t\t[\n\t\t\t\t\"xsd:integer\",\n\t\t\t\t\"xsd:decimal\",\n\t\t\t\t\"xsd:float\",\n\t\t\t\t\"xsd:double\",\n\t\t\t\t\"xsd:long\",\n\t\t\t\t\"xsd:int\",\n\t\t\t\t\"xsd:short\",\n\t\t\t\t\"xsd:byte\"\n\t\t\t].includes(type)\n\t\t) {\n\t\t\t// Handle standard xsd types\n\t\t\treturn Coerce.number(value);\n\t\t} else if (type === \"xsd:boolean\") {\n\t\t\t// Handle standard xsd types\n\t\t\treturn Coerce.boolean(value);\n\t\t} else if ([\"xsd:date\", \"xsd:dateTime\", \"xsd:time\"].includes(type)) {\n\t\t\t// Handle standard xsd types\n\t\t\treturn Coerce.dateTime(value);\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"defaultPolicyArbiter.js","sourceRoot":"","sources":["../../../src/policyArbiters/defaultPolicyArbiter.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,MAAM,EACN,EAAE,EACF,YAAY,EACZ,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EACN,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,+BAA+B,EAK/B,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAEN,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,SAAS,EAaT,MAAM,8BAA8B,CAAC;AAGtC;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAChC;;OAEG;IACI,MAAM,CAAU,UAAU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YACpE,4BAA4B;YAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tArrayHelper,\n\tCoerce,\n\tComponentFactory,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tObjectHelper,\n\tStringHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { JsonPathHelper } from \"@twin.org/data-json-path\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\tOdrlProfiles,\n\tPolicyDecision,\n\tPolicyObligationEnforcerFactory,\n\ttype IPolicyAdministrationPointComponent,\n\ttype IPolicyArbiter,\n\ttype IPolicyDecision,\n\ttype IRightsManagementPolicy\n} from \"@twin.org/rights-management-models\";\nimport type { IDataspaceProtocolAgreement } from \"@twin.org/standards-dataspace-protocol\";\nimport {\n\ttype IOdrlAssetCollection,\n\tOdrlConflictStrategyType,\n\tOdrlLogicalConstraintType,\n\tOdrlOperatorType,\n\tOdrlTypes,\n\ttype IOdrlAction,\n\ttype IOdrlAsset,\n\ttype IOdrlConstraint,\n\ttype IOdrlDuty,\n\ttype IOdrlLogicalConstraint,\n\ttype IOdrlLogicalConstraintOperand,\n\ttype IOdrlParty,\n\ttype IOdrlPartyCollection,\n\ttype IOdrlPermission,\n\ttype IOdrlProhibition,\n\ttype IOdrlRule,\n\ttype OdrlActionType\n} from \"@twin.org/standards-w3c-odrl\";\nimport type { IDefaultPolicyArbiterConstructorOptions } from \"../models/IDefaultPolicyArbiterConstructorOptions.js\";\n\n/**\n * Default Policy Arbiter.\n */\nexport class DefaultPolicyArbiter implements IPolicyArbiter {\n\t/**\n\t * The class name of the Default Policy Arbiter.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DefaultPolicyArbiter>();\n\n\t/**\n\t * ODRL profiles whose custom vocabulary this arbiter understands and supports.\n\t * Any policy declaring a profile not in this set will be rejected.\n\t * Add a new entry here when support for an additional profile is implemented.\n\t */\n\tpublic static readonly SUPPORTED_PROFILES: ReadonlySet<string> = new Set([OdrlProfiles.Twin]);\n\n\t/**\n\t * Default maximum inheritance depth.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_MAX_INHERITANCE_DEPTH = 10;\n\n\t/**\n\t * TWIN prefix operations.\n\t * @internal\n\t */\n\tprivate static readonly _TWIN_PREFIX_OPERATIONS = \"twin:\";\n\n\t/**\n\t * TWIN prefix JSONPath.\n\t * @internal\n\t */\n\tprivate static readonly _TWIN_PREFIX_JSONPATH = \"jsonpath\";\n\n\t/**\n\t * TWIN prefix information.\n\t * @internal\n\t */\n\tprivate static readonly _TWIN_PREFIX_INFORMATION = \"information\";\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging: ILoggingComponent;\n\n\t/**\n\t * The policy administration point component.\n\t * @internal\n\t */\n\tprivate readonly _policyAdministrationPoint: IPolicyAdministrationPointComponent;\n\n\t/**\n\t * The maximum depth to traverse when resolving inherited policies.\n\t * @internal\n\t */\n\tprivate readonly _maxInheritanceDepth: number;\n\n\t/**\n\t * Create a new instance of DefaultPolicyArbiter.\n\t * @param options The options for the default policy arbiter.\n\t */\n\tconstructor(options?: IDefaultPolicyArbiterConstructorOptions) {\n\t\tthis._logging = ComponentFactory.get<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\n\t\tthis._policyAdministrationPoint = ComponentFactory.get<IPolicyAdministrationPointComponent>(\n\t\t\toptions?.policyAdministrationPointComponentType ?? \"policy-administration-point\"\n\t\t);\n\n\t\tthis._maxInheritanceDepth =\n\t\t\tCoerce.integer(options?.config?.maxInheritanceDepth) ??\n\t\t\tDefaultPolicyArbiter._DEFAULT_MAX_INHERITANCE_DEPTH;\n\t}\n\n\t/**\n\t * Normalises a profile IRI for comparison against the supported-profiles allowlist.\n\t * Per RFC 3986: scheme and host are case-insensitive (the URL constructor folds them to\n\t * lowercase automatically); a trailing slash on the terminal path segment is treated as\n\t * equivalent to its absence; repeated slashes in the path are collapsed to a single slash.\n\t * Non-URL strings are returned unchanged.\n\t * @param iri The IRI to normalise.\n\t * @returns The normalised IRI.\n\t * @internal\n\t */\n\tprivate static normalizeProfileIri(iri: string): string {\n\t\ttry {\n\t\t\tconst url = new URL(iri);\n\t\t\tconst pathname = url.pathname.replace(/\\/+/g, \"/\");\n\t\t\treturn `${url.protocol}//${url.host}${StringHelper.trimTrailingSlashes(pathname)}`;\n\t\t} catch {\n\t\t\treturn iri;\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 DefaultPolicyArbiter.CLASS_NAME;\n\t}\n\n\t/**\n\t * Makes decisions regarding policy access to data.\n\t * @param agreement The agreement to evaluate.\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 arbiter will evaluate all actions in the agreement.\n\t * @returns The decisions about access to the data.\n\t */\n\tpublic async decide<D = unknown>(\n\t\tagreement: IDataspaceProtocolAgreement,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: D,\n\t\taction?: OdrlActionType | string\n\t): Promise<IPolicyDecision[]> {\n\t\tGuards.object<IDataspaceProtocolAgreement>(\n\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\n\t\t// ODRL policy profiles extend the vocabulary with additional semantics (e.g. custom\n\t\t// operators, left operands). Without profile-aware evaluation logic the arbiter\n\t\t// cannot guarantee correctness, so any policy that declares an unknown profile is\n\t\t// rejected. The TWIN platform profile is explicitly supported.\n\t\t//\n\t\t// Empty-string profile values (e.g. from over-eager schema defaults or serialization\n\t\t// round-trips) are treated as \"no profile declared\" and filtered out before comparison.\n\t\t//\n\t\t// Profile IRIs are normalized before lookup: scheme and host are case-folded to\n\t\t// lowercase and a trailing slash on the last path segment is stripped. This accepts\n\t\t// common IRI variants (HTTPS://, uppercase host, trailing slash) instead of silently\n\t\t// rejecting valid policies authored by IRI-aware tooling.\n\t\t//\n\t\t// `every` (conjunction) is intentional: a policy declaring [\"TWIN\", \"unknown\"] is\n\t\t// rejected — the arbiter refuses to evaluate rules from a profile whose semantics it\n\t\t// does not understand, even if other declared profiles are known.\n\t\tconst declaredProfiles = ArrayHelper.fromObjectOrArray<string>(agreement.profile ?? [])\n\t\t\t.filter(p => Is.stringValue(p))\n\t\t\t.map(p => DefaultPolicyArbiter.normalizeProfileIri(p));\n\t\tif (\n\t\t\tIs.arrayValue(declaredProfiles) &&\n\t\t\t!declaredProfiles.every(p => DefaultPolicyArbiter.SUPPORTED_PROFILES.has(p))\n\t\t) {\n\t\t\tconst unsupportedProfile = declaredProfiles.find(\n\t\t\t\tp => !DefaultPolicyArbiter.SUPPORTED_PROFILES.has(p)\n\t\t\t);\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"policyProfileNotSupported\", {\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(agreement) ?? \"\",\n\t\t\t\tunsupportedProfile\n\t\t\t});\n\t\t}\n\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DefaultPolicyArbiter.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"decidingPolicy\",\n\t\t\tdata: {\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\t// Resolve and merge inherited policies.\n\t\tconst mergedPolicy = await this.mergeInheritedPolicies(agreement);\n\t\tconst expandedPolicy = this.expandCompactPolicyRules(mergedPolicy);\n\t\tconst dataSources = {\n\t\t\t[`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}`]:\n\t\t\t\tdata,\n\t\t\t[`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_INFORMATION}`]:\n\t\t\t\tinformation\n\t\t};\n\n\t\t// Extract agreement parties once for use in rule evaluation\n\t\tconst agreementAssigner = OdrlPolicyHelper.getPartyIds(agreement.assigner);\n\t\tconst agreementAssignee = OdrlPolicyHelper.getPartyIds(agreement.assignee);\n\t\tconst obligationsFulfilled = await this.evaluatePolicyObligations(\n\t\t\tagreementAssigner,\n\t\t\tagreementAssignee,\n\t\t\texpandedPolicy,\n\t\t\tdataSources\n\t\t);\n\n\t\t// ODRL-style rule evaluation grouped by decision target:\n\t\t// - Permission rules authorize if ANY applicable permission on the same target matches.\n\t\t// - Default to denied when no permission applies on a target (closed-world for access control).\n\t\t// - Conflict strategy controls how applicable permissions/prohibitions are resolved per target.\n\t\tconst targetStates: {\n\t\t\t[target: string]: {\n\t\t\t\tpermissionApplies: boolean;\n\t\t\t\tprohibitionApplies: boolean;\n\t\t\t};\n\t\t} = Object.create(null) as {\n\t\t\t[target: string]: {\n\t\t\t\tpermissionApplies: boolean;\n\t\t\t\tprohibitionApplies: boolean;\n\t\t\t};\n\t\t};\n\n\t\tconst permissions = ArrayHelper.fromObjectOrArray(expandedPolicy.permission ?? []);\n\t\tfor (const permission of permissions) {\n\t\t\tconst decisionTargets = this.resolveRuleDecisionTargets(permission, dataSources);\n\t\t\tfor (const decisionTarget of decisionTargets) {\n\t\t\t\tconst state = this.getOrCreateTargetState(targetStates, decisionTarget.target);\n\t\t\t\tif (\n\t\t\t\t\tawait this.evaluatePermission(\n\t\t\t\t\t\tagreementAssigner,\n\t\t\t\t\t\tagreementAssignee,\n\t\t\t\t\t\texpandedPolicy,\n\t\t\t\t\t\tpermission,\n\t\t\t\t\t\tdecisionTarget.refinements,\n\t\t\t\t\t\tdataSources,\n\t\t\t\t\t\taction,\n\t\t\t\t\t\tdecisionTarget.target\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tstate.permissionApplies = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst prohibitions = ArrayHelper.fromObjectOrArray<IOdrlProhibition>(\n\t\t\texpandedPolicy.prohibition ?? []\n\t\t);\n\t\tfor (const prohibition of prohibitions) {\n\t\t\tconst decisionTargets = this.resolveRuleDecisionTargets(prohibition, dataSources);\n\t\t\tfor (const decisionTarget of decisionTargets) {\n\t\t\t\tif (\n\t\t\t\t\tawait this.evaluateProhibition(\n\t\t\t\t\t\texpandedPolicy,\n\t\t\t\t\t\tagreementAssigner,\n\t\t\t\t\t\tagreementAssignee,\n\t\t\t\t\t\tprohibition,\n\t\t\t\t\t\tdecisionTarget.refinements,\n\t\t\t\t\t\tdataSources,\n\t\t\t\t\t\taction,\n\t\t\t\t\t\tdecisionTarget.target\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tconst state = this.getOrCreateTargetState(targetStates, decisionTarget.target);\n\t\t\t\t\tstate.prohibitionApplies = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst conflictStrategy = expandedPolicy.conflict ?? OdrlConflictStrategyType.Invalid;\n\t\tif (Object.keys(targetStates).length === 0) {\n\t\t\t// Closed-world fallback when the policy has no rules at all.\n\t\t\treturn [{ decision: PolicyDecision.Denied, target: \"$\" }];\n\t\t}\n\n\t\tconst decisions: IPolicyDecision[] = [];\n\t\tfor (const [target, state] of Object.entries(targetStates)) {\n\t\t\tlet decision: PolicyDecision;\n\t\t\tif (state.permissionApplies && state.prohibitionApplies) {\n\t\t\t\tswitch (conflictStrategy) {\n\t\t\t\t\tcase OdrlConflictStrategyType.Perm:\n\t\t\t\t\t\tdecision = PolicyDecision.Granted;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase OdrlConflictStrategyType.Prohibit:\n\t\t\t\t\tcase OdrlConflictStrategyType.Invalid:\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tdecision = PolicyDecision.Denied;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdecision = state.permissionApplies ? PolicyDecision.Granted : PolicyDecision.Denied;\n\t\t\t}\n\n\t\t\tif (!obligationsFulfilled) {\n\t\t\t\tdecision = PolicyDecision.Denied;\n\t\t\t}\n\n\t\t\tdecisions.push({\n\t\t\t\tdecision,\n\t\t\t\ttarget\n\t\t\t});\n\t\t}\n\n\t\treturn decisions;\n\t}\n\n\t/**\n\t * Expand compact/compound policy rule forms into atomic rules.\n\t * ODRL 2.7 allows compact forms where rule properties can be arrays.\n\t * Evaluation in this arbiter is performed on expanded atomic rules.\n\t * @param policy The policy to expand.\n\t * @returns A policy with expanded rule arrays.\n\t * @internal\n\t */\n\tprivate expandCompactPolicyRules(policy: IRightsManagementPolicy): IRightsManagementPolicy {\n\t\tconst expandedPermissions = this.expandRules(\n\t\t\tArrayHelper.fromObjectOrArray<IOdrlPermission>(policy.permission ?? [])\n\t\t);\n\t\tconst expandedProhibitions = this.expandRules(\n\t\t\tArrayHelper.fromObjectOrArray<IOdrlProhibition>(policy.prohibition ?? [])\n\t\t);\n\t\tconst expandedObligations = this.expandRules(\n\t\t\tArrayHelper.fromObjectOrArray<IOdrlDuty>(policy.obligation ?? [])\n\t\t);\n\n\t\treturn {\n\t\t\t...policy,\n\t\t\tpermission: expandedPermissions.length > 0 ? expandedPermissions : undefined,\n\t\t\tprohibition: expandedProhibitions.length > 0 ? expandedProhibitions : undefined,\n\t\t\tobligation: expandedObligations.length > 0 ? expandedObligations : undefined\n\t\t};\n\t}\n\n\t/**\n\t * Expand a rule list into atomic rules.\n\t * @param rules The rules to expand.\n\t * @returns Expanded atomic rules.\n\t * @internal\n\t */\n\tprivate expandRules<T extends IOdrlRule>(rules: T[]): T[] {\n\t\tconst expanded: T[] = [];\n\t\tfor (const rule of rules) {\n\t\t\texpanded.push(...this.expandRule(rule));\n\t\t}\n\n\t\treturn expanded;\n\t}\n\n\t/**\n\t * Expand a single compact/compound rule into atomic rules.\n\t * @param rule The rule to expand.\n\t * @returns Expanded atomic rules.\n\t * @internal\n\t */\n\tprivate expandRule<T extends IOdrlRule>(rule: T): T[] {\n\t\tconst targets = this.normalizeRuleField<NonNullable<IOdrlRule[\"target\"]>>(rule.target);\n\t\tconst actions = this.normalizeRuleField<NonNullable<IOdrlRule[\"action\"]>>(rule.action);\n\t\tconst assigners = this.normalizeRuleField<NonNullable<IOdrlRule[\"assigner\"]>>(rule.assigner);\n\t\tconst assignees = this.normalizeRuleField<NonNullable<IOdrlRule[\"assignee\"]>>(rule.assignee);\n\n\t\tconst expanded: T[] = [];\n\t\tfor (const target of targets) {\n\t\t\tfor (const action of actions) {\n\t\t\t\tfor (const assigner of assigners) {\n\t\t\t\t\tfor (const assignee of assignees) {\n\t\t\t\t\t\tconst atomicRule = { ...rule };\n\t\t\t\t\t\tatomicRule.target = target;\n\t\t\t\t\t\tatomicRule.action = action;\n\t\t\t\t\t\tatomicRule.assigner = assigner;\n\t\t\t\t\t\tatomicRule.assignee = assignee;\n\t\t\t\t\t\texpanded.push(atomicRule);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn expanded;\n\t}\n\n\t/**\n\t * Normalize a potentially compact rule field into an array for expansion.\n\t * @param value The field value.\n\t * @returns Normalized values (or a single undefined when not provided).\n\t * @internal\n\t */\n\tprivate normalizeRuleField<T>(value: T | undefined): (T | undefined)[] {\n\t\tif (Is.undefined(value)) {\n\t\t\treturn [undefined];\n\t\t}\n\n\t\tconst values = ArrayHelper.fromObjectOrArray(value);\n\t\treturn values.length > 0 ? values : [undefined];\n\t}\n\n\t/**\n\t * Get an existing target state or create an initial state if it doesn't exist.\n\t * @param targetStates The dictionary of target states.\n\t * @param target The target key.\n\t * @returns The target state.\n\t * @internal\n\t */\n\tprivate getOrCreateTargetState(\n\t\ttargetStates: {\n\t\t\t[target: string]: {\n\t\t\t\tpermissionApplies: boolean;\n\t\t\t\tprohibitionApplies: boolean;\n\t\t\t};\n\t\t},\n\t\ttarget: string\n\t): {\n\t\tpermissionApplies: boolean;\n\t\tprohibitionApplies: boolean;\n\t} {\n\t\tlet state = targetStates[target];\n\t\tif (Is.undefined(state)) {\n\t\t\tstate = {\n\t\t\t\tpermissionApplies: false,\n\t\t\t\tprohibitionApplies: false\n\t\t\t};\n\t\t\ttargetStates[target] = state;\n\t\t}\n\n\t\treturn state;\n\t}\n\n\t/**\n\t * Evaluate whether a prohibition applies.\n\t * @param policy The policy containing the prohibition.\n\t * @param agreementAssigner The assigner ID from the agreement.\n\t * @param agreementAssignee The assignee ID from the agreement.\n\t * @param prohibition The prohibition to evaluate.\n\t * @param targetRefinements Additional constraints from target refinement.\n\t * @param dataSources The operand lookup sources.\n\t * @param action Optional action to check against the prohibition's applicable actions.\n\t * @returns True if the prohibition applies.\n\t * @internal\n\t */\n\tprivate async evaluateProhibition(\n\t\tpolicy: IRightsManagementPolicy,\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tprohibition: IOdrlProhibition,\n\t\ttargetRefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[],\n\t\tdataSources: { [prefix: string]: unknown },\n\t\taction?: OdrlActionType | string,\n\t\tdecisionTarget?: string\n\t): Promise<boolean> {\n\t\tif (\n\t\t\t!this.isRuleApplicableToParties(\n\t\t\t\tprohibition,\n\t\t\t\tagreementAssigner,\n\t\t\t\tagreementAssignee,\n\t\t\t\tdataSources\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check if the prohibition's action(s) match the requested action\n\t\tif (!this.isActionApplicable(prohibition.action, action, dataSources)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// ODRL semantics: a rule without constraints is unconditional.\n\t\tconst constraints = [\n\t\t\t...ArrayHelper.fromObjectOrArray(prohibition.constraint ?? []),\n\t\t\t...targetRefinements\n\t\t];\n\t\tif (\n\t\t\tconstraints.length > 0 &&\n\t\t\t!constraints.every(c => this.evaluateConstraint(c, dataSources))\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst prohibitionTargetLookup = this.tryResolveTargetDataSource(\n\t\t\tthis.buildRuleDataContextTargetId(\n\t\t\t\tthis.getRuleDataContextTargetId(prohibition.target),\n\t\t\t\tdecisionTarget\n\t\t\t),\n\t\t\tdataSources,\n\t\t\ttrue\n\t\t);\n\t\tconst ruleDataContext = prohibitionTargetLookup.value;\n\n\t\tconst remedies = ArrayHelper.fromObjectOrArray<IOdrlDuty>(prohibition.remedy ?? []);\n\t\tif (remedies.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tfor (const remedy of remedies) {\n\t\t\tif (!(await this.enforceDuty(policy, remedy, dataSources, ruleDataContext))) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// Remedies satisfied: prohibition is treated as no longer infringed.\n\t\treturn false;\n\t}\n\n\t/**\n\t * Evaluate all policy-level obligations.\n\t * @param agreementAssigner The assigner ID from the agreement.\n\t * @param agreementAssignee The assignee ID from the agreement.\n\t * @param policy The policy containing obligations.\n\t * @param dataSources The operand lookup sources.\n\t * @returns True if all applicable obligations are fulfilled.\n\t * @internal\n\t */\n\tprivate async evaluatePolicyObligations(\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tpolicy: IRightsManagementPolicy,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): Promise<boolean> {\n\t\tconst obligations = ArrayHelper.fromObjectOrArray<IOdrlDuty>(policy.obligation ?? []);\n\t\tfor (const obligation of obligations) {\n\t\t\tif (\n\t\t\t\t!(await this.evaluateObligation(\n\t\t\t\t\tagreementAssigner,\n\t\t\t\t\tagreementAssignee,\n\t\t\t\t\tpolicy,\n\t\t\t\t\tobligation,\n\t\t\t\t\tdataSources\n\t\t\t\t))\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Evaluate whether a policy-level obligation is fulfilled.\n\t * @param agreementAssigner The assigner ID from the agreement.\n\t * @param agreementAssignee The assignee ID from the agreement.\n\t * @param policy The policy containing the obligation.\n\t * @param obligation The obligation to evaluate.\n\t * @param dataSources The operand lookup sources.\n\t * @returns True if the obligation is not applicable or is fulfilled.\n\t * @internal\n\t */\n\tprivate async evaluateObligation(\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tpolicy: IRightsManagementPolicy,\n\t\tobligation: IOdrlDuty,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): Promise<boolean> {\n\t\tif (\n\t\t\t!this.isRuleApplicableToParties(obligation, agreementAssigner, agreementAssignee, dataSources)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst { refinements } = this.resolveRuleTarget(obligation, dataSources);\n\t\tconst obligationTargetLookup = this.tryResolveTargetDataSource(\n\t\t\tthis.getTargetId(obligation.target),\n\t\t\tdataSources,\n\t\t\ttrue\n\t\t);\n\t\tconst ruleDataContext = obligationTargetLookup.value;\n\t\tconst constraints = [\n\t\t\t...ArrayHelper.fromObjectOrArray(obligation.constraint ?? []),\n\t\t\t...refinements\n\t\t];\n\n\t\tif (\n\t\t\tconstraints.length > 0 &&\n\t\t\t!constraints.every(c => this.evaluateConstraint(c, dataSources))\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn this.enforceDuty(policy, obligation, dataSources, ruleDataContext);\n\t}\n\n\t/**\n\t * Merge inherited policies into the current policy.\n\t * Inherited policies' permissions, prohibitions, and obligations are combined with the current policy's rules.\n\t * @param policy The policy to evaluate.\n\t * @returns A new policy with merged rules from all ancestors.\n\t * @internal\n\t */\n\tprivate async mergeInheritedPolicies(\n\t\tpolicy: IRightsManagementPolicy\n\t): Promise<IRightsManagementPolicy> {\n\t\tconst visitedPolicyIds: string[] = [];\n\t\tvisitedPolicyIds.push(OdrlPolicyHelper.getUid(policy) ?? \"\");\n\t\tconst inheritedPolicies = await this.resolveInheritedPolicies(policy, visitedPolicyIds, 0);\n\t\tconst conflictStrategies = new Set<OdrlConflictStrategyType>();\n\t\tif (Is.stringValue(policy.conflict)) {\n\t\t\tconflictStrategies.add(policy.conflict);\n\t\t}\n\n\t\t// Start with copies of the current policy's rules\n\t\tconst mergedPermissions: IOdrlPermission[] = ArrayHelper.fromObjectOrArray(\n\t\t\tpolicy.permission ?? []\n\t\t).map(permission => this.applyPolicyDefaultsToRule(policy, permission));\n\n\t\tconst mergedProhibitions: IOdrlProhibition[] = ArrayHelper.fromObjectOrArray(\n\t\t\tpolicy.prohibition ?? []\n\t\t).map(prohibition => this.applyPolicyDefaultsToRule(policy, prohibition));\n\n\t\tconst mergedObligations: IOdrlDuty[] = ArrayHelper.fromObjectOrArray(\n\t\t\tpolicy.obligation ?? []\n\t\t).map(obligation => this.applyPolicyDefaultsToRule(policy, obligation));\n\n\t\t// Merge rules from each inherited policy, applying the same profile guard as the\n\t\t// top-level policy. A parent that declares an unsupported profile may carry rules\n\t\t// whose semantics the arbiter cannot guarantee, so it is rejected.\n\t\tfor (const inheritedPolicy of inheritedPolicies) {\n\t\t\tconst inheritedProfiles = ArrayHelper.fromObjectOrArray<string>(inheritedPolicy.profile ?? [])\n\t\t\t\t.filter(p => Is.stringValue(p))\n\t\t\t\t.map(p => DefaultPolicyArbiter.normalizeProfileIri(p));\n\t\t\tif (\n\t\t\t\tIs.arrayValue(inheritedProfiles) &&\n\t\t\t\t!inheritedProfiles.every(p => DefaultPolicyArbiter.SUPPORTED_PROFILES.has(p))\n\t\t\t) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\t\t\t\"inheritedPolicyProfileNotSupported\",\n\t\t\t\t\t{ policyId: OdrlPolicyHelper.getUid(inheritedPolicy) ?? \"\" }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (Is.stringValue(inheritedPolicy.conflict)) {\n\t\t\t\tconflictStrategies.add(inheritedPolicy.conflict);\n\t\t\t}\n\t\t\tconst inheritedPermissions = ArrayHelper.fromObjectOrArray(inheritedPolicy.permission ?? []);\n\t\t\tif (inheritedPermissions.length > 0) {\n\t\t\t\tmergedPermissions.push(\n\t\t\t\t\t...inheritedPermissions.map(permission =>\n\t\t\t\t\t\tthis.applyPolicyDefaultsToRule(inheritedPolicy, permission)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst inheritedProhibitions = ArrayHelper.fromObjectOrArray(\n\t\t\t\tinheritedPolicy.prohibition ?? []\n\t\t\t);\n\t\t\tif (inheritedProhibitions.length > 0) {\n\t\t\t\tmergedProhibitions.push(\n\t\t\t\t\t...inheritedProhibitions.map(prohibition =>\n\t\t\t\t\t\tthis.applyPolicyDefaultsToRule(inheritedPolicy, prohibition)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst inheritedObligations = ArrayHelper.fromObjectOrArray(inheritedPolicy.obligation ?? []);\n\t\t\tif (inheritedObligations.length > 0) {\n\t\t\t\tmergedObligations.push(\n\t\t\t\t\t...inheritedObligations.map(obligation =>\n\t\t\t\t\t\tthis.applyPolicyDefaultsToRule(inheritedPolicy, obligation)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tlet mergedConflict: OdrlConflictStrategyType | undefined;\n\t\tif (conflictStrategies.size === 1) {\n\t\t\tmergedConflict = Array.from(conflictStrategies)[0];\n\t\t} else if (conflictStrategies.size > 1) {\n\t\t\tmergedConflict = OdrlConflictStrategyType.Invalid;\n\t\t}\n\n\t\t// Return a new policy with merged rules\n\t\treturn {\n\t\t\t...policy,\n\t\t\tconflict: mergedConflict,\n\t\t\tpermission: mergedPermissions.length > 0 ? mergedPermissions : undefined,\n\t\t\tprohibition: mergedProhibitions.length > 0 ? mergedProhibitions : undefined,\n\t\t\tobligation: mergedObligations.length > 0 ? mergedObligations : undefined\n\t\t};\n\t}\n\n\t/**\n\t * Resolve inherited policies by their UIDs from the Policy Administration Point.\n\t * Policies can inherit from other policies via the inheritFrom property.\n\t * @param policy The policy that may have inheritFrom references.\n\t * @param visitedPolicyIds Array of policy UIDs already visited in this inheritance chain.\n\t * @returns Array of inherited policies fetched from the PAP.\n\t * @internal\n\t */\n\tprivate async resolveInheritedPolicies(\n\t\tpolicy: IRightsManagementPolicy,\n\t\tvisitedPolicyIds: string[],\n\t\tcurrentDepth: number\n\t): Promise<IRightsManagementPolicy[]> {\n\t\tconst inheritedPolicies: IRightsManagementPolicy[] = [];\n\n\t\t// If policy has no inheritFrom, return empty array\n\t\tif (Is.empty(policy.inheritFrom)) {\n\t\t\treturn inheritedPolicies;\n\t\t}\n\n\t\tconst inheritFromIds = ArrayHelper.fromObjectOrArray<string>(policy.inheritFrom) ?? [];\n\n\t\tfor (const inheritFromId of inheritFromIds) {\n\t\t\tconst nextDepth = currentDepth + 1;\n\t\t\tif (nextDepth > this._maxInheritanceDepth) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"maxInheritanceDepthExceeded\", {\n\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\tinheritFromId,\n\t\t\t\t\tmaxInheritanceDepth: this._maxInheritanceDepth\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Check for circular inheritance\n\t\t\tif (visitedPolicyIds.includes(inheritFromId)) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"circularInheritanceDetected\", {\n\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\tinheritFromId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Fetch the inherited policy from the PAP\n\t\t\tconst inheritedPolicy = await this._policyAdministrationPoint.get(inheritFromId);\n\t\t\tif (Is.empty(inheritedPolicy)) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"inheritedPolicyNotFound\", {\n\t\t\t\t\tinheritFromId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Mark this policy as visited\n\t\t\tvisitedPolicyIds.push(inheritFromId);\n\n\t\t\tinheritedPolicies.push(inheritedPolicy);\n\n\t\t\t// Recursively resolve inherited policies of the parent\n\t\t\tconst grandparentPolicies = await this.resolveInheritedPolicies(\n\t\t\t\tinheritedPolicy,\n\t\t\t\tvisitedPolicyIds,\n\t\t\t\tnextDepth\n\t\t\t);\n\t\t\tinheritedPolicies.push(...grandparentPolicies);\n\t\t}\n\n\t\treturn inheritedPolicies;\n\t}\n\n\t/**\n\t * Apply policy-level default values (assigner, assignee, target, action) to rules that don't override them.\n\t * @param policy The policy providing defaults.\n\t * @param rule The rule to apply defaults to.\n\t * @returns The rule with policy-level defaults applied.\n\t * @internal\n\t */\n\tprivate applyPolicyDefaultsToRule<T extends IOdrlRule>(\n\t\tpolicy: IRightsManagementPolicy,\n\t\trule: T\n\t): T {\n\t\tconst assigner = Is.empty(rule.assigner) ? policy.assigner : rule.assigner;\n\t\tconst assignee = Is.empty(rule.assignee) ? policy.assignee : rule.assignee;\n\t\tconst target = Is.empty(rule.target) ? policy.target : rule.target;\n\t\tconst action = Is.empty(rule.action) ? policy.action : rule.action;\n\n\t\tconst assignerIds = OdrlPolicyHelper.getPartyIds(assigner);\n\t\tconst ruleAssignerIds = OdrlPolicyHelper.getPartyIds(rule.assigner);\n\t\tconst assigneeIds = OdrlPolicyHelper.getPartyIds(assignee);\n\t\tconst ruleAssigneeIds = OdrlPolicyHelper.getPartyIds(rule.assignee);\n\n\t\tlet assignerEqual = false;\n\t\tif (Is.empty(assignerIds) && Is.empty(ruleAssignerIds)) {\n\t\t\tassignerEqual = true;\n\t\t} else if (!Is.empty(assignerIds) && !Is.empty(ruleAssignerIds)) {\n\t\t\tassignerEqual =\n\t\t\t\tassignerIds.length === ruleAssignerIds.length &&\n\t\t\t\tassignerIds.every(id => ruleAssignerIds.includes(id));\n\t\t}\n\n\t\tlet assigneeEqual = false;\n\t\tif (Is.empty(assigneeIds) && Is.empty(ruleAssigneeIds)) {\n\t\t\tassigneeEqual = true;\n\t\t} else if (!Is.empty(assigneeIds) && !Is.empty(ruleAssigneeIds)) {\n\t\t\tassigneeEqual =\n\t\t\t\tassigneeIds.length === ruleAssigneeIds.length &&\n\t\t\t\tassigneeIds.every(id => ruleAssigneeIds.includes(id));\n\t\t}\n\n\t\tconst targetEqual = target === rule.target;\n\t\tconst actionEqual = action === rule.action;\n\n\t\tif (assignerEqual && assigneeEqual && targetEqual && actionEqual) {\n\t\t\treturn rule;\n\t\t}\n\n\t\treturn {\n\t\t\t...rule,\n\t\t\tassigner,\n\t\t\tassignee,\n\t\t\ttarget,\n\t\t\taction\n\t\t};\n\t}\n\n\t/**\n\t * Determine whether a rule applies to the agreement parties based on assigner/assignee.\n\t * @param rule The rule to evaluate.\n\t * @param agreementAssigner The assigner ID from the agreement.\n\t * @param agreementAssignee The assignee ID from the agreement.\n\t * @returns True if the rule is applicable to the agreement parties.\n\t * @internal\n\t */\n\tprivate isRuleApplicableToParties(\n\t\trule: IOdrlRule,\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): boolean {\n\t\tconst assignerContext = this.resolveRulePartyContext(rule.assigner);\n\t\tconst assigneeContext = this.resolveRulePartyContext(rule.assignee);\n\n\t\tif (!this.isPartyApplicable(assignerContext.partyIds, agreementAssigner)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (\n\t\t\tassignerContext.refinements.length > 0 &&\n\t\t\t!assignerContext.refinements.every(c => this.evaluateConstraint(c, dataSources))\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!this.isPartyApplicable(assigneeContext.partyIds, agreementAssignee)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (\n\t\t\tassigneeContext.refinements.length > 0 &&\n\t\t\t!assigneeContext.refinements.every(c => this.evaluateConstraint(c, dataSources))\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Resolve rule party identifiers and refinements.\n\t * PartyCollection source values are currently not supported for party matching.\n\t * @param party The rule party value.\n\t * @returns Resolved party identifiers and refinement constraints.\n\t * @throws GeneralError if PartyCollection source has a value.\n\t * @internal\n\t */\n\tprivate resolveRulePartyContext(party: IOdrlRule[\"assigner\"] | IOdrlRule[\"assignee\"]): {\n\t\tpartyIds: string[];\n\t\trefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t} {\n\t\tconst partyIds: string[] = [];\n\t\tconst refinements: (IOdrlConstraint | IOdrlLogicalConstraint)[] = [];\n\n\t\tconst parties = ArrayHelper.fromObjectOrArray(party ?? []);\n\t\tfor (const partyEntry of parties) {\n\t\t\tif (Is.stringValue(partyEntry)) {\n\t\t\t\tpartyIds.push(partyEntry);\n\t\t\t} else if (Is.object<IOdrlParty>(partyEntry)) {\n\t\t\t\t// Guard against unsupported ODRL party properties\n\t\t\t\tif (Is.notEmpty(partyEntry.assignerOf)) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"partyAssignerOfNotSupported\");\n\t\t\t\t}\n\t\t\t\tif (Is.notEmpty(partyEntry.assigneeOf)) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"partyAssigneeOfNotSupported\");\n\t\t\t\t}\n\t\t\t\tif (Is.notEmpty(partyEntry.partOf)) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"partyPartOfNotSupported\");\n\t\t\t\t}\n\n\t\t\t\tif (OdrlPolicyHelper.getType(partyEntry) === OdrlTypes.PartyCollection) {\n\t\t\t\t\tconst partyCollectionEntry = partyEntry as IOdrlPartyCollection;\n\t\t\t\t\tif (Is.stringValue(partyCollectionEntry.source)) {\n\t\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\t\t\t\t\t\"partyCollectionSourceNotSupported\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsource: partyCollectionEntry.source ?? \"\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\trefinements.push(...ArrayHelper.fromObjectOrArray(partyCollectionEntry.refinement ?? []));\n\t\t\t\t} else {\n\t\t\t\t\tconst partyId = OdrlPolicyHelper.getUid(partyEntry);\n\t\t\t\t\tif (Is.stringValue(partyId)) {\n\t\t\t\t\t\tpartyIds.push(partyId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tpartyIds,\n\t\t\trefinements\n\t\t};\n\t}\n\n\t/**\n\t * Determine whether a rule party constraint applies to the agreement parties.\n\t * Rule party is treated as a constraint: if specified, it must match at least one agreement party.\n\t * @param rulePartyIds The party ids specified on the rule (if any).\n\t * @param agreementPartyIds The party ids extracted from the agreement.\n\t * @returns True if the rule party constraint is satisfied.\n\t * @internal\n\t */\n\tprivate isPartyApplicable(\n\t\trulePartyIds: string[] | undefined,\n\t\tagreementPartyIds: string[] | undefined\n\t): boolean {\n\t\t// No party specified on rule means it applies to any agreement party.\n\t\tif (Is.empty(rulePartyIds)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Rule specifies party/parties, but agreement doesn't provide any.\n\t\tif (Is.empty(agreementPartyIds)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const rulePartyId of rulePartyIds) {\n\t\t\tif (agreementPartyIds.includes(rulePartyId)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Determine whether a rule's action(s) match the requested action.\n\t * Supports exact match, includedIn hierarchy, and implies relationships.\n\t * If no action is specified in the rule, it applies to all actions (action-agnostic).\n\t * If an action is specified in the rule and a specific action is requested, they must match.\n\t * If an action is specified in the rule but no specific action is requested, the rule applies (general evaluation).\n\t * @param ruleActions The actions defined in the rule (can be string, object, or array).\n\t * @param requestedAction The action being requested (optional).\n\t * @returns True if the rule's action(s) apply.\n\t * @internal\n\t */\n\tprivate isActionApplicable(\n\t\truleActions: IOdrlRule[\"action\"],\n\t\trequestedAction: OdrlActionType | string | undefined,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): boolean {\n\t\t// If the rule has no action specified, it applies to all actions\n\t\tif (Is.empty(ruleActions)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If the rule has actions but no specific action is requested,\n\t\t// the rule applies (we're evaluating permissions in general)\n\t\tif (Is.empty(requestedAction)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst requestedActionId = Is.string(requestedAction)\n\t\t\t? requestedAction\n\t\t\t: OdrlPolicyHelper.getUid(requestedAction);\n\n\t\tif (!Is.stringValue(requestedActionId)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst ruleActionArray = ArrayHelper.fromObjectOrArray(ruleActions) ?? [];\n\n\t\tfor (const ruleAction of ruleActionArray) {\n\t\t\tif (this.ruleActionCoversRequested(ruleAction, requestedActionId, dataSources)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Determine whether a single rule action covers a requested action.\n\t * Covers exact match plus ODRL action hierarchy semantics.\n\t * - includedIn: the rule action is a sub-action of a broader parent.\n\t * A rule naming the narrower action also covers requests for the parent.\n\t * E.g. rule action \"print\" with includedIn \"reproduce\" covers a request for \"reproduce\".\n\t * - implies: the rule action entails another action.\n\t * A rule granting action X also covers action Y when X implies Y.\n\t * E.g. rule action \"distribute\" implying \"reproduce\" covers a request for \"reproduce\".\n\t * @param ruleAction The action specified in the rule.\n\t * @param requestedActionId The requested action identifier.\n\t * @returns True if the rule action covers the requested action.\n\t * @internal\n\t */\n\tprivate ruleActionCoversRequested(\n\t\truleAction: OdrlActionType | string | IOdrlAction,\n\t\trequestedActionId: string,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): boolean {\n\t\t// Extract the rule action ID — support both @id and rdf:value forms\n\t\tlet ruleActionId: string | undefined;\n\t\tif (Is.string(ruleAction)) {\n\t\t\truleActionId = ruleAction;\n\t\t} else if (Is.object<IOdrlAction>(ruleAction)) {\n\t\t\truleActionId = ruleAction[\"rdf:value\"]?.[\"@id\"] ?? OdrlPolicyHelper.getUid(ruleAction);\n\t\t}\n\n\t\t// Determine whether this rule action covers the requested action via any semantic path.\n\t\tlet covers = false;\n\n\t\tif (Is.stringValue(ruleActionId) && ruleActionId === requestedActionId) {\n\t\t\t// Exact match\n\t\t\tcovers = true;\n\t\t} else if (Is.object<IOdrlAction>(ruleAction)) {\n\t\t\t// includedIn: rule action A includedIn B means A is a sub-type of B.\n\t\t\t// A rule that names the narrower action A with includedIn B also covers requests for B.\n\t\t\tif (Is.stringValue(ruleAction.includedIn) && ruleAction.includedIn === requestedActionId) {\n\t\t\t\tcovers = true;\n\t\t\t}\n\n\t\t\t// implies: rule action A implies B means exercising A also entails B.\n\t\t\t// A rule granting A therefore also grants each implied action.\n\t\t\tif (!covers && (ruleAction.implies ?? []).includes(requestedActionId as OdrlActionType)) {\n\t\t\t\tcovers = true;\n\t\t\t}\n\t\t}\n\n\t\tif (!covers) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// If the action specifies refinements, all must be satisfied for the action to apply.\n\t\t// Refinements constrain the manner in which the action is exercised (e.g. print count <= 5).\n\t\tif (Is.object<IOdrlAction>(ruleAction) && Is.notEmpty(ruleAction.refinement)) {\n\t\t\tconst refinements = ArrayHelper.fromObjectOrArray<IOdrlConstraint | IOdrlLogicalConstraint>(\n\t\t\t\truleAction.refinement ?? []\n\t\t\t);\n\t\t\treturn refinements.every((refinement: IOdrlConstraint | IOdrlLogicalConstraint) =>\n\t\t\t\tthis.evaluateConstraint(refinement, dataSources)\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Apply a permission and create decisions based on that information.\n\t * @param agreementAssigner The assigner ID from the agreement.\n\t * @param agreementAssignee The assignee ID from the agreement.\n\t * @param policy The policy containing the permission.\n\t * @param permission The permission to apply.\n\t * @param targetRefinements Additional constraints from target refinement.\n\t * @param dataSources The operand lookup sources.\n\t * @returns True if the permission applies.\n\t * @internal\n\t */\n\tprivate async evaluatePermission(\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tpolicy: IRightsManagementPolicy,\n\t\tpermission: IOdrlPermission,\n\t\ttargetRefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[],\n\t\tdataSources: { [prefix: string]: unknown },\n\t\taction?: OdrlActionType | string,\n\t\tdecisionTarget?: string\n\t): Promise<boolean> {\n\t\tif (\n\t\t\t!this.isRuleApplicableToParties(permission, agreementAssigner, agreementAssignee, dataSources)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check if the permission's action(s) match the requested action\n\t\tif (!this.isActionApplicable(permission.action, action, dataSources)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// ODRL semantics: a Permission without constraints is unconditional.\n\t\tconst constraints = [\n\t\t\t...ArrayHelper.fromObjectOrArray(permission.constraint ?? []),\n\t\t\t...targetRefinements\n\t\t];\n\t\tconst permissionTargetLookup = this.tryResolveTargetDataSource(\n\t\t\tthis.buildRuleDataContextTargetId(\n\t\t\t\tthis.getRuleDataContextTargetId(permission.target),\n\t\t\t\tdecisionTarget\n\t\t\t),\n\t\t\tdataSources,\n\t\t\ttrue\n\t\t);\n\t\tconst ruleDataContext = permissionTargetLookup.value;\n\t\tif (constraints.length === 0) {\n\t\t\treturn this.enforcePermissionDuties(policy, permission, dataSources, ruleDataContext);\n\t\t}\n\n\t\t// All constraints must be satisfied for the permission to apply.\n\t\tconst constraintsSatisfied = constraints.every(c => this.evaluateConstraint(c, dataSources));\n\n\t\tif (!constraintsSatisfied) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.enforcePermissionDuties(policy, permission, dataSources, ruleDataContext);\n\t}\n\n\t/**\n\t * Enforce duties attached to a permission.\n\t * @param policy The policy being evaluated.\n\t * @param permission The permission being evaluated.\n\t * @param dataSources The operand lookup sources.\n\t * @param ruleDataContext The target-scoped data context passed to enforcers.\n\t * @returns True if all duties are enforced or none are present.\n\t * @internal\n\t */\n\tprivate async enforcePermissionDuties(\n\t\tpolicy: IRightsManagementPolicy,\n\t\tpermission: IOdrlPermission,\n\t\tdataSources: { [prefix: string]: unknown },\n\t\truleDataContext?: unknown\n\t): Promise<boolean> {\n\t\tconst duties = ArrayHelper.fromObjectOrArray(permission.duty ?? []);\n\t\tif (duties.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tfor (const duty of duties) {\n\t\t\tconst enforced = await this.enforceDuty(policy, duty, dataSources, ruleDataContext);\n\t\t\tif (!enforced) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Enforce a single duty using registered obligation enforcers.\n\t * @param policy The policy being evaluated.\n\t * @param duty The duty to enforce.\n\t * @param dataSources The operand lookup sources.\n\t * @param ruleDataContext The target-scoped data context passed to enforcers.\n\t * @returns True if any enforcer succeeds.\n\t * @internal\n\t */\n\tprivate async enforceDuty(\n\t\tpolicy: IRightsManagementPolicy,\n\t\tduty: IOdrlDuty,\n\t\tdataSources: { [prefix: string]: unknown },\n\t\truleDataContext?: unknown\n\t): Promise<boolean> {\n\t\tconst enforcerNames = PolicyObligationEnforcerFactory.names();\n\t\tconst information = dataSources[\n\t\t\t`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_INFORMATION}`\n\t\t] as { [id: string]: IJsonLdNodeObject } | undefined;\n\n\t\tif (enforcerNames.length === 0) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"noObligationEnforcersRegistered\");\n\t\t}\n\n\t\tfor (const enforcerName of enforcerNames) {\n\t\t\tconst enforcer = PolicyObligationEnforcerFactory.get(enforcerName);\n\t\t\tif (await enforcer.enforce(policy, duty, information, ruleDataContext)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tconst consequences = ArrayHelper.fromObjectOrArray<IOdrlDuty>(duty.consequence ?? []);\n\t\tif (consequences.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (const consequence of consequences) {\n\t\t\tif (!(await this.enforceDuty(policy, consequence, dataSources, ruleDataContext))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Resolve a target string to a matching datasource prefix and remaining target value.\n\t * @param targetId The target identifier to resolve.\n\t * @param dataSources The available lookup sources.\n\t * @param resolveValue True to resolve an item from the target path/key.\n\t * @returns The matching prefix, source, remaining target and optional resolved value.\n\t * @internal\n\t */\n\tprivate tryResolveTargetDataSource(\n\t\ttargetId: string | undefined,\n\t\tdataSources: { [prefix: string]: unknown },\n\t\tresolveValue: boolean = false\n\t): { prefix: string; source: unknown; target: string; value?: unknown } {\n\t\t// If there is no target id, default to the entire \"twin:jsonpath\" datasource\n\t\tif (Is.empty(targetId)) {\n\t\t\treturn {\n\t\t\t\tprefix: `${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}`,\n\t\t\t\tsource:\n\t\t\t\t\tdataSources[\n\t\t\t\t\t\t`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}`\n\t\t\t\t\t],\n\t\t\t\ttarget: \"$\",\n\t\t\t\tvalue:\n\t\t\t\t\tdataSources[\n\t\t\t\t\t\t`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}`\n\t\t\t\t\t]\n\t\t\t};\n\t\t}\n\n\t\t// Otherwise lookup the target id prefix in the datasources and return the remaining suffix as the target path/key\n\t\tconst prefixes = Object.keys(dataSources).sort((a, b) => b.length - a.length);\n\t\tfor (const prefix of prefixes) {\n\t\t\tif (targetId.startsWith(`${prefix}:`)) {\n\t\t\t\tconst source = dataSources[prefix];\n\t\t\t\tconst target = targetId.slice(prefix.length + 1);\n\n\t\t\t\tif (!target.startsWith(\"$\")) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"ruleTargetNotSupported\", {\n\t\t\t\t\t\ttarget: targetId\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (!resolveValue) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tprefix,\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\ttarget\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst matches = JsonPathHelper.query(target, source);\n\t\t\t\tif (matches.length === 0) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"ruleTargetNotSupported\", {\n\t\t\t\t\t\ttarget: targetId\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tprefix,\n\t\t\t\t\tsource,\n\t\t\t\t\ttarget,\n\t\t\t\t\tvalue: matches.length === 1 ? matches[0].value : matches.map(m => m.value)\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"ruleTargetNotSupported\", {\n\t\t\ttarget: targetId\n\t\t});\n\t}\n\n\t/**\n\t * Extract the target id from the permission.\n\t * @param target The permission target.\n\t * @returns The information key, or undefined when the target is not an information reference.\n\t * @internal\n\t */\n\tprivate getTargetId(target: IOdrlRule[\"target\"]): string | undefined {\n\t\tif (Is.undefined(target)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (Is.array(target) && target.length > 1) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"multipleTargetsNotSupported\");\n\t\t}\n\n\t\tconst arr = ArrayHelper.fromObjectOrArray(target ?? []);\n\t\tif (arr.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn Is.string(arr[0]) ? arr[0] : OdrlPolicyHelper.getUid(arr[0]);\n\t}\n\n\t/**\n\t * Resolve the target identifier used for rule data context lookup.\n\t * For AssetCollection targets the `source` property is used because the collection has no `uid`.\n\t * Falls back to `getTargetId` for all other target forms.\n\t * @param target The rule target field value.\n\t * @returns The prefixed target string for data context resolution.\n\t * @internal\n\t */\n\tprivate getRuleDataContextTargetId(target: IOdrlRule[\"target\"]): string | undefined {\n\t\tconst arr = ArrayHelper.fromObjectOrArray(target ?? []);\n\t\tif (arr.length === 1) {\n\t\t\tconst firstTarget = arr[0];\n\t\t\tif (\n\t\t\t\tIs.object<IOdrlAssetCollection>(firstTarget) &&\n\t\t\t\tOdrlPolicyHelper.getType(firstTarget) === OdrlTypes.AssetCollection &&\n\t\t\t\tIs.stringValue(firstTarget.source)\n\t\t\t) {\n\t\t\t\treturn firstTarget.source;\n\t\t\t}\n\t\t}\n\t\treturn this.getTargetId(target);\n\t}\n\n\t/**\n\t * Build a concrete prefixed target id for rule data-context lookup.\n\t * @param baseTargetId The original prefixed target id from the rule.\n\t * @param decisionTarget The concrete decision JSONPath target.\n\t * @returns The concrete prefixed target id.\n\t * @internal\n\t */\n\tprivate buildRuleDataContextTargetId(\n\t\tbaseTargetId: string | undefined,\n\t\tdecisionTarget: string | undefined\n\t): string | undefined {\n\t\tif (!Is.stringValue(decisionTarget) || decisionTarget === \"$\") {\n\t\t\treturn baseTargetId;\n\t\t}\n\n\t\tif (!Is.stringValue(baseTargetId)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst pathStartIndex = baseTargetId.indexOf(\":$\");\n\t\tif (pathStartIndex < 0) {\n\t\t\treturn baseTargetId;\n\t\t}\n\n\t\treturn `${baseTargetId.slice(0, pathStartIndex)}:${decisionTarget}`;\n\t}\n\n\t/**\n\t * Resolve a rule target into a policy-decision JSONPath target and extracted refinements.\n\t * For AssetCollection targets, `source` is treated as the decision target and `refinement`\n\t * constraints are applied as additional rule constraints.\n\t * @param rule The rule to resolve the target for.\n\t * @returns The decision target and target refinements.\n\t * @throws GeneralError if target is invalid or unsupported.\n\t * @internal\n\t */\n\tprivate resolveRuleTarget(\n\t\trule: IOdrlRule,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): {\n\t\ttarget: string;\n\t\trefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t} {\n\t\tconst arr = ArrayHelper.fromObjectOrArray(rule.target ?? []);\n\t\tif (arr.length === 0) {\n\t\t\treturn {\n\t\t\t\ttarget: \"$\",\n\t\t\t\trefinements: []\n\t\t\t};\n\t\t}\n\n\t\tif (arr.length > 1) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"multipleTargetsNotSupported\");\n\t\t}\n\n\t\tconst firstTarget = arr[0];\n\n\t\tif (Is.object<IOdrlAsset>(firstTarget)) {\n\t\t\t// Guard against unsupported ODRL asset properties\n\t\t\tif (Is.notEmpty(firstTarget.hasPolicy)) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"assetHasPolicyNotSupported\");\n\t\t\t}\n\t\t\tif (Is.notEmpty(firstTarget.partOf)) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"assetPartOfNotSupported\");\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tIs.object<IOdrlAssetCollection>(firstTarget) &&\n\t\t\t\tOdrlPolicyHelper.getType(firstTarget) === OdrlTypes.AssetCollection\n\t\t\t) {\n\t\t\t\tif (!Is.stringValue(firstTarget.source)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\t\t\t\t\"assetCollectionSourceNotSupported\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsource: firstTarget.source ?? \"\"\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tlet sourceLookup: { prefix: string; source: unknown; target: string; value?: unknown };\n\t\t\t\ttry {\n\t\t\t\t\tsourceLookup = this.tryResolveTargetDataSource(firstTarget.source, dataSources);\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\t\t\t\t\"assetCollectionSourceNotSupported\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsource: firstTarget.source\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\ttarget: sourceLookup.target,\n\t\t\t\t\trefinements: ArrayHelper.fromObjectOrArray(firstTarget.refinement ?? [])\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst targetId = Is.string(firstTarget) ? firstTarget : OdrlPolicyHelper.getUid(firstTarget);\n\t\tif (!Is.stringValue(targetId)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"ruleTargetNotSupported\", {\n\t\t\t\ttarget: \"\"\n\t\t\t});\n\t\t}\n\n\t\tconst targetLookup = this.tryResolveTargetDataSource(targetId, dataSources);\n\n\t\treturn {\n\t\t\ttarget: targetLookup.target,\n\t\t\trefinements: []\n\t\t};\n\t}\n\n\t/**\n\t * Resolve decision targets for a rule.\n\t * AssetCollection wildcard targets with refinements are expanded to per-item targets.\n\t * @param rule The rule being evaluated.\n\t * @param dataSources The operand lookup sources.\n\t * @returns The decision targets and scoped refinements.\n\t * @internal\n\t */\n\tprivate resolveRuleDecisionTargets(\n\t\trule: IOdrlRule,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): {\n\t\ttarget: string;\n\t\trefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t}[] {\n\t\tconst resolvedTarget = this.resolveRuleTarget(rule, dataSources);\n\n\t\tif (!this.shouldExpandToPerItemTargets(rule, resolvedTarget)) {\n\t\t\treturn [resolvedTarget];\n\t\t}\n\n\t\tconst sourceLookup = this.tryResolveTargetDataSource(\n\t\t\tthis.getRuleDataContextTargetId(rule.target),\n\t\t\tdataSources\n\t\t);\n\t\tconst matches = JsonPathHelper.query(sourceLookup.target, sourceLookup.source);\n\t\tif (matches.length === 0) {\n\t\t\treturn [resolvedTarget];\n\t\t}\n\n\t\treturn matches.map(match => {\n\t\t\tconst itemTarget = this.normalizeDecisionTargetPath(match.path ?? resolvedTarget.target);\n\t\t\treturn {\n\t\t\t\ttarget: itemTarget,\n\t\t\t\trefinements: resolvedTarget.refinements.map(refinement =>\n\t\t\t\t\tthis.rewriteRefinementForDecisionTarget(refinement, resolvedTarget.target, itemTarget)\n\t\t\t\t)\n\t\t\t};\n\t\t});\n\t}\n\n\t/**\n\t * Determine if a rule should be expanded to per-item targets.\n\t * @param rule The rule.\n\t * @param resolvedTarget The resolved target details.\n\t * @returns True if the rule should emit per-item decisions.\n\t * @internal\n\t */\n\tprivate shouldExpandToPerItemTargets(\n\t\trule: IOdrlRule,\n\t\tresolvedTarget: {\n\t\t\ttarget: string;\n\t\t\trefinements: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t\t}\n\t): boolean {\n\t\tif (resolvedTarget.refinements.length === 0 || !resolvedTarget.target.includes(\"[*]\")) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst targets = ArrayHelper.fromObjectOrArray(rule.target ?? []);\n\t\tif (targets.length !== 1 || !Is.object<IOdrlAssetCollection>(targets[0])) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn OdrlPolicyHelper.getType(targets[0]) === OdrlTypes.AssetCollection;\n\t}\n\n\t/**\n\t * Rewrite a refinement so wildcard paths are scoped to a concrete item target.\n\t * @param refinement The refinement to rewrite.\n\t * @param sourceTarget The wildcard source target.\n\t * @param itemTarget The concrete item target.\n\t * @returns The rewritten refinement.\n\t * @internal\n\t */\n\tprivate rewriteRefinementForDecisionTarget(\n\t\trefinement: IOdrlConstraint | IOdrlLogicalConstraint,\n\t\tsourceTarget: string,\n\t\titemTarget: string\n\t): IOdrlConstraint | IOdrlLogicalConstraint {\n\t\tconst logicalConstraint = this.getLogicalConstraintOperands(refinement);\n\t\tif (logicalConstraint) {\n\t\t\treturn {\n\t\t\t\t...refinement,\n\t\t\t\t[logicalConstraint.operator]: logicalConstraint.constraints.map(item =>\n\t\t\t\t\tthis.rewriteRefinementForDecisionTarget(item, sourceTarget, itemTarget)\n\t\t\t\t)\n\t\t\t} as IOdrlLogicalConstraint;\n\t\t}\n\n\t\tconst regularConstraint = refinement as IOdrlConstraint;\n\t\treturn {\n\t\t\t...regularConstraint,\n\t\t\tleftOperand: this.rewriteOperandForDecisionTarget(\n\t\t\t\tregularConstraint.leftOperand,\n\t\t\t\tsourceTarget,\n\t\t\t\titemTarget\n\t\t\t) as IOdrlConstraint[\"leftOperand\"],\n\t\t\trightOperand: this.rewriteOperandForDecisionTarget(\n\t\t\t\tregularConstraint.rightOperand,\n\t\t\t\tsourceTarget,\n\t\t\t\titemTarget\n\t\t\t)\n\t\t};\n\t}\n\n\t/**\n\t * Rewrite JSONPath-based operands from wildcard source to concrete item target.\n\t * @param operand The operand to rewrite.\n\t * @param sourceTarget The wildcard source target.\n\t * @param itemTarget The concrete item target.\n\t * @returns The rewritten operand.\n\t * @internal\n\t */\n\tprivate rewriteOperandForDecisionTarget(\n\t\toperand: IOdrlConstraint[\"leftOperand\"] | IOdrlConstraint[\"rightOperand\"] | string,\n\t\tsourceTarget: string,\n\t\titemTarget: string\n\t): IOdrlConstraint[\"leftOperand\"] | IOdrlConstraint[\"rightOperand\"] | string {\n\t\tif (Is.stringValue(operand)) {\n\t\t\tconst prefix = `${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}:`;\n\t\t\tif (operand.startsWith(prefix)) {\n\t\t\t\tconst valuePath = operand.slice(prefix.length);\n\t\t\t\treturn `${prefix}${this.rewriteWildcardPath(valuePath, sourceTarget, itemTarget)}`;\n\t\t\t}\n\t\t\treturn operand;\n\t\t}\n\n\t\tif (Is.object<{ \"@type\": unknown; \"@value\": unknown }>(operand)) {\n\t\t\tconst typedOperand = { ...operand };\n\t\t\tif (\n\t\t\t\ttypedOperand[\"@type\"] ===\n\t\t\t\t\t`${DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS}${DefaultPolicyArbiter._TWIN_PREFIX_JSONPATH}` &&\n\t\t\t\tIs.stringValue(typedOperand[\"@value\"])\n\t\t\t) {\n\t\t\t\ttypedOperand[\"@value\"] = this.rewriteWildcardPath(\n\t\t\t\t\ttypedOperand[\"@value\"],\n\t\t\t\t\tsourceTarget,\n\t\t\t\t\titemTarget\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn typedOperand;\n\t\t}\n\n\t\treturn operand;\n\t}\n\n\t/**\n\t * Rewrite wildcard source JSONPath segments to a concrete item JSONPath.\n\t * @param valuePath The operand path.\n\t * @param sourceTarget The wildcard source path.\n\t * @param itemTarget The concrete item path.\n\t * @returns The rewritten path.\n\t * @internal\n\t */\n\tprivate rewriteWildcardPath(valuePath: string, sourceTarget: string, itemTarget: string): string {\n\t\tif (!sourceTarget.includes(\"[*]\") || !valuePath.includes(\"[*]\")) {\n\t\t\treturn valuePath;\n\t\t}\n\n\t\tif (valuePath.startsWith(sourceTarget)) {\n\t\t\treturn `${itemTarget}${valuePath.slice(sourceTarget.length)}`;\n\t\t}\n\n\t\treturn valuePath;\n\t}\n\n\t/**\n\t * Normalize JSONPath strings to dot notation for stable decision targets.\n\t * @param path The JSONPath to normalize.\n\t * @returns The normalized path.\n\t * @internal\n\t */\n\tprivate normalizeDecisionTargetPath(path: string): string {\n\t\treturn path.replace(/\\['([^']+)']/g, \".$1\");\n\t}\n\n\t/**\n\t * Evaluate a single ODRL constraint against the available context.\n\t * Supports logical constraint composition through nested refinements.\n\t * @param constraint The constraint to evaluate.\n\t * @param dataSources The operand lookup sources.\n\t * @returns True if the constraint is satisfied.\n\t * @internal\n\t */\n\tprivate evaluateConstraint(\n\t\tconstraint: IOdrlConstraint | IOdrlLogicalConstraint,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): boolean {\n\t\tconst logicalConstraint = this.getLogicalConstraintOperands(constraint);\n\t\tif (logicalConstraint) {\n\t\t\treturn this.evaluateLogicalConstraint(logicalConstraint, dataSources);\n\t\t}\n\n\t\t// Must be a regular constraint beyond this point\n\t\tconst regularConstraint = constraint as IOdrlConstraint;\n\n\t\t// rightOperandReference is not supported — it requires an external IRI lookup that\n\t\t// is outside the scope of the local evaluation engine.\n\t\tif (Is.notEmpty(regularConstraint.rightOperandReference)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"rightOperandReferenceNotSupported\");\n\t\t}\n\n\t\t// dataType specifies how the rightOperand value should be coerced before comparison.\n\t\t// Without dataType-aware coercion logic the comparison may produce incorrect results.\n\t\tif (Is.notEmpty(regularConstraint.dataType)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"constraintDataTypeNotSupported\");\n\t\t}\n\n\t\t// unit specifies the measurement unit for the right operand (e.g. currency, length).\n\t\t// Unit-aware comparison is not implemented.\n\t\tif (Is.notEmpty(regularConstraint.unit)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"constraintUnitNotSupported\");\n\t\t}\n\n\t\t// status represents a state-based evaluation operand (e.g. odrl:policyUsage).\n\t\t// State-based evaluation is not implemented.\n\t\tif (Is.notEmpty(regularConstraint.status)) {\n\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"constraintStatusNotSupported\");\n\t\t}\n\n\t\t// Evaluate the main constraint condition\n\t\tconst leftValue = this.calculateOperandValue(regularConstraint.leftOperand, dataSources);\n\t\tconst rightValue = this.calculateOperandValue(regularConstraint.rightOperand, dataSources);\n\t\tconst mainSatisfied = this.evaluateOperator(regularConstraint.operator, leftValue, rightValue);\n\n\t\t// If main constraint is not satisfied, the overall constraint fails\n\t\treturn mainSatisfied;\n\t}\n\n\t/**\n\t * Extract logical constraint operands when present.\n\t * @param constraint The constraint to inspect.\n\t * @returns The logical operator and its operands, or undefined when not logical.\n\t * @throws GeneralError if logical constraint operands are not unique.\n\t * @internal\n\t */\n\tprivate getLogicalConstraintOperands(constraint: IOdrlConstraint | IOdrlLogicalConstraint):\n\t\t| {\n\t\t\t\toperator: OdrlLogicalConstraintType;\n\t\t\t\tconstraints: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t\t }\n\t\t| undefined {\n\t\tconst logicalConstraint = constraint as IOdrlLogicalConstraint;\n\t\tconst operators: OdrlLogicalConstraintType[] = Object.values(OdrlLogicalConstraintType);\n\t\tfor (const operator of operators) {\n\t\t\tconst value = logicalConstraint[operator];\n\t\t\tif (!Is.undefined(value)) {\n\t\t\t\tconst constraints = this.normalizeLogicalConstraintOperands(value);\n\t\t\t\tthis.validateLogicalConstraintOperandUniqueness(constraints, operator);\n\t\t\t\treturn {\n\t\t\t\t\toperator,\n\t\t\t\t\tconstraints\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Normalize logical constraint operands into a constraint array.\n\t * Handles both IOdrlConstraint and IOdrlLogicalConstraint types.\n\t * @param raw The raw operand value.\n\t * @returns The constraint array.\n\t * @internal\n\t */\n\tprivate normalizeLogicalConstraintOperands(\n\t\traw: unknown\n\t): (IOdrlConstraint | IOdrlLogicalConstraint)[] {\n\t\tlet normalized = raw;\n\t\tif (\n\t\t\tIs.object<IOdrlLogicalConstraintOperand>(normalized) &&\n\t\t\t!Is.undefined(normalized[\"@list\"])\n\t\t) {\n\t\t\tnormalized = normalized[\"@list\"];\n\t\t}\n\n\t\treturn (ArrayHelper.fromObjectOrArray(normalized) ?? [])\n\t\t\t.filter(item => Is.object(item))\n\t\t\t.map(item => item as IOdrlConstraint | IOdrlLogicalConstraint);\n\t}\n\n\t/**\n\t * Validate that all operands in a logical constraint are unique.\n\t * ODRL spec 2.5.2 requires that all operand values MUST be unique Constraint instances.\n\t * Uniqueness is checked by uid property and id property.\n\t * @param constraints The constraint operands to validate.\n\t * @param operator The logical operator type (for error messaging).\n\t * @throws GeneralError if duplicate constraints are found.\n\t * @internal\n\t */\n\tprivate validateLogicalConstraintOperandUniqueness(\n\t\tconstraints: (IOdrlConstraint | IOdrlLogicalConstraint)[],\n\t\toperator: OdrlLogicalConstraintType\n\t): void {\n\t\tconst seenIdentifiers = new Set<string>();\n\n\t\tfor (let i = 0; i < constraints.length; i++) {\n\t\t\tconst constraint = constraints[i];\n\t\t\tconst identifier = OdrlPolicyHelper.getUid(constraint);\n\n\t\t\t// If we have an identifier, check for duplicates\n\t\t\tif (Is.stringValue(identifier)) {\n\t\t\t\tif (seenIdentifiers.has(identifier)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyArbiter.CLASS_NAME,\n\t\t\t\t\t\t\"logicalConstraintOperandNotUnique\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\toperator,\n\t\t\t\t\t\t\tidentifier,\n\t\t\t\t\t\t\tindex: i\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tseenIdentifiers.add(identifier);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Evaluate a logical constraint operator against its operands.\n\t * @param logicalConstraint The operator and operand list.\n\t * @param dataSources The operand lookup sources.\n\t * @returns True if the logical constraint is satisfied.\n\t * @internal\n\t */\n\tprivate evaluateLogicalConstraint(\n\t\tlogicalConstraint: {\n\t\t\toperator: OdrlLogicalConstraintType;\n\t\t\tconstraints: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t\t},\n\t\tdataSources: { [prefix: string]: unknown }\n\t): boolean {\n\t\tconst { operator, constraints } = logicalConstraint;\n\t\tif (constraints.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tswitch (operator) {\n\t\t\tcase OdrlLogicalConstraintType.And:\n\t\t\t\treturn constraints.every(item => this.evaluateConstraint(item, dataSources));\n\t\t\tcase OdrlLogicalConstraintType.AndSequence: {\n\t\t\t\tfor (const item of constraints) {\n\t\t\t\t\tif (!this.evaluateConstraint(item, dataSources)) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tcase OdrlLogicalConstraintType.Or:\n\t\t\t\treturn constraints.some(item => this.evaluateConstraint(item, dataSources));\n\t\t\tcase OdrlLogicalConstraintType.Xone: {\n\t\t\t\tlet satisfied = 0;\n\t\t\t\tfor (const item of constraints) {\n\t\t\t\t\tif (this.evaluateConstraint(item, dataSources)) {\n\t\t\t\t\t\tsatisfied += 1;\n\t\t\t\t\t\tif (satisfied > 1) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn satisfied === 1;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Resolve a prefixed operand to its source object and JSONPath expression.\n\t * Prefix matching is dictionary-driven so additional operand namespaces can be\n\t * added in one place by extending the lookup sources map.\n\t * @param operandTypeOrValue The string operand value or typed operand namespace.\n\t * @param operandValue The JSONPath expression.\n\t * @param dataSources The available lookup sources.\n\t * @returns The resolved source and JSONPath, or undefined when not namespaced.\n\t * @throws GeneralError if a twin: prefixed operand doesn't resolve to any available datasource key.\n\t * @internal\n\t */\n\tprivate tryResolveOperandLookup(\n\t\toperandTypeOrValue: string,\n\t\toperandValue: unknown,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): { source: unknown; jsonPath: string } | undefined {\n\t\tlet lookupTargetId: string | undefined;\n\n\t\tif (dataSources[operandTypeOrValue]) {\n\t\t\tif (!Is.stringValue(operandValue)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tlookupTargetId = `${operandTypeOrValue}:${operandValue}`;\n\t\t} else if (operandTypeOrValue.includes(\":\")) {\n\t\t\tlookupTargetId = operandTypeOrValue;\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Delegate prefixed path matching to shared datasource resolver\n\t\tif (operandTypeOrValue.startsWith(DefaultPolicyArbiter._TWIN_PREFIX_OPERATIONS)) {\n\t\t\tconst resolved = this.tryResolveTargetDataSource(lookupTargetId, dataSources);\n\t\t\treturn {\n\t\t\t\tsource: resolved.source,\n\t\t\t\tjsonPath: resolved.target\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Calculate an operand value.\n\t * @param operand The operand.\n\t * @param dataSources The available prefixed operand sources.\n\t * @returns The resolved operand value.\n\t * @internal\n\t */\n\tprivate calculateOperandValue(\n\t\toperand: IOdrlConstraint[\"leftOperand\"] | IOdrlConstraint[\"rightOperand\"] | string,\n\t\tdataSources: { [prefix: string]: unknown }\n\t): unknown {\n\t\t// Treat prefixed operands as selectors against a namespaced source dictionary.\n\t\t// Examples: twin:jsonpath:$.field, twin:information:$.credentials.level\n\t\tlet jsonPath: string | undefined;\n\t\tlet operandRoot: unknown;\n\t\tif (Is.stringValue(operand)) {\n\t\t\tconst lookup = this.tryResolveOperandLookup(operand, operand, dataSources);\n\t\t\tif (lookup) {\n\t\t\t\tjsonPath = lookup.jsonPath;\n\t\t\t\toperandRoot = lookup.source;\n\t\t\t}\n\t\t} else if (Is.object<{ \"@type\": unknown; \"@value\": unknown }>(operand)) {\n\t\t\t// Is this an object { \"@value\": \"18\", \"@type\": \"xsd:integer\" } ?\n\t\t\tconst value = operand[\"@value\"];\n\t\t\tconst type = operand[\"@type\"];\n\t\t\tif (Is.stringValue(type)) {\n\t\t\t\tconst lookup = this.tryResolveOperandLookup(type, value, dataSources);\n\t\t\t\tif (lookup) {\n\t\t\t\t\tjsonPath = lookup.jsonPath;\n\t\t\t\t\toperandRoot = lookup.source;\n\t\t\t\t} else {\n\t\t\t\t\tconst xsdValue = this.coerceXsdType(value, type);\n\t\t\t\t\tif (!Is.undefined(xsdValue)) {\n\t\t\t\t\t\treturn xsdValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// We have a JSON Path to resolve\n\t\tif (Is.stringValue(jsonPath)) {\n\t\t\tconst jsonPaths = JsonPathHelper.query(jsonPath, operandRoot);\n\t\t\tif (jsonPaths.length === 0) {\n\t\t\t\t// No matches\n\t\t\t\treturn undefined;\n\t\t\t} else if (jsonPaths.length === 1) {\n\t\t\t\t// Single match - return the value directly\n\t\t\t\treturn jsonPaths[0].value;\n\t\t\t}\n\n\t\t\t// Multiple matches - return array of values\n\t\t\treturn jsonPaths.map(p => p.value);\n\t\t}\n\n\t\t// Not JSON Path or object value so return as is\n\t\treturn operand;\n\t}\n\n\t/**\n\t * Evaluate an ODRL operator against resolved operands.\n\t * @param operator The operator.\n\t * @param left The resolved left operand.\n\t * @param right The resolved right operand.\n\t * @returns True if the comparison is satisfied.\n\t * @internal\n\t */\n\tprivate evaluateOperator(operator: OdrlOperatorType, left: unknown, right: unknown): boolean {\n\t\t// Handle array/collection left values (e.g. JSONPath returning multiple matches).\n\t\tconst leftValues = ArrayHelper.fromObjectOrArray(left ?? []);\n\n\t\tswitch (operator) {\n\t\t\tcase OdrlOperatorType.Eq:\n\t\t\t\treturn leftValues.some(v => ObjectHelper.equal(v, right, false));\n\t\t\tcase OdrlOperatorType.Neq:\n\t\t\t\treturn leftValues.every(v => !ObjectHelper.equal(v, right, false));\n\t\t\tcase OdrlOperatorType.Gt:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a > b));\n\t\t\tcase OdrlOperatorType.Gteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a >= b));\n\t\t\tcase OdrlOperatorType.Lt:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a < b));\n\t\t\tcase OdrlOperatorType.Lteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a <= b));\n\t\t\tcase OdrlOperatorType.IsAnyOf: {\n\t\t\t\treturn leftValues.some(v => {\n\t\t\t\t\tconst stringValue =\n\t\t\t\t\t\ttypeof v === \"string\" || typeof v === \"number\" || typeof v === \"boolean\"\n\t\t\t\t\t\t\t? String(v)\n\t\t\t\t\t\t\t: JSON.stringify(v);\n\t\t\t\t\treturn (ArrayHelper.fromObjectOrArray(right) ?? []).includes(stringValue);\n\t\t\t\t});\n\t\t\t}\n\t\t\tcase OdrlOperatorType.IsAllOf: {\n\t\t\t\treturn ObjectHelper.equal(leftValues, ArrayHelper.fromObjectOrArray(right) ?? [], false);\n\t\t\t}\n\t\t\tcase OdrlOperatorType.IsNoneOf: {\n\t\t\t\treturn leftValues.every(v => !(ArrayHelper.fromObjectOrArray(right) ?? []).includes(v));\n\t\t\t}\n\t\t\tcase OdrlOperatorType.LocTimeEq:\n\t\t\t\treturn leftValues.some(v => ObjectHelper.equal(v, right, false));\n\t\t\tcase OdrlOperatorType.LocTimeGteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a >= b));\n\t\t\tcase OdrlOperatorType.IsA:\n\t\t\tcase OdrlOperatorType.HasPart:\n\t\t\tcase OdrlOperatorType.IsPartOf:\n\t\t\t\t// For now, treat these as simple equality/ordering semantics where meaningful.\n\t\t\t\t// Profiles can introduce richer semantics via additional arbiters.\n\t\t\t\treturn leftValues.some(v => ObjectHelper.equal(v, right, false));\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Compare values with numeric/date/string coercion.\n\t * @param left The left value.\n\t * @param right The right value.\n\t * @param compare Comparison operator.\n\t * @returns True if ordered comparison passes.\n\t * @internal\n\t */\n\tprivate compareOrdered(\n\t\tleft: unknown,\n\t\tright: unknown,\n\t\tcompare: (a: number, b: number) => boolean\n\t): boolean {\n\t\tconst leftNum = Coerce.number(left);\n\t\tconst rightNum = Coerce.number(right);\n\t\tif (!Is.undefined(leftNum) && !Is.undefined(rightNum)) {\n\t\t\treturn compare(leftNum, rightNum);\n\t\t}\n\t\tconst leftDate = Coerce.dateTime(left);\n\t\tconst rightDate = Coerce.dateTime(right);\n\t\tif (!Is.undefined(leftDate) && !Is.undefined(rightDate)) {\n\t\t\treturn compare(leftDate.getTime(), rightDate.getTime());\n\t\t}\n\n\t\t// Only use string ordering when both operands are actual strings.\n\t\t// Avoid coercing other types into strings, as that can cause\n\t\t// unintended comparisons like 18 >= \"$.minAge\" evaluating to true.\n\t\tif (Is.string(left) && Is.string(right)) {\n\t\t\treturn compare(left.localeCompare(right), 0);\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Coerce a value to a specific XSD type.\n\t * @param value The value to coerce.\n\t * @param type The XSD type.\n\t * @returns The coerced value, or undefined when coercion is not possible.\n\t * @internal\n\t */\n\tprivate coerceXsdType(value: unknown, type: string): unknown {\n\t\tif (\n\t\t\t[\n\t\t\t\t\"xsd:string\",\n\t\t\t\t\"xsd:normalizedString\",\n\t\t\t\t\"xsd:token\",\n\t\t\t\t\"xsd:anyURI\",\n\t\t\t\t\"xsd:QName\",\n\t\t\t\t\"xsd:NOTATION\"\n\t\t\t].includes(type)\n\t\t) {\n\t\t\t// Handle standard xsd types\n\t\t\treturn Coerce.string(value);\n\t\t} else if (\n\t\t\t[\n\t\t\t\t\"xsd:integer\",\n\t\t\t\t\"xsd:decimal\",\n\t\t\t\t\"xsd:float\",\n\t\t\t\t\"xsd:double\",\n\t\t\t\t\"xsd:long\",\n\t\t\t\t\"xsd:int\",\n\t\t\t\t\"xsd:short\",\n\t\t\t\t\"xsd:byte\"\n\t\t\t].includes(type)\n\t\t) {\n\t\t\t// Handle standard xsd types\n\t\t\treturn Coerce.number(value);\n\t\t} else if (type === \"xsd:boolean\") {\n\t\t\t// Handle standard xsd types\n\t\t\treturn Coerce.boolean(value);\n\t\t} else if ([\"xsd:date\", \"xsd:dateTime\", \"xsd:time\"].includes(type)) {\n\t\t\t// Handle standard xsd types\n\t\t\treturn Coerce.dateTime(value);\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggingPolicyExecutionAction.js","sourceRoot":"","sources":["../../../src/policyExecutionActions/loggingPolicyExecutionAction.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAG9D,OAAO,
|
|
1
|
+
{"version":3,"file":"loggingPolicyExecutionAction.js","sourceRoot":"","sources":["../../../src/policyExecutionActions/loggingPolicyExecutionAction.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAIN,gBAAgB,EAChB,mBAAmB,EACnB,MAAM,oCAAoC,CAAC;AAI5C;;GAEG;AACH,MAAM,OAAO,4BAA4B;IACxC;;OAEG;IACI,MAAM,CAAU,UAAU,kCAAkD;IAEnF;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACc,OAAO,CAAwB;IAEhD;;OAEG;IACc,YAAY,CAAU;IAEvC;;OAEG;IACc,cAAc,CAAU;IAEzC;;OAEG;IACc,iBAAiB,CAAU;IAE5C;;;OAGG;IACH,YAAY,OAAyD;QACpE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;QAEF,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI;YACzC,mBAAmB,CAAC,MAAM;YAC1B,mBAAmB,CAAC,KAAK;SACzB,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,IAAI,KAAK,CAAC;QAC1D,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,MAAM,EAAE,aA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BACrC,IAAI,EAAE;wBACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;wBAC/C,IAAI,EAAE,OAAO;wBACb,MAAM,EAAE,SAAS;wBACjB,SAAS,EAAE,YAAY;wBACvB,MAAM;wBACN,KAAK;qBACL;iBACD,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACP,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;oBACvB,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,4BAA4B,CAAC,UAAU;oBAC/C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;oBACd,OAAO,EAAE,2BAA2B;oBACpC,IAAI,EAAE;wBACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;wBAC/C,IAAI,EAAE,OAAO;wBACb,MAAM,EAAE,SAAS;wBACjB,SAAS,EAAE,YAAY;wBACvB,MAAM;wBACN,KAAK;qBACL;iBACD,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\ttype IPolicyDecision,\n\ttype IPolicyExecutionAction,\n\ttype IRightsManagementPolicy,\n\tOdrlPolicyHelper,\n\tPolicyDecisionStage\n} from \"@twin.org/rights-management-models\";\nimport type { OdrlActionType } from \"@twin.org/standards-w3c-odrl\";\nimport type { ILoggingPolicyExecutionActionConstructorOptions } from \"../models/ILoggingPolicyExecutionActionConstructorOptions.js\";\n\n/**\n * Logging Policy Execution Action to send decisions to logging.\n */\nexport class LoggingPolicyExecutionAction implements IPolicyExecutionAction {\n\t/**\n\t * The class name of the Logging Policy Execution Action.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<LoggingPolicyExecutionAction>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging: ILoggingComponent;\n\n\t/**\n\t * The policy decision stages to log, if undefined defaults to all.\n\t * @internal\n\t */\n\tprivate readonly _stages: PolicyDecisionStage[];\n\n\t/**\n\t * Whether to include the data in the log.\n\t */\n\tprivate readonly _includeData: boolean;\n\n\t/**\n\t * Whether to include the policy in the log.\n\t */\n\tprivate readonly _includePolicy: boolean;\n\n\t/**\n\t * Whether to include the decisions in the log.\n\t */\n\tprivate readonly _includeDecisions: boolean;\n\n\t/**\n\t * Create a new instance of LoggingPolicyExecutionAction.\n\t * @param options The options for the logging policy execution action.\n\t */\n\tconstructor(options?: ILoggingPolicyExecutionActionConstructorOptions) {\n\t\tthis._logging = ComponentFactory.get<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\n\t\tthis._stages = options?.config?.stages ?? [\n\t\t\tPolicyDecisionStage.Before,\n\t\t\tPolicyDecisionStage.After\n\t\t];\n\t\tthis._includeData = options?.config?.includeData ?? false;\n\t\tthis._includePolicy = options?.config?.includePolicy ?? false;\n\t\tthis._includeDecisions = options?.config?.includeDecisions ?? false;\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 LoggingPolicyExecutionAction.CLASS_NAME;\n\t}\n\n\t/**\n\t * Which stages should the action be executed at.\n\t * @returns List of stages.\n\t */\n\tpublic supportedStages(): PolicyDecisionStage[] {\n\t\treturn this._stages;\n\t}\n\n\t/**\n\t * Execute function type for policy actions.\n\t * @param policy The policy that applied to the data.\n\t * @param decisions The decisions made by the PDP.\n\t * @param data The data to process.\n\t * @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.\n\t * @param stage The stage of the policy decision.\n\t * @returns A promise that resolves when the action is complete.\n\t */\n\tpublic async execute<D = unknown>(\n\t\tpolicy: IRightsManagementPolicy,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata: D | undefined,\n\t\taction: OdrlActionType | string,\n\t\tstage: PolicyDecisionStage\n\t): Promise<void> {\n\t\tGuards.arrayOneOf(\n\t\t\tLoggingPolicyExecutionAction.CLASS_NAME,\n\t\t\tnameof(stage),\n\t\t\tstage,\n\t\t\tObject.values(PolicyDecisionStage)\n\t\t);\n\n\t\tif (this._stages.includes(stage)) {\n\t\t\t// Even if we don't have the options to include data or include policy we\n\t\t\t// still create dummy entries, as the logging string still has them embedded\n\t\t\tlet logData;\n\t\t\tif (!Is.empty(data)) {\n\t\t\t\tlogData = this._includeData ? data : \"{...}\";\n\t\t\t}\n\t\t\tconst logPolicy = this._includePolicy ? policy : \"{}\";\n\t\t\tconst logDecisions = this._includeDecisions ? decisions : \"[...]\";\n\n\t\t\tif (stage === PolicyDecisionStage.Before) {\n\t\t\t\tawait this._logging.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tsource: LoggingPolicyExecutionAction.CLASS_NAME,\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"policyActionExecutedBefore\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\t\tdata: logData,\n\t\t\t\t\t\tpolicy: logPolicy,\n\t\t\t\t\t\tdecisions: logDecisions,\n\t\t\t\t\t\taction,\n\t\t\t\t\t\tstage\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tawait this._logging.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tsource: LoggingPolicyExecutionAction.CLASS_NAME,\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"policyActionExecutedAfter\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\t\tdata: logData,\n\t\t\t\t\t\tpolicy: logPolicy,\n\t\t\t\t\t\tdecisions: logDecisions,\n\t\t\t\t\t\taction,\n\t\t\t\t\t\tstage\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +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,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAA0B,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI9E,OAAO,
|
|
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,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAA0B,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI9E,OAAO,EAGN,gBAAgB,EAChB,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,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AG,EAAE,CAAC;oBACd,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;wBACxB,KAAK,EAAE,OAAO;wBACd,MAAM,EAAE,+BAA+B,CAAC,UAAU;wBAClD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;wBACd,OAAO,EAAE,yBAAyB;wBAClC,IAAI,EAAE;4BACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;4BAC/C,EAAE;yBACF;wBACD,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC;qBAC/B,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,WAAW,CAAC;IACpB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport { type IJsonLdNodeObject, JsonLdHelper } 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 IRightsManagementPolicy,\n\tOdrlPolicyHelper,\n\tPolicyInformationAccessMode\n} from \"@twin.org/rights-management-models\";\nimport type { OdrlActionType } 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 policy The policy to retrieve information for if available.\n\t * @param accessMode The access mode to use for the retrieval.\n\t * @param data The data to process.\n\t * @param action The action that was evaluated.\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\tpolicy: IRightsManagementPolicy | undefined,\n\t\taccessMode: PolicyInformationAccessMode,\n\t\tdata?: D,\n\t\taction?: OdrlActionType | string\n\t): Promise<{ [id: string]: IJsonLdNodeObject } | undefined> {\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\n\t\tconst information: { [id: string]: IJsonLdNodeObject } = {};\n\n\t\tif (Is.object<IRightsManagementPolicy>(policy)) {\n\t\t\tconst ids = [];\n\n\t\t\tif (Is.stringValue(policy.assignee)) {\n\t\t\t\tids.push(policy.assignee);\n\t\t\t}\n\t\t\tif (Is.stringValue(policy.assigner)) {\n\t\t\t\tids.push(policy.assigner);\n\t\t\t}\n\n\t\t\tfor (const id of ids) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\t\tsource: IdentityPolicyInformationSource.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"identityRetrieving\",\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tconst idDoc = await this._identityResolver.identityResolve(id);\n\t\t\t\t\tinformation[id] = JsonLdHelper.toNodeObject(idDoc);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\tsource: IdentityPolicyInformationSource.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"identityRetrievalFailed\",\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror: BaseError.fromError(err)\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn information;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticPolicyInformationSource.js","sourceRoot":"","sources":["../../../src/policyInformationSources/staticPolicyInformationSource.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAI9D,OAAO,EACN,gBAAgB,EAChB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"staticPolicyInformationSource.js","sourceRoot":"","sources":["../../../src/policyInformationSources/staticPolicyInformationSource.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAI9D,OAAO,EACN,gBAAgB,EAChB,2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\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\tOdrlPolicyHelper,\n\tPolicyInformationAccessMode,\n\ttype IPolicyInformationSource,\n\ttype IRightsManagementPolicy\n} from \"@twin.org/rights-management-models\";\nimport type { OdrlActionType } 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 policy The policy to retrieve information for if available.\n\t * @param accessMode The access mode to use for the retrieval.\n\t * @param data The data to process.\n\t * @param action The action to get any additional information for.\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\tpolicy: IRightsManagementPolicy | undefined,\n\t\taccessMode: PolicyInformationAccessMode,\n\t\tdata?: D,\n\t\taction?: OdrlActionType | string\n\t): Promise<{ [id: string]: IJsonLdNodeObject } | undefined> {\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\n\t\tlet information: { [id: string]: 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\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\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\tconst matchLocators = info.matchLocators;\n\t\t\t\tif (\n\t\t\t\t\t!Is.arrayValue(matchLocators) ||\n\t\t\t\t\tmatchLocators.some(locator => OdrlPolicyHelper.matchPolicy(policy, locator))\n\t\t\t\t) {\n\t\t\t\t\tinformation = {\n\t\t\t\t\t\t...information,\n\t\t\t\t\t\t...info.objects\n\t\t\t\t\t};\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\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\taccessMode,\n\t\t\t\titemCount: Object.keys(information).length\n\t\t\t}\n\t\t});\n\n\t\treturn Object.keys(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.objectValue<{ [id: string]: 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"]}
|
|
@@ -1 +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,
|
|
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"]}
|
|
@@ -11,6 +11,12 @@ export declare class DefaultPolicyArbiter implements IPolicyArbiter {
|
|
|
11
11
|
* The class name of the Default Policy Arbiter.
|
|
12
12
|
*/
|
|
13
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>;
|
|
14
20
|
/**
|
|
15
21
|
* Create a new instance of DefaultPolicyArbiter.
|
|
16
22
|
* @param options The options for the default policy arbiter.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type IPolicyDecision, type IPolicyExecutionAction, PolicyDecisionStage } from "@twin.org/rights-management-models";
|
|
2
|
-
import type { IDataspaceProtocolPolicy } from "@twin.org/standards-dataspace-protocol";
|
|
1
|
+
import { type IPolicyDecision, type IPolicyExecutionAction, type IRightsManagementPolicy, PolicyDecisionStage } from "@twin.org/rights-management-models";
|
|
3
2
|
import type { OdrlActionType } from "@twin.org/standards-w3c-odrl";
|
|
4
3
|
import type { ILoggingPolicyExecutionActionConstructorOptions } from "../models/ILoggingPolicyExecutionActionConstructorOptions.js";
|
|
5
4
|
/**
|
|
@@ -46,5 +45,5 @@ export declare class LoggingPolicyExecutionAction implements IPolicyExecutionAct
|
|
|
46
45
|
* @param stage The stage of the policy decision.
|
|
47
46
|
* @returns A promise that resolves when the action is complete.
|
|
48
47
|
*/
|
|
49
|
-
execute<D = unknown>(policy:
|
|
48
|
+
execute<D = unknown>(policy: IRightsManagementPolicy, decisions: IPolicyDecision[], data: D | undefined, action: OdrlActionType | string, stage: PolicyDecisionStage): Promise<void>;
|
|
50
49
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
-
import { type IPolicyInformationSource, PolicyInformationAccessMode } from "@twin.org/rights-management-models";
|
|
3
|
-
import type { IDataspaceProtocolPolicy } from "@twin.org/standards-dataspace-protocol";
|
|
2
|
+
import { type IPolicyInformationSource, type IRightsManagementPolicy, PolicyInformationAccessMode } from "@twin.org/rights-management-models";
|
|
4
3
|
import type { OdrlActionType } from "@twin.org/standards-w3c-odrl";
|
|
5
4
|
import type { IIdentityPolicyInformationSourceConstructorOptions } from "../models/IIdentityPolicyInformationSourceConstructorOptions.js";
|
|
6
5
|
/**
|
|
@@ -29,7 +28,7 @@ export declare class IdentityPolicyInformationSource implements IPolicyInformati
|
|
|
29
28
|
* @param action The action that was evaluated.
|
|
30
29
|
* @returns The objects containing relevant information or undefined if nothing relevant is found.
|
|
31
30
|
*/
|
|
32
|
-
retrieve<D = unknown>(policy:
|
|
31
|
+
retrieve<D = unknown>(policy: IRightsManagementPolicy | undefined, accessMode: PolicyInformationAccessMode, data?: D, action?: OdrlActionType | string): Promise<{
|
|
33
32
|
[id: string]: IJsonLdNodeObject;
|
|
34
33
|
} | undefined>;
|
|
35
34
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
-
import { PolicyInformationAccessMode, type IPolicyInformationSource } from "@twin.org/rights-management-models";
|
|
3
|
-
import type { IDataspaceProtocolPolicy } from "@twin.org/standards-dataspace-protocol";
|
|
2
|
+
import { PolicyInformationAccessMode, type IPolicyInformationSource, type IRightsManagementPolicy } from "@twin.org/rights-management-models";
|
|
4
3
|
import type { OdrlActionType } from "@twin.org/standards-w3c-odrl";
|
|
5
4
|
import type { IStaticPolicyInformationSource } from "../models/IStaticPolicyInformationSource.js";
|
|
6
5
|
import type { IStaticPolicyInformationSourceConstructorOptions } from "../models/IStaticPolicyInformationSourceConstructorOptions.js";
|
|
@@ -30,7 +29,7 @@ export declare class StaticPolicyInformationSource implements IPolicyInformation
|
|
|
30
29
|
* @param action The action to get any additional information for.
|
|
31
30
|
* @returns The objects containing relevant information or undefined if nothing relevant is found.
|
|
32
31
|
*/
|
|
33
|
-
retrieve<D = unknown>(policy:
|
|
32
|
+
retrieve<D = unknown>(policy: IRightsManagementPolicy | undefined, accessMode: PolicyInformationAccessMode, data?: D, action?: OdrlActionType | string): Promise<{
|
|
34
33
|
[id: string]: IJsonLdNodeObject;
|
|
35
34
|
} | undefined>;
|
|
36
35
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
-
import { type IPolicyObligationEnforcer } from "@twin.org/rights-management-models";
|
|
3
|
-
import type { IDataspaceProtocolPolicy } from "@twin.org/standards-dataspace-protocol";
|
|
2
|
+
import { type IPolicyObligationEnforcer, type IRightsManagementPolicy } from "@twin.org/rights-management-models";
|
|
4
3
|
import type { OdrlActionType, IOdrlDuty } from "@twin.org/standards-w3c-odrl";
|
|
5
4
|
import type { IPassThroughPolicyObligationEnforcerConstructorOptions } from "../models/IPassThroughPolicyObligationEnforcerConstructorOptions.js";
|
|
6
5
|
/**
|
|
@@ -30,7 +29,7 @@ export declare class PassThroughPolicyObligationEnforcer implements IPolicyOblig
|
|
|
30
29
|
* @param action Optional action to make a decision on, if not provided, the enforcer will evaluate all actions in the duty.
|
|
31
30
|
* @returns Whether the obligations were successfully enforced.
|
|
32
31
|
*/
|
|
33
|
-
enforce<D = unknown>(policy:
|
|
32
|
+
enforce<D = unknown>(policy: IRightsManagementPolicy, duty: IOdrlDuty, information?: {
|
|
34
33
|
[id: string]: IJsonLdNodeObject;
|
|
35
34
|
}, data?: D, action?: OdrlActionType | string): Promise<boolean>;
|
|
36
35
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.28](https://github.com/twinfoundation/rights-management/compare/rights-management-plugins-v0.0.3-next.27...rights-management-plugins-v0.0.3-next.28) (2026-04-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add EcosystemPolicy typed getter across PAP stack ([#114](https://github.com/twinfoundation/rights-management/issues/114)) ([2a8e941](https://github.com/twinfoundation/rights-management/commit/2a8e941bbea229fb74f81dc869ce1f85c66c300d))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/rights-management-models bumped from 0.0.3-next.27 to 0.0.3-next.28
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.3-next.27 to 0.0.3-next.28
|
|
18
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.3-next.27 to 0.0.3-next.28
|
|
19
|
+
* @twin.org/rights-management-pep-service bumped from 0.0.3-next.27 to 0.0.3-next.28
|
|
20
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.3-next.27 to 0.0.3-next.28
|
|
21
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.3-next.27 to 0.0.3-next.28
|
|
22
|
+
* @twin.org/rights-management-pnp-service bumped from 0.0.3-next.27 to 0.0.3-next.28
|
|
23
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.3-next.27 to 0.0.3-next.28
|
|
24
|
+
|
|
25
|
+
## [0.0.3-next.27](https://github.com/twinfoundation/rights-management/compare/rights-management-plugins-v0.0.3-next.26...rights-management-plugins-v0.0.3-next.27) (2026-03-31)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Miscellaneous Chores
|
|
29
|
+
|
|
30
|
+
* **rights-management-plugins:** Synchronize repo versions
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Dependencies
|
|
34
|
+
|
|
35
|
+
* The following workspace dependencies were updated
|
|
36
|
+
* dependencies
|
|
37
|
+
* @twin.org/rights-management-models bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
38
|
+
* devDependencies
|
|
39
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
40
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
41
|
+
* @twin.org/rights-management-pep-service bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
42
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
43
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
44
|
+
* @twin.org/rights-management-pnp-service bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
45
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
46
|
+
|
|
3
47
|
## [0.0.3-next.26](https://github.com/twinfoundation/rights-management/compare/rights-management-plugins-v0.0.3-next.25...rights-management-plugins-v0.0.3-next.26) (2026-03-27)
|
|
4
48
|
|
|
5
49
|
|
package/docs/examples.md
CHANGED
|
@@ -176,6 +176,35 @@ console.log(arbiter.className()); // DefaultPolicyArbiter
|
|
|
176
176
|
console.log(decisions[0].decision); // granted
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
+
```typescript
|
|
180
|
+
import { DefaultPolicyArbiter } from '@twin.org/rights-management-plugins';
|
|
181
|
+
import { OdrlPolicyType, OdrlProfiles } from '@twin.org/standards-w3c-odrl';
|
|
182
|
+
|
|
183
|
+
const arbiter = new DefaultPolicyArbiter();
|
|
184
|
+
|
|
185
|
+
// EcosystemPolicy with the TWIN profile — the arbiter evaluates its obligations directly.
|
|
186
|
+
const ecosystemDecisions = await arbiter.decide(
|
|
187
|
+
{
|
|
188
|
+
'@id': 'urn:rights-management:ecosystem-policy-1',
|
|
189
|
+
'@type': OdrlPolicyType.EcosystemPolicy,
|
|
190
|
+
profile: OdrlProfiles.Twin,
|
|
191
|
+
assigner: 'did:example:publisher',
|
|
192
|
+
obligation: [
|
|
193
|
+
{
|
|
194
|
+
action: 'inform',
|
|
195
|
+
assignee: 'did:example:border-agency',
|
|
196
|
+
target: 'urn:twin:asset:consignment:abc123'
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
{},
|
|
201
|
+
{ consignment: 'abc123' },
|
|
202
|
+
'inform'
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
console.log(ecosystemDecisions[0].decision); // granted
|
|
206
|
+
```
|
|
207
|
+
|
|
179
208
|
## PassThroughPolicyArbiter
|
|
180
209
|
|
|
181
210
|
```typescript
|
|
@@ -34,6 +34,16 @@ The options for the default policy arbiter.
|
|
|
34
34
|
|
|
35
35
|
The class name of the Default Policy Arbiter.
|
|
36
36
|
|
|
37
|
+
***
|
|
38
|
+
|
|
39
|
+
### SUPPORTED\_PROFILES {#supported_profiles}
|
|
40
|
+
|
|
41
|
+
> `readonly` `static` **SUPPORTED\_PROFILES**: `ReadonlySet`\<`string`\>
|
|
42
|
+
|
|
43
|
+
ODRL profiles whose custom vocabulary this arbiter understands and supports.
|
|
44
|
+
Any policy declaring a profile not in this set will be rejected.
|
|
45
|
+
Add a new entry here when support for an additional profile is implemented.
|
|
46
|
+
|
|
37
47
|
## Methods
|
|
38
48
|
|
|
39
49
|
### className() {#classname}
|
package/locales/en.json
CHANGED
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"constraintDataTypeNotSupported": "Constraint dataType is not supported. Value coercion based on dataType is not implemented.",
|
|
23
23
|
"constraintUnitNotSupported": "Constraint unit is not supported. Unit-aware comparison is not implemented.",
|
|
24
24
|
"constraintStatusNotSupported": "Constraint status is not supported. State-based evaluation is not implemented.",
|
|
25
|
-
"policyProfileNotSupported": "Policy \"{policyId}\" declares
|
|
25
|
+
"policyProfileNotSupported": "Policy \"{policyId}\" declares unsupported profile \"{unsupportedProfile}\". Only known profiles are supported.",
|
|
26
|
+
"inheritedPolicyProfileNotSupported": "Inherited policy \"{policyId}\" declares an unsupported profile. All policies in the inheritFrom chain must declare only supported profiles."
|
|
26
27
|
},
|
|
27
28
|
"defaultPolicyEnforcementProcessor": {
|
|
28
29
|
"targetNotJsonPath": "The policy decision target \"{target}\" is not a valid JSON-path string, it should be a minimum of $.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/rights-management-plugins",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.28",
|
|
4
4
|
"description": "Plugin implementations for extending rights management behaviour across components.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@twin.org/data-json-path": "next",
|
|
25
25
|
"@twin.org/logging-models": "next",
|
|
26
26
|
"@twin.org/nameof": "next",
|
|
27
|
-
"@twin.org/rights-management-models": "0.0.3-next.
|
|
27
|
+
"@twin.org/rights-management-models": "0.0.3-next.28",
|
|
28
28
|
"@twin.org/standards-w3c-odrl": "next"
|
|
29
29
|
},
|
|
30
30
|
"main": "./dist/es/index.js",
|