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

@fnet/filenet-infra-api

v0.1.15

Published

This project is a simple serverless API designed to manage encrypted content in an S3 bucket. Users can securely fetch or store files associated with a unique address using this API. By ensuring content integrity and authenticity, it serves as a straightf

Downloads

31

Readme

@fnet/filenet-infra-api

This project is a simple serverless API designed to manage encrypted content in an S3 bucket. Users can securely fetch or store files associated with a unique address using this API. By ensuring content integrity and authenticity, it serves as a straightforward solution for securely managing file operations via HTTP requests.

How It Works

The API allows users to perform HTTP requests to either retrieve or store encrypted content on Amazon S3. Each piece of content is associated with a unique address. The process ensures security and validation through the use of public keys, nonces, and signatures. It supports GET, POST, and PUT methods to fetch or push data, ensuring that only valid requests are processed.

Key Features

  • Secure Content Storage: Safely store encrypted content in an S3 bucket through authenticated POST and PUT requests.
  • Reliable Content Retrieval: Fetch encrypted content associated with a unique address via GET requests.
  • Signature Verification: Ensures content integrity and origin authentication by verifying digital signatures.
  • Public Key Validation: Confirms that the provided public key can derive the correct address for accurate authorization.

Conclusion

The @fnet/filenet-infra-api provides a modest yet effective way to manage encrypted files on S3. With built-in security and verification measures, users can confidently store and retrieve data through a simple API interface.

Developer Guide for @fnet/filenet-infra-api

Overview

@fnet/filenet-infra-api is a library designed to interact with a FileNet infrastructure that utilizes AWS S3 for storing and retrieving encrypted content. The primary function exposed by this library allows developers to securely manage content in an S3 bucket using cryptographic verification based on public keys, nonces, and digital signatures. This library ensures that the appropriate security measures are applied during content manipulation operations.

Installation

You can install the @fnet/filenet-infra-api library using either npm or yarn. Here are the commands to do so:

Using npm:

npm install @fnet/filenet-infra-api

Using yarn:

yarn add @fnet/filenet-infra-api

Usage

The primary export of the library is an asynchronous function suitable for handling HTTP events related to file storage and retrieval. Below is a basic example demonstrating how you might use it in an AWS Lambda function:

import api from '@fnet/filenet-infra-api';

exports.handler = async (event) => {
  try {
    const response = await api(event);
    return {
      statusCode: response.statusCode,
      body: JSON.stringify(response.body || { message: response.message }),
    };
  } catch (error) {
    return {
      statusCode: 500,
      body: JSON.stringify({ message: 'Internal Server Error' }),
    };
  }
};

Examples

Here are some examples of how to use the @fnet/filenet-infra-api function in different scenarios:

  • GET Request Example: Fetch the encrypted content from the S3 bucket for a specific address.
const event = {
  httpMethod: 'GET',
  pathParameters: { address: 'yourAddressHere' },
  headers: {
    'x-public-key': 'yourPublicKeyInHexFormat',
    'x-nonce': 'uniqueNonceValue',
  },
};

const response = await api(event);
console.log(response.statusCode); // Expect 200
console.log(response.body); // Expect binary content or error message
  • POST/PUT Request Example: Store encrypted content to the S3 bucket with verification.
const contentToStore = Buffer.from('your data');
const event = {
  httpMethod: 'POST',
  pathParameters: { address: 'yourAddressHere' },
  body: contentToStore,
  headers: {
    'x-public-key': 'yourPublicKeyInHexFormat',
    'x-nonce': 'uniqueNonceValue',
    'x-signature': 'signatureGeneratedForContent',
  },
};

const response = await api(event);
console.log(response.statusCode); // Expect 200
console.log(response.message); // Expect success message

Acknowledgement

While specific external libraries utilized by @fnet/filenet-infra-api are not exposed directly, the usage of cryptographic functions and AWS SDK internals are crucial for its operation. Thank you to the contributors and maintainers of these foundational libraries.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  httpMethod:
    type: string
    description: The HTTP method, e.g., 'GET', 'POST', 'PUT'.
  pathParameters:
    type: object
    properties:
      address:
        type: string
        description: The address extracted from the path parameters.
    required:
      - address
  body:
    oneOf:
      - type: string
        description: The base64 encoded string of the content to be stored.
      - type: "null"
        description: Body can be null when not provided.
  headers:
    type: object
    properties:
      x-public-key:
        type: string
        description: The public key of the client.
      x-nonce:
        type: string
        description: A unique nonce value for the request.
      x-signature:
        type: string
        description: The signature for the request, required for POST or PUT methods.
    required:
      - x-public-key
      - x-nonce
required:
  - httpMethod
  - pathParameters
  - headers