@twin.org/rights-management-service 0.0.2-next.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.
@@ -227,7 +227,50 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
227
227
  }
228
228
  ]
229
229
  };
230
- return [createRoute, updateRoute, retrieveRoute, removeRoute, queryRoute];
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.
@@ -338,13 +396,20 @@ class RightsManagementService {
338
396
  * The PAP component implementation.
339
397
  * @internal
340
398
  */
341
- _papComponent;
399
+ _policyAdministrationPointComponent;
400
+ /**
401
+ * The PEP component implementation.
402
+ * @internal
403
+ */
404
+ _policyEnforcementPointComponent;
342
405
  /**
343
406
  * Create a new instance of RightsManagementService.
344
407
  * @param options The options for the service.
345
408
  */
346
409
  constructor(options) {
347
- this._papComponent = core.ComponentFactory.get(options?.papComponentType ?? "pap");
410
+ this._policyAdministrationPointComponent =
411
+ core.ComponentFactory.get(options?.policyAdministrationPointComponentType ?? "policy-administration-point");
412
+ this._policyEnforcementPointComponent = core.ComponentFactory.get(options?.policyEnforcementPointComponentType ?? "policy-enforcement-point");
348
413
  }
349
414
  /**
350
415
  * PAP: Create a new policy with auto-generated UID.
@@ -352,9 +417,9 @@ class RightsManagementService {
352
417
  * @returns The UID of the created policy.
353
418
  */
354
419
  async papCreate(policy) {
420
+ core.Guards.object(this.CLASS_NAME, "policy", policy);
355
421
  try {
356
- core.Guards.object(this.CLASS_NAME, "policy", policy);
357
- const result = await this._papComponent.create(policy);
422
+ const result = await this._policyAdministrationPointComponent.create(policy);
358
423
  return result;
359
424
  }
360
425
  catch (error) {
@@ -367,9 +432,9 @@ class RightsManagementService {
367
432
  * @returns Nothing.
368
433
  */
369
434
  async papUpdate(policy) {
435
+ core.Guards.object(this.CLASS_NAME, "policy", policy);
370
436
  try {
371
- core.Guards.object(this.CLASS_NAME, "policy", policy);
372
- await this._papComponent.update(policy);
437
+ await this._policyAdministrationPointComponent.update(policy);
373
438
  }
374
439
  catch (error) {
375
440
  throw new core.GeneralError(this.CLASS_NAME, "papUpdateFailed", undefined, error);
@@ -381,9 +446,9 @@ class RightsManagementService {
381
446
  * @returns The policy.
382
447
  */
383
448
  async papRetrieve(policyId) {
449
+ core.Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
384
450
  try {
385
- core.Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
386
- const policy = await this._papComponent.retrieve(policyId);
451
+ const policy = await this._policyAdministrationPointComponent.retrieve(policyId);
387
452
  return policy;
388
453
  }
389
454
  catch (error) {
@@ -396,9 +461,9 @@ class RightsManagementService {
396
461
  * @returns Nothing.
397
462
  */
398
463
  async papRemove(policyId) {
464
+ core.Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
399
465
  try {
400
- core.Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
401
- await this._papComponent.remove(policyId);
466
+ await this._policyAdministrationPointComponent.remove(policyId);
402
467
  }
403
468
  catch (error) {
404
469
  throw new core.GeneralError(this.CLASS_NAME, "papRemoveFailed", undefined, error);
@@ -412,23 +477,43 @@ class RightsManagementService {
412
477
  * @returns Cursor for next page of results and the policies matching the query.
413
478
  */
414
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
+ }
415
489
  try {
416
- if (!core.Is.empty(conditions)) {
417
- core.Guards.object(this.CLASS_NAME, "conditions", conditions);
418
- }
419
- if (!core.Is.empty(cursor)) {
420
- core.Guards.stringValue(this.CLASS_NAME, "cursor", cursor);
421
- }
422
- if (!core.Is.empty(pageSize)) {
423
- core.Guards.integer(this.CLASS_NAME, "pageSize", pageSize);
424
- }
425
- const result = await this._papComponent.query(conditions, cursor, pageSize);
490
+ const result = await this._policyAdministrationPointComponent.query(conditions, cursor, pageSize);
426
491
  return result;
427
492
  }
428
493
  catch (error) {
429
494
  throw new core.GeneralError(this.CLASS_NAME, "papQueryFailed", undefined, error);
430
495
  }
431
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
+ }
432
517
  }
433
518
 
434
519
  /**
@@ -450,5 +535,6 @@ exports.papQuery = papQuery;
450
535
  exports.papRemove = papRemove;
451
536
  exports.papRetrieve = papRetrieve;
452
537
  exports.papUpdate = papUpdate;
538
+ exports.pepIntercept = pepIntercept;
453
539
  exports.restEntryPoints = restEntryPoints;
454
540
  exports.tags = tags;
@@ -225,7 +225,50 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
225
225
  }
226
226
  ]
227
227
  };
228
- return [createRoute, updateRoute, retrieveRoute, removeRoute, queryRoute];
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.
@@ -336,13 +394,20 @@ class RightsManagementService {
336
394
  * The PAP component implementation.
337
395
  * @internal
338
396
  */
339
- _papComponent;
397
+ _policyAdministrationPointComponent;
398
+ /**
399
+ * The PEP component implementation.
400
+ * @internal
401
+ */
402
+ _policyEnforcementPointComponent;
340
403
  /**
341
404
  * Create a new instance of RightsManagementService.
342
405
  * @param options The options for the service.
343
406
  */
344
407
  constructor(options) {
345
- this._papComponent = ComponentFactory.get(options?.papComponentType ?? "pap");
408
+ this._policyAdministrationPointComponent =
409
+ ComponentFactory.get(options?.policyAdministrationPointComponentType ?? "policy-administration-point");
410
+ this._policyEnforcementPointComponent = ComponentFactory.get(options?.policyEnforcementPointComponentType ?? "policy-enforcement-point");
346
411
  }
347
412
  /**
348
413
  * PAP: Create a new policy with auto-generated UID.
@@ -350,9 +415,9 @@ class RightsManagementService {
350
415
  * @returns The UID of the created policy.
351
416
  */
352
417
  async papCreate(policy) {
418
+ Guards.object(this.CLASS_NAME, "policy", policy);
353
419
  try {
354
- Guards.object(this.CLASS_NAME, "policy", policy);
355
- const result = await this._papComponent.create(policy);
420
+ const result = await this._policyAdministrationPointComponent.create(policy);
356
421
  return result;
357
422
  }
358
423
  catch (error) {
@@ -365,9 +430,9 @@ class RightsManagementService {
365
430
  * @returns Nothing.
366
431
  */
367
432
  async papUpdate(policy) {
433
+ Guards.object(this.CLASS_NAME, "policy", policy);
368
434
  try {
369
- Guards.object(this.CLASS_NAME, "policy", policy);
370
- await this._papComponent.update(policy);
435
+ await this._policyAdministrationPointComponent.update(policy);
371
436
  }
372
437
  catch (error) {
373
438
  throw new GeneralError(this.CLASS_NAME, "papUpdateFailed", undefined, error);
@@ -379,9 +444,9 @@ class RightsManagementService {
379
444
  * @returns The policy.
380
445
  */
381
446
  async papRetrieve(policyId) {
447
+ Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
382
448
  try {
383
- Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
384
- const policy = await this._papComponent.retrieve(policyId);
449
+ const policy = await this._policyAdministrationPointComponent.retrieve(policyId);
385
450
  return policy;
386
451
  }
387
452
  catch (error) {
@@ -394,9 +459,9 @@ class RightsManagementService {
394
459
  * @returns Nothing.
395
460
  */
396
461
  async papRemove(policyId) {
462
+ Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
397
463
  try {
398
- Guards.stringValue(this.CLASS_NAME, "policyId", policyId);
399
- await this._papComponent.remove(policyId);
464
+ await this._policyAdministrationPointComponent.remove(policyId);
400
465
  }
401
466
  catch (error) {
402
467
  throw new GeneralError(this.CLASS_NAME, "papRemoveFailed", undefined, error);
@@ -410,23 +475,43 @@ class RightsManagementService {
410
475
  * @returns Cursor for next page of results and the policies matching the query.
411
476
  */
412
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
+ }
413
487
  try {
414
- if (!Is.empty(conditions)) {
415
- Guards.object(this.CLASS_NAME, "conditions", conditions);
416
- }
417
- if (!Is.empty(cursor)) {
418
- Guards.stringValue(this.CLASS_NAME, "cursor", cursor);
419
- }
420
- if (!Is.empty(pageSize)) {
421
- Guards.integer(this.CLASS_NAME, "pageSize", pageSize);
422
- }
423
- const result = await this._papComponent.query(conditions, cursor, pageSize);
488
+ const result = await this._policyAdministrationPointComponent.query(conditions, cursor, pageSize);
424
489
  return result;
425
490
  }
426
491
  catch (error) {
427
492
  throw new GeneralError(this.CLASS_NAME, "papQueryFailed", undefined, error);
428
493
  }
429
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
+ }
430
515
  }
431
516
 
432
517
  /**
@@ -441,4 +526,4 @@ const restEntryPoints = [
441
526
  }
442
527
  ];
443
528
 
444
- 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 pap
7
+ * @default policy-administration-point
8
8
  */
9
- papComponentType?: string;
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>;
@@ -51,4 +51,14 @@ export declare class RightsManagementService implements IRightsManagementCompone
51
51
  cursor?: string;
52
52
  policies: IOdrlPolicy[];
53
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>;
54
64
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,26 @@
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
+
3
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)
4
25
 
5
26
 
@@ -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": {
@@ -989,6 +1104,32 @@
989
1104
  ],
990
1105
  "additionalProperties": false,
991
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."
992
1133
  }
993
1134
  },
994
1135
  "securitySchemes": {
@@ -180,3 +180,59 @@ Cursor for next page of results and the policies matching the query.
180
180
  #### Implementation of
181
181
 
182
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.
@@ -21,3 +21,4 @@
21
21
  - [papRetrieve](functions/papRetrieve.md)
22
22
  - [papRemove](functions/papRemove.md)
23
23
  - [papQuery](functions/papQuery.md)
24
+ - [pepIntercept](functions/pepIntercept.md)
@@ -4,14 +4,28 @@ The constructor options for the RightsManagementService.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### papComponentType?
7
+ ### policyAdministrationPointComponentType?
8
8
 
9
- > `optional` **papComponentType**: `string`
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
- pap
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.2-next.1",
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",
@@ -18,8 +18,7 @@
18
18
  "@twin.org/core": "next",
19
19
  "@twin.org/entity": "next",
20
20
  "@twin.org/nameof": "next",
21
- "@twin.org/rights-management-models": "0.0.2-next.1",
22
- "@twin.org/rights-management-pap-service": "0.0.2-next.1",
21
+ "@twin.org/rights-management-models": "0.0.2-next.2",
23
22
  "@twin.org/standards-w3c-odrl": "next",
24
23
  "@twin.org/web": "next"
25
24
  },