Giter Club home page Giter Club logo

zacharydavidsaunders / pseudonameapi Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 430 KB

The backend API that serves the Pseudoname website. — A javascript Node/Express API wrapper with middlewares, Mocha/Chai unit tests, and Travis CI integration.

Home Page: https://pseudoname-api.herokuapp.com/

License: Mozilla Public License 2.0

JavaScript 100.00%
api express express-js nodejs node email http privacy security anonymity pseudoname mocha chai forwardmx

pseudonameapi's Introduction

Pseudoname_API

Build Status Pseudoname License: MPL 2.0

What is "PseudonameAPI"?

PseudonameAPI is the backend API that serves the Pseudoname.io website.

To a larger extent, the PseudonameAPI can be viewed as a node.js wrapper for the ForwardMX API. By using this wrapper, Pseudoname is able to keep their API key secret and not exposed in the development console following each ForwardMX API call. Instead of allowing the user to directly access the ForwardMX API, the PseudonameAPI acts as an intermediary and applies additional validation, logging, and security checks to each user request.

PseudonameAPI Diagram

What is "Pseudoname"?

Pseudoname.io is a free, disposable email alias generating service. Pseudoname is also open source and more information about it can be found here.

Installation

PseudonameAPI is very easy to install and launch.

  1. Download the latest release from the Releases Page.
  2. (Optional) If you haven't already, download and install node.js.
  3. Open your terminal of choice.
  4. Move into the project's directory via:
cd Downloads/PseudonameAPI
  1. Install the dependency node modules by running the following command:
npm install

Note: When prompted, you may need to provide administrator credentials to complete the installation.

  1. You will need to set an environment variable for your ForwardMX API Key. On a Mac, this is done via the following command (omit the <> symbols):
export localForwardMxApiKey=<value>

Note: If you make a mistake, you can reverse this action by running:

unset <localForwardMxApiKey>

Once complete, verify that the API key has been set correctly by viewing your environment variables. Again, using a Mac as an example:

env
  1. If correct, you may then start the server via:
node src/index.js
  1. (Optional) Once the server is running, you can use Postman to craft requests, send requests, and view the server's responses.

Tests

Mocha/Chai unit tests have been provided within the /test/ directory. The test files mirror the application files, i.e /test/test.middlewares.js tests the functionality of the middlewares.js file. Run all the tests via:

npm test

Continuous Integration (Build Status) / Deployment

Travis CI is used for continuous integration, the project page can be viewed here. The badge listed above^ (which is also located at the top of this README document) displays the current build status. Each merge into master and each Pull Request is automatically tested and upon passing, is automatically deployed to heroku.

Travis CI arrow Heroku

Supported Routes

Route: HTTP Method: Usage: Requires Parameters?: Is Rate-Limited?:
/ GET This route verifies connectivity, displays the API name, version, and a link to the API documentation (what you're reading now). No No
/add/ POST This route is used to create aliases. Yes Yes
/delete/ DELETE This route is used to delete aliases. Yes Yes

When using a route that requires parameters, the following parameters must be included in the request. If these parameters are not provided, the request will be refused:

Parameter Name (as it must be sent to the API): Parameter Information: Example Parameter Value:
alias This is the desired email alias. The alias is the first few characters of an email, as in @<domain.com>. myalias
realEmail This is the real email address in which the emails destined to the aliases will be forwarded to. [email protected]

The table below contains the response values (JSON keys) associated with each successful API call:

API Response Value Name: Possible Values: Usage:
success TRUE or FALSE This response value indicates whether the requested operation was performed successfully.
message Really anything. Each API call has a specific list of possible messages. This response value provides other information that cannot be expressed in boolean logic.

Rate-Limiting

In an effort to keep the system running smoothly for all users, each IP address is only permitted to make 10 requests, per route, every 60 minutes.

Please see the routes table above for information as to which routes are rate-limited.

Dependencies

In order to make use of the PseudonameAPI, a paid ForwardMX account is required. This service, which is programmatically interacted with, manages users' email aliases and provides the email forwarding/liaison service.

PseudonameAPI utilizes the following open source libraries:

  • Node.js — A Javascript-based, evented input/output framework for the backend.
  • Express — A fast node.js network application framework.
  • XMLHTTPRequest — A wrapper that emulates the web browser's native Javascript XMLHttpRequest object and functionalities.
  • Mocha — A feature-rich JavaScript unit-testing framework.
  • Chai — A BDD (Behavior-Driven Development) / TDD (Test-Driven-Development) assertion library for node.
  • Chai-HTTP — A Chai plug-in that enables Chai assertions to integrate with HTTP operations.
  • Helmet.js — A collection of security addons that can be toggled on/off together or in isolation.
  • ESLint — A linter that helps to enforce code style, structure, and ECMAScript compliance.

"Thank you" to the developers and supporters of these projects, and all open source work for that matter. Without you, PseudonameAPI would not exist.

Logo Mashup

Pull Requests / Contributions

Please review the CONTRIBUTING.md document.

To-Do's

  • Explore the possibility of encryption. — (This may require collaboration with ForwardMX)

Release Notes

You'll find information about each release below.

Version 1.5

  • Updated lodash dependency to address security concern (for more info, see lodash/lodash#4336)

Version 1.4

  • Added Helmet.js for security. (#8)
  • Added rate-limiting. (#9)
  • Updated the codebase to be ECMAScript 8 / ECMAScript 2017 compliant. (#10)
  • Updated the API's HTTP methods (/delete/ is now a DELETE, /add/ is now a POST). (#11)
    • Updated the methods allowed in the CORS middleware.
    • Updated tests.
  • Added the CONTRIBUTING.md file. (#12)
  • Prevented the daisy-chaining of aliases. (#13)
    • Added tests.
  • Upgraded ES-Lint dependency per reports of security issues (#16)
  • Fixed start script (#21)
  • Changed ES-Lint rules (AirBnB laid a good foundation, but some of their requirements, namely forced destructuring, made the codebase less readable).
  • Other small tweaks to logging.
  • Updated documentation.

Version 1.3

  • Added a simple logging middleware for diagnostic purposes.

Version 1.2

  • Tweaked routes to have more uniform responses.
  • Purged old API key.

Version 1.1

  • Added a CORS IP filtering middleware.

Version 1.0

  • Built /, /add/, and /delete/ routes.
  • Added parameter checking middleware.
  • Added parameter validation middleware.
  • Added internal versioning.
  • Added Mocha/Chai unit tests.
  • Added Travis CI support.
  • Added API documentation in the README.

License

Mozilla Public License 2.0

pseudonameapi's People

Contributors

dcstone09 avatar dependabot[bot] avatar zacharydavidsaunders avatar

Stargazers

 avatar

Watchers

 avatar  avatar

pseudonameapi's Issues

Fix start script

The existing start script does not work. The script should install and run PseudonameAPI like:

npm install && node ./src/index.js

Make the codebase ES2017 compliant

In an effort to follow industry standards, the codebase should become ES2017 compliant. ESLint will help identify and correct poor usage and will enforce rules going forward.

Prevent the daisy-chaining of aliases

Users should not be able to chain aliases (create a new alias with an existing alias provided as the “real email” parameter). Daisy-chained aliases puts unnecessary load on the system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.