@sphereon/ssi-sdk.pd-manager-rest-api 0.34.1-fix.79 → 0.34.1-next.278

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -114,10 +114,11 @@ function pdPersistEndpoint(router, context, opts) {
114
114
  router.post(path, async (request, response) => {
115
115
  try {
116
116
  const addPd = request.body;
117
- const pd = await context.agent.pdmPersistDefinitionItem(addPd);
117
+ const pd = await context.agent.pdmPersistDefinition(addPd);
118
118
  response.statusCode = 200;
119
119
  return response.json(pd);
120
120
  } catch (error) {
121
+ console.error(error);
121
122
  return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
122
123
  }
123
124
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/pd-manager-api-server.ts","../src/api-functions.ts"],"sourcesContent":["export * from './types'\nexport * from './pd-manager-api-server'\nexport * from './api-functions'\n","import { agentContext } from '@sphereon/ssi-sdk.core'\nimport { TAgent } from '@veramo/core'\n\nimport express, { Express, Router } from 'express'\nimport { IPDManagerAPIEndpointOpts, IRequiredPlugins } from './types'\nimport { pdDeleteEndpoint, pdHasEndpoint, pdPersistEndpoint, pdReadEndpoint, pdsDeleteEndpoint, pdsReadEndpoint } from './api-functions'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\n\ntype PdManagerApiServerArgs = {\n agent: TAgent<IRequiredPlugins>\n expressSupport: ExpressSupport\n opts?: IPDManagerAPIEndpointOpts\n}\n\nexport class PdManagerApiServer {\n private readonly _express: Express\n private readonly _agent: TAgent<IRequiredPlugins>\n private readonly _opts?: IPDManagerAPIEndpointOpts\n private readonly _router: Router\n\n constructor(args: PdManagerApiServerArgs) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n if (opts?.endpointOpts?.globalAuth?.securePDManagerEndpoints) {\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n }\n this._opts = opts\n this._express = args.expressSupport.express\n this._router = express.Router()\n const context = agentContext(agent)\n const features = opts?.enableFeatures ?? ['pd_read', 'pd_write', 'pd_delete']\n console.log(`Presentation Definition API enabled, with features: ${JSON.stringify(features)}}`)\n\n // endpoints\n if (features.includes('pd_read')) {\n pdReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdHasEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdsReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n }\n if (features.includes('pd_write')) {\n pdPersistEndpoint(this.router, context, this._opts?.endpointOpts?.pdWrite)\n }\n if (features.includes('pd_delete')) {\n pdDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n pdsDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n }\n this._express.use(opts?.endpointOpts?.basePath ?? '', this.router)\n }\n\n get express(): Express {\n return this._express\n }\n\n get router(): Router {\n return this._router\n }\n\n get agent(): TAgent<IRequiredPlugins> {\n return this._agent\n }\n\n get opts(): IPDManagerAPIEndpointOpts | undefined {\n return this._opts\n }\n}\n","import { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { Request, Response, Router } from 'express'\nimport { IRequiredContext } from './types'\nimport { PersistDefinitionArgs } from '@sphereon/ssi-sdk.pd-manager'\nimport { DeleteDefinitionArgs } from '@sphereon/ssi-sdk.data-store'\n\nconst operation = '/presentation-definitions'\n\nexport function pdReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const pd = await context.agent.pdmGetDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdHasEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmHasDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdsReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // TODO Get all of them for now\n const pd = await context.agent.pdmGetDefinitions()\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdPersistEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdPersistEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.post(path, async (request: Request, response: Response) => {\n try {\n const addPd = request.body\n const pd = await context.agent.pdmPersistDefinitionItem(addPd as PersistDefinitionArgs)\n response.statusCode = 200 // TODO find out if pdmPersistDefinitionItem added or updated\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/:itemId`, async (request, response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmDeleteDefinition({ itemId: itemId } as DeleteDefinitionArgs)\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdsDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/filter`, async (request, response) => {\n try {\n // TODO we are not going to delete all PDs without filter like we did with pdsGet... Finish when filter is implemented\n response.statusCode = 500\n response.statusMessage = 'Not yet implemented'\n return sendErrorResponse(response, 500, 'Not yet implemented')\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;ACAA,qBAA6B;AAG7B,qBAAyC;;;ACHzC,iCAAkE;AAMlE,IAAMA,YAAY;AAEX,SAASC,eAAeC,QAAgBC,SAA2BC,MAA0B;AAClG,MAAIA,MAAMC,YAAY,OAAO;AAC3BC,YAAQC,IAAI,uCAAuC;AACnD;EACF;AACA,QAAMC,OAAOJ,MAAMI,QAAQR;AAC3BE,SAAOO,IAAI,GAAGD,IAAAA,gBAAgBE,sCAAUN,MAAMO,QAAAA,GAAW,OAAOC,SAAkBC,aAAAA;AAChF,QAAI;AACF,YAAMC,SAASF,QAAQG,OAAOD;AAC9B,YAAME,KAAK,MAAMb,QAAQc,MAAMC,iBAAiB;QAAEJ;MAAe,CAAA;AACjED,eAASM,aAAa;AACtB,aAAON,SAASO,KAAKJ,EAAAA;IACvB,SAASK,OAAO;AACd,iBAAOC,8CAAkBT,UAAU,KAAKQ,MAAME,SAAmBF,KAAAA;IACnE;EACF,CAAA;AACF;AAhBgBpB;AAkBT,SAASuB,cAActB,QAAgBC,SAA2BC,MAA0B;AACjG,MA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;AACpC,WAAO,KAAKL;EACd;EAEA,IAAIM,OAA8C;AAChD,WAAO,KAAKL;EACd;AACF;","names":["operation","pdReadEndpoint","router","context","opts","enabled","console","log","path","get","checkAuth","endpoint","request","response","itemId","params","pd","agent","pdmGetDefinition","statusCode","json","error","sendErrorResponse","message","pdHasEndpoint","result","pdmHasDefinition","pdsReadEndpoint","pdmGetDefinitions","pdPersistEndpoint","post","addPd","body","pdmPersistDefinitionItem","pdDeleteEndpoint","delete","pdmDeleteDefinition","pdsDeleteEndpoint","statusMessage","import_ssi_express_support","PdManagerApiServer","_express","_agent","_opts","_router","constructor","args","agent","opts","copyGlobalAuthToEndpoints","keys","endpointOpts","globalAuth","securePDManagerEndpoints","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","pdReadEndpoint","router","pdRead","pdHasEndpoint","pdsReadEndpoint","pdPersistEndpoint","pdWrite","pdDeleteEndpoint","pdDelete","pdsDeleteEndpoint","use","basePath"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/pd-manager-api-server.ts","../src/api-functions.ts"],"sourcesContent":["export * from './types'\nexport * from './pd-manager-api-server'\nexport * from './api-functions'\n","import { agentContext } from '@sphereon/ssi-sdk.core'\nimport { TAgent } from '@veramo/core'\n\nimport express, { Express, Router } from 'express'\nimport { IPDManagerAPIEndpointOpts, IRequiredPlugins } from './types'\nimport { pdDeleteEndpoint, pdHasEndpoint, pdPersistEndpoint, pdReadEndpoint, pdsDeleteEndpoint, pdsReadEndpoint } from './api-functions'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\n\ntype PdManagerApiServerArgs = {\n agent: TAgent<IRequiredPlugins>\n expressSupport: ExpressSupport\n opts?: IPDManagerAPIEndpointOpts\n}\n\nexport class PdManagerApiServer {\n private readonly _express: Express\n private readonly _agent: TAgent<IRequiredPlugins>\n private readonly _opts?: IPDManagerAPIEndpointOpts\n private readonly _router: Router\n\n constructor(args: PdManagerApiServerArgs) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n if (opts?.endpointOpts?.globalAuth?.securePDManagerEndpoints) {\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n }\n this._opts = opts\n this._express = args.expressSupport.express\n this._router = express.Router()\n const context = agentContext(agent)\n const features = opts?.enableFeatures ?? ['pd_read', 'pd_write', 'pd_delete']\n console.log(`Presentation Definition API enabled, with features: ${JSON.stringify(features)}}`)\n\n // endpoints\n if (features.includes('pd_read')) {\n pdReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdHasEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdsReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n }\n if (features.includes('pd_write')) {\n pdPersistEndpoint(this.router, context, this._opts?.endpointOpts?.pdWrite)\n }\n if (features.includes('pd_delete')) {\n pdDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n pdsDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n }\n this._express.use(opts?.endpointOpts?.basePath ?? '', this.router)\n }\n\n get express(): Express {\n return this._express\n }\n\n get router(): Router {\n return this._router\n }\n\n get agent(): TAgent<IRequiredPlugins> {\n return this._agent\n }\n\n get opts(): IPDManagerAPIEndpointOpts | undefined {\n return this._opts\n }\n}\n","import { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { Request, Response, Router } from 'express'\nimport { IRequiredContext } from './types'\nimport { PersistDcqlQueryArgs } from '@sphereon/ssi-sdk.pd-manager'\nimport { DeleteDefinitionArgs } from '@sphereon/ssi-sdk.data-store-types'\n\nconst operation = '/presentation-definitions'\n\nexport function pdReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const pd = await context.agent.pdmGetDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdHasEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmHasDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdsReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // TODO Get all of them for now\n const pd = await context.agent.pdmGetDefinitions()\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdPersistEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdPersistEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.post(path, async (request: Request, response: Response) => {\n try {\n const addPd = request.body\n const pd = await context.agent.pdmPersistDefinition(addPd as PersistDcqlQueryArgs)\n response.statusCode = 200 // TODO find out if pdmPersistDefinitionItem added or updated\n return response.json(pd)\n } catch (error) {\n console.error(error)\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/:itemId`, async (request, response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmDeleteDefinition({ itemId: itemId } as DeleteDefinitionArgs)\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdsDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/filter`, async (request, response) => {\n try {\n // TODO we are not going to delete all PDs without filter like we did with pdsGet... Finish when filter is implemented\n response.statusCode = 500\n response.statusMessage = 'Not yet implemented'\n return sendErrorResponse(response, 500, 'Not yet implemented')\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;ACAA,qBAA6B;AAG7B,qBAAyC;;;ACHzC,iCAAkE;AAMlE,IAAMA,YAAY;AAEX,SAASC,eAAeC,QAAgBC,SAA2BC,MAA0B;AAClG,MAAIA,MAAMC,YAAY,OAAO;AAC3BC,YAAQC,IAAI,uCAAuC;AACnD;EACF;AACA,QAAMC,OAAOJ,MAAMI,QAAQR;AAC3BE,SAAOO,IAAI,GAAGD,IAAAA,gBAAgBE,sCAAUN,MAAMO,QAAAA,GAAW,OAAOC,SAAkBC,aAAAA;AAChF,QAAI;AACF,YAAMC,SAASF,QAAQG,OAAOD;AAC9B,YAAME,KAAK,MAAMb,QAAQc,MAAMC,iBAAiB;QAAEJ;MAAe,CAAA;AACjED,eAASM,aAAa;AACtB,aAAON,SAASO,KAAKJ,EAAAA;IACvB,SAASK,OAAO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I5B,MAAMG,cAAc0B,YAAY,IAAI,KAAKV,MAAM;EACnE;EAEA,IAAIZ,UAAmB;AACrB,WAAO,KAAKb;EACd;EAEA,IAAIyB,SAAiB;AACnB,WAAO,KAAKtB;EACd;EAEA,IAAIE,QAAkC;AACpC,WAAO,KAAKJ;EACd;EAEA,IAAIK,OAA8C;AAChD,WAAO,KAAKJ;EACd;AACF;","names":["operation","pdReadEndpoint","router","context","opts","enabled","console","log","path","get","checkAuth","endpoint","request","response","itemId","params","pd","agent","pdmGetDefinition","statusCode","json","error","sendErrorResponse","message","pdHasEndpoint","result","pdmHasDefinition","pdsReadEndpoint","pdmGetDefinitions","pdPersistEndpoint","post","addPd","body","pdmPersistDefinition","pdDeleteEndpoint","delete","pdmDeleteDefinition","pdsDeleteEndpoint","statusMessage","import_ssi_express_support","PdManagerApiServer","_express","_agent","_opts","_router","args","agent","opts","copyGlobalAuthToEndpoints","keys","endpointOpts","globalAuth","securePDManagerEndpoints","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","pdReadEndpoint","router","pdRead","pdHasEndpoint","pdsReadEndpoint","pdPersistEndpoint","pdWrite","pdDeleteEndpoint","pdDelete","pdsDeleteEndpoint","use","basePath"]}
package/dist/index.js CHANGED
@@ -74,10 +74,11 @@ function pdPersistEndpoint(router, context, opts) {
74
74
  router.post(path, async (request, response) => {
75
75
  try {
76
76
  const addPd = request.body;
77
- const pd = await context.agent.pdmPersistDefinitionItem(addPd);
77
+ const pd = await context.agent.pdmPersistDefinition(addPd);
78
78
  response.statusCode = 200;
79
79
  return response.json(pd);
80
80
  } catch (error) {
81
+ console.error(error);
81
82
  return sendErrorResponse(response, 500, error.message, error);
82
83
  }
83
84
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/pd-manager-api-server.ts","../src/api-functions.ts"],"sourcesContent":["import { agentContext } from '@sphereon/ssi-sdk.core'\nimport { TAgent } from '@veramo/core'\n\nimport express, { Express, Router } from 'express'\nimport { IPDManagerAPIEndpointOpts, IRequiredPlugins } from './types'\nimport { pdDeleteEndpoint, pdHasEndpoint, pdPersistEndpoint, pdReadEndpoint, pdsDeleteEndpoint, pdsReadEndpoint } from './api-functions'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\n\ntype PdManagerApiServerArgs = {\n agent: TAgent<IRequiredPlugins>\n expressSupport: ExpressSupport\n opts?: IPDManagerAPIEndpointOpts\n}\n\nexport class PdManagerApiServer {\n private readonly _express: Express\n private readonly _agent: TAgent<IRequiredPlugins>\n private readonly _opts?: IPDManagerAPIEndpointOpts\n private readonly _router: Router\n\n constructor(args: PdManagerApiServerArgs) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n if (opts?.endpointOpts?.globalAuth?.securePDManagerEndpoints) {\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n }\n this._opts = opts\n this._express = args.expressSupport.express\n this._router = express.Router()\n const context = agentContext(agent)\n const features = opts?.enableFeatures ?? ['pd_read', 'pd_write', 'pd_delete']\n console.log(`Presentation Definition API enabled, with features: ${JSON.stringify(features)}}`)\n\n // endpoints\n if (features.includes('pd_read')) {\n pdReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdHasEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdsReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n }\n if (features.includes('pd_write')) {\n pdPersistEndpoint(this.router, context, this._opts?.endpointOpts?.pdWrite)\n }\n if (features.includes('pd_delete')) {\n pdDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n pdsDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n }\n this._express.use(opts?.endpointOpts?.basePath ?? '', this.router)\n }\n\n get express(): Express {\n return this._express\n }\n\n get router(): Router {\n return this._router\n }\n\n get agent(): TAgent<IRequiredPlugins> {\n return this._agent\n }\n\n get opts(): IPDManagerAPIEndpointOpts | undefined {\n return this._opts\n }\n}\n","import { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { Request, Response, Router } from 'express'\nimport { IRequiredContext } from './types'\nimport { PersistDefinitionArgs } from '@sphereon/ssi-sdk.pd-manager'\nimport { DeleteDefinitionArgs } from '@sphereon/ssi-sdk.data-store'\n\nconst operation = '/presentation-definitions'\n\nexport function pdReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const pd = await context.agent.pdmGetDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdHasEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmHasDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdsReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // TODO Get all of them for now\n const pd = await context.agent.pdmGetDefinitions()\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdPersistEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdPersistEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.post(path, async (request: Request, response: Response) => {\n try {\n const addPd = request.body\n const pd = await context.agent.pdmPersistDefinitionItem(addPd as PersistDefinitionArgs)\n response.statusCode = 200 // TODO find out if pdmPersistDefinitionItem added or updated\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/:itemId`, async (request, response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmDeleteDefinition({ itemId: itemId } as DeleteDefinitionArgs)\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdsDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/filter`, async (request, response) => {\n try {\n // TODO we are not going to delete all PDs without filter like we did with pdsGet... Finish when filter is implemented\n response.statusCode = 500\n response.statusMessage = 'Not yet implemented'\n return sendErrorResponse(response, 500, 'Not yet implemented')\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n"],"mappings":";;;;AAAA,SAASA,oBAAoB;AAG7B,OAAOC,aAAkC;;;ACHzC,SAASC,WAAgCC,yBAAyB;AAMlE,IAAMC,YAAY;AAEX,SAASC,eAAeC,QAAgBC,SAA2BC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SAAS,KAAKd,OAAOQ,cAAciB,MAAAA;IAClE;AACA,QAAIT,SAASM,SAAS,UAAA,GAAa;AACjCM,wBAAkB,KAAKJ,QAAQV,SAAS,KAAKd,OAAOQ,cAAcqB,OAAAA;IACpE;AACA,QAAIb,SAASM,SAAS,WAAA,GAAc;AAClCQ,uBAAiB,KAAKN,QAAQV,SAAS,KAAKd,OAAOQ,cAAcuB,QAAAA;AACjEC,wBAAkB,KAAKR,QAAQV,SAAS,KAAKd,OAAOQ,cAAcuB,QAAAA;IACpE;AACA,SAAKjC,SAASmC,IAAI5B,MAAMG,cAAc0B,YAAY,IAAI,KAAKV,MAAM;EACnE;EAEA,IAAIZ,UAAmB;AACrB,WAAO,KAAKd;EACd;EAEA,IAAI0B,SAAiB;AACnB,WAAO,KAAKvB;EACd;EAEA,IAAIG,QAAkC;AACpC,WAAO,KAAKL;EACd;EAEA,IAAIM,OAA8C;AAChD,WAAO,KAAKL;EACd;AACF;","names":["agentContext","express","checkAuth","sendErrorResponse","operation","pdReadEndpoint","router","context","opts","enabled","console","log","path","get","checkAuth","endpoint","request","response","itemId","params","pd","agent","pdmGetDefinition","statusCode","json","error","sendErrorResponse","message","pdHasEndpoint","result","pdmHasDefinition","pdsReadEndpoint","pdmGetDefinitions","pdPersistEndpoint","post","addPd","body","pdmPersistDefinitionItem","pdDeleteEndpoint","delete","pdmDeleteDefinition","pdsDeleteEndpoint","statusMessage","copyGlobalAuthToEndpoints","PdManagerApiServer","_express","_agent","_opts","_router","constructor","args","agent","opts","copyGlobalAuthToEndpoints","keys","endpointOpts","globalAuth","securePDManagerEndpoints","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","pdReadEndpoint","router","pdRead","pdHasEndpoint","pdsReadEndpoint","pdPersistEndpoint","pdWrite","pdDeleteEndpoint","pdDelete","pdsDeleteEndpoint","use","basePath"]}
1
+ {"version":3,"sources":["../src/pd-manager-api-server.ts","../src/api-functions.ts"],"sourcesContent":["import { agentContext } from '@sphereon/ssi-sdk.core'\nimport { TAgent } from '@veramo/core'\n\nimport express, { Express, Router } from 'express'\nimport { IPDManagerAPIEndpointOpts, IRequiredPlugins } from './types'\nimport { pdDeleteEndpoint, pdHasEndpoint, pdPersistEndpoint, pdReadEndpoint, pdsDeleteEndpoint, pdsReadEndpoint } from './api-functions'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\n\ntype PdManagerApiServerArgs = {\n agent: TAgent<IRequiredPlugins>\n expressSupport: ExpressSupport\n opts?: IPDManagerAPIEndpointOpts\n}\n\nexport class PdManagerApiServer {\n private readonly _express: Express\n private readonly _agent: TAgent<IRequiredPlugins>\n private readonly _opts?: IPDManagerAPIEndpointOpts\n private readonly _router: Router\n\n constructor(args: PdManagerApiServerArgs) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n if (opts?.endpointOpts?.globalAuth?.securePDManagerEndpoints) {\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n }\n this._opts = opts\n this._express = args.expressSupport.express\n this._router = express.Router()\n const context = agentContext(agent)\n const features = opts?.enableFeatures ?? ['pd_read', 'pd_write', 'pd_delete']\n console.log(`Presentation Definition API enabled, with features: ${JSON.stringify(features)}}`)\n\n // endpoints\n if (features.includes('pd_read')) {\n pdReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdHasEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdsReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n }\n if (features.includes('pd_write')) {\n pdPersistEndpoint(this.router, context, this._opts?.endpointOpts?.pdWrite)\n }\n if (features.includes('pd_delete')) {\n pdDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n pdsDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n }\n this._express.use(opts?.endpointOpts?.basePath ?? '', this.router)\n }\n\n get express(): Express {\n return this._express\n }\n\n get router(): Router {\n return this._router\n }\n\n get agent(): TAgent<IRequiredPlugins> {\n return this._agent\n }\n\n get opts(): IPDManagerAPIEndpointOpts | undefined {\n return this._opts\n }\n}\n","import { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { Request, Response, Router } from 'express'\nimport { IRequiredContext } from './types'\nimport { PersistDcqlQueryArgs } from '@sphereon/ssi-sdk.pd-manager'\nimport { DeleteDefinitionArgs } from '@sphereon/ssi-sdk.data-store-types'\n\nconst operation = '/presentation-definitions'\n\nexport function pdReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const pd = await context.agent.pdmGetDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdHasEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmHasDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdsReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // TODO Get all of them for now\n const pd = await context.agent.pdmGetDefinitions()\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdPersistEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdPersistEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.post(path, async (request: Request, response: Response) => {\n try {\n const addPd = request.body\n const pd = await context.agent.pdmPersistDefinition(addPd as PersistDcqlQueryArgs)\n response.statusCode = 200 // TODO find out if pdmPersistDefinitionItem added or updated\n return response.json(pd)\n } catch (error) {\n console.error(error)\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/:itemId`, async (request, response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmDeleteDefinition({ itemId: itemId } as DeleteDefinitionArgs)\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdsDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/filter`, async (request, response) => {\n try {\n // TODO we are not going to delete all PDs without filter like we did with pdsGet... Finish when filter is implemented\n response.statusCode = 500\n response.statusMessage = 'Not yet implemented'\n return sendErrorResponse(response, 500, 'Not yet implemented')\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n"],"mappings":";;;;AAAA,SAASA,oBAAoB;AAG7B,OAAOC,aAAkC;;;ACHzC,SAASC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AAC/DC,oBAAc,KAAKF,QAAQV,SAAS,KAAKb,OAAOO,cAAciB,MAAAA;AAC9DE,sBAAgB,KAAKH,QAAQV,SAAS,KAAKb,OAAOO,cAAciB,MAAAA;IAClE;AACA,QAAIT,SAASM,SAAS,UAAA,GAAa;AACjCM,wBAAkB,KAAKJ,QAAQV,SAAS,KAAKb,OAAOO,cAAcqB,OAAAA;IACpE;AACA,QAAIb,SAASM,SAAS,WAAA,GAAc;AAClCQ,uBAAiB,KAAKN,QAAQV,SAAS,KAAKb,OAAOO,cAAcuB,QAAAA;AACjEC,wBAAkB,KAAKR,QAAQV,SAAS,KAAKb,OAAOO,cAAcuB,QAAAA;IACpE;AACA,SAAKhC,SAASkC,IAAI5B,MAAMG,cAAc0B,YAAY,IAAI,KAAKV,MAAM;EACnE;EAEA,IAAIZ,UAAmB;AACrB,WAAO,KAAKb;EACd;EAEA,IAAIyB,SAAiB;AACnB,WAAO,KAAKtB;EACd;EAEA,IAAIE,QAAkC;AACpC,WAAO,KAAKJ;EACd;EAEA,IAAIK,OAA8C;AAChD,WAAO,KAAKJ;EACd;AACF;","names":["agentContext","express","checkAuth","sendErrorResponse","operation","pdReadEndpoint","router","context","opts","enabled","console","log","path","get","checkAuth","endpoint","request","response","itemId","params","pd","agent","pdmGetDefinition","statusCode","json","error","sendErrorResponse","message","pdHasEndpoint","result","pdmHasDefinition","pdsReadEndpoint","pdmGetDefinitions","pdPersistEndpoint","post","addPd","body","pdmPersistDefinition","pdDeleteEndpoint","delete","pdmDeleteDefinition","pdsDeleteEndpoint","statusMessage","copyGlobalAuthToEndpoints","PdManagerApiServer","_express","_agent","_opts","_router","args","agent","opts","copyGlobalAuthToEndpoints","keys","endpointOpts","globalAuth","securePDManagerEndpoints","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","pdReadEndpoint","router","pdRead","pdHasEndpoint","pdsReadEndpoint","pdPersistEndpoint","pdWrite","pdDeleteEndpoint","pdDelete","pdsDeleteEndpoint","use","basePath"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.pd-manager-rest-api",
3
- "version": "0.34.1-fix.79+d10eff80",
3
+ "version": "0.34.1-next.278+0eacb25b",
4
4
  "source": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -23,11 +23,12 @@
23
23
  "start:dev": "ts-node __tests__/RestAPI.ts"
24
24
  },
25
25
  "dependencies": {
26
- "@sphereon/ssi-express-support": "0.34.1-fix.79+d10eff80",
27
- "@sphereon/ssi-sdk.core": "0.34.1-fix.79+d10eff80",
28
- "@sphereon/ssi-sdk.data-store": "0.34.1-fix.79+d10eff80",
29
- "@sphereon/ssi-sdk.pd-manager": "0.34.1-fix.79+d10eff80",
30
- "@sphereon/ssi-types": "0.34.1-fix.79+d10eff80",
26
+ "@sphereon/ssi-express-support": "0.34.1-next.278+0eacb25b",
27
+ "@sphereon/ssi-sdk.core": "0.34.1-next.278+0eacb25b",
28
+ "@sphereon/ssi-sdk.data-store": "0.34.1-next.278+0eacb25b",
29
+ "@sphereon/ssi-sdk.data-store-types": "0.34.1-next.278+0eacb25b",
30
+ "@sphereon/ssi-sdk.pd-manager": "0.34.1-next.278+0eacb25b",
31
+ "@sphereon/ssi-types": "0.34.1-next.278+0eacb25b",
31
32
  "@veramo/core": "4.2.0",
32
33
  "body-parser": "^1.20.2",
33
34
  "casbin": "^5.30.0",
@@ -42,7 +43,7 @@
42
43
  },
43
44
  "devDependencies": {
44
45
  "@decentralized-identity/ion-sdk": "^0.6.0",
45
- "@sphereon/ssi-sdk.agent-config": "0.34.1-fix.79+d10eff80",
46
+ "@sphereon/ssi-sdk.agent-config": "0.34.1-next.278+0eacb25b",
46
47
  "@types/body-parser": "^1.19.5",
47
48
  "@types/cookie-parser": "^1.4.7",
48
49
  "@types/cors": "^2.8.17",
@@ -90,5 +91,5 @@
90
91
  "pd-management",
91
92
  "presentation-definition-management"
92
93
  ],
93
- "gitHead": "d10eff8075537d257b9ec2188eed2c60315a5ce7"
94
+ "gitHead": "0eacb25b6e38cef88d04d696d84e3c2ebcf89ede"
94
95
  }
@@ -1,8 +1,8 @@
1
1
  import { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'
2
2
  import { Request, Response, Router } from 'express'
3
3
  import { IRequiredContext } from './types'
4
- import { PersistDefinitionArgs } from '@sphereon/ssi-sdk.pd-manager'
5
- import { DeleteDefinitionArgs } from '@sphereon/ssi-sdk.data-store'
4
+ import { PersistDcqlQueryArgs } from '@sphereon/ssi-sdk.pd-manager'
5
+ import { DeleteDefinitionArgs } from '@sphereon/ssi-sdk.data-store-types'
6
6
 
7
7
  const operation = '/presentation-definitions'
8
8
 
@@ -69,10 +69,11 @@ export function pdPersistEndpoint(router: Router, context: IRequiredContext, opt
69
69
  router.post(path, async (request: Request, response: Response) => {
70
70
  try {
71
71
  const addPd = request.body
72
- const pd = await context.agent.pdmPersistDefinitionItem(addPd as PersistDefinitionArgs)
72
+ const pd = await context.agent.pdmPersistDefinition(addPd as PersistDcqlQueryArgs)
73
73
  response.statusCode = 200 // TODO find out if pdmPersistDefinitionItem added or updated
74
74
  return response.json(pd)
75
75
  } catch (error) {
76
+ console.error(error)
76
77
  return sendErrorResponse(response, 500, error.message, error)
77
78
  }
78
79
  })