@twin.org/rights-management-plugins 0.0.3-next.13 → 0.0.3-next.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/es/index.js +5 -0
  2. package/dist/es/index.js.map +1 -1
  3. package/dist/es/models/IDefaultPolicyArbiterConfig.js +4 -0
  4. package/dist/es/models/IDefaultPolicyArbiterConfig.js.map +1 -0
  5. package/dist/es/models/IDefaultPolicyArbiterConstructorOptions.js +4 -0
  6. package/dist/es/models/IDefaultPolicyArbiterConstructorOptions.js.map +1 -0
  7. package/dist/es/models/IPassThroughPolicyObligationEnforcerConstructorOptions.js +4 -0
  8. package/dist/es/models/IPassThroughPolicyObligationEnforcerConstructorOptions.js.map +1 -0
  9. package/dist/es/policyArbiters/defaultPolicyArbiter.js +824 -0
  10. package/dist/es/policyArbiters/defaultPolicyArbiter.js.map +1 -0
  11. package/dist/es/policyArbiters/passThroughPolicyArbiter.js +5 -4
  12. package/dist/es/policyArbiters/passThroughPolicyArbiter.js.map +1 -1
  13. package/dist/es/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.js +5 -4
  14. package/dist/es/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.js.map +1 -1
  15. package/dist/es/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.js +5 -4
  16. package/dist/es/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.js.map +1 -1
  17. package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js +4 -1
  18. package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js.map +1 -1
  19. package/dist/es/policyInformationSources/identityPolicyInformationSource.js +2 -1
  20. package/dist/es/policyInformationSources/identityPolicyInformationSource.js.map +1 -1
  21. package/dist/es/policyInformationSources/staticPolicyInformationSource.js +2 -1
  22. package/dist/es/policyInformationSources/staticPolicyInformationSource.js.map +1 -1
  23. package/dist/es/policyObligationEnforcers/passThroughPolicyObligationEnforcer.js +55 -0
  24. package/dist/es/policyObligationEnforcers/passThroughPolicyObligationEnforcer.js.map +1 -0
  25. package/dist/types/index.d.ts +5 -0
  26. package/dist/types/models/IDefaultPolicyArbiterConfig.d.ts +10 -0
  27. package/dist/types/models/IDefaultPolicyArbiterConstructorOptions.d.ts +20 -0
  28. package/dist/types/models/IPassThroughPolicyObligationEnforcerConstructorOptions.d.ts +10 -0
  29. package/dist/types/policyArbiters/defaultPolicyArbiter.d.ts +34 -0
  30. package/dist/types/policyArbiters/passThroughPolicyArbiter.d.ts +5 -4
  31. package/dist/types/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.d.ts +4 -3
  32. package/dist/types/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.d.ts +4 -3
  33. package/dist/types/policyExecutionActions/loggingPolicyExecutionAction.d.ts +3 -2
  34. package/dist/types/policyInformationSources/identityPolicyInformationSource.d.ts +3 -2
  35. package/dist/types/policyInformationSources/staticPolicyInformationSource.d.ts +3 -2
  36. package/dist/types/policyObligationEnforcers/passThroughPolicyObligationEnforcer.d.ts +35 -0
  37. package/docs/changelog.md +23 -0
  38. package/docs/reference/classes/DefaultPolicyArbiter.md +101 -0
  39. package/docs/reference/classes/DefaultPolicyEnforcementProcessor.md +10 -4
  40. package/docs/reference/classes/IdentityPolicyInformationSource.md +7 -1
  41. package/docs/reference/classes/LoggingPolicyExecutionAction.md +7 -1
  42. package/docs/reference/classes/PassThroughPolicyArbiter.md +10 -4
  43. package/docs/reference/classes/PassThroughPolicyEnforcementProcessor.md +10 -4
  44. package/docs/reference/classes/PassThroughPolicyObligationEnforcer.md +107 -0
  45. package/docs/reference/classes/StaticPolicyInformationSource.md +7 -1
  46. package/docs/reference/index.md +5 -0
  47. package/docs/reference/interfaces/IDefaultPolicyArbiterConfig.md +17 -0
  48. package/docs/reference/interfaces/IDefaultPolicyArbiterConstructorOptions.md +39 -0
  49. package/docs/reference/interfaces/IPassThroughPolicyObligationEnforcerConstructorOptions.md +17 -0
  50. package/locales/en.json +16 -0
  51. package/package.json +2 -2
@@ -0,0 +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,YAAY,OAAiD;QAC5D,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;QAEF,IAAI,CAAC,0BAA0B,GAAG,gBAAgB,CAAC,GAAG,CACrD,OAAO,EAAE,sCAAsC,IAAI,6BAA6B,CAChF,CAAC;QAEF,IAAI,CAAC,oBAAoB;YACxB,MAAM,CA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\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"]}
@@ -31,20 +31,21 @@ export class PassThroughPolicyArbiter {
31
31
  }
32
32
  /**
33
33
  * Makes decisions regarding policy access to data.
34
- * @param policy The policy to evaluate.
34
+ * @param agreement The agreement to evaluate.
35
35
  * @param information Information provided by the requester to determine if a policy can be created.
36
36
  * @param data The data to make a decision on.
37
+ * @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
37
38
  * @returns The decisions about access to the data.
38
39
  */
39
- async decide(policy, information, data) {
40
- Guards.object(PassThroughPolicyArbiter.CLASS_NAME, "policy", policy);
40
+ async decide(agreement, information, data, action) {
41
+ Guards.object(PassThroughPolicyArbiter.CLASS_NAME, "agreement", agreement);
41
42
  await this._logging.log({
42
43
  level: "info",
43
44
  source: PassThroughPolicyArbiter.CLASS_NAME,
44
45
  ts: Date.now(),
45
46
  message: "decidingPolicy",
46
47
  data: {
47
- policyId: policy.uid
48
+ policyId: agreement.uid
48
49
  }
49
50
  });
50
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;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CAClB,MAAmB,EACnB,WAAiD,EACjD,IAAQ;QAER,MAAM,CAAC,MAAM,CAAc,wBAAwB,CAAC,UAAU,YAAkB,MAAM,CAAC,CAAC;QAExF,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,MAAM,CAAC,GAAG;aACpB;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\tPolicyDecision,\n\ttype IPolicyArbiter,\n\ttype IPolicyDecision\n} from \"@twin.org/rights-management-models\";\nimport type { IOdrlPolicy } 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 policy The policy 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 * @returns The decisions about access to the data.\n\t */\n\tpublic async decide<D = unknown>(\n\t\tpolicy: IOdrlPolicy,\n\t\tinformation?: { [id: string]: IJsonLdNodeObject },\n\t\tdata?: D\n\t): Promise<IPolicyDecision[]> {\n\t\tGuards.object<IOdrlPolicy>(PassThroughPolicyArbiter.CLASS_NAME, nameof(policy), policy);\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: policy.uid\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"]}
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,GAAG;aACvB;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\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: agreement.uid\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"]}
@@ -32,20 +32,21 @@ export class DefaultPolicyEnforcementProcessor {
32
32
  }
33
33
  /**
34
34
  * Process the response from the policy decision point.
35
- * @param policy The policy to process.
35
+ * @param agreement The agreement to process.
36
36
  * @param decisions The decisions made by the policy decision point.
37
37
  * @param data The data to process.
38
+ * @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
38
39
  * @returns The data after processing.
39
40
  */
40
- async process(policy, decisions, data) {
41
- Guards.object(DefaultPolicyEnforcementProcessor.CLASS_NAME, "policy", policy);
41
+ async process(agreement, decisions, data, action) {
42
+ Guards.object(DefaultPolicyEnforcementProcessor.CLASS_NAME, "agreement", agreement);
42
43
  await this._logging.log({
43
44
  level: "info",
44
45
  source: DefaultPolicyEnforcementProcessor.CLASS_NAME,
45
46
  ts: Date.now(),
46
47
  message: "processingPolicy",
47
48
  data: {
48
- policyId: policy.uid
49
+ policyId: agreement.uid
49
50
  }
50
51
  });
51
52
  const isOriginalEmpty = Is.empty(data);
@@ -1 +1 @@
1
- {"version":3,"file":"defaultPolicyEnforcementProcessor.js","source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AC;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 { IOdrlPolicy } 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 policy The policy to process.\n\t * @param decisions The decisions made by the policy decision point.\n\t * @param data The data to process.\n\t * @returns The data after processing.\n\t */\n\tpublic async process<D = unknown, R = D>(\n\t\tpolicy: IOdrlPolicy,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata?: D\n\t): Promise<R> {\n\t\tGuards.object<IOdrlPolicy>(\n\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tnameof(policy),\n\t\t\tpolicy\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: policy.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,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,QAAQ,EAAE,SAAS,CAAC,GAAG;aACvB;SACD,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;Q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Ac,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\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"]}
@@ -30,20 +30,21 @@ export class PassThroughPolicyEnforcementProcessor {
30
30
  }
31
31
  /**
32
32
  * Process the response from the policy decision point.
33
- * @param policy The policy to process.
33
+ * @param agreement The agreement to process.
34
34
  * @param decisions The decisions made by the policy decision point.
35
35
  * @param data The data to process.
36
+ * @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
36
37
  * @returns The data after processing.
37
38
  */
38
- async process(policy, decisions, data) {
39
- Guards.object(PassThroughPolicyEnforcementProcessor.CLASS_NAME, "policy", policy);
39
+ async process(agreement, decisions, data, action) {
40
+ Guards.object(PassThroughPolicyEnforcementProcessor.CLASS_NAME, "agreement", agreement);
40
41
  await this._logging.log({
41
42
  level: "info",
42
43
  source: PassThroughPolicyEnforcementProcessor.CLASS_NAME,
43
44
  ts: Date.now(),
44
45
  message: "processingPolicy",
45
46
  data: {
46
- policyId: policy.uid
47
+ policyId: agreement.uid
47
48
  }
48
49
  });
49
50
  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;AAU1D;;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;;;;;;OAMG;IACI,KAAK,CAAC,OAAO,CACnB,MAAmB,EACnB,SAA4B,EAC5B,IAAQ;QAER,MAAM,CAAC,MAAM,CACZ,qCAAqC,CAAC,UAAU,YAEhD,MAAM,CACN,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,MAAM,CAAC,GAAG;aACpB;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 type {\n\tIPolicyDecision,\n\tIPolicyEnforcementProcessor\n} from \"@twin.org/rights-management-models\";\nimport type { IOdrlPolicy } 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 policy The policy to process.\n\t * @param decisions The decisions made by the policy decision point.\n\t * @param data The data to process.\n\t * @returns The data after processing.\n\t */\n\tpublic async process<D = unknown, R = D>(\n\t\tpolicy: IOdrlPolicy,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata?: D\n\t): Promise<R> {\n\t\tGuards.object<IOdrlPolicy>(\n\t\t\tPassThroughPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tnameof(policy),\n\t\t\tpolicy\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: policy.uid\n\t\t\t}\n\t\t});\n\n\t\treturn data as unknown as R;\n\t}\n}\n"]}
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;AAU1D;;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,SAAS,CAAC,GAAG;aACvB;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 type {\n\tIPolicyDecision,\n\tIPolicyEnforcementProcessor\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: agreement.uid\n\t\t\t}\n\t\t});\n\n\t\treturn data as unknown as R;\n\t}\n}\n"]}
@@ -65,10 +65,11 @@ export class LoggingPolicyExecutionAction {
65
65
  * @param policy The policy that applied to the data.
66
66
  * @param decisions The decisions made by the PDP.
67
67
  * @param data The data to process.
68
+ * @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
68
69
  * @param stage The stage of the policy decision.
69
70
  * @returns A promise that resolves when the action is complete.
70
71
  */
71
- async execute(policy, decisions, data, stage) {
72
+ async execute(policy, decisions, data, action, stage) {
72
73
  Guards.arrayOneOf(LoggingPolicyExecutionAction.CLASS_NAME, "stage", stage, Object.values(PolicyDecisionStage));
73
74
  if (this._stages.includes(stage)) {
74
75
  // Even if we don't have the options to include data or include policy we
@@ -90,6 +91,7 @@ export class LoggingPolicyExecutionAction {
90
91
  data: logData,
91
92
  policy: logPolicy,
92
93
  decisions: logDecisions,
94
+ action,
93
95
  stage
94
96
  }
95
97
  });
@@ -105,6 +107,7 @@ export class LoggingPolicyExecutionAction {
105
107
  data: logData,
106
108
  policy: logPolicy,
107
109
  decisions: logDecisions,
110
+ action,
108
111
  stage
109
112
  }
110
113
  });
@@ -1 +1 @@
1
- {"version":3,"file":"loggingPolicyExecutionAction.js","sourceRoot":"","sources":["../../../src/policyExecutionActions/loggingPolicyExecutionAction.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAGN,mBAAmB,EACnB,MAAM,oCAAoC,CAAC;AAI5C;;GAEG;AACH,MAAM,OAAO,4BAA4B;IACxC;;OAEG;IACI,MAAM,CAAU,UAAU,kCAAkD;IAEnF;;;OAGG;IACc,QAAQ,CAAoB;IAE7C;;;OAGG;IACc,OAAO,CAAwB;IAEhD;;OAEG;IACc,YAAY,CAAU;IAEvC;;OAEG;IACc,cAAc,CAAU;IAEzC;;OAEG;IACc,iBAAiB,CAAU;IAE5C;;;OAGG;IACH,YAAY,OAAyD;QACpE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACnC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAC1C,CAAC;QAEF,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI;YACzC,mBAAmB,CAAC,MAAM;YAC1B,mBAAmB,CAAC,KAAK;S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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,GAAG;wBACpB,IAAI,EAAE,OAAO;wBACb,MAAM,EAAE,SAAS;wBACjB,SAAS,EAAE,YAAY;wBACvB,KAAK;qBACL;iBACD,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACP,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;oBACvB,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,4BAA4B,CAAC,UAAU;oBAC/C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;oBACd,OAAO,EAAE,2BAA2B;oBACpC,IAAI,EAAE;wBACL,QAAQ,EAAE,MAAM,CAAC,GAAG;wBACpB,IAAI,EAAE,OAAO;wBACb,MAAM,EAAE,SAAS;wBACjB,SAAS,EAAE,YAAY;wBACvB,KAAK;qBACL;iBACD,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\ttype IPolicyDecision,\n\ttype IPolicyExecutionAction,\n\tPolicyDecisionStage\n} from \"@twin.org/rights-management-models\";\nimport type { 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 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\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: policy.uid,\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\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: policy.uid,\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\tstage\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"loggingPolicyExecutionAction.js","sourceRoot":"","sources":["../../../src/policyExecutionAct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AA2B;oBACpC,IAAI,EAAE;wBACL,QAAQ,EAAE,MAAM,CAAC,GAAG;wBACpB,IAAI,EAAE,OAAO;wBACb,MAAM,EAAE,SAAS;wBACjB,SAAS,EAAE,YAAY;wBACvB,MAAM;wBACN,KAAK;qBACL;iBACD,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\ttype IPolicyDecision,\n\ttype IPolicyExecutionAction,\n\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: policy.uid,\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: policy.uid,\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"]}
@@ -41,9 +41,10 @@ export class IdentityPolicyInformationSource {
41
41
  * @param policy The policy to retrieve information for if available.
42
42
  * @param accessMode The access mode to use for the retrieval.
43
43
  * @param data The data to process.
44
+ * @param action The action that was evaluated.
44
45
  * @returns The objects containing relevant information or undefined if nothing relevant is found.
45
46
  */
46
- async retrieve(policy, accessMode, data) {
47
+ async retrieve(policy, accessMode, data, action) {
47
48
  Guards.arrayOneOf(IdentityPolicyInformationSource.CLASS_NAME, "accessMode", accessMode, Object.values(PolicyInformationAccessMode));
48
49
  const information = {};
49
50
  if (Is.object(policy)) {
@@ -1 +1 @@
1
- {"version":3,"file":"identityPolicyInformationSource.js","sourceRoot":"","sources":["../../../src/policyInformationSources/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D,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,GAAG;4BACpB,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,MAAM,CAAC,GAAG;4BACpB,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\tPolicyInformationAccessMode\n} from \"@twin.org/rights-management-models\";\nimport type { IOdrlPolicy } from \"@twin.org/standards-w3c-odrl\";\nimport type { IIdentityPolicyInformationSourceConstructorOptions } from \"../models/IIdentityPolicyInformationSourceConstructorOptions.js\";\n\n/**\n * Policy information source which retrieves the identity information.\n */\nexport class IdentityPolicyInformationSource implements IPolicyInformationSource {\n\t/**\n\t * The class name of the Identity Policy Information Source.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityPolicyInformationSource>();\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * The identity resolver component.\n\t * @internal\n\t */\n\tprivate readonly _identityResolver: IIdentityResolverComponent;\n\n\t/**\n\t * Create a new instance of IdentityPolicyInformationSource.\n\t * @param options The options for the logging policy source.\n\t */\n\tconstructor(options?: IIdentityPolicyInformationSourceConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\t\tthis._identityResolver = ComponentFactory.get(\n\t\t\toptions?.identityResolverComponentType ?? \"identity-resolver\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityPolicyInformationSource.CLASS_NAME;\n\t}\n\n\t/**\n\t * Retrieve information from the sources.\n\t * @param 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 * @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): 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: policy.uid,\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: policy.uid,\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror: BaseError.fromError(err)\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn information;\n\t}\n}\n"]}
1
+ {"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,CAA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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\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: policy.uid,\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: policy.uid,\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"]}
@@ -40,9 +40,10 @@ export class StaticPolicyInformationSource {
40
40
  * @param policy The policy to retrieve information for if available.
41
41
  * @param accessMode The access mode to use for the retrieval.
42
42
  * @param data The data to process.
43
+ * @param action The action to get any additional information for.
43
44
  * @returns The objects containing relevant information or undefined if nothing relevant is found.
44
45
  */
45
- async retrieve(policy, accessMode, data) {
46
+ async retrieve(policy, accessMode, data, action) {
46
47
  Guards.arrayOneOf(StaticPolicyInformationSource.CLASS_NAME, "accessMode", accessMode, Object.values(PolicyInformationAccessMode));
47
48
  let information = {};
48
49
  await this._logging?.log({
@@ -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;;;;;;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iB;YAC1B,IAAI,EAAE;gBACL,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE;gBAC3B,UAAU;gBACV,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM;aAC1C;SACD,CAAC,CAAC;QAEH,OAAO,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 { 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 * @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): 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: policy?.uid ?? \"\",\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: policy?.uid ?? \"\",\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
+ {"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,gBAAg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.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\tPolicyInformationAccessMode,\n\ttype IPolicyInformationSource\n} 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: policy?.uid ?? \"\",\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: policy?.uid ?? \"\",\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"]}
@@ -0,0 +1,55 @@
1
+ // Copyright 2025 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { ComponentFactory, Guards } from "@twin.org/core";
4
+ /**
5
+ * Pass Through Policy Obligation Enforcer.
6
+ */
7
+ export class PassThroughPolicyObligationEnforcer {
8
+ /**
9
+ * The class name of the Pass Through Policy Obligation Enforcer.
10
+ */
11
+ static CLASS_NAME = "PassThroughPolicyObligationEnforcer";
12
+ /**
13
+ * The logging component.
14
+ * @internal
15
+ */
16
+ _logging;
17
+ /**
18
+ * Create a new instance of Pass Through Policy Obligation Enforcer.
19
+ * @param options The options for the pass through policy obligation enforcer.
20
+ */
21
+ constructor(options) {
22
+ this._logging = ComponentFactory.get(options?.loggingComponentType ?? "logging");
23
+ }
24
+ /**
25
+ * Returns the class name of the component.
26
+ * @returns The class name of the component.
27
+ */
28
+ className() {
29
+ return PassThroughPolicyObligationEnforcer.CLASS_NAME;
30
+ }
31
+ /**
32
+ * Enforces obligations regarding policy access to data.
33
+ * @param policy The policy to evaluate.
34
+ * @param duty The duty to enforce.
35
+ * @param information Information provided by the requester to determine if a policy can be created.
36
+ * @param data The data to make a decision on.
37
+ * @param action Optional action to make a decision on, if not provided, the enforcer will evaluate all actions in the duty.
38
+ * @returns Whether the obligations were successfully enforced.
39
+ */
40
+ async enforce(policy, duty, information, data, action) {
41
+ Guards.object(PassThroughPolicyObligationEnforcer.CLASS_NAME, "policy", policy);
42
+ Guards.object(PassThroughPolicyObligationEnforcer.CLASS_NAME, "duty", duty);
43
+ await this._logging.log({
44
+ level: "info",
45
+ source: PassThroughPolicyObligationEnforcer.CLASS_NAME,
46
+ ts: Date.now(),
47
+ message: "enforcingDuty",
48
+ data: {
49
+ policyId: policy.uid
50
+ }
51
+ });
52
+ return true;
53
+ }
54
+ }
55
+ //# sourceMappingURL=passThroughPolicyObligationEnforcer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passThroughPolicyObligationEnforcer.js","sourceRoot":"","sources":["../../../src/policyObligationEnforcers/passThroughPolicyObligationEnforcer.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQ1D;;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,MAAM,CAAC,GAAG;aACpB;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 type { IPolicyObligationEnforcer } 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: policy.uid\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t}\n}\n"]}
@@ -1,3 +1,5 @@
1
+ export * from "./models/IDefaultPolicyArbiterConstructorOptions.js";
2
+ export * from "./models/IDefaultPolicyArbiterConfig.js";
1
3
  export * from "./models/IDefaultPolicyEnforcementProcessorConstructorOptions.js";
2
4
  export * from "./models/IIdentityPolicyInformationSourceConstructorOptions.js";
3
5
  export * from "./models/ILoggingPolicyExecutionActionConfig.js";
@@ -5,14 +7,17 @@ export * from "./models/ILoggingPolicyExecutionActionConstructorOptions.js";
5
7
  export * from "./models/IPassThroughPolicyArbiterConstructorOptions.js";
6
8
  export * from "./models/IPassThroughPolicyEnforcementProcessorConstructorOptions.js";
7
9
  export * from "./models/IPassThroughPolicyNegotiatorConstructorOptions.js";
10
+ export * from "./models/IPassThroughPolicyObligationEnforcerConstructorOptions.js";
8
11
  export * from "./models/IPassThroughPolicyRequesterConstructorOptions.js";
9
12
  export * from "./models/IStaticPolicyInformationSource.js";
10
13
  export * from "./models/IStaticPolicyInformationSourceConfig.js";
11
14
  export * from "./models/IStaticPolicyInformationSourceConstructorOptions.js";
15
+ export * from "./policyArbiters/defaultPolicyArbiter.js";
12
16
  export * from "./policyArbiters/passThroughPolicyArbiter.js";
13
17
  export * from "./policyEnforcementProcessor/defaultPolicyEnforcementProcessor.js";
14
18
  export * from "./policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.js";
15
19
  export * from "./policyExecutionActions/loggingPolicyExecutionAction.js";
20
+ export * from "./policyObligationEnforcers/passThroughPolicyObligationEnforcer.js";
16
21
  export * from "./policyInformationSources/identityPolicyInformationSource.js";
17
22
  export * from "./policyInformationSources/staticPolicyInformationSource.js";
18
23
  export * from "./policyNegotiators/passThroughPolicyNegotiator.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Configuration for the Default Policy Arbiter.
3
+ */
4
+ export interface IDefaultPolicyArbiterConfig {
5
+ /**
6
+ * The maximum depth to traverse when resolving inherited policies.
7
+ * @default 10
8
+ */
9
+ maxInheritanceDepth?: number;
10
+ }