1.0.6 • Published 5 years ago

@getcolo/colo v1.0.6

Weekly downloads
7
License
ISC
Repository
github
Last release
5 years ago

Colo.js

The purpose of this library is to provide a easy-to-use, universal OAuth abstraction to 3rd party identity providers. With Colo, you will be able to abstract away messy OAuth protocol logic when implementing integrations with 3rd party systems. The main use case right now is linking an existing user's account to a 3rd-party provider with the motivation of being able to authorized requests.

Installation

yarn add @colo

Quickstart

In your API, create a route for generating the state value, which we will use to relate the user back to.

import { generateStateValue } from '@colo/middleware';


function genStateValueRouteHandler(req, res) {
    stateValue = generateStateValue(req.body.user_id);
    res.send(200)
}

In your React app, where you will ask the end-user to link their account with a 3rd party provider, include this:

import ColoLink from '@colo/ColoLink';

<ColoLink
    integration={'your 3rd party provider e.g. slack'}
    genStateUrl={'https://your-state-url.com/generate-state'}
    redirectUrl={'https://your-callback-url.com/callback'}
    userId={'johnsmith@gmail.com'}
/>

In your callback url method (server-side), include this:

import { getAccessToken } from '@colo/middleware';

// ...

function callbackUrl(req, res) {
    const access_token = getAccessToken(req, 'integration')
    // store access token in your db (encrypted appropriately of course, please)
}

Supported Providers

Currently, Colo supports the following provider strategies:

  • Slack
  • Google

In Development

  • Jira
  • GitHub
  • Salesforce
  • Facebook
  • Instagram

ColoLink

ColoLink is the React button component that directs the end-user to the appropriate authorization URL. It has the following parameters:

  • integration - the provider you're connecting with i.e. 'slack'
  • redirectUrl - the callback url the end-user goes to after authorizing your app access. This endpoint will also be responsible for getting the user access token
  • generateStateValueUrl - the url that generates and stores a unique state value for the end-user
  • userId - a unique id for the end-user (can be their email; doesn't have to be the pk in the database)

middleware

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago