New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ugc-guard

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ugc-guard

A JavaScript SDK for UGC Guard content moderation.

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

UGC Guard JavaScript SDK

A JavaScript SDK for UGC Guard content moderation.

Installation

Install the SDK using npm:

npm install ugc-guard

If you need the low-level OpenAPI client:

npm install ugc-guard-api

Usage

Initialize the Client

import { GuardClient } from 'ugc-guard';

const guardClient = new GuardClient({
  organizationId: 'your-org-id',
  baseUrl: 'http://localhost:8099/'
});

Reporting Content

To report content, you need to provide the following:

  • moduleId: The ID of the module.
  • moduleSecret: The secret key for the module.
  • typeId: The type ID of the content.
  • mainContent: The main content to report.
  • reporter: The person reporting the content.
  • options: Additional options such as description, report category, user message, context, and channels.

Example:

import { 
  ReportContent,
  ReportPerson,
  ContentWrapper,
  MultiMediaBody,
  TextBody
} from 'ugc-guard';

const mainContent = new ContentWrapper(
  new ReportContent(
    "3",
    new TextBody({ text: "Example text" })
  ),
  new ReportPerson("1", {
    name: "John Doe",
    email: "john.doe@example.com"
  })
);

const context = [
  new ContentWrapper(
    new ReportContent(
      "4",
      new TextBody({ text: "Context text" })
    ),
    new ReportPerson("2", {
      name: "Jane Doe",
      email: "jane.doe@example.com"
    })
  )
];

const reporter = new ReportPerson("3", {
  name: "Reporter Name",
  email: "reporter@example.com"
});

await guardClient.report(
  "module-id",
  "module-secret",
  "type-id",
  mainContent,
  reporter,
  {
    description: "Report description",
    reportCategory: "other",
    userMessage: "User message",
    context: context,
    channels: []
  }
);

Uploading Files

To upload files, use the MultiMediaBody class:

const body = await MultiMediaBody.fromFilePath('./path-to-file.png');

Verifying Signatures

To verify webhook signatures:

import { GuardClient } from 'ugc-guard';

const isValid = GuardClient.verifySignature(payloadBody, secretToken, signatureHeader);
console.log(`Signature valid: ${isValid}`);

API Client

For advanced use cases, you can use the low-level OpenAPI client:

import { ApiClient, ReportsApi } from 'ugc-guard-api';

const apiClient = new ApiClient('http://localhost:8099/');
const reportsApi = new ReportsApi(apiClient);

FAQs

Package last updated on 24 Jun 2025

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