npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@defra/fcp-audit-publisher

v1.0.5

Published

A library to validate and/or publish FCP Audit events to the FCP Audit service.

Readme

Quality Gate Status Bugs Code Smells Duplicated Lines (%) Coverage Dependabot

FCP Audit Publisher

A library to validate and/or publish FCP Audit events to the FCP Audit service.

Installation

npm install fcp-audit-publisher

Usage

ESM

import { validateAuditEvent, publishAuditEvent } from '@defra/fcp-audit-publisher'

CommonJS

const { validateAuditEvent, publishAuditEvent } = require('@defra/fcp-audit-publisher')

validateAuditEvent(event)

Validates a JSON object against the FCP Audit event schema.

const result = validateAuditEvent({
  correlationid: 'abc-123',
  datetime: '2025-12-01T12:51:41.381Z',
  environment: 'prod',
  version: '1.0.0',
  application: 'FCP001',
  component: 'my-service',
  ip: '192.168.1.100',
  audit: {
    entities: [{ entity: 'application', action: 'created', entityid: 'APP-001' }]
  },
  security: null
})

Return value

On success:

{ valid: true, value: { /* normalised event */ } }

On failure:

{
  valid: false,
  errors: [
    '"datetime" is required',
    '"application" is required'
  ]
}

publishAuditEvent(event, config)

Applies defaults, validates the event, then publishes it to an AWS SNS topic.

The caller is responsible for constructing and reusing an SNSClient.

import { SNSClient } from '@aws-sdk/client-sns'
import { publishAuditEvent } from '@defra/fcp-audit-publisher'

const snsClient = new SNSClient({ region: 'eu-west-2' })

const result = await publishAuditEvent(
  {
    audit: {
      entities: [{ entity: 'application', action: 'created', entityid: 'APP-001' }]
    },
    security: null
  },
  {
    snsClient,
    sns: { topicArn: 'arn:aws:sns:eu-west-2:123456789012:your-sns' },
    application: 'FCP001',
    component: 'my-service',
    environment: 'prod',
    ip: '192.168.1.100',
    generateCorrelationId: true
  }
)

console.log(result.messageId)

Throws an Error if the config is invalid or if the event is invalid after defaults are applied.

Config reference

| Option | Type | Required | Description | |---|---|---|---| | snsClient | SNSClient | Yes | A pre-constructed AWS SDK SNSClient instance. The caller owns its lifecycle | | sns.topicArn | string | Yes | ARN of the SNS topic to publish to | | version | string | No | Default event schema version. Overridden by the event's own version field | | application | string | No | Default application name. Overridden by the event's own application field | | component | string | No | Default component name. Overridden by the event's own component field | | environment | string | No | Default environment. Overridden by the event's own environment field | | ip | string | No | Default IP address. Overridden by the event's own ip field | | generateCorrelationId | boolean | No | When true, generates a UUID v4 as correlationid if the event has none |

Default precedence

For fields that can be defaulted, the order of precedence from lowest to highest is:

library default → config value → event value

| Field | Library default | Config override | Notes | |---|---|---|---| | version | '1.0.0' | config.version | | | datetime | new Date().toISOString() | — | Applied only when absent from event | | correlationid | — | generateCorrelationId: true generates a UUID | Applied only when absent from event | | application | — | config.application | | | component | — | config.component | | | environment | — | config.environment | | | ip | — | config.ip | Should only be used for services reporting their own IP address, ie Cron job or background service. Not when handling requests from users or other services. |


Event schema

All events must satisfy the following schema (validated via Joi):

| Field | Type | Required | Constraints | |---|---|---|---| | correlationid | string | Yes | max 50 chars | | datetime | ISO date string | Yes | | | environment | string | Yes | lowercase, max 20 chars | | version | string | Yes | max 10 chars | | application | string | Yes | max 30 chars | | component | string | Yes | max 30 chars | | ip | string | Yes | max 20 chars | | user | string | No | max 50 chars | | sessionid | string | No | max 50 chars | | audit | object or null | No* | See audit schema below | | security | object or null | No* | See security schema below |

* At least one of audit or security must be present and non-null.

audit object

| Field | Type | Required | Constraints | |---|---|---|---| | entities | array | Yes | min 1 item | | entities[].entity | string | Yes | lowercase, max 120 chars | | entities[].action | string | Yes | lowercase, max 120 chars | | entities[].entityid | string | No | max 120 chars | | accounts | object | No | keys: sbi, frn, vendor, trader, organisationId, crn, personId | | status | string | No | max 120 chars | | details | object | No | free-form |

security object

| Field | Type | Required | Constraints | |---|---|---|---| | pmccode | string | Yes | max 4 chars (hyphens stripped) | | priority | integer | No | defaults to 0 | | details.transactioncode | string | No | max 4 chars | | details.message | string | No | max 120 chars | | details.additionalinfo | string | No | max 120 chars |


Licence

THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at: http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3