@twin.org/rights-management-service 0.0.2-next.4 → 0.0.2-next.6
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/cjs/index.cjs +561 -211
- package/dist/esm/index.mjs +548 -210
- package/dist/types/index.d.ts +4 -3
- package/dist/types/{rightsManagementRoutes.d.ts → policyAdministrationPointRoutes.d.ts} +6 -14
- package/dist/types/policyEnforcementPointRoutes.d.ts +21 -0
- package/dist/types/policyNegotiationAdminPointRoutes.d.ts +45 -0
- package/dist/types/policyNegotiationPointRoutes.d.ts +37 -0
- package/docs/changelog.md +46 -0
- package/docs/open-api/spec.json +1198 -162
- package/docs/reference/functions/generateRestRoutesPolicyAdministrationPoint.md +25 -0
- package/docs/reference/functions/{generateRestRoutesRightsManagement.md → generateRestRoutesPolicyEnforcementPoint.md} +3 -3
- package/docs/reference/functions/generateRestRoutesPolicyNegotiationAdminPoint.md +25 -0
- package/docs/reference/functions/generateRestRoutesPolicyNegotiationPoint.md +25 -0
- package/docs/reference/functions/{papRetrieve.md → papGet.md} +5 -5
- package/docs/reference/functions/pnapGet.md +31 -0
- package/docs/reference/functions/pnapQuery.md +31 -0
- package/docs/reference/functions/pnapRemove.md +31 -0
- package/docs/reference/functions/pnapSet.md +31 -0
- package/docs/reference/functions/pnpNegotiate.md +31 -0
- package/docs/reference/functions/pnpNegotiationCancel.md +31 -0
- package/docs/reference/functions/pnpNegotiationState.md +31 -0
- package/docs/reference/index.md +16 -11
- package/docs/reference/variables/papTags.md +5 -0
- package/docs/reference/variables/pepTags.md +5 -0
- package/docs/reference/variables/pnapTags.md +5 -0
- package/docs/reference/variables/pnpTags.md +5 -0
- package/locales/en.json +1 -11
- package/package.json +4 -2
- package/dist/types/models/IRightsManagementServiceConstructorOptions.d.ts +0 -15
- package/dist/types/rightsManagementService.d.ts +0 -64
- package/docs/reference/classes/RightsManagementService.md +0 -238
- package/docs/reference/interfaces/IRightsManagementServiceConstructorOptions.md +0 -31
- package/docs/reference/variables/tags.md +0 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -10,27 +10,27 @@ var web = require('@twin.org/web');
|
|
|
10
10
|
/**
|
|
11
11
|
* The source used when communicating about these routes.
|
|
12
12
|
*/
|
|
13
|
-
const ROUTES_SOURCE = "
|
|
13
|
+
const ROUTES_SOURCE$3 = "policyAdministrationPointRoutes";
|
|
14
14
|
/**
|
|
15
15
|
* The tag to associate with the routes.
|
|
16
16
|
*/
|
|
17
|
-
const
|
|
17
|
+
const papTags = [
|
|
18
18
|
{
|
|
19
19
|
name: "Policy Administration Point",
|
|
20
20
|
description: "Endpoints for managing ODRL policies in the Policy Administration Point"
|
|
21
21
|
}
|
|
22
22
|
];
|
|
23
23
|
/**
|
|
24
|
-
* The REST routes for the
|
|
24
|
+
* The REST routes for the Policy Administration Point.
|
|
25
25
|
* @param baseRouteName Prefix to prepend to the paths.
|
|
26
26
|
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
27
27
|
* @returns The generated routes.
|
|
28
28
|
*/
|
|
29
|
-
function
|
|
30
|
-
const
|
|
29
|
+
function generateRestRoutesPolicyAdministrationPoint(baseRouteName, componentName) {
|
|
30
|
+
const papCreateRoute = {
|
|
31
31
|
operationId: "papCreate",
|
|
32
32
|
summary: "Create a policy",
|
|
33
|
-
tag:
|
|
33
|
+
tag: papTags[0].name,
|
|
34
34
|
method: "POST",
|
|
35
35
|
path: `${baseRouteName}/pap/`,
|
|
36
36
|
handler: async (httpRequestContext, request) => papCreate(httpRequestContext, componentName, request),
|
|
@@ -38,7 +38,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
38
38
|
type: "IPapCreateRequest",
|
|
39
39
|
examples: [
|
|
40
40
|
{
|
|
41
|
-
id: "
|
|
41
|
+
id: "papCreateRequestExample",
|
|
42
42
|
request: {
|
|
43
43
|
body: {
|
|
44
44
|
"@context": standardsW3cOdrl.OdrlContexts.ContextRoot,
|
|
@@ -71,10 +71,10 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
71
71
|
}
|
|
72
72
|
]
|
|
73
73
|
};
|
|
74
|
-
const
|
|
74
|
+
const papUpdateRoute = {
|
|
75
75
|
operationId: "papUpdate",
|
|
76
76
|
summary: "Update a policy",
|
|
77
|
-
tag:
|
|
77
|
+
tag: papTags[0].name,
|
|
78
78
|
method: "PUT",
|
|
79
79
|
path: `${baseRouteName}/pap/:id`,
|
|
80
80
|
handler: async (httpRequestContext, request) => papUpdate(httpRequestContext, componentName, request),
|
|
@@ -82,7 +82,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
82
82
|
type: "IPapUpdateRequest",
|
|
83
83
|
examples: [
|
|
84
84
|
{
|
|
85
|
-
id: "
|
|
85
|
+
id: "papUpdateRequestExample",
|
|
86
86
|
request: {
|
|
87
87
|
pathParams: {
|
|
88
88
|
id: "urn:rights-management:abc123def456"
|
|
@@ -108,18 +108,18 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
108
108
|
}
|
|
109
109
|
]
|
|
110
110
|
};
|
|
111
|
-
const
|
|
112
|
-
operationId: "
|
|
113
|
-
summary: "
|
|
114
|
-
tag:
|
|
111
|
+
const papGetRoute = {
|
|
112
|
+
operationId: "papGet",
|
|
113
|
+
summary: "Get a policy",
|
|
114
|
+
tag: papTags[0].name,
|
|
115
115
|
method: "GET",
|
|
116
116
|
path: `${baseRouteName}/pap/:id`,
|
|
117
|
-
handler: async (httpRequestContext, request) =>
|
|
117
|
+
handler: async (httpRequestContext, request) => papGet(httpRequestContext, componentName, request),
|
|
118
118
|
requestType: {
|
|
119
|
-
type: "
|
|
119
|
+
type: "IPapGetRequest",
|
|
120
120
|
examples: [
|
|
121
121
|
{
|
|
122
|
-
id: "
|
|
122
|
+
id: "papGetRequestExample",
|
|
123
123
|
request: {
|
|
124
124
|
pathParams: {
|
|
125
125
|
id: "urn:rights-management:abc123def456"
|
|
@@ -130,10 +130,10 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
130
130
|
},
|
|
131
131
|
responseType: [
|
|
132
132
|
{
|
|
133
|
-
type: "
|
|
133
|
+
type: "IPapGetResponse",
|
|
134
134
|
examples: [
|
|
135
135
|
{
|
|
136
|
-
id: "
|
|
136
|
+
id: "papGetResponseExample",
|
|
137
137
|
response: {
|
|
138
138
|
body: {
|
|
139
139
|
"@context": standardsW3cOdrl.OdrlContexts.ContextRoot,
|
|
@@ -152,10 +152,10 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
152
152
|
}
|
|
153
153
|
]
|
|
154
154
|
};
|
|
155
|
-
const
|
|
155
|
+
const papRemoveRoute = {
|
|
156
156
|
operationId: "papRemove",
|
|
157
157
|
summary: "Remove a policy",
|
|
158
|
-
tag:
|
|
158
|
+
tag: papTags[0].name,
|
|
159
159
|
method: "DELETE",
|
|
160
160
|
path: `${baseRouteName}/pap/:id`,
|
|
161
161
|
handler: async (httpRequestContext, request) => papRemove(httpRequestContext, componentName, request),
|
|
@@ -163,7 +163,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
163
163
|
type: "IPapRemoveRequest",
|
|
164
164
|
examples: [
|
|
165
165
|
{
|
|
166
|
-
id: "
|
|
166
|
+
id: "papRemoveRequestExample",
|
|
167
167
|
request: {
|
|
168
168
|
pathParams: {
|
|
169
169
|
id: "urn:rights-management:abc123def456"
|
|
@@ -178,10 +178,10 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
178
178
|
}
|
|
179
179
|
]
|
|
180
180
|
};
|
|
181
|
-
const
|
|
181
|
+
const papQueryRoute = {
|
|
182
182
|
operationId: "papQuery",
|
|
183
183
|
summary: "Query policies",
|
|
184
|
-
tag:
|
|
184
|
+
tag: papTags[0].name,
|
|
185
185
|
method: "GET",
|
|
186
186
|
path: `${baseRouteName}/pap/query`,
|
|
187
187
|
handler: async (httpRequestContext, request) => papQuery(httpRequestContext, componentName, request),
|
|
@@ -189,7 +189,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
189
189
|
type: "IPapQueryRequest",
|
|
190
190
|
examples: [
|
|
191
191
|
{
|
|
192
|
-
id: "
|
|
192
|
+
id: "papQueryRequestExample",
|
|
193
193
|
request: {
|
|
194
194
|
query: {
|
|
195
195
|
cursor: "optional-pagination-cursor"
|
|
@@ -227,10 +227,123 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
227
227
|
}
|
|
228
228
|
]
|
|
229
229
|
};
|
|
230
|
-
|
|
230
|
+
return [papCreateRoute, papUpdateRoute, papGetRoute, papRemoveRoute, papQueryRoute];
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* PAP: Create a policy.
|
|
234
|
+
* @param httpRequestContext The request context for the API.
|
|
235
|
+
* @param componentName The name of the component to use in the routes.
|
|
236
|
+
* @param request The request.
|
|
237
|
+
* @returns The response object with additional http response properties.
|
|
238
|
+
*/
|
|
239
|
+
async function papCreate(httpRequestContext, componentName, request) {
|
|
240
|
+
core.Guards.object(ROUTES_SOURCE$3, "request", request);
|
|
241
|
+
core.Guards.object(ROUTES_SOURCE$3, "request.body", request.body);
|
|
242
|
+
const component = core.ComponentFactory.get(componentName);
|
|
243
|
+
const policy = request.body;
|
|
244
|
+
const uid = await component.create(policy);
|
|
245
|
+
return {
|
|
246
|
+
statusCode: web.HttpStatusCode.created,
|
|
247
|
+
headers: {
|
|
248
|
+
location: uid
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* PAP: Update a policy.
|
|
254
|
+
* @param httpRequestContext The request context for the API.
|
|
255
|
+
* @param componentName The name of the component to use in the routes.
|
|
256
|
+
* @param request The request.
|
|
257
|
+
* @returns The response object with additional http response properties.
|
|
258
|
+
*/
|
|
259
|
+
async function papUpdate(httpRequestContext, componentName, request) {
|
|
260
|
+
core.Guards.object(ROUTES_SOURCE$3, "request", request);
|
|
261
|
+
core.Guards.object(ROUTES_SOURCE$3, "request.pathParams", request.pathParams);
|
|
262
|
+
core.Guards.stringValue(ROUTES_SOURCE$3, "request.pathParams.id", request.pathParams.id);
|
|
263
|
+
core.Guards.object(ROUTES_SOURCE$3, "request.body", request.body);
|
|
264
|
+
const component = core.ComponentFactory.get(componentName);
|
|
265
|
+
await component.update(request.body);
|
|
266
|
+
return {
|
|
267
|
+
statusCode: web.HttpStatusCode.noContent
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* PAP: Get a policy.
|
|
272
|
+
* @param httpRequestContext The request context for the API.
|
|
273
|
+
* @param componentName The name of the component to use in the routes.
|
|
274
|
+
* @param request The request.
|
|
275
|
+
* @returns The response object with additional http response properties.
|
|
276
|
+
*/
|
|
277
|
+
async function papGet(httpRequestContext, componentName, request) {
|
|
278
|
+
core.Guards.object(ROUTES_SOURCE$3, "request", request);
|
|
279
|
+
core.Guards.object(ROUTES_SOURCE$3, "request.pathParams", request.pathParams);
|
|
280
|
+
core.Guards.stringValue(ROUTES_SOURCE$3, "request.pathParams.id", request.pathParams.id);
|
|
281
|
+
const component = core.ComponentFactory.get(componentName);
|
|
282
|
+
const policy = await component.get(request.pathParams.id);
|
|
283
|
+
return {
|
|
284
|
+
body: policy
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* PAP: Remove a policy.
|
|
289
|
+
* @param httpRequestContext The request context for the API.
|
|
290
|
+
* @param componentName The name of the component to use in the routes.
|
|
291
|
+
* @param request The request.
|
|
292
|
+
* @returns The response object with additional http response properties.
|
|
293
|
+
*/
|
|
294
|
+
async function papRemove(httpRequestContext, componentName, request) {
|
|
295
|
+
core.Guards.object(ROUTES_SOURCE$3, "request", request);
|
|
296
|
+
core.Guards.object(ROUTES_SOURCE$3, "request.pathParams", request.pathParams);
|
|
297
|
+
core.Guards.stringValue(ROUTES_SOURCE$3, "request.pathParams.id", request.pathParams.id);
|
|
298
|
+
const component = core.ComponentFactory.get(componentName);
|
|
299
|
+
await component.remove(request.pathParams.id);
|
|
300
|
+
return {
|
|
301
|
+
statusCode: web.HttpStatusCode.noContent
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* PAP: Query policies.
|
|
306
|
+
* @param httpRequestContext The request context for the API.
|
|
307
|
+
* @param componentName The name of the component to use in the routes.
|
|
308
|
+
* @param request The request.
|
|
309
|
+
* @returns The response object with additional http response properties.
|
|
310
|
+
*/
|
|
311
|
+
async function papQuery(httpRequestContext, componentName, request) {
|
|
312
|
+
core.Guards.object(ROUTES_SOURCE$3, "request", request);
|
|
313
|
+
const component = core.ComponentFactory.get(componentName);
|
|
314
|
+
const result = await component.query(apiModels.HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.cursor, core.Coerce.integer(request.query?.pageSize));
|
|
315
|
+
return {
|
|
316
|
+
body: {
|
|
317
|
+
cursor: result.cursor,
|
|
318
|
+
policies: result.policies
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The source used when communicating about these routes.
|
|
325
|
+
*/
|
|
326
|
+
const ROUTES_SOURCE$2 = "policyEnforcementPointRoutes";
|
|
327
|
+
/**
|
|
328
|
+
* The tag to associate with the routes.
|
|
329
|
+
*/
|
|
330
|
+
const pepTags = [
|
|
331
|
+
{
|
|
332
|
+
name: "Policy Enforcement Point",
|
|
333
|
+
description: "Endpoints for managing ODRL policies in the Policy Enforcement Point"
|
|
334
|
+
}
|
|
335
|
+
];
|
|
336
|
+
/**
|
|
337
|
+
* The REST routes for the Policy Enforcement Point.
|
|
338
|
+
* @param baseRouteName Prefix to prepend to the paths.
|
|
339
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
340
|
+
* @returns The generated routes.
|
|
341
|
+
*/
|
|
342
|
+
function generateRestRoutesPolicyEnforcementPoint(baseRouteName, componentName) {
|
|
343
|
+
const pepInterceptRoute = {
|
|
231
344
|
operationId: "pepIntercept",
|
|
232
345
|
summary: "Intercept a request",
|
|
233
|
-
tag:
|
|
346
|
+
tag: pepTags[0].name,
|
|
234
347
|
method: "POST",
|
|
235
348
|
path: `${baseRouteName}/pep/intercept`,
|
|
236
349
|
handler: async (httpRequestContext, request) => pepIntercept(httpRequestContext, componentName, request),
|
|
@@ -238,7 +351,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
238
351
|
type: "IPepInterceptRequest",
|
|
239
352
|
examples: [
|
|
240
353
|
{
|
|
241
|
-
id: "
|
|
354
|
+
id: "pepInterceptRequestExample",
|
|
242
355
|
request: {
|
|
243
356
|
body: {
|
|
244
357
|
assetType: "document",
|
|
@@ -270,250 +383,457 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
270
383
|
}
|
|
271
384
|
]
|
|
272
385
|
};
|
|
273
|
-
return [
|
|
386
|
+
return [pepInterceptRoute];
|
|
274
387
|
}
|
|
275
388
|
/**
|
|
276
|
-
*
|
|
389
|
+
* PEP: Intercept.
|
|
277
390
|
* @param httpRequestContext The request context for the API.
|
|
278
391
|
* @param componentName The name of the component to use in the routes.
|
|
279
392
|
* @param request The request.
|
|
280
393
|
* @returns The response object with additional http response properties.
|
|
281
394
|
*/
|
|
282
|
-
async function
|
|
283
|
-
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
284
|
-
core.Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
285
|
-
core.Guards.stringValue(ROUTES_SOURCE, "httpRequestContext.nodeIdentity", httpRequestContext.nodeIdentity);
|
|
395
|
+
async function pepIntercept(httpRequestContext, componentName, request) {
|
|
396
|
+
core.Guards.object(ROUTES_SOURCE$2, "request", request);
|
|
286
397
|
const component = core.ComponentFactory.get(componentName);
|
|
287
|
-
const
|
|
288
|
-
|
|
398
|
+
const result = await component.intercept(request.body.assetType, request.body.action, {
|
|
399
|
+
...(request.body.context ?? {}),
|
|
400
|
+
userIdentity: httpRequestContext.userIdentity,
|
|
401
|
+
nodeIdentity: httpRequestContext.nodeIdentity
|
|
402
|
+
}, request.body.data);
|
|
289
403
|
return {
|
|
290
|
-
|
|
291
|
-
headers: {
|
|
292
|
-
location: uid
|
|
293
|
-
}
|
|
404
|
+
body: result
|
|
294
405
|
};
|
|
295
406
|
}
|
|
407
|
+
|
|
296
408
|
/**
|
|
297
|
-
*
|
|
409
|
+
* The source used when communicating about these routes.
|
|
410
|
+
*/
|
|
411
|
+
const ROUTES_SOURCE$1 = "policyNegotiationAdminPointRoutes";
|
|
412
|
+
/**
|
|
413
|
+
* The tag to associate with the routes.
|
|
414
|
+
*/
|
|
415
|
+
const pnapTags = [
|
|
416
|
+
{
|
|
417
|
+
name: "Policy Negotiation Administration Point",
|
|
418
|
+
description: "Endpoints for managing ODRL policies in the Policy Negotiation Administration Point"
|
|
419
|
+
}
|
|
420
|
+
];
|
|
421
|
+
/**
|
|
422
|
+
* The REST routes for the Policy Negotiation Administration Point.
|
|
423
|
+
* @param baseRouteName Prefix to prepend to the paths.
|
|
424
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
425
|
+
* @returns The generated routes.
|
|
426
|
+
*/
|
|
427
|
+
function generateRestRoutesPolicyNegotiationAdminPoint(baseRouteName, componentName) {
|
|
428
|
+
const pnapGetRoute = {
|
|
429
|
+
operationId: "pnapGet",
|
|
430
|
+
summary: "Get a policy negotiation",
|
|
431
|
+
tag: pnapTags[0].name,
|
|
432
|
+
method: web.HttpMethod.GET,
|
|
433
|
+
path: `${baseRouteName}/pnap/:policyId`,
|
|
434
|
+
handler: async (httpRequestContext, request) => pnapGet(httpRequestContext, componentName, request),
|
|
435
|
+
requestType: {
|
|
436
|
+
type: "IPnapGetRequest",
|
|
437
|
+
examples: [
|
|
438
|
+
{
|
|
439
|
+
id: "pnapGetRequestExample",
|
|
440
|
+
request: {
|
|
441
|
+
pathParams: { policyId: "policy-1" }
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
]
|
|
445
|
+
},
|
|
446
|
+
responseType: [
|
|
447
|
+
{
|
|
448
|
+
type: "IPnapGetResponse",
|
|
449
|
+
examples: [
|
|
450
|
+
{
|
|
451
|
+
id: "pnapGetResponseExample",
|
|
452
|
+
response: {
|
|
453
|
+
body: {
|
|
454
|
+
id: "policy-1",
|
|
455
|
+
status: "manual",
|
|
456
|
+
dateCreated: "2025-09-03T00:00:00.000Z",
|
|
457
|
+
assetType: "document",
|
|
458
|
+
action: "view",
|
|
459
|
+
context: {}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
]
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
};
|
|
467
|
+
const pnapSetRoute = {
|
|
468
|
+
operationId: "pnapSet",
|
|
469
|
+
summary: "Set a policy negotiation",
|
|
470
|
+
tag: pnapTags[0].name,
|
|
471
|
+
method: web.HttpMethod.PUT,
|
|
472
|
+
path: `${baseRouteName}/pnap/:policyId`,
|
|
473
|
+
handler: async (httpRequestContext, request) => pnapSet(httpRequestContext, componentName, request),
|
|
474
|
+
requestType: {
|
|
475
|
+
type: "IPnapSetRequest",
|
|
476
|
+
examples: [
|
|
477
|
+
{
|
|
478
|
+
id: "pnapSetRequestExample",
|
|
479
|
+
request: {
|
|
480
|
+
pathParams: { policyId: "policy-1" },
|
|
481
|
+
body: {
|
|
482
|
+
id: "policy-1",
|
|
483
|
+
status: "approved",
|
|
484
|
+
dateCreated: "2025-09-03T00:00:00.000Z",
|
|
485
|
+
assetType: "document",
|
|
486
|
+
action: "view",
|
|
487
|
+
context: {}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
]
|
|
492
|
+
},
|
|
493
|
+
responseType: [{ type: "INoContentResponse" }]
|
|
494
|
+
};
|
|
495
|
+
const pnapRemoveRoute = {
|
|
496
|
+
operationId: "pnapRemove",
|
|
497
|
+
summary: "Remove a policy negotiation",
|
|
498
|
+
tag: pnapTags[0].name,
|
|
499
|
+
method: web.HttpMethod.DELETE,
|
|
500
|
+
path: `${baseRouteName}/pnap/:policyId`,
|
|
501
|
+
handler: async (httpRequestContext, request) => pnapRemove(httpRequestContext, componentName, request),
|
|
502
|
+
requestType: {
|
|
503
|
+
type: "IPnapRemoveRequest",
|
|
504
|
+
examples: [
|
|
505
|
+
{
|
|
506
|
+
id: "pnapRemoveRequestExample",
|
|
507
|
+
request: {
|
|
508
|
+
pathParams: { policyId: "policy-1" }
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
]
|
|
512
|
+
},
|
|
513
|
+
responseType: [{ type: "INoContentResponse" }]
|
|
514
|
+
};
|
|
515
|
+
const pnapQueryRoute = {
|
|
516
|
+
operationId: "pnapQuery",
|
|
517
|
+
summary: "Query policy negotiations",
|
|
518
|
+
tag: pnapTags[0].name,
|
|
519
|
+
method: web.HttpMethod.GET,
|
|
520
|
+
path: `${baseRouteName}/pnap`,
|
|
521
|
+
handler: async (httpRequestContext, request) => pnapQuery(httpRequestContext, componentName, request),
|
|
522
|
+
requestType: {
|
|
523
|
+
type: "IPnapQueryRequest",
|
|
524
|
+
examples: [
|
|
525
|
+
{
|
|
526
|
+
id: "pnapQueryRequestExample",
|
|
527
|
+
request: {
|
|
528
|
+
query: { status: "manual", cursor: "next-cursor" }
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
]
|
|
532
|
+
},
|
|
533
|
+
responseType: [
|
|
534
|
+
{
|
|
535
|
+
type: "IPnapQueryResponse",
|
|
536
|
+
examples: [
|
|
537
|
+
{
|
|
538
|
+
id: "pnapQueryResponseExample",
|
|
539
|
+
response: {
|
|
540
|
+
body: {
|
|
541
|
+
items: [
|
|
542
|
+
{
|
|
543
|
+
id: "policy-1",
|
|
544
|
+
status: "manual",
|
|
545
|
+
dateCreated: "2025-09-03T00:00:00.000Z",
|
|
546
|
+
assetType: "document",
|
|
547
|
+
action: "view",
|
|
548
|
+
context: {}
|
|
549
|
+
}
|
|
550
|
+
],
|
|
551
|
+
cursor: "next-cursor"
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
]
|
|
556
|
+
}
|
|
557
|
+
]
|
|
558
|
+
};
|
|
559
|
+
return [pnapGetRoute, pnapSetRoute, pnapRemoveRoute, pnapQueryRoute];
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* PNAP: Get a policy negotiation.
|
|
298
563
|
* @param httpRequestContext The request context for the API.
|
|
299
564
|
* @param componentName The name of the component to use in the routes.
|
|
300
565
|
* @param request The request.
|
|
301
566
|
* @returns The response object with additional http response properties.
|
|
302
567
|
*/
|
|
303
|
-
async function
|
|
304
|
-
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
305
|
-
core.Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
306
|
-
core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.
|
|
307
|
-
core.Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
308
|
-
core.Guards.stringValue(ROUTES_SOURCE, "httpRequestContext.nodeIdentity", httpRequestContext.nodeIdentity);
|
|
568
|
+
async function pnapGet(httpRequestContext, componentName, request) {
|
|
569
|
+
core.Guards.object(ROUTES_SOURCE$1, "request", request);
|
|
570
|
+
core.Guards.object(ROUTES_SOURCE$1, "request.pathParams", request.pathParams);
|
|
571
|
+
core.Guards.stringValue(ROUTES_SOURCE$1, "request.pathParams.policyId", request.pathParams.policyId);
|
|
309
572
|
const component = core.ComponentFactory.get(componentName);
|
|
310
|
-
await component.
|
|
573
|
+
const negotiation = await component.get(request.pathParams.policyId);
|
|
311
574
|
return {
|
|
312
|
-
|
|
575
|
+
body: negotiation
|
|
313
576
|
};
|
|
314
577
|
}
|
|
315
578
|
/**
|
|
316
|
-
*
|
|
579
|
+
* PNAP: Set a policy negotiation.
|
|
317
580
|
* @param httpRequestContext The request context for the API.
|
|
318
581
|
* @param componentName The name of the component to use in the routes.
|
|
319
582
|
* @param request The request.
|
|
320
583
|
* @returns The response object with additional http response properties.
|
|
321
584
|
*/
|
|
322
|
-
async function
|
|
323
|
-
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
324
|
-
core.Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
325
|
-
core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.
|
|
326
|
-
core.Guards.
|
|
585
|
+
async function pnapSet(httpRequestContext, componentName, request) {
|
|
586
|
+
core.Guards.object(ROUTES_SOURCE$1, "request", request);
|
|
587
|
+
core.Guards.object(ROUTES_SOURCE$1, "request.pathParams", request.pathParams);
|
|
588
|
+
core.Guards.stringValue(ROUTES_SOURCE$1, "request.pathParams.policyId", request.pathParams.policyId);
|
|
589
|
+
core.Guards.object(ROUTES_SOURCE$1, "request.body", request.body);
|
|
327
590
|
const component = core.ComponentFactory.get(componentName);
|
|
328
|
-
|
|
591
|
+
await component.set(request.body);
|
|
329
592
|
return {
|
|
330
|
-
|
|
593
|
+
statusCode: web.HttpStatusCode.noContent
|
|
331
594
|
};
|
|
332
595
|
}
|
|
333
596
|
/**
|
|
334
|
-
*
|
|
597
|
+
* PNAP: Remove a policy negotiation.
|
|
335
598
|
* @param httpRequestContext The request context for the API.
|
|
336
599
|
* @param componentName The name of the component to use in the routes.
|
|
337
600
|
* @param request The request.
|
|
338
601
|
* @returns The response object with additional http response properties.
|
|
339
602
|
*/
|
|
340
|
-
async function
|
|
341
|
-
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
342
|
-
core.Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
343
|
-
core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.
|
|
603
|
+
async function pnapRemove(httpRequestContext, componentName, request) {
|
|
604
|
+
core.Guards.object(ROUTES_SOURCE$1, "request", request);
|
|
605
|
+
core.Guards.object(ROUTES_SOURCE$1, "request.pathParams", request.pathParams);
|
|
606
|
+
core.Guards.stringValue(ROUTES_SOURCE$1, "request.pathParams.policyId", request.pathParams.policyId);
|
|
344
607
|
const component = core.ComponentFactory.get(componentName);
|
|
345
|
-
await component.
|
|
608
|
+
await component.remove(request.pathParams.policyId);
|
|
346
609
|
return {
|
|
347
610
|
statusCode: web.HttpStatusCode.noContent
|
|
348
611
|
};
|
|
349
612
|
}
|
|
350
613
|
/**
|
|
351
|
-
*
|
|
614
|
+
* PNAP: Query policy negotiations.
|
|
352
615
|
* @param httpRequestContext The request context for the API.
|
|
353
616
|
* @param componentName The name of the component to use in the routes.
|
|
354
617
|
* @param request The request.
|
|
355
618
|
* @returns The response object with additional http response properties.
|
|
356
619
|
*/
|
|
357
|
-
async function
|
|
358
|
-
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
620
|
+
async function pnapQuery(httpRequestContext, componentName, request) {
|
|
621
|
+
core.Guards.object(ROUTES_SOURCE$1, "request", request);
|
|
359
622
|
const component = core.ComponentFactory.get(componentName);
|
|
360
|
-
const result = await component.
|
|
623
|
+
const result = await component.query(request.query?.status, request.query?.cursor);
|
|
361
624
|
return {
|
|
362
625
|
body: {
|
|
363
|
-
|
|
364
|
-
|
|
626
|
+
items: result.items,
|
|
627
|
+
cursor: result.cursor
|
|
365
628
|
}
|
|
366
629
|
};
|
|
367
630
|
}
|
|
631
|
+
|
|
368
632
|
/**
|
|
369
|
-
*
|
|
633
|
+
* The source used when communicating about these routes.
|
|
634
|
+
*/
|
|
635
|
+
const ROUTES_SOURCE = "policyNegotiationPointRoutes";
|
|
636
|
+
/**
|
|
637
|
+
* The tag to associate with the routes.
|
|
638
|
+
*/
|
|
639
|
+
const pnpTags = [
|
|
640
|
+
{
|
|
641
|
+
name: "Policy Negotiation Point",
|
|
642
|
+
description: "Endpoints for managing ODRL policies in the Policy Negotiation Point"
|
|
643
|
+
}
|
|
644
|
+
];
|
|
645
|
+
/**
|
|
646
|
+
* The REST routes for the Policy Negotiation Point.
|
|
647
|
+
* @param baseRouteName Prefix to prepend to the paths.
|
|
648
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
649
|
+
* @returns The generated routes.
|
|
650
|
+
*/
|
|
651
|
+
function generateRestRoutesPolicyNegotiationPoint(baseRouteName, componentName) {
|
|
652
|
+
const pnpNegotiateRoute = {
|
|
653
|
+
operationId: "pnpNegotiate",
|
|
654
|
+
summary: "Negotiate a policy",
|
|
655
|
+
tag: pnpTags[0].name,
|
|
656
|
+
method: "POST",
|
|
657
|
+
path: `${baseRouteName}/pnp/negotiate`,
|
|
658
|
+
handler: async (httpRequestContext, request) => pnpNegotiate(httpRequestContext, componentName, request),
|
|
659
|
+
requestType: {
|
|
660
|
+
type: "IPnpNegotiateRequest",
|
|
661
|
+
examples: [
|
|
662
|
+
{
|
|
663
|
+
id: "pnpNegotiateRequestExample",
|
|
664
|
+
request: {
|
|
665
|
+
body: {
|
|
666
|
+
assetType: "document",
|
|
667
|
+
action: "view",
|
|
668
|
+
context: {
|
|
669
|
+
nodeIdentity: "urn:example:node:1"
|
|
670
|
+
},
|
|
671
|
+
proof: {
|
|
672
|
+
created: "2024-08-22T11:56:56.272Z",
|
|
673
|
+
type: "DataIntegrityProof",
|
|
674
|
+
cryptosuite: "eddsa-jcs-2022",
|
|
675
|
+
proofPurpose: "assertionMethod",
|
|
676
|
+
proofValue: "z3Vcuh2BP9ShC4UEJ3yRZgcTJ6gmRtydDrh6AmY1zEciQqEWTvXfBZNxxjTzdJjT44cmn9VDWbBHqxFsX9fjsfXzK",
|
|
677
|
+
verificationMethod: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363#assertion"
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
]
|
|
683
|
+
},
|
|
684
|
+
responseType: [
|
|
685
|
+
{
|
|
686
|
+
type: "IPnpNegotiateResponse",
|
|
687
|
+
examples: [
|
|
688
|
+
{
|
|
689
|
+
id: "IPnpNegotiateResponseExample",
|
|
690
|
+
response: {
|
|
691
|
+
body: {
|
|
692
|
+
id: "policy-1",
|
|
693
|
+
status: "approved"
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
]
|
|
698
|
+
}
|
|
699
|
+
],
|
|
700
|
+
skipAuth: true
|
|
701
|
+
};
|
|
702
|
+
const papNegotiationStateRoute = {
|
|
703
|
+
operationId: "pnpNegotiationState",
|
|
704
|
+
summary: "Get the state of a policy",
|
|
705
|
+
tag: pnpTags[0].name,
|
|
706
|
+
method: "POST",
|
|
707
|
+
path: `${baseRouteName}/pnp/:policyId`,
|
|
708
|
+
handler: async (httpRequestContext, request) => pnpNegotiationState(httpRequestContext, componentName, request),
|
|
709
|
+
requestType: {
|
|
710
|
+
type: "IPnpNegotiationStateRequest",
|
|
711
|
+
examples: [
|
|
712
|
+
{
|
|
713
|
+
id: "pnpNegotiationStateRequestExample",
|
|
714
|
+
request: {
|
|
715
|
+
pathParams: {
|
|
716
|
+
policyId: "policy-1"
|
|
717
|
+
},
|
|
718
|
+
body: {
|
|
719
|
+
nodeIdentity: "urn:example:node:1",
|
|
720
|
+
proof: {
|
|
721
|
+
created: "2024-08-22T11:56:56.272Z",
|
|
722
|
+
type: "DataIntegrityProof",
|
|
723
|
+
cryptosuite: "eddsa-jcs-2022",
|
|
724
|
+
proofPurpose: "assertionMethod",
|
|
725
|
+
proofValue: "z3Vcuh2BP9ShC4UEJ3yRZgcTJ6gmRtydDrh6AmY1zEciQqEWTvXfBZNxxjTzdJjT44cmn9VDWbBHqxFsX9fjsfXzK",
|
|
726
|
+
verificationMethod: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363#assertion"
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
]
|
|
732
|
+
},
|
|
733
|
+
responseType: [
|
|
734
|
+
{
|
|
735
|
+
type: "IPnpNegotiationStateResponse",
|
|
736
|
+
examples: [
|
|
737
|
+
{
|
|
738
|
+
id: "IPnpNegotiationStateResponseExample",
|
|
739
|
+
response: {
|
|
740
|
+
body: {
|
|
741
|
+
id: "policy-1",
|
|
742
|
+
status: "approved"
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
]
|
|
747
|
+
}
|
|
748
|
+
],
|
|
749
|
+
skipAuth: true
|
|
750
|
+
};
|
|
751
|
+
const pnpNegotiationCancelRoute = {
|
|
752
|
+
operationId: "pnpCancel",
|
|
753
|
+
summary: "Cancel a policy negotiation",
|
|
754
|
+
tag: pnpTags[0].name,
|
|
755
|
+
method: "DELETE",
|
|
756
|
+
path: `${baseRouteName}/pnp/:policyId`,
|
|
757
|
+
handler: async (httpRequestContext, request) => pnpNegotiationCancel(httpRequestContext, componentName, request),
|
|
758
|
+
requestType: {
|
|
759
|
+
type: "IPnpNegotiationCancelRequest",
|
|
760
|
+
examples: [
|
|
761
|
+
{
|
|
762
|
+
id: "pnpNegotiationCancelRequestExample",
|
|
763
|
+
request: {
|
|
764
|
+
pathParams: {
|
|
765
|
+
policyId: "policy-1"
|
|
766
|
+
},
|
|
767
|
+
body: {
|
|
768
|
+
nodeIdentity: "urn:example:node:1",
|
|
769
|
+
proof: {
|
|
770
|
+
created: "2024-08-22T11:56:56.272Z",
|
|
771
|
+
type: "DataIntegrityProof",
|
|
772
|
+
cryptosuite: "eddsa-jcs-2022",
|
|
773
|
+
proofPurpose: "assertionMethod",
|
|
774
|
+
proofValue: "z3Vcuh2BP9ShC4UEJ3yRZgcTJ6gmRtydDrh6AmY1zEciQqEWTvXfBZNxxjTzdJjT44cmn9VDWbBHqxFsX9fjsfXzK",
|
|
775
|
+
verificationMethod: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363#assertion"
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
]
|
|
781
|
+
},
|
|
782
|
+
responseType: [
|
|
783
|
+
{
|
|
784
|
+
type: "INoContentResponse"
|
|
785
|
+
}
|
|
786
|
+
],
|
|
787
|
+
skipAuth: true
|
|
788
|
+
};
|
|
789
|
+
return [pnpNegotiateRoute, papNegotiationStateRoute, pnpNegotiationCancelRoute];
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* PNP: Negotiate.
|
|
370
793
|
* @param httpRequestContext The request context for the API.
|
|
371
794
|
* @param componentName The name of the component to use in the routes.
|
|
372
795
|
* @param request The request.
|
|
373
796
|
* @returns The response object with additional http response properties.
|
|
374
797
|
*/
|
|
375
|
-
async function
|
|
798
|
+
async function pnpNegotiate(httpRequestContext, componentName, request) {
|
|
376
799
|
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
377
800
|
const component = core.ComponentFactory.get(componentName);
|
|
378
|
-
const result = await component.
|
|
801
|
+
const result = await component.negotiate(request.body.assetType, request.body.action, request.body.resourceId, request.body.context, request.body.requesterInformation, request.body.proof);
|
|
379
802
|
return {
|
|
380
803
|
body: result
|
|
381
804
|
};
|
|
382
805
|
}
|
|
383
|
-
|
|
384
|
-
// Copyright 2024 IOTA Stiftung.
|
|
385
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
386
806
|
/**
|
|
387
|
-
*
|
|
388
|
-
*
|
|
807
|
+
* PNP: Negotiation State.
|
|
808
|
+
* @param httpRequestContext The request context for the API.
|
|
809
|
+
* @param componentName The name of the component to use in the routes.
|
|
810
|
+
* @param request The request.
|
|
811
|
+
* @returns The response object with additional http response properties.
|
|
389
812
|
*/
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* PAP: Create a new policy with auto-generated UID.
|
|
416
|
-
* @param policy The policy to create (uid will be auto-generated).
|
|
417
|
-
* @returns The UID of the created policy.
|
|
418
|
-
*/
|
|
419
|
-
async papCreate(policy) {
|
|
420
|
-
core.Guards.object(this.CLASS_NAME, "policy", policy);
|
|
421
|
-
try {
|
|
422
|
-
const result = await this._policyAdministrationPointComponent.create(policy);
|
|
423
|
-
return result;
|
|
424
|
-
}
|
|
425
|
-
catch (error) {
|
|
426
|
-
throw new core.GeneralError(this.CLASS_NAME, "papCreateFailed", undefined, error);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* PAP: Update an existing policy.
|
|
431
|
-
* @param policy The policy to update (must include uid).
|
|
432
|
-
* @returns Nothing.
|
|
433
|
-
*/
|
|
434
|
-
async papUpdate(policy) {
|
|
435
|
-
core.Guards.object(this.CLASS_NAME, "policy", policy);
|
|
436
|
-
try {
|
|
437
|
-
await this._policyAdministrationPointComponent.update(policy);
|
|
438
|
-
}
|
|
439
|
-
catch (error) {
|
|
440
|
-
throw new core.GeneralError(this.CLASS_NAME, "papUpdateFailed", undefined, error);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* PAP: Retrieve a policy.
|
|
445
|
-
* @param policyId The id of the policy to retrieve.
|
|
446
|
-
* @returns The policy.
|
|
447
|
-
*/
|
|
448
|
-
async papRetrieve(policyId) {
|
|
449
|
-
core.Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
|
|
450
|
-
try {
|
|
451
|
-
const policy = await this._policyAdministrationPointComponent.retrieve(policyId);
|
|
452
|
-
return policy;
|
|
453
|
-
}
|
|
454
|
-
catch (error) {
|
|
455
|
-
throw new core.GeneralError(this.CLASS_NAME, "papRetrieveFailed", undefined, error);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* PAP: Remove a policy.
|
|
460
|
-
* @param policyId The id of the policy to remove.
|
|
461
|
-
* @returns Nothing.
|
|
462
|
-
*/
|
|
463
|
-
async papRemove(policyId) {
|
|
464
|
-
core.Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
|
|
465
|
-
try {
|
|
466
|
-
await this._policyAdministrationPointComponent.remove(policyId);
|
|
467
|
-
}
|
|
468
|
-
catch (error) {
|
|
469
|
-
throw new core.GeneralError(this.CLASS_NAME, "papRemoveFailed", undefined, error);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* PAP: Query the policies using the specified conditions.
|
|
474
|
-
* @param conditions The conditions to use for the query.
|
|
475
|
-
* @param cursor The cursor to use for pagination.
|
|
476
|
-
* @param pageSize The number of results to return per page.
|
|
477
|
-
* @returns Cursor for next page of results and the policies matching the query.
|
|
478
|
-
*/
|
|
479
|
-
async papQuery(conditions, cursor, pageSize) {
|
|
480
|
-
if (!core.Is.empty(conditions)) {
|
|
481
|
-
core.Guards.object(this.CLASS_NAME, "conditions", conditions);
|
|
482
|
-
}
|
|
483
|
-
if (!core.Is.empty(cursor)) {
|
|
484
|
-
core.Guards.stringValue(this.CLASS_NAME, "cursor", cursor);
|
|
485
|
-
}
|
|
486
|
-
if (!core.Is.empty(pageSize)) {
|
|
487
|
-
core.Guards.integer(this.CLASS_NAME, "pageSize", pageSize);
|
|
488
|
-
}
|
|
489
|
-
try {
|
|
490
|
-
const result = await this._policyAdministrationPointComponent.query(conditions, cursor, pageSize);
|
|
491
|
-
return result;
|
|
492
|
-
}
|
|
493
|
-
catch (error) {
|
|
494
|
-
throw new core.GeneralError(this.CLASS_NAME, "papQueryFailed", undefined, error);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* PEP: Process the data using Policy Decision Point (PDP) and return the manipulated data.
|
|
499
|
-
* @param assetType The type of asset being processed.
|
|
500
|
-
* @param action The action being performed on the asset.
|
|
501
|
-
* @param data The data to process.
|
|
502
|
-
* @param userIdentity The user identity to use in the decision making.
|
|
503
|
-
* @param nodeIdentity The node identity to use in the decision making.
|
|
504
|
-
* @returns The manipulated data with any policies applied.
|
|
505
|
-
*/
|
|
506
|
-
async pepIntercept(assetType, action, data, userIdentity, nodeIdentity) {
|
|
507
|
-
core.Guards.stringValue(this.CLASS_NAME, "assetType", assetType);
|
|
508
|
-
core.Guards.stringValue(this.CLASS_NAME, "action", action);
|
|
509
|
-
try {
|
|
510
|
-
const result = await this._policyEnforcementPointComponent.intercept(assetType, action, data, userIdentity, nodeIdentity);
|
|
511
|
-
return result;
|
|
512
|
-
}
|
|
513
|
-
catch (error) {
|
|
514
|
-
throw new core.GeneralError(this.CLASS_NAME, "pepInterceptFailed", undefined, error);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
813
|
+
async function pnpNegotiationState(httpRequestContext, componentName, request) {
|
|
814
|
+
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
815
|
+
core.Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
816
|
+
const component = core.ComponentFactory.get(componentName);
|
|
817
|
+
const result = await component.negotiationState(request.pathParams.policyId, request.body.nodeIdentity, request.body.proof);
|
|
818
|
+
return {
|
|
819
|
+
body: result
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* PNP: Negotiation Cancel.
|
|
824
|
+
* @param httpRequestContext The request context for the API.
|
|
825
|
+
* @param componentName The name of the component to use in the routes.
|
|
826
|
+
* @param request The request.
|
|
827
|
+
* @returns The response object with additional http response properties.
|
|
828
|
+
*/
|
|
829
|
+
async function pnpNegotiationCancel(httpRequestContext, componentName, request) {
|
|
830
|
+
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
831
|
+
core.Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
832
|
+
const component = core.ComponentFactory.get(componentName);
|
|
833
|
+
await component.negotiationCancel(request.pathParams.policyId, request.body.nodeIdentity, request.body.proof);
|
|
834
|
+
return {
|
|
835
|
+
statusCode: web.HttpStatusCode.noContent
|
|
836
|
+
};
|
|
517
837
|
}
|
|
518
838
|
|
|
519
839
|
/**
|
|
@@ -521,20 +841,50 @@ class RightsManagementService {
|
|
|
521
841
|
*/
|
|
522
842
|
const restEntryPoints = [
|
|
523
843
|
{
|
|
524
|
-
name: "
|
|
844
|
+
name: "policy-administration-point",
|
|
845
|
+
defaultBaseRoute: "rights-management",
|
|
846
|
+
tags: papTags,
|
|
847
|
+
generateRoutes: generateRestRoutesPolicyAdministrationPoint
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
name: "policy-enforcement-point",
|
|
851
|
+
defaultBaseRoute: "rights-management",
|
|
852
|
+
tags: pepTags,
|
|
853
|
+
generateRoutes: generateRestRoutesPolicyEnforcementPoint
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
name: "policy-negotiation-point",
|
|
857
|
+
defaultBaseRoute: "rights-management",
|
|
858
|
+
tags: pnpTags,
|
|
859
|
+
generateRoutes: generateRestRoutesPolicyNegotiationPoint
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
name: "policy-negotiation-admin-point",
|
|
525
863
|
defaultBaseRoute: "rights-management",
|
|
526
|
-
tags,
|
|
527
|
-
generateRoutes:
|
|
864
|
+
tags: pnapTags,
|
|
865
|
+
generateRoutes: generateRestRoutesPolicyNegotiationAdminPoint
|
|
528
866
|
}
|
|
529
867
|
];
|
|
530
868
|
|
|
531
|
-
exports.
|
|
532
|
-
exports.
|
|
869
|
+
exports.generateRestRoutesPolicyAdministrationPoint = generateRestRoutesPolicyAdministrationPoint;
|
|
870
|
+
exports.generateRestRoutesPolicyEnforcementPoint = generateRestRoutesPolicyEnforcementPoint;
|
|
871
|
+
exports.generateRestRoutesPolicyNegotiationAdminPoint = generateRestRoutesPolicyNegotiationAdminPoint;
|
|
872
|
+
exports.generateRestRoutesPolicyNegotiationPoint = generateRestRoutesPolicyNegotiationPoint;
|
|
533
873
|
exports.papCreate = papCreate;
|
|
874
|
+
exports.papGet = papGet;
|
|
534
875
|
exports.papQuery = papQuery;
|
|
535
876
|
exports.papRemove = papRemove;
|
|
536
|
-
exports.
|
|
877
|
+
exports.papTags = papTags;
|
|
537
878
|
exports.papUpdate = papUpdate;
|
|
538
879
|
exports.pepIntercept = pepIntercept;
|
|
880
|
+
exports.pepTags = pepTags;
|
|
881
|
+
exports.pnapGet = pnapGet;
|
|
882
|
+
exports.pnapQuery = pnapQuery;
|
|
883
|
+
exports.pnapRemove = pnapRemove;
|
|
884
|
+
exports.pnapSet = pnapSet;
|
|
885
|
+
exports.pnapTags = pnapTags;
|
|
886
|
+
exports.pnpNegotiate = pnpNegotiate;
|
|
887
|
+
exports.pnpNegotiationCancel = pnpNegotiationCancel;
|
|
888
|
+
exports.pnpNegotiationState = pnpNegotiationState;
|
|
889
|
+
exports.pnpTags = pnpTags;
|
|
539
890
|
exports.restEntryPoints = restEntryPoints;
|
|
540
|
-
exports.tags = tags;
|