@twin.org/rights-management-service 0.0.1 → 0.0.2-next.2
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 +107 -25
- package/dist/esm/index.mjs +107 -26
- package/dist/types/models/IRightsManagementServiceConstructorOptions.d.ts +7 -2
- package/dist/types/rightsManagementRoutes.d.ts +9 -1
- package/dist/types/rightsManagementService.d.ts +10 -4
- package/docs/changelog.md +51 -0
- package/docs/open-api/spec.json +499 -6
- package/docs/reference/classes/RightsManagementService.md +56 -8
- package/docs/reference/functions/pepIntercept.md +31 -0
- package/docs/reference/index.md +1 -0
- package/docs/reference/interfaces/IRightsManagementServiceConstructorOptions.md +17 -3
- package/locales/en.json +2 -1
- package/package.json +8 -9
package/dist/cjs/index.cjs
CHANGED
|
@@ -227,7 +227,50 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
227
227
|
}
|
|
228
228
|
]
|
|
229
229
|
};
|
|
230
|
-
|
|
230
|
+
const interceptRoute = {
|
|
231
|
+
operationId: "pepIntercept",
|
|
232
|
+
summary: "Intercept a request",
|
|
233
|
+
tag: tags[0].name,
|
|
234
|
+
method: "POST",
|
|
235
|
+
path: `${baseRouteName}/pep/intercept`,
|
|
236
|
+
handler: async (httpRequestContext, request) => pepIntercept(httpRequestContext, componentName, request),
|
|
237
|
+
requestType: {
|
|
238
|
+
type: "IPepInterceptRequest",
|
|
239
|
+
examples: [
|
|
240
|
+
{
|
|
241
|
+
id: "pepInterceptExample",
|
|
242
|
+
request: {
|
|
243
|
+
body: {
|
|
244
|
+
assetType: "document",
|
|
245
|
+
action: "view",
|
|
246
|
+
data: {
|
|
247
|
+
id: "document-1",
|
|
248
|
+
param1: 1,
|
|
249
|
+
param2: 2
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
responseType: [
|
|
257
|
+
{
|
|
258
|
+
type: "IPepInterceptResponse",
|
|
259
|
+
examples: [
|
|
260
|
+
{
|
|
261
|
+
id: "pepInterceptResponseExample",
|
|
262
|
+
response: {
|
|
263
|
+
body: {
|
|
264
|
+
id: "document-1",
|
|
265
|
+
param1: 1
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
};
|
|
273
|
+
return [createRoute, updateRoute, retrieveRoute, removeRoute, queryRoute, interceptRoute];
|
|
231
274
|
}
|
|
232
275
|
/**
|
|
233
276
|
* PAP: Create a policy.
|
|
@@ -322,6 +365,21 @@ async function papQuery(httpRequestContext, componentName, request) {
|
|
|
322
365
|
}
|
|
323
366
|
};
|
|
324
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* PEP: Intercept.
|
|
370
|
+
* @param httpRequestContext The request context for the API.
|
|
371
|
+
* @param componentName The name of the component to use in the routes.
|
|
372
|
+
* @param request The request.
|
|
373
|
+
* @returns The response object with additional http response properties.
|
|
374
|
+
*/
|
|
375
|
+
async function pepIntercept(httpRequestContext, componentName, request) {
|
|
376
|
+
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
377
|
+
const component = core.ComponentFactory.get(componentName);
|
|
378
|
+
const result = await component.pepIntercept(request.body.assetType, request.body.action, request.body.data, httpRequestContext.userIdentity ?? "", httpRequestContext.nodeIdentity ?? "");
|
|
379
|
+
return {
|
|
380
|
+
body: result
|
|
381
|
+
};
|
|
382
|
+
}
|
|
325
383
|
|
|
326
384
|
// Copyright 2024 IOTA Stiftung.
|
|
327
385
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -330,10 +388,6 @@ async function papQuery(httpRequestContext, componentName, request) {
|
|
|
330
388
|
* This is a unified service that provides access to all Rights Management components.
|
|
331
389
|
*/
|
|
332
390
|
class RightsManagementService {
|
|
333
|
-
/**
|
|
334
|
-
* The namespace supported by the Rights Management service.
|
|
335
|
-
*/
|
|
336
|
-
static NAMESPACE = "rights-management";
|
|
337
391
|
/**
|
|
338
392
|
* Runtime name for the class.
|
|
339
393
|
*/
|
|
@@ -342,13 +396,20 @@ class RightsManagementService {
|
|
|
342
396
|
* The PAP component implementation.
|
|
343
397
|
* @internal
|
|
344
398
|
*/
|
|
345
|
-
|
|
399
|
+
_policyAdministrationPointComponent;
|
|
400
|
+
/**
|
|
401
|
+
* The PEP component implementation.
|
|
402
|
+
* @internal
|
|
403
|
+
*/
|
|
404
|
+
_policyEnforcementPointComponent;
|
|
346
405
|
/**
|
|
347
406
|
* Create a new instance of RightsManagementService.
|
|
348
407
|
* @param options The options for the service.
|
|
349
408
|
*/
|
|
350
409
|
constructor(options) {
|
|
351
|
-
this.
|
|
410
|
+
this._policyAdministrationPointComponent =
|
|
411
|
+
core.ComponentFactory.get(options?.policyAdministrationPointComponentType ?? "policy-administration-point");
|
|
412
|
+
this._policyEnforcementPointComponent = core.ComponentFactory.get(options?.policyEnforcementPointComponentType ?? "policy-enforcement-point");
|
|
352
413
|
}
|
|
353
414
|
/**
|
|
354
415
|
* PAP: Create a new policy with auto-generated UID.
|
|
@@ -356,9 +417,9 @@ class RightsManagementService {
|
|
|
356
417
|
* @returns The UID of the created policy.
|
|
357
418
|
*/
|
|
358
419
|
async papCreate(policy) {
|
|
420
|
+
core.Guards.object(this.CLASS_NAME, "policy", policy);
|
|
359
421
|
try {
|
|
360
|
-
|
|
361
|
-
const result = await this._papComponent.create(policy);
|
|
422
|
+
const result = await this._policyAdministrationPointComponent.create(policy);
|
|
362
423
|
return result;
|
|
363
424
|
}
|
|
364
425
|
catch (error) {
|
|
@@ -371,9 +432,9 @@ class RightsManagementService {
|
|
|
371
432
|
* @returns Nothing.
|
|
372
433
|
*/
|
|
373
434
|
async papUpdate(policy) {
|
|
435
|
+
core.Guards.object(this.CLASS_NAME, "policy", policy);
|
|
374
436
|
try {
|
|
375
|
-
|
|
376
|
-
await this._papComponent.update(policy);
|
|
437
|
+
await this._policyAdministrationPointComponent.update(policy);
|
|
377
438
|
}
|
|
378
439
|
catch (error) {
|
|
379
440
|
throw new core.GeneralError(this.CLASS_NAME, "papUpdateFailed", undefined, error);
|
|
@@ -385,9 +446,9 @@ class RightsManagementService {
|
|
|
385
446
|
* @returns The policy.
|
|
386
447
|
*/
|
|
387
448
|
async papRetrieve(policyId) {
|
|
449
|
+
core.Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
|
|
388
450
|
try {
|
|
389
|
-
|
|
390
|
-
const policy = await this._papComponent.retrieve(policyId);
|
|
451
|
+
const policy = await this._policyAdministrationPointComponent.retrieve(policyId);
|
|
391
452
|
return policy;
|
|
392
453
|
}
|
|
393
454
|
catch (error) {
|
|
@@ -400,9 +461,9 @@ class RightsManagementService {
|
|
|
400
461
|
* @returns Nothing.
|
|
401
462
|
*/
|
|
402
463
|
async papRemove(policyId) {
|
|
464
|
+
core.Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
|
|
403
465
|
try {
|
|
404
|
-
|
|
405
|
-
await this._papComponent.remove(policyId);
|
|
466
|
+
await this._policyAdministrationPointComponent.remove(policyId);
|
|
406
467
|
}
|
|
407
468
|
catch (error) {
|
|
408
469
|
throw new core.GeneralError(this.CLASS_NAME, "papRemoveFailed", undefined, error);
|
|
@@ -416,23 +477,43 @@ class RightsManagementService {
|
|
|
416
477
|
* @returns Cursor for next page of results and the policies matching the query.
|
|
417
478
|
*/
|
|
418
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
|
+
}
|
|
419
489
|
try {
|
|
420
|
-
|
|
421
|
-
core.Guards.object(this.CLASS_NAME, "conditions", conditions);
|
|
422
|
-
}
|
|
423
|
-
if (!core.Is.empty(cursor)) {
|
|
424
|
-
core.Guards.stringValue(this.CLASS_NAME, "cursor", cursor);
|
|
425
|
-
}
|
|
426
|
-
if (!core.Is.empty(pageSize)) {
|
|
427
|
-
core.Guards.integer(this.CLASS_NAME, "pageSize", pageSize);
|
|
428
|
-
}
|
|
429
|
-
const result = await this._papComponent.query(conditions, cursor, pageSize);
|
|
490
|
+
const result = await this._policyAdministrationPointComponent.query(conditions, cursor, pageSize);
|
|
430
491
|
return result;
|
|
431
492
|
}
|
|
432
493
|
catch (error) {
|
|
433
494
|
throw new core.GeneralError(this.CLASS_NAME, "papQueryFailed", undefined, error);
|
|
434
495
|
}
|
|
435
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
|
+
}
|
|
436
517
|
}
|
|
437
518
|
|
|
438
519
|
/**
|
|
@@ -454,5 +535,6 @@ exports.papQuery = papQuery;
|
|
|
454
535
|
exports.papRemove = papRemove;
|
|
455
536
|
exports.papRetrieve = papRetrieve;
|
|
456
537
|
exports.papUpdate = papUpdate;
|
|
538
|
+
exports.pepIntercept = pepIntercept;
|
|
457
539
|
exports.restEntryPoints = restEntryPoints;
|
|
458
540
|
exports.tags = tags;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -225,7 +225,50 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
225
225
|
}
|
|
226
226
|
]
|
|
227
227
|
};
|
|
228
|
-
|
|
228
|
+
const interceptRoute = {
|
|
229
|
+
operationId: "pepIntercept",
|
|
230
|
+
summary: "Intercept a request",
|
|
231
|
+
tag: tags[0].name,
|
|
232
|
+
method: "POST",
|
|
233
|
+
path: `${baseRouteName}/pep/intercept`,
|
|
234
|
+
handler: async (httpRequestContext, request) => pepIntercept(httpRequestContext, componentName, request),
|
|
235
|
+
requestType: {
|
|
236
|
+
type: "IPepInterceptRequest",
|
|
237
|
+
examples: [
|
|
238
|
+
{
|
|
239
|
+
id: "pepInterceptExample",
|
|
240
|
+
request: {
|
|
241
|
+
body: {
|
|
242
|
+
assetType: "document",
|
|
243
|
+
action: "view",
|
|
244
|
+
data: {
|
|
245
|
+
id: "document-1",
|
|
246
|
+
param1: 1,
|
|
247
|
+
param2: 2
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
responseType: [
|
|
255
|
+
{
|
|
256
|
+
type: "IPepInterceptResponse",
|
|
257
|
+
examples: [
|
|
258
|
+
{
|
|
259
|
+
id: "pepInterceptResponseExample",
|
|
260
|
+
response: {
|
|
261
|
+
body: {
|
|
262
|
+
id: "document-1",
|
|
263
|
+
param1: 1
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
]
|
|
270
|
+
};
|
|
271
|
+
return [createRoute, updateRoute, retrieveRoute, removeRoute, queryRoute, interceptRoute];
|
|
229
272
|
}
|
|
230
273
|
/**
|
|
231
274
|
* PAP: Create a policy.
|
|
@@ -320,6 +363,21 @@ async function papQuery(httpRequestContext, componentName, request) {
|
|
|
320
363
|
}
|
|
321
364
|
};
|
|
322
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* PEP: Intercept.
|
|
368
|
+
* @param httpRequestContext The request context for the API.
|
|
369
|
+
* @param componentName The name of the component to use in the routes.
|
|
370
|
+
* @param request The request.
|
|
371
|
+
* @returns The response object with additional http response properties.
|
|
372
|
+
*/
|
|
373
|
+
async function pepIntercept(httpRequestContext, componentName, request) {
|
|
374
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
375
|
+
const component = ComponentFactory.get(componentName);
|
|
376
|
+
const result = await component.pepIntercept(request.body.assetType, request.body.action, request.body.data, httpRequestContext.userIdentity ?? "", httpRequestContext.nodeIdentity ?? "");
|
|
377
|
+
return {
|
|
378
|
+
body: result
|
|
379
|
+
};
|
|
380
|
+
}
|
|
323
381
|
|
|
324
382
|
// Copyright 2024 IOTA Stiftung.
|
|
325
383
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -328,10 +386,6 @@ async function papQuery(httpRequestContext, componentName, request) {
|
|
|
328
386
|
* This is a unified service that provides access to all Rights Management components.
|
|
329
387
|
*/
|
|
330
388
|
class RightsManagementService {
|
|
331
|
-
/**
|
|
332
|
-
* The namespace supported by the Rights Management service.
|
|
333
|
-
*/
|
|
334
|
-
static NAMESPACE = "rights-management";
|
|
335
389
|
/**
|
|
336
390
|
* Runtime name for the class.
|
|
337
391
|
*/
|
|
@@ -340,13 +394,20 @@ class RightsManagementService {
|
|
|
340
394
|
* The PAP component implementation.
|
|
341
395
|
* @internal
|
|
342
396
|
*/
|
|
343
|
-
|
|
397
|
+
_policyAdministrationPointComponent;
|
|
398
|
+
/**
|
|
399
|
+
* The PEP component implementation.
|
|
400
|
+
* @internal
|
|
401
|
+
*/
|
|
402
|
+
_policyEnforcementPointComponent;
|
|
344
403
|
/**
|
|
345
404
|
* Create a new instance of RightsManagementService.
|
|
346
405
|
* @param options The options for the service.
|
|
347
406
|
*/
|
|
348
407
|
constructor(options) {
|
|
349
|
-
this.
|
|
408
|
+
this._policyAdministrationPointComponent =
|
|
409
|
+
ComponentFactory.get(options?.policyAdministrationPointComponentType ?? "policy-administration-point");
|
|
410
|
+
this._policyEnforcementPointComponent = ComponentFactory.get(options?.policyEnforcementPointComponentType ?? "policy-enforcement-point");
|
|
350
411
|
}
|
|
351
412
|
/**
|
|
352
413
|
* PAP: Create a new policy with auto-generated UID.
|
|
@@ -354,9 +415,9 @@ class RightsManagementService {
|
|
|
354
415
|
* @returns The UID of the created policy.
|
|
355
416
|
*/
|
|
356
417
|
async papCreate(policy) {
|
|
418
|
+
Guards.object(this.CLASS_NAME, "policy", policy);
|
|
357
419
|
try {
|
|
358
|
-
|
|
359
|
-
const result = await this._papComponent.create(policy);
|
|
420
|
+
const result = await this._policyAdministrationPointComponent.create(policy);
|
|
360
421
|
return result;
|
|
361
422
|
}
|
|
362
423
|
catch (error) {
|
|
@@ -369,9 +430,9 @@ class RightsManagementService {
|
|
|
369
430
|
* @returns Nothing.
|
|
370
431
|
*/
|
|
371
432
|
async papUpdate(policy) {
|
|
433
|
+
Guards.object(this.CLASS_NAME, "policy", policy);
|
|
372
434
|
try {
|
|
373
|
-
|
|
374
|
-
await this._papComponent.update(policy);
|
|
435
|
+
await this._policyAdministrationPointComponent.update(policy);
|
|
375
436
|
}
|
|
376
437
|
catch (error) {
|
|
377
438
|
throw new GeneralError(this.CLASS_NAME, "papUpdateFailed", undefined, error);
|
|
@@ -383,9 +444,9 @@ class RightsManagementService {
|
|
|
383
444
|
* @returns The policy.
|
|
384
445
|
*/
|
|
385
446
|
async papRetrieve(policyId) {
|
|
447
|
+
Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
|
|
386
448
|
try {
|
|
387
|
-
|
|
388
|
-
const policy = await this._papComponent.retrieve(policyId);
|
|
449
|
+
const policy = await this._policyAdministrationPointComponent.retrieve(policyId);
|
|
389
450
|
return policy;
|
|
390
451
|
}
|
|
391
452
|
catch (error) {
|
|
@@ -398,9 +459,9 @@ class RightsManagementService {
|
|
|
398
459
|
* @returns Nothing.
|
|
399
460
|
*/
|
|
400
461
|
async papRemove(policyId) {
|
|
462
|
+
Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
|
|
401
463
|
try {
|
|
402
|
-
|
|
403
|
-
await this._papComponent.remove(policyId);
|
|
464
|
+
await this._policyAdministrationPointComponent.remove(policyId);
|
|
404
465
|
}
|
|
405
466
|
catch (error) {
|
|
406
467
|
throw new GeneralError(this.CLASS_NAME, "papRemoveFailed", undefined, error);
|
|
@@ -414,23 +475,43 @@ class RightsManagementService {
|
|
|
414
475
|
* @returns Cursor for next page of results and the policies matching the query.
|
|
415
476
|
*/
|
|
416
477
|
async papQuery(conditions, cursor, pageSize) {
|
|
478
|
+
if (!Is.empty(conditions)) {
|
|
479
|
+
Guards.object(this.CLASS_NAME, "conditions", conditions);
|
|
480
|
+
}
|
|
481
|
+
if (!Is.empty(cursor)) {
|
|
482
|
+
Guards.stringValue(this.CLASS_NAME, "cursor", cursor);
|
|
483
|
+
}
|
|
484
|
+
if (!Is.empty(pageSize)) {
|
|
485
|
+
Guards.integer(this.CLASS_NAME, "pageSize", pageSize);
|
|
486
|
+
}
|
|
417
487
|
try {
|
|
418
|
-
|
|
419
|
-
Guards.object(this.CLASS_NAME, "conditions", conditions);
|
|
420
|
-
}
|
|
421
|
-
if (!Is.empty(cursor)) {
|
|
422
|
-
Guards.stringValue(this.CLASS_NAME, "cursor", cursor);
|
|
423
|
-
}
|
|
424
|
-
if (!Is.empty(pageSize)) {
|
|
425
|
-
Guards.integer(this.CLASS_NAME, "pageSize", pageSize);
|
|
426
|
-
}
|
|
427
|
-
const result = await this._papComponent.query(conditions, cursor, pageSize);
|
|
488
|
+
const result = await this._policyAdministrationPointComponent.query(conditions, cursor, pageSize);
|
|
428
489
|
return result;
|
|
429
490
|
}
|
|
430
491
|
catch (error) {
|
|
431
492
|
throw new GeneralError(this.CLASS_NAME, "papQueryFailed", undefined, error);
|
|
432
493
|
}
|
|
433
494
|
}
|
|
495
|
+
/**
|
|
496
|
+
* PEP: Process the data using Policy Decision Point (PDP) and return the manipulated data.
|
|
497
|
+
* @param assetType The type of asset being processed.
|
|
498
|
+
* @param action The action being performed on the asset.
|
|
499
|
+
* @param data The data to process.
|
|
500
|
+
* @param userIdentity The user identity to use in the decision making.
|
|
501
|
+
* @param nodeIdentity The node identity to use in the decision making.
|
|
502
|
+
* @returns The manipulated data with any policies applied.
|
|
503
|
+
*/
|
|
504
|
+
async pepIntercept(assetType, action, data, userIdentity, nodeIdentity) {
|
|
505
|
+
Guards.stringValue(this.CLASS_NAME, "assetType", assetType);
|
|
506
|
+
Guards.stringValue(this.CLASS_NAME, "action", action);
|
|
507
|
+
try {
|
|
508
|
+
const result = await this._policyEnforcementPointComponent.intercept(assetType, action, data, userIdentity, nodeIdentity);
|
|
509
|
+
return result;
|
|
510
|
+
}
|
|
511
|
+
catch (error) {
|
|
512
|
+
throw new GeneralError(this.CLASS_NAME, "pepInterceptFailed", undefined, error);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
434
515
|
}
|
|
435
516
|
|
|
436
517
|
/**
|
|
@@ -445,4 +526,4 @@ const restEntryPoints = [
|
|
|
445
526
|
}
|
|
446
527
|
];
|
|
447
528
|
|
|
448
|
-
export { RightsManagementService, generateRestRoutesRightsManagement, papCreate, papQuery, papRemove, papRetrieve, papUpdate, restEntryPoints, tags };
|
|
529
|
+
export { RightsManagementService, generateRestRoutesRightsManagement, papCreate, papQuery, papRemove, papRetrieve, papUpdate, pepIntercept, restEntryPoints, tags };
|
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
export interface IRightsManagementServiceConstructorOptions {
|
|
5
5
|
/**
|
|
6
6
|
* The type of the Policy Administration Point (PAP) component.
|
|
7
|
-
* @default
|
|
7
|
+
* @default policy-administration-point
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
policyAdministrationPointComponentType?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The type of the Policy Enforcement Point (PEP) component.
|
|
12
|
+
* @default policy-enforcement-point
|
|
13
|
+
*/
|
|
14
|
+
policyEnforcementPointComponentType?: string;
|
|
10
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ICreatedResponse, type IHttpRequestContext, type INoContentResponse, type IRestRoute, type ITag } from "@twin.org/api-models";
|
|
2
|
-
import type { IPapCreateRequest, IPapQueryRequest, IPapQueryResponse, IPapRemoveRequest, IPapRetrieveRequest, IPapRetrieveResponse, IPapUpdateRequest } from "@twin.org/rights-management-models";
|
|
2
|
+
import type { IPapCreateRequest, IPapQueryRequest, IPapQueryResponse, IPapRemoveRequest, IPapRetrieveRequest, IPapRetrieveResponse, IPapUpdateRequest, IPepInterceptRequest, IPepInterceptResponse } from "@twin.org/rights-management-models";
|
|
3
3
|
/**
|
|
4
4
|
* The tag to associate with the routes.
|
|
5
5
|
*/
|
|
@@ -51,3 +51,11 @@ export declare function papRemove(httpRequestContext: IHttpRequestContext, compo
|
|
|
51
51
|
* @returns The response object with additional http response properties.
|
|
52
52
|
*/
|
|
53
53
|
export declare function papQuery(httpRequestContext: IHttpRequestContext, componentName: string, request: IPapQueryRequest): Promise<IPapQueryResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* PEP: Intercept.
|
|
56
|
+
* @param httpRequestContext The request context for the API.
|
|
57
|
+
* @param componentName The name of the component to use in the routes.
|
|
58
|
+
* @param request The request.
|
|
59
|
+
* @returns The response object with additional http response properties.
|
|
60
|
+
*/
|
|
61
|
+
export declare function pepIntercept(httpRequestContext: IHttpRequestContext, componentName: string, request: IPepInterceptRequest): Promise<IPepInterceptResponse>;
|
|
@@ -7,10 +7,6 @@ import type { IRightsManagementServiceConstructorOptions } from "./models/IRight
|
|
|
7
7
|
* This is a unified service that provides access to all Rights Management components.
|
|
8
8
|
*/
|
|
9
9
|
export declare class RightsManagementService implements IRightsManagementComponent {
|
|
10
|
-
/**
|
|
11
|
-
* The namespace supported by the Rights Management service.
|
|
12
|
-
*/
|
|
13
|
-
static readonly NAMESPACE: string;
|
|
14
10
|
/**
|
|
15
11
|
* Runtime name for the class.
|
|
16
12
|
*/
|
|
@@ -55,4 +51,14 @@ export declare class RightsManagementService implements IRightsManagementCompone
|
|
|
55
51
|
cursor?: string;
|
|
56
52
|
policies: IOdrlPolicy[];
|
|
57
53
|
}>;
|
|
54
|
+
/**
|
|
55
|
+
* PEP: Process the data using Policy Decision Point (PDP) and return the manipulated data.
|
|
56
|
+
* @param assetType The type of asset being processed.
|
|
57
|
+
* @param action The action being performed on the asset.
|
|
58
|
+
* @param data The data to process.
|
|
59
|
+
* @param userIdentity The user identity to use in the decision making.
|
|
60
|
+
* @param nodeIdentity The node identity to use in the decision making.
|
|
61
|
+
* @returns The manipulated data with any policies applied.
|
|
62
|
+
*/
|
|
63
|
+
pepIntercept<T = unknown>(assetType: string, action: string, data: T | undefined, userIdentity: string | undefined, nodeIdentity: string | undefined): Promise<T | undefined>;
|
|
58
64
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @twin.org/rights-management-pap-service - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.2](https://github.com/twinfoundation/rights-management/compare/rights-management-service-v0.0.2-next.1...rights-management-service-v0.0.2-next.2) (2025-08-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add scaffold for other services ([de25f34](https://github.com/twinfoundation/rights-management/commit/de25f34c40fb65b6d73df98965ea4e368019da84))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
18
|
+
* @twin.org/rights-management-pdp-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
19
|
+
* @twin.org/rights-management-pep-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
20
|
+
* @twin.org/rights-management-pip-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
21
|
+
* @twin.org/rights-management-pmp-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
22
|
+
* @twin.org/rights-management-pxp-service bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
23
|
+
|
|
24
|
+
## [0.0.2-next.1](https://github.com/twinfoundation/rights-management/compare/rights-management-service-v0.0.2-next.0...rights-management-service-v0.0.2-next.1) (2025-08-20)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* pap create, update methods ([#13](https://github.com/twinfoundation/rights-management/issues/13)) ([edb6c9e](https://github.com/twinfoundation/rights-management/commit/edb6c9efcfda55ac96f7594253bf831b4f0e5993))
|
|
30
|
+
* remove unnecessary config options from service ([31ef3a2](https://github.com/twinfoundation/rights-management/commit/31ef3a2eb2293efdad7e6b8b55f105cc62bba3ed))
|
|
31
|
+
* remove unused namespace ([e8aa679](https://github.com/twinfoundation/rights-management/commit/e8aa679479231a49f86dd8dec5f9b811bd3f595f))
|
|
32
|
+
* rename pap entity storage to pap service ([38a2c14](https://github.com/twinfoundation/rights-management/commit/38a2c14d8f63a86e398820166c83437be5aca1b8))
|
|
33
|
+
* rights management pap ([#4](https://github.com/twinfoundation/rights-management/issues/4)) ([d1165a9](https://github.com/twinfoundation/rights-management/commit/d1165a92f57128731cfb308d977832e28cf33493))
|
|
34
|
+
* update dependencies ([dd0a553](https://github.com/twinfoundation/rights-management/commit/dd0a553020b0dc5c41fb6865a2e36bd26045b0b9))
|
|
35
|
+
* update framework core ([d0ffcba](https://github.com/twinfoundation/rights-management/commit/d0ffcba9cf1dc2b562193ee298f099612d100ce8))
|
|
36
|
+
* update twindev schemas ([5d4edc1](https://github.com/twinfoundation/rights-management/commit/5d4edc1326fef611619d4b371a5d05a75ada719a))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* adding missing dependency ([#15](https://github.com/twinfoundation/rights-management/issues/15)) ([c7e6267](https://github.com/twinfoundation/rights-management/commit/c7e62678b296ef8d28c31921cb78aeabe674cd84))
|
|
42
|
+
* modifying the function name for the rest routes ([#6](https://github.com/twinfoundation/rights-management/issues/6)) ([7915111](https://github.com/twinfoundation/rights-management/commit/7915111ac608c9d69bcaa819c85b553fc9bace6a))
|
|
43
|
+
* query params force coercion ([8590a0d](https://github.com/twinfoundation/rights-management/commit/8590a0da92584c04b67e73c448319f96f70c34a5))
|
|
44
|
+
* slimline openapi spec ([aacb9d5](https://github.com/twinfoundation/rights-management/commit/aacb9d50f80d3652ef7419ca3777f53e542773f1))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Dependencies
|
|
48
|
+
|
|
49
|
+
* The following workspace dependencies were updated
|
|
50
|
+
* dependencies
|
|
51
|
+
* @twin.org/rights-management-models bumped from 0.0.2-next.0 to 0.0.2-next.1
|
|
52
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.2-next.0 to 0.0.2-next.1
|
|
53
|
+
|
|
3
54
|
## 0.0.1 (2025-07-08)
|
|
4
55
|
|
|
5
56
|
|
package/docs/open-api/spec.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"openapi": "3.1.
|
|
2
|
+
"openapi": "3.1.1",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "TWIN - Test Endpoints",
|
|
5
5
|
"description": "REST API for TWIN - Test Endpoints.",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"content": {
|
|
40
40
|
"application/json": {
|
|
41
41
|
"schema": {
|
|
42
|
-
"$ref": "https://schema.twindev.org/odrl/OdrlPolicy"
|
|
42
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlPolicy"
|
|
43
43
|
},
|
|
44
44
|
"examples": {
|
|
45
45
|
"papCreateExample": {
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
"content": {
|
|
162
162
|
"application/json": {
|
|
163
163
|
"schema": {
|
|
164
|
-
"$ref": "https://schema.twindev.org/odrl/OdrlPolicy"
|
|
164
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlPolicy"
|
|
165
165
|
},
|
|
166
166
|
"examples": {
|
|
167
167
|
"papUpdateExample": {
|
|
@@ -274,7 +274,7 @@
|
|
|
274
274
|
"content": {
|
|
275
275
|
"application/json": {
|
|
276
276
|
"schema": {
|
|
277
|
-
"$ref": "https://schema.twindev.org/odrl/OdrlPolicy"
|
|
277
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlPolicy"
|
|
278
278
|
},
|
|
279
279
|
"examples": {
|
|
280
280
|
"papRetrieveResponseExample": {
|
|
@@ -576,6 +576,121 @@
|
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
|
+
},
|
|
580
|
+
"/rights-management/pep/intercept": {
|
|
581
|
+
"post": {
|
|
582
|
+
"operationId": "pepIntercept",
|
|
583
|
+
"summary": "Intercept a request",
|
|
584
|
+
"tags": [
|
|
585
|
+
"Policy Administration Point"
|
|
586
|
+
],
|
|
587
|
+
"security": [
|
|
588
|
+
{
|
|
589
|
+
"jwtBearerAuthScheme": []
|
|
590
|
+
}
|
|
591
|
+
],
|
|
592
|
+
"requestBody": {
|
|
593
|
+
"description": "The request structure for intercepting a request and enforcing a policy.",
|
|
594
|
+
"required": true,
|
|
595
|
+
"content": {
|
|
596
|
+
"application/json": {
|
|
597
|
+
"schema": {
|
|
598
|
+
"$ref": "#/components/schemas/PepInterceptRequest"
|
|
599
|
+
},
|
|
600
|
+
"examples": {
|
|
601
|
+
"pepInterceptExample": {
|
|
602
|
+
"value": {
|
|
603
|
+
"assetType": "document",
|
|
604
|
+
"action": "view",
|
|
605
|
+
"data": {
|
|
606
|
+
"id": "document-1",
|
|
607
|
+
"param1": 1,
|
|
608
|
+
"param2": 2
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
"responses": {
|
|
617
|
+
"200": {
|
|
618
|
+
"description": "The response structure for intercepting a request and enforcing a policy.",
|
|
619
|
+
"content": {
|
|
620
|
+
"application/json": {
|
|
621
|
+
"schema": {
|
|
622
|
+
"$ref": "#/components/schemas/PepInterceptResponse"
|
|
623
|
+
},
|
|
624
|
+
"examples": {
|
|
625
|
+
"pepInterceptResponseExample": {
|
|
626
|
+
"value": {
|
|
627
|
+
"id": "document-1",
|
|
628
|
+
"param1": 1
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
"400": {
|
|
636
|
+
"description": "The server cannot process the request, see the content for more details.",
|
|
637
|
+
"content": {
|
|
638
|
+
"application/json": {
|
|
639
|
+
"schema": {
|
|
640
|
+
"$ref": "#/components/schemas/Error"
|
|
641
|
+
},
|
|
642
|
+
"examples": {
|
|
643
|
+
"exampleResponse": {
|
|
644
|
+
"value": {
|
|
645
|
+
"name": "GeneralError",
|
|
646
|
+
"message": "component.error",
|
|
647
|
+
"properties": {
|
|
648
|
+
"foo": "bar"
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
"401": {
|
|
657
|
+
"description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
|
|
658
|
+
"content": {
|
|
659
|
+
"application/json": {
|
|
660
|
+
"schema": {
|
|
661
|
+
"$ref": "#/components/schemas/Error"
|
|
662
|
+
},
|
|
663
|
+
"examples": {
|
|
664
|
+
"exampleResponse": {
|
|
665
|
+
"value": {
|
|
666
|
+
"name": "UnauthorizedError",
|
|
667
|
+
"message": "component.error"
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
"500": {
|
|
675
|
+
"description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
|
|
676
|
+
"content": {
|
|
677
|
+
"application/json": {
|
|
678
|
+
"schema": {
|
|
679
|
+
"$ref": "#/components/schemas/Error"
|
|
680
|
+
},
|
|
681
|
+
"examples": {
|
|
682
|
+
"exampleResponse": {
|
|
683
|
+
"value": {
|
|
684
|
+
"name": "InternalServerError",
|
|
685
|
+
"message": "component.error"
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
579
694
|
}
|
|
580
695
|
},
|
|
581
696
|
"components": {
|
|
@@ -604,7 +719,7 @@
|
|
|
604
719
|
"type": "string",
|
|
605
720
|
"description": "The stack trace for the error."
|
|
606
721
|
},
|
|
607
|
-
"
|
|
722
|
+
"cause": {
|
|
608
723
|
"$ref": "#/components/schemas/Error"
|
|
609
724
|
}
|
|
610
725
|
},
|
|
@@ -615,6 +730,357 @@
|
|
|
615
730
|
"additionalProperties": false,
|
|
616
731
|
"description": "Model to describe serialized error."
|
|
617
732
|
},
|
|
733
|
+
"OdrlPolicy": {
|
|
734
|
+
"type": "object",
|
|
735
|
+
"properties": {
|
|
736
|
+
"@context": {
|
|
737
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlContextType"
|
|
738
|
+
},
|
|
739
|
+
"@type": {
|
|
740
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/PolicyType"
|
|
741
|
+
},
|
|
742
|
+
"profile": {
|
|
743
|
+
"anyOf": [
|
|
744
|
+
{
|
|
745
|
+
"type": "string"
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
"type": "array",
|
|
749
|
+
"items": false,
|
|
750
|
+
"prefixItems": [
|
|
751
|
+
{
|
|
752
|
+
"type": "string"
|
|
753
|
+
}
|
|
754
|
+
]
|
|
755
|
+
}
|
|
756
|
+
],
|
|
757
|
+
"description": "The profile(s) this policy conforms to. IRIs identifying the ODRL Profile(s)."
|
|
758
|
+
},
|
|
759
|
+
"assigner": {
|
|
760
|
+
"anyOf": [
|
|
761
|
+
{
|
|
762
|
+
"type": "string"
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlParty"
|
|
766
|
+
}
|
|
767
|
+
],
|
|
768
|
+
"description": "The assigner of the policy. Applies to all rules unless overridden at rule level."
|
|
769
|
+
},
|
|
770
|
+
"assignee": {
|
|
771
|
+
"anyOf": [
|
|
772
|
+
{
|
|
773
|
+
"type": "string"
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlParty"
|
|
777
|
+
}
|
|
778
|
+
],
|
|
779
|
+
"description": "The assignee of the policy. Applies to all rules unless overridden at rule level."
|
|
780
|
+
},
|
|
781
|
+
"target": {
|
|
782
|
+
"anyOf": [
|
|
783
|
+
{
|
|
784
|
+
"type": "string"
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlAsset"
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
"type": "array",
|
|
791
|
+
"items": false,
|
|
792
|
+
"prefixItems": [
|
|
793
|
+
{
|
|
794
|
+
"anyOf": [
|
|
795
|
+
{
|
|
796
|
+
"type": "string"
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlAsset"
|
|
800
|
+
}
|
|
801
|
+
]
|
|
802
|
+
}
|
|
803
|
+
]
|
|
804
|
+
}
|
|
805
|
+
],
|
|
806
|
+
"description": "The target asset for the rule."
|
|
807
|
+
},
|
|
808
|
+
"action": {
|
|
809
|
+
"anyOf": [
|
|
810
|
+
{
|
|
811
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/ActionType"
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlAction"
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
"type": "array",
|
|
818
|
+
"items": false,
|
|
819
|
+
"prefixItems": [
|
|
820
|
+
{
|
|
821
|
+
"anyOf": [
|
|
822
|
+
{
|
|
823
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/ActionType"
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlAction"
|
|
827
|
+
}
|
|
828
|
+
]
|
|
829
|
+
}
|
|
830
|
+
]
|
|
831
|
+
}
|
|
832
|
+
],
|
|
833
|
+
"description": "The action associated with the rule."
|
|
834
|
+
},
|
|
835
|
+
"inheritFrom": {
|
|
836
|
+
"anyOf": [
|
|
837
|
+
{
|
|
838
|
+
"type": "string"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
"type": "array",
|
|
842
|
+
"items": false,
|
|
843
|
+
"prefixItems": [
|
|
844
|
+
{
|
|
845
|
+
"type": "string"
|
|
846
|
+
}
|
|
847
|
+
]
|
|
848
|
+
}
|
|
849
|
+
],
|
|
850
|
+
"description": "The parent policy(ies) this policy inherits from. IRIs identifying the parent Policy(ies)."
|
|
851
|
+
},
|
|
852
|
+
"conflict": {
|
|
853
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/ConflictStrategyType"
|
|
854
|
+
},
|
|
855
|
+
"permission": {
|
|
856
|
+
"type": "array",
|
|
857
|
+
"items": false,
|
|
858
|
+
"description": "The permissions in the policy. At least one of permission, prohibition, or obligation must be present.",
|
|
859
|
+
"prefixItems": [
|
|
860
|
+
{
|
|
861
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlPermission"
|
|
862
|
+
}
|
|
863
|
+
]
|
|
864
|
+
},
|
|
865
|
+
"prohibition": {
|
|
866
|
+
"type": "array",
|
|
867
|
+
"items": false,
|
|
868
|
+
"description": "The prohibitions in the policy. At least one of permission, prohibition, or obligation must be present.",
|
|
869
|
+
"prefixItems": [
|
|
870
|
+
{
|
|
871
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlProhibition"
|
|
872
|
+
}
|
|
873
|
+
]
|
|
874
|
+
},
|
|
875
|
+
"obligation": {
|
|
876
|
+
"type": "array",
|
|
877
|
+
"items": false,
|
|
878
|
+
"description": "The obligations in the policy. At least one of permission, prohibition, or obligation must be present.",
|
|
879
|
+
"prefixItems": [
|
|
880
|
+
{
|
|
881
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlDuty"
|
|
882
|
+
}
|
|
883
|
+
]
|
|
884
|
+
},
|
|
885
|
+
"@id": {
|
|
886
|
+
"anyOf": [
|
|
887
|
+
{
|
|
888
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
"type": "array",
|
|
892
|
+
"items": false,
|
|
893
|
+
"prefixItems": [
|
|
894
|
+
{
|
|
895
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
896
|
+
}
|
|
897
|
+
]
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdLanguageMap"
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIndexMap"
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIdMap"
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdTypeMap"
|
|
913
|
+
}
|
|
914
|
+
]
|
|
915
|
+
},
|
|
916
|
+
"@included": {
|
|
917
|
+
"anyOf": [
|
|
918
|
+
{
|
|
919
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
"type": "array",
|
|
923
|
+
"items": false,
|
|
924
|
+
"prefixItems": [
|
|
925
|
+
{
|
|
926
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
927
|
+
}
|
|
928
|
+
]
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdLanguageMap"
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIndexMap"
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIdMap"
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdTypeMap"
|
|
944
|
+
}
|
|
945
|
+
]
|
|
946
|
+
},
|
|
947
|
+
"@graph": {
|
|
948
|
+
"anyOf": [
|
|
949
|
+
{
|
|
950
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
"type": "array",
|
|
954
|
+
"items": false,
|
|
955
|
+
"prefixItems": [
|
|
956
|
+
{
|
|
957
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
958
|
+
}
|
|
959
|
+
]
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdLanguageMap"
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIndexMap"
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIdMap"
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdTypeMap"
|
|
975
|
+
}
|
|
976
|
+
]
|
|
977
|
+
},
|
|
978
|
+
"@nest": {
|
|
979
|
+
"anyOf": [
|
|
980
|
+
{
|
|
981
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
"type": "array",
|
|
985
|
+
"items": false,
|
|
986
|
+
"prefixItems": [
|
|
987
|
+
{
|
|
988
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
989
|
+
}
|
|
990
|
+
]
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdLanguageMap"
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIndexMap"
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIdMap"
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdTypeMap"
|
|
1006
|
+
}
|
|
1007
|
+
]
|
|
1008
|
+
},
|
|
1009
|
+
"@reverse": {
|
|
1010
|
+
"anyOf": [
|
|
1011
|
+
{
|
|
1012
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
"type": "array",
|
|
1016
|
+
"items": false,
|
|
1017
|
+
"prefixItems": [
|
|
1018
|
+
{
|
|
1019
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
1020
|
+
}
|
|
1021
|
+
]
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdLanguageMap"
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIndexMap"
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIdMap"
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdTypeMap"
|
|
1037
|
+
}
|
|
1038
|
+
]
|
|
1039
|
+
},
|
|
1040
|
+
"@index": {
|
|
1041
|
+
"anyOf": [
|
|
1042
|
+
{
|
|
1043
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
"type": "array",
|
|
1047
|
+
"items": false,
|
|
1048
|
+
"prefixItems": [
|
|
1049
|
+
{
|
|
1050
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
|
|
1051
|
+
}
|
|
1052
|
+
]
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdLanguageMap"
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIndexMap"
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdIdMap"
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdTypeMap"
|
|
1068
|
+
}
|
|
1069
|
+
]
|
|
1070
|
+
}
|
|
1071
|
+
},
|
|
1072
|
+
"required": [
|
|
1073
|
+
"@context",
|
|
1074
|
+
"@type",
|
|
1075
|
+
"@id",
|
|
1076
|
+
"@included",
|
|
1077
|
+
"@graph",
|
|
1078
|
+
"@nest",
|
|
1079
|
+
"@reverse",
|
|
1080
|
+
"@index"
|
|
1081
|
+
],
|
|
1082
|
+
"additionalProperties": false
|
|
1083
|
+
},
|
|
618
1084
|
"PapQueryResponse": {
|
|
619
1085
|
"type": "object",
|
|
620
1086
|
"properties": {
|
|
@@ -624,10 +1090,11 @@
|
|
|
624
1090
|
},
|
|
625
1091
|
"policies": {
|
|
626
1092
|
"type": "array",
|
|
1093
|
+
"items": false,
|
|
627
1094
|
"description": "The policies matching the query.",
|
|
628
1095
|
"prefixItems": [
|
|
629
1096
|
{
|
|
630
|
-
"$ref": "https://schema.twindev.org/odrl/OdrlPolicy"
|
|
1097
|
+
"$ref": "https://schema.twindev.org/w3c-odrl/OdrlPolicy"
|
|
631
1098
|
}
|
|
632
1099
|
]
|
|
633
1100
|
}
|
|
@@ -637,6 +1104,32 @@
|
|
|
637
1104
|
],
|
|
638
1105
|
"additionalProperties": false,
|
|
639
1106
|
"description": "The body of the response."
|
|
1107
|
+
},
|
|
1108
|
+
"PepInterceptRequest": {
|
|
1109
|
+
"type": "object",
|
|
1110
|
+
"properties": {
|
|
1111
|
+
"assetType": {
|
|
1112
|
+
"type": "string",
|
|
1113
|
+
"description": "The type of the asset to enforce the policy on."
|
|
1114
|
+
},
|
|
1115
|
+
"action": {
|
|
1116
|
+
"type": "string",
|
|
1117
|
+
"description": "The action to perform on the asset."
|
|
1118
|
+
},
|
|
1119
|
+
"data": {
|
|
1120
|
+
"description": "The data to include in the request."
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
"required": [
|
|
1124
|
+
"assetType",
|
|
1125
|
+
"action",
|
|
1126
|
+
"data"
|
|
1127
|
+
],
|
|
1128
|
+
"additionalProperties": false,
|
|
1129
|
+
"description": "The body parameters of the request."
|
|
1130
|
+
},
|
|
1131
|
+
"PepInterceptResponse": {
|
|
1132
|
+
"description": "The manipulated data with any policies applied."
|
|
640
1133
|
}
|
|
641
1134
|
},
|
|
642
1135
|
"securitySchemes": {
|
|
@@ -29,14 +29,6 @@ The options for the service.
|
|
|
29
29
|
|
|
30
30
|
## Properties
|
|
31
31
|
|
|
32
|
-
### NAMESPACE
|
|
33
|
-
|
|
34
|
-
> `readonly` `static` **NAMESPACE**: `string` = `"rights-management"`
|
|
35
|
-
|
|
36
|
-
The namespace supported by the Rights Management service.
|
|
37
|
-
|
|
38
|
-
***
|
|
39
|
-
|
|
40
32
|
### CLASS\_NAME
|
|
41
33
|
|
|
42
34
|
> `readonly` **CLASS\_NAME**: `string`
|
|
@@ -188,3 +180,59 @@ Cursor for next page of results and the policies matching the query.
|
|
|
188
180
|
#### Implementation of
|
|
189
181
|
|
|
190
182
|
`IRightsManagementComponent.papQuery`
|
|
183
|
+
|
|
184
|
+
***
|
|
185
|
+
|
|
186
|
+
### pepIntercept()
|
|
187
|
+
|
|
188
|
+
> **pepIntercept**\<`T`\>(`assetType`, `action`, `data`, `userIdentity`, `nodeIdentity`): `Promise`\<`undefined` \| `T`\>
|
|
189
|
+
|
|
190
|
+
PEP: Process the data using Policy Decision Point (PDP) and return the manipulated data.
|
|
191
|
+
|
|
192
|
+
#### Type Parameters
|
|
193
|
+
|
|
194
|
+
##### T
|
|
195
|
+
|
|
196
|
+
`T` = `unknown`
|
|
197
|
+
|
|
198
|
+
#### Parameters
|
|
199
|
+
|
|
200
|
+
##### assetType
|
|
201
|
+
|
|
202
|
+
`string`
|
|
203
|
+
|
|
204
|
+
The type of asset being processed.
|
|
205
|
+
|
|
206
|
+
##### action
|
|
207
|
+
|
|
208
|
+
`string`
|
|
209
|
+
|
|
210
|
+
The action being performed on the asset.
|
|
211
|
+
|
|
212
|
+
##### data
|
|
213
|
+
|
|
214
|
+
The data to process.
|
|
215
|
+
|
|
216
|
+
`undefined` | `T`
|
|
217
|
+
|
|
218
|
+
##### userIdentity
|
|
219
|
+
|
|
220
|
+
The user identity to use in the decision making.
|
|
221
|
+
|
|
222
|
+
`undefined` | `string`
|
|
223
|
+
|
|
224
|
+
##### nodeIdentity
|
|
225
|
+
|
|
226
|
+
The node identity to use in the decision making.
|
|
227
|
+
|
|
228
|
+
`undefined` | `string`
|
|
229
|
+
|
|
230
|
+
#### Returns
|
|
231
|
+
|
|
232
|
+
`Promise`\<`undefined` \| `T`\>
|
|
233
|
+
|
|
234
|
+
The manipulated data with any policies applied.
|
|
235
|
+
|
|
236
|
+
#### Implementation of
|
|
237
|
+
|
|
238
|
+
`IRightsManagementComponent.pepIntercept`
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Function: pepIntercept()
|
|
2
|
+
|
|
3
|
+
> **pepIntercept**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`IPepInterceptResponse`\>
|
|
4
|
+
|
|
5
|
+
PEP: Intercept.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### httpRequestContext
|
|
10
|
+
|
|
11
|
+
`IHttpRequestContext`
|
|
12
|
+
|
|
13
|
+
The request context for the API.
|
|
14
|
+
|
|
15
|
+
### componentName
|
|
16
|
+
|
|
17
|
+
`string`
|
|
18
|
+
|
|
19
|
+
The name of the component to use in the routes.
|
|
20
|
+
|
|
21
|
+
### request
|
|
22
|
+
|
|
23
|
+
`IPepInterceptRequest`
|
|
24
|
+
|
|
25
|
+
The request.
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
`Promise`\<`IPepInterceptResponse`\>
|
|
30
|
+
|
|
31
|
+
The response object with additional http response properties.
|
package/docs/reference/index.md
CHANGED
|
@@ -4,14 +4,28 @@ The constructor options for the RightsManagementService.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### policyAdministrationPointComponentType?
|
|
8
8
|
|
|
9
|
-
> `optional` **
|
|
9
|
+
> `optional` **policyAdministrationPointComponentType**: `string`
|
|
10
10
|
|
|
11
11
|
The type of the Policy Administration Point (PAP) component.
|
|
12
12
|
|
|
13
13
|
#### Default
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
|
|
16
|
+
policy-administration-point
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### policyEnforcementPointComponentType?
|
|
22
|
+
|
|
23
|
+
> `optional` **policyEnforcementPointComponentType**: `string`
|
|
24
|
+
|
|
25
|
+
The type of the Policy Enforcement Point (PEP) component.
|
|
26
|
+
|
|
27
|
+
#### Default
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
policy-enforcement-point
|
|
17
31
|
```
|
package/locales/en.json
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
"papUpdateFailed": "Failed to update policy through PAP",
|
|
7
7
|
"papRetrieveFailed": "Failed to retrieve policy through PAP",
|
|
8
8
|
"papRemoveFailed": "Failed to remove policy through PAP",
|
|
9
|
-
"papQueryFailed": "Failed to query policies through PAP"
|
|
9
|
+
"papQueryFailed": "Failed to query policies through PAP",
|
|
10
|
+
"pepInterceptFailed": "Failed to intercept data through PEP"
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/rights-management-service",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-next.2",
|
|
4
4
|
"description": "Rights Management service implementation and REST endpoint definitions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,14 +14,13 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/api-models": "
|
|
18
|
-
"@twin.org/core": "
|
|
19
|
-
"@twin.org/entity": "
|
|
20
|
-
"@twin.org/nameof": "
|
|
21
|
-
"@twin.org/rights-management-models": "
|
|
22
|
-
"@twin.org/
|
|
23
|
-
"@twin.org/
|
|
24
|
-
"@twin.org/web": "^0.0.1"
|
|
17
|
+
"@twin.org/api-models": "next",
|
|
18
|
+
"@twin.org/core": "next",
|
|
19
|
+
"@twin.org/entity": "next",
|
|
20
|
+
"@twin.org/nameof": "next",
|
|
21
|
+
"@twin.org/rights-management-models": "0.0.2-next.2",
|
|
22
|
+
"@twin.org/standards-w3c-odrl": "next",
|
|
23
|
+
"@twin.org/web": "next"
|
|
25
24
|
},
|
|
26
25
|
"main": "./dist/cjs/index.cjs",
|
|
27
26
|
"module": "./dist/esm/index.mjs",
|