fabbricadigitale / proauth.js Goto Github PK
View Code? Open in Web Editor NEWAutomagically attach OAuth2's tokens to HTTP requests
License: MIT License
Automagically attach OAuth2's tokens to HTTP requests
License: MIT License
The console.log
used to warn the user about the unsupported synchronous XHR to warnings, using console.warn
.
Also accordingly change the the Jasmine spies on them within the xhr-patched.js
test file.
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.
We need to well define packages scopes and usages.
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:
To make it easy to implement such decisions we must explain in detail where, when, and how provided packages should be used.
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 bundlelegacy
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.Thus, just the following bundles are needed:
legacy
that can be included in page by <script>
or imported by end-user app bundledefault
that can be included in page by <script>
or imported by end-user app bundleservice-worker
that can be registered as-is (by default
) or imported by end-user serviceWorker bundleIMHO, for any other customisation end-users should import sources not bundles.
Currently, the normal operation mode (i.e. using the ServiceWorker) is not yet implemented.
The legacy mode behaviour should be replicated using the ServiceWorker.
proath.client.login("user", "qwerty").then(() => {
// Even if fetching a request at this point should work properly...
// but proauth.client.hasSession() is still false because setting session is async
})
Actually, the internal loader has been removed.
An alternative could be to use an external library to decide which operational mode should be used (so which package file should be loaded).
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.
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
).
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
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.