Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@ministryofjustice/hmpps-audit-client

Package Overview
Dependencies
Maintainers
21
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ministryofjustice/hmpps-audit-client

Read [this Confluence page](https://dsdmoj.atlassian.net/wiki/spaces/HAA/pages/4598071684/How+to+integrate+with+the+HMPPS+Audit+service) for the full breakdown of this project.

latest
npmnpm
Version
1.1.1
Version published
Maintainers
21
Created
Source

@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.

FAQs

Package last updated on 12 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts