OAuth 2.0 for the masses!
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github
dist chore(release): 2.11.5 [skip ci] Aug 28, 2018
src
tests fix: fetch requests are now properly enriched with the access token (#… Sep 17, 2018
.babelrc chore(package): update babel-loader to version 8.0.0 🚀 (#255) Aug 29, 2018
.browserslistrc BREAKING CHANGE: 2.0.0 (#93) Oct 14, 2017
.editorconfig
.esdoc.json docs: added examples to each of the login / logout functions (#156) Mar 14, 2018
.eslintrc.yml fix: fetch requests are now properly enriched with the access token (#… Sep 17, 2018
.gitattributes Initial Commit Oct 10, 2016
.gitignore BREAKING CHANGE: 2.0.0 (#93) Oct 14, 2017
.npmignore Initial Commit Oct 10, 2016
.releaserc.yml fix: version should be bumped before building Aug 9, 2018
.travis.yml chore: revert branches only change [ci skip] (#175) Apr 20, 2018
CHANGELOG.md Initial Commit Oct 10, 2016
CODE_OF_CONDUCT.md chore: code of conduct (#76) Oct 14, 2017
CONTRIBUTING.md
LICENSE chore(license): fixed consistency and url in license (#31) Nov 11, 2016
README.md fix: fetch requests are now properly enriched with the access token (#… Sep 17, 2018
bower.json fix: individual lodash functions are now compiled into the source Feb 11, 2018
index.html feat: some providers allow for separate login and logout urls (#224) Jul 6, 2018
karma.ci.conf.js chore: add safari 7 back as a test browser (#238) Jul 18, 2018
karma.conf.js
package-scripts.yml
package.json fix: fetch requests are now properly enriched with the access token (#… Sep 17, 2018
salte-auth.html fix: individual lodash functions are now compiled into the source Feb 11, 2018
webpack.config.js fix: resolved issues with minified and unminified builds (#132) Feb 26, 2018
webpack.server.config.js feat: added ability to login / logout via a new tab (#126) Feb 23, 2018
webpack.test.config.js

README.md

Salte Auth

Gitter NPM Version NPM Downloads Travis Coveralls

Commitizen friendly semantic-release Greenkeeper badge

OAuth 2.0 for the masses!

Supported Browsers

If a version isn't specified that means we test on the latest and greatest, however most versions of that browser should work.

Promise Polyfill

Here's a list of well known ES6 Promise implementations developed by the community!

Any other ES6 Promise implementation will work as well!

Install

You can install this package either with npm or with bower.

npm

$ npm install @salte-io/salte-auth

Then add a <script> to your index.html:

<script src="/node_modules/@salte-io/dist/salte-auth.js"></script>

Or require('@salte-io/salte-auth') from your code.

bower

$ bower install salte-io/salte-auth

Then add a <script> to your index.html:

<script src="/bower_components/salte-auth/dist/salte-auth.js"></script>

HTML Imports (Polymer 1.x - 2.x)

We also support HTML Imports:

<link rel="import" href="/bower_components/salte-auth/salte-auth.html">

ES6 Usage

import { SalteAuth } from '@salte-io/salte-auth';

// Configure SalteAuth with Auth0's url and client id.
const auth = new SalteAuth({
  providerUrl: 'https://salte-alpha.auth0.com',
  responseType: 'id_token',
  redirectUrl: location.origin,
  clientId: 'mM6h2LHJikwdbkvdoiyE8kHhL7gcV8Wb',
  scope: 'openid',

  routes: [
    'http://localhost:8080/account'
  ],

  endpoints: [
    'https://jsonplaceholder.typicode.com/posts/1'
  ],

  provider: 'auth0'
});

// Display an iframe to the user that allows them to login
auth.loginWithIframe();

ES5 Usage

<!DOCTYPE html>
<html>
  <head>
    <script src="/node_modules/@salte-io/salte-auth/dist/salte-auth.js"></script>
    <script>
      const auth = new salte.SalteAuth({
        providerUrl: 'https://salte-alpha.auth0.com',
        responseType: 'id_token',
        redirectUrl: location.origin,
        clientId: 'mM6h2LHJikwdbkvdoiyE8kHhL7gcV8Wb',
        scope: 'openid',
        
        routes: [
          'http://localhost:8080/account'
        ],

        endpoints: [
          'https://jsonplaceholder.typicode.com/posts/1'
        ],

        provider: 'auth0',
      });

      auth.loginWithIframe();
    </script>
  </head>
  <body>
    ...
  </body>
</html>

Known Issues

These are issues that we know about, but don't have a clear fix for!

There are currently no known issues, thanks for checking!

Debugging

Debug logging can be enabled by setting a localStorage variable of debug to @salte-io/salte-auth*.

Documentation

Click here to view the documentation!

Use private or undocumented methods at your own risk, as they will not require a major version bump when breaking changes are made!