@twin.org/rights-management-plugins 0.0.3-next.14 → 0.0.3-next.17
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 +8 -22
- package/dist/es/policyArbiters/defaultPolicyArbiter.js.map +1 -1
- package/dist/es/policyArbiters/passThroughPolicyArbiter.js +2 -2
- package/dist/es/policyArbiters/passThroughPolicyArbiter.js.map +1 -1
- package/dist/es/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.js +2 -2
- package/dist/es/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.js.map +1 -1
- package/dist/es/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.js +2 -1
- package/dist/es/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.js.map +1 -1
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js +3 -3
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js.map +1 -1
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js +3 -3
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js.map +1 -1
- package/dist/es/policyInformationSources/staticPolicyInformationSource.js +2 -2
- package/dist/es/policyInformationSources/staticPolicyInformationSource.js.map +1 -1
- package/dist/es/policyNegotiators/passThroughPolicyNegotiator.js +4 -3
- package/dist/es/policyNegotiators/passThroughPolicyNegotiator.js.map +1 -1
- package/dist/es/policyObligationEnforcers/passThroughPolicyObligationEnforcer.js +2 -1
- package/dist/es/policyObligationEnforcers/passThroughPolicyObligationEnforcer.js.map +1 -1
- package/dist/es/policyRequesters/passThroughPolicyRequester.js +3 -2
- package/dist/es/policyRequesters/passThroughPolicyRequester.js.map +1 -1
- package/dist/types/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.d.ts +1 -1
- package/dist/types/policyNegotiators/passThroughPolicyNegotiator.d.ts +1 -1
- package/dist/types/policyObligationEnforcers/passThroughPolicyObligationEnforcer.d.ts +1 -1
- package/dist/types/policyRequesters/passThroughPolicyRequester.d.ts +1 -1
- package/docs/changelog.md +74 -0
- package/package.json +2 -2
|
@@ -81,7 +81,7 @@ export class DefaultPolicyArbiter {
|
|
|
81
81
|
ts: Date.now(),
|
|
82
82
|
message: "decidingPolicy",
|
|
83
83
|
data: {
|
|
84
|
-
policyId: agreement
|
|
84
|
+
policyId: OdrlPolicyHelper.getUid(agreement) ?? ""
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
// Resolve and merge inherited policies.
|
|
@@ -164,7 +164,7 @@ export class DefaultPolicyArbiter {
|
|
|
164
164
|
*/
|
|
165
165
|
async mergeInheritedPolicies(policy) {
|
|
166
166
|
const visitedPolicyIds = [];
|
|
167
|
-
visitedPolicyIds.push(policy
|
|
167
|
+
visitedPolicyIds.push(OdrlPolicyHelper.getUid(policy) ?? "");
|
|
168
168
|
const inheritedPolicies = await this.resolveInheritedPolicies(policy, visitedPolicyIds, 0);
|
|
169
169
|
const conflictStrategies = new Set();
|
|
170
170
|
if (Is.stringValue(policy.conflict)) {
|
|
@@ -229,7 +229,7 @@ export class DefaultPolicyArbiter {
|
|
|
229
229
|
const nextDepth = currentDepth + 1;
|
|
230
230
|
if (nextDepth > this._maxInheritanceDepth) {
|
|
231
231
|
throw new GeneralError(DefaultPolicyArbiter.CLASS_NAME, "maxInheritanceDepthExceeded", {
|
|
232
|
-
policyId: policy
|
|
232
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
233
233
|
inheritFromId,
|
|
234
234
|
maxInheritanceDepth: this._maxInheritanceDepth
|
|
235
235
|
});
|
|
@@ -237,7 +237,7 @@ export class DefaultPolicyArbiter {
|
|
|
237
237
|
// Check for circular inheritance
|
|
238
238
|
if (visitedPolicyIds.includes(inheritFromId)) {
|
|
239
239
|
throw new GeneralError(DefaultPolicyArbiter.CLASS_NAME, "circularInheritanceDetected", {
|
|
240
|
-
policyId: policy
|
|
240
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
241
241
|
inheritFromId
|
|
242
242
|
});
|
|
243
243
|
}
|
|
@@ -365,13 +365,10 @@ export class DefaultPolicyArbiter {
|
|
|
365
365
|
const ruleActionArray = ArrayHelper.fromObjectOrArray(ruleActions) ?? [];
|
|
366
366
|
// Check if the requested action matches any of the rule's actions
|
|
367
367
|
for (const ruleAction of ruleActionArray) {
|
|
368
|
-
const ruleActionId = Is.string(ruleAction)
|
|
369
|
-
? ruleAction
|
|
370
|
-
: (ruleAction.uid ?? ruleAction["@id"]);
|
|
368
|
+
const ruleActionId = Is.string(ruleAction) ? ruleAction : OdrlPolicyHelper.getUid(ruleAction);
|
|
371
369
|
const requestedActionId = Is.string(requestedAction)
|
|
372
370
|
? requestedAction
|
|
373
|
-
: (requestedAction
|
|
374
|
-
requestedAction?.["@id"]);
|
|
371
|
+
: OdrlPolicyHelper.getUid(requestedAction);
|
|
375
372
|
if (Is.stringValue(ruleActionId) && Is.stringValue(requestedActionId)) {
|
|
376
373
|
if (ruleActionId === requestedActionId) {
|
|
377
374
|
return true;
|
|
@@ -498,7 +495,7 @@ export class DefaultPolicyArbiter {
|
|
|
498
495
|
if (arr.length === 0) {
|
|
499
496
|
return undefined;
|
|
500
497
|
}
|
|
501
|
-
return Is.string(arr[0]) ? arr[0] : arr[0]
|
|
498
|
+
return Is.string(arr[0]) ? arr[0] : OdrlPolicyHelper.getUid(arr[0]);
|
|
502
499
|
}
|
|
503
500
|
/**
|
|
504
501
|
* Evaluate a single ODRL constraint against the available context.
|
|
@@ -575,18 +572,7 @@ export class DefaultPolicyArbiter {
|
|
|
575
572
|
const seenIdentifiers = new Set();
|
|
576
573
|
for (let i = 0; i < constraints.length; i++) {
|
|
577
574
|
const constraint = constraints[i];
|
|
578
|
-
|
|
579
|
-
// Try to get identifier from uid property
|
|
580
|
-
if (Is.stringValue(constraint.uid)) {
|
|
581
|
-
identifier = constraint.uid;
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
// Try to get identifier from @id property (JSON-LD)
|
|
585
|
-
const jsonLdId = constraint["@id"];
|
|
586
|
-
if (Is.stringValue(jsonLdId)) {
|
|
587
|
-
identifier = jsonLdId;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
575
|
+
const identifier = OdrlPolicyHelper.getUid(constraint);
|
|
590
576
|
// If we have an identifier, check for duplicates
|
|
591
577
|
if (Is.stringValue(identifier)) {
|
|
592
578
|
if (seenIdentifiers.has(identifier)) {
|
|
@@ -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;AAC5C,OAAO,EACN,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EAWZ,MAAM,8BAA8B,CAAC;AAGtC;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAChC;;OAEG;IACI,MAAM,CAAU,UAAU,0BAA0C;IAE3E;;;OAGG;IACK,MAAM,CAAU,eAAe,GAAG,UAAU,CAAC;IAErD;;;OAGG;IACK,MAAM,CAAU,yBAAyB,GAAG,QAAQ,oBAAoB,CAAC,eAAe,EAAE,CAAC;IAEnG;;;OAGG;IACK,MAAM,CAAU,0BAA0B,GAAG,mBAAmB,CAAC;IAEzE;;;OAGG;IACK,MAAM,CAAU,8BAA8B,GAAG,EAAE,CAAC;IAE5D;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACc,0BAA0B,CAAsC;IAEjF;;;OAGG;IACc,oBAAoB,CAAS;IAE9C;;;OAGG;IACH,YA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AE,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 {\n\tConflictStrategyType,\n\tLogicalConstraintType,\n\tOperatorType,\n\ttype ActionType,\n\ttype IOdrlAgreement,\n\ttype IOdrlConstraint,\n\ttype IOdrlDuty,\n\ttype IOdrlLogicalConstraint,\n\ttype IOdrlLogicalConstraintOperand,\n\ttype IOdrlPermission,\n\ttype IOdrlPolicy,\n\ttype IOdrlProhibition,\n\ttype IOdrlRule\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 * Type indicating the operand type is JSONPath.\n\t * @internal\n\t */\n\tprivate static readonly _JSON_PATH_TYPE = \"jsonpath\";\n\n\t/**\n\t * Prefix indicating the operand encodes a JSONPath.\n\t * @internal\n\t */\n\tprivate static readonly _JSON_PATH_OPERAND_PREFIX = `twin:${DefaultPolicyArbiter._JSON_PATH_TYPE}`;\n\n\t/**\n\t * Prefix indicating the permission target references an item in the information map.\n\t * @internal\n\t */\n\tprivate static readonly _INFORMATION_TARGET_PREFIX = \"twin:information:\";\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 * 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: IOdrlAgreement,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: D,\n\t\taction?: ActionType | string\n\t): Promise<IPolicyDecision[]> {\n\t\tGuards.object<IOdrlAgreement>(DefaultPolicyArbiter.CLASS_NAME, nameof(agreement), agreement);\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: agreement.uid\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\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\n\t\t// ODRL-style rule evaluation:\n\t\t// - Permission rules authorize if ANY applicable permission matches (OR across permissions).\n\t\t// - Default to denied when there are no permissions (closed-world for access control).\n\t\t// - Conflict strategy controls how applicable permissions/prohibitions are resolved.\n\t\tconst permissions = ArrayHelper.fromObjectOrArray(mergedPolicy.permission ?? []);\n\t\tlet permissionApplies = false;\n\t\tif (permissions.length > 0) {\n\t\t\tfor (const permission of permissions) {\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\tmergedPolicy,\n\t\t\t\t\t\tpermission,\n\t\t\t\t\t\tinformation,\n\t\t\t\t\t\tdata,\n\t\t\t\t\t\taction\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tpermissionApplies = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst prohibitions = ArrayHelper.fromObjectOrArray<IOdrlProhibition>(\n\t\t\tmergedPolicy.prohibition ?? []\n\t\t);\n\t\tlet prohibitionApplies = false;\n\t\tfor (const prohibition of prohibitions) {\n\t\t\tif (\n\t\t\t\tthis.evaluateProhibition(agreementAssigner, agreementAssignee, prohibition, data, action)\n\t\t\t) {\n\t\t\t\tprohibitionApplies = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst conflictStrategy = mergedPolicy.conflict ?? ConflictStrategyType.Invalid;\n\t\tlet decision: PolicyDecision;\n\t\tif (permissionApplies && prohibitionApplies) {\n\t\t\tswitch (conflictStrategy) {\n\t\t\t\tcase ConflictStrategyType.Perm:\n\t\t\t\t\tdecision = PolicyDecision.Granted;\n\t\t\t\t\tbreak;\n\t\t\t\tcase ConflictStrategyType.Prohibit:\n\t\t\t\tcase ConflictStrategyType.Invalid:\n\t\t\t\tdefault:\n\t\t\t\t\tdecision = PolicyDecision.Denied;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tdecision = permissionApplies ? PolicyDecision.Granted : PolicyDecision.Denied;\n\t\t}\n\n\t\treturn [{ target: \"$\", decision }];\n\t}\n\n\t/**\n\t * Evaluate whether a prohibition applies.\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 data The request data/context.\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 evaluateProhibition(\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tprohibition: IOdrlProhibition,\n\t\tdata?: unknown,\n\t\taction?: ActionType | string\n\t): boolean {\n\t\tif (!this.isRuleApplicableToParties(prohibition, agreementAssigner, agreementAssignee)) {\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)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// ODRL semantics: a rule without constraints is unconditional.\n\t\tconst constraints = ArrayHelper.fromObjectOrArray(prohibition.constraint ?? []);\n\t\tif (constraints.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn constraints.every(c => this.evaluateConstraint(c, data));\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(policy: IOdrlPolicy): Promise<IOdrlPolicy> {\n\t\tconst visitedPolicyIds: string[] = [];\n\t\tvisitedPolicyIds.push(policy.uid);\n\t\tconst inheritedPolicies = await this.resolveInheritedPolicies(policy, visitedPolicyIds, 0);\n\t\tconst conflictStrategies = new Set<string>();\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.applyPolicyPartiesToRule(policy, permission));\n\n\t\tconst mergedProhibitions: IOdrlProhibition[] = ArrayHelper.fromObjectOrArray(\n\t\t\tpolicy.prohibition ?? []\n\t\t).map(prohibition => this.applyPolicyPartiesToRule(policy, prohibition));\n\n\t\tconst mergedObligations: IOdrlDuty[] = ArrayHelper.fromObjectOrArray(\n\t\t\tpolicy.obligation ?? []\n\t\t).map(obligation => this.applyPolicyPartiesToRule(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.applyPolicyPartiesToRule(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.applyPolicyPartiesToRule(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.applyPolicyPartiesToRule(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: IOdrlPolicy[\"conflict\"] | undefined;\n\t\tif (conflictStrategies.size === 1) {\n\t\t\tmergedConflict = Array.from(conflictStrategies)[0] as IOdrlPolicy[\"conflict\"];\n\t\t} else if (conflictStrategies.size > 1) {\n\t\t\tmergedConflict = ConflictStrategyType.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 * Detects circular inheritance and throws an exception if detected.\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 * @throws GeneralError if a parent policy cannot be found or if circular inheritance is detected.\n\t * @internal\n\t */\n\tprivate async resolveInheritedPolicies(\n\t\tpolicy: IOdrlPolicy,\n\t\tvisitedPolicyIds: string[],\n\t\tcurrentDepth: number\n\t): Promise<IOdrlPolicy[]> {\n\t\tconst inheritedPolicies: IOdrlPolicy[] = [];\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: policy.uid,\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: policy.uid,\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 assigner/assignee values 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 assigner/assignee applied.\n\t * @internal\n\t */\n\tprivate applyPolicyPartiesToRule<T extends IOdrlRule>(policy: IOdrlPolicy, rule: 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\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\tif (assignerEqual && assigneeEqual) {\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};\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): boolean {\n\t\tconst ruleAssigners = OdrlPolicyHelper.getPartyIds(rule.assigner);\n\t\tconst ruleAssignees = OdrlPolicyHelper.getPartyIds(rule.assignee);\n\n\t\tif (!this.isPartyApplicable(ruleAssigners, agreementAssigner)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!this.isPartyApplicable(ruleAssignees, agreementAssignee)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\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 * 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?: ActionType | string\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\t// Both rule actions and requested action are specified - check for match\n\t\tconst ruleActionArray = ArrayHelper.fromObjectOrArray(ruleActions) ?? [];\n\n\t\t// Check if the requested action matches any of the rule's actions\n\t\tfor (const ruleAction of ruleActionArray) {\n\t\t\tconst ruleActionId = Is.string(ruleAction)\n\t\t\t\t? ruleAction\n\t\t\t\t: ((ruleAction as IJsonLdNodeObject).uid ?? (ruleAction as IJsonLdNodeObject)[\"@id\"]);\n\t\t\tconst requestedActionId = Is.string(requestedAction)\n\t\t\t\t? requestedAction\n\t\t\t\t: ((requestedAction as IJsonLdNodeObject)?.uid ??\n\t\t\t\t\t(requestedAction as IJsonLdNodeObject)?.[\"@id\"]);\n\n\t\t\tif (Is.stringValue(ruleActionId) && Is.stringValue(requestedActionId)) {\n\t\t\t\tif (ruleActionId === requestedActionId) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn false;\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 information Additional facts provided by the PIP.\n\t * @param data The request data/context.\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: IOdrlPolicy,\n\t\tpermission: IOdrlPermission,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: unknown,\n\t\taction?: ActionType | string\n\t): Promise<boolean> {\n\t\tif (!this.isRuleApplicableToParties(permission, agreementAssigner, agreementAssignee)) {\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)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// ODRL semantics: a Permission without constraints is unconditional.\n\t\tconst constraints = ArrayHelper.fromObjectOrArray(permission.constraint ?? []);\n\t\tif (constraints.length === 0) {\n\t\t\treturn this.enforcePermissionDuties(policy, permission, information, data);\n\t\t}\n\n\t\t// Resolve the data context for evaluating this permission.\n\t\t// If the target starts with twin:information:<key>, the key references an entry in the information map.\n\t\tconst ruleDataContext = this.resolveRuleDataContext(permission, information, data);\n\n\t\t// All constraints must be satisfied for the permission to apply.\n\t\tconst constraintsSatisfied = constraints.every(c =>\n\t\t\tthis.evaluateConstraint(c, ruleDataContext)\n\t\t);\n\n\t\tif (!constraintsSatisfied) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.enforcePermissionDuties(policy, permission, information, 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 information Additional facts provided by the PIP.\n\t * @param data The request data/context.\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: IOdrlPolicy,\n\t\tpermission: IOdrlPermission,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: 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, information, data);\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 information Additional facts provided by the PIP.\n\t * @param data The request data/context.\n\t * @returns True if any enforcer succeeds.\n\t * @internal\n\t */\n\tprivate async enforceDuty(\n\t\tpolicy: IOdrlPolicy,\n\t\tduty: IOdrlDuty,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: unknown\n\t): Promise<boolean> {\n\t\tconst enforcerNames = PolicyObligationEnforcerFactory.names();\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, data)) {\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 * Resolve the data context used when evaluating a permission's constraints.\n\t * If the permission target is `twin:information:<key>`, the key references an entry in the information map.\n\t * @param rule The permission being evaluated.\n\t * @param information Additional facts provided by the PIP.\n\t * @param data The request data/context.\n\t * @returns The data context to use for JSONPath resolution.\n\t * @throws GeneralError When the information target key is missing.\n\t * @internal\n\t */\n\tprivate resolveRuleDataContext(\n\t\trule: IOdrlRule,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: unknown\n\t): unknown {\n\t\tconst targetId = this.getTargetId(rule.target);\n\n\t\tif (targetId?.startsWith(DefaultPolicyArbiter._INFORMATION_TARGET_PREFIX)) {\n\t\t\tconst key = targetId.slice(DefaultPolicyArbiter._INFORMATION_TARGET_PREFIX.length);\n\t\t\tif (Is.empty(key) || Is.empty(information?.[key])) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"informationTargetMissing\", {\n\t\t\t\t\tkey\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn information[key];\n\t\t}\n\n\t\treturn data;\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: IOdrlPermission[\"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] : arr[0].uid;\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 ruleDataContext The request data/context.\n\t * @returns True if the constraint is satisfied.\n\t * @internal\n\t */\n\tprivate evaluateConstraint(\n\t\tconstraint: IOdrlConstraint | IOdrlLogicalConstraint,\n\t\truleDataContext?: unknown\n\t): boolean {\n\t\tconst logicalConstraint = this.getLogicalConstraintOperands(constraint);\n\t\tif (logicalConstraint) {\n\t\t\treturn this.evaluateLogicalConstraint(logicalConstraint, ruleDataContext);\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// Evaluate the main constraint condition\n\t\tconst leftValue = this.calculateOperandValue(regularConstraint.leftOperand, ruleDataContext);\n\t\tconst rightValue = this.calculateOperandValue(regularConstraint.rightOperand, ruleDataContext);\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: LogicalConstraintType;\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: LogicalConstraintType[] = Object.values(LogicalConstraintType);\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: LogicalConstraintType\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\tlet identifier: string | undefined;\n\n\t\t\t// Try to get identifier from uid property\n\t\t\tif (Is.stringValue((constraint as IOdrlConstraint).uid)) {\n\t\t\t\tidentifier = (constraint as IOdrlConstraint).uid;\n\t\t\t} else {\n\t\t\t\t// Try to get identifier from @id property (JSON-LD)\n\t\t\t\tconst jsonLdId = (constraint as IJsonLdNodeObject)[\"@id\"];\n\t\t\t\tif (Is.stringValue(jsonLdId)) {\n\t\t\t\t\tidentifier = jsonLdId;\n\t\t\t\t}\n\t\t\t}\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 ruleDataContext The request data/context.\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: LogicalConstraintType;\n\t\t\tconstraints: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t\t},\n\t\truleDataContext?: 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 LogicalConstraintType.And:\n\t\t\t\treturn constraints.every(item => this.evaluateConstraint(item, ruleDataContext));\n\t\t\tcase LogicalConstraintType.AndSequence: {\n\t\t\t\tfor (const item of constraints) {\n\t\t\t\t\tif (!this.evaluateConstraint(item, ruleDataContext)) {\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 LogicalConstraintType.Or:\n\t\t\t\treturn constraints.some(item => this.evaluateConstraint(item, ruleDataContext));\n\t\t\tcase LogicalConstraintType.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, ruleDataContext)) {\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 * Calculate an operand value.\n\t * @param operand The operand.\n\t * @param ruleDataContext The request data/context.\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\truleDataContext?: unknown\n\t): unknown {\n\t\t// Treat JSONPath operands as selectors against the current rule data context.\n\t\t// Will be in the format twin:jsonpath:<jsonPath>\n\t\tlet jsonPath: string | undefined;\n\t\tif (Is.stringValue(operand)) {\n\t\t\tif (operand.startsWith(`${DefaultPolicyArbiter._JSON_PATH_OPERAND_PREFIX}:`)) {\n\t\t\t\tjsonPath = operand.slice(DefaultPolicyArbiter._JSON_PATH_OPERAND_PREFIX.length + 1);\n\t\t\t\tif (jsonPath.length === 0) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"jsonPathOperandMissingTarget\", {\n\t\t\t\t\t\toperand\n\t\t\t\t\t});\n\t\t\t\t}\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\t// If the type is set we can try and extract the value\n\t\t\t\t// is it twin:jsonpath ?\n\t\t\t\tif (type === DefaultPolicyArbiter._JSON_PATH_OPERAND_PREFIX) {\n\t\t\t\t\tif (Is.stringValue(value)) {\n\t\t\t\t\t\tjsonPath = value;\n\t\t\t\t\t}\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, ruleDataContext);\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: OperatorType, 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 OperatorType.Eq:\n\t\t\t\treturn leftValues.some(v => ObjectHelper.equal(v, right, false));\n\t\t\tcase OperatorType.Neq:\n\t\t\t\treturn leftValues.every(v => !ObjectHelper.equal(v, right, false));\n\t\t\tcase OperatorType.Gt:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a > b));\n\t\t\tcase OperatorType.Gteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a >= b));\n\t\t\tcase OperatorType.Lt:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a < b));\n\t\t\tcase OperatorType.Lteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a <= b));\n\t\t\tcase OperatorType.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 OperatorType.IsAllOf: {\n\t\t\t\treturn ObjectHelper.equal(leftValues, ArrayHelper.fromObjectOrArray(right) ?? [], false);\n\t\t\t}\n\t\t\tcase OperatorType.IsNoneOf: {\n\t\t\t\treturn leftValues.every(v => !(ArrayHelper.fromObjectOrArray(right) ?? []).includes(v));\n\t\t\t}\n\t\t\tcase OperatorType.LocTimeEq:\n\t\t\t\treturn leftValues.some(v => ObjectHelper.equal(v, right, false));\n\t\t\tcase OperatorType.LocTimeGteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a >= b));\n\t\t\tcase OperatorType.IsA:\n\t\t\tcase OperatorType.HasPart:\n\t\t\tcase OperatorType.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,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AA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a;YACb,aAAa;YACb,WAAW;YACX,YAAY;YACZ,UAAU;YACV,SAAS;YACT,WAAW;YACX,UAAU;SACV,CAAC,QAAQ,CAAC,IAAI,CAAC,EACf,CAAC;YACF,4BAA4B;YAC5B,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;aAAM,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;YACnC,4BAA4B;YAC5B,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;aAAM,IAAI,CAAC,UAAU,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 {\n\tConflictStrategyType,\n\tLogicalConstraintType,\n\tOperatorType,\n\ttype ActionType,\n\ttype IOdrlAgreement,\n\ttype IOdrlConstraint,\n\ttype IOdrlDuty,\n\ttype IOdrlLogicalConstraint,\n\ttype IOdrlLogicalConstraintOperand,\n\ttype IOdrlPermission,\n\ttype IOdrlPolicy,\n\ttype IOdrlProhibition,\n\ttype IOdrlRule\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 * Type indicating the operand type is JSONPath.\n\t * @internal\n\t */\n\tprivate static readonly _JSON_PATH_TYPE = \"jsonpath\";\n\n\t/**\n\t * Prefix indicating the operand encodes a JSONPath.\n\t * @internal\n\t */\n\tprivate static readonly _JSON_PATH_OPERAND_PREFIX = `twin:${DefaultPolicyArbiter._JSON_PATH_TYPE}`;\n\n\t/**\n\t * Prefix indicating the permission target references an item in the information map.\n\t * @internal\n\t */\n\tprivate static readonly _INFORMATION_TARGET_PREFIX = \"twin:information:\";\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 * 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: IOdrlAgreement,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: D,\n\t\taction?: ActionType | string\n\t): Promise<IPolicyDecision[]> {\n\t\tGuards.object<IOdrlAgreement>(DefaultPolicyArbiter.CLASS_NAME, nameof(agreement), agreement);\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\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\n\t\t// ODRL-style rule evaluation:\n\t\t// - Permission rules authorize if ANY applicable permission matches (OR across permissions).\n\t\t// - Default to denied when there are no permissions (closed-world for access control).\n\t\t// - Conflict strategy controls how applicable permissions/prohibitions are resolved.\n\t\tconst permissions = ArrayHelper.fromObjectOrArray(mergedPolicy.permission ?? []);\n\t\tlet permissionApplies = false;\n\t\tif (permissions.length > 0) {\n\t\t\tfor (const permission of permissions) {\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\tmergedPolicy,\n\t\t\t\t\t\tpermission,\n\t\t\t\t\t\tinformation,\n\t\t\t\t\t\tdata,\n\t\t\t\t\t\taction\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tpermissionApplies = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst prohibitions = ArrayHelper.fromObjectOrArray<IOdrlProhibition>(\n\t\t\tmergedPolicy.prohibition ?? []\n\t\t);\n\t\tlet prohibitionApplies = false;\n\t\tfor (const prohibition of prohibitions) {\n\t\t\tif (\n\t\t\t\tthis.evaluateProhibition(agreementAssigner, agreementAssignee, prohibition, data, action)\n\t\t\t) {\n\t\t\t\tprohibitionApplies = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst conflictStrategy = mergedPolicy.conflict ?? ConflictStrategyType.Invalid;\n\t\tlet decision: PolicyDecision;\n\t\tif (permissionApplies && prohibitionApplies) {\n\t\t\tswitch (conflictStrategy) {\n\t\t\t\tcase ConflictStrategyType.Perm:\n\t\t\t\t\tdecision = PolicyDecision.Granted;\n\t\t\t\t\tbreak;\n\t\t\t\tcase ConflictStrategyType.Prohibit:\n\t\t\t\tcase ConflictStrategyType.Invalid:\n\t\t\t\tdefault:\n\t\t\t\t\tdecision = PolicyDecision.Denied;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tdecision = permissionApplies ? PolicyDecision.Granted : PolicyDecision.Denied;\n\t\t}\n\n\t\treturn [{ target: \"$\", decision }];\n\t}\n\n\t/**\n\t * Evaluate whether a prohibition applies.\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 data The request data/context.\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 evaluateProhibition(\n\t\tagreementAssigner: string[] | undefined,\n\t\tagreementAssignee: string[] | undefined,\n\t\tprohibition: IOdrlProhibition,\n\t\tdata?: unknown,\n\t\taction?: ActionType | string\n\t): boolean {\n\t\tif (!this.isRuleApplicableToParties(prohibition, agreementAssigner, agreementAssignee)) {\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)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// ODRL semantics: a rule without constraints is unconditional.\n\t\tconst constraints = ArrayHelper.fromObjectOrArray(prohibition.constraint ?? []);\n\t\tif (constraints.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn constraints.every(c => this.evaluateConstraint(c, data));\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(policy: IOdrlPolicy): Promise<IOdrlPolicy> {\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<string>();\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.applyPolicyPartiesToRule(policy, permission));\n\n\t\tconst mergedProhibitions: IOdrlProhibition[] = ArrayHelper.fromObjectOrArray(\n\t\t\tpolicy.prohibition ?? []\n\t\t).map(prohibition => this.applyPolicyPartiesToRule(policy, prohibition));\n\n\t\tconst mergedObligations: IOdrlDuty[] = ArrayHelper.fromObjectOrArray(\n\t\t\tpolicy.obligation ?? []\n\t\t).map(obligation => this.applyPolicyPartiesToRule(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.applyPolicyPartiesToRule(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.applyPolicyPartiesToRule(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.applyPolicyPartiesToRule(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: IOdrlPolicy[\"conflict\"] | undefined;\n\t\tif (conflictStrategies.size === 1) {\n\t\t\tmergedConflict = Array.from(conflictStrategies)[0] as IOdrlPolicy[\"conflict\"];\n\t\t} else if (conflictStrategies.size > 1) {\n\t\t\tmergedConflict = ConflictStrategyType.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 * Detects circular inheritance and throws an exception if detected.\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 * @throws GeneralError if a parent policy cannot be found or if circular inheritance is detected.\n\t * @internal\n\t */\n\tprivate async resolveInheritedPolicies(\n\t\tpolicy: IOdrlPolicy,\n\t\tvisitedPolicyIds: string[],\n\t\tcurrentDepth: number\n\t): Promise<IOdrlPolicy[]> {\n\t\tconst inheritedPolicies: IOdrlPolicy[] = [];\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 assigner/assignee values 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 assigner/assignee applied.\n\t * @internal\n\t */\n\tprivate applyPolicyPartiesToRule<T extends IOdrlRule>(policy: IOdrlPolicy, rule: 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\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\tif (assignerEqual && assigneeEqual) {\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};\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): boolean {\n\t\tconst ruleAssigners = OdrlPolicyHelper.getPartyIds(rule.assigner);\n\t\tconst ruleAssignees = OdrlPolicyHelper.getPartyIds(rule.assignee);\n\n\t\tif (!this.isPartyApplicable(ruleAssigners, agreementAssigner)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!this.isPartyApplicable(ruleAssignees, agreementAssignee)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\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 * 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?: ActionType | string\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\t// Both rule actions and requested action are specified - check for match\n\t\tconst ruleActionArray = ArrayHelper.fromObjectOrArray(ruleActions) ?? [];\n\n\t\t// Check if the requested action matches any of the rule's actions\n\t\tfor (const ruleAction of ruleActionArray) {\n\t\t\tconst ruleActionId = Is.string(ruleAction) ? ruleAction : OdrlPolicyHelper.getUid(ruleAction);\n\t\t\tconst requestedActionId = Is.string(requestedAction)\n\t\t\t\t? requestedAction\n\t\t\t\t: OdrlPolicyHelper.getUid(requestedAction);\n\n\t\t\tif (Is.stringValue(ruleActionId) && Is.stringValue(requestedActionId)) {\n\t\t\t\tif (ruleActionId === requestedActionId) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn false;\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 information Additional facts provided by the PIP.\n\t * @param data The request data/context.\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: IOdrlPolicy,\n\t\tpermission: IOdrlPermission,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: unknown,\n\t\taction?: ActionType | string\n\t): Promise<boolean> {\n\t\tif (!this.isRuleApplicableToParties(permission, agreementAssigner, agreementAssignee)) {\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)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// ODRL semantics: a Permission without constraints is unconditional.\n\t\tconst constraints = ArrayHelper.fromObjectOrArray(permission.constraint ?? []);\n\t\tif (constraints.length === 0) {\n\t\t\treturn this.enforcePermissionDuties(policy, permission, information, data);\n\t\t}\n\n\t\t// Resolve the data context for evaluating this permission.\n\t\t// If the target starts with twin:information:<key>, the key references an entry in the information map.\n\t\tconst ruleDataContext = this.resolveRuleDataContext(permission, information, data);\n\n\t\t// All constraints must be satisfied for the permission to apply.\n\t\tconst constraintsSatisfied = constraints.every(c =>\n\t\t\tthis.evaluateConstraint(c, ruleDataContext)\n\t\t);\n\n\t\tif (!constraintsSatisfied) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.enforcePermissionDuties(policy, permission, information, 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 information Additional facts provided by the PIP.\n\t * @param data The request data/context.\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: IOdrlPolicy,\n\t\tpermission: IOdrlPermission,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: 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, information, data);\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 information Additional facts provided by the PIP.\n\t * @param data The request data/context.\n\t * @returns True if any enforcer succeeds.\n\t * @internal\n\t */\n\tprivate async enforceDuty(\n\t\tpolicy: IOdrlPolicy,\n\t\tduty: IOdrlDuty,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: unknown\n\t): Promise<boolean> {\n\t\tconst enforcerNames = PolicyObligationEnforcerFactory.names();\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, data)) {\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 * Resolve the data context used when evaluating a permission's constraints.\n\t * If the permission target is `twin:information:<key>`, the key references an entry in the information map.\n\t * @param rule The permission being evaluated.\n\t * @param information Additional facts provided by the PIP.\n\t * @param data The request data/context.\n\t * @returns The data context to use for JSONPath resolution.\n\t * @throws GeneralError When the information target key is missing.\n\t * @internal\n\t */\n\tprivate resolveRuleDataContext(\n\t\trule: IOdrlRule,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: unknown\n\t): unknown {\n\t\tconst targetId = this.getTargetId(rule.target);\n\n\t\tif (targetId?.startsWith(DefaultPolicyArbiter._INFORMATION_TARGET_PREFIX)) {\n\t\t\tconst key = targetId.slice(DefaultPolicyArbiter._INFORMATION_TARGET_PREFIX.length);\n\t\t\tif (Is.empty(key) || Is.empty(information?.[key])) {\n\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"informationTargetMissing\", {\n\t\t\t\t\tkey\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn information[key];\n\t\t}\n\n\t\treturn data;\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: IOdrlPermission[\"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 * 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 ruleDataContext The request data/context.\n\t * @returns True if the constraint is satisfied.\n\t * @internal\n\t */\n\tprivate evaluateConstraint(\n\t\tconstraint: IOdrlConstraint | IOdrlLogicalConstraint,\n\t\truleDataContext?: unknown\n\t): boolean {\n\t\tconst logicalConstraint = this.getLogicalConstraintOperands(constraint);\n\t\tif (logicalConstraint) {\n\t\t\treturn this.evaluateLogicalConstraint(logicalConstraint, ruleDataContext);\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// Evaluate the main constraint condition\n\t\tconst leftValue = this.calculateOperandValue(regularConstraint.leftOperand, ruleDataContext);\n\t\tconst rightValue = this.calculateOperandValue(regularConstraint.rightOperand, ruleDataContext);\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: LogicalConstraintType;\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: LogicalConstraintType[] = Object.values(LogicalConstraintType);\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: LogicalConstraintType\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 ruleDataContext The request data/context.\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: LogicalConstraintType;\n\t\t\tconstraints: (IOdrlConstraint | IOdrlLogicalConstraint)[];\n\t\t},\n\t\truleDataContext?: 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 LogicalConstraintType.And:\n\t\t\t\treturn constraints.every(item => this.evaluateConstraint(item, ruleDataContext));\n\t\t\tcase LogicalConstraintType.AndSequence: {\n\t\t\t\tfor (const item of constraints) {\n\t\t\t\t\tif (!this.evaluateConstraint(item, ruleDataContext)) {\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 LogicalConstraintType.Or:\n\t\t\t\treturn constraints.some(item => this.evaluateConstraint(item, ruleDataContext));\n\t\t\tcase LogicalConstraintType.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, ruleDataContext)) {\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 * Calculate an operand value.\n\t * @param operand The operand.\n\t * @param ruleDataContext The request data/context.\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\truleDataContext?: unknown\n\t): unknown {\n\t\t// Treat JSONPath operands as selectors against the current rule data context.\n\t\t// Will be in the format twin:jsonpath:<jsonPath>\n\t\tlet jsonPath: string | undefined;\n\t\tif (Is.stringValue(operand)) {\n\t\t\tif (operand.startsWith(`${DefaultPolicyArbiter._JSON_PATH_OPERAND_PREFIX}:`)) {\n\t\t\t\tjsonPath = operand.slice(DefaultPolicyArbiter._JSON_PATH_OPERAND_PREFIX.length + 1);\n\t\t\t\tif (jsonPath.length === 0) {\n\t\t\t\t\tthrow new GeneralError(DefaultPolicyArbiter.CLASS_NAME, \"jsonPathOperandMissingTarget\", {\n\t\t\t\t\t\toperand\n\t\t\t\t\t});\n\t\t\t\t}\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\t// If the type is set we can try and extract the value\n\t\t\t\t// is it twin:jsonpath ?\n\t\t\t\tif (type === DefaultPolicyArbiter._JSON_PATH_OPERAND_PREFIX) {\n\t\t\t\t\tif (Is.stringValue(value)) {\n\t\t\t\t\t\tjsonPath = value;\n\t\t\t\t\t}\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, ruleDataContext);\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: OperatorType, 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 OperatorType.Eq:\n\t\t\t\treturn leftValues.some(v => ObjectHelper.equal(v, right, false));\n\t\t\tcase OperatorType.Neq:\n\t\t\t\treturn leftValues.every(v => !ObjectHelper.equal(v, right, false));\n\t\t\tcase OperatorType.Gt:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a > b));\n\t\t\tcase OperatorType.Gteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a >= b));\n\t\t\tcase OperatorType.Lt:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a < b));\n\t\t\tcase OperatorType.Lteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a <= b));\n\t\t\tcase OperatorType.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 OperatorType.IsAllOf: {\n\t\t\t\treturn ObjectHelper.equal(leftValues, ArrayHelper.fromObjectOrArray(right) ?? [], false);\n\t\t\t}\n\t\t\tcase OperatorType.IsNoneOf: {\n\t\t\t\treturn leftValues.every(v => !(ArrayHelper.fromObjectOrArray(right) ?? []).includes(v));\n\t\t\t}\n\t\t\tcase OperatorType.LocTimeEq:\n\t\t\t\treturn leftValues.some(v => ObjectHelper.equal(v, right, false));\n\t\t\tcase OperatorType.LocTimeGteq:\n\t\t\t\treturn leftValues.some(v => this.compareOrdered(v, right, (a, b) => a >= b));\n\t\t\tcase OperatorType.IsA:\n\t\t\tcase OperatorType.HasPart:\n\t\t\tcase OperatorType.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,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2025 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { ComponentFactory, Guards } from "@twin.org/core";
|
|
4
|
-
import { PolicyDecision } from "@twin.org/rights-management-models";
|
|
4
|
+
import { OdrlPolicyHelper, PolicyDecision } from "@twin.org/rights-management-models";
|
|
5
5
|
/**
|
|
6
6
|
* Pass Through Policy Arbiter.
|
|
7
7
|
*/
|
|
@@ -45,7 +45,7 @@ export class PassThroughPolicyArbiter {
|
|
|
45
45
|
ts: Date.now(),
|
|
46
46
|
message: "decidingPolicy",
|
|
47
47
|
data: {
|
|
48
|
-
policyId: agreement
|
|
48
|
+
policyId: OdrlPolicyHelper.getUid(agreement) ?? ""
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passThroughPolicyArbiter.js","sourceRoot":"","sources":["../../../src/policyArbiters/passThroughPolicyArbiter.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI1D,OAAO,EACN,cAAc,EAGd,MAAM,oCAAoC,CAAC;AAI5C;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACpC;;OAEG;IACI,MAAM,CAAU,UAAU,8BAA8C;IAE/E;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAAqD;QAChE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,wBAAwB,CAAC,UAAU,CAAC;IAC5C,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,MAAM,CAClB,SAAyB,EACzB,WAAiD,EACjD,IAAQ,EACR,MAA4B;QAE5B,MAAM,CAAC,MAAM,CACZ,wBAAwB,CAAC,UAAU,eAEnC,SAAS,CACT,CAAC;QAEF,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,wBAAwB,CAAC,UAAU;YAC3C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,gBAAgB;YACzB,IAAI,EAAE;gBACL,QAAQ,EAAE,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"passThroughPolicyArbiter.js","sourceRoot":"","sources":["../../../src/policyArbiters/passThroughPolicyArbiter.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI1D,OAAO,EACN,gBAAgB,EAChB,cAAc,EAGd,MAAM,oCAAoC,CAAC;AAI5C;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACpC;;OAEG;IACI,MAAM,CAAU,UAAU,8BAA8C;IAE/E;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAAqD;QAChE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,wBAAwB,CAAC,UAAU,CAAC;IAC5C,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,MAAM,CAClB,SAAyB,EACzB,WAAiD,EACjD,IAAQ,EACR,MAA4B;QAE5B,MAAM,CAAC,MAAM,CACZ,wBAAwB,CAAC,UAAU,eAEnC,SAAS,CACT,CAAC;QAEF,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,wBAAwB,CAAC,UAAU;YAC3C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,gBAAgB;YACzB,IAAI,EAAE;gBACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;aAClD;SACD,CAAC,CAAC;QAEH,OAAO;YACN;gBACC,MAAM,EAAE,GAAG;gBACX,QAAQ,EAAE,cAAc,CAAC,OAAO;aAChC;SACD,CAAC;IACH,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\tPolicyDecision,\n\ttype IPolicyArbiter,\n\ttype IPolicyDecision\n} from \"@twin.org/rights-management-models\";\nimport type { ActionType, IOdrlAgreement } from \"@twin.org/standards-w3c-odrl\";\nimport type { IPassThroughPolicyArbiterConstructorOptions } from \"../models/IPassThroughPolicyArbiterConstructorOptions.js\";\n\n/**\n * Pass Through Policy Arbiter.\n */\nexport class PassThroughPolicyArbiter implements IPolicyArbiter {\n\t/**\n\t * The class name of the Pass Through Policy Arbiter.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<PassThroughPolicyArbiter>();\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 PassThroughPolicyArbiter.\n\t * @param options The options for the pass through policy arbiter.\n\t */\n\tconstructor(options?: IPassThroughPolicyArbiterConstructorOptions) {\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 PassThroughPolicyArbiter.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: IOdrlAgreement,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: D,\n\t\taction?: ActionType | string\n\t): Promise<IPolicyDecision[]> {\n\t\tGuards.object<IOdrlAgreement>(\n\t\t\tPassThroughPolicyArbiter.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyArbiter.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\treturn [\n\t\t\t{\n\t\t\t\ttarget: \"$\",\n\t\t\t\tdecision: PolicyDecision.Granted\n\t\t\t}\n\t\t];\n\t}\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { ComponentFactory, GeneralError, Guards, Is, ObjectHelper } from "@twin.org/core";
|
|
4
4
|
import { JsonPathHelper } from "@twin.org/data-json-path";
|
|
5
|
-
import { PolicyDecision } from "@twin.org/rights-management-models";
|
|
5
|
+
import { OdrlPolicyHelper, PolicyDecision } from "@twin.org/rights-management-models";
|
|
6
6
|
/**
|
|
7
7
|
* Default Policy Enforcement Processor.
|
|
8
8
|
*/
|
|
@@ -46,7 +46,7 @@ export class DefaultPolicyEnforcementProcessor {
|
|
|
46
46
|
ts: Date.now(),
|
|
47
47
|
message: "processingPolicy",
|
|
48
48
|
data: {
|
|
49
|
-
policyId: agreement
|
|
49
|
+
policyId: OdrlPolicyHelper.getUid(agreement) ?? ""
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
const isOriginalEmpty = Is.empty(data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultPolicyEnforcementProcessor.js","sour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1F,CAAC;QACF,CAAC;aAAM,CAAC;YACP,8FAA8F;YAC9F,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAC1E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC9B,cAAc,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;YAChE,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, GeneralError, Guards, Is, ObjectHelper } from \"@twin.org/core\";\nimport { JsonPathHelper } from \"@twin.org/data-json-path\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tPolicyDecision,\n\ttype IPolicyDecision,\n\ttype IPolicyEnforcementProcessor\n} from \"@twin.org/rights-management-models\";\nimport type { ActionType, IOdrlAgreement } from \"@twin.org/standards-w3c-odrl\";\nimport type { IDefaultPolicyEnforcementProcessorConstructorOptions } from \"../models/IDefaultPolicyEnforcementProcessorConstructorOptions.js\";\n\n/**\n * Default Policy Enforcement Processor.\n */\nexport class DefaultPolicyEnforcementProcessor implements IPolicyEnforcementProcessor {\n\t/**\n\t * The class name of the Default Policy Enforcement Processor.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DefaultPolicyEnforcementProcessor>();\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 DefaultPolicyEnforcementProcessor.\n\t * @param options The options for the default policy enforcement processor.\n\t */\n\tconstructor(options?: IDefaultPolicyEnforcementProcessorConstructorOptions) {\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 DefaultPolicyEnforcementProcessor.CLASS_NAME;\n\t}\n\n\t/**\n\t * Process the response from the policy decision point.\n\t * @param agreement The agreement to process.\n\t * @param decisions The decisions made by the policy decision point.\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 * @returns The data after processing.\n\t */\n\tpublic async process<D = unknown, R = D>(\n\t\tagreement: IOdrlAgreement,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata?: D,\n\t\taction?: ActionType | string\n\t): Promise<R> {\n\t\tGuards.object<IOdrlAgreement>(\n\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"processingPolicy\",\n\t\t\tdata: {\n\t\t\t\tpolicyId: agreement.uid\n\t\t\t}\n\t\t});\n\n\t\tconst isOriginalEmpty = Is.empty(data);\n\t\tconst outputObject: R = (Is.arrayValue(data) ? [] : {}) as unknown as R;\n\n\t\tif (Is.arrayValue(decisions)) {\n\t\t\t// If this is a single simple decision with no values, handle that quickly.\n\t\t\tif (decisions.length === 1 && decisions[0].target === \"$\") {\n\t\t\t\tif (!Is.stringValue(decisions[0].target)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\t\t\t\t\"targetNotJsonPath\",\n\t\t\t\t\t\t{ target: decisions[0].target }\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (decisions[0].decision === PolicyDecision.Granted) {\n\t\t\t\t\t// Object granted, if original data is an object return it, otherwise return true.\n\t\t\t\t\treturn isOriginalEmpty ? (true as R) : (data as unknown as R);\n\t\t\t\t} else if (\n\t\t\t\t\tdecisions[0].decision === PolicyDecision.Replace &&\n\t\t\t\t\tIs.object(decisions[0].replaceValue)\n\t\t\t\t) {\n\t\t\t\t\t// Object replaced, return the replace value.\n\t\t\t\t\treturn decisions[0].replaceValue as R;\n\t\t\t\t}\n\n\t\t\t\t// Object denied, or replace with no value\n\t\t\t\t// if original data is an object return empty object, otherwise return false.\n\t\t\t\treturn isOriginalEmpty ? (false as R) : ({} as unknown as R);\n\t\t\t}\n\n\t\t\tfor (const policyDecision of decisions) {\n\t\t\t\tif (!Is.stringValue(policyDecision.target)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\t\t\t\t\"targetNotJsonPath\",\n\t\t\t\t\t\t{ target: policyDecision.target }\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tpolicyDecision.decision === PolicyDecision.Replace &&\n\t\t\t\t\tIs.undefined(policyDecision.replaceValue)\n\t\t\t\t) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\t\t\t\t\"replaceValueMissing\",\n\t\t\t\t\t\t{ target: policyDecision.target }\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.processDecision<D, R>(data, outputObject, policyDecision);\n\t\t\t}\n\t\t}\n\n\t\treturn outputObject;\n\t}\n\n\t/**\n\t * Process a single policy decision.\n\t * @param sourceObject The data to process.\n\t * @param outputObject The currently processed object.\n\t * @param policyDecision The policy decision to process.\n\t * @throws GeneralError When replaceValue is missing or invalid.\n\t */\n\tprivate processDecision<D = unknown, R = D>(\n\t\tsourceObject: D | undefined,\n\t\toutputObject: R,\n\t\tpolicyDecision: IPolicyDecision\n\t): void {\n\t\t// If the target is \"$\" assume we are using the entire source object.\n\t\tif (policyDecision.target === \"$\") {\n\t\t\tconst sourceKeys = Object.keys(sourceObject ?? {});\n\t\t\tconst outputKeys = Object.keys(outputObject ?? {});\n\n\t\t\tif (policyDecision.decision === PolicyDecision.Granted) {\n\t\t\t\tfor (const key of sourceKeys) {\n\t\t\t\t\tObjectHelper.propertySet(outputObject, key, ObjectHelper.propertyGet(sourceObject, key));\n\t\t\t\t}\n\t\t\t} else if (policyDecision.decision === PolicyDecision.Replace) {\n\t\t\t\t// Replace everything, first remove all the current keys.\n\t\t\t\tfor (const key of outputKeys) {\n\t\t\t\t\tObjectHelper.propertyDelete(outputObject, key);\n\t\t\t\t}\n\t\t\t\tif (Is.objectValue(policyDecision.replaceValue)) {\n\t\t\t\t\tconst replaceKeys = Object.keys(policyDecision.replaceValue);\n\t\t\t\t\tfor (const key of replaceKeys) {\n\t\t\t\t\t\tObjectHelper.propertySet(\n\t\t\t\t\t\t\toutputObject,\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tObjectHelper.propertyGet(policyDecision.replaceValue, key)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Denied everything, so remove all the properties.\n\t\t\t\tfor (const key of sourceKeys) {\n\t\t\t\t\tObjectHelper.propertyDelete(outputObject, key);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (policyDecision.decision === PolicyDecision.Granted) {\n\t\t\t// We have a specific granted target (JSONPath), so copy all matching values into the output.\n\t\t\tconst results = JsonPathHelper.query(policyDecision.target, sourceObject ?? {});\n\t\t\tfor (const result of results) {\n\t\t\t\tJsonPathHelper.setAtLocation(outputObject, result.location, result.value);\n\t\t\t}\n\t\t} else if (policyDecision.decision === PolicyDecision.Replace) {\n\t\t\t// We have a specific replace target (JSONPath), so write replaceValue into all matching locations.\n\t\t\tconst results = JsonPathHelper.query(policyDecision.target, sourceObject ?? {});\n\t\t\tfor (const result of results) {\n\t\t\t\tJsonPathHelper.setAtLocation(outputObject, result.location, policyDecision.replaceValue);\n\t\t\t}\n\t\t} else {\n\t\t\t// We have a specific denied target (JSONPath), so remove all matching values from the output.\n\t\t\tconst results = JsonPathHelper.query(policyDecision.target, outputObject);\n\t\t\tfor (const result of results) {\n\t\t\t\tJsonPathHelper.deleteAtLocation(outputObject, result.location);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"defaultPolicyEnforcementProcessor.js","sourceRoot":"","sources":["../../../src/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EACN,gBAAgB,EAChB,cAAc,EAGd,MAAM,oCAAoC,CAAC;AAI5C;;GAEG;AACH,MAAM,OAAO,iCAAiC;IAC7C;;OAEG;IACI,MAAM,CAAU,UAAU,uCAAuD;IAExF;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAA8D;QACzE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,iCAAiC,CAAC,UAAU,CAAC;IACrD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,OAAO,CACnB,SAAyB,EACzB,SAA4B,EAC5B,IAAQ,EACR,MAA4B;QAE5B,MAAM,CAAC,MAAM,CACZ,iCAAiC,CAAC,UAAU,eAE5C,SAAS,CACT,CAAC;QAEF,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,iCAAiC,CAAC,UAAU;YACpD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,kBAAkB;YAC3B,IAAI,EAAE;gBACL,QAA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,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,IAAI,EAAE,CAAC,CAAC;YAChF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC9B,cAAc,CAAC,aAAa,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;YAC1F,CAAC;QACF,CAAC;aAAM,CAAC;YACP,8FAA8F;YAC9F,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAC1E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC9B,cAAc,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;YAChE,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, GeneralError, Guards, Is, ObjectHelper } from \"@twin.org/core\";\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\ttype IPolicyDecision,\n\ttype IPolicyEnforcementProcessor\n} from \"@twin.org/rights-management-models\";\nimport type { ActionType, IOdrlAgreement } from \"@twin.org/standards-w3c-odrl\";\nimport type { IDefaultPolicyEnforcementProcessorConstructorOptions } from \"../models/IDefaultPolicyEnforcementProcessorConstructorOptions.js\";\n\n/**\n * Default Policy Enforcement Processor.\n */\nexport class DefaultPolicyEnforcementProcessor implements IPolicyEnforcementProcessor {\n\t/**\n\t * The class name of the Default Policy Enforcement Processor.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DefaultPolicyEnforcementProcessor>();\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 DefaultPolicyEnforcementProcessor.\n\t * @param options The options for the default policy enforcement processor.\n\t */\n\tconstructor(options?: IDefaultPolicyEnforcementProcessorConstructorOptions) {\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 DefaultPolicyEnforcementProcessor.CLASS_NAME;\n\t}\n\n\t/**\n\t * Process the response from the policy decision point.\n\t * @param agreement The agreement to process.\n\t * @param decisions The decisions made by the policy decision point.\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 * @returns The data after processing.\n\t */\n\tpublic async process<D = unknown, R = D>(\n\t\tagreement: IOdrlAgreement,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata?: D,\n\t\taction?: ActionType | string\n\t): Promise<R> {\n\t\tGuards.object<IOdrlAgreement>(\n\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"processingPolicy\",\n\t\t\tdata: {\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\tconst isOriginalEmpty = Is.empty(data);\n\t\tconst outputObject: R = (Is.arrayValue(data) ? [] : {}) as unknown as R;\n\n\t\tif (Is.arrayValue(decisions)) {\n\t\t\t// If this is a single simple decision with no values, handle that quickly.\n\t\t\tif (decisions.length === 1 && decisions[0].target === \"$\") {\n\t\t\t\tif (!Is.stringValue(decisions[0].target)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\t\t\t\t\"targetNotJsonPath\",\n\t\t\t\t\t\t{ target: decisions[0].target }\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (decisions[0].decision === PolicyDecision.Granted) {\n\t\t\t\t\t// Object granted, if original data is an object return it, otherwise return true.\n\t\t\t\t\treturn isOriginalEmpty ? (true as R) : (data as unknown as R);\n\t\t\t\t} else if (\n\t\t\t\t\tdecisions[0].decision === PolicyDecision.Replace &&\n\t\t\t\t\tIs.object(decisions[0].replaceValue)\n\t\t\t\t) {\n\t\t\t\t\t// Object replaced, return the replace value.\n\t\t\t\t\treturn decisions[0].replaceValue as R;\n\t\t\t\t}\n\n\t\t\t\t// Object denied, or replace with no value\n\t\t\t\t// if original data is an object return empty object, otherwise return false.\n\t\t\t\treturn isOriginalEmpty ? (false as R) : ({} as unknown as R);\n\t\t\t}\n\n\t\t\tfor (const policyDecision of decisions) {\n\t\t\t\tif (!Is.stringValue(policyDecision.target)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\t\t\t\t\"targetNotJsonPath\",\n\t\t\t\t\t\t{ target: policyDecision.target }\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tpolicyDecision.decision === PolicyDecision.Replace &&\n\t\t\t\t\tIs.undefined(policyDecision.replaceValue)\n\t\t\t\t) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\t\t\t\t\"replaceValueMissing\",\n\t\t\t\t\t\t{ target: policyDecision.target }\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.processDecision<D, R>(data, outputObject, policyDecision);\n\t\t\t}\n\t\t}\n\n\t\treturn outputObject;\n\t}\n\n\t/**\n\t * Process a single policy decision.\n\t * @param sourceObject The data to process.\n\t * @param outputObject The currently processed object.\n\t * @param policyDecision The policy decision to process.\n\t * @throws GeneralError When replaceValue is missing or invalid.\n\t */\n\tprivate processDecision<D = unknown, R = D>(\n\t\tsourceObject: D | undefined,\n\t\toutputObject: R,\n\t\tpolicyDecision: IPolicyDecision\n\t): void {\n\t\t// If the target is \"$\" assume we are using the entire source object.\n\t\tif (policyDecision.target === \"$\") {\n\t\t\tconst sourceKeys = Object.keys(sourceObject ?? {});\n\t\t\tconst outputKeys = Object.keys(outputObject ?? {});\n\n\t\t\tif (policyDecision.decision === PolicyDecision.Granted) {\n\t\t\t\tfor (const key of sourceKeys) {\n\t\t\t\t\tObjectHelper.propertySet(outputObject, key, ObjectHelper.propertyGet(sourceObject, key));\n\t\t\t\t}\n\t\t\t} else if (policyDecision.decision === PolicyDecision.Replace) {\n\t\t\t\t// Replace everything, first remove all the current keys.\n\t\t\t\tfor (const key of outputKeys) {\n\t\t\t\t\tObjectHelper.propertyDelete(outputObject, key);\n\t\t\t\t}\n\t\t\t\tif (Is.objectValue(policyDecision.replaceValue)) {\n\t\t\t\t\tconst replaceKeys = Object.keys(policyDecision.replaceValue);\n\t\t\t\t\tfor (const key of replaceKeys) {\n\t\t\t\t\t\tObjectHelper.propertySet(\n\t\t\t\t\t\t\toutputObject,\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tObjectHelper.propertyGet(policyDecision.replaceValue, key)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Denied everything, so remove all the properties.\n\t\t\t\tfor (const key of sourceKeys) {\n\t\t\t\t\tObjectHelper.propertyDelete(outputObject, key);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (policyDecision.decision === PolicyDecision.Granted) {\n\t\t\t// We have a specific granted target (JSONPath), so copy all matching values into the output.\n\t\t\tconst results = JsonPathHelper.query(policyDecision.target, sourceObject ?? {});\n\t\t\tfor (const result of results) {\n\t\t\t\tJsonPathHelper.setAtLocation(outputObject, result.location, result.value);\n\t\t\t}\n\t\t} else if (policyDecision.decision === PolicyDecision.Replace) {\n\t\t\t// We have a specific replace target (JSONPath), so write replaceValue into all matching locations.\n\t\t\tconst results = JsonPathHelper.query(policyDecision.target, sourceObject ?? {});\n\t\t\tfor (const result of results) {\n\t\t\t\tJsonPathHelper.setAtLocation(outputObject, result.location, policyDecision.replaceValue);\n\t\t\t}\n\t\t} else {\n\t\t\t// We have a specific denied target (JSONPath), so remove all matching values from the output.\n\t\t\tconst results = JsonPathHelper.query(policyDecision.target, outputObject);\n\t\t\tfor (const result of results) {\n\t\t\t\tJsonPathHelper.deleteAtLocation(outputObject, result.location);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2025 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { ComponentFactory, Guards } from "@twin.org/core";
|
|
4
|
+
import { OdrlPolicyHelper } from "@twin.org/rights-management-models";
|
|
4
5
|
/**
|
|
5
6
|
* Pass Through Policy Enforcement Processor.
|
|
6
7
|
*/
|
|
@@ -44,7 +45,7 @@ export class PassThroughPolicyEnforcementProcessor {
|
|
|
44
45
|
ts: Date.now(),
|
|
45
46
|
message: "processingPolicy",
|
|
46
47
|
data: {
|
|
47
|
-
policyId: agreement
|
|
48
|
+
policyId: OdrlPolicyHelper.getUid(agreement) ?? ""
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
51
|
return data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passThroughPolicyEnforcementProcessor.js","sourceRoot":"","sources":["../../../src/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"passThroughPolicyEnforcementProcessor.js","sourceRoot":"","sources":["../../../src/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,EACN,gBAAgB,EAGhB,MAAM,oCAAoC,CAAC;AAI5C;;GAEG;AACH,MAAM,OAAO,qCAAqC;IACjD;;OAEG;IACI,MAAM,CAAU,UAAU,2CAA2D;IAE5F;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACH,YAAY,OAAkE;QAC7E,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,qCAAqC,CAAC,UAAU,CAAC;IACzD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,OAAO,CACnB,SAAyB,EACzB,SAA4B,EAC5B,IAAQ,EACR,MAA4B;QAE5B,MAAM,CAAC,MAAM,CACZ,qCAAqC,CAAC,UAAU,eAEhD,SAAS,CACT,CAAC;QAEF,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,qCAAqC,CAAC,UAAU;YACxD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,kBAAkB;YAC3B,IAAI,EAAE;gBACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;aAClD;SACD,CAAC,CAAC;QAEH,OAAO,IAAoB,CAAC;IAC7B,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\ttype IPolicyDecision,\n\ttype IPolicyEnforcementProcessor\n} from \"@twin.org/rights-management-models\";\nimport type { ActionType, IOdrlAgreement } from \"@twin.org/standards-w3c-odrl\";\nimport type { IPassThroughPolicyEnforcementProcessorConstructorOptions } from \"../models/IPassThroughPolicyEnforcementProcessorConstructorOptions.js\";\n\n/**\n * Pass Through Policy Enforcement Processor.\n */\nexport class PassThroughPolicyEnforcementProcessor implements IPolicyEnforcementProcessor {\n\t/**\n\t * The class name of the Pass Through Policy Enforcement Processor.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<PassThroughPolicyEnforcementProcessor>();\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 PassThroughPolicyEnforcementProcessor.\n\t * @param options The options for the pass through policy enforcement processor.\n\t */\n\tconstructor(options?: IPassThroughPolicyEnforcementProcessorConstructorOptions) {\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 PassThroughPolicyEnforcementProcessor.CLASS_NAME;\n\t}\n\n\t/**\n\t * Process the response from the policy decision point.\n\t * @param agreement The agreement to process.\n\t * @param decisions The decisions made by the policy decision point.\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 * @returns The data after processing.\n\t */\n\tpublic async process<D = unknown, R = D>(\n\t\tagreement: IOdrlAgreement,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata?: D,\n\t\taction?: ActionType | string\n\t): Promise<R> {\n\t\tGuards.object<IOdrlAgreement>(\n\t\t\tPassThroughPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"processingPolicy\",\n\t\t\tdata: {\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\treturn data as unknown as R;\n\t}\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2025 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { ComponentFactory, Guards, Is } from "@twin.org/core";
|
|
4
|
-
import { PolicyDecisionStage } from "@twin.org/rights-management-models";
|
|
4
|
+
import { OdrlPolicyHelper, PolicyDecisionStage } from "@twin.org/rights-management-models";
|
|
5
5
|
/**
|
|
6
6
|
* Logging Policy Execution Action to send decisions to logging.
|
|
7
7
|
*/
|
|
@@ -87,7 +87,7 @@ export class LoggingPolicyExecutionAction {
|
|
|
87
87
|
ts: Date.now(),
|
|
88
88
|
message: "policyActionExecutedBefore",
|
|
89
89
|
data: {
|
|
90
|
-
policyId: policy
|
|
90
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
91
91
|
data: logData,
|
|
92
92
|
policy: logPolicy,
|
|
93
93
|
decisions: logDecisions,
|
|
@@ -103,7 +103,7 @@ export class LoggingPolicyExecutionAction {
|
|
|
103
103
|
ts: Date.now(),
|
|
104
104
|
message: "policyActionExecutedAfter",
|
|
105
105
|
data: {
|
|
106
|
-
policyId: policy
|
|
106
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
107
107
|
data: logData,
|
|
108
108
|
policy: logPolicy,
|
|
109
109
|
decisions: logDecisions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggingPolicyExecutionAction.js","sourceRoot":"","sources":["../../../src/policyExecutionActions/loggingPolicyExecutionAction.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,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B,CAAC,CAClC,CAAC;QAEF,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,yEAAyE;YACzE,4EAA4E;YAC5E,IAAI,OAAO,CAAC;YACZ,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrB,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;YAC9C,CAAC;YACD,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;YACtD,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;YAElE,IAAI,KAAK,KAAK,mBAAmB,CAAC,MAAM,EAAE,CAAC;gBAC1C,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,4BAA4B;oBACrC,IAAI,EAAE;wBACL,QAAQ,EAAE,MAAM,CAAC,
|
|
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,EAGN,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,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: 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\tOdrlPolicyHelper,\n\tPolicyDecisionStage\n} from \"@twin.org/rights-management-models\";\nimport type { ActionType, IOdrlPolicy } 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: IOdrlPolicy,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata: D | undefined,\n\t\taction: ActionType | 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"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { BaseError, ComponentFactory, Guards, Is } from "@twin.org/core";
|
|
4
4
|
import { JsonLdHelper } from "@twin.org/data-json-ld";
|
|
5
|
-
import { PolicyInformationAccessMode } from "@twin.org/rights-management-models";
|
|
5
|
+
import { OdrlPolicyHelper, PolicyInformationAccessMode } from "@twin.org/rights-management-models";
|
|
6
6
|
/**
|
|
7
7
|
* Policy information source which retrieves the identity information.
|
|
8
8
|
*/
|
|
@@ -63,7 +63,7 @@ export class IdentityPolicyInformationSource {
|
|
|
63
63
|
ts: Date.now(),
|
|
64
64
|
message: "identityRetrieving",
|
|
65
65
|
data: {
|
|
66
|
-
policyId: policy
|
|
66
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
67
67
|
id
|
|
68
68
|
}
|
|
69
69
|
});
|
|
@@ -77,7 +77,7 @@ export class IdentityPolicyInformationSource {
|
|
|
77
77
|
ts: Date.now(),
|
|
78
78
|
message: "identityRetrievalFailed",
|
|
79
79
|
data: {
|
|
80
|
-
policyId: policy
|
|
80
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
81
81
|
id
|
|
82
82
|
},
|
|
83
83
|
error: BaseError.fromError(err)
|
|
@@ -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,EAEN,2BAA2B,EAC3B,MAAM,oCAAoC,CAAC;AAI5C;;GAEG;AACH,MAAM,OAAO,+BAA+B;IAC3C;;OAEG;IACI,MAAM,CAAU,UAAU,qCAAqD;IAEtF;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,iBAAiB,CAA6B;IAE/D;;;OAGG;IACH,YAAY,OAA4D;QACvE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAC3C,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,CAC5C,OAAO,EAAE,6BAA6B,IAAI,mBAAmB,CAC7D,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,+BAA+B,CAAC,UAAU,CAAC;IACnD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,QAAQ,CACpB,MAA+B,EAC/B,UAAuC,EACvC,IAAQ,EACR,MAA4B;QAE5B,MAAM,CAAC,UAAU,CAChB,+BAA+B,CAAC,UAAU,gBAE1C,UAAU,EACV,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAC1C,CAAC;QAEF,MAAM,WAAW,GAAwC,EAAE,CAAC;QAE5D,IAAI,EAAE,CAAC,MAAM,CAAc,MAAM,CAAC,EAAE,CAAC;YACpC,MAAM,GAAG,GAAG,EAAE,CAAC;YAEf,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACrC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3B,CAAC;YACD,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACrC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3B,CAAC;YAED,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;gBACtB,IAAI,CAAC;oBACJ,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;wBACxB,KAAK,EAAE,MAAM;wBACb,MAAM,EAAE,+BAA+B,CAAC,UAAU;wBAClD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;wBACd,OAAO,EAAE,oBAAoB;wBAC7B,IAAI,EAAE;4BACL,QAAQ,EAAE,MAAM,CAAC,
|
|
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,EAEN,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;;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AI,EAAE;4BACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;4BAC/C,EAAE;yBACF;qBACD,CAAC,CAAC;oBACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;oBAC/D,WAAW,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpD,CAAC;gBAAC,OAAO,GAAG,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\tOdrlPolicyHelper,\n\tPolicyInformationAccessMode\n} from \"@twin.org/rights-management-models\";\nimport type { ActionType, IOdrlPolicy } from \"@twin.org/standards-w3c-odrl\";\nimport type { IIdentityPolicyInformationSourceConstructorOptions } from \"../models/IIdentityPolicyInformationSourceConstructorOptions.js\";\n\n/**\n * Policy information source which retrieves the identity information.\n */\nexport class IdentityPolicyInformationSource implements IPolicyInformationSource {\n\t/**\n\t * The class name of the Identity Policy Information Source.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityPolicyInformationSource>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * The identity resolver component.\n\t * @internal\n\t */\n\tprivate readonly _identityResolver: IIdentityResolverComponent;\n\n\t/**\n\t * Create a new instance of IdentityPolicyInformationSource.\n\t * @param options The options for the logging policy source.\n\t */\n\tconstructor(options?: IIdentityPolicyInformationSourceConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\t\tthis._identityResolver = ComponentFactory.get(\n\t\t\toptions?.identityResolverComponentType ?? \"identity-resolver\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityPolicyInformationSource.CLASS_NAME;\n\t}\n\n\t/**\n\t * Retrieve information from the sources.\n\t * @param 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: IOdrlPolicy | undefined,\n\t\taccessMode: PolicyInformationAccessMode,\n\t\tdata?: D,\n\t\taction?: ActionType | 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<IOdrlPolicy>(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"]}
|
|
@@ -52,7 +52,7 @@ export class StaticPolicyInformationSource {
|
|
|
52
52
|
ts: Date.now(),
|
|
53
53
|
message: "staticRetrieving",
|
|
54
54
|
data: {
|
|
55
|
-
policyId: policy
|
|
55
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
56
56
|
accessMode
|
|
57
57
|
}
|
|
58
58
|
});
|
|
@@ -76,7 +76,7 @@ export class StaticPolicyInformationSource {
|
|
|
76
76
|
ts: Date.now(),
|
|
77
77
|
message: "staticRetrieved",
|
|
78
78
|
data: {
|
|
79
|
-
policyId: policy
|
|
79
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
80
80
|
accessMode,
|
|
81
81
|
itemCount: Object.keys(information).length
|
|
82
82
|
}
|
|
@@ -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,EAE3B,MAAM,oCAAoC,CAAC;AAK5C;;GAEG;AACH,MAAM,OAAO,6BAA6B;IACzC;;OAEG;IACI,MAAM,CAAU,UAAU,mCAAmD;IAEpF;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,YAAY,CAAmC;IAEhE;;;OAGG;IACH,YAAY,OAA0D;QACrE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAC3C,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,IAAI,EAAE,CAAC;IACxD,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,6BAA6B,CAAC,UAAU,CAAC;IACjD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,QAAQ,CACpB,MAA+B,EAC/B,UAAuC,EACvC,IAAQ,EACR,MAA4B;QAE5B,MAAM,CAAC,UAAU,CAChB,6BAA6B,CAAC,UAAU,gBAExC,UAAU,EACV,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAC1C,CAAC;QAEF,IAAI,WAAW,GAAwC,EAAE,CAAC;QAE1D,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;YACxB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,6BAA6B,CAAC,UAAU;YAChD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,kBAAkB;YAC3B,IAAI,EAAE;gBACL,QAAQ,EAAE,MAAM,
|
|
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,EAE3B,MAAM,oCAAoC,CAAC;AAK5C;;GAEG;AACH,MAAM,OAAO,6BAA6B;IACzC;;OAEG;IACI,MAAM,CAAU,UAAU,mCAAmD;IAEpF;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,YAAY,CAAmC;IAEhE;;;OAGG;IACH,YAAY,OAA0D;QACrE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAC3C,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,IAAI,EAAE,CAAC;IACxD,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,6BAA6B,CAAC,UAAU,CAAC;IACjD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,QAAQ,CACpB,MAA+B,EAC/B,UAAuC,EACvC,IAAQ,EACR,MAA4B;QAE5B,MAAM,CAAC,UAAU,CAChB,6BAA6B,CAAC,UAAU,gBAExC,UAAU,EACV,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAC1C,CAAC;QAEF,IAAI,WAAW,GAAwC,EAAE,CAAC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AO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IACtE,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,IAAoC;QACzD,MAAM,CAAC,UAAU,CAChB,6BAA6B,CAAC,UAAU,qBAExC,IAAI,CAAC,UAAU,EACf,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAC1C,CAAC;QACF,MAAM,CAAC,WAAW,CACjB,6BAA6B,CAAC,UAAU,kBAExC,IAAI,CAAC,OAAO,CACZ,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\tPolicyInformationAccessMode,\n\ttype IPolicyInformationSource\n} from \"@twin.org/rights-management-models\";\nimport type { ActionType, IOdrlPolicy } from \"@twin.org/standards-w3c-odrl\";\nimport type { IStaticPolicyInformationSource } from \"../models/IStaticPolicyInformationSource.js\";\nimport type { IStaticPolicyInformationSourceConstructorOptions } from \"../models/IStaticPolicyInformationSourceConstructorOptions.js\";\n\n/**\n * Policy information source which retrieves static information.\n */\nexport class StaticPolicyInformationSource implements IPolicyInformationSource {\n\t/**\n\t * The class name of the Static Policy Information Source.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<StaticPolicyInformationSource>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * The information sources.\n\t * @internal\n\t */\n\tprivate readonly _information: IStaticPolicyInformationSource[];\n\n\t/**\n\t * Create a new instance of StaticPolicyInformationSource.\n\t * @param options The options for the logging policy source.\n\t */\n\tconstructor(options?: IStaticPolicyInformationSourceConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\t\tthis._information = options?.config?.information ?? [];\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn StaticPolicyInformationSource.CLASS_NAME;\n\t}\n\n\t/**\n\t * Retrieve information from the sources.\n\t * @param 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: IOdrlPolicy | undefined,\n\t\taccessMode: PolicyInformationAccessMode,\n\t\tdata?: D,\n\t\taction?: ActionType | 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,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2025 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { ComponentFactory, Guards, ObjectHelper } from "@twin.org/core";
|
|
4
|
+
import { OdrlPolicyHelper } from "@twin.org/rights-management-models";
|
|
4
5
|
import { PolicyType } from "@twin.org/standards-w3c-odrl";
|
|
5
6
|
/**
|
|
6
7
|
* Pass Through Policy Negotiator.
|
|
@@ -51,7 +52,7 @@ export class PassThroughPolicyNegotiator {
|
|
|
51
52
|
ts: Date.now(),
|
|
52
53
|
message: "handlingOffer",
|
|
53
54
|
data: {
|
|
54
|
-
offerId: offer
|
|
55
|
+
offerId: OdrlPolicyHelper.getUid(offer) ?? ""
|
|
55
56
|
}
|
|
56
57
|
});
|
|
57
58
|
return {
|
|
@@ -74,11 +75,11 @@ export class PassThroughPolicyNegotiator {
|
|
|
74
75
|
ts: Date.now(),
|
|
75
76
|
message: "createAgreement",
|
|
76
77
|
data: {
|
|
77
|
-
offerId: offer
|
|
78
|
+
offerId: OdrlPolicyHelper.getUid(offer) ?? ""
|
|
78
79
|
}
|
|
79
80
|
});
|
|
80
81
|
const agreement = ObjectHelper.clone(offer);
|
|
81
|
-
agreement
|
|
82
|
+
agreement["@type"] = PolicyType.Agreement;
|
|
82
83
|
agreement.assignee = assignee;
|
|
83
84
|
return agreement;
|
|
84
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passThroughPolicyNegotiator.js","sourceRoot":"","sources":["../../../src/policyNegotiators/passThroughPolicyNegotiator.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"passThroughPolicyNegotiator.js","sourceRoot":"","sources":["../../../src/policyNegotiators/passThroughPolicyNegotiator.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAIxE,OAAO,EAAE,gBAAgB,EAA0B,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EAEN,UAAU,EAIV,MAAM,8BAA8B,CAAC;AAGtC;;GAEG;AACH,MAAM,OAAO,2BAA2B;IACvC;;OAEG;IACI,MAAM,CAAU,UAAU,iCAAiD;IAElF;;;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CAAC,KAAK,CAAC,IAAI,EAAE;aAC7C;SACD,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAc,KAAK,CAAC,CAAC;QAEzD,SAAS,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC;QAC1C,SAAS,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAE9B,OAAO,SAA2B,CAAC;IACpC,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards, ObjectHelper } 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 { OdrlPolicyHelper, type IPolicyNegotiator } from \"@twin.org/rights-management-models\";\nimport {\n\ttype IOdrlPolicy,\n\tPolicyType,\n\ttype IOdrlAgreement,\n\ttype IOdrlOffer,\n\ttype IOdrlParty\n} from \"@twin.org/standards-w3c-odrl\";\nimport type { IPassThroughPolicyNegotiatorConstructorOptions } from \"../models/IPassThroughPolicyNegotiatorConstructorOptions.js\";\n\n/**\n * Pass Through Policy Negotiator.\n */\nexport class PassThroughPolicyNegotiator implements IPolicyNegotiator {\n\t/**\n\t * The class name of the Pass Through Policy Negotiator.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<PassThroughPolicyNegotiator>();\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 PassThroughPolicyNegotiator.\n\t * @param options The options for the pass through policy negotiator.\n\t */\n\tconstructor(options?: IPassThroughPolicyNegotiatorConstructorOptions) {\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 PassThroughPolicyNegotiator.CLASS_NAME;\n\t}\n\n\t/**\n\t * Determines if the negotiator supports the given offer.\n\t * @param offer The offer to check.\n\t * @returns Sets the supports flag if it can be offered, and the interventionRequired flag if manual agreement is needed.\n\t */\n\tpublic supportsOffer(offer: IOdrlOffer): boolean {\n\t\treturn true;\n\t}\n\n\t/**\n\t * Handle the offer.\n\t * @param offer The offer to check.\n\t * @param information Information provided by the requester to determine if a policy can be created.\n\t * @returns Sets the accepted flag if it can be offered, and the interventionRequired flag if manual agreement is needed.\n\t */\n\tpublic async handleOffer(\n\t\toffer: IOdrlOffer,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject }\n\t): Promise<{\n\t\taccepted: boolean;\n\t\tinterventionRequired: boolean;\n\t}> {\n\t\tGuards.object<IOdrlOffer>(PassThroughPolicyNegotiator.CLASS_NAME, nameof(offer), offer);\n\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyNegotiator.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"handlingOffer\",\n\t\t\tdata: {\n\t\t\t\tofferId: OdrlPolicyHelper.getUid(offer) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\taccepted: true,\n\t\t\tinterventionRequired: false\n\t\t};\n\t}\n\n\t/**\n\t * Create an agreement based on the offer.\n\t * @param offer The offer to create the agreement from.\n\t * @param assignee The assignee of the agreement.\n\t * @param information Information provided by the requester to aid in the creation of the agreement.\n\t * @returns The agreement created from the offer or undefined if an agreement could not be created.\n\t */\n\tpublic async createAgreement(\n\t\toffer: IOdrlOffer,\n\t\tassignee: string | IOdrlParty,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject }\n\t): Promise<IOdrlAgreement | undefined> {\n\t\tGuards.object<IOdrlOffer>(PassThroughPolicyNegotiator.CLASS_NAME, nameof(offer), offer);\n\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyNegotiator.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"createAgreement\",\n\t\t\tdata: {\n\t\t\t\tofferId: OdrlPolicyHelper.getUid(offer) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\tconst agreement = ObjectHelper.clone<IOdrlPolicy>(offer);\n\n\t\tagreement[\"@type\"] = PolicyType.Agreement;\n\t\tagreement.assignee = assignee;\n\n\t\treturn agreement as IOdrlAgreement;\n\t}\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2025 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { ComponentFactory, Guards } from "@twin.org/core";
|
|
4
|
+
import { OdrlPolicyHelper } from "@twin.org/rights-management-models";
|
|
4
5
|
/**
|
|
5
6
|
* Pass Through Policy Obligation Enforcer.
|
|
6
7
|
*/
|
|
@@ -46,7 +47,7 @@ export class PassThroughPolicyObligationEnforcer {
|
|
|
46
47
|
ts: Date.now(),
|
|
47
48
|
message: "enforcingDuty",
|
|
48
49
|
data: {
|
|
49
|
-
policyId: policy
|
|
50
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? ""
|
|
50
51
|
}
|
|
51
52
|
});
|
|
52
53
|
return true;
|
|
@@ -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;
|
|
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,EAEhB,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,MAAmB,EACnB,IAAe,EACf,WAAiD,EACjD,IAAQ,EACR,MAA4B;QAE5B,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} from \"@twin.org/rights-management-models\";\nimport type { ActionType, IOdrlDuty, IOdrlPolicy } 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: IOdrlPolicy,\n\t\tduty: IOdrlDuty,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: D,\n\t\taction?: ActionType | string\n\t): Promise<boolean> {\n\t\tGuards.object<IOdrlPolicy>(\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"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2025 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { ComponentFactory } from "@twin.org/core";
|
|
4
|
+
import { OdrlPolicyHelper } from "@twin.org/rights-management-models";
|
|
4
5
|
/**
|
|
5
6
|
* Pass Through Policy Requester.
|
|
6
7
|
*/
|
|
@@ -42,7 +43,7 @@ export class PassThroughPolicyRequester {
|
|
|
42
43
|
message: "offer",
|
|
43
44
|
data: {
|
|
44
45
|
negotiationId,
|
|
45
|
-
offerId: offer
|
|
46
|
+
offerId: OdrlPolicyHelper.getUid(offer) ?? ""
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
return true;
|
|
@@ -61,7 +62,7 @@ export class PassThroughPolicyRequester {
|
|
|
61
62
|
message: "agreement",
|
|
62
63
|
data: {
|
|
63
64
|
negotiationId,
|
|
64
|
-
agreementId: agreement
|
|
65
|
+
agreementId: OdrlPolicyHelper.getUid(agreement) ?? ""
|
|
65
66
|
}
|
|
66
67
|
});
|
|
67
68
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passThroughPolicyRequester.js","sourceRoot":"","sources":["../../../src/policyRequesters/passThroughPolicyRequester.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"passThroughP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AAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;aACrD;SACD,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,SAAS,CAAC,aAAqB;QAC3C,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,0BAA0B,CAAC,UAAU;YAC7C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,WAAW;YACpB,IAAI,EAAE;gBACL,aAAa;aACb;SACD,CAAC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,UAAU,CAAC,aAAqB;QAC5C,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,0BAA0B,CAAC,UAAU;YAC7C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,YAAY;YACrB,IAAI,EAAE;gBACL,aAAa;aACb;SACD,CAAC,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { OdrlPolicyHelper, type IPolicyRequester } from \"@twin.org/rights-management-models\";\nimport type { IOdrlAgreement, IOdrlOffer } from \"@twin.org/standards-w3c-odrl\";\nimport type { IPassThroughPolicyRequesterConstructorOptions } from \"../models/IPassThroughPolicyRequesterConstructorOptions.js\";\n\n/**\n * Pass Through Policy Requester.\n */\nexport class PassThroughPolicyRequester implements IPolicyRequester {\n\t/**\n\t * The class name of the Pass Through Policy Requester.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<PassThroughPolicyRequester>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging: ILoggingComponent;\n\n\t/**\n\t * Create a new instance of PassThroughPolicyRequester.\n\t * @param options The options for the pass through policy Requester.\n\t */\n\tconstructor(options?: IPassThroughPolicyRequesterConstructorOptions) {\n\t\tthis._logging = ComponentFactory.get<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn PassThroughPolicyRequester.CLASS_NAME;\n\t}\n\n\t/**\n\t * A policy has been offered by a provider, let the request handler know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @param offer The offer sent by the provider.\n\t * @returns True if the offer was accepted, false otherwise.\n\t */\n\tpublic async offer(negotiationId: string, offer: IOdrlOffer): Promise<boolean> {\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyRequester.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"offer\",\n\t\t\tdata: {\n\t\t\t\tnegotiationId,\n\t\t\t\tofferId: OdrlPolicyHelper.getUid(offer) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * A policy agreement has been sent by a provider, let the request handler know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @param agreement The agreement sent by the provider.\n\t * @returns True if the agreement was accepted, false otherwise.\n\t */\n\tpublic async agreement(negotiationId: string, agreement: IOdrlAgreement): Promise<boolean> {\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyRequester.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"agreement\",\n\t\t\tdata: {\n\t\t\t\tnegotiationId,\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * A policy finalisation has been sent by a provider, let the request handler know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @returns Nothing.\n\t */\n\tpublic async finalised(negotiationId: string): Promise<void> {\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyRequester.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"finalised\",\n\t\t\tdata: {\n\t\t\t\tnegotiationId\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * A policy termination has been sent by a provider, let the request handler know about it.\n\t * @param negotiationId The id of the negotiation.\n\t * @returns Nothing.\n\t */\n\tpublic async terminated(negotiationId: string): Promise<void> {\n\t\tawait this._logging.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyRequester.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"terminated\",\n\t\t\tdata: {\n\t\t\t\tnegotiationId\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IPolicyDecision, type IPolicyEnforcementProcessor } from "@twin.org/rights-management-models";
|
|
2
2
|
import type { ActionType, IOdrlAgreement } from "@twin.org/standards-w3c-odrl";
|
|
3
3
|
import type { IPassThroughPolicyEnforcementProcessorConstructorOptions } from "../models/IPassThroughPolicyEnforcementProcessorConstructorOptions.js";
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
-
import type
|
|
2
|
+
import { type IPolicyNegotiator } from "@twin.org/rights-management-models";
|
|
3
3
|
import { type IOdrlAgreement, type IOdrlOffer, type IOdrlParty } from "@twin.org/standards-w3c-odrl";
|
|
4
4
|
import type { IPassThroughPolicyNegotiatorConstructorOptions } from "../models/IPassThroughPolicyNegotiatorConstructorOptions.js";
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
2
|
-
import type
|
|
2
|
+
import { type IPolicyObligationEnforcer } from "@twin.org/rights-management-models";
|
|
3
3
|
import type { ActionType, IOdrlDuty, IOdrlPolicy } from "@twin.org/standards-w3c-odrl";
|
|
4
4
|
import type { IPassThroughPolicyObligationEnforcerConstructorOptions } from "../models/IPassThroughPolicyObligationEnforcerConstructorOptions.js";
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IPolicyRequester } from "@twin.org/rights-management-models";
|
|
2
2
|
import type { IOdrlAgreement, IOdrlOffer } from "@twin.org/standards-w3c-odrl";
|
|
3
3
|
import type { IPassThroughPolicyRequesterConstructorOptions } from "../models/IPassThroughPolicyRequesterConstructorOptions.js";
|
|
4
4
|
/**
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.17](https://github.com/twinfoundation/rights-management/compare/rights-management-plugins-v0.0.3-next.16...rights-management-plugins-v0.0.3-next.17) (2026-02-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add default enforcement processor ([#73](https://github.com/twinfoundation/rights-management/issues/73)) ([0c64d49](https://github.com/twinfoundation/rights-management/commit/0c64d49bab363b3da6d197536a605f7929a7c584))
|
|
9
|
+
* add default policy arbiter ([#76](https://github.com/twinfoundation/rights-management/issues/76)) ([b62ff9c](https://github.com/twinfoundation/rights-management/commit/b62ff9ce1b3400c4a95909da01863af47f430dbf))
|
|
10
|
+
* add factory pattern ([d26b4c0](https://github.com/twinfoundation/rights-management/commit/d26b4c08a2f3ba5758df66a1c48203b8d8e3638e))
|
|
11
|
+
* add missing dependency ([f7c8e0e](https://github.com/twinfoundation/rights-management/commit/f7c8e0e4819c945ef823b853139440ad7999b9b9))
|
|
12
|
+
* add missing dependency ([c62a098](https://github.com/twinfoundation/rights-management/commit/c62a0983e912c252ab0c27261c9bb92a63c06f96))
|
|
13
|
+
* consistent uid usage ([#83](https://github.com/twinfoundation/rights-management/issues/83)) ([bdfb9f9](https://github.com/twinfoundation/rights-management/commit/bdfb9f92777cbfdb65b5b7df5660b70d869ed19d))
|
|
14
|
+
* policy negotiator callback ([#77](https://github.com/twinfoundation/rights-management/issues/77)) ([6566ed0](https://github.com/twinfoundation/rights-management/commit/6566ed0e2186b6445f1669f9b2f88a6ce059ab83))
|
|
15
|
+
* remove data access point ([#67](https://github.com/twinfoundation/rights-management/issues/67)) ([8573676](https://github.com/twinfoundation/rights-management/commit/8573676862c9f1634a66a0677b225b4de16a89cd))
|
|
16
|
+
* update processors ([#71](https://github.com/twinfoundation/rights-management/issues/71)) ([d6e8c1e](https://github.com/twinfoundation/rights-management/commit/d6e8c1e593acb28556674d5180123f220766eb6b))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Dependencies
|
|
20
|
+
|
|
21
|
+
* The following workspace dependencies were updated
|
|
22
|
+
* dependencies
|
|
23
|
+
* @twin.org/rights-management-models bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
24
|
+
* devDependencies
|
|
25
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
26
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
27
|
+
* @twin.org/rights-management-pep-service bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
28
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
29
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
30
|
+
* @twin.org/rights-management-pnp-service bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
31
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
32
|
+
|
|
33
|
+
## [0.0.3-next.16](https://github.com/twinfoundation/rights-management/compare/rights-management-plugins-v0.0.3-next.15...rights-management-plugins-v0.0.3-next.16) (2026-02-24)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Miscellaneous Chores
|
|
37
|
+
|
|
38
|
+
* **rights-management-plugins:** Synchronize repo versions
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Dependencies
|
|
42
|
+
|
|
43
|
+
* The following workspace dependencies were updated
|
|
44
|
+
* dependencies
|
|
45
|
+
* @twin.org/rights-management-models bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
46
|
+
* devDependencies
|
|
47
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
48
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
49
|
+
* @twin.org/rights-management-pep-service bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
50
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
51
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
52
|
+
* @twin.org/rights-management-pnp-service bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
53
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
54
|
+
|
|
55
|
+
## [0.0.3-next.15](https://github.com/twinfoundation/rights-management/compare/rights-management-plugins-v0.0.3-next.14...rights-management-plugins-v0.0.3-next.15) (2026-02-12)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Miscellaneous Chores
|
|
59
|
+
|
|
60
|
+
* **rights-management-plugins:** Synchronize repo versions
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Dependencies
|
|
64
|
+
|
|
65
|
+
* The following workspace dependencies were updated
|
|
66
|
+
* dependencies
|
|
67
|
+
* @twin.org/rights-management-models bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
68
|
+
* devDependencies
|
|
69
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
70
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
71
|
+
* @twin.org/rights-management-pep-service bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
72
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
73
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
74
|
+
* @twin.org/rights-management-pnp-service bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
75
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
76
|
+
|
|
3
77
|
## [0.0.3-next.14](https://github.com/twinfoundation/rights-management/compare/rights-management-plugins-v0.0.3-next.13...rights-management-plugins-v0.0.3-next.14) (2026-02-12)
|
|
4
78
|
|
|
5
79
|
|
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.17",
|
|
4
4
|
"description": "Rights management plugin implementations",
|
|
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.17",
|
|
28
28
|
"@twin.org/standards-w3c-odrl": "next"
|
|
29
29
|
},
|
|
30
30
|
"main": "./dist/es/index.js",
|