Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

volos-s3

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

volos-s3 - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

2

package.json
{
"name": "volos-s3",
"version": "0.0.0",
"version": "0.0.1",
"description": "Volos AWS S3 Connector",

@@ -5,0 +5,0 @@ "main": "s3Connector.js",

@@ -1,8 +0,8 @@

# volos-s3 connector
# Volos S3 connector
The ``volos-s3`` connector lets you perform CRUD operations on an Amazon Web Services Simple Storage Service (S3) account.
The Volos S3 connector is a Node.js module that lets you perform CRUD operations an Amazon Web Services Simple Storage Service (S3) account through a RESTful API. It is one of the Volos Node.js modules from Apigee. The module is designed to work on Apigee Edge but can be run anywhere Node.js applications can run. You can use this module without any dependency on Apigee.
## What is the volos-s3 connector?
### Quick example
The ``volos-s3`` connector maps S3 operations to RESTful API resources and query parameters. For example, a properly configured S3 connector returns a list of buckets, like this:
This module maps S3 operations to RESTful API resources and query parameters. For example, this API call asks for a list of buckets:

@@ -13,3 +13,4 @@ ``curl http://localhost:9058/buckets``

````[{
````
[{
"Buckets": [

@@ -28,58 +29,122 @@ {

To get a larger set of attributes, use the query parameter ``expand=true``. This option gives you the flexibility to have a small message payload for a subset of fields if those are all that are required. For example:
# Getting started
``curl http://localhost:9058/buckets?expand=true``
To use this connector you need two things:
# Installation
* a correctly configured S3 connection, and
* an S3-to-REST mapping file.
The ``volos-s3`` module is designed for Node.js and is available through npm:
Let's start by configuring a connection and testing it with the default mapping file. After that, we'll dive into the details of customizing the mapping file.
```
$ npm install volos-s3
```
## What do I need to do first?
# Usage
This connector is a Node.js module. So, you must download and install Node.js on your system to use the connector. Follow the instructions at http://nodejs.org/download/.
There are two examples below, one basic example and one that uses the ``avault`` (Apigee Vault) Node.js module, which is a secure local storage module. Apigee Vault is used to encrypt sensitive login credentials sent to the backend database.
Most of our examples use cURL, a utility for making HTTP requests to servers. We recommend you install cURL or have a REST tool like Postman handy.
### Simple example without Apigee Vault
## How do I install the connector?
The example below shows a simple usage of the ``volos-s3`` connector using the ``http`` module to proxy requests to the connector.
This connector is available through ``npm``. Note that ``npm`` was installed when you installed Node.js.
>**Note:** For this example, you need to specify your S3 login credentials in plaintext. This is not a best practice.
1. Create a folder for the connector.
2. Go to that folder.
3. Enter: ``npm install volos-s3``
## How do I configure my AWS S3 connection?
```
var s3Connector = require('volos-s3');
var http = require('http');
var configuration = require('./configuration.js');
The connector needs to know a little bit about your AWS S3 account before it can actually connect. You'll need this information to complete the config:
var profile = {
accessKeyId: 'myaccesskeyid',
secretAccessKey: 'mysecretkey'
};
var svr = http.createServer(function (req, resp) {
s3ConnectorObject.dispatchRequest(req, resp);
});
svr.listen(9089, function () {
var s3ConnectorObject = new s3Connector.S3Connector({"profile": profile, "configuration": configuration});
s3ConnectorObject.initializePaths(configuration.restMap);
console.log(s3ConnectorObject.applicationName + ' node server is listening');
});
```
### Simple example using the Apigee Vault for local secure storage
This example shows the usage of the ``avault`` module to provide a secure local storage option for credentials and endpoint configuration.
This example assumes you have configured a vault and loaded a configuration profile with a key '*my_profile_key*'. See the section "[S3 connection profile](#s3-connection-profile)" below for a quick example. For a complete description of the ``avault`` module see the [Apigee Vault page on GitHub](https://github.com/apigee-127/avault).
```
var s3Connector = require('volos-s3');
var http = require('http');
var vault = require('avault').createVault(__dirname);
var configuration = require('./configuration.js');
var s3;
vault.get('my-profile-key', function(profileString) {
if (!profileString) {
console.log('Error: required vault not found.');
} else {
var profile = JSON.parse(profileString);
var svr = http.createServer(function(req, resp) {
s3.dispatchRequest(req, resp);
});
svr.listen(9058, function() {
s3 = new s3Connector.S3Connector({"profile": profile, "configuration": configuration});
s3.initializePaths(configuration.restMap);
console.log(s3.applicationName + ' server is listening');
});
}
});
```
# Getting started with your app
To use this connector you need a correctly configured S3 connection for your AWS S3 account.
### S3 connection profile
The S3 configuration profile is used by the connector to establish a connection to the backend S3 data store. The profile includes the following fields:
* **acessKeyId** - The access key ID for your Amazon Web Services S3 account.
* **secretAccessKey** - The secret access key for your Amazon Web Services S3 account.
**Tip:** Log in to your S3 account to find your security credentials, including AWS access keys.
>**Tip:** Log in to your S3 account to find your security credentials, including AWS access keys.
Let's walk through the configuration steps:
**Example:**
```
var profile = {
accessKeyId: 'myaccesskeyid',
secretAccessKey: 'mysecretkey'
};
```
**Note:** We're going to run a utility called ``vaultcli.js``, which will encrypt your sensitive database login credentials. This utility is an ``npm`` module called ``avault``, which was installed along with this connector. If you're curious, you can find it in the ``node_modules`` folder.
### Optional: Encrypting the connection profile with Apigee Vault
1. In a terminal, go to the folder where the ``volos-s3`` module is installed.
2. Enter this command to encrypt your S3 credentials. Fill in your AWS access keys. Also, specify a name for the vault, which is the name the connector uses to load your encrypted credentials.
The ``avault`` module provides local, double-key encrypted storage of sensitive information such as credentials and system endpoints. This provides an option to store these kinds of data in a format other than `text/plain`.
``./node_modules/avault/vaultcli.js --verbose --value='{"accessKeyId":"my-aws-access-key-id", "secretAccessKey": "my-aws-secret-access-key"}' my-vault-name``
In order to insert a value into the vault a command-line tool is provided called `vaultcli`. This tool comes with the `avault` module. Here's an example:
3. Your connector folder now has two new files: ``store.js`` and ``keys.js``. Check to make sure they're present.
4. Open the file ``server-http.js`` and change the first parameter of the ``vault.get()`` method to the name of the vault you created previously:
```
$ vaultcli --verbose --value='{"accessKeyId":"myaccesskeyid", "secretAccessKey": "mysecretaccesskey"}' my-profile-name
```
``vault.get('my-vault-name', function(profileString)``
Note that these are the same keys that are required in the plaintext version of the profile. If this command completes successfully you will find two new files: `store.js` and `keys.js`. Place them in the root directory of the ``volos-s3`` module.
5. Start the HTTP server:
For more detailed usage of the `avault` module refer to the [Apigee Vault page on GitHub](https://github.com/apigee-127/avault).
``node server-http``
# Using the S3 connector
5. Test the server. In another terminal, or in a REST tool like Postman, enter this command:
If you run the Node.js server and call the API like this:
``curl http://localhost:9058``
``curl http://localhost:9058/``
6. This call returns usage information for the API:
The server will return the following API usage information:

@@ -104,20 +169,4 @@ ```

Note that there are some optional query parameters that you can use to filter the results: ``limit`` and ``expand``.
For example, to get a list of all of your buckets:
* **limit** - Specifies the maximum number of records to fetch. For example: ``?limit=10``.
* **expand** - Retrieves expanded records. You can customize both the basic and expanded query strings in the mapping file. For example: ``?expand=true``. By default, this parameter is ``false``.
## Checkpoint
You've configured the S3 connector and verified that you have a valid connection. Next, we'll explain how to use the API.
# Do I need to configure the connector?
The answer is "no". The file ``configurations.js`` contains the infomation that maps S3 bucket queries to well-defined RESTful API resources. You don't need to change this file, but, if you're curious, you can read it to see exactly how the REST API is constructed.
# How do I use the API?
To use this connector's REST API, simply refer to the usage information shown previously. For example, to get a list of all of your buckets:
``curl http://localhost:9056/buckets``

@@ -164,5 +213,9 @@

``curl -X PUT -H Content-Type: application/json http://localhost:9056/buckets/<bucketId>/object?Key=<theObjectKey> -d {./myfile}
```
curl -X PUT -H Content-Type: application/json http://localhost:9056/buckets/<bucketId>/object?Key=<theObjectKey> -d {./myfile}
```
# License
MIT

@@ -175,1 +228,2 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc