GithubHelp home page GithubHelp logo

fabbricadigitale / proauth.js Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 0.0 366 KB

Automagically attach OAuth2's tokens to HTTP requests

License: MIT License

HTML 0.78% JavaScript 99.22%
auth authentication browser client es2015 oauth2 service-worker session-management token-authetication

proauth.js's People

Contributors

leodido avatar leogr avatar theboolean avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

proauth.js's Issues

Occasionally tests fail

Since some of the checks run after a timeout (at the moment 1000ms) after a request is started, we cannot be sure the request was completed, and the test may fail.
This happens a few times, but it shouldn't.

Cross-browser testing

As soon as possible I plan to send our tests on various browsers.

Please help me to define a minimum compatibility matrix.

Refs #7 and #8.

cc @fabbricadigitale/openinnovation.

Docs required for packages and bundles

We need to well define packages scopes and usages.

Rationale

proauth could be used in many ways. Devs could just use it as a standalone library (ie. just adding a <script src="proauth.js></script>) or could bundle it within their apps.
Anyway, some requirements must be met:

  1. The proper built file must be chosen (eg. some browsers need transpiled code)
  2. Choose the operational mode (default or legacy), usually at runtime because it may depend on feature detection
  3. If default mode is chosen, the serviceWorker controller must be included

To make it easy to implement such decisions we must explain in detail where, when, and how provided packages should be used.

Packages

  • client src/client.js should be always included in page context by legacy or default. They should import it directly, because it's an always required dependency. client does nothing until the legacy or the default is bootstrapped. End-users should not include include within the page client directly, but in some edge cases they could import it within their own bundle
  • legacy src/legacy.js should be included in page context. It loads the legacy stuff and bootstraps the client.
  • default src/default.js should be included in page context. It can register the serviceWorker (optionally, opt-out) then when the serviceWorker is ready it bootstraps the client.
  • service-worker src/service-worker.js should run within the serviceWorker context. It's required when the default mode is being used. End-users could use it directly by importing it in their serviceWorker installation, or could use default that's register it automatically.

Bundles

Thus, just the following bundles are needed:

  • legacy that can be included in page by <script> or imported by end-user app bundle
  • default that can be included in page by <script> or imported by end-user app bundle
  • service-worker that can be registered as-is (by default) or imported by end-user serviceWorker bundle

IMHO, for any other customisation end-users should import sources not bundles.

Implement ServiceWorker mode

Currently, the normal operation mode (i.e. using the ServiceWorker) is not yet implemented.

The legacy mode behaviour should be replicated using the ServiceWorker.

Create separate test environments

One for the default library, the other for the legacy one.

This way will be more straightforward to understand compatibilities and to create 2 different browser-support matrices.

To achive this simply use the different saucelabs sub-accounts.

Improve documentation

  • Merge feature/docs
  • Generate diagram images and link within the docs
  • Explain how to use packages
  • Explain how to use proauth.js with ServiceWorker
  • Install section
  • Configuration section
  • Move the releasing section away from README
  • Contributing docs

Source maps not preserved during transpiling

Sinche the libraries are first bundled (via rollup) and then singularly transpiled (via babel) we lost the sourcemaps (generated in the first phase when BUILD_ENV is set to develop).

Sometimes, a test fail

1) doesn't refresh tokens concurrently
     Proauth client
     Expected 2 to be 1.
    at test/unit/client/Client.js:244:23
    at <anonymous>

This is likely a race condition

Safari 9 incompatibility

Using Safari 9 under Mac OS El Capitan (10.11) and making an XHR, results in no network request done and in a JavaScript error that complains about the fact that _extendableBuiltin2.apply is not a function.

The strange thing is that _extendableBuiltin2 is a function itself (maybe this is a babel-plugin-transform-builtin-extend bug?).

Using fetch the behaviour is different: the network request is done, but the promise is not resolved.

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.