@3sixty/rights-management-plugins 0.0.0-stage → 0.20.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +32 -2
- package/dist/es/index.js +34 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IAutomationPolicyExecutionActionConfig.js +4 -0
- package/dist/es/models/IAutomationPolicyExecutionActionConfig.js.map +1 -0
- package/dist/es/models/IAutomationPolicyExecutionActionConstructorOptions.js +2 -0
- package/dist/es/models/IAutomationPolicyExecutionActionConstructorOptions.js.map +1 -0
- package/dist/es/models/IDefaultPolicyArbiterConfig.js +4 -0
- package/dist/es/models/IDefaultPolicyArbiterConfig.js.map +1 -0
- package/dist/es/models/IDefaultPolicyArbiterConstructorOptions.js +4 -0
- package/dist/es/models/IDefaultPolicyArbiterConstructorOptions.js.map +1 -0
- package/dist/es/models/IDefaultPolicyEnforcementProcessorConfig.js +4 -0
- package/dist/es/models/IDefaultPolicyEnforcementProcessorConfig.js.map +1 -0
- package/dist/es/models/IDefaultPolicyEnforcementProcessorConstructorOptions.js +2 -0
- package/dist/es/models/IDefaultPolicyEnforcementProcessorConstructorOptions.js.map +1 -0
- package/dist/es/models/IIdentityPolicyInformationSourceConstructorOptions.js +4 -0
- package/dist/es/models/IIdentityPolicyInformationSourceConstructorOptions.js.map +1 -0
- package/dist/es/models/IIdentityProfilePolicyInformationSourceConstructorOptions.js +4 -0
- package/dist/es/models/IIdentityProfilePolicyInformationSourceConstructorOptions.js.map +1 -0
- package/dist/es/models/ILoggingPolicyExecutionActionConfig.js +2 -0
- package/dist/es/models/ILoggingPolicyExecutionActionConfig.js.map +1 -0
- package/dist/es/models/ILoggingPolicyExecutionActionConstructorOptions.js +2 -0
- package/dist/es/models/ILoggingPolicyExecutionActionConstructorOptions.js.map +1 -0
- package/dist/es/models/IPassThroughPolicyArbiterConstructorOptions.js +4 -0
- package/dist/es/models/IPassThroughPolicyArbiterConstructorOptions.js.map +1 -0
- package/dist/es/models/IPassThroughPolicyEnforcementProcessorConstructorOptions.js +4 -0
- package/dist/es/models/IPassThroughPolicyEnforcementProcessorConstructorOptions.js.map +1 -0
- package/dist/es/models/IPassThroughPolicyNegotiatorConfig.js +4 -0
- package/dist/es/models/IPassThroughPolicyNegotiatorConfig.js.map +1 -0
- package/dist/es/models/IPassThroughPolicyNegotiatorConstructorOptions.js +2 -0
- package/dist/es/models/IPassThroughPolicyNegotiatorConstructorOptions.js.map +1 -0
- package/dist/es/models/IPassThroughPolicyObligationEnforcerConstructorOptions.js +4 -0
- package/dist/es/models/IPassThroughPolicyObligationEnforcerConstructorOptions.js.map +1 -0
- package/dist/es/models/IPassThroughPolicyRequesterConstructorOptions.js +4 -0
- package/dist/es/models/IPassThroughPolicyRequesterConstructorOptions.js.map +1 -0
- package/dist/es/models/IStaticPolicyInformationSource.js +2 -0
- package/dist/es/models/IStaticPolicyInformationSource.js.map +1 -0
- package/dist/es/models/IStaticPolicyInformationSourceConfig.js +2 -0
- package/dist/es/models/IStaticPolicyInformationSourceConfig.js.map +1 -0
- package/dist/es/models/IStaticPolicyInformationSourceConstructorOptions.js +2 -0
- package/dist/es/models/IStaticPolicyInformationSourceConstructorOptions.js.map +1 -0
- package/dist/es/policyArbiters/defaultPolicyArbiter.js +1880 -0
- package/dist/es/policyArbiters/defaultPolicyArbiter.js.map +1 -0
- package/dist/es/policyArbiters/passThroughPolicyArbiter.js +59 -0
- package/dist/es/policyArbiters/passThroughPolicyArbiter.js.map +1 -0
- package/dist/es/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.js +198 -0
- package/dist/es/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.js.map +1 -0
- package/dist/es/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.js +54 -0
- package/dist/es/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.js.map +1 -0
- package/dist/es/policyExecutionActions/automationPolicyExecutionAction.js +77 -0
- package/dist/es/policyExecutionActions/automationPolicyExecutionAction.js.map +1 -0
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js +121 -0
- package/dist/es/policyExecutionActions/loggingPolicyExecutionAction.js.map +1 -0
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js +91 -0
- package/dist/es/policyInformationSources/identityPolicyInformationSource.js.map +1 -0
- package/dist/es/policyInformationSources/identityProfilePolicyInformationSource.js +112 -0
- package/dist/es/policyInformationSources/identityProfilePolicyInformationSource.js.map +1 -0
- package/dist/es/policyInformationSources/staticPolicyInformationSource.js +96 -0
- package/dist/es/policyInformationSources/staticPolicyInformationSource.js.map +1 -0
- package/dist/es/policyNegotiators/passThroughPolicyNegotiator.js +95 -0
- package/dist/es/policyNegotiators/passThroughPolicyNegotiator.js.map +1 -0
- package/dist/es/policyObligationEnforcers/passThroughPolicyObligationEnforcer.js +56 -0
- package/dist/es/policyObligationEnforcers/passThroughPolicyObligationEnforcer.js.map +1 -0
- package/dist/es/policyRequesters/passThroughPolicyRequester.js +103 -0
- package/dist/es/policyRequesters/passThroughPolicyRequester.js.map +1 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/models/IAutomationPolicyExecutionActionConfig.d.ts +9 -0
- package/dist/types/models/IAutomationPolicyExecutionActionConstructorOptions.d.ts +15 -0
- package/dist/types/models/IDefaultPolicyArbiterConfig.d.ts +10 -0
- package/dist/types/models/IDefaultPolicyArbiterConstructorOptions.d.ts +19 -0
- package/dist/types/models/IDefaultPolicyEnforcementProcessorConfig.d.ts +11 -0
- package/dist/types/models/IDefaultPolicyEnforcementProcessorConstructorOptions.d.ts +14 -0
- package/dist/types/models/IIdentityPolicyInformationSourceConstructorOptions.d.ts +14 -0
- package/dist/types/models/IIdentityProfilePolicyInformationSourceConstructorOptions.d.ts +14 -0
- package/dist/types/models/ILoggingPolicyExecutionActionConfig.d.ts +25 -0
- package/dist/types/models/ILoggingPolicyExecutionActionConstructorOptions.d.ts +14 -0
- package/dist/types/models/IPassThroughPolicyArbiterConstructorOptions.d.ts +9 -0
- package/dist/types/models/IPassThroughPolicyEnforcementProcessorConstructorOptions.d.ts +9 -0
- package/dist/types/models/IPassThroughPolicyNegotiatorConfig.d.ts +9 -0
- package/dist/types/models/IPassThroughPolicyNegotiatorConstructorOptions.d.ts +14 -0
- package/dist/types/models/IPassThroughPolicyObligationEnforcerConstructorOptions.d.ts +9 -0
- package/dist/types/models/IPassThroughPolicyRequesterConstructorOptions.d.ts +9 -0
- package/dist/types/models/IStaticPolicyInformationSource.d.ts +23 -0
- package/dist/types/models/IStaticPolicyInformationSourceConfig.d.ts +10 -0
- package/dist/types/models/IStaticPolicyInformationSourceConstructorOptions.d.ts +14 -0
- package/dist/types/policyArbiters/defaultPolicyArbiter.d.ts +38 -0
- package/dist/types/policyArbiters/passThroughPolicyArbiter.d.ts +32 -0
- package/dist/types/policyEnforcementProcessor/defaultPolicyEnforcementProcessor.d.ts +36 -0
- package/dist/types/policyEnforcementProcessor/passThroughPolicyEnforcementProcessor.d.ts +32 -0
- package/dist/types/policyExecutionActions/automationPolicyExecutionAction.d.ts +45 -0
- package/dist/types/policyExecutionActions/loggingPolicyExecutionAction.d.ts +37 -0
- package/dist/types/policyInformationSources/identityPolicyInformationSource.d.ts +31 -0
- package/dist/types/policyInformationSources/identityProfilePolicyInformationSource.d.ts +31 -0
- package/dist/types/policyInformationSources/staticPolicyInformationSource.d.ts +37 -0
- package/dist/types/policyNegotiators/passThroughPolicyNegotiator.d.ts +48 -0
- package/dist/types/policyObligationEnforcers/passThroughPolicyObligationEnforcer.d.ts +32 -0
- package/dist/types/policyRequesters/passThroughPolicyRequester.d.ts +48 -0
- package/docs/changelog.md +0 -0
- package/docs/examples.md +295 -0
- package/docs/reference/classes/AutomationPolicyExecutionAction.md +143 -0
- package/docs/reference/classes/DefaultPolicyArbiter.md +113 -0
- package/docs/reference/classes/DefaultPolicyEnforcementProcessor.md +115 -0
- package/docs/reference/classes/IdentityPolicyInformationSource.md +103 -0
- package/docs/reference/classes/IdentityProfilePolicyInformationSource.md +103 -0
- package/docs/reference/classes/LoggingPolicyExecutionAction.md +127 -0
- package/docs/reference/classes/PassThroughPolicyArbiter.md +103 -0
- package/docs/reference/classes/PassThroughPolicyEnforcementProcessor.md +107 -0
- package/docs/reference/classes/PassThroughPolicyNegotiator.md +149 -0
- package/docs/reference/classes/PassThroughPolicyObligationEnforcer.md +109 -0
- package/docs/reference/classes/PassThroughPolicyRequester.md +169 -0
- package/docs/reference/classes/StaticPolicyInformationSource.md +123 -0
- package/docs/reference/index.md +38 -0
- package/docs/reference/interfaces/IAutomationPolicyExecutionActionConfig.md +11 -0
- package/docs/reference/interfaces/IAutomationPolicyExecutionActionConstructorOptions.md +25 -0
- package/docs/reference/interfaces/IDefaultPolicyArbiterConfig.md +17 -0
- package/docs/reference/interfaces/IDefaultPolicyArbiterConstructorOptions.md +33 -0
- package/docs/reference/interfaces/IDefaultPolicyEnforcementProcessorConfig.md +13 -0
- package/docs/reference/interfaces/IDefaultPolicyEnforcementProcessorConstructorOptions.md +19 -0
- package/docs/reference/interfaces/IIdentityPolicyInformationSourceConstructorOptions.md +25 -0
- package/docs/reference/interfaces/IIdentityProfilePolicyInformationSourceConstructorOptions.md +25 -0
- package/docs/reference/interfaces/ILoggingPolicyExecutionActionConfig.md +53 -0
- package/docs/reference/interfaces/ILoggingPolicyExecutionActionConstructorOptions.md +19 -0
- package/docs/reference/interfaces/IPassThroughPolicyArbiterConstructorOptions.md +11 -0
- package/docs/reference/interfaces/IPassThroughPolicyEnforcementProcessorConstructorOptions.md +11 -0
- package/docs/reference/interfaces/IPassThroughPolicyNegotiatorConfig.md +11 -0
- package/docs/reference/interfaces/IPassThroughPolicyNegotiatorConstructorOptions.md +19 -0
- package/docs/reference/interfaces/IPassThroughPolicyObligationEnforcerConstructorOptions.md +11 -0
- package/docs/reference/interfaces/IPassThroughPolicyRequesterConstructorOptions.md +11 -0
- package/docs/reference/interfaces/IStaticPolicyInformationSource.md +43 -0
- package/docs/reference/interfaces/IStaticPolicyInformationSourceConfig.md +11 -0
- package/docs/reference/interfaces/IStaticPolicyInformationSourceConstructorOptions.md +19 -0
- package/locales/en.json +79 -0
- package/package.json +60 -5
|
@@ -0,0 +1 @@
|
|
|
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,cAAc,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EACN,gBAAgB,EAChB,cAAc,EAGd,MAAM,kCAAkC,CAAC;AAK1C;;GAEG;AACH,MAAM,OAAO,iCAAiC;IAC7C;;OAEG;IACI,MAAM,CAAU,UAAU,uCAAuD;IAExF;;OAEG;IACI,MAAM,CAAU,uBAAuB,GAAa;QAC1D,UAAU;QACV,OAAO;QACP,KAAK;QACL,MAAM;QACN,IAAI;KACJ,CAAC;IAEF;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,eAAe,CAAW;IAE3C;;;OAGG;IACH,YAAY,OAA8D;QACzE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAAoB,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAC/F,IAAI,CAAC,eAAe;YACnB,OAAO,EAAE,MAAM,EAAE,cAAc,IAAI,iCAAiC,CAAC,uBAAuB,CAAC;IAC/F,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,iCAAiC,CAAC,UAAU,CAAC;IACrD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,OAAO,CACnB,SAAsC,EACtC,SAA4B,EAC5B,IAAQ,EACR,MAAgC;QAEhC,MAAM,CAAC,MAAM,CACZ,iCAAiC,CAAC,UAAU,eAE5C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AAO,EAAE,CAAC;gBAC9B,cAAc,CAAC,aAAa,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YAC3E,CAAC;QACF,CAAC;aAAM,IAAI,cAAc,CAAC,QAAQ,KAAK,cAAc,CAAC,OAAO,EAAE,CAAC;YAC/D,mGAAmG;YACnG,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,IAAI,EAAE,CAAC,CAAC;YAChF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC9B,cAAc,CAAC,aAAa,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;YAC1F,CAAC;QACF,CAAC;aAAM,CAAC;YACP,8FAA8F;YAC9F,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAC1E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC9B,cAAc,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;YAChE,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, GeneralError, Guards, Is, ObjectHelper } from \"@3sixty/core\";\nimport { JsonPathHelper } from \"@3sixty/data-json-path\";\nimport type { ILoggingComponent } from \"@3sixty/logging-models\";\nimport { nameof } from \"@3sixty/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\tPolicyDecision,\n\ttype IPolicyDecision,\n\ttype IPolicyEnforcementProcessor\n} from \"@3sixty/rights-management-models\";\nimport type { IDataspaceProtocolAgreement } from \"@3sixty/standards-dataspace-protocol\";\nimport type { OdrlActionType } from \"@3sixty/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 * Default set of top-level keys treated as document-structural fields.\n\t */\n\tpublic static readonly DEFAULT_STRUCTURAL_KEYS: string[] = [\n\t\t\"@context\",\n\t\t\"@type\",\n\t\t\"@id\",\n\t\t\"type\",\n\t\t\"id\"\n\t];\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * Keys unconditionally passed through from source to output.\n\t * @internal\n\t */\n\tprivate readonly _structuralKeys: string[];\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.getIfExists<ILoggingComponent>(options?.loggingComponentType);\n\t\tthis._structuralKeys =\n\t\t\toptions?.config?.structuralKeys ?? DefaultPolicyEnforcementProcessor.DEFAULT_STRUCTURAL_KEYS;\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: IDataspaceProtocolAgreement,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata?: D,\n\t\taction?: OdrlActionType | string\n\t): Promise<R> {\n\t\tGuards.object<IDataspaceProtocolAgreement>(\n\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"processingPolicy\",\n\t\t\tdata: {\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\tconst isOriginalEmpty = Is.empty(data);\n\t\tconst outputObject: R = (Is.arrayValue(data) ? [] : {}) as unknown as R;\n\n\t\tif (Is.arrayValue(decisions)) {\n\t\t\t// If this is a single simple decision with no values, handle that quickly.\n\t\t\tif (decisions.length === 1 && decisions[0].target === \"$\") {\n\t\t\t\tif (!Is.stringValue(decisions[0].target)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\t\t\t\t\"targetNotJsonPath\",\n\t\t\t\t\t\t{ target: decisions[0].target }\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (decisions[0].decision === PolicyDecision.Granted) {\n\t\t\t\t\t// Object granted, if original data is an object return it, otherwise return true.\n\t\t\t\t\treturn isOriginalEmpty ? (true as R) : (data as unknown as R);\n\t\t\t\t} else if (\n\t\t\t\t\tdecisions[0].decision === PolicyDecision.Replace &&\n\t\t\t\t\tIs.object(decisions[0].replaceValue)\n\t\t\t\t) {\n\t\t\t\t\t// Object replaced, return the replace value.\n\t\t\t\t\treturn decisions[0].replaceValue as R;\n\t\t\t\t}\n\n\t\t\t\t// Object denied, or replace with no value\n\t\t\t\t// if original data is an object return empty object, otherwise return false.\n\t\t\t\treturn isOriginalEmpty ? (false as R) : ({} as unknown as R);\n\t\t\t}\n\n\t\t\tfor (const policyDecision of decisions) {\n\t\t\t\tif (!Is.stringValue(policyDecision.target)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\t\t\t\t\"targetNotJsonPath\",\n\t\t\t\t\t\t{ target: policyDecision.target }\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tpolicyDecision.decision === PolicyDecision.Replace &&\n\t\t\t\t\tIs.undefined(policyDecision.replaceValue)\n\t\t\t\t) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDefaultPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\t\t\t\t\"replaceValueMissing\",\n\t\t\t\t\t\t{ target: policyDecision.target }\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.processDecision<D, R>(data, outputObject, policyDecision);\n\t\t\t}\n\t\t\tthis.compactArrays(outputObject);\n\n\t\t\t// Well-known JSON-LD envelope fields carry document structure, not\n\t\t\t// access-controlled data. Pass them through unconditionally so that a policy\n\t\t\t// targeting only a nested array does not strip @context / type from the root.\n\t\t\tif (!isOriginalEmpty && Is.object(data) && Is.object(outputObject)) {\n\t\t\t\tfor (const structuralKey of this._structuralKeys) {\n\t\t\t\t\tconst structuralData = ObjectHelper.propertyGet(data, structuralKey);\n\t\t\t\t\tif (!Is.empty(structuralData)) {\n\t\t\t\t\t\tObjectHelper.propertySet(outputObject, structuralKey, structuralData);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn outputObject;\n\t}\n\n\t/**\n\t * Remove undefined holes left by deleteAtLocation from every array in the object tree.\n\t * @param obj The object to compact in place.\n\t * @internal\n\t */\n\tprivate compactArrays(obj: unknown): void {\n\t\tif (Is.array(obj)) {\n\t\t\tfor (let i = obj.length - 1; i >= 0; i--) {\n\t\t\t\tif (Is.undefined(obj[i])) {\n\t\t\t\t\tobj.splice(i, 1);\n\t\t\t\t} else {\n\t\t\t\t\tthis.compactArrays(obj[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Is.object(obj)) {\n\t\t\tfor (const value of Object.values(obj)) {\n\t\t\t\tthis.compactArrays(value);\n\t\t\t}\n\t\t}\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 * @internal\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"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ComponentFactory, Guards } from "@3sixty/core";
|
|
4
|
+
import { OdrlPolicyHelper } from "@3sixty/rights-management-models";
|
|
5
|
+
/**
|
|
6
|
+
* Pass Through Policy Enforcement Processor.
|
|
7
|
+
*/
|
|
8
|
+
export class PassThroughPolicyEnforcementProcessor {
|
|
9
|
+
/**
|
|
10
|
+
* The class name of the Pass Through Policy Enforcement Processor.
|
|
11
|
+
*/
|
|
12
|
+
static CLASS_NAME = "PassThroughPolicyEnforcementProcessor";
|
|
13
|
+
/**
|
|
14
|
+
* The logging component.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
_logging;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of PassThroughPolicyEnforcementProcessor.
|
|
20
|
+
* @param options The options for the pass through policy enforcement processor.
|
|
21
|
+
*/
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this._logging = ComponentFactory.getIfExists(options?.loggingComponentType);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the class name of the component.
|
|
27
|
+
* @returns The class name of the component.
|
|
28
|
+
*/
|
|
29
|
+
className() {
|
|
30
|
+
return PassThroughPolicyEnforcementProcessor.CLASS_NAME;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Process the response from the policy decision point.
|
|
34
|
+
* @param agreement The agreement to process.
|
|
35
|
+
* @param decisions The decisions made by the policy decision point.
|
|
36
|
+
* @param data The data to process.
|
|
37
|
+
* @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
38
|
+
* @returns The data after processing.
|
|
39
|
+
*/
|
|
40
|
+
async process(agreement, decisions, data, action) {
|
|
41
|
+
Guards.object(PassThroughPolicyEnforcementProcessor.CLASS_NAME, "agreement", agreement);
|
|
42
|
+
await this._logging?.log({
|
|
43
|
+
level: "info",
|
|
44
|
+
source: PassThroughPolicyEnforcementProcessor.CLASS_NAME,
|
|
45
|
+
ts: Date.now(),
|
|
46
|
+
message: "processingPolicy",
|
|
47
|
+
data: {
|
|
48
|
+
policyId: OdrlPolicyHelper.getUid(agreement) ?? ""
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=passThroughPolicyEnforcementProcessor.js.map
|
|
@@ -0,0 +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,cAAc,CAAC;AAGxD,OAAO,EACN,gBAAgB,EAGhB,MAAM,kCAAkC,CAAC;AAK1C;;GAEG;AACH,MAAM,OAAO,qCAAqC;IACjD;;OAEG;IACI,MAAM,CAAU,UAAU,2CAA2D;IAE5F;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACH,YAAY,OAAkE;QAC7E,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAAoB,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAChG,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,qCAAqC,CAAC,UAAU,CAAC;IACzD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,OAAO,CACnB,SAAsC,EACtC,SAA4B,EAC5B,IAAQ,EACR,MAAgC;QAEhC,MAAM,CAAC,MAAM,CACZ,qCAAqC,CAAC,UAAU,eAEhD,SAAS,CACT,CAAC;QAEF,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;YACxB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,qCAAqC,CAAC,UAAU;YACxD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,kBAAkB;YAC3B,IAAI,EAAE;gBACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;aAClD;SACD,CAAC,CAAC;QAEH,OAAO,IAAoB,CAAC;IAC7B,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards } from \"@3sixty/core\";\nimport type { ILoggingComponent } from \"@3sixty/logging-models\";\nimport { nameof } from \"@3sixty/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\ttype IPolicyDecision,\n\ttype IPolicyEnforcementProcessor\n} from \"@3sixty/rights-management-models\";\nimport type { IDataspaceProtocolAgreement } from \"@3sixty/standards-dataspace-protocol\";\nimport type { OdrlActionType } from \"@3sixty/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.getIfExists<ILoggingComponent>(options?.loggingComponentType);\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: IDataspaceProtocolAgreement,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata?: D,\n\t\taction?: OdrlActionType | string\n\t): Promise<R> {\n\t\tGuards.object<IDataspaceProtocolAgreement>(\n\t\t\tPassThroughPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: PassThroughPolicyEnforcementProcessor.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"processingPolicy\",\n\t\t\tdata: {\n\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t}\n\t\t});\n\n\t\treturn data as unknown as R;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ComponentFactory, Guards, Is } from "@3sixty/core";
|
|
2
|
+
import { PolicyDecisionStage } from "@3sixty/rights-management-models";
|
|
3
|
+
import { OdrlActionType } from "@3sixty/standards-w3c-odrl";
|
|
4
|
+
/**
|
|
5
|
+
* Automation Policy Execution Action to execute automation policies.
|
|
6
|
+
*/
|
|
7
|
+
export class AutomationPolicyExecutionAction {
|
|
8
|
+
/**
|
|
9
|
+
* The class name of the Automation Policy Execution Action.
|
|
10
|
+
*/
|
|
11
|
+
static CLASS_NAME = "AutomationPolicyExecutionAction";
|
|
12
|
+
/**
|
|
13
|
+
* The before automation trigger name.
|
|
14
|
+
*/
|
|
15
|
+
static BEFORE_TRIGGER_NAME = "rights-management:pxp:before";
|
|
16
|
+
/**
|
|
17
|
+
* The after automation trigger name.
|
|
18
|
+
*/
|
|
19
|
+
static AFTER_TRIGGER_NAME = "rights-management:pxp:after";
|
|
20
|
+
/**
|
|
21
|
+
* The automation component.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
_automation;
|
|
25
|
+
/**
|
|
26
|
+
* The policy decision stages to trigger the automation actions, if undefined defaults to "inform".
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
_triggerActions;
|
|
30
|
+
/**
|
|
31
|
+
* Create a new instance of AutomationPolicyExecutionAction.
|
|
32
|
+
* @param options The options for the automation policy execution action.
|
|
33
|
+
*/
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this._automation = ComponentFactory.get(options?.automationComponentType ?? "automation");
|
|
36
|
+
this._triggerActions = Is.arrayValue(options?.config?.triggerActions)
|
|
37
|
+
? options?.config?.triggerActions
|
|
38
|
+
: [OdrlActionType.Inform];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns the class name of the component.
|
|
42
|
+
* @returns The class name of the component.
|
|
43
|
+
*/
|
|
44
|
+
className() {
|
|
45
|
+
return AutomationPolicyExecutionAction.CLASS_NAME;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Which stages should the action be executed at.
|
|
49
|
+
* @returns List of stages.
|
|
50
|
+
*/
|
|
51
|
+
supportedStages() {
|
|
52
|
+
return [PolicyDecisionStage.Before, PolicyDecisionStage.After];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Execute function type for policy actions.
|
|
56
|
+
* @param policy The policy that applied to the data.
|
|
57
|
+
* @param decisions The decisions made by the PDP.
|
|
58
|
+
* @param data The data to process.
|
|
59
|
+
* @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
60
|
+
* @param stage The stage of the policy decision.
|
|
61
|
+
* @returns A promise that resolves when the action is complete.
|
|
62
|
+
*/
|
|
63
|
+
async execute(policy, decisions, data, action, stage) {
|
|
64
|
+
Guards.arrayOneOf(AutomationPolicyExecutionAction.CLASS_NAME, "stage", stage, Object.values(PolicyDecisionStage));
|
|
65
|
+
if (Is.stringValue(action) && this._triggerActions.includes(action)) {
|
|
66
|
+
await this._automation.trigger(stage === PolicyDecisionStage.Before
|
|
67
|
+
? AutomationPolicyExecutionAction.BEFORE_TRIGGER_NAME
|
|
68
|
+
: AutomationPolicyExecutionAction.AFTER_TRIGGER_NAME, {
|
|
69
|
+
policy,
|
|
70
|
+
decisions,
|
|
71
|
+
data,
|
|
72
|
+
action
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=automationPolicyExecutionAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automationPolicyExecutionAction.js","sourceRoot":"","sources":["../../../src/policyExecutionActions/automationPolicyExecutionAction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAIN,mBAAmB,EACnB,MAAM,kCAAkC,CAAC;AAC1C,O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C7B,KAAK,KAAK,mBAAmB,CAAC,MAAM;gBACnC,CAAC,CAAC,+BAA+B,CAAC,mBAAmB;gBACrD,CAAC,CAAC,+BAA+B,CAAC,kBAAkB,EACrD;gBACC,MAAM;gBACN,SAAS;gBACT,IAAI;gBACJ,MAAM;aACN,CACD,CAAC;QACH,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IAutomationComponent } from \"@3sixty/automation-models\";\nimport { ComponentFactory, Guards, Is } from \"@3sixty/core\";\nimport { nameof } from \"@3sixty/nameof\";\nimport {\n\ttype IPolicyDecision,\n\ttype IPolicyExecutionAction,\n\ttype IRightsManagementPolicy,\n\tPolicyDecisionStage\n} from \"@3sixty/rights-management-models\";\nimport { OdrlActionType } from \"@3sixty/standards-w3c-odrl\";\nimport type { IAutomationPolicyExecutionActionConstructorOptions } from \"../models/IAutomationPolicyExecutionActionConstructorOptions.js\";\n\n/**\n * Automation Policy Execution Action to execute automation policies.\n */\nexport class AutomationPolicyExecutionAction implements IPolicyExecutionAction {\n\t/**\n\t * The class name of the Automation Policy Execution Action.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<AutomationPolicyExecutionAction>();\n\n\t/**\n\t * The before automation trigger name.\n\t */\n\tpublic static readonly BEFORE_TRIGGER_NAME: string = \"rights-management:pxp:before\";\n\n\t/**\n\t * The after automation trigger name.\n\t */\n\tpublic static readonly AFTER_TRIGGER_NAME: string = \"rights-management:pxp:after\";\n\n\t/**\n\t * The automation component.\n\t * @internal\n\t */\n\tprivate readonly _automation: IAutomationComponent;\n\n\t/**\n\t * The policy decision stages to trigger the automation actions, if undefined defaults to \"inform\".\n\t * @internal\n\t */\n\tprivate readonly _triggerActions: string[];\n\n\t/**\n\t * Create a new instance of AutomationPolicyExecutionAction.\n\t * @param options The options for the automation policy execution action.\n\t */\n\tconstructor(options?: IAutomationPolicyExecutionActionConstructorOptions) {\n\t\tthis._automation = ComponentFactory.get<IAutomationComponent>(\n\t\t\toptions?.automationComponentType ?? \"automation\"\n\t\t);\n\t\tthis._triggerActions = Is.arrayValue(options?.config?.triggerActions)\n\t\t\t? options?.config?.triggerActions\n\t\t\t: [OdrlActionType.Inform];\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 AutomationPolicyExecutionAction.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 [PolicyDecisionStage.Before, PolicyDecisionStage.After];\n\t}\n\n\t/**\n\t * Execute function type for policy actions.\n\t * @param policy The policy that applied to the data.\n\t * @param decisions The decisions made by the PDP.\n\t * @param data The data to process.\n\t * @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.\n\t * @param stage The stage of the policy decision.\n\t * @returns A promise that resolves when the action is complete.\n\t */\n\tpublic async execute<D = unknown>(\n\t\tpolicy: IRightsManagementPolicy,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata: D | undefined,\n\t\taction: OdrlActionType | string | undefined,\n\t\tstage: PolicyDecisionStage\n\t): Promise<void> {\n\t\tGuards.arrayOneOf(\n\t\t\tAutomationPolicyExecutionAction.CLASS_NAME,\n\t\t\tnameof(stage),\n\t\t\tstage,\n\t\t\tObject.values(PolicyDecisionStage)\n\t\t);\n\n\t\tif (Is.stringValue(action) && this._triggerActions.includes(action)) {\n\t\t\tawait this._automation.trigger(\n\t\t\t\tstage === PolicyDecisionStage.Before\n\t\t\t\t\t? AutomationPolicyExecutionAction.BEFORE_TRIGGER_NAME\n\t\t\t\t\t: AutomationPolicyExecutionAction.AFTER_TRIGGER_NAME,\n\t\t\t\t{\n\t\t\t\t\tpolicy,\n\t\t\t\t\tdecisions,\n\t\t\t\t\tdata,\n\t\t\t\t\taction\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ComponentFactory, Guards, Is } from "@3sixty/core";
|
|
4
|
+
import { OdrlPolicyHelper, PolicyDecisionStage } from "@3sixty/rights-management-models";
|
|
5
|
+
/**
|
|
6
|
+
* Logging Policy Execution Action to send decisions to logging.
|
|
7
|
+
*/
|
|
8
|
+
export class LoggingPolicyExecutionAction {
|
|
9
|
+
/**
|
|
10
|
+
* The class name of the Logging Policy Execution Action.
|
|
11
|
+
*/
|
|
12
|
+
static CLASS_NAME = "LoggingPolicyExecutionAction";
|
|
13
|
+
/**
|
|
14
|
+
* The logging component.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
_logging;
|
|
18
|
+
/**
|
|
19
|
+
* The policy decision stages to log, if undefined defaults to all.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
_stages;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to include the data in the log.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
_includeData;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to include the policy in the log.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
_includePolicy;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to include the decisions in the log.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
_includeDecisions;
|
|
38
|
+
/**
|
|
39
|
+
* Create a new instance of LoggingPolicyExecutionAction.
|
|
40
|
+
* @param options The options for the logging policy execution action.
|
|
41
|
+
*/
|
|
42
|
+
constructor(options) {
|
|
43
|
+
this._logging = ComponentFactory.getIfExists(options?.loggingComponentType);
|
|
44
|
+
this._stages = options?.config?.stages ?? [
|
|
45
|
+
PolicyDecisionStage.Before,
|
|
46
|
+
PolicyDecisionStage.After
|
|
47
|
+
];
|
|
48
|
+
this._includeData = options?.config?.includeData ?? false;
|
|
49
|
+
this._includePolicy = options?.config?.includePolicy ?? false;
|
|
50
|
+
this._includeDecisions = options?.config?.includeDecisions ?? false;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns the class name of the component.
|
|
54
|
+
* @returns The class name of the component.
|
|
55
|
+
*/
|
|
56
|
+
className() {
|
|
57
|
+
return LoggingPolicyExecutionAction.CLASS_NAME;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Which stages should the action be executed at.
|
|
61
|
+
* @returns List of stages.
|
|
62
|
+
*/
|
|
63
|
+
supportedStages() {
|
|
64
|
+
return this._stages;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Execute function type for policy actions.
|
|
68
|
+
* @param policy The policy that applied to the data.
|
|
69
|
+
* @param decisions The decisions made by the PDP.
|
|
70
|
+
* @param data The data to process.
|
|
71
|
+
* @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.
|
|
72
|
+
* @param stage The stage of the policy decision.
|
|
73
|
+
* @returns A promise that resolves when the action is complete.
|
|
74
|
+
*/
|
|
75
|
+
async execute(policy, decisions, data, action, stage) {
|
|
76
|
+
Guards.arrayOneOf(LoggingPolicyExecutionAction.CLASS_NAME, "stage", stage, Object.values(PolicyDecisionStage));
|
|
77
|
+
if (this._stages.includes(stage)) {
|
|
78
|
+
// Even if we don't have the options to include data or include policy we
|
|
79
|
+
// still create dummy entries, as the logging string still has them embedded
|
|
80
|
+
let logData;
|
|
81
|
+
if (!Is.empty(data)) {
|
|
82
|
+
logData = this._includeData ? data : "{...}";
|
|
83
|
+
}
|
|
84
|
+
const logPolicy = this._includePolicy ? policy : "{}";
|
|
85
|
+
const logDecisions = this._includeDecisions ? decisions : "[...]";
|
|
86
|
+
if (stage === PolicyDecisionStage.Before) {
|
|
87
|
+
await this._logging?.log({
|
|
88
|
+
level: "info",
|
|
89
|
+
source: LoggingPolicyExecutionAction.CLASS_NAME,
|
|
90
|
+
ts: Date.now(),
|
|
91
|
+
message: "policyActionExecutedBefore",
|
|
92
|
+
data: {
|
|
93
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
94
|
+
data: logData,
|
|
95
|
+
policy: logPolicy,
|
|
96
|
+
decisions: logDecisions,
|
|
97
|
+
action,
|
|
98
|
+
stage
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
await this._logging?.log({
|
|
104
|
+
level: "info",
|
|
105
|
+
source: LoggingPolicyExecutionAction.CLASS_NAME,
|
|
106
|
+
ts: Date.now(),
|
|
107
|
+
message: "policyActionExecutedAfter",
|
|
108
|
+
data: {
|
|
109
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
110
|
+
data: logData,
|
|
111
|
+
policy: logPolicy,
|
|
112
|
+
decisions: logDecisions,
|
|
113
|
+
action,
|
|
114
|
+
stage
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=loggingPolicyExecutionAction.js.map
|
|
@@ -0,0 +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,cAAc,CAAC;AAG5D,OAAO,EAIN,gBAAgB,EAChB,mBAAmB,EACnB,MAAM,kCAAkC,CAAC;AAI1C;;GAEG;AACH,MAAM,OAAO,4BAA4B;IACxC;;OAEG;IACI,MAAM,CAAU,UAAU,kCAAkD;IAEnF;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,OAAO,CAAwB;IAEhD;;;OAGG;IACc,YAAY,CAAU;IAEvC;;;OAGG;IACc,cAAc,CAAU;IAEzC;;;OAGG;IACc,i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AC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;YACtD,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;YAElE,IAAI,KAAK,KAAK,mBAAmB,CAAC,MAAM,EAAE,CAAC;gBAC1C,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;oBACxB,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,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;wBAC/C,IAAI,EAAE,OAAO;wBACb,MAAM,EAAE,SAAS;wBACjB,SAAS,EAAE,YAAY;wBACvB,MAAM;wBACN,KAAK;qBACL;iBACD,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACP,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;oBACxB,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,4BAA4B,CAAC,UAAU;oBAC/C,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;oBACd,OAAO,EAAE,2BAA2B;oBACpC,IAAI,EAAE;wBACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;wBAC/C,IAAI,EAAE,OAAO;wBACb,MAAM,EAAE,SAAS;wBACjB,SAAS,EAAE,YAAY;wBACvB,MAAM;wBACN,KAAK;qBACL;iBACD,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, Guards, Is } from \"@3sixty/core\";\nimport type { ILoggingComponent } from \"@3sixty/logging-models\";\nimport { nameof } from \"@3sixty/nameof\";\nimport {\n\ttype IPolicyDecision,\n\ttype IPolicyExecutionAction,\n\ttype IRightsManagementPolicy,\n\tOdrlPolicyHelper,\n\tPolicyDecisionStage\n} from \"@3sixty/rights-management-models\";\nimport type { OdrlActionType } from \"@3sixty/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 * @internal\n\t */\n\tprivate readonly _includeData: boolean;\n\n\t/**\n\t * Whether to include the policy in the log.\n\t * @internal\n\t */\n\tprivate readonly _includePolicy: boolean;\n\n\t/**\n\t * Whether to include the decisions in the log.\n\t * @internal\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.getIfExists<ILoggingComponent>(options?.loggingComponentType);\n\n\t\tthis._stages = options?.config?.stages ?? [\n\t\t\tPolicyDecisionStage.Before,\n\t\t\tPolicyDecisionStage.After\n\t\t];\n\t\tthis._includeData = options?.config?.includeData ?? false;\n\t\tthis._includePolicy = options?.config?.includePolicy ?? false;\n\t\tthis._includeDecisions = options?.config?.includeDecisions ?? false;\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn LoggingPolicyExecutionAction.CLASS_NAME;\n\t}\n\n\t/**\n\t * Which stages should the action be executed at.\n\t * @returns List of stages.\n\t */\n\tpublic supportedStages(): PolicyDecisionStage[] {\n\t\treturn this._stages;\n\t}\n\n\t/**\n\t * Execute function type for policy actions.\n\t * @param policy The policy that applied to the data.\n\t * @param decisions The decisions made by the PDP.\n\t * @param data The data to process.\n\t * @param action Optional action to make a decision on, if not provided, the arbiter will evaluate all actions in the agreement.\n\t * @param stage The stage of the policy decision.\n\t * @returns A promise that resolves when the action is complete.\n\t */\n\tpublic async execute<D = unknown>(\n\t\tpolicy: IRightsManagementPolicy,\n\t\tdecisions: IPolicyDecision[],\n\t\tdata: D | undefined,\n\t\taction: OdrlActionType | string | 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: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\t\tdata: logData,\n\t\t\t\t\t\tpolicy: logPolicy,\n\t\t\t\t\t\tdecisions: logDecisions,\n\t\t\t\t\t\taction,\n\t\t\t\t\t\tstage\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tawait this._logging?.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tsource: LoggingPolicyExecutionAction.CLASS_NAME,\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"policyActionExecutedAfter\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\t\tdata: logData,\n\t\t\t\t\t\tpolicy: logPolicy,\n\t\t\t\t\t\tdecisions: logDecisions,\n\t\t\t\t\t\taction,\n\t\t\t\t\t\tstage\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { BaseError, ComponentFactory, Guards, Is } from "@3sixty/core";
|
|
4
|
+
import { JsonLdHelper } from "@3sixty/data-json-ld";
|
|
5
|
+
import { OdrlPolicyHelper, PolicyInformationAccessMode } from "@3sixty/rights-management-models";
|
|
6
|
+
/**
|
|
7
|
+
* Policy information source which retrieves the identity information.
|
|
8
|
+
*/
|
|
9
|
+
export class IdentityPolicyInformationSource {
|
|
10
|
+
/**
|
|
11
|
+
* The class name of the Identity Policy Information Source.
|
|
12
|
+
*/
|
|
13
|
+
static CLASS_NAME = "IdentityPolicyInformationSource";
|
|
14
|
+
/**
|
|
15
|
+
* The logging component.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
_logging;
|
|
19
|
+
/**
|
|
20
|
+
* The identity resolver component.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
_identityResolver;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new instance of IdentityPolicyInformationSource.
|
|
26
|
+
* @param options The options for the logging policy source.
|
|
27
|
+
*/
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this._logging = ComponentFactory.getIfExists(options?.loggingComponentType);
|
|
30
|
+
this._identityResolver = ComponentFactory.get(options?.identityResolverComponentType ?? "identity-resolver");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the class name of the component.
|
|
34
|
+
* @returns The class name of the component.
|
|
35
|
+
*/
|
|
36
|
+
className() {
|
|
37
|
+
return IdentityPolicyInformationSource.CLASS_NAME;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve information from the sources.
|
|
41
|
+
* @param policy The policy to retrieve information for if available.
|
|
42
|
+
* @param accessMode The access mode to use for the retrieval.
|
|
43
|
+
* @param data The data to process.
|
|
44
|
+
* @param action The action that was evaluated.
|
|
45
|
+
* @returns The objects containing relevant information or undefined if nothing relevant is found.
|
|
46
|
+
*/
|
|
47
|
+
async retrieve(policy, accessMode, data, action) {
|
|
48
|
+
Guards.arrayOneOf(IdentityPolicyInformationSource.CLASS_NAME, "accessMode", accessMode, Object.values(PolicyInformationAccessMode));
|
|
49
|
+
const information = {};
|
|
50
|
+
if (Is.object(policy)) {
|
|
51
|
+
const ids = [];
|
|
52
|
+
if (Is.stringValue(policy.assignee)) {
|
|
53
|
+
ids.push(policy.assignee);
|
|
54
|
+
}
|
|
55
|
+
if (Is.stringValue(policy.assigner)) {
|
|
56
|
+
ids.push(policy.assigner);
|
|
57
|
+
}
|
|
58
|
+
for (const id of ids) {
|
|
59
|
+
try {
|
|
60
|
+
await this._logging?.log({
|
|
61
|
+
level: "info",
|
|
62
|
+
source: IdentityPolicyInformationSource.CLASS_NAME,
|
|
63
|
+
ts: Date.now(),
|
|
64
|
+
message: "identityRetrieving",
|
|
65
|
+
data: {
|
|
66
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
67
|
+
id
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const idDoc = await this._identityResolver.identityResolve(id);
|
|
71
|
+
information[id] = JsonLdHelper.toNodeObject(idDoc);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
await this._logging?.log({
|
|
75
|
+
level: "error",
|
|
76
|
+
source: IdentityPolicyInformationSource.CLASS_NAME,
|
|
77
|
+
ts: Date.now(),
|
|
78
|
+
message: "identityRetrievalFailed",
|
|
79
|
+
data: {
|
|
80
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
81
|
+
id
|
|
82
|
+
},
|
|
83
|
+
error: BaseError.fromError(err)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return information;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=identityPolicyInformationSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identityPolicyInformationSource.js","sourceRoot":"","sources":["../../../src/policyInformationSources/identityPolicyInformationSource.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,OAAO,EAIN,gBAAgB,EAChB,2BAA2B,EAC3B,MAAM,kCAAkC,CAAC;AAI1C;;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,CAAoB,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAC/F,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,CAC5C,OAAO,EAAE,6BAA6B,I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D,WAAW,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpD,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACd,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;wBACxB,KAAK,EAAE,OAAO;wBACd,MAAM,EAAE,+BAA+B,CAAC,UAAU;wBAClD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;wBACd,OAAO,EAAE,yBAAyB;wBAClC,IAAI,EAAE;4BACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;4BAC/C,EAAE;yBACF;wBACD,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC;qBAC/B,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,WAAW,CAAC;IACpB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, ComponentFactory, Guards, Is } from \"@3sixty/core\";\nimport { JsonLdHelper } from \"@3sixty/data-json-ld\";\nimport type { IIdentityResolverComponent } from \"@3sixty/identity-models\";\nimport type { ILoggingComponent } from \"@3sixty/logging-models\";\nimport { nameof } from \"@3sixty/nameof\";\nimport {\n\ttype IPolicyInformationSource,\n\ttype IRightsManagementInformation,\n\ttype IRightsManagementPolicy,\n\tOdrlPolicyHelper,\n\tPolicyInformationAccessMode\n} from \"@3sixty/rights-management-models\";\nimport type { OdrlActionType } from \"@3sixty/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>(options?.loggingComponentType);\n\t\tthis._identityResolver = ComponentFactory.get(\n\t\t\toptions?.identityResolverComponentType ?? \"identity-resolver\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityPolicyInformationSource.CLASS_NAME;\n\t}\n\n\t/**\n\t * Retrieve information from the sources.\n\t * @param policy The policy to retrieve information for if available.\n\t * @param accessMode The access mode to use for the retrieval.\n\t * @param data The data to process.\n\t * @param action The action that was evaluated.\n\t * @returns The objects containing relevant information or undefined if nothing relevant is found.\n\t */\n\tpublic async retrieve<D = unknown>(\n\t\tpolicy: IRightsManagementPolicy | undefined,\n\t\taccessMode: PolicyInformationAccessMode,\n\t\tdata?: D,\n\t\taction?: OdrlActionType | string\n\t): Promise<IRightsManagementInformation | 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: IRightsManagementInformation = {};\n\n\t\tif (Is.object<IRightsManagementPolicy>(policy)) {\n\t\t\tconst ids = [];\n\n\t\t\tif (Is.stringValue(policy.assignee)) {\n\t\t\t\tids.push(policy.assignee);\n\t\t\t}\n\t\t\tif (Is.stringValue(policy.assigner)) {\n\t\t\t\tids.push(policy.assigner);\n\t\t\t}\n\n\t\t\tfor (const id of ids) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\t\tsource: IdentityPolicyInformationSource.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"identityRetrieving\",\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tconst idDoc = await this._identityResolver.identityResolve(id);\n\t\t\t\t\tinformation[id] = JsonLdHelper.toNodeObject(idDoc);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\tsource: IdentityPolicyInformationSource.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"identityRetrievalFailed\",\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror: BaseError.fromError(err)\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn information;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Copyright 2025 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { BaseError, ComponentFactory, Guards, Is, NotFoundError } from "@3sixty/core";
|
|
4
|
+
import { JsonLdHelper } from "@3sixty/data-json-ld";
|
|
5
|
+
import { OdrlPolicyHelper, PolicyInformationAccessMode } from "@3sixty/rights-management-models";
|
|
6
|
+
/**
|
|
7
|
+
* Policy information source which retrieves identity profile information.
|
|
8
|
+
*/
|
|
9
|
+
export class IdentityProfilePolicyInformationSource {
|
|
10
|
+
/**
|
|
11
|
+
* The class name of the Identity Profile Policy Information Source.
|
|
12
|
+
*/
|
|
13
|
+
static CLASS_NAME = "IdentityProfilePolicyInformationSource";
|
|
14
|
+
/**
|
|
15
|
+
* The logging component.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
_logging;
|
|
19
|
+
/**
|
|
20
|
+
* The identity profile component.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
_identityProfile;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new instance of IdentityProfilePolicyInformationSource.
|
|
26
|
+
* @param options The options for the identity profile policy source.
|
|
27
|
+
*/
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this._logging = ComponentFactory.getIfExists(options?.loggingComponentType);
|
|
30
|
+
this._identityProfile = ComponentFactory.get(options?.identityProfileComponentType ?? "identity-profile");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the class name of the component.
|
|
34
|
+
* @returns The class name of the component.
|
|
35
|
+
*/
|
|
36
|
+
className() {
|
|
37
|
+
return IdentityProfilePolicyInformationSource.CLASS_NAME;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve information from the sources.
|
|
41
|
+
* @param policy The policy to retrieve information for if available.
|
|
42
|
+
* @param accessMode The access mode to use for the retrieval.
|
|
43
|
+
* @param data The data to process.
|
|
44
|
+
* @param action The action that was evaluated.
|
|
45
|
+
* @returns The objects containing relevant information or undefined if nothing relevant is found.
|
|
46
|
+
*/
|
|
47
|
+
async retrieve(policy, accessMode, data, action) {
|
|
48
|
+
Guards.arrayOneOf(IdentityProfilePolicyInformationSource.CLASS_NAME, "accessMode", accessMode, Object.values(PolicyInformationAccessMode));
|
|
49
|
+
const information = {};
|
|
50
|
+
if (Is.object(policy)) {
|
|
51
|
+
const ids = [];
|
|
52
|
+
if (Is.stringValue(policy.assignee)) {
|
|
53
|
+
ids.push(policy.assignee);
|
|
54
|
+
}
|
|
55
|
+
if (Is.stringValue(policy.assigner)) {
|
|
56
|
+
ids.push(policy.assigner);
|
|
57
|
+
}
|
|
58
|
+
for (const id of ids) {
|
|
59
|
+
try {
|
|
60
|
+
await this._logging?.log({
|
|
61
|
+
level: "info",
|
|
62
|
+
source: IdentityProfilePolicyInformationSource.CLASS_NAME,
|
|
63
|
+
ts: Date.now(),
|
|
64
|
+
message: "profileRetrieving",
|
|
65
|
+
data: {
|
|
66
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
67
|
+
id
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const profile = information.profile ?? {};
|
|
71
|
+
if (accessMode === PolicyInformationAccessMode.Public) {
|
|
72
|
+
const publicProfile = await this._identityProfile.getPublic(id);
|
|
73
|
+
profile[id] = {
|
|
74
|
+
public: Is.object(publicProfile)
|
|
75
|
+
? JsonLdHelper.toNodeObject(publicProfile)
|
|
76
|
+
: undefined
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const result = await this._identityProfile.get(undefined, undefined, id);
|
|
81
|
+
profile[id] = {
|
|
82
|
+
public: Is.object(result.publicProfile)
|
|
83
|
+
? JsonLdHelper.toNodeObject(result.publicProfile)
|
|
84
|
+
: undefined,
|
|
85
|
+
private: Is.object(result.privateProfile)
|
|
86
|
+
? JsonLdHelper.toNodeObject(result.privateProfile)
|
|
87
|
+
: undefined
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
information.profile = profile;
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
if (!BaseError.someErrorName(err, NotFoundError.CLASS_NAME)) {
|
|
94
|
+
await this._logging?.log({
|
|
95
|
+
level: "error",
|
|
96
|
+
source: IdentityProfilePolicyInformationSource.CLASS_NAME,
|
|
97
|
+
ts: Date.now(),
|
|
98
|
+
message: "profileRetrievalFailed",
|
|
99
|
+
data: {
|
|
100
|
+
policyId: OdrlPolicyHelper.getUid(policy) ?? "",
|
|
101
|
+
id
|
|
102
|
+
},
|
|
103
|
+
error: BaseError.fromError(err)
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return information;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=identityProfilePolicyInformationSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identityProfilePolicyInformationSource.js","sourceRoot":"","sources":["../../../src/policyInformationSources/identityProfilePolicyInformationSource.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAA0B,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI5E,OAAO,EACN,gBAAgB,EAChB,2BAA2B,EAI3B,MAAM,kCAAkC,CAAC;AAI1C;;GAEG;AACH,MAAM,OAAO,sCAAsC;IAClD;;OAEG;IACI,MAAM,CAAU,UAAU,4CAA4D;IAE7F;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,gBAAgB,CAA4B;IAE7D;;;OAGG;IACH,YAAY,OAAmE;QAC9E,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAAoB,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAC/F,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,GAAG,CAC3C,OAAO,EAAE,4BAA4B,IAAI,kBAAkB,CAC3D,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,sCAAsC,CAAC,UAAU,CAAC;IAC1D,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,QAAQ,CACpB,MAA2C,EAC3C,UAAuC,EACvC,IAAQ,EACR,MAAgC;QAEhC,MAAM,CAAC,UAAU,CAChB,sCAAsC,CAAC,UAAU,gBAEjD,UAAU,EACV,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAC1C,CAAC;QAEF,MAAM,WAAW,GAAiC,EAAE,CAAC;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CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;wBACzE,OAAO,CAAC,EAAE,CAAC,GAAG;4BACb,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;gCACtC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC;gCACjD,CAAC,CAAC,SAAS;4BACZ,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;gCACxC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC;gCAClD,CAAC,CAAC,SAAS;yBACZ,CAAC;oBACH,CAAC;oBACD,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;gBAC/B,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACd,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;wBAC7D,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;4BACxB,KAAK,EAAE,OAAO;4BACd,MAAM,EAAE,sCAAsC,CAAC,UAAU;4BACzD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;4BACd,OAAO,EAAE,wBAAwB;4BACjC,IAAI,EAAE;gCACL,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;gCAC/C,EAAE;6BACF;4BACD,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC;yBAC/B,CAAC,CAAC;oBACJ,CAAC;gBACF,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, NotFoundError } from \"@3sixty/core\";\nimport { type IJsonLdNodeObject, JsonLdHelper } from \"@3sixty/data-json-ld\";\nimport type { IIdentityProfileComponent } from \"@3sixty/identity-models\";\nimport type { ILoggingComponent } from \"@3sixty/logging-models\";\nimport { nameof } from \"@3sixty/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\tPolicyInformationAccessMode,\n\ttype IPolicyInformationSource,\n\ttype IRightsManagementInformation,\n\ttype IRightsManagementPolicy\n} from \"@3sixty/rights-management-models\";\nimport type { OdrlActionType } from \"@3sixty/standards-w3c-odrl\";\nimport type { IIdentityProfilePolicyInformationSourceConstructorOptions } from \"../models/IIdentityProfilePolicyInformationSourceConstructorOptions.js\";\n\n/**\n * Policy information source which retrieves identity profile information.\n */\nexport class IdentityProfilePolicyInformationSource implements IPolicyInformationSource {\n\t/**\n\t * The class name of the Identity Profile Policy Information Source.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityProfilePolicyInformationSource>();\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 profile component.\n\t * @internal\n\t */\n\tprivate readonly _identityProfile: IIdentityProfileComponent;\n\n\t/**\n\t * Create a new instance of IdentityProfilePolicyInformationSource.\n\t * @param options The options for the identity profile policy source.\n\t */\n\tconstructor(options?: IIdentityProfilePolicyInformationSourceConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(options?.loggingComponentType);\n\t\tthis._identityProfile = ComponentFactory.get(\n\t\t\toptions?.identityProfileComponentType ?? \"identity-profile\"\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 IdentityProfilePolicyInformationSource.CLASS_NAME;\n\t}\n\n\t/**\n\t * Retrieve information from the sources.\n\t * @param policy The policy to retrieve information for if available.\n\t * @param accessMode The access mode to use for the retrieval.\n\t * @param data The data to process.\n\t * @param action The action that was evaluated.\n\t * @returns The objects containing relevant information or undefined if nothing relevant is found.\n\t */\n\tpublic async retrieve<D = unknown>(\n\t\tpolicy: IRightsManagementPolicy | undefined,\n\t\taccessMode: PolicyInformationAccessMode,\n\t\tdata?: D,\n\t\taction?: OdrlActionType | string\n\t): Promise<IRightsManagementInformation | undefined> {\n\t\tGuards.arrayOneOf(\n\t\t\tIdentityProfilePolicyInformationSource.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: IRightsManagementInformation = {};\n\n\t\tif (Is.object<IRightsManagementPolicy>(policy)) {\n\t\t\tconst ids = [];\n\n\t\t\tif (Is.stringValue(policy.assignee)) {\n\t\t\t\tids.push(policy.assignee);\n\t\t\t}\n\t\t\tif (Is.stringValue(policy.assigner)) {\n\t\t\t\tids.push(policy.assigner);\n\t\t\t}\n\n\t\t\tfor (const id of ids) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\t\tsource: IdentityProfilePolicyInformationSource.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"profileRetrieving\",\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tconst profile = (information.profile as { [id: string]: IJsonLdNodeObject }) ?? {};\n\n\t\t\t\t\tif (accessMode === PolicyInformationAccessMode.Public) {\n\t\t\t\t\t\tconst publicProfile = await this._identityProfile.getPublic(id);\n\t\t\t\t\t\tprofile[id] = {\n\t\t\t\t\t\t\tpublic: Is.object(publicProfile)\n\t\t\t\t\t\t\t\t? JsonLdHelper.toNodeObject(publicProfile)\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t};\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst result = await this._identityProfile.get(undefined, undefined, id);\n\t\t\t\t\t\tprofile[id] = {\n\t\t\t\t\t\t\tpublic: Is.object(result.publicProfile)\n\t\t\t\t\t\t\t\t? JsonLdHelper.toNodeObject(result.publicProfile)\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tprivate: Is.object(result.privateProfile)\n\t\t\t\t\t\t\t\t? JsonLdHelper.toNodeObject(result.privateProfile)\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tinformation.profile = profile;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tif (!BaseError.someErrorName(err, NotFoundError.CLASS_NAME)) {\n\t\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tsource: IdentityProfilePolicyInformationSource.CLASS_NAME,\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tmessage: \"profileRetrievalFailed\",\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tpolicyId: OdrlPolicyHelper.getUid(policy) ?? \"\",\n\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\terror: BaseError.fromError(err)\n\t\t\t\t\t\t});\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"]}
|