@twin.org/dataspace-control-plane-service 0.0.3-next.17 → 0.0.3-next.18

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.
@@ -37,6 +37,7 @@ export function generateRestRoutesDataspaceControlPlane(baseRouteName, component
37
37
  tag: tagsDataspaceControlPlane[0].name,
38
38
  method: "POST",
39
39
  path: `${baseRouteName}/transfers/request`,
40
+ skipAuth: true,
40
41
  handler: async (httpRequestContext, request) => requestTransferHandler(httpRequestContext, componentName, request)
41
42
  });
42
43
  // GET /transfers/:pid - Get Transfer Process state (DSP)
@@ -46,6 +47,7 @@ export function generateRestRoutesDataspaceControlPlane(baseRouteName, component
46
47
  tag: tagsDataspaceControlPlane[0].name,
47
48
  method: "GET",
48
49
  path: `${baseRouteName}/transfers/:pid`,
50
+ skipAuth: true,
49
51
  handler: async (httpRequestContext, request) => getTransferProcessHandler(httpRequestContext, componentName, request)
50
52
  });
51
53
  // POST /transfers/:pid/start - Start Transfer Process (DSP)
@@ -55,6 +57,7 @@ export function generateRestRoutesDataspaceControlPlane(baseRouteName, component
55
57
  tag: tagsDataspaceControlPlane[0].name,
56
58
  method: "POST",
57
59
  path: `${baseRouteName}/transfers/:pid/start`,
60
+ skipAuth: true,
58
61
  handler: async (httpRequestContext, request) => startTransferHandler(httpRequestContext, componentName, request)
59
62
  });
60
63
  // POST /transfers/:pid/complete - Complete Transfer Process (DSP)
@@ -64,6 +67,7 @@ export function generateRestRoutesDataspaceControlPlane(baseRouteName, component
64
67
  tag: tagsDataspaceControlPlane[0].name,
65
68
  method: "POST",
66
69
  path: `${baseRouteName}/transfers/:pid/complete`,
70
+ skipAuth: true,
67
71
  handler: async (httpRequestContext, request) => completeTransferHandler(httpRequestContext, componentName, request)
68
72
  });
69
73
  // POST /transfers/:pid/suspend - Suspend Transfer Process (DSP)
@@ -73,6 +77,7 @@ export function generateRestRoutesDataspaceControlPlane(baseRouteName, component
73
77
  tag: tagsDataspaceControlPlane[0].name,
74
78
  method: "POST",
75
79
  path: `${baseRouteName}/transfers/:pid/suspend`,
80
+ skipAuth: true,
76
81
  handler: async (httpRequestContext, request) => suspendTransferHandler(httpRequestContext, componentName, request)
77
82
  });
78
83
  // POST /transfers/:pid/terminate - Terminate Transfer Process (DSP)
@@ -82,6 +87,7 @@ export function generateRestRoutesDataspaceControlPlane(baseRouteName, component
82
87
  tag: tagsDataspaceControlPlane[0].name,
83
88
  method: "POST",
84
89
  path: `${baseRouteName}/transfers/:pid/terminate`,
90
+ skipAuth: true,
85
91
  handler: async (httpRequestContext, request) => terminateTransferHandler(httpRequestContext, componentName, request)
86
92
  });
87
93
  return routes;
@@ -1 +1 @@
1
- {"version":3,"file":"dataspaceControlPlaneRoutes.js","sourceRoot":"","sources":["../../src/dataspaceControlPlaneRoutes.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAiB1D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;GAEG;AACH,MAAM,aAAa,GAAG,6BAA6B,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAW;IAChD;QACC,IAAI,EAAE,kBAAkB;QACxB,WAAW,EACV,qFAAqF;KACtF;CACD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uCAAuC,CACtD,aAAqB,EACrB,aAAqB;IAErB,MAAM,MAAM,GAAiB,EAAE,CAAC;IAEhC,+EAA+E;IAC/E,kCAAkC;IAClC,+EAA+E;IAE/E,2DAA2D;IAC3D,MAAM,CAAC,IAAI,CAAC;QACX,WAAW,EAAE,iBAAiB;QAC9B,OAAO,EAAE,gCAAgC;QACzC,GAAG,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAAC,IAAI;QACtC,MAAM,EAAE,MAAM;QACd,IAAI,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,CAAC,CAAC;IAEjE,MAAM,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAE5F,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAkC,aAAa,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAE3E,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,0BAA0B,CAAC,MAAM,CAAC;KAC9C,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,wBAAwB,CACtC,kBAAuC,EACvC,aAAqB,EACrB,OAAkC;IAElC,MAAM,CAAC,MAAM,CAAC,aAAa,aAAmB,OAAO,CAAC,CAAC;IACvD,MAAM,CAAC,MAAM,CAAC,aAAa,kBAAwB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE,MAAM,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAE5F,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAkC,aAAa,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAE7E,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,0BAA0B,CAAC,MAAM,CAAC;KAC9C,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIHostingComponent,\n\tIHttpRequestContext,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type {\n\tIDataspaceControlPlaneComponent,\n\tIRequestTransferRequest,\n\tIRequestTransferResponse,\n\tIGetTransferProcessRequest,\n\tIGetTransferProcessResponse,\n\tIStartTransferRequest,\n\tIStartTransferResponse,\n\tICompleteTransferRequest,\n\tICompleteTransferResponse,\n\tISuspendTransferRequest,\n\tISuspendTransferResponse,\n\tITerminateTransferRequest,\n\tITerminateTransferResponse\n} from \"@twin.org/dataspace-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderHelper, HeaderTypes } from \"@twin.org/web\";\nimport { transformErrorToStatusCode } from \"./utils/transferErrorUtils.js\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"dataspaceControlPlaneRoutes\";\n\n/**\n * The tags to associate with the DSP protocol routes.\n */\nexport const tagsDataspaceControlPlane: ITag[] = [\n\t{\n\t\tname: \"Transfer Process\",\n\t\tdescription:\n\t\t\t\"DSP Transfer Process Protocol endpoints for initiating and managing data transfers.\"\n\t}\n];\n\n/**\n * The REST routes for dataspace control plane (DSP Protocol only).\n * These routes implement the Eclipse Dataspace Protocol Transfer Process Protocol.\n *\n * Contract Negotiation is handled internally via PNP callbacks — no REST endpoints needed.\n * PNP registers its own inbound callback routes for negotiation messages from providers.\n *\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated DSP protocol routes.\n */\nexport function generateRestRoutesDataspaceControlPlane(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst routes: IRestRoute[] = [];\n\n\t// ============================================================================\n\t// TRANSFER PROCESS PROTOCOL (DSP)\n\t// ============================================================================\n\n\t// POST /transfers/request - Request Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"requestTransfer\",\n\t\tsummary: \"Request Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/request`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\trequestTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// GET /transfers/:pid - Get Transfer Process state (DSP)\n\troutes.push({\n\t\toperationId: \"getTransferProcess\",\n\t\tsummary: \"Get Transfer Process state (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/transfers/:pid`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tgetTransferProcessHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/start - Start Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"startTransfer\",\n\t\tsummary: \"Start Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/start`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tstartTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/complete - Complete Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"completeTransfer\",\n\t\tsummary: \"Complete Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/complete`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tcompleteTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/suspend - Suspend Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"suspendTransfer\",\n\t\tsummary: \"Suspend Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/suspend`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tsuspendTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/terminate - Terminate Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"terminateTransfer\",\n\t\tsummary: \"Terminate Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/terminate`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tterminateTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\treturn routes;\n}\n\n// ============================================================================\n// TRANSFER PROCESS PROTOCOL HANDLERS\n// ============================================================================\n\n/**\n * Request Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers and body.\n * @returns The response.\n */\nasync function requestTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IRequestTransferRequest\n): Promise<IRequestTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.requestTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Get Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers and path parameters.\n * @returns The response.\n */\nasync function getTransferProcessHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IGetTransferProcessRequest\n): Promise<IGetTransferProcessResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.pathParams), request.pathParams);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.pid), request.pathParams.pid);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.getTransferProcess(request.pathParams.pid, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Start Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function startTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IStartTransferRequest\n): Promise<IStartTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.startTransfer(\n\t\trequest.body,\n\t\tawait hostingComponent.getPublicOrigin(httpRequestContext.serverRequest.url),\n\t\ttrustPayload\n\t);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Complete Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function completeTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ICompleteTransferRequest\n): Promise<ICompleteTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.completeTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Suspend Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function suspendTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ISuspendTransferRequest\n): Promise<ISuspendTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.suspendTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Terminate Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function terminateTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITerminateTransferRequest\n): Promise<ITerminateTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.terminateTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n"]}
1
+ {"version":3,"file":"dataspaceControlPlaneRoutes.js","sourceRoot":"","sources":["../../src/dataspaceControlPlaneRoutes.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAiB1D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;GAEG;AACH,MAAM,aAAa,G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,IAAI,CAAC,CAAC;IAEjE,MAAM,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAE5F,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAkC,aAAa,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAE7E,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,0BAA0B,CAAC,MAAM,CAAC;KAC9C,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIHostingComponent,\n\tIHttpRequestContext,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type {\n\tIDataspaceControlPlaneComponent,\n\tIRequestTransferRequest,\n\tIRequestTransferResponse,\n\tIGetTransferProcessRequest,\n\tIGetTransferProcessResponse,\n\tIStartTransferRequest,\n\tIStartTransferResponse,\n\tICompleteTransferRequest,\n\tICompleteTransferResponse,\n\tISuspendTransferRequest,\n\tISuspendTransferResponse,\n\tITerminateTransferRequest,\n\tITerminateTransferResponse\n} from \"@twin.org/dataspace-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderHelper, HeaderTypes } from \"@twin.org/web\";\nimport { transformErrorToStatusCode } from \"./utils/transferErrorUtils.js\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"dataspaceControlPlaneRoutes\";\n\n/**\n * The tags to associate with the DSP protocol routes.\n */\nexport const tagsDataspaceControlPlane: ITag[] = [\n\t{\n\t\tname: \"Transfer Process\",\n\t\tdescription:\n\t\t\t\"DSP Transfer Process Protocol endpoints for initiating and managing data transfers.\"\n\t}\n];\n\n/**\n * The REST routes for dataspace control plane (DSP Protocol only).\n * These routes implement the Eclipse Dataspace Protocol Transfer Process Protocol.\n *\n * Contract Negotiation is handled internally via PNP callbacks — no REST endpoints needed.\n * PNP registers its own inbound callback routes for negotiation messages from providers.\n *\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated DSP protocol routes.\n */\nexport function generateRestRoutesDataspaceControlPlane(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst routes: IRestRoute[] = [];\n\n\t// ============================================================================\n\t// TRANSFER PROCESS PROTOCOL (DSP)\n\t// ============================================================================\n\n\t// POST /transfers/request - Request Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"requestTransfer\",\n\t\tsummary: \"Request Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/request`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\trequestTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// GET /transfers/:pid - Get Transfer Process state (DSP)\n\troutes.push({\n\t\toperationId: \"getTransferProcess\",\n\t\tsummary: \"Get Transfer Process state (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/transfers/:pid`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tgetTransferProcessHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/start - Start Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"startTransfer\",\n\t\tsummary: \"Start Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/start`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tstartTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/complete - Complete Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"completeTransfer\",\n\t\tsummary: \"Complete Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/complete`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tcompleteTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/suspend - Suspend Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"suspendTransfer\",\n\t\tsummary: \"Suspend Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/suspend`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tsuspendTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/terminate - Terminate Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"terminateTransfer\",\n\t\tsummary: \"Terminate Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/terminate`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tterminateTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\treturn routes;\n}\n\n// ============================================================================\n// TRANSFER PROCESS PROTOCOL HANDLERS\n// ============================================================================\n\n/**\n * Request Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers and body.\n * @returns The response.\n */\nasync function requestTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IRequestTransferRequest\n): Promise<IRequestTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.requestTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Get Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers and path parameters.\n * @returns The response.\n */\nasync function getTransferProcessHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IGetTransferProcessRequest\n): Promise<IGetTransferProcessResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.pathParams), request.pathParams);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.pid), request.pathParams.pid);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.getTransferProcess(request.pathParams.pid, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Start Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function startTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IStartTransferRequest\n): Promise<IStartTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.startTransfer(\n\t\trequest.body,\n\t\tawait hostingComponent.getPublicOrigin(httpRequestContext.serverRequest.url),\n\t\ttrustPayload\n\t);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Complete Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function completeTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ICompleteTransferRequest\n): Promise<ICompleteTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.completeTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Suspend Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function suspendTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ISuspendTransferRequest\n): Promise<ISuspendTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.suspendTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Terminate Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function terminateTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITerminateTransferRequest\n): Promise<ITerminateTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.terminateTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ContextIdKeys, ContextIdStore } from "@twin.org/context";
2
- import { ArrayHelper, BaseError, ComponentFactory, Converter, GeneralError, Guards, Is, NotFoundError, ObjectHelper, RandomHelper, StringHelper, UnauthorizedError } from "@twin.org/core";
2
+ import { ArrayHelper, BaseError, ComponentFactory, Converter, GeneralError, Guards, Is, NotFoundError, RandomHelper, StringHelper, UnauthorizedError } from "@twin.org/core";
3
3
  import { JsonLdHelper } from "@twin.org/data-json-ld";
4
4
  import { DataspaceAppFactory, TransferProcessRole } from "@twin.org/dataspace-models";
5
5
  import { EngineCoreFactory } from "@twin.org/engine-models";
@@ -333,7 +333,7 @@ export class DataspaceControlPlaneService {
333
333
  * Called by: Consumer when it wants to request a new Transfer Process
334
334
  */
335
335
  async requestTransfer(request, trustPayload) {
336
- await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "requestTransfer");
336
+ const trustInfo = await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "requestTransfer");
337
337
  const validationFailures = [];
338
338
  const isConformant = await DataspaceProtocolHelper.checkConformance(JsonLdHelper.toNodeObject(request), validationFailures);
339
339
  if (!isConformant) {
@@ -372,9 +372,17 @@ export class DataspaceControlPlaneService {
372
372
  });
373
373
  }
374
374
  const assigneeIdentity = OdrlPolicyHelper.extractAssigneeIdentity(agreement);
375
- consumerIdentity = Is.array(assigneeIdentity) ? assigneeIdentity[0] : assigneeIdentity;
375
+ const assigneeIds = ArrayHelper.fromObjectOrArray(assigneeIdentity);
376
+ if (!assigneeIds.includes(trustInfo.identity)) {
377
+ throw new UnauthorizedError(DataspaceControlPlaneService.CLASS_NAME, "callerNotAuthorizedForAgreement");
378
+ }
379
+ consumerIdentity = trustInfo.identity;
376
380
  const assignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);
377
- providerIdentity = Is.array(assignerIdentity) ? assignerIdentity[0] : assignerIdentity;
381
+ const assignerIds = ArrayHelper.fromObjectOrArray(assignerIdentity);
382
+ if (assignerIds.length > 1) {
383
+ throw new GeneralError(DataspaceControlPlaneService.CLASS_NAME, "multipleAssignersNotSupported");
384
+ }
385
+ providerIdentity = assignerIds[0];
378
386
  datasetId = this.extractDatasetId(agreement);
379
387
  await this.validateCatalogDataset(datasetId, agreement);
380
388
  policies = [agreement];
@@ -390,8 +398,8 @@ export class DataspaceControlPlaneService {
390
398
  state: DataspaceProtocolTransferProcessStateType.REQUESTED,
391
399
  agreementId: request.agreementId,
392
400
  datasetId,
393
- consumerIdentity: ArrayHelper.fromObjectOrArray(consumerIdentity)[0],
394
- providerIdentity: ArrayHelper.fromObjectOrArray(providerIdentity)[0],
401
+ consumerIdentity,
402
+ providerIdentity,
395
403
  // offerId should reference Catalog Offer (via Agreement)
396
404
  // For now, use agreementId as reference (proper flow: Catalog → Negotiation → Agreement)
397
405
  offerId: request.agreementId,
@@ -437,7 +445,7 @@ export class DataspaceControlPlaneService {
437
445
  * Role Performed: Provider / Consumer
438
446
  */
439
447
  async startTransfer(message, publicOrigin, trustPayload) {
440
- await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "startTransfer");
448
+ const trustInfo = await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "startTransfer");
441
449
  const validationFailures = [];
442
450
  const isConformant = await DataspaceProtocolHelper.checkConformance(JsonLdHelper.toNodeObject(message), validationFailures);
443
451
  if (!isConformant) {
@@ -447,6 +455,7 @@ export class DataspaceControlPlaneService {
447
455
  }
448
456
  try {
449
457
  const { entity, role } = await this.lookupTransferByMessage(message);
458
+ this.validateCallerIsProvider(trustInfo.identity, entity);
450
459
  if (entity.state !== DataspaceProtocolTransferProcessStateType.REQUESTED &&
451
460
  entity.state !== DataspaceProtocolTransferProcessStateType.SUSPENDED) {
452
461
  return transformToTransferError(new GeneralError(DataspaceControlPlaneService.CLASS_NAME, "invalidStateForStart", {
@@ -501,13 +510,21 @@ export class DataspaceControlPlaneService {
501
510
  providerPid: entity.providerPid
502
511
  }), message);
503
512
  }
504
- const accessToken = await this._trustComponent.generate(entity.consumerIdentity ?? entity.consumerPid, this._overrideTrustGeneratorType, {
505
- consumerPid: entity.consumerPid,
506
- providerPid: entity.providerPid,
507
- agreementId: entity.agreementId,
508
- datasetId: entity.datasetId
513
+ // Provider signs the data access token with its own identity.
514
+ // The subject contains the transfer context claims that the data plane
515
+ // will verify when the consumer presents this token.
516
+ if (!Is.stringValue(entity.providerIdentity)) {
517
+ throw new GeneralError(DataspaceControlPlaneService.CLASS_NAME, "providerIdentityMissing");
518
+ }
519
+ const accessToken = await this._trustComponent.generate(entity.providerIdentity, this._overrideTrustGeneratorType, {
520
+ subject: {
521
+ consumerPid: entity.consumerPid,
522
+ providerPid: entity.providerPid,
523
+ agreementId: entity.agreementId,
524
+ datasetId: entity.datasetId
525
+ }
509
526
  });
510
- const tokenString = Converter.bytesToBase64(ObjectHelper.toBytes(accessToken));
527
+ const tokenString = accessToken;
511
528
  const fullEndpoint = `${publicOrigin}/${this._dataPlanePath}`;
512
529
  response.dataAddress = {
513
530
  "@type": DataspaceProtocolTransferProcessTypes.DataAddress,
@@ -586,7 +603,7 @@ export class DataspaceControlPlaneService {
586
603
  * @returns Transfer Process (DSP compliant) with state COMPLETED, or TransferError if the operation fails.
587
604
  */
588
605
  async completeTransfer(message, trustPayload) {
589
- await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "completeTransfer");
606
+ const trustInfo = await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "completeTransfer");
590
607
  const validationFailures = [];
591
608
  const isConformant = await DataspaceProtocolHelper.checkConformance(JsonLdHelper.toNodeObject(message), validationFailures);
592
609
  if (!isConformant) {
@@ -594,6 +611,7 @@ export class DataspaceControlPlaneService {
594
611
  }
595
612
  try {
596
613
  const { entity, role } = await this.lookupTransferByMessage(message);
614
+ this.validateCallerIsConsumer(trustInfo.identity, entity);
597
615
  if (entity.state !== DataspaceProtocolTransferProcessStateType.STARTED) {
598
616
  return transformToTransferError(new GeneralError(DataspaceControlPlaneService.CLASS_NAME, "invalidStateForComplete", {
599
617
  consumerPid: entity.consumerPid,
@@ -634,7 +652,7 @@ export class DataspaceControlPlaneService {
634
652
  * @returns Transfer Process (DSP compliant) with state SUSPENDED, or TransferError if the operation fails.
635
653
  */
636
654
  async suspendTransfer(message, trustPayload) {
637
- await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "suspendTransfer");
655
+ const trustInfo = await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "suspendTransfer");
638
656
  const validationFailures = [];
639
657
  const isConformant = await DataspaceProtocolHelper.checkConformance(JsonLdHelper.toNodeObject(message), validationFailures);
640
658
  if (!isConformant) {
@@ -642,6 +660,7 @@ export class DataspaceControlPlaneService {
642
660
  }
643
661
  try {
644
662
  const { entity, role } = await this.lookupTransferByMessage(message);
663
+ this.validateCallerIsTransferParty(trustInfo.identity, entity);
645
664
  if (entity.state !== DataspaceProtocolTransferProcessStateType.STARTED) {
646
665
  return transformToTransferError(new GeneralError(DataspaceControlPlaneService.CLASS_NAME, "invalidStateForSuspend", {
647
666
  consumerPid: entity.consumerPid,
@@ -683,7 +702,7 @@ export class DataspaceControlPlaneService {
683
702
  * @returns Transfer Process (DSP compliant) with state TERMINATED, or TransferError if the operation fails.
684
703
  */
685
704
  async terminateTransfer(message, trustPayload) {
686
- await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "terminateTransfer");
705
+ const trustInfo = await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "terminateTransfer");
687
706
  const validationFailures = [];
688
707
  const isConformant = await DataspaceProtocolHelper.checkConformance(JsonLdHelper.toNodeObject(message), validationFailures);
689
708
  if (!isConformant) {
@@ -691,6 +710,7 @@ export class DataspaceControlPlaneService {
691
710
  }
692
711
  try {
693
712
  const { entity, role } = await this.lookupTransferByMessage(message);
713
+ this.validateCallerIsTransferParty(trustInfo.identity, entity);
694
714
  entity.state = DataspaceProtocolTransferProcessStateType.TERMINATED;
695
715
  entity.dateModified = new Date();
696
716
  await this._transferProcessStorage.set(this.modelToStorageEntity(entity));
@@ -725,9 +745,10 @@ export class DataspaceControlPlaneService {
725
745
  * @returns Transfer Process (DSP compliant) with current state, or TransferError if the operation fails.
726
746
  */
727
747
  async getTransferProcess(pid, trustPayload) {
728
- await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "getTransferProcess");
748
+ const trustInfo = await TrustHelper.verifyTrust(this._trustComponent, trustPayload, "getTransferProcess");
729
749
  try {
730
750
  const { entity, role } = await this.lookupTransferByPid(pid);
751
+ this.validateCallerIsTransferParty(trustInfo.identity, entity);
731
752
  await this._loggingComponent?.log({
732
753
  level: "info",
733
754
  source: DataspaceControlPlaneService.CLASS_NAME,
@@ -759,13 +780,15 @@ export class DataspaceControlPlaneService {
759
780
  * Returns immediately with a negotiationId. The caller is notified
760
781
  * via the registered INegotiationCallback when the negotiation completes.
761
782
  *
783
+ * @param datasetId The dataset ID from the provider's catalog.
762
784
  * @param offerId The offer ID from the provider's catalog.
763
785
  * @param providerEndpoint The provider's contract negotiation endpoint URL.
764
786
  * @param publicOrigin The public origin URL of this control plane (for callbacks).
765
787
  * @param trustPayload The trust payload for authentication.
766
788
  * @returns The negotiation ID. Use the registered callback for completion notification.
767
789
  */
768
- async negotiateAgreement(offerId, providerEndpoint, publicOrigin, trustPayload) {
790
+ async negotiateAgreement(datasetId, offerId, providerEndpoint, publicOrigin, trustPayload) {
791
+ Guards.stringValue(DataspaceControlPlaneService.CLASS_NAME, "datasetId", datasetId);
769
792
  Guards.stringValue(DataspaceControlPlaneService.CLASS_NAME, "offerId", offerId);
770
793
  Guards.stringValue(DataspaceControlPlaneService.CLASS_NAME, "providerEndpoint", providerEndpoint);
771
794
  Guards.stringValue(DataspaceControlPlaneService.CLASS_NAME, "publicOrigin", publicOrigin);
@@ -774,17 +797,19 @@ export class DataspaceControlPlaneService {
774
797
  source: DataspaceControlPlaneService.CLASS_NAME,
775
798
  ts: Date.now(),
776
799
  message: "startingContractNegotiation",
777
- data: { offerId, providerEndpoint, publicOrigin }
800
+ data: { datasetId, offerId, providerEndpoint, publicOrigin }
778
801
  });
779
- const catalogResult = await this._federatedCatalogueComponent.get(offerId);
802
+ const catalogResult = await this._federatedCatalogueComponent.get(datasetId);
780
803
  if (isCatalogError(catalogResult)) {
781
804
  if (isCatalogErrorName(catalogResult, NotFoundError.CLASS_NAME)) {
782
- throw new NotFoundError(DataspaceControlPlaneService.CLASS_NAME, "datasetNotFoundInCatalog", offerId, {
805
+ throw new NotFoundError(DataspaceControlPlaneService.CLASS_NAME, "datasetNotFoundInCatalog", datasetId, {
806
+ datasetId,
783
807
  offerId,
784
808
  providerEndpoint
785
809
  });
786
810
  }
787
811
  throw new GeneralError(DataspaceControlPlaneService.CLASS_NAME, "catalogLookupFailedForNegotiation", {
812
+ datasetId,
788
813
  offerId,
789
814
  providerEndpoint,
790
815
  errorCode: catalogResult.code
@@ -960,13 +985,13 @@ export class DataspaceControlPlaneService {
960
985
  });
961
986
  }
962
987
  const assignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);
963
- const assignerId = Is.array(assignerIdentity) ? assignerIdentity[0] : assignerIdentity;
964
- if (assignerId !== currentOrgId) {
988
+ const assignerIds = ArrayHelper.fromObjectOrArray(assignerIdentity);
989
+ if (!assignerIds.includes(currentOrgId)) {
965
990
  throw new UnauthorizedError(DataspaceControlPlaneService.CLASS_NAME, "agreementAssignerMismatch", {
966
991
  consumerPid,
967
992
  agreementId: OdrlPolicyHelper.getUid(agreement),
968
993
  expectedOrgId: currentOrgId,
969
- actualAssigner: assignerId
994
+ actualAssigner: assignerIds.join(", ")
970
995
  });
971
996
  }
972
997
  await this._loggingComponent?.log({
@@ -1020,26 +1045,27 @@ export class DataspaceControlPlaneService {
1020
1045
  }
1021
1046
  // Extract assigner UID (can be string, array, or IOdrlParty object)
1022
1047
  const assignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);
1023
- const assignerId = Is.array(assignerIdentity) ? assignerIdentity[0] : assignerIdentity;
1024
- if (assignerId !== currentOrgId) {
1048
+ const assignerIds = ArrayHelper.fromObjectOrArray(assignerIdentity);
1049
+ if (!assignerIds.includes(currentOrgId)) {
1025
1050
  throw new UnauthorizedError(DataspaceControlPlaneService.CLASS_NAME, "agreementAssignerMismatchProvider", {
1026
1051
  providerPid,
1027
1052
  agreementId: OdrlPolicyHelper.getUid(agreement),
1028
1053
  expectedOrgId: currentOrgId,
1029
- actualAssigner: assignerId
1054
+ actualAssigner: assignerIds.join(", ")
1030
1055
  });
1031
1056
  }
1032
1057
  // Validate that Agreement assignee matches expected consumer identity
1033
1058
  // This ensures we're pushing to the correct consumer
1034
1059
  // If assignee is undefined but consumerIdentity has a value, this is also a mismatch
1035
1060
  const assigneeIdentity = OdrlPolicyHelper.extractAssigneeIdentity(agreement);
1036
- const assigneeId = Is.array(assigneeIdentity) ? assigneeIdentity[0] : assigneeIdentity;
1037
- if (assigneeId !== entity.consumerIdentity) {
1061
+ const assigneeIds = ArrayHelper.fromObjectOrArray(assigneeIdentity);
1062
+ if (!Is.stringValue(entity.consumerIdentity) ||
1063
+ !assigneeIds.includes(entity.consumerIdentity)) {
1038
1064
  throw new UnauthorizedError(DataspaceControlPlaneService.CLASS_NAME, "agreementAssigneeMismatch", {
1039
1065
  providerPid,
1040
1066
  agreementId: OdrlPolicyHelper.getUid(agreement),
1041
1067
  expectedConsumerIdentity: entity.consumerIdentity,
1042
- actualAssignee: assigneeId
1068
+ actualAssignee: assigneeIds.join(", ")
1043
1069
  });
1044
1070
  }
1045
1071
  await this._loggingComponent?.log({
@@ -1189,6 +1215,42 @@ export class DataspaceControlPlaneService {
1189
1215
  }
1190
1216
  return agreement;
1191
1217
  }
1218
+ /**
1219
+ * Validate that the caller's verified identity matches the consumer of a transfer process.
1220
+ * @param callerIdentity The identity from the verified trust token.
1221
+ * @param entity The transfer process entity.
1222
+ * @throws UnauthorizedError if the caller is not the consumer.
1223
+ * @internal
1224
+ */
1225
+ validateCallerIsConsumer(callerIdentity, entity) {
1226
+ if (callerIdentity !== entity.consumerIdentity) {
1227
+ throw new UnauthorizedError(DataspaceControlPlaneService.CLASS_NAME, "callerNotAuthorizedAsConsumer");
1228
+ }
1229
+ }
1230
+ /**
1231
+ * Validate that the caller's verified identity matches the provider of a transfer process.
1232
+ * @param callerIdentity The identity from the verified trust token.
1233
+ * @param entity The transfer process entity.
1234
+ * @throws UnauthorizedError if the caller is not the provider.
1235
+ * @internal
1236
+ */
1237
+ validateCallerIsProvider(callerIdentity, entity) {
1238
+ if (callerIdentity !== entity.providerIdentity) {
1239
+ throw new UnauthorizedError(DataspaceControlPlaneService.CLASS_NAME, "callerNotAuthorizedAsProvider");
1240
+ }
1241
+ }
1242
+ /**
1243
+ * Validate that the caller's verified identity matches either the consumer or provider of a transfer process.
1244
+ * @param callerIdentity The identity from the verified trust token.
1245
+ * @param entity The transfer process entity.
1246
+ * @throws UnauthorizedError if the caller is not a party to the transfer.
1247
+ * @internal
1248
+ */
1249
+ validateCallerIsTransferParty(callerIdentity, entity) {
1250
+ if (callerIdentity !== entity.consumerIdentity && callerIdentity !== entity.providerIdentity) {
1251
+ throw new UnauthorizedError(DataspaceControlPlaneService.CLASS_NAME, "callerNotAuthorizedForTransfer");
1252
+ }
1253
+ }
1192
1254
  /**
1193
1255
  * Extract dataset ID from Agreement target.
1194
1256
  * @param agreement Agreement.
@@ -1322,6 +1384,10 @@ export class DataspaceControlPlaneService {
1322
1384
  async validateAgreementMatchesOffer(agreement, catalogDataset) {
1323
1385
  Guards.object(DataspaceControlPlaneService.CLASS_NAME, "agreement", agreement);
1324
1386
  Guards.object(DataspaceControlPlaneService.CLASS_NAME, "catalogDataset", catalogDataset);
1387
+ const datasetId = getJsonLdId(catalogDataset);
1388
+ if (!Is.stringValue(datasetId)) {
1389
+ throw new NotFoundError(DataspaceControlPlaneService.CLASS_NAME, "catalogDatasetMissingId");
1390
+ }
1325
1391
  const rawOffers = this.getCatalogDatasetPolicies(catalogDataset);
1326
1392
  if (!Is.arrayValue(rawOffers)) {
1327
1393
  await this._loggingComponent?.log({
@@ -1369,15 +1435,20 @@ export class DataspaceControlPlaneService {
1369
1435
  data: {
1370
1436
  agreementId: OdrlPolicyHelper.getUid(agreement) ?? "",
1371
1437
  offerId: OdrlPolicyHelper.getUid(matchingOffer) ?? "",
1372
- datasetId: getJsonLdId(catalogDataset) ?? ""
1438
+ datasetId
1373
1439
  }
1374
1440
  });
1375
1441
  }
1376
1442
  /**
1377
1443
  * Check if an Agreement is derived from an Offer.
1444
+ * Per the DS Protocol spec, Offers within a Dataset's hasPolicy array must NOT
1445
+ * include an explicit "target" property — the target is implicitly the Dataset itself.
1446
+ * When the offer has no explicit targets, we use the datasetId as the implicit target
1447
+ * so that the comparison with the agreement's target can succeed.
1378
1448
  * @param agreement Agreement to check.
1379
1449
  * @param offer Offer to compare against.
1380
1450
  * @returns True if Agreement appears derived from Offer.
1451
+ * @see https://eclipse-dataspace-protocol-base.github.io/DataspaceProtocol/2025-1-err1/#lower-level-types
1381
1452
  * @internal
1382
1453
  */
1383
1454
  isPolicyDerivedFrom(agreement, offer) {
@@ -1 +1 @@
1
- {"version":3,"file":"dataspaceControlPlaneService.js","sourceRoot":"","sources":["../../src/dataspaceControlPlaneService.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,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AO,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAClC,OAAO,OAAO,CAAC;QAChB,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QAEvD,IAAI,KAAK,EAAE,CAAC;YACX,OAAO;gBACN,GAAG,OAAO;gBACV,mBAAmB,EAAE,KAAK;aAC1B,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ITaskSchedulerComponent } from \"@twin.org/background-task-models\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tArrayHelper,\n\tBaseError,\n\tComponentFactory,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tObjectHelper,\n\tRandomHelper,\n\tStringHelper,\n\tUnauthorizedError,\n\ttype IValidationFailure,\n\ttype ObjectOrArray\n} from \"@twin.org/core\";\nimport { JsonLdHelper, type JsonLdObjectWithNoContext } from \"@twin.org/data-json-ld\";\nimport {\n\tDataspaceAppFactory,\n\tTransferProcessRole,\n\ttype IDataspaceApp,\n\ttype IDataspaceControlPlaneComponent,\n\ttype IDataspaceControlPlaneResolverComponent,\n\ttype INegotiationCallback,\n\ttype ITransferContext,\n\ttype ITransferProcess,\n\ttype TransferProcess\n} from \"@twin.org/dataspace-models\";\nimport { EngineCoreFactory } from \"@twin.org/engine-models\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IFederatedCatalogueComponent } from \"@twin.org/federated-catalogue-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\tPolicyRequesterFactory,\n\ttype IPolicyAdministrationPointComponent,\n\ttype IPolicyNegotiationAdminPointComponent,\n\ttype IPolicyNegotiationPointComponent\n} from \"@twin.org/rights-management-models\";\nimport {\n\tDataspaceProtocolContexts,\n\tDataspaceProtocolContractNegotiationTypes,\n\tDataspaceProtocolEndpointType,\n\tDataspaceProtocolHelper,\n\tDataspaceProtocolTransferProcessStateType,\n\tDataspaceProtocolTransferProcessTypes,\n\ttype DataspaceProtocolContractNegotiationStateType,\n\ttype IDataspaceProtocolAgreement,\n\ttype IDataspaceProtocolContractNegotiation,\n\ttype IDataspaceProtocolContractNegotiationError,\n\ttype IDataspaceProtocolDataset,\n\ttype IDataspaceProtocolPolicy,\n\ttype IDataspaceProtocolTransferCompletionMessage,\n\ttype IDataspaceProtocolTransferError,\n\ttype IDataspaceProtocolTransferProcess,\n\ttype IDataspaceProtocolTransferRequestMessage,\n\ttype IDataspaceProtocolTransferStartMessage,\n\ttype IDataspaceProtocolTransferSuspensionMessage,\n\ttype IDataspaceProtocolTransferTerminationMessage\n} from \"@twin.org/standards-dataspace-protocol\";\nimport type { IDcatDataset } from \"@twin.org/standards-w3c-dcat\";\nimport { TrustHelper, type ITrustComponent } from \"@twin.org/trust-models\";\nimport { DataspaceControlPlanePolicyRequester } from \"./dataspaceControlPlanePolicyRequester.js\";\nimport type { IDataspaceControlPlaneServiceConstructorOptions } from \"./models/IDataspaceControlPlaneServiceConstructorOptions.js\";\nimport { getJsonLdId, getJsonLdType } from \"./utils/dataHelpers.js\";\nimport {\n\tisCatalogError,\n\tisCatalogErrorName,\n\ttransformToTransferError\n} from \"./utils/transferErrorUtils.js\";\n\n/**\n * Stalled negotiation threshold in milliseconds (30 minutes).\n * Negotiations that haven't received a state update within this time are considered stalled.\n */\nconst STALLED_NEGOTIATION_THRESHOLD_MS = 30 * 60 * 1000;\n\n/**\n * Dataspace Control Plane Service implementation.\n *\n * Handles contract negotiation (via PNP callbacks) and transfer process management.\n * Negotiation is fully callback-driven: negotiateAgreement() returns immediately with\n * a negotiationId, and the caller is notified via INegotiationCallback when complete.\n */\nexport class DataspaceControlPlaneService\n\timplements IDataspaceControlPlaneComponent, IDataspaceControlPlaneResolverComponent\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataspaceControlPlaneService>();\n\n\t/**\n\t * Hardcoded requester type for PNP registration.\n\t * PNP uses this to route callbacks to our PolicyRequester.\n\t * @internal\n\t */\n\tprivate static readonly _REQUESTER_TYPE = \"dataspace-control-plane-requester\";\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _loggingComponent?: ILoggingComponent;\n\n\t/**\n\t * Policy Administration Point component for Agreement lookup.\n\t * @internal\n\t */\n\tprivate readonly _policyAdministrationPointComponent: IPolicyAdministrationPointComponent;\n\n\t/**\n\t * Policy Negotiation Point component for contract negotiation.\n\t * Used to negotiate agreements with providers before creating transfer processes.\n\n\t * @internal\n\t */\n\tprivate readonly _policyNegotiationPointComponent: IPolicyNegotiationPointComponent;\n\n\t/**\n\t * Policy Negotiation Admin Point component for negotiation history.\n\t * Optional - if not configured, history queries will fail gracefully.\n\t * @internal\n\t */\n\tprivate readonly _policyNegotiationAdminPointComponent?: IPolicyNegotiationAdminPointComponent;\n\n\t/**\n\t * Federated Catalogue component for dataset validation.\n\t * Used to validate that Agreements reference valid catalog datasets.\n\t * @internal\n\t */\n\tprivate readonly _federatedCatalogueComponent: IFederatedCatalogueComponent;\n\n\t/**\n\t * Entity storage for Transfer Process entities.\n\t * Shared between Control Plane and Data Plane.\n\t * @internal\n\t */\n\tprivate readonly _transferProcessStorage: IEntityStorageConnector<TransferProcess>;\n\n\t/**\n\t * The trust component for token verification and generation.\n\t * @internal\n\t */\n\tprivate readonly _trustComponent: ITrustComponent;\n\n\t/**\n\t * Override trust generator type for token generation.\n\t * @internal\n\t */\n\tprivate readonly _overrideTrustGeneratorType?: string;\n\n\t/**\n\t * Data plane endpoint path (path only, not full URL).\n\t * Will be combined with public origin from hosting component.\n\t * If not configured, PULL transfers are not supported.\n\t * @internal\n\t */\n\tprivate readonly _dataPlanePath?: string;\n\n\t/**\n\t * Policy requester instance for handling negotiation callbacks.\n\t * @internal\n\t */\n\tprivate readonly _policyRequester: DataspaceControlPlanePolicyRequester;\n\n\t/**\n\t * Task scheduler for periodic stalled negotiation cleanup.\n\t * @internal\n\t */\n\tprivate readonly _taskScheduler?: ITaskSchedulerComponent;\n\n\t/**\n\t * Registered negotiation callbacks from upstream callers, keyed by registration key.\n\t * @internal\n\t */\n\tprivate readonly _negotiationCallbacks: Map<string, INegotiationCallback>;\n\n\t/**\n\t * Create a new instance of DataspaceControlPlaneService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IDataspaceControlPlaneServiceConstructorOptions) {\n\t\tthis._loggingComponent = ComponentFactory.getIfExists<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\n\t\t// Retrieve PAP component with default\n\t\tthis._policyAdministrationPointComponent =\n\t\t\tComponentFactory.get<IPolicyAdministrationPointComponent>(\n\t\t\t\toptions?.policyAdministrationPointComponentType ?? \"policy-administration-point\"\n\t\t\t);\n\n\t\t// Retrieve PNP component with default\n\t\tthis._policyNegotiationPointComponent = ComponentFactory.get<IPolicyNegotiationPointComponent>(\n\t\t\toptions?.policyNegotiationPointComponentType ?? \"policy-negotiation-point\"\n\t\t);\n\n\t\t// Retrieve PNAP component (optional) for negotiation history\n\t\tthis._policyNegotiationAdminPointComponent =\n\t\t\tComponentFactory.getIfExists<IPolicyNegotiationAdminPointComponent>(\n\t\t\t\toptions?.policyNegotiationAdminPointComponentType ?? \"policy-negotiation-admin-point\"\n\t\t\t);\n\n\t\t// Retrieve Federated Catalogue component with default\n\t\tthis._federatedCatalogueComponent = ComponentFactory.get<IFederatedCatalogueComponent>(\n\t\t\toptions?.federatedCatalogueComponentType ?? \"federated-catalogue\"\n\t\t);\n\n\t\tthis._transferProcessStorage = EntityStorageConnectorFactory.get<\n\t\t\tIEntityStorageConnector<TransferProcess>\n\t\t>(options?.transferProcessEntityStorageType ?? nameofKebabCase<TransferProcess>());\n\n\t\tthis._trustComponent = ComponentFactory.get<ITrustComponent>(\n\t\t\toptions?.trustComponentType ?? \"trust\"\n\t\t);\n\n\t\tthis._overrideTrustGeneratorType = options?.config?.overrideTrustGeneratorType;\n\n\t\tthis._dataPlanePath = Is.stringValue(options?.config?.dataPlanePath)\n\t\t\t? StringHelper.trimLeadingSlashes(options.config.dataPlanePath)\n\t\t\t: undefined;\n\n\t\tthis._taskScheduler = ComponentFactory.getIfExists<ITaskSchedulerComponent>(\n\t\t\toptions?.taskSchedulerComponentType ?? \"task-scheduler\"\n\t\t);\n\n\t\tthis._negotiationCallbacks = new Map();\n\n\t\tconst internalCallback: INegotiationCallback = {\n\t\t\tonStateChanged: async (negotiationId, state, data) => {\n\t\t\t\tfor (const [key, cb] of this._negotiationCallbacks.entries()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait cb.onStateChanged(negotiationId, state, data);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tmessage: \"negotiationCallbackError\",\n\t\t\t\t\t\t\tdata: { key, negotiationId, method: \"onStateChanged\", error }\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\tonCompleted: async (negotiationId, agreementId) => {\n\t\t\t\tfor (const [key, cb] of this._negotiationCallbacks.entries()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait cb.onCompleted(negotiationId, agreementId);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tmessage: \"negotiationCallbackError\",\n\t\t\t\t\t\t\tdata: { key, negotiationId, method: \"onCompleted\", error }\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\tonFailed: async (negotiationId, reason) => {\n\t\t\t\tfor (const [key, cb] of this._negotiationCallbacks.entries()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait cb.onFailed(negotiationId, reason);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tmessage: \"negotiationCallbackError\",\n\t\t\t\t\t\t\tdata: { key, negotiationId, method: \"onFailed\", error }\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\tthis._policyRequester = new DataspaceControlPlanePolicyRequester(\n\t\t\toptions?.loggingComponentType ?? \"logging\",\n\t\t\tinternalCallback\n\t\t);\n\n\t\tPolicyRequesterFactory.register(\n\t\t\tDataspaceControlPlaneService._REQUESTER_TYPE,\n\t\t\t() => this._policyRequester\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 DataspaceControlPlaneService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Register a callback to receive negotiation state change notifications.\n\t * Upstream modules (e.g. supply-chain) register their callback here.\n\t * @param key A unique key identifying this callback registration.\n\t * @param callback The callback interface to register.\n\t */\n\tpublic registerNegotiationCallback(key: string, callback: INegotiationCallback): void {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(key), key);\n\t\tthis._negotiationCallbacks.set(key, callback);\n\t}\n\n\t/**\n\t * Unregister a previously registered negotiation callback.\n\t * @param key The key used when registering the callback.\n\t */\n\tpublic unregisterNegotiationCallback(key: string): void {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(key), key);\n\t\tthis._negotiationCallbacks.delete(key);\n\t}\n\n\t/**\n\t * The service needs to be started when the application is initialized.\n\t * Populates the Federated Catalogue with datasets from registered apps\n\t * and starts the stalled negotiation cleanup task.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t */\n\tpublic async start(nodeLoggingComponentType?: string): Promise<void> {\n\t\tconst engine = EngineCoreFactory.getIfExists(\"engine\");\n\t\t// Skip if no engine exists OR if this is a clone instance\n\t\tif (Is.empty(engine) || engine.isClone()) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tts: Date.now(),\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"engineCloneStart\"\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tts: Date.now(),\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tmessage: \"populatingFederatedCatalogue\"\n\t\t});\n\n\t\t// Get all registered apps\n\t\tconst appNames = DataspaceAppFactory.names();\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tts: Date.now(),\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tmessage: \"discoveredApps\",\n\t\t\tdata: { count: appNames.length, apps: appNames }\n\t\t});\n\n\t\tlet registeredCount = 0;\n\t\tlet errorCount = 0;\n\n\t\t// Collect and register datasets from each app\n\t\tfor (const appName of appNames) {\n\t\t\ttry {\n\t\t\t\tconst app = DataspaceAppFactory.get<IDataspaceApp>(appName);\n\t\t\t\tconst datasets = await app.datasetsHandled();\n\n\t\t\t\tfor (const dataset of datasets) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Ensure publisher is set (required for Federated Catalogue)\n\t\t\t\t\t\tconst datasetWithPublisher = await this.ensurePublisher(dataset);\n\n\t\t\t\t\t\t// Register with Federated Catalogue\n\t\t\t\t\t\tawait this._federatedCatalogueComponent.set(\n\t\t\t\t\t\t\tdatasetWithPublisher as unknown as IDcatDataset\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tregisteredCount++;\n\n\t\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\t\tlevel: \"debug\",\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\tmessage: \"datasetRegistered\",\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tdatasetId: getJsonLdId(datasetWithPublisher) ?? \"\",\n\t\t\t\t\t\t\t\tappName\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\terrorCount++;\n\t\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\tmessage: \"datasetRegistrationFailed\",\n\t\t\t\t\t\t\terror: BaseError.fromError(error),\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tdatasetId: getJsonLdId(dataset) ?? \"\",\n\t\t\t\t\t\t\t\tappName\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\tmessage: \"appDatasetsRetrievalFailed\",\n\t\t\t\t\terror: BaseError.fromError(error),\n\t\t\t\t\tdata: { appName }\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tts: Date.now(),\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tmessage: \"federatedCataloguePopulated\",\n\t\t\tdata: {\n\t\t\t\tregisteredCount,\n\t\t\t\terrorCount,\n\t\t\t\ttotalApps: appNames.length\n\t\t\t}\n\t\t});\n\n\t\tif (this._taskScheduler) {\n\t\t\tawait this._taskScheduler.addTask(\n\t\t\t\t\"control-plane-negotiation-cleanup\",\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tnextTriggerTime: Date.now(),\n\t\t\t\t\t\tintervalMinutes: 5\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tasync () => {\n\t\t\t\t\tawait this.cleanupStalledNegotiations();\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Stop the service.\n\t * Removes the stalled negotiation cleanup task.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t */\n\tpublic async stop(nodeLoggingComponentType?: string): Promise<void> {\n\t\tif (this._taskScheduler) {\n\t\t\tawait this._taskScheduler.removeTask(\"control-plane-negotiation-cleanup\");\n\t\t}\n\t}\n\n\t// ----------------------------------------------------------------------------\n\t// CONSUMER SIDE OPERATIONS\n\t// ----------------------------------------------------------------------------\n\n\t/**\n\t * Request a Transfer Process.\n\t * Creates a new Transfer Process in REQUESTED state.\n\t * @param request Transfer request message (DSP compliant).\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Process (DSP compliant) with state REQUESTED, or TransferError if the operation fails.\n\t *\n\t * Role Performed: Provider\n\t * Called by: Consumer when it wants to request a new Transfer Process\n\t */\n\tpublic async requestTransfer(\n\t\trequest: IDataspaceProtocolTransferRequestMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferProcess | IDataspaceProtocolTransferError> {\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"requestTransfer\");\n\n\t\tconst validationFailures: IValidationFailure[] = [];\n\t\tconst isConformant = await DataspaceProtocolHelper.checkConformance(\n\t\t\tJsonLdHelper.toNodeObject(request),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\tif (!isConformant) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"invalidTransferRequest\",\n\t\t\t\tdata: { validationFailures }\n\t\t\t});\n\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"invalidTransferRequest\", {\n\t\t\t\tvalidationFailures\n\t\t\t});\n\t\t}\n\n\t\tconst providerPid = `urn:uuid:${RandomHelper.generateUuidV7()}`;\n\n\t\tlet datasetId: string;\n\t\tlet consumerIdentity: ObjectOrArray<string>;\n\t\tlet providerIdentity: ObjectOrArray<string>;\n\t\tlet policies: IDataspaceProtocolPolicy[] = [];\n\n\t\ttry {\n\t\t\tconst agreement = await this.lookupAgreement(request.agreementId);\n\n\t\t\tif (!agreement) {\n\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"agreementNotFound\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tagreementId: request.agreementId,\n\t\t\t\t\t\thint: \"Agreement must exist before transfer. Use contract negotiation to create agreement first.\"\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"agreementNotFound\",\n\t\t\t\t\trequest.agreementId,\n\t\t\t\t\t{\n\t\t\t\t\t\tagreementId: request.agreementId,\n\t\t\t\t\t\thint: \"Perform contract negotiation first to create an agreement\"\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst assigneeIdentity = OdrlPolicyHelper.extractAssigneeIdentity(agreement);\n\t\t\tconsumerIdentity = Is.array(assigneeIdentity) ? assigneeIdentity[0] : assigneeIdentity;\n\n\t\t\tconst assignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);\n\t\t\tproviderIdentity = Is.array(assignerIdentity) ? assignerIdentity[0] : assignerIdentity;\n\t\t\tdatasetId = this.extractDatasetId(agreement);\n\n\t\t\tawait this.validateCatalogDataset(datasetId, agreement);\n\n\t\t\tpolicies = [agreement];\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, { consumerPid: request.consumerPid, providerPid });\n\t\t}\n\n\t\tconst now = new Date();\n\n\t\tconst storageEntity: TransferProcess = {\n\t\t\tid: Converter.bytesToHex(RandomHelper.generate(32)),\n\t\t\tconsumerPid: request.consumerPid,\n\t\t\tproviderPid,\n\t\t\tstate: DataspaceProtocolTransferProcessStateType.REQUESTED,\n\t\t\tagreementId: request.agreementId,\n\t\t\tdatasetId,\n\t\t\tconsumerIdentity: ArrayHelper.fromObjectOrArray<string>(consumerIdentity)[0],\n\t\t\tproviderIdentity: ArrayHelper.fromObjectOrArray<string>(providerIdentity)[0],\n\t\t\t// offerId should reference Catalog Offer (via Agreement)\n\t\t\t// For now, use agreementId as reference (proper flow: Catalog → Negotiation → Agreement)\n\t\t\tofferId: request.agreementId,\n\t\t\tpolicies,\n\t\t\tcallbackAddress: request.callbackAddress,\n\t\t\tformat: request.format,\n\t\t\tdataAddress: request.dataAddress,\n\t\t\tdateCreated: now.toISOString(),\n\t\t\tdateModified: now.toISOString()\n\t\t};\n\n\t\tawait this._transferProcessStorage.set(storageEntity);\n\n\t\tconst entity: ITransferProcess = this.storageEntityToModel(storageEntity);\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"transferProcessInitiated\",\n\t\t\tdata: {\n\t\t\t\tconsumerPid: request.consumerPid,\n\t\t\t\tproviderPid,\n\t\t\t\tagreementId: request.agreementId\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\t\t\tconsumerPid: entity.consumerPid,\n\t\t\tproviderPid: entity.providerPid,\n\t\t\tstate: entity.state\n\t\t};\n\t}\n\n\t// ----------------------------------------------------------------------------\n\t// PROVIDER SIDE OPERATIONS\n\t// ----------------------------------------------------------------------------\n\n\t/**\n\t * Start a Transfer Process.\n\t * Transitions Transfer Process from REQUESTED to STARTED state or resumes from SUSPENDED state.\n\t * @param message Transfer start message (DSP compliant).\n\t * @param publicOrigin The public origin URL of this service.\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Start Message (DSP compliant) with dataAddress for PULL transfers, or TransferError if the operation fails.\n\t *\n\t * Role Performed: Provider / Consumer\n\t */\n\tpublic async startTransfer(\n\t\tmessage: IDataspaceProtocolTransferStartMessage,\n\t\tpublicOrigin: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferStartMessage | IDataspaceProtocolTransferError> {\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"startTransfer\");\n\n\t\tconst validationFailures: IValidationFailure[] = [];\n\t\tconst isConformant = await DataspaceProtocolHelper.checkConformance(\n\t\t\tJsonLdHelper.toNodeObject(message),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\tif (!isConformant) {\n\t\t\treturn transformToTransferError(\n\t\t\t\tnew GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"invalidTransferStartMessage\", {\n\t\t\t\t\tvalidationFailures\n\t\t\t\t}),\n\t\t\t\tmessage\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst { entity, role } = await this.lookupTransferByMessage(message);\n\n\t\t\tif (\n\t\t\t\tentity.state !== DataspaceProtocolTransferProcessStateType.REQUESTED &&\n\t\t\t\tentity.state !== DataspaceProtocolTransferProcessStateType.SUSPENDED\n\t\t\t) {\n\t\t\t\treturn transformToTransferError(\n\t\t\t\t\tnew GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"invalidStateForStart\", {\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tcurrentState: entity.state\n\t\t\t\t\t}),\n\t\t\t\t\tmessage\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tentity.state = DataspaceProtocolTransferProcessStateType.STARTED;\n\t\t\tentity.dateModified = new Date();\n\n\t\t\tawait this._transferProcessStorage.set(this.modelToStorageEntity(entity));\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transferProcessStarted\",\n\t\t\t\tdata: {\n\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\trole\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst response: IDataspaceProtocolTransferStartMessage = {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferStartMessage,\n\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\tproviderPid: entity.providerPid\n\t\t\t};\n\n\t\t\t// ============================================================================\n\t\t\t// PULL vs PUSH Transfer Mode Detection (DSP Protocol)\n\t\t\t// ============================================================================\n\t\t\t// The transfer mode is determined by whether the consumer provided a dataAddress\n\t\t\t// in the original TransferRequestMessage:\n\t\t\t//\n\t\t\t// PULL Mode (dataAddress NOT provided by consumer):\n\t\t\t// - Consumer requests data but doesn't specify where to receive it\n\t\t\t// - Provider generates access token and returns dataAddress in TransferStartMessage\n\t\t\t// - Consumer uses the returned endpoint + token to PULL data from provider\n\t\t\t// - Flow: Consumer → GET /entities?consumerPid=X (with Bearer token) → Provider\n\t\t\t//\n\t\t\t// PUSH Mode (dataAddress PROVIDED by consumer):\n\t\t\t// - Consumer specifies endpoint where they want data sent (e.g., webhook URL)\n\t\t\t// - Provider will PUSH data to the consumer's specified endpoint\n\t\t\t// - Flow: Provider → POST to consumer's dataAddress endpoint → Consumer\n\t\t\t//\n\t\t\t// See: https://eclipse-dataspace-protocol-base.github.io/DataspaceProtocol/2025-1-err1/#transfer-start-message\n\t\t\t// ============================================================================\n\n\t\t\tif (Is.empty(entity.dataAddress)) {\n\t\t\t\tif (!Is.stringValue(this._dataPlanePath)) {\n\t\t\t\t\treturn transformToTransferError(\n\t\t\t\t\t\tnew GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"pullTransfersNotSupported\", {\n\t\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\t\tproviderPid: entity.providerPid\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tmessage\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst accessToken = await this._trustComponent.generate(\n\t\t\t\t\tentity.consumerIdentity ?? entity.consumerPid,\n\t\t\t\t\tthis._overrideTrustGeneratorType,\n\t\t\t\t\t{\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tagreementId: entity.agreementId,\n\t\t\t\t\t\tdatasetId: entity.datasetId\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst tokenString = Converter.bytesToBase64(ObjectHelper.toBytes(accessToken));\n\t\t\t\tconst fullEndpoint = `${publicOrigin}/${this._dataPlanePath}`;\n\n\t\t\t\tresponse.dataAddress = {\n\t\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.DataAddress,\n\t\t\t\t\tendpointType: DataspaceProtocolEndpointType.HttpsQueryEndpoint,\n\t\t\t\t\tendpoint: fullEndpoint,\n\t\t\t\t\tendpointProperties: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.EndpointProperty,\n\t\t\t\t\t\t\tname: \"authorization\",\n\t\t\t\t\t\t\tvalue: tokenString\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.EndpointProperty,\n\t\t\t\t\t\t\tname: \"authType\",\n\t\t\t\t\t\t\tvalue: \"bearer\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t};\n\n\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"dataAccessTokenGenerated\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tendpoint: fullEndpoint,\n\t\t\t\t\t\ttransferMode: \"PULL\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// PUSH MODE: Provider will push data to consumer's specified endpoint\n\t\t\t\t// The consumer provided dataAddress in TransferRequestMessage, indicating\n\t\t\t\t// where they want data sent. Provider acknowledges and will push data there.\n\t\t\t\t//\n\t\t\t\t// TODO: PUSH transfer implementation (RFC-007 future work)\n\t\t\t\t// Implementation would need to:\n\t\t\t\t// 1. Generate provider's own trust token to authenticate when pushing to consumer\n\t\t\t\t// 2. Validate consumer's dataAddress endpoint is reachable\n\t\t\t\t// 3. Extract any consumer-provided authorization from endpointProperties\n\t\t\t\t// 4. Schedule background task to push data to consumer's endpoint\n\t\t\t\t// 5. POST data to entity.dataAddress.endpoint with provider's trust token\n\t\t\t\t// 6. Implement retry logic with exponential backoff\n\t\t\t\t// 7. Send TransferCompletionMessage when push completes successfully\n\t\t\t\t//\n\t\t\t\t// Trust flow for PUSH (mirror of PULL):\n\t\t\t\t// - PULL: Provider generates token → Consumer uses to authenticate when pulling\n\t\t\t\t// - PUSH: Provider generates token → Provider uses to authenticate when pushing\n\n\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"pushTransferModeNotImplemented\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tconsumerEndpoint: entity.dataAddress.endpoint,\n\t\t\t\t\t\ttransferMode: \"PUSH\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn response;\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, message);\n\t\t}\n\t}\n\n\t// ----------------------------------------------------------------------------\n\t// SHARED STATE MANAGEMENT OPERATIONS (Either Side)\n\t// ----------------------------------------------------------------------------\n\n\t/**\n\t * Complete a Transfer Process.\n\t * @param message Transfer completion message (DSP compliant).\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Process (DSP compliant) with state COMPLETED, or TransferError if the operation fails.\n\t */\n\tpublic async completeTransfer(\n\t\tmessage: IDataspaceProtocolTransferCompletionMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferProcess | IDataspaceProtocolTransferError> {\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"completeTransfer\");\n\n\t\tconst validationFailures: IValidationFailure[] = [];\n\t\tconst isConformant = await DataspaceProtocolHelper.checkConformance(\n\t\t\tJsonLdHelper.toNodeObject(message),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\tif (!isConformant) {\n\t\t\treturn transformToTransferError(\n\t\t\t\tnew GeneralError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"invalidTransferCompletionMessage\",\n\t\t\t\t\t{ validationFailures }\n\t\t\t\t),\n\t\t\t\tmessage\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst { entity, role } = await this.lookupTransferByMessage(message);\n\n\t\t\tif (entity.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\t\treturn transformToTransferError(\n\t\t\t\t\tnew GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"invalidStateForComplete\", {\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tcurrentState: entity.state\n\t\t\t\t\t}),\n\t\t\t\t\tmessage\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tentity.state = DataspaceProtocolTransferProcessStateType.COMPLETED;\n\t\t\tentity.dateModified = new Date();\n\n\t\t\tawait this._transferProcessStorage.set(this.modelToStorageEntity(entity));\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transferProcessCompleted\",\n\t\t\t\tdata: {\n\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\trole\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\tstate: entity.state\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, message);\n\t\t}\n\t}\n\n\t/**\n\t * Suspend a Transfer Process.\n\t * @param message Transfer suspension message (DSP compliant).\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Process (DSP compliant) with state SUSPENDED, or TransferError if the operation fails.\n\t */\n\tpublic async suspendTransfer(\n\t\tmessage: IDataspaceProtocolTransferSuspensionMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferProcess | IDataspaceProtocolTransferError> {\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"suspendTransfer\");\n\n\t\tconst validationFailures: IValidationFailure[] = [];\n\t\tconst isConformant = await DataspaceProtocolHelper.checkConformance(\n\t\t\tJsonLdHelper.toNodeObject(message),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\tif (!isConformant) {\n\t\t\treturn transformToTransferError(\n\t\t\t\tnew GeneralError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"invalidTransferSuspensionMessage\",\n\t\t\t\t\t{ validationFailures }\n\t\t\t\t),\n\t\t\t\tmessage\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst { entity, role } = await this.lookupTransferByMessage(message);\n\n\t\t\tif (entity.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\t\treturn transformToTransferError(\n\t\t\t\t\tnew GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"invalidStateForSuspend\", {\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tcurrentState: entity.state\n\t\t\t\t\t}),\n\t\t\t\t\tmessage\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tentity.state = DataspaceProtocolTransferProcessStateType.SUSPENDED;\n\t\t\tentity.dateModified = new Date();\n\n\t\t\tawait this._transferProcessStorage.set(this.modelToStorageEntity(entity));\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transferProcessSuspended\",\n\t\t\t\tdata: {\n\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\trole,\n\t\t\t\t\treason: message.reason\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\tstate: entity.state\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, message);\n\t\t}\n\t}\n\n\t/**\n\t * Terminate a Transfer Process.\n\t * @param message Transfer termination message (DSP compliant).\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Process (DSP compliant) with state TERMINATED, or TransferError if the operation fails.\n\t */\n\tpublic async terminateTransfer(\n\t\tmessage: IDataspaceProtocolTransferTerminationMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferProcess | IDataspaceProtocolTransferError> {\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"terminateTransfer\");\n\n\t\tconst validationFailures: IValidationFailure[] = [];\n\t\tconst isConformant = await DataspaceProtocolHelper.checkConformance(\n\t\t\tJsonLdHelper.toNodeObject(message),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\tif (!isConformant) {\n\t\t\treturn transformToTransferError(\n\t\t\t\tnew GeneralError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"invalidTransferTerminationMessage\",\n\t\t\t\t\t{ validationFailures }\n\t\t\t\t),\n\t\t\t\tmessage\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst { entity, role } = await this.lookupTransferByMessage(message);\n\n\t\t\tentity.state = DataspaceProtocolTransferProcessStateType.TERMINATED;\n\t\t\tentity.dateModified = new Date();\n\n\t\t\tawait this._transferProcessStorage.set(this.modelToStorageEntity(entity));\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transferProcessTerminated\",\n\t\t\t\tdata: {\n\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\trole,\n\t\t\t\t\treason: message.reason\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\tstate: entity.state\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, message);\n\t\t}\n\t}\n\n\t/**\n\t * Get Transfer Process state.\n\t * @param pid Process ID (consumerPid or providerPid).\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Process (DSP compliant) with current state, or TransferError if the operation fails.\n\t */\n\tpublic async getTransferProcess(\n\t\tpid: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferProcess | IDataspaceProtocolTransferError> {\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"getTransferProcess\");\n\n\t\ttry {\n\t\t\tconst { entity, role } = await this.lookupTransferByPid(pid);\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transferProcessQueried\",\n\t\t\t\tdata: {\n\t\t\t\t\tpid,\n\t\t\t\t\trole,\n\t\t\t\t\tstate: entity.state\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\tstate: entity.state\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, { consumerPid: pid, providerPid: pid });\n\t\t}\n\t}\n\n\t// ============================================================================\n\t// CONTRACT NEGOTIATION\n\t// ============================================================================\n\n\t/**\n\t * Negotiate a contract agreement with a provider.\n\t * Returns immediately with a negotiationId. The caller is notified\n\t * via the registered INegotiationCallback when the negotiation completes.\n\t *\n\t * @param offerId The offer ID from the provider's catalog.\n\t * @param providerEndpoint The provider's contract negotiation endpoint URL.\n\t * @param publicOrigin The public origin URL of this control plane (for callbacks).\n\t * @param trustPayload The trust payload for authentication.\n\t * @returns The negotiation ID. Use the registered callback for completion notification.\n\t */\n\tpublic async negotiateAgreement(\n\t\tofferId: string,\n\t\tproviderEndpoint: string,\n\t\tpublicOrigin: string,\n\t\ttrustPayload: unknown\n\t): Promise<{ negotiationId: string }> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(offerId), offerId);\n\t\tGuards.stringValue(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\tnameof(providerEndpoint),\n\t\t\tproviderEndpoint\n\t\t);\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(publicOrigin), publicOrigin);\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"startingContractNegotiation\",\n\t\t\tdata: { offerId, providerEndpoint, publicOrigin }\n\t\t});\n\n\t\tconst catalogResult = await this._federatedCatalogueComponent.get(offerId);\n\n\t\tif (isCatalogError(catalogResult)) {\n\t\t\tif (isCatalogErrorName(catalogResult, NotFoundError.CLASS_NAME)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"datasetNotFoundInCatalog\",\n\t\t\t\t\tofferId,\n\t\t\t\t\t{\n\t\t\t\t\t\tofferId,\n\t\t\t\t\t\tproviderEndpoint\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"catalogLookupFailedForNegotiation\",\n\t\t\t\t{\n\t\t\t\t\tofferId,\n\t\t\t\t\tproviderEndpoint,\n\t\t\t\t\terrorCode: catalogResult.code\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tconst rawOffers = this.getCatalogDatasetPolicies(catalogResult);\n\n\t\tif (!Is.arrayValue(rawOffers)) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"datasetHasNoOffers\", {\n\t\t\t\tofferId,\n\t\t\t\tdatasetId: getJsonLdId(catalogResult) ?? \"\"\n\t\t\t});\n\t\t}\n\n\t\tconst catalogOffers = rawOffers.filter(offer => Is.object<IDataspaceProtocolPolicy>(offer));\n\n\t\tif (!Is.arrayValue(catalogOffers)) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"datasetHasNoValidOffers\", {\n\t\t\t\tofferId,\n\t\t\t\tdatasetId: getJsonLdId(catalogResult) ?? \"\"\n\t\t\t});\n\t\t}\n\n\t\tconst matchingOffer = catalogOffers.find((offer: IDataspaceProtocolPolicy) => {\n\t\t\tconst offerUid = OdrlPolicyHelper.getUid(offer);\n\t\t\treturn offerUid === offerId;\n\t\t});\n\n\t\tif (!matchingOffer) {\n\t\t\tconst availableOffers = catalogOffers\n\t\t\t\t.map((o: IDataspaceProtocolPolicy) => OdrlPolicyHelper.getUid(o) ?? \"unknown\")\n\t\t\t\t.join(\", \");\n\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"offerNotFoundInDataset\",\n\t\t\t\tofferId,\n\t\t\t\t{\n\t\t\t\t\tofferId,\n\t\t\t\t\tdatasetId: getJsonLdId(catalogResult) ?? \"\",\n\t\t\t\t\tavailableOffers\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"offerFoundInCatalog\",\n\t\t\tdata: {\n\t\t\t\tofferId,\n\t\t\t\tdatasetId: getJsonLdId(catalogResult) ?? \"\",\n\t\t\t\tofferType: getJsonLdType(matchingOffer)\n\t\t\t}\n\t\t});\n\n\t\tconst negotiationId = await this._policyNegotiationPointComponent.sendRequestToProvider(\n\t\t\tproviderEndpoint,\n\t\t\tDataspaceControlPlaneService._REQUESTER_TYPE,\n\t\t\tofferId,\n\t\t\tpublicOrigin\n\t\t);\n\n\t\tif (!negotiationId) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"negotiationInitiationFailed\",\n\t\t\t\t{\n\t\t\t\t\tofferId,\n\t\t\t\t\tproviderEndpoint\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tthis._policyRequester.trackNegotiation(negotiationId);\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"negotiationInitiated\",\n\t\t\tdata: { negotiationId, offerId }\n\t\t});\n\n\t\treturn { negotiationId };\n\t}\n\n\t/**\n\t * Get the current state of a contract negotiation.\n\t * @param negotiationId The unique identifier of the negotiation.\n\t * @param trustPayload The trust payload for authentication.\n\t * @returns Current state of the negotiation.\n\t */\n\tpublic async getNegotiation(\n\t\tnegotiationId: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiation | IDataspaceProtocolContractNegotiationError> {\n\t\tGuards.stringValue(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\tnameof(negotiationId),\n\t\t\tnegotiationId\n\t\t);\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"getNegotiation\",\n\t\t\tdata: { negotiationId }\n\t\t});\n\n\t\tconst result = await this._policyNegotiationPointComponent.getNegotiation(\n\t\t\tnegotiationId,\n\t\t\ttrustPayload\n\t\t);\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"negotiationStateRetrieved\",\n\t\t\tdata: {\n\t\t\t\tnegotiationId,\n\t\t\t\ttype: getJsonLdType(result),\n\t\t\t\tstate: (result as IDataspaceProtocolContractNegotiation).state\n\t\t\t}\n\t\t});\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get negotiation history.\n\t * @param state Optional filter by negotiation state.\n\t * @param cursor Optional pagination cursor.\n\t * @param trustPayload Trust payload for authentication.\n\t * @returns List of negotiation history entries with pagination.\n\t */\n\tpublic async getNegotiationHistory(\n\t\tstate: string | undefined,\n\t\tcursor: string | undefined,\n\t\ttrustPayload: unknown\n\t): Promise<{\n\t\tnegotiations: {\n\t\t\tnegotiation:\n\t\t\t\t| IDataspaceProtocolContractNegotiation\n\t\t\t\t| IDataspaceProtocolContractNegotiationError;\n\t\t\tcreatedAt: string;\n\t\t\tofferId?: string;\n\t\t\tagreementId?: string;\n\t\t}[];\n\t\tcursor?: string;\n\t\tcount: number;\n\t}> {\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"getNegotiationHistory\",\n\t\t\tdata: { state, cursor }\n\t\t});\n\n\t\tif (!this._policyNegotiationAdminPointComponent) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"pnapNotConfigured\", {\n\t\t\t\tmessage:\n\t\t\t\t\t\"Policy Negotiation Admin Point not configured. \" +\n\t\t\t\t\t\"Set policyNegotiationAdminPointComponentType in constructor options.\"\n\t\t\t});\n\t\t}\n\n\t\tconst { items: pnapNegotiations, cursor: nextCursor } =\n\t\t\tawait this._policyNegotiationAdminPointComponent.query(\n\t\t\t\tstate as DataspaceProtocolContractNegotiationStateType | undefined,\n\t\t\t\tcursor\n\t\t\t);\n\n\t\tconst negotiations = pnapNegotiations.map(pnapNeg => {\n\t\t\tconst dspNegotiation: IDataspaceProtocolContractNegotiation = {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolContractNegotiationTypes.ContractNegotiation,\n\t\t\t\tconsumerPid: pnapNeg.id,\n\t\t\t\tproviderPid: pnapNeg.correlationId,\n\t\t\t\tstate: pnapNeg.state\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tnegotiation: dspNegotiation,\n\t\t\t\tcreatedAt: pnapNeg.dateCreated,\n\t\t\t\tofferId: OdrlPolicyHelper.getUid(pnapNeg.offer),\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(pnapNeg.agreement)\n\t\t\t};\n\t\t});\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"negotiationHistoryRetrieved\",\n\t\t\tdata: {\n\t\t\t\tcount: negotiations.length,\n\t\t\t\tstate,\n\t\t\t\thasCursor: Boolean(nextCursor)\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tnegotiations,\n\t\t\tcursor: nextCursor,\n\t\t\tcount: negotiations.length\n\t\t};\n\t}\n\n\t// ============================================================================\n\t// RESOLVER METHODS - IDataspaceControlPlaneResolverComponent\n\t// ============================================================================\n\n\t/**\n\t * Resolve consumerPid to Transfer Context.\n\t * @param consumerPid Consumer Process ID.\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Context with Agreement, datasetId, and Transfer Process metadata.\n\t */\n\tpublic async resolveConsumerPid(\n\t\tconsumerPid: string,\n\t\ttrustPayload: unknown\n\t): Promise<ITransferContext> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"resolveConsumerPid\");\n\n\t\tconst storageEntity = await this._transferProcessStorage.get(consumerPid);\n\n\t\tif (!storageEntity) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"transferProcessNotFound\",\n\t\t\t\tundefined,\n\t\t\t\t{ consumerPid }\n\t\t\t);\n\t\t}\n\n\t\tconst entity = this.storageEntityToModel(storageEntity);\n\n\t\tif (entity.state === DataspaceProtocolTransferProcessStateType.TERMINATED) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"transferProcessTerminated\", {\n\t\t\t\tconsumerPid\n\t\t\t});\n\t\t}\n\n\t\tconst agreement = await this.lookupAgreement(entity.agreementId);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst currentOrgId = contextIds?.[ContextIdKeys.Organization];\n\n\t\tif (!currentOrgId) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"organizationContextMissing\",\n\t\t\t\t{\n\t\t\t\t\tconsumerPid\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tconst assignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);\n\t\tconst assignerId = Is.array(assignerIdentity) ? assignerIdentity[0] : assignerIdentity;\n\n\t\tif (assignerId !== currentOrgId) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"agreementAssignerMismatch\",\n\t\t\t\t{\n\t\t\t\t\tconsumerPid,\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\t\texpectedOrgId: currentOrgId,\n\t\t\t\t\tactualAssigner: assignerId\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"resolvedConsumerPid\",\n\t\t\tdata: {\n\t\t\t\tconsumerPid,\n\t\t\t\tdatasetId: entity.datasetId,\n\t\t\t\tstate: entity.state,\n\t\t\t\tconsumerIdentity: entity.consumerIdentity,\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\torganizationId: currentOrgId\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tconsumerPid: entity.consumerPid,\n\t\t\tproviderPid: entity.providerPid,\n\t\t\tagreement,\n\t\t\tdatasetId: entity.datasetId,\n\t\t\tofferId: entity.offerId,\n\t\t\tstate: entity.state,\n\t\t\tconsumerIdentity: entity.consumerIdentity,\n\t\t\tproviderIdentity: entity.providerIdentity,\n\t\t\tdataAddress: entity.dataAddress\n\t\t};\n\t}\n\n\t/**\n\t * Resolve providerPid to Transfer Context.\n\t * @param providerPid Provider Process ID.\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Context with Agreement, datasetId, and Transfer Process metadata.\n\t */\n\tpublic async resolveProviderPid(\n\t\tproviderPid: string,\n\t\ttrustPayload: unknown\n\t): Promise<ITransferContext> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(providerPid), providerPid);\n\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"resolveProviderPid\");\n\n\t\tconst { entity } = await this.lookupTransferByPid(providerPid);\n\n\t\tif (entity.state === DataspaceProtocolTransferProcessStateType.TERMINATED) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"transferProcessTerminatedProvider\",\n\t\t\t\t{\n\t\t\t\t\tproviderPid\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tconst agreement = await this.lookupAgreement(entity.agreementId);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst currentOrgId = contextIds?.[ContextIdKeys.Organization];\n\n\t\tif (!currentOrgId) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"organizationContextMissingProvider\",\n\t\t\t\t{\n\t\t\t\t\tproviderPid\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t// Extract assigner UID (can be string, array, or IOdrlParty object)\n\n\t\tconst assignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);\n\t\tconst assignerId = Is.array(assignerIdentity) ? assignerIdentity[0] : assignerIdentity;\n\n\t\tif (assignerId !== currentOrgId) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"agreementAssignerMismatchProvider\",\n\t\t\t\t{\n\t\t\t\t\tproviderPid,\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\t\texpectedOrgId: currentOrgId,\n\t\t\t\t\tactualAssigner: assignerId\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t// Validate that Agreement assignee matches expected consumer identity\n\t\t// This ensures we're pushing to the correct consumer\n\t\t// If assignee is undefined but consumerIdentity has a value, this is also a mismatch\n\t\tconst assigneeIdentity = OdrlPolicyHelper.extractAssigneeIdentity(agreement);\n\t\tconst assigneeId = Is.array(assigneeIdentity) ? assigneeIdentity[0] : assigneeIdentity;\n\n\t\tif (assigneeId !== entity.consumerIdentity) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"agreementAssigneeMismatch\",\n\t\t\t\t{\n\t\t\t\t\tproviderPid,\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\t\texpectedConsumerIdentity: entity.consumerIdentity,\n\t\t\t\t\tactualAssignee: assigneeId\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"resolvedProviderPid\",\n\t\t\tdata: {\n\t\t\t\tproviderPid,\n\t\t\t\tdatasetId: entity.datasetId,\n\t\t\t\tstate: entity.state,\n\t\t\t\tconsumerIdentity: entity.consumerIdentity,\n\t\t\t\tproviderIdentity: entity.providerIdentity,\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\torganizationId: currentOrgId\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tconsumerPid: entity.consumerPid,\n\t\t\tproviderPid: entity.providerPid,\n\t\t\tagreement,\n\t\t\tdatasetId: entity.datasetId,\n\t\t\tofferId: entity.offerId,\n\t\t\tstate: entity.state,\n\t\t\tconsumerIdentity: entity.consumerIdentity,\n\t\t\tproviderIdentity: entity.providerIdentity,\n\t\t\tdataAddress: entity.dataAddress\n\t\t};\n\t}\n\n\t// ============================================================================\n\t// PRIVATE HELPER METHODS\n\t// ============================================================================\n\n\t/**\n\t * Cleanup stalled negotiations.\n\t * Called periodically by the task scheduler.\n\t * @internal\n\t */\n\tprivate async cleanupStalledNegotiations(): Promise<void> {\n\t\tconst now = Date.now();\n\t\tconst stalled: string[] = [];\n\n\t\tfor (const [negotiationId, state] of this._policyRequester.getActiveNegotiations()) {\n\t\t\tif (now - state.updatedAt > STALLED_NEGOTIATION_THRESHOLD_MS) {\n\t\t\t\tstalled.push(negotiationId);\n\t\t\t}\n\t\t}\n\n\t\tfor (const negotiationId of stalled) {\n\t\t\tthis._policyRequester.removeNegotiation(negotiationId);\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"stalledNegotiationCleanedUp\",\n\t\t\t\tdata: { negotiationId }\n\t\t\t});\n\n\t\t\tfor (const [key, cb] of this._negotiationCallbacks.entries()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait cb.onFailed(negotiationId, \"negotiationStalled\");\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"negotiationCallbackError\",\n\t\t\t\t\t\tdata: { key, negotiationId, method: \"onFailed\", error }\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (stalled.length > 0) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"stalledNegotiationsCleanupComplete\",\n\t\t\t\tdata: { cleanedUp: stalled.length }\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Convert a storage entity to model.\n\t * @param storageEntity The entity from storage.\n\t * @returns The model representation.\n\t * @internal\n\t */\n\tprivate storageEntityToModel(storageEntity: TransferProcess): ITransferProcess {\n\t\treturn {\n\t\t\tid: storageEntity.id,\n\t\t\tconsumerPid: storageEntity.consumerPid,\n\t\t\tproviderPid: storageEntity.providerPid,\n\t\t\tstate: storageEntity.state,\n\t\t\tagreementId: storageEntity.agreementId,\n\t\t\tdatasetId: storageEntity.datasetId,\n\t\t\tofferId: storageEntity.offerId,\n\t\t\tconsumerIdentity: storageEntity.consumerIdentity,\n\t\t\tproviderIdentity: storageEntity.providerIdentity,\n\t\t\tformat: storageEntity.format,\n\t\t\tcallbackAddress: storageEntity.callbackAddress,\n\t\t\tdateCreated: new Date(storageEntity.dateCreated),\n\t\t\tdateModified: new Date(storageEntity.dateModified),\n\t\t\tpolicies: storageEntity.policies,\n\t\t\tdataAddress: storageEntity.dataAddress\n\t\t};\n\t}\n\n\t/**\n\t * Convert a model to storage entity.\n\t * @param entity The model representation.\n\t * @returns The entity for storage.\n\t * @internal\n\t */\n\tprivate modelToStorageEntity(entity: ITransferProcess): TransferProcess {\n\t\treturn {\n\t\t\tid: entity.id,\n\t\t\tconsumerPid: entity.consumerPid,\n\t\t\tproviderPid: entity.providerPid,\n\t\t\tstate: entity.state,\n\t\t\tagreementId: entity.agreementId,\n\t\t\tdatasetId: entity.datasetId,\n\t\t\tofferId: entity.offerId,\n\t\t\tconsumerIdentity: entity.consumerIdentity,\n\t\t\tproviderIdentity: entity.providerIdentity,\n\t\t\tformat: entity.format,\n\t\t\tcallbackAddress: entity.callbackAddress,\n\t\t\tdateCreated: entity.dateCreated.toISOString(),\n\t\t\tdateModified: entity.dateModified.toISOString(),\n\t\t\tpolicies: entity.policies,\n\t\t\tdataAddress: entity.dataAddress\n\t\t};\n\t}\n\n\t/**\n\t * Look up Agreement from PAP.\n\t * @param agreementId Agreement ID.\n\t * @returns Agreement.\n\t * @internal\n\t */\n\tprivate async lookupAgreement(agreementId: string): Promise<IDataspaceProtocolAgreement> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(agreementId), agreementId);\n\n\t\tlet agreement;\n\t\ttry {\n\t\t\tagreement = await this._policyAdministrationPointComponent.getAgreement(agreementId);\n\t\t} catch (error) {\n\t\t\tif (BaseError.isErrorName(error, NotFoundError.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"agreementLookupFailed\",\n\t\t\t\t{ agreementId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\n\t\treturn agreement;\n\t}\n\n\t/**\n\t * Extract dataset ID from Agreement target.\n\t * @param agreement Agreement.\n\t * @returns Dataset ID.\n\t * @internal\n\t */\n\tprivate extractDatasetId(agreement: IDataspaceProtocolAgreement): string {\n\t\tif (Is.empty(agreement.target)) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"agreementMissingTarget\", {\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement)\n\t\t\t});\n\t\t}\n\n\t\tconst targetIds = OdrlPolicyHelper.getTargets(agreement);\n\n\t\tif (targetIds.length === 0) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"agreementTargetMissingUid\", {\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement)\n\t\t\t});\n\t\t}\n\n\t\t// Validate single target, multiple targets are not currently supported\n\t\tif (targetIds.length > 1) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"agreementMultipleTargetsNotSupported\",\n\t\t\t\t{\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\t\ttargetCount: targetIds.length\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn targetIds[0];\n\t}\n\n\t/**\n\t * Validate that the dataset exists in the Federated Catalogue.\n\t * @param datasetId Dataset identifier extracted from Agreement.\n\t * @param agreement The Agreement being validated.\n\t * @internal\n\t */\n\tprivate async validateCatalogDataset(\n\t\tdatasetId: string,\n\t\tagreement: IDataspaceProtocolAgreement\n\t): Promise<void> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(datasetId), datasetId);\n\t\tGuards.object<IDataspaceProtocolAgreement>(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\n\t\t// Lookup dataset in catalog\n\t\tconst catalogResult = await this._federatedCatalogueComponent.get(datasetId);\n\n\t\tif (isCatalogError(catalogResult)) {\n\t\t\tif (isCatalogErrorName(catalogResult, NotFoundError.CLASS_NAME)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"datasetNotInCatalog\",\n\t\t\t\t\tdatasetId,\n\t\t\t\t\t{\n\t\t\t\t\t\tdatasetId,\n\t\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement)\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"catalogLookupFailed\", {\n\t\t\t\tdatasetId,\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\",\n\t\t\t\terrorCode: catalogResult.code\n\t\t\t});\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"catalogDatasetFound\",\n\t\t\tdata: {\n\t\t\t\tdatasetId,\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\",\n\t\t\t\tdatasetTitle: catalogResult[\"dcterms:title\"]\n\t\t\t}\n\t\t});\n\n\t\tawait this.validateAgreementMatchesOffer(agreement, catalogResult);\n\t}\n\n\t/**\n\t * Extract PID from DSP message and lookup Transfer Process with role detection.\n\t * @param message DSP protocol message with consumerPid and/or providerPid fields.\n\t * @returns Transfer Process entity and our role in this transfer.\n\t * @internal\n\t */\n\tprivate async lookupTransferByMessage(message: {\n\t\tconsumerPid?: string;\n\t\tproviderPid?: string;\n\t}): Promise<{\n\t\tentity: ITransferProcess;\n\t\trole: TransferProcessRole;\n\t}> {\n\t\tconst pid = message.consumerPid ?? message.providerPid;\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, \"pid\", pid);\n\n\t\treturn this.lookupTransferByPid(pid);\n\t}\n\n\t/**\n\t * Lookup Transfer Process by PID and determine our role.\n\t * @param pid Either consumerPid or providerPid.\n\t * @returns Transfer Process entity and our role in this transfer.\n\t * @internal\n\t */\n\tprivate async lookupTransferByPid(pid: string): Promise<{\n\t\tentity: ITransferProcess;\n\t\trole: TransferProcessRole;\n\t}> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(pid), pid);\n\n\t\t// Check if pid is a consumerPid (primary key lookup)\n\t\tconst storageEntity = await this._transferProcessStorage.get(pid);\n\n\t\tif (storageEntity) {\n\t\t\treturn {\n\t\t\t\tentity: this.storageEntityToModel(storageEntity),\n\t\t\t\trole: TransferProcessRole.Consumer\n\t\t\t};\n\t\t}\n\n\t\t// Check if pid is a providerPid (secondary key lookup)\n\t\tconst providerPidEntity = await this._transferProcessStorage.get(pid, \"providerPid\");\n\t\tif (providerPidEntity) {\n\t\t\treturn {\n\t\t\t\tentity: this.storageEntityToModel(providerPidEntity),\n\t\t\t\trole: TransferProcessRole.Provider\n\t\t\t};\n\t\t}\n\n\t\tthrow new NotFoundError(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\"transferProcessNotFound\",\n\t\t\tpid,\n\t\t\t{\n\t\t\t\tpid\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Get raw policy entries from a catalog dataset.\n\t * @param catalogDataset Catalog dataset.\n\t * @returns Raw policy entries.\n\t * @internal\n\t */\n\tprivate getCatalogDatasetPolicies(\n\t\tcatalogDataset: IDcatDataset | IDataspaceProtocolDataset\n\t): JsonLdObjectWithNoContext<IDataspaceProtocolPolicy>[] {\n\t\t// Support both \"odrl:hasPolicy\" and \"hasPolicy\" to accommodate different catalog implementations\n\t\tif (Is.object<IDcatDataset>(catalogDataset) && !Is.empty(catalogDataset[\"odrl:hasPolicy\"])) {\n\t\t\tconst items = ArrayHelper.fromObjectOrArray(catalogDataset[\"odrl:hasPolicy\"]) ?? [];\n\t\t\treturn items.map(item => ({\n\t\t\t\t...item,\n\t\t\t\t\"@id\": OdrlPolicyHelper.getUid(item) ?? \"\"\n\t\t\t}));\n\t\t}\n\n\t\tif (\n\t\t\tIs.object<IDataspaceProtocolDataset>(catalogDataset) &&\n\t\t\t!Is.empty(catalogDataset.hasPolicy)\n\t\t) {\n\t\t\treturn ArrayHelper.fromObjectOrArray(catalogDataset.hasPolicy) ?? [];\n\t\t}\n\n\t\treturn [];\n\t}\n\n\t/**\n\t * Validate that the Agreement policies match at least one Catalog Offer.\n\t * @param agreement Agreement to validate.\n\t * @param catalogDataset Catalog dataset containing Offers.\n\t * @internal\n\t */\n\tprivate async validateAgreementMatchesOffer(\n\t\tagreement: IDataspaceProtocolAgreement,\n\t\tcatalogDataset: IDcatDataset\n\t): Promise<void> {\n\t\tGuards.object<IDataspaceProtocolAgreement>(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\t\tGuards.object<IDcatDataset>(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\tnameof(catalogDataset),\n\t\t\tcatalogDataset\n\t\t);\n\n\t\tconst rawOffers = this.getCatalogDatasetPolicies(catalogDataset);\n\n\t\tif (!Is.arrayValue(rawOffers)) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"catalogDatasetHasNoOffers\",\n\t\t\t\tdata: {\n\t\t\t\t\tdatasetId: getJsonLdId(catalogDataset) ?? \"\",\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst catalogOffers = rawOffers.filter(offer => Is.object<IDataspaceProtocolPolicy>(offer));\n\n\t\tif (!Is.arrayValue(catalogOffers)) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"catalogDatasetHasNoOffers\",\n\t\t\t\tdata: {\n\t\t\t\t\tdatasetId: getJsonLdId(catalogDataset) ?? \"\",\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst matchingOffer = catalogOffers.find(\n\t\t\t(offer: IDataspaceProtocolPolicy) =>\n\t\t\t\tOdrlPolicyHelper.getUid(offer) === OdrlPolicyHelper.getUid(agreement) ||\n\t\t\t\tthis.isPolicyDerivedFrom(agreement, offer)\n\t\t);\n\n\t\tif (!matchingOffer) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"agreementNotMatchingOffer\", {\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\",\n\t\t\t\tdatasetId: getJsonLdId(catalogDataset) ?? \"\",\n\t\t\t\tavailableOffers: catalogOffers\n\t\t\t\t\t.map((o: IDataspaceProtocolPolicy) => OdrlPolicyHelper.getUid(o) ?? \"unknown\")\n\t\t\t\t\t.join(\", \")\n\t\t\t});\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"agreementMatchedOffer\",\n\t\t\tdata: {\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\",\n\t\t\t\tofferId: OdrlPolicyHelper.getUid(matchingOffer) ?? \"\",\n\t\t\t\tdatasetId: getJsonLdId(catalogDataset) ?? \"\"\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Check if an Agreement is derived from an Offer.\n\t * @param agreement Agreement to check.\n\t * @param offer Offer to compare against.\n\t * @returns True if Agreement appears derived from Offer.\n\t * @internal\n\t */\n\tprivate isPolicyDerivedFrom(\n\t\tagreement: IDataspaceProtocolAgreement,\n\t\toffer: IDataspaceProtocolPolicy\n\t): boolean {\n\t\tconst agreementTargets = OdrlPolicyHelper.getTargets(agreement);\n\t\tconst offerTargets = OdrlPolicyHelper.getTargets(offer);\n\n\t\tif (\n\t\t\tagreementTargets.length === 0 ||\n\t\t\tofferTargets.length === 0 ||\n\t\t\t!agreementTargets.some((agreementTarget: string) => offerTargets.includes(agreementTarget))\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst agreementAssignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);\n\t\tconst offerAssignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(offer);\n\n\t\tconst agreementAssigner = ArrayHelper.fromObjectOrArray(agreementAssignerIdentity);\n\t\tconst offerAssigner = ArrayHelper.fromObjectOrArray(offerAssignerIdentity);\n\n\t\tif (!agreementAssigner.some(assigner => offerAssigner.includes(assigner))) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!Is.array(agreement.permission) || !Is.array(offer.permission)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Ensure the dataset has a publisher set.\n\t * @param dataset The dataset.\n\t * @returns The dataset with publisher set.\n\t * @internal\n\t */\n\tprivate async ensurePublisher(\n\t\tdataset: IDataspaceProtocolDataset\n\t): Promise<IDataspaceProtocolDataset> {\n\t\tif (dataset[\"dcterms:publisher\"]) {\n\t\t\treturn dataset;\n\t\t}\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst orgId = contextIds?.[ContextIdKeys.Organization];\n\n\t\tif (orgId) {\n\t\t\treturn {\n\t\t\t\t...dataset,\n\t\t\t\t\"dcterms:publisher\": orgId\n\t\t\t};\n\t\t}\n\n\t\treturn dataset;\n\t}\n}\n"]}
1
+ {"version":3,"file":"dataspaceControlPlaneService.js","sourceRoot":"","sources":["../../src/dataspaceControlPla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MAAM,qBAAqB,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAE9E,MAAM,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;QACnF,MAAM,aAAa,GAAG,WAAW,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;QAE3E,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YAC3E,OAAO,KAAK,CAAC;QACd,CAAC;QAED,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;YACpE,OAAO,KAAK,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,eAAe,CAC5B,OAAkC;QAElC,IAAI,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAClC,OAAO,OAAO,CAAC;QAChB,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QAEvD,IAAI,KAAK,EAAE,CAAC;YACX,OAAO;gBACN,GAAG,OAAO;gBACV,mBAAmB,EAAE,KAAK;aAC1B,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ITaskSchedulerComponent } from \"@twin.org/background-task-models\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tArrayHelper,\n\tBaseError,\n\tComponentFactory,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tRandomHelper,\n\tStringHelper,\n\tUnauthorizedError,\n\ttype IValidationFailure\n} from \"@twin.org/core\";\nimport { JsonLdHelper, type JsonLdObjectWithNoContext } from \"@twin.org/data-json-ld\";\nimport {\n\tDataspaceAppFactory,\n\tTransferProcessRole,\n\ttype IDataspaceApp,\n\ttype IDataspaceControlPlaneComponent,\n\ttype IDataspaceControlPlaneResolverComponent,\n\ttype INegotiationCallback,\n\ttype ITransferContext,\n\ttype ITransferProcess,\n\ttype TransferProcess\n} from \"@twin.org/dataspace-models\";\nimport { EngineCoreFactory } from \"@twin.org/engine-models\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IFederatedCatalogueComponent } from \"@twin.org/federated-catalogue-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport {\n\tOdrlPolicyHelper,\n\tPolicyRequesterFactory,\n\ttype IPolicyAdministrationPointComponent,\n\ttype IPolicyNegotiationAdminPointComponent,\n\ttype IPolicyNegotiationPointComponent\n} from \"@twin.org/rights-management-models\";\nimport {\n\tDataspaceProtocolContexts,\n\tDataspaceProtocolContractNegotiationTypes,\n\tDataspaceProtocolEndpointType,\n\tDataspaceProtocolHelper,\n\tDataspaceProtocolTransferProcessStateType,\n\tDataspaceProtocolTransferProcessTypes,\n\ttype DataspaceProtocolContractNegotiationStateType,\n\ttype IDataspaceProtocolAgreement,\n\ttype IDataspaceProtocolContractNegotiation,\n\ttype IDataspaceProtocolContractNegotiationError,\n\ttype IDataspaceProtocolDataset,\n\ttype IDataspaceProtocolPolicy,\n\ttype IDataspaceProtocolTransferCompletionMessage,\n\ttype IDataspaceProtocolTransferError,\n\ttype IDataspaceProtocolTransferProcess,\n\ttype IDataspaceProtocolTransferRequestMessage,\n\ttype IDataspaceProtocolTransferStartMessage,\n\ttype IDataspaceProtocolTransferSuspensionMessage,\n\ttype IDataspaceProtocolTransferTerminationMessage\n} from \"@twin.org/standards-dataspace-protocol\";\nimport type { IDcatDataset } from \"@twin.org/standards-w3c-dcat\";\nimport { TrustHelper, type ITrustComponent } from \"@twin.org/trust-models\";\nimport { DataspaceControlPlanePolicyRequester } from \"./dataspaceControlPlanePolicyRequester.js\";\nimport type { IDataspaceControlPlaneServiceConstructorOptions } from \"./models/IDataspaceControlPlaneServiceConstructorOptions.js\";\nimport { getJsonLdId, getJsonLdType } from \"./utils/dataHelpers.js\";\nimport {\n\tisCatalogError,\n\tisCatalogErrorName,\n\ttransformToTransferError\n} from \"./utils/transferErrorUtils.js\";\n\n/**\n * Stalled negotiation threshold in milliseconds (30 minutes).\n * Negotiations that haven't received a state update within this time are considered stalled.\n */\nconst STALLED_NEGOTIATION_THRESHOLD_MS = 30 * 60 * 1000;\n\n/**\n * Dataspace Control Plane Service implementation.\n *\n * Handles contract negotiation (via PNP callbacks) and transfer process management.\n * Negotiation is fully callback-driven: negotiateAgreement() returns immediately with\n * a negotiationId, and the caller is notified via INegotiationCallback when complete.\n */\nexport class DataspaceControlPlaneService\n\timplements IDataspaceControlPlaneComponent, IDataspaceControlPlaneResolverComponent\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataspaceControlPlaneService>();\n\n\t/**\n\t * Hardcoded requester type for PNP registration.\n\t * PNP uses this to route callbacks to our PolicyRequester.\n\t * @internal\n\t */\n\tprivate static readonly _REQUESTER_TYPE = \"dataspace-control-plane-requester\";\n\n\t/**\n\t * The logging component.\n\t * @internal\n\t */\n\tprivate readonly _loggingComponent?: ILoggingComponent;\n\n\t/**\n\t * Policy Administration Point component for Agreement lookup.\n\t * @internal\n\t */\n\tprivate readonly _policyAdministrationPointComponent: IPolicyAdministrationPointComponent;\n\n\t/**\n\t * Policy Negotiation Point component for contract negotiation.\n\t * Used to negotiate agreements with providers before creating transfer processes.\n\n\t * @internal\n\t */\n\tprivate readonly _policyNegotiationPointComponent: IPolicyNegotiationPointComponent;\n\n\t/**\n\t * Policy Negotiation Admin Point component for negotiation history.\n\t * Optional - if not configured, history queries will fail gracefully.\n\t * @internal\n\t */\n\tprivate readonly _policyNegotiationAdminPointComponent?: IPolicyNegotiationAdminPointComponent;\n\n\t/**\n\t * Federated Catalogue component for dataset validation.\n\t * Used to validate that Agreements reference valid catalog datasets.\n\t * @internal\n\t */\n\tprivate readonly _federatedCatalogueComponent: IFederatedCatalogueComponent;\n\n\t/**\n\t * Entity storage for Transfer Process entities.\n\t * Shared between Control Plane and Data Plane.\n\t * @internal\n\t */\n\tprivate readonly _transferProcessStorage: IEntityStorageConnector<TransferProcess>;\n\n\t/**\n\t * The trust component for token verification and generation.\n\t * @internal\n\t */\n\tprivate readonly _trustComponent: ITrustComponent;\n\n\t/**\n\t * Override trust generator type for token generation.\n\t * @internal\n\t */\n\tprivate readonly _overrideTrustGeneratorType?: string;\n\n\t/**\n\t * Data plane endpoint path (path only, not full URL).\n\t * Will be combined with public origin from hosting component.\n\t * If not configured, PULL transfers are not supported.\n\t * @internal\n\t */\n\tprivate readonly _dataPlanePath?: string;\n\n\t/**\n\t * Policy requester instance for handling negotiation callbacks.\n\t * @internal\n\t */\n\tprivate readonly _policyRequester: DataspaceControlPlanePolicyRequester;\n\n\t/**\n\t * Task scheduler for periodic stalled negotiation cleanup.\n\t * @internal\n\t */\n\tprivate readonly _taskScheduler?: ITaskSchedulerComponent;\n\n\t/**\n\t * Registered negotiation callbacks from upstream callers, keyed by registration key.\n\t * @internal\n\t */\n\tprivate readonly _negotiationCallbacks: Map<string, INegotiationCallback>;\n\n\t/**\n\t * Create a new instance of DataspaceControlPlaneService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IDataspaceControlPlaneServiceConstructorOptions) {\n\t\tthis._loggingComponent = ComponentFactory.getIfExists<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\n\t\t// Retrieve PAP component with default\n\t\tthis._policyAdministrationPointComponent =\n\t\t\tComponentFactory.get<IPolicyAdministrationPointComponent>(\n\t\t\t\toptions?.policyAdministrationPointComponentType ?? \"policy-administration-point\"\n\t\t\t);\n\n\t\t// Retrieve PNP component with default\n\t\tthis._policyNegotiationPointComponent = ComponentFactory.get<IPolicyNegotiationPointComponent>(\n\t\t\toptions?.policyNegotiationPointComponentType ?? \"policy-negotiation-point\"\n\t\t);\n\n\t\t// Retrieve PNAP component (optional) for negotiation history\n\t\tthis._policyNegotiationAdminPointComponent =\n\t\t\tComponentFactory.getIfExists<IPolicyNegotiationAdminPointComponent>(\n\t\t\t\toptions?.policyNegotiationAdminPointComponentType ?? \"policy-negotiation-admin-point\"\n\t\t\t);\n\n\t\t// Retrieve Federated Catalogue component with default\n\t\tthis._federatedCatalogueComponent = ComponentFactory.get<IFederatedCatalogueComponent>(\n\t\t\toptions?.federatedCatalogueComponentType ?? \"federated-catalogue\"\n\t\t);\n\n\t\tthis._transferProcessStorage = EntityStorageConnectorFactory.get<\n\t\t\tIEntityStorageConnector<TransferProcess>\n\t\t>(options?.transferProcessEntityStorageType ?? nameofKebabCase<TransferProcess>());\n\n\t\tthis._trustComponent = ComponentFactory.get<ITrustComponent>(\n\t\t\toptions?.trustComponentType ?? \"trust\"\n\t\t);\n\n\t\tthis._overrideTrustGeneratorType = options?.config?.overrideTrustGeneratorType;\n\n\t\tthis._dataPlanePath = Is.stringValue(options?.config?.dataPlanePath)\n\t\t\t? StringHelper.trimLeadingSlashes(options.config.dataPlanePath)\n\t\t\t: undefined;\n\n\t\tthis._taskScheduler = ComponentFactory.getIfExists<ITaskSchedulerComponent>(\n\t\t\toptions?.taskSchedulerComponentType ?? \"task-scheduler\"\n\t\t);\n\n\t\tthis._negotiationCallbacks = new Map();\n\n\t\tconst internalCallback: INegotiationCallback = {\n\t\t\tonStateChanged: async (negotiationId, state, data) => {\n\t\t\t\tfor (const [key, cb] of this._negotiationCallbacks.entries()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait cb.onStateChanged(negotiationId, state, data);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tmessage: \"negotiationCallbackError\",\n\t\t\t\t\t\t\tdata: { key, negotiationId, method: \"onStateChanged\", error }\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\tonCompleted: async (negotiationId, agreementId) => {\n\t\t\t\tfor (const [key, cb] of this._negotiationCallbacks.entries()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait cb.onCompleted(negotiationId, agreementId);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tmessage: \"negotiationCallbackError\",\n\t\t\t\t\t\t\tdata: { key, negotiationId, method: \"onCompleted\", error }\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\tonFailed: async (negotiationId, reason) => {\n\t\t\t\tfor (const [key, cb] of this._negotiationCallbacks.entries()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait cb.onFailed(negotiationId, reason);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tmessage: \"negotiationCallbackError\",\n\t\t\t\t\t\t\tdata: { key, negotiationId, method: \"onFailed\", error }\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\tthis._policyRequester = new DataspaceControlPlanePolicyRequester(\n\t\t\toptions?.loggingComponentType ?? \"logging\",\n\t\t\tinternalCallback\n\t\t);\n\n\t\tPolicyRequesterFactory.register(\n\t\t\tDataspaceControlPlaneService._REQUESTER_TYPE,\n\t\t\t() => this._policyRequester\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 DataspaceControlPlaneService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Register a callback to receive negotiation state change notifications.\n\t * Upstream modules (e.g. supply-chain) register their callback here.\n\t * @param key A unique key identifying this callback registration.\n\t * @param callback The callback interface to register.\n\t */\n\tpublic registerNegotiationCallback(key: string, callback: INegotiationCallback): void {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(key), key);\n\t\tthis._negotiationCallbacks.set(key, callback);\n\t}\n\n\t/**\n\t * Unregister a previously registered negotiation callback.\n\t * @param key The key used when registering the callback.\n\t */\n\tpublic unregisterNegotiationCallback(key: string): void {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(key), key);\n\t\tthis._negotiationCallbacks.delete(key);\n\t}\n\n\t/**\n\t * The service needs to be started when the application is initialized.\n\t * Populates the Federated Catalogue with datasets from registered apps\n\t * and starts the stalled negotiation cleanup task.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t */\n\tpublic async start(nodeLoggingComponentType?: string): Promise<void> {\n\t\tconst engine = EngineCoreFactory.getIfExists(\"engine\");\n\t\t// Skip if no engine exists OR if this is a clone instance\n\t\tif (Is.empty(engine) || engine.isClone()) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"debug\",\n\t\t\t\tts: Date.now(),\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tmessage: \"engineCloneStart\"\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tts: Date.now(),\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tmessage: \"populatingFederatedCatalogue\"\n\t\t});\n\n\t\t// Get all registered apps\n\t\tconst appNames = DataspaceAppFactory.names();\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"debug\",\n\t\t\tts: Date.now(),\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tmessage: \"discoveredApps\",\n\t\t\tdata: { count: appNames.length, apps: appNames }\n\t\t});\n\n\t\tlet registeredCount = 0;\n\t\tlet errorCount = 0;\n\n\t\t// Collect and register datasets from each app\n\t\tfor (const appName of appNames) {\n\t\t\ttry {\n\t\t\t\tconst app = DataspaceAppFactory.get<IDataspaceApp>(appName);\n\t\t\t\tconst datasets = await app.datasetsHandled();\n\n\t\t\t\tfor (const dataset of datasets) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Ensure publisher is set (required for Federated Catalogue)\n\t\t\t\t\t\tconst datasetWithPublisher = await this.ensurePublisher(dataset);\n\n\t\t\t\t\t\t// Register with Federated Catalogue\n\t\t\t\t\t\tawait this._federatedCatalogueComponent.set(\n\t\t\t\t\t\t\tdatasetWithPublisher as unknown as IDcatDataset\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tregisteredCount++;\n\n\t\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\t\tlevel: \"debug\",\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\tmessage: \"datasetRegistered\",\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tdatasetId: getJsonLdId(datasetWithPublisher) ?? \"\",\n\t\t\t\t\t\t\t\tappName\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\terrorCount++;\n\t\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\tmessage: \"datasetRegistrationFailed\",\n\t\t\t\t\t\t\terror: BaseError.fromError(error),\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tdatasetId: getJsonLdId(dataset) ?? \"\",\n\t\t\t\t\t\t\t\tappName\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\tmessage: \"appDatasetsRetrievalFailed\",\n\t\t\t\t\terror: BaseError.fromError(error),\n\t\t\t\t\tdata: { appName }\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tts: Date.now(),\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tmessage: \"federatedCataloguePopulated\",\n\t\t\tdata: {\n\t\t\t\tregisteredCount,\n\t\t\t\terrorCount,\n\t\t\t\ttotalApps: appNames.length\n\t\t\t}\n\t\t});\n\n\t\tif (this._taskScheduler) {\n\t\t\tawait this._taskScheduler.addTask(\n\t\t\t\t\"control-plane-negotiation-cleanup\",\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tnextTriggerTime: Date.now(),\n\t\t\t\t\t\tintervalMinutes: 5\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tasync () => {\n\t\t\t\t\tawait this.cleanupStalledNegotiations();\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Stop the service.\n\t * Removes the stalled negotiation cleanup task.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t */\n\tpublic async stop(nodeLoggingComponentType?: string): Promise<void> {\n\t\tif (this._taskScheduler) {\n\t\t\tawait this._taskScheduler.removeTask(\"control-plane-negotiation-cleanup\");\n\t\t}\n\t}\n\n\t// ----------------------------------------------------------------------------\n\t// CONSUMER SIDE OPERATIONS\n\t// ----------------------------------------------------------------------------\n\n\t/**\n\t * Request a Transfer Process.\n\t * Creates a new Transfer Process in REQUESTED state.\n\t * @param request Transfer request message (DSP compliant).\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Process (DSP compliant) with state REQUESTED, or TransferError if the operation fails.\n\t *\n\t * Role Performed: Provider\n\t * Called by: Consumer when it wants to request a new Transfer Process\n\t */\n\tpublic async requestTransfer(\n\t\trequest: IDataspaceProtocolTransferRequestMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferProcess | IDataspaceProtocolTransferError> {\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"requestTransfer\"\n\t\t);\n\n\t\tconst validationFailures: IValidationFailure[] = [];\n\t\tconst isConformant = await DataspaceProtocolHelper.checkConformance(\n\t\t\tJsonLdHelper.toNodeObject(request),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\tif (!isConformant) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"invalidTransferRequest\",\n\t\t\t\tdata: { validationFailures }\n\t\t\t});\n\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"invalidTransferRequest\", {\n\t\t\t\tvalidationFailures\n\t\t\t});\n\t\t}\n\n\t\tconst providerPid = `urn:uuid:${RandomHelper.generateUuidV7()}`;\n\n\t\tlet datasetId: string;\n\t\tlet consumerIdentity: string;\n\t\tlet providerIdentity: string;\n\t\tlet policies: IDataspaceProtocolPolicy[] = [];\n\n\t\ttry {\n\t\t\tconst agreement = await this.lookupAgreement(request.agreementId);\n\n\t\t\tif (!agreement) {\n\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"agreementNotFound\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tagreementId: request.agreementId,\n\t\t\t\t\t\thint: \"Agreement must exist before transfer. Use contract negotiation to create agreement first.\"\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"agreementNotFound\",\n\t\t\t\t\trequest.agreementId,\n\t\t\t\t\t{\n\t\t\t\t\t\tagreementId: request.agreementId,\n\t\t\t\t\t\thint: \"Perform contract negotiation first to create an agreement\"\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst assigneeIdentity = OdrlPolicyHelper.extractAssigneeIdentity(agreement);\n\t\t\tconst assigneeIds = ArrayHelper.fromObjectOrArray<string>(assigneeIdentity);\n\n\t\t\tif (!assigneeIds.includes(trustInfo.identity)) {\n\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"callerNotAuthorizedForAgreement\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tconsumerIdentity = trustInfo.identity;\n\n\t\t\tconst assignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);\n\t\t\tconst assignerIds = ArrayHelper.fromObjectOrArray<string>(assignerIdentity);\n\t\t\tif (assignerIds.length > 1) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"multipleAssignersNotSupported\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tproviderIdentity = assignerIds[0];\n\n\t\t\tdatasetId = this.extractDatasetId(agreement);\n\n\t\t\tawait this.validateCatalogDataset(datasetId, agreement);\n\n\t\t\tpolicies = [agreement];\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, { consumerPid: request.consumerPid, providerPid });\n\t\t}\n\n\t\tconst now = new Date();\n\n\t\tconst storageEntity: TransferProcess = {\n\t\t\tid: Converter.bytesToHex(RandomHelper.generate(32)),\n\t\t\tconsumerPid: request.consumerPid,\n\t\t\tproviderPid,\n\t\t\tstate: DataspaceProtocolTransferProcessStateType.REQUESTED,\n\t\t\tagreementId: request.agreementId,\n\t\t\tdatasetId,\n\t\t\tconsumerIdentity,\n\t\t\tproviderIdentity,\n\t\t\t// offerId should reference Catalog Offer (via Agreement)\n\t\t\t// For now, use agreementId as reference (proper flow: Catalog → Negotiation → Agreement)\n\t\t\tofferId: request.agreementId,\n\t\t\tpolicies,\n\t\t\tcallbackAddress: request.callbackAddress,\n\t\t\tformat: request.format,\n\t\t\tdataAddress: request.dataAddress,\n\t\t\tdateCreated: now.toISOString(),\n\t\t\tdateModified: now.toISOString()\n\t\t};\n\n\t\tawait this._transferProcessStorage.set(storageEntity);\n\n\t\tconst entity: ITransferProcess = this.storageEntityToModel(storageEntity);\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"transferProcessInitiated\",\n\t\t\tdata: {\n\t\t\t\tconsumerPid: request.consumerPid,\n\t\t\t\tproviderPid,\n\t\t\t\tagreementId: request.agreementId\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\t\t\tconsumerPid: entity.consumerPid,\n\t\t\tproviderPid: entity.providerPid,\n\t\t\tstate: entity.state\n\t\t};\n\t}\n\n\t// ----------------------------------------------------------------------------\n\t// PROVIDER SIDE OPERATIONS\n\t// ----------------------------------------------------------------------------\n\n\t/**\n\t * Start a Transfer Process.\n\t * Transitions Transfer Process from REQUESTED to STARTED state or resumes from SUSPENDED state.\n\t * @param message Transfer start message (DSP compliant).\n\t * @param publicOrigin The public origin URL of this service.\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Start Message (DSP compliant) with dataAddress for PULL transfers, or TransferError if the operation fails.\n\t *\n\t * Role Performed: Provider / Consumer\n\t */\n\tpublic async startTransfer(\n\t\tmessage: IDataspaceProtocolTransferStartMessage,\n\t\tpublicOrigin: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferStartMessage | IDataspaceProtocolTransferError> {\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"startTransfer\"\n\t\t);\n\n\t\tconst validationFailures: IValidationFailure[] = [];\n\t\tconst isConformant = await DataspaceProtocolHelper.checkConformance(\n\t\t\tJsonLdHelper.toNodeObject(message),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\tif (!isConformant) {\n\t\t\treturn transformToTransferError(\n\t\t\t\tnew GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"invalidTransferStartMessage\", {\n\t\t\t\t\tvalidationFailures\n\t\t\t\t}),\n\t\t\t\tmessage\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst { entity, role } = await this.lookupTransferByMessage(message);\n\n\t\t\tthis.validateCallerIsProvider(trustInfo.identity, entity);\n\n\t\t\tif (\n\t\t\t\tentity.state !== DataspaceProtocolTransferProcessStateType.REQUESTED &&\n\t\t\t\tentity.state !== DataspaceProtocolTransferProcessStateType.SUSPENDED\n\t\t\t) {\n\t\t\t\treturn transformToTransferError(\n\t\t\t\t\tnew GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"invalidStateForStart\", {\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tcurrentState: entity.state\n\t\t\t\t\t}),\n\t\t\t\t\tmessage\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tentity.state = DataspaceProtocolTransferProcessStateType.STARTED;\n\t\t\tentity.dateModified = new Date();\n\n\t\t\tawait this._transferProcessStorage.set(this.modelToStorageEntity(entity));\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transferProcessStarted\",\n\t\t\t\tdata: {\n\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\trole\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst response: IDataspaceProtocolTransferStartMessage = {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferStartMessage,\n\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\tproviderPid: entity.providerPid\n\t\t\t};\n\n\t\t\t// ============================================================================\n\t\t\t// PULL vs PUSH Transfer Mode Detection (DSP Protocol)\n\t\t\t// ============================================================================\n\t\t\t// The transfer mode is determined by whether the consumer provided a dataAddress\n\t\t\t// in the original TransferRequestMessage:\n\t\t\t//\n\t\t\t// PULL Mode (dataAddress NOT provided by consumer):\n\t\t\t// - Consumer requests data but doesn't specify where to receive it\n\t\t\t// - Provider generates access token and returns dataAddress in TransferStartMessage\n\t\t\t// - Consumer uses the returned endpoint + token to PULL data from provider\n\t\t\t// - Flow: Consumer → GET /entities?consumerPid=X (with Bearer token) → Provider\n\t\t\t//\n\t\t\t// PUSH Mode (dataAddress PROVIDED by consumer):\n\t\t\t// - Consumer specifies endpoint where they want data sent (e.g., webhook URL)\n\t\t\t// - Provider will PUSH data to the consumer's specified endpoint\n\t\t\t// - Flow: Provider → POST to consumer's dataAddress endpoint → Consumer\n\t\t\t//\n\t\t\t// See: https://eclipse-dataspace-protocol-base.github.io/DataspaceProtocol/2025-1-err1/#transfer-start-message\n\t\t\t// ============================================================================\n\n\t\t\tif (Is.empty(entity.dataAddress)) {\n\t\t\t\tif (!Is.stringValue(this._dataPlanePath)) {\n\t\t\t\t\treturn transformToTransferError(\n\t\t\t\t\t\tnew GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"pullTransfersNotSupported\", {\n\t\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\t\tproviderPid: entity.providerPid\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tmessage\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Provider signs the data access token with its own identity.\n\t\t\t\t// The subject contains the transfer context claims that the data plane\n\t\t\t\t// will verify when the consumer presents this token.\n\t\t\t\tif (!Is.stringValue(entity.providerIdentity)) {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\t\"providerIdentityMissing\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst accessToken = await this._trustComponent.generate(\n\t\t\t\t\tentity.providerIdentity,\n\t\t\t\t\tthis._overrideTrustGeneratorType,\n\t\t\t\t\t{\n\t\t\t\t\t\tsubject: {\n\t\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\t\tagreementId: entity.agreementId,\n\t\t\t\t\t\t\tdatasetId: entity.datasetId\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst tokenString = accessToken as string;\n\t\t\t\tconst fullEndpoint = `${publicOrigin}/${this._dataPlanePath}`;\n\n\t\t\t\tresponse.dataAddress = {\n\t\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.DataAddress,\n\t\t\t\t\tendpointType: DataspaceProtocolEndpointType.HttpsQueryEndpoint,\n\t\t\t\t\tendpoint: fullEndpoint,\n\t\t\t\t\tendpointProperties: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.EndpointProperty,\n\t\t\t\t\t\t\tname: \"authorization\",\n\t\t\t\t\t\t\tvalue: tokenString\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.EndpointProperty,\n\t\t\t\t\t\t\tname: \"authType\",\n\t\t\t\t\t\t\tvalue: \"bearer\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t};\n\n\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"dataAccessTokenGenerated\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tendpoint: fullEndpoint,\n\t\t\t\t\t\ttransferMode: \"PULL\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// PUSH MODE: Provider will push data to consumer's specified endpoint\n\t\t\t\t// The consumer provided dataAddress in TransferRequestMessage, indicating\n\t\t\t\t// where they want data sent. Provider acknowledges and will push data there.\n\t\t\t\t//\n\t\t\t\t// TODO: PUSH transfer implementation (RFC-007 future work)\n\t\t\t\t// Implementation would need to:\n\t\t\t\t// 1. Generate provider's own trust token to authenticate when pushing to consumer\n\t\t\t\t// 2. Validate consumer's dataAddress endpoint is reachable\n\t\t\t\t// 3. Extract any consumer-provided authorization from endpointProperties\n\t\t\t\t// 4. Schedule background task to push data to consumer's endpoint\n\t\t\t\t// 5. POST data to entity.dataAddress.endpoint with provider's trust token\n\t\t\t\t// 6. Implement retry logic with exponential backoff\n\t\t\t\t// 7. Send TransferCompletionMessage when push completes successfully\n\t\t\t\t//\n\t\t\t\t// Trust flow for PUSH (mirror of PULL):\n\t\t\t\t// - PULL: Provider generates token → Consumer uses to authenticate when pulling\n\t\t\t\t// - PUSH: Provider generates token → Provider uses to authenticate when pushing\n\n\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\tlevel: \"warn\",\n\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\tts: Date.now(),\n\t\t\t\t\tmessage: \"pushTransferModeNotImplemented\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tconsumerEndpoint: entity.dataAddress.endpoint,\n\t\t\t\t\t\ttransferMode: \"PUSH\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn response;\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, message);\n\t\t}\n\t}\n\n\t// ----------------------------------------------------------------------------\n\t// SHARED STATE MANAGEMENT OPERATIONS (Either Side)\n\t// ----------------------------------------------------------------------------\n\n\t/**\n\t * Complete a Transfer Process.\n\t * @param message Transfer completion message (DSP compliant).\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Process (DSP compliant) with state COMPLETED, or TransferError if the operation fails.\n\t */\n\tpublic async completeTransfer(\n\t\tmessage: IDataspaceProtocolTransferCompletionMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferProcess | IDataspaceProtocolTransferError> {\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"completeTransfer\"\n\t\t);\n\n\t\tconst validationFailures: IValidationFailure[] = [];\n\t\tconst isConformant = await DataspaceProtocolHelper.checkConformance(\n\t\t\tJsonLdHelper.toNodeObject(message),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\tif (!isConformant) {\n\t\t\treturn transformToTransferError(\n\t\t\t\tnew GeneralError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"invalidTransferCompletionMessage\",\n\t\t\t\t\t{ validationFailures }\n\t\t\t\t),\n\t\t\t\tmessage\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst { entity, role } = await this.lookupTransferByMessage(message);\n\n\t\t\tthis.validateCallerIsConsumer(trustInfo.identity, entity);\n\n\t\t\tif (entity.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\t\treturn transformToTransferError(\n\t\t\t\t\tnew GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"invalidStateForComplete\", {\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tcurrentState: entity.state\n\t\t\t\t\t}),\n\t\t\t\t\tmessage\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tentity.state = DataspaceProtocolTransferProcessStateType.COMPLETED;\n\t\t\tentity.dateModified = new Date();\n\n\t\t\tawait this._transferProcessStorage.set(this.modelToStorageEntity(entity));\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transferProcessCompleted\",\n\t\t\t\tdata: {\n\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\trole\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\tstate: entity.state\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, message);\n\t\t}\n\t}\n\n\t/**\n\t * Suspend a Transfer Process.\n\t * @param message Transfer suspension message (DSP compliant).\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Process (DSP compliant) with state SUSPENDED, or TransferError if the operation fails.\n\t */\n\tpublic async suspendTransfer(\n\t\tmessage: IDataspaceProtocolTransferSuspensionMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferProcess | IDataspaceProtocolTransferError> {\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"suspendTransfer\"\n\t\t);\n\n\t\tconst validationFailures: IValidationFailure[] = [];\n\t\tconst isConformant = await DataspaceProtocolHelper.checkConformance(\n\t\t\tJsonLdHelper.toNodeObject(message),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\tif (!isConformant) {\n\t\t\treturn transformToTransferError(\n\t\t\t\tnew GeneralError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"invalidTransferSuspensionMessage\",\n\t\t\t\t\t{ validationFailures }\n\t\t\t\t),\n\t\t\t\tmessage\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst { entity, role } = await this.lookupTransferByMessage(message);\n\n\t\t\tthis.validateCallerIsTransferParty(trustInfo.identity, entity);\n\n\t\t\tif (entity.state !== DataspaceProtocolTransferProcessStateType.STARTED) {\n\t\t\t\treturn transformToTransferError(\n\t\t\t\t\tnew GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"invalidStateForSuspend\", {\n\t\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\t\tcurrentState: entity.state\n\t\t\t\t\t}),\n\t\t\t\t\tmessage\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tentity.state = DataspaceProtocolTransferProcessStateType.SUSPENDED;\n\t\t\tentity.dateModified = new Date();\n\n\t\t\tawait this._transferProcessStorage.set(this.modelToStorageEntity(entity));\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transferProcessSuspended\",\n\t\t\t\tdata: {\n\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\trole,\n\t\t\t\t\treason: message.reason\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\tstate: entity.state\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, message);\n\t\t}\n\t}\n\n\t/**\n\t * Terminate a Transfer Process.\n\t * @param message Transfer termination message (DSP compliant).\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Process (DSP compliant) with state TERMINATED, or TransferError if the operation fails.\n\t */\n\tpublic async terminateTransfer(\n\t\tmessage: IDataspaceProtocolTransferTerminationMessage,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferProcess | IDataspaceProtocolTransferError> {\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"terminateTransfer\"\n\t\t);\n\n\t\tconst validationFailures: IValidationFailure[] = [];\n\t\tconst isConformant = await DataspaceProtocolHelper.checkConformance(\n\t\t\tJsonLdHelper.toNodeObject(message),\n\t\t\tvalidationFailures\n\t\t);\n\n\t\tif (!isConformant) {\n\t\t\treturn transformToTransferError(\n\t\t\t\tnew GeneralError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"invalidTransferTerminationMessage\",\n\t\t\t\t\t{ validationFailures }\n\t\t\t\t),\n\t\t\t\tmessage\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst { entity, role } = await this.lookupTransferByMessage(message);\n\n\t\t\tthis.validateCallerIsTransferParty(trustInfo.identity, entity);\n\n\t\t\tentity.state = DataspaceProtocolTransferProcessStateType.TERMINATED;\n\t\t\tentity.dateModified = new Date();\n\n\t\t\tawait this._transferProcessStorage.set(this.modelToStorageEntity(entity));\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transferProcessTerminated\",\n\t\t\t\tdata: {\n\t\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\t\trole,\n\t\t\t\t\treason: message.reason\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\tstate: entity.state\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, message);\n\t\t}\n\t}\n\n\t/**\n\t * Get Transfer Process state.\n\t * @param pid Process ID (consumerPid or providerPid).\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Process (DSP compliant) with current state, or TransferError if the operation fails.\n\t */\n\tpublic async getTransferProcess(\n\t\tpid: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolTransferProcess | IDataspaceProtocolTransferError> {\n\t\tconst trustInfo = await TrustHelper.verifyTrust(\n\t\t\tthis._trustComponent,\n\t\t\ttrustPayload,\n\t\t\t\"getTransferProcess\"\n\t\t);\n\n\t\ttry {\n\t\t\tconst { entity, role } = await this.lookupTransferByPid(pid);\n\n\t\t\tthis.validateCallerIsTransferParty(trustInfo.identity, entity);\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transferProcessQueried\",\n\t\t\t\tdata: {\n\t\t\t\t\tpid,\n\t\t\t\t\trole,\n\t\t\t\t\tstate: entity.state\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\t\t\t\tconsumerPid: entity.consumerPid,\n\t\t\t\tproviderPid: entity.providerPid,\n\t\t\t\tstate: entity.state\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn transformToTransferError(error, { consumerPid: pid, providerPid: pid });\n\t\t}\n\t}\n\n\t// ============================================================================\n\t// CONTRACT NEGOTIATION\n\t// ============================================================================\n\n\t/**\n\t * Negotiate a contract agreement with a provider.\n\t * Returns immediately with a negotiationId. The caller is notified\n\t * via the registered INegotiationCallback when the negotiation completes.\n\t *\n\t * @param datasetId The dataset ID from the provider's catalog.\n\t * @param offerId The offer ID from the provider's catalog.\n\t * @param providerEndpoint The provider's contract negotiation endpoint URL.\n\t * @param publicOrigin The public origin URL of this control plane (for callbacks).\n\t * @param trustPayload The trust payload for authentication.\n\t * @returns The negotiation ID. Use the registered callback for completion notification.\n\t */\n\tpublic async negotiateAgreement(\n\t\tdatasetId: string,\n\t\tofferId: string,\n\t\tproviderEndpoint: string,\n\t\tpublicOrigin: string,\n\t\ttrustPayload: unknown\n\t): Promise<{ negotiationId: string }> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(datasetId), datasetId);\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(offerId), offerId);\n\t\tGuards.stringValue(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\tnameof(providerEndpoint),\n\t\t\tproviderEndpoint\n\t\t);\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(publicOrigin), publicOrigin);\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"startingContractNegotiation\",\n\t\t\tdata: { datasetId, offerId, providerEndpoint, publicOrigin }\n\t\t});\n\n\t\tconst catalogResult = await this._federatedCatalogueComponent.get(datasetId);\n\n\t\tif (isCatalogError(catalogResult)) {\n\t\t\tif (isCatalogErrorName(catalogResult, NotFoundError.CLASS_NAME)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"datasetNotFoundInCatalog\",\n\t\t\t\t\tdatasetId,\n\t\t\t\t\t{\n\t\t\t\t\t\tdatasetId,\n\t\t\t\t\t\tofferId,\n\t\t\t\t\t\tproviderEndpoint\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"catalogLookupFailedForNegotiation\",\n\t\t\t\t{\n\t\t\t\t\tdatasetId,\n\t\t\t\t\tofferId,\n\t\t\t\t\tproviderEndpoint,\n\t\t\t\t\terrorCode: catalogResult.code\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tconst rawOffers = this.getCatalogDatasetPolicies(catalogResult);\n\n\t\tif (!Is.arrayValue(rawOffers)) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"datasetHasNoOffers\", {\n\t\t\t\tofferId,\n\t\t\t\tdatasetId: getJsonLdId(catalogResult) ?? \"\"\n\t\t\t});\n\t\t}\n\n\t\tconst catalogOffers = rawOffers.filter(offer => Is.object<IDataspaceProtocolPolicy>(offer));\n\n\t\tif (!Is.arrayValue(catalogOffers)) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"datasetHasNoValidOffers\", {\n\t\t\t\tofferId,\n\t\t\t\tdatasetId: getJsonLdId(catalogResult) ?? \"\"\n\t\t\t});\n\t\t}\n\n\t\tconst matchingOffer = catalogOffers.find((offer: IDataspaceProtocolPolicy) => {\n\t\t\tconst offerUid = OdrlPolicyHelper.getUid(offer);\n\t\t\treturn offerUid === offerId;\n\t\t});\n\n\t\tif (!matchingOffer) {\n\t\t\tconst availableOffers = catalogOffers\n\t\t\t\t.map((o: IDataspaceProtocolPolicy) => OdrlPolicyHelper.getUid(o) ?? \"unknown\")\n\t\t\t\t.join(\", \");\n\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"offerNotFoundInDataset\",\n\t\t\t\tofferId,\n\t\t\t\t{\n\t\t\t\t\tofferId,\n\t\t\t\t\tdatasetId: getJsonLdId(catalogResult) ?? \"\",\n\t\t\t\t\tavailableOffers\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"offerFoundInCatalog\",\n\t\t\tdata: {\n\t\t\t\tofferId,\n\t\t\t\tdatasetId: getJsonLdId(catalogResult) ?? \"\",\n\t\t\t\tofferType: getJsonLdType(matchingOffer)\n\t\t\t}\n\t\t});\n\n\t\tconst negotiationId = await this._policyNegotiationPointComponent.sendRequestToProvider(\n\t\t\tproviderEndpoint,\n\t\t\tDataspaceControlPlaneService._REQUESTER_TYPE,\n\t\t\tofferId,\n\t\t\tpublicOrigin\n\t\t);\n\n\t\tif (!negotiationId) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"negotiationInitiationFailed\",\n\t\t\t\t{\n\t\t\t\t\tofferId,\n\t\t\t\t\tproviderEndpoint\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tthis._policyRequester.trackNegotiation(negotiationId);\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"negotiationInitiated\",\n\t\t\tdata: { negotiationId, offerId }\n\t\t});\n\n\t\treturn { negotiationId };\n\t}\n\n\t/**\n\t * Get the current state of a contract negotiation.\n\t * @param negotiationId The unique identifier of the negotiation.\n\t * @param trustPayload The trust payload for authentication.\n\t * @returns Current state of the negotiation.\n\t */\n\tpublic async getNegotiation(\n\t\tnegotiationId: string,\n\t\ttrustPayload: unknown\n\t): Promise<IDataspaceProtocolContractNegotiation | IDataspaceProtocolContractNegotiationError> {\n\t\tGuards.stringValue(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\tnameof(negotiationId),\n\t\t\tnegotiationId\n\t\t);\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"getNegotiation\",\n\t\t\tdata: { negotiationId }\n\t\t});\n\n\t\tconst result = await this._policyNegotiationPointComponent.getNegotiation(\n\t\t\tnegotiationId,\n\t\t\ttrustPayload\n\t\t);\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"negotiationStateRetrieved\",\n\t\t\tdata: {\n\t\t\t\tnegotiationId,\n\t\t\t\ttype: getJsonLdType(result),\n\t\t\t\tstate: (result as IDataspaceProtocolContractNegotiation).state\n\t\t\t}\n\t\t});\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get negotiation history.\n\t * @param state Optional filter by negotiation state.\n\t * @param cursor Optional pagination cursor.\n\t * @param trustPayload Trust payload for authentication.\n\t * @returns List of negotiation history entries with pagination.\n\t */\n\tpublic async getNegotiationHistory(\n\t\tstate: string | undefined,\n\t\tcursor: string | undefined,\n\t\ttrustPayload: unknown\n\t): Promise<{\n\t\tnegotiations: {\n\t\t\tnegotiation:\n\t\t\t\t| IDataspaceProtocolContractNegotiation\n\t\t\t\t| IDataspaceProtocolContractNegotiationError;\n\t\t\tcreatedAt: string;\n\t\t\tofferId?: string;\n\t\t\tagreementId?: string;\n\t\t}[];\n\t\tcursor?: string;\n\t\tcount: number;\n\t}> {\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"getNegotiationHistory\",\n\t\t\tdata: { state, cursor }\n\t\t});\n\n\t\tif (!this._policyNegotiationAdminPointComponent) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"pnapNotConfigured\", {\n\t\t\t\tmessage:\n\t\t\t\t\t\"Policy Negotiation Admin Point not configured. \" +\n\t\t\t\t\t\"Set policyNegotiationAdminPointComponentType in constructor options.\"\n\t\t\t});\n\t\t}\n\n\t\tconst { items: pnapNegotiations, cursor: nextCursor } =\n\t\t\tawait this._policyNegotiationAdminPointComponent.query(\n\t\t\t\tstate as DataspaceProtocolContractNegotiationStateType | undefined,\n\t\t\t\tcursor\n\t\t\t);\n\n\t\tconst negotiations = pnapNegotiations.map(pnapNeg => {\n\t\t\tconst dspNegotiation: IDataspaceProtocolContractNegotiation = {\n\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\"@type\": DataspaceProtocolContractNegotiationTypes.ContractNegotiation,\n\t\t\t\tconsumerPid: pnapNeg.id,\n\t\t\t\tproviderPid: pnapNeg.correlationId,\n\t\t\t\tstate: pnapNeg.state\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tnegotiation: dspNegotiation,\n\t\t\t\tcreatedAt: pnapNeg.dateCreated,\n\t\t\t\tofferId: OdrlPolicyHelper.getUid(pnapNeg.offer),\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(pnapNeg.agreement)\n\t\t\t};\n\t\t});\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"negotiationHistoryRetrieved\",\n\t\t\tdata: {\n\t\t\t\tcount: negotiations.length,\n\t\t\t\tstate,\n\t\t\t\thasCursor: Boolean(nextCursor)\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tnegotiations,\n\t\t\tcursor: nextCursor,\n\t\t\tcount: negotiations.length\n\t\t};\n\t}\n\n\t// ============================================================================\n\t// RESOLVER METHODS - IDataspaceControlPlaneResolverComponent\n\t// ============================================================================\n\n\t/**\n\t * Resolve consumerPid to Transfer Context.\n\t * @param consumerPid Consumer Process ID.\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Context with Agreement, datasetId, and Transfer Process metadata.\n\t */\n\tpublic async resolveConsumerPid(\n\t\tconsumerPid: string,\n\t\ttrustPayload: unknown\n\t): Promise<ITransferContext> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(consumerPid), consumerPid);\n\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"resolveConsumerPid\");\n\n\t\tconst storageEntity = await this._transferProcessStorage.get(consumerPid);\n\n\t\tif (!storageEntity) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"transferProcessNotFound\",\n\t\t\t\tundefined,\n\t\t\t\t{ consumerPid }\n\t\t\t);\n\t\t}\n\n\t\tconst entity = this.storageEntityToModel(storageEntity);\n\n\t\tif (entity.state === DataspaceProtocolTransferProcessStateType.TERMINATED) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"transferProcessTerminated\", {\n\t\t\t\tconsumerPid\n\t\t\t});\n\t\t}\n\n\t\tconst agreement = await this.lookupAgreement(entity.agreementId);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst currentOrgId = contextIds?.[ContextIdKeys.Organization];\n\n\t\tif (!currentOrgId) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"organizationContextMissing\",\n\t\t\t\t{\n\t\t\t\t\tconsumerPid\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tconst assignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);\n\t\tconst assignerIds = ArrayHelper.fromObjectOrArray<string>(assignerIdentity);\n\n\t\tif (!assignerIds.includes(currentOrgId)) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"agreementAssignerMismatch\",\n\t\t\t\t{\n\t\t\t\t\tconsumerPid,\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\t\texpectedOrgId: currentOrgId,\n\t\t\t\t\tactualAssigner: assignerIds.join(\", \")\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"resolvedConsumerPid\",\n\t\t\tdata: {\n\t\t\t\tconsumerPid,\n\t\t\t\tdatasetId: entity.datasetId,\n\t\t\t\tstate: entity.state,\n\t\t\t\tconsumerIdentity: entity.consumerIdentity,\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\torganizationId: currentOrgId\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tconsumerPid: entity.consumerPid,\n\t\t\tproviderPid: entity.providerPid,\n\t\t\tagreement,\n\t\t\tdatasetId: entity.datasetId,\n\t\t\tofferId: entity.offerId,\n\t\t\tstate: entity.state,\n\t\t\tconsumerIdentity: entity.consumerIdentity,\n\t\t\tproviderIdentity: entity.providerIdentity,\n\t\t\tdataAddress: entity.dataAddress\n\t\t};\n\t}\n\n\t/**\n\t * Resolve providerPid to Transfer Context.\n\t * @param providerPid Provider Process ID.\n\t * @param trustPayload Trust payload containing authorization information (Base64-encoded token).\n\t * @returns Transfer Context with Agreement, datasetId, and Transfer Process metadata.\n\t */\n\tpublic async resolveProviderPid(\n\t\tproviderPid: string,\n\t\ttrustPayload: unknown\n\t): Promise<ITransferContext> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(providerPid), providerPid);\n\n\t\tawait TrustHelper.verifyTrust(this._trustComponent, trustPayload, \"resolveProviderPid\");\n\n\t\tconst { entity } = await this.lookupTransferByPid(providerPid);\n\n\t\tif (entity.state === DataspaceProtocolTransferProcessStateType.TERMINATED) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"transferProcessTerminatedProvider\",\n\t\t\t\t{\n\t\t\t\t\tproviderPid\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tconst agreement = await this.lookupAgreement(entity.agreementId);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst currentOrgId = contextIds?.[ContextIdKeys.Organization];\n\n\t\tif (!currentOrgId) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"organizationContextMissingProvider\",\n\t\t\t\t{\n\t\t\t\t\tproviderPid\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t// Extract assigner UID (can be string, array, or IOdrlParty object)\n\n\t\tconst assignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);\n\t\tconst assignerIds = ArrayHelper.fromObjectOrArray<string>(assignerIdentity);\n\n\t\tif (!assignerIds.includes(currentOrgId)) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"agreementAssignerMismatchProvider\",\n\t\t\t\t{\n\t\t\t\t\tproviderPid,\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\t\texpectedOrgId: currentOrgId,\n\t\t\t\t\tactualAssigner: assignerIds.join(\", \")\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t// Validate that Agreement assignee matches expected consumer identity\n\t\t// This ensures we're pushing to the correct consumer\n\t\t// If assignee is undefined but consumerIdentity has a value, this is also a mismatch\n\t\tconst assigneeIdentity = OdrlPolicyHelper.extractAssigneeIdentity(agreement);\n\t\tconst assigneeIds = ArrayHelper.fromObjectOrArray<string>(assigneeIdentity);\n\n\t\tif (\n\t\t\t!Is.stringValue(entity.consumerIdentity) ||\n\t\t\t!assigneeIds.includes(entity.consumerIdentity)\n\t\t) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"agreementAssigneeMismatch\",\n\t\t\t\t{\n\t\t\t\t\tproviderPid,\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\t\texpectedConsumerIdentity: entity.consumerIdentity,\n\t\t\t\t\tactualAssignee: assigneeIds.join(\", \")\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"resolvedProviderPid\",\n\t\t\tdata: {\n\t\t\t\tproviderPid,\n\t\t\t\tdatasetId: entity.datasetId,\n\t\t\t\tstate: entity.state,\n\t\t\t\tconsumerIdentity: entity.consumerIdentity,\n\t\t\t\tproviderIdentity: entity.providerIdentity,\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\torganizationId: currentOrgId\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tconsumerPid: entity.consumerPid,\n\t\t\tproviderPid: entity.providerPid,\n\t\t\tagreement,\n\t\t\tdatasetId: entity.datasetId,\n\t\t\tofferId: entity.offerId,\n\t\t\tstate: entity.state,\n\t\t\tconsumerIdentity: entity.consumerIdentity,\n\t\t\tproviderIdentity: entity.providerIdentity,\n\t\t\tdataAddress: entity.dataAddress\n\t\t};\n\t}\n\n\t// ============================================================================\n\t// PRIVATE HELPER METHODS\n\t// ============================================================================\n\n\t/**\n\t * Cleanup stalled negotiations.\n\t * Called periodically by the task scheduler.\n\t * @internal\n\t */\n\tprivate async cleanupStalledNegotiations(): Promise<void> {\n\t\tconst now = Date.now();\n\t\tconst stalled: string[] = [];\n\n\t\tfor (const [negotiationId, state] of this._policyRequester.getActiveNegotiations()) {\n\t\t\tif (now - state.updatedAt > STALLED_NEGOTIATION_THRESHOLD_MS) {\n\t\t\t\tstalled.push(negotiationId);\n\t\t\t}\n\t\t}\n\n\t\tfor (const negotiationId of stalled) {\n\t\t\tthis._policyRequester.removeNegotiation(negotiationId);\n\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"stalledNegotiationCleanedUp\",\n\t\t\t\tdata: { negotiationId }\n\t\t\t});\n\n\t\t\tfor (const [key, cb] of this._negotiationCallbacks.entries()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait cb.onFailed(negotiationId, \"negotiationStalled\");\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"negotiationCallbackError\",\n\t\t\t\t\t\tdata: { key, negotiationId, method: \"onFailed\", error }\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (stalled.length > 0) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"stalledNegotiationsCleanupComplete\",\n\t\t\t\tdata: { cleanedUp: stalled.length }\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Convert a storage entity to model.\n\t * @param storageEntity The entity from storage.\n\t * @returns The model representation.\n\t * @internal\n\t */\n\tprivate storageEntityToModel(storageEntity: TransferProcess): ITransferProcess {\n\t\treturn {\n\t\t\tid: storageEntity.id,\n\t\t\tconsumerPid: storageEntity.consumerPid,\n\t\t\tproviderPid: storageEntity.providerPid,\n\t\t\tstate: storageEntity.state,\n\t\t\tagreementId: storageEntity.agreementId,\n\t\t\tdatasetId: storageEntity.datasetId,\n\t\t\tofferId: storageEntity.offerId,\n\t\t\tconsumerIdentity: storageEntity.consumerIdentity,\n\t\t\tproviderIdentity: storageEntity.providerIdentity,\n\t\t\tformat: storageEntity.format,\n\t\t\tcallbackAddress: storageEntity.callbackAddress,\n\t\t\tdateCreated: new Date(storageEntity.dateCreated),\n\t\t\tdateModified: new Date(storageEntity.dateModified),\n\t\t\tpolicies: storageEntity.policies,\n\t\t\tdataAddress: storageEntity.dataAddress\n\t\t};\n\t}\n\n\t/**\n\t * Convert a model to storage entity.\n\t * @param entity The model representation.\n\t * @returns The entity for storage.\n\t * @internal\n\t */\n\tprivate modelToStorageEntity(entity: ITransferProcess): TransferProcess {\n\t\treturn {\n\t\t\tid: entity.id,\n\t\t\tconsumerPid: entity.consumerPid,\n\t\t\tproviderPid: entity.providerPid,\n\t\t\tstate: entity.state,\n\t\t\tagreementId: entity.agreementId,\n\t\t\tdatasetId: entity.datasetId,\n\t\t\tofferId: entity.offerId,\n\t\t\tconsumerIdentity: entity.consumerIdentity,\n\t\t\tproviderIdentity: entity.providerIdentity,\n\t\t\tformat: entity.format,\n\t\t\tcallbackAddress: entity.callbackAddress,\n\t\t\tdateCreated: entity.dateCreated.toISOString(),\n\t\t\tdateModified: entity.dateModified.toISOString(),\n\t\t\tpolicies: entity.policies,\n\t\t\tdataAddress: entity.dataAddress\n\t\t};\n\t}\n\n\t/**\n\t * Look up Agreement from PAP.\n\t * @param agreementId Agreement ID.\n\t * @returns Agreement.\n\t * @internal\n\t */\n\tprivate async lookupAgreement(agreementId: string): Promise<IDataspaceProtocolAgreement> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(agreementId), agreementId);\n\n\t\tlet agreement;\n\t\ttry {\n\t\t\tagreement = await this._policyAdministrationPointComponent.getAgreement(agreementId);\n\t\t} catch (error) {\n\t\t\tif (BaseError.isErrorName(error, NotFoundError.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"agreementLookupFailed\",\n\t\t\t\t{ agreementId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\n\t\treturn agreement;\n\t}\n\n\t/**\n\t * Validate that the caller's verified identity matches the consumer of a transfer process.\n\t * @param callerIdentity The identity from the verified trust token.\n\t * @param entity The transfer process entity.\n\t * @throws UnauthorizedError if the caller is not the consumer.\n\t * @internal\n\t */\n\tprivate validateCallerIsConsumer(callerIdentity: string, entity: ITransferProcess): void {\n\t\tif (callerIdentity !== entity.consumerIdentity) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"callerNotAuthorizedAsConsumer\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Validate that the caller's verified identity matches the provider of a transfer process.\n\t * @param callerIdentity The identity from the verified trust token.\n\t * @param entity The transfer process entity.\n\t * @throws UnauthorizedError if the caller is not the provider.\n\t * @internal\n\t */\n\tprivate validateCallerIsProvider(callerIdentity: string, entity: ITransferProcess): void {\n\t\tif (callerIdentity !== entity.providerIdentity) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"callerNotAuthorizedAsProvider\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Validate that the caller's verified identity matches either the consumer or provider of a transfer process.\n\t * @param callerIdentity The identity from the verified trust token.\n\t * @param entity The transfer process entity.\n\t * @throws UnauthorizedError if the caller is not a party to the transfer.\n\t * @internal\n\t */\n\tprivate validateCallerIsTransferParty(callerIdentity: string, entity: ITransferProcess): void {\n\t\tif (callerIdentity !== entity.consumerIdentity && callerIdentity !== entity.providerIdentity) {\n\t\t\tthrow new UnauthorizedError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"callerNotAuthorizedForTransfer\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Extract dataset ID from Agreement target.\n\t * @param agreement Agreement.\n\t * @returns Dataset ID.\n\t * @internal\n\t */\n\tprivate extractDatasetId(agreement: IDataspaceProtocolAgreement): string {\n\t\tif (Is.empty(agreement.target)) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"agreementMissingTarget\", {\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement)\n\t\t\t});\n\t\t}\n\n\t\tconst targetIds = OdrlPolicyHelper.getTargets(agreement);\n\n\t\tif (targetIds.length === 0) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"agreementTargetMissingUid\", {\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement)\n\t\t\t});\n\t\t}\n\n\t\t// Validate single target, multiple targets are not currently supported\n\t\tif (targetIds.length > 1) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\"agreementMultipleTargetsNotSupported\",\n\t\t\t\t{\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement),\n\t\t\t\t\ttargetCount: targetIds.length\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn targetIds[0];\n\t}\n\n\t/**\n\t * Validate that the dataset exists in the Federated Catalogue.\n\t * @param datasetId Dataset identifier extracted from Agreement.\n\t * @param agreement The Agreement being validated.\n\t * @internal\n\t */\n\tprivate async validateCatalogDataset(\n\t\tdatasetId: string,\n\t\tagreement: IDataspaceProtocolAgreement\n\t): Promise<void> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(datasetId), datasetId);\n\t\tGuards.object<IDataspaceProtocolAgreement>(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\n\t\t// Lookup dataset in catalog\n\t\tconst catalogResult = await this._federatedCatalogueComponent.get(datasetId);\n\n\t\tif (isCatalogError(catalogResult)) {\n\t\t\tif (isCatalogErrorName(catalogResult, NotFoundError.CLASS_NAME)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\t\t\"datasetNotInCatalog\",\n\t\t\t\t\tdatasetId,\n\t\t\t\t\t{\n\t\t\t\t\t\tdatasetId,\n\t\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement)\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"catalogLookupFailed\", {\n\t\t\t\tdatasetId,\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\",\n\t\t\t\terrorCode: catalogResult.code\n\t\t\t});\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"catalogDatasetFound\",\n\t\t\tdata: {\n\t\t\t\tdatasetId,\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\",\n\t\t\t\tdatasetTitle: catalogResult[\"dcterms:title\"]\n\t\t\t}\n\t\t});\n\n\t\tawait this.validateAgreementMatchesOffer(agreement, catalogResult);\n\t}\n\n\t/**\n\t * Extract PID from DSP message and lookup Transfer Process with role detection.\n\t * @param message DSP protocol message with consumerPid and/or providerPid fields.\n\t * @returns Transfer Process entity and our role in this transfer.\n\t * @internal\n\t */\n\tprivate async lookupTransferByMessage(message: {\n\t\tconsumerPid?: string;\n\t\tproviderPid?: string;\n\t}): Promise<{\n\t\tentity: ITransferProcess;\n\t\trole: TransferProcessRole;\n\t}> {\n\t\tconst pid = message.consumerPid ?? message.providerPid;\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, \"pid\", pid);\n\n\t\treturn this.lookupTransferByPid(pid);\n\t}\n\n\t/**\n\t * Lookup Transfer Process by PID and determine our role.\n\t * @param pid Either consumerPid or providerPid.\n\t * @returns Transfer Process entity and our role in this transfer.\n\t * @internal\n\t */\n\tprivate async lookupTransferByPid(pid: string): Promise<{\n\t\tentity: ITransferProcess;\n\t\trole: TransferProcessRole;\n\t}> {\n\t\tGuards.stringValue(DataspaceControlPlaneService.CLASS_NAME, nameof(pid), pid);\n\n\t\t// Check if pid is a consumerPid (primary key lookup)\n\t\tconst storageEntity = await this._transferProcessStorage.get(pid);\n\n\t\tif (storageEntity) {\n\t\t\treturn {\n\t\t\t\tentity: this.storageEntityToModel(storageEntity),\n\t\t\t\trole: TransferProcessRole.Consumer\n\t\t\t};\n\t\t}\n\n\t\t// Check if pid is a providerPid (secondary key lookup)\n\t\tconst providerPidEntity = await this._transferProcessStorage.get(pid, \"providerPid\");\n\t\tif (providerPidEntity) {\n\t\t\treturn {\n\t\t\t\tentity: this.storageEntityToModel(providerPidEntity),\n\t\t\t\trole: TransferProcessRole.Provider\n\t\t\t};\n\t\t}\n\n\t\tthrow new NotFoundError(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\"transferProcessNotFound\",\n\t\t\tpid,\n\t\t\t{\n\t\t\t\tpid\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Get raw policy entries from a catalog dataset.\n\t * @param catalogDataset Catalog dataset.\n\t * @returns Raw policy entries.\n\t * @internal\n\t */\n\tprivate getCatalogDatasetPolicies(\n\t\tcatalogDataset: IDcatDataset | IDataspaceProtocolDataset\n\t): JsonLdObjectWithNoContext<IDataspaceProtocolPolicy>[] {\n\t\t// Support both \"odrl:hasPolicy\" and \"hasPolicy\" to accommodate different catalog implementations\n\t\tif (Is.object<IDcatDataset>(catalogDataset) && !Is.empty(catalogDataset[\"odrl:hasPolicy\"])) {\n\t\t\tconst items = ArrayHelper.fromObjectOrArray(catalogDataset[\"odrl:hasPolicy\"]) ?? [];\n\t\t\treturn items.map(item => ({\n\t\t\t\t...item,\n\t\t\t\t\"@id\": OdrlPolicyHelper.getUid(item) ?? \"\"\n\t\t\t}));\n\t\t}\n\n\t\tif (\n\t\t\tIs.object<IDataspaceProtocolDataset>(catalogDataset) &&\n\t\t\t!Is.empty(catalogDataset.hasPolicy)\n\t\t) {\n\t\t\treturn ArrayHelper.fromObjectOrArray(catalogDataset.hasPolicy) ?? [];\n\t\t}\n\n\t\treturn [];\n\t}\n\n\t/**\n\t * Validate that the Agreement policies match at least one Catalog Offer.\n\t * @param agreement Agreement to validate.\n\t * @param catalogDataset Catalog dataset containing Offers.\n\t * @internal\n\t */\n\tprivate async validateAgreementMatchesOffer(\n\t\tagreement: IDataspaceProtocolAgreement,\n\t\tcatalogDataset: IDcatDataset\n\t): Promise<void> {\n\t\tGuards.object<IDataspaceProtocolAgreement>(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\tnameof(agreement),\n\t\t\tagreement\n\t\t);\n\t\tGuards.object<IDcatDataset>(\n\t\t\tDataspaceControlPlaneService.CLASS_NAME,\n\t\t\tnameof(catalogDataset),\n\t\t\tcatalogDataset\n\t\t);\n\n\t\tconst datasetId = getJsonLdId(catalogDataset);\n\t\tif (!Is.stringValue(datasetId)) {\n\t\t\tthrow new NotFoundError(DataspaceControlPlaneService.CLASS_NAME, \"catalogDatasetMissingId\");\n\t\t}\n\t\tconst rawOffers = this.getCatalogDatasetPolicies(catalogDataset);\n\n\t\tif (!Is.arrayValue(rawOffers)) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"catalogDatasetHasNoOffers\",\n\t\t\t\tdata: {\n\t\t\t\t\tdatasetId: getJsonLdId(catalogDataset) ?? \"\",\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst catalogOffers = rawOffers.filter(offer => Is.object<IDataspaceProtocolPolicy>(offer));\n\n\t\tif (!Is.arrayValue(catalogOffers)) {\n\t\t\tawait this._loggingComponent?.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"catalogDatasetHasNoOffers\",\n\t\t\t\tdata: {\n\t\t\t\t\tdatasetId: getJsonLdId(catalogDataset) ?? \"\",\n\t\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\"\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst matchingOffer = catalogOffers.find(\n\t\t\t(offer: IDataspaceProtocolPolicy) =>\n\t\t\t\tOdrlPolicyHelper.getUid(offer) === OdrlPolicyHelper.getUid(agreement) ||\n\t\t\t\tthis.isPolicyDerivedFrom(agreement, offer)\n\t\t);\n\n\t\tif (!matchingOffer) {\n\t\t\tthrow new GeneralError(DataspaceControlPlaneService.CLASS_NAME, \"agreementNotMatchingOffer\", {\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\",\n\t\t\t\tdatasetId: getJsonLdId(catalogDataset) ?? \"\",\n\t\t\t\tavailableOffers: catalogOffers\n\t\t\t\t\t.map((o: IDataspaceProtocolPolicy) => OdrlPolicyHelper.getUid(o) ?? \"unknown\")\n\t\t\t\t\t.join(\", \")\n\t\t\t});\n\t\t}\n\n\t\tawait this._loggingComponent?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceControlPlaneService.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"agreementMatchedOffer\",\n\t\t\tdata: {\n\t\t\t\tagreementId: OdrlPolicyHelper.getUid(agreement) ?? \"\",\n\t\t\t\tofferId: OdrlPolicyHelper.getUid(matchingOffer) ?? \"\",\n\t\t\t\tdatasetId\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Check if an Agreement is derived from an Offer.\n\t * Per the DS Protocol spec, Offers within a Dataset's hasPolicy array must NOT\n\t * include an explicit \"target\" property — the target is implicitly the Dataset itself.\n\t * When the offer has no explicit targets, we use the datasetId as the implicit target\n\t * so that the comparison with the agreement's target can succeed.\n\t * @param agreement Agreement to check.\n\t * @param offer Offer to compare against.\n\t * @returns True if Agreement appears derived from Offer.\n\t * @see https://eclipse-dataspace-protocol-base.github.io/DataspaceProtocol/2025-1-err1/#lower-level-types\n\t * @internal\n\t */\n\tprivate isPolicyDerivedFrom(\n\t\tagreement: IDataspaceProtocolAgreement,\n\t\toffer: IDataspaceProtocolPolicy\n\t): boolean {\n\t\tconst agreementTargets = OdrlPolicyHelper.getTargets(agreement);\n\t\tconst offerTargets = OdrlPolicyHelper.getTargets(offer);\n\n\t\tif (\n\t\t\tagreementTargets.length === 0 ||\n\t\t\tofferTargets.length === 0 ||\n\t\t\t!agreementTargets.some((agreementTarget: string) => offerTargets.includes(agreementTarget))\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst agreementAssignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(agreement);\n\t\tconst offerAssignerIdentity = OdrlPolicyHelper.extractAssignerIdentity(offer);\n\n\t\tconst agreementAssigner = ArrayHelper.fromObjectOrArray(agreementAssignerIdentity);\n\t\tconst offerAssigner = ArrayHelper.fromObjectOrArray(offerAssignerIdentity);\n\n\t\tif (!agreementAssigner.some(assigner => offerAssigner.includes(assigner))) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!Is.array(agreement.permission) || !Is.array(offer.permission)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Ensure the dataset has a publisher set.\n\t * @param dataset The dataset.\n\t * @returns The dataset with publisher set.\n\t * @internal\n\t */\n\tprivate async ensurePublisher(\n\t\tdataset: IDataspaceProtocolDataset\n\t): Promise<IDataspaceProtocolDataset> {\n\t\tif (dataset[\"dcterms:publisher\"]) {\n\t\t\treturn dataset;\n\t\t}\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst orgId = contextIds?.[ContextIdKeys.Organization];\n\n\t\tif (orgId) {\n\t\t\treturn {\n\t\t\t\t...dataset,\n\t\t\t\t\"dcterms:publisher\": orgId\n\t\t\t};\n\t\t}\n\n\t\treturn dataset;\n\t}\n}\n"]}
@@ -103,13 +103,14 @@ export declare class DataspaceControlPlaneService implements IDataspaceControlPl
103
103
  * Returns immediately with a negotiationId. The caller is notified
104
104
  * via the registered INegotiationCallback when the negotiation completes.
105
105
  *
106
+ * @param datasetId The dataset ID from the provider's catalog.
106
107
  * @param offerId The offer ID from the provider's catalog.
107
108
  * @param providerEndpoint The provider's contract negotiation endpoint URL.
108
109
  * @param publicOrigin The public origin URL of this control plane (for callbacks).
109
110
  * @param trustPayload The trust payload for authentication.
110
111
  * @returns The negotiation ID. Use the registered callback for completion notification.
111
112
  */
112
- negotiateAgreement(offerId: string, providerEndpoint: string, publicOrigin: string, trustPayload: unknown): Promise<{
113
+ negotiateAgreement(datasetId: string, offerId: string, providerEndpoint: string, publicOrigin: string, trustPayload: unknown): Promise<{
113
114
  negotiationId: string;
114
115
  }>;
115
116
  /**
package/docs/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.18](https://github.com/twinfoundation/dataspace/compare/dataspace-control-plane-service-v0.0.3-next.17...dataspace-control-plane-service-v0.0.3-next.18) (2026-03-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * resolve DSP transfer flow bugs for cross-node communication ([#76](https://github.com/twinfoundation/dataspace/issues/76)) ([506a45c](https://github.com/twinfoundation/dataspace/commit/506a45c94e63d5f958b1fc7131adfe452c3e2974))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/dataspace-models bumped from 0.0.3-next.17 to 0.0.3-next.18
16
+
3
17
  ## [0.0.3-next.17](https://github.com/twinfoundation/dataspace/compare/dataspace-control-plane-service-v0.0.3-next.16...dataspace-control-plane-service-v0.0.3-next.17) (2026-03-06)
4
18
 
5
19
 
@@ -372,7 +372,7 @@ Transfer Process (DSP compliant) with current state, or TransferError if the ope
372
372
 
373
373
  ### negotiateAgreement()
374
374
 
375
- > **negotiateAgreement**(`offerId`, `providerEndpoint`, `publicOrigin`, `trustPayload`): `Promise`\<\{ `negotiationId`: `string`; \}\>
375
+ > **negotiateAgreement**(`datasetId`, `offerId`, `providerEndpoint`, `publicOrigin`, `trustPayload`): `Promise`\<\{ `negotiationId`: `string`; \}\>
376
376
 
377
377
  Negotiate a contract agreement with a provider.
378
378
  Returns immediately with a negotiationId. The caller is notified
@@ -380,6 +380,12 @@ via the registered INegotiationCallback when the negotiation completes.
380
380
 
381
381
  #### Parameters
382
382
 
383
+ ##### datasetId
384
+
385
+ `string`
386
+
387
+ The dataset ID from the provider's catalog.
388
+
383
389
  ##### offerId
384
390
 
385
391
  `string`
package/locales/en.json CHANGED
@@ -86,7 +86,14 @@
86
86
  "datasetHasNoValidOffers": "Dataset \"{datasetId}\" has no valid ODRL offer objects. Cannot negotiate without a valid offer.",
87
87
  "offerNotFoundInDataset": "Offer \"{offerId}\" not found in dataset \"{datasetId}\". Available offers: {availableOffers}",
88
88
  "pnapNotConfigured": "Policy Negotiation Admin Point not configured. Cannot retrieve negotiation history without PNAP.",
89
- "negotiationCallbackError": "Negotiation callback \"{key}\" threw an error during {method} for negotiation {negotiationId}"
89
+ "negotiationCallbackError": "Negotiation callback \"{key}\" threw an error during {method} for negotiation {negotiationId}",
90
+ "catalogDatasetMissingId": "Catalog dataset is missing a required @id identifier",
91
+ "providerIdentityMissing": "Provider identity (DID) is required to sign data access tokens but was not set on the Transfer Process",
92
+ "callerNotAuthorizedForAgreement": "The caller's verified identity does not match the agreement assignee (consumer)",
93
+ "callerNotAuthorizedAsConsumer": "The caller's verified identity does not match the consumer for this transfer process",
94
+ "callerNotAuthorizedAsProvider": "The caller's verified identity does not match the provider for this transfer process",
95
+ "callerNotAuthorizedForTransfer": "The caller's verified identity does not match the consumer or provider for this transfer process",
96
+ "multipleAssignersNotSupported": "Multiple assigners found in agreement, which is not supported. Only single assigner agreements are supported."
90
97
  },
91
98
  "dataspaceControlPlanePolicyRequester": {}
92
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/dataspace-control-plane-service",
3
- "version": "0.0.3-next.17",
3
+ "version": "0.0.3-next.18",
4
4
  "description": "Dataspace Control Plane service implementation for Eclipse Dataspace Protocol Transfer Process Protocol",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "@twin.org/api-models": "next",
18
18
  "@twin.org/context": "next",
19
19
  "@twin.org/core": "next",
20
- "@twin.org/dataspace-models": "0.0.3-next.17",
20
+ "@twin.org/dataspace-models": "0.0.3-next.18",
21
21
  "@twin.org/entity": "next",
22
22
  "@twin.org/entity-storage-models": "next",
23
23
  "@twin.org/federated-catalogue-models": "next",