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
- Installation
- Upload Media
- Fetch Media Status
- Redact Media
- Download Media
- Delete Media
- Create User
- Login User
- Generic Types
Install via NPM
npm i @secure-redact/javascript-sdk
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);
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);
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
type SecureRedactUsername = string;
type SecureRedactMediaId = string;