1.1.1 • Published 11 months ago

@ministryofjustice/hmpps-audit-client v1.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

@ministryofjustice/hmpps-audit-client

Read this Confluence page for the full breakdown of this project.

hmpps-audit-client is a Typescript client library designed to simplify the process of publishing audit events in your HMPPS projects. It provides an AuditService class that interfaces with AWS SQS (Simple Queue Service) to send audit messages asynchronously.

Installation

To install the package, run the following command in your project directory:

npm install @ministryofjustice/hmpps-audit-client

Usage

Here's a quick example of how to use hmpps-audit-client:

import { auditService } from 'hmpps-audit-client';

async function sendAuditEvent() {
  try {
    await auditService.sendAuditMessage({
      action: 'DELETE_USER',
      who: 'userWhoCarriedOutDelete@example.com',
      subjectId: '123',
      subjectType: 'USER_ID',
      service: 'hmpps-audit-poc-ui',
      details: "{ 'deletionSuccessful': true }",
      // Additional parameters are optional
    });
    console.log('Audit event sent successfully');
  } catch (error) {
    console.error('Error sending audit event:', error);
  }
}

sendAuditEvent();

API

The sendAuditMessage method accepts an object with the following properties:

  • action (string): The action being audited. This should be capitalised with underscore separators e.g. VIEW_DPS_USER
  • who (string): Identifier of the user or entity performing the action.
  • subjectId (optional string): Identifier of the subject of the action e.g. which user is being viewed.
  • subjectType (optional string): Type of the subject (e.g., 'USER_ID').
  • correlationId (optional string): Correlation ID for the event. This is useful for linking multiple audit events to each other.
  • service (string): the service that produced this event e.g. 'hmpps-manage-users'.
  • details (optional string): Additional details about the event. This must be a JSON string, as per the example.
  • logErrors (optional boolean, defaults to true): Whether to log errors to the console.

Configuration

Have a look at hmpps-audit-poc-ui for a minimal setup for this project.

Contributing

Contributions to @ministryofjustice/hmpps-audit-client are welcome. Please ensure that your code adheres to the existing style and that all tests pass.

1.1.1

11 months ago

1.1.0

11 months ago

1.0.23

12 months ago

1.0.22

12 months ago

1.0.21-SNAPSHOT

12 months ago

1.0.21

12 months ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago