@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
190
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