Permalink
Browse files

refactor(project): refactor all

DEPRECATED:  BaseConfig.current is deprecated. Use BaseConfig instance directly instead
DEPRECATED:  Some BaseConfig parameters have been renamed for consistency
DEPRECATED:  Some AuthService and Authentication parameters and methods have been renamed for consistency
BREAKING CHANGE: authUtils got removed. Extend and aurelia-path are used instead for some functions
  • Loading branch information...
doktordirk committed Apr 8, 2016
1 parent 29d22c5 commit 671f087a2c2e40e2fc1b37d79a2305b32b3ebe2a
Showing with 730 additions and 727 deletions.
  1. +2 −0 config.js
  2. +12 −3 package.json
  3. +18 −16 src/aurelia-authentication.js
  4. +168 −42 src/authService.js
  5. +0 −169 src/authUtils.js
  6. +90 −103 src/authentication.js
  7. +3 −4 src/authorizeStep.js
  8. +306 −232 src/baseConfig.js
  9. +24 −17 src/{app.fetch-httpClient.config.js → fetchClientConfig.js}
  10. +21 −35 src/oAuth1.js
  11. +49 −52 src/oAuth2.js
  12. +29 −41 src/popup.js
  13. +8 −13 src/storage.js
@@ -10,8 +10,10 @@ System.config({
"aurelia-api": "npm:aurelia-api@2.2.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0-beta.1.2.0",
"aurelia-fetch-client": "npm:aurelia-fetch-client@1.0.0-beta.1.2.1",
"aurelia-path": "npm:aurelia-path@1.0.0-beta.1.2.0",
"aurelia-polyfills": "npm:aurelia-polyfills@1.0.0-beta.1.1.1",
"aurelia-router": "npm:aurelia-router@1.0.0-beta.1.2.0",
"extend": "npm:extend@3.0.0",
"fetch": "github:github/fetch@0.11.0",
"npm:aurelia-api@2.2.0": {
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0-beta.1.2.0",
@@ -33,13 +33,17 @@
"aurelia-api": "^2.2.0",
"aurelia-dependency-injection": "^1.0.0-beta.1.2.0",
"aurelia-fetch-client": "^1.0.0-beta.1.2.1",
"aurelia-router": "^1.0.0-beta.1.2.0"
"aurelia-path": "^1.0.0-beta.1.2.0",
"aurelia-router": "^1.0.0-beta.1.2.0",
"extend": "^3.0.0"
},
"peerDependencies": {
"aurelia-api": "^2.2.0",
"aurelia-dependency-injection": "^1.0.0-beta.1.2.0",
"aurelia-fetch-client": "^1.0.0-beta.1.2.1",
"aurelia-router": "^1.0.0-beta.1.2.0"
"aurelia-path": "^1.0.0-beta.1.2.0",
"aurelia-router": "^1.0.0-beta.1.2.0",
"extend": "^3.0.0"
},
"devDependencies": {
"aurelia-polyfills": "^1.0.0-beta.1.1.0",
@@ -50,7 +54,9 @@
"aurelia-api": "^2.2.0",
"aurelia-dependency-injection": "^1.0.0-beta.1.2.0",
"aurelia-fetch-client": "^1.0.0-beta.1.2.1",
"aurelia-router": "^1.0.0-beta.1.2.0"
"aurelia-path": "^1.0.0-beta.1.2.0",
"aurelia-router": "^1.0.0-beta.1.2.0",
"extend": "^3.0.0"
},
"devDependencies": {
"aurelia-tools": "^0.1.20",
@@ -65,8 +71,11 @@
"babel-preset-es2015": "^6.6.0",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-1": "^6.5.0",
"body-parser": "^1.14.2",
"conventional-changelog": "0.0.17",
"cors": "^2.7.1",
"del": "^2.2.0",
"express": "^4.13.3",
"gulp": "^3.8.10",
"gulp-babel": "^6.1.2",
"gulp-bump": "^2.0.1",
@@ -4,8 +4,7 @@ import {Config, Rest} from 'aurelia-api';
import {AuthService} from './authService';
import {AuthorizeStep} from './authorizeStep';
import {BaseConfig} from './baseConfig';
import {FetchConfig} from './app.fetch-httpClient.config';
import {authUtils} from './authUtils';
import {FetchConfig} from './fetchClientConfig';
import './authFilter';
/**
@@ -17,32 +16,36 @@ import './authFilter';
function configure(aurelia, config) {
aurelia.globalResources('./authFilter');
let baseConfig = aurelia.container.get(BaseConfig);
const baseConfig = aurelia.container.get(BaseConfig);
if (typeof config === 'function') {
config(baseConfig);
} else if (typeof config === 'object') {
baseConfig.configure(config);
}
// after baseConfig was configured
let fetchConfig = aurelia.container.get(FetchConfig);
let clientConfig = aurelia.container.get(Config);
const fetchConfig = aurelia.container.get(FetchConfig);
const clientConfig = aurelia.container.get(Config);
// Array? Configure the provided endpoints.
if (Array.isArray(baseConfig.current.configureEndpoints)) {
baseConfig.current.configureEndpoints.forEach(endpointToPatch => {
if (Array.isArray(baseConfig.configureEndpoints)) {
baseConfig.configureEndpoints.forEach(endpointToPatch => {
fetchConfig.configure(endpointToPatch);
});
}
let client;
// Let's see if there's a configured named or default client.
if (baseConfig.current.endpoint !== null) {
client = clientConfig.getEndpoint(baseConfig.current.endpoint);
if (!client) {
throw new Error(`There is no '${baseConfig.current.endpoint || 'default'}' endpoint registered.`);
// Let's see if there's a configured named or default endpoint or a HttpClient.
if (baseConfig.endpoint !== null) {
if (typeof baseConfig.endpoint === 'string') {
const endpoint = clientConfig.getEndpoint(baseConfig.endpoint);
if (!endpoint) {
throw new Error(`There is no '${baseConfig.endpoint || 'default'}' endpoint registered.`);
}
client = endpoint;
} else if (baseConfig.endpoint instanceof HttpClient) {
client = new Rest(baseConfig.endpoint);
}
}
@@ -52,13 +55,12 @@ function configure(aurelia, config) {
}
// Set the client on the config, for use throughout the plugin.
baseConfig.current.client = client;
baseConfig.client = client;
}
export {
configure,
FetchConfig,
AuthService,
AuthorizeStep,
authUtils
AuthorizeStep
};
Oops, something went wrong.

0 comments on commit 671f087

Please sign in to comment.