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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@secure-redact/javascript-sdk

v1.0.4

Published

Javascript SDK wrapper for Secure Redact platform. Built and maintained by Pimloc.

Downloads

2

Readme

Secure Redact Javascript SDK

NPM version

Built and maintained by the Pimloc team.

This repo provides a Javascript SDK wrapper for talking to the Secure Redact API. For more information see the API Reference

Table of Contents

Installation

Install via NPM

npm i @secure-redact/javascript-sdk

Usage

The package needs to be configured with your account's clientId and clientSecret, which is available in the Secure Redact App

import { SecureRedactSDK } from '@secure-redact/javascript-sdk';

const secureRedact = new SecureRedact({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET'
});

const data = await secureRedact.uploadMedia({
  mediaPath: 'PRESIGNED_URL'
});

console.log(data.mediaId);

Usage with Typescript

import { SecureRedactSDK } from '@secure-redact/javascript-sdk';
import type {
  SecureRedactUploadMediaParams,
  SecureRedactUploadMediaResponse
} from '@secure-redact/javascript-sdk';

const secureRedact = new SecureRedact({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET'
});

const params: SecureRedactUploadMediaParams = {
  mediaPath: 'PRESIGNED_URL'
};
const data: SecureRedactUploadMediaResponse = await secureRedact.uploadMedia(
  params
);

console.log(data.mediaId);

Upload Media

Function that adds a media to the Secure Redact system. The mediaPath must be a presigned URL that the Secure Redact system can download the file from. To upload a file directly use the File parameter to pass in a File object and pass in an empty string for the mediaPath.

You can monitor progress in two ways. Either by polling our /info route (see Fetch Media Status) or by setting up the stateCallback URL. This must be a URL where the Secure Redact system can POST updates to. For more information see the API reference

const data = await secureRedact.uploadMedia({
  mediaPath: 'PRESIGNED_URL'
});

Parameters:

interface SecureRedactUploadMediaParams {
  mediaPath: string;
  videoTag?: string;
  increasedDetectionAccuracy?: boolean;
  stateCallback?: string;
  exportCallback?: string;
  exportToken?: string;
  detectLicensePlates?: boolean;
  detectFaces?: boolean;
  file?: File;
}

Response:

interface SecureRedactUploadResponse {
  fileInfo: {
    name: string;
    mimetype: string;
    size: number;
  };
  mediaId: SecureRedactMediaId;
  message?: string;
  error: string | null;
}

Fetch Media Status

Function that responds with the current media status. For information on the potential status' see the API reference

const data = await secureRedact.fetchMediaStatus({
  mediaId: 'MEDIA_ID'
});

Parameters:

interface SecureRedactFetchMediaStatusParams {
  mediaId: SecureRedactMediaId;
  username?: SecureRedactUsername;
}

Response:

interface SecureRedactMediaInfo {
  mediaId: SecureRedactMediaId;
  username: SecureRedactUsername;
  error: string | null;
  status: string;
}

Redact Media

Function that starts the Redact Media process, for more information see API reference

const data = await secureRedact.redactMedia({
  mediaId: 'MEDIA_ID'
});

Parameters:

interface SecureRedactRedactMediaParams {
  mediaId: SecureRedactMediaId;
  enlargeBoxes?: number;
  redactAudio?: boolean;
  blur?: 'pixelated' | 'smooth';
  username?: SecureRedactUsername;
}

Response:

interface SecureRedactRedactResponse {
  error: string | null;
}

Download Media

Function that responds with the redacted media, for more information see API reference

const blob = await secureRedact.downloadMedia({
  mediaId: 'MEDIA_ID'
});

// simulate downloading file to user's machine
const blobURL = URL.createObjectURL(blob);
const a = document.createElement('a');
a.setAttribute('href', blobURL);
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(blobURL);

Parameters:

interface SecureRedactDownloadMediaParams {
  username?: SecureRedactUsername;
  mediaId: SecureRedactMediaId;
}

Response:

interface SecureRedactDownloadMediaResponse {
  blob: Blob;
}

Delete Media

Function that deletes the media, for more information see API reference

const blob = await secureRedact.deleteMedia({
  mediaId: 'MEDIA_ID'
});

Parameters:

interface SecureRedactDeleteMediaParams {
  mediaId: SecureRedactMediaId;
}

Response:

interface SecureRedactDeleteMediaResponse {
  error: string | null;
  message: string;
  mediaId: SecureRedactMediaId;
}

Create User

Enterprise Accounts ONLY

Function that creates a new user that belongs to your enterprise account, for more information see API reference

const blob = await secureRedact.createUser({
  username: 'DUMMY_USERNAME'
});

Parameters:

interface SecureRedactCreateUserParams {
  username: SecureRedactUsername;
}

Response:

interface SecureRedactUserInfo {
  username: SecureRedactUsername;
  error: string | null;
  msg?: string;
}

Login User

Enterprise Accounts ONLY

Function that returns a URL to log the user in to the Secure Redact UI, for more information see API reference

const blob = await secureRedact.loginUser({
  username: 'DUMMY_USERNAME'
});

Parameters:

interface SecureRedactLoginUserParams {
  username: SecureRedactUsername;
  mediaId: SecureRedactMediaId;
}

Response:

interface SecureRedactLoginResponse {
  redirectUrl: string;
  success: boolean;
}

Generic Types

type SecureRedactUsername = string;
type SecureRedactMediaId = string;