diff --git a/packages/auth/src/utils.js b/packages/auth/src/utils.js deleted file mode 100644 index 7e96c124421c14cf2e4b3c9ab8144a58d4971bda..0000000000000000000000000000000000000000 --- a/packages/auth/src/utils.js +++ /dev/null @@ -1,58 +0,0 @@ -import vars from './vars.js'; - -export default { - getAPiUrl: function(path = "", withPrefix = true) { - return vars.apiBaseUrl + (withPrefix ? vars.apiUrlPrefix : "") + path; - }, - - /** - * Parses a link header - * - * The node module parse-link-header didn't work, so https://gist.github.com/niallo/3109252 became handy - * - * @param header - */ - parseLinkHeader: (header) => { - if (header.length === 0) { - throw new Error("input must not be of zero length"); - } - - // Split parts by comma - const parts = header.split(','); - const links = {}; - - // Parse each part into a named link - for(let i=0; i<parts.length; i++) { - const section = parts[i].split(';'); - if (section.length !== 2) { - throw new Error("section could not be split on ';'"); - } - const url = section[0].replace(/<(.*)>/, '$1').trim(); - const name = section[1].replace(/rel="(.*)"/, '$1').trim(); - links[name] = url; - } - - return links; - }, - - /** - * Parses the base url from an url - * - * @param url - * @returns {string} - */ - parseBaseUrl: (url) => { - const pathArray = url.split('/'); - const protocol = pathArray[0]; - const host = pathArray[2]; - return protocol + '//' + host; - }, - - /** - * Reads a setting - * - * @param key - * @returns {*} - */ - setting: (key) => vars[key] -}; diff --git a/packages/auth/src/vars.js b/packages/auth/src/vars.js deleted file mode 100644 index 741b34e27abf609923ce55b7f4051f02b471a615..0000000000000000000000000000000000000000 --- a/packages/auth/src/vars.js +++ /dev/null @@ -1,35 +0,0 @@ -var config = undefined; - -switch(process.env.BUILD) { - case "development": - config = { - apiBaseUrl: 'https://mw-dev.tugraz.at', - apiUrlPrefix: '', - keyCloakClientId: 'auth-dev-mw-frontend', - }; - - break; - case "production": - config = { - apiBaseUrl: 'https://mw.tugraz.at', - apiUrlPrefix: '', - keyCloakClientId: 'auth-prod-mw-frontend', - }; - break; - case "demo": - config = { - apiBaseUrl: 'https://api-demo.tugraz.at', - apiUrlPrefix: '', - keyCloakClientId: 'auth-dev-mw-frontend', - }; - break; - case "local": - default: - config = { - apiBaseUrl: 'http://127.0.0.1:8000', - apiUrlPrefix: '', - keyCloakClientId: 'auth-dev-mw-frontend-local', - }; -} - -export default config; diff --git a/packages/auth/src/vpu-auth-demo.js b/packages/auth/src/vpu-auth-demo.js index 55f67106e01b0e8d54a53899a26140bdc68e6f92..49553319b9fce2fc8987c707a28639746f315dcd 100644 --- a/packages/auth/src/vpu-auth-demo.js +++ b/packages/auth/src/vpu-auth-demo.js @@ -1,4 +1,3 @@ -import utils from './utils.js'; import {i18n} from './i18n.js'; import {html, LitElement} from 'lit-element'; import './vpu-auth'; @@ -37,7 +36,7 @@ class AuthDemo extends LitElement { <h1 class="title">Auth-Demo</h1> </div> <div class="container"> - <vpu-auth lang="${this.lang}" client-id="${utils.setting('keyCloakClientId')}" load-person></vpu-auth> + <vpu-auth lang="${this.lang}" client-id="${commonUtils.setting('keyCloakClientId')}" load-person></vpu-auth> </div> </section> `; diff --git a/packages/auth/src/vpu-auth.js b/packages/auth/src/vpu-auth.js index b1198740dbc05c79eec626e26e55793d4f79cd25..e2bdb65e9920741b32da1088cb09d6f83692d7bc 100644 --- a/packages/auth/src/vpu-auth.js +++ b/packages/auth/src/vpu-auth.js @@ -1,7 +1,6 @@ import {i18n} from './i18n.js'; import {html, LitElement} from 'lit-element'; import JSONLD from 'vpu-common/jsonld' -import utils from "./utils"; import commonUtils from 'vpu-common/utils'; /** @@ -94,7 +93,7 @@ class VPUAuth extends LitElement { that.dispatchInitEvent(); if (that.loadPerson) { - JSONLD.initialize(utils.getAPiUrl(), (jsonld) => { + JSONLD.initialize(commonUtils.getAPiUrl(), (jsonld) => { // find the correct api url for the current person // we are fetching the logged-in person directly to respect the REST philosophy // see: https://github.com/api-platform/api-platform/issues/337 diff --git a/packages/auth/vendor/common b/packages/auth/vendor/common index 378256b0ae92712fd5b8feed3a987cd014617c0b..fdcb4c14ef0375b5dc61d48ca4f59bd6c2561708 160000 --- a/packages/auth/vendor/common +++ b/packages/auth/vendor/common @@ -1 +1 @@ -Subproject commit 378256b0ae92712fd5b8feed3a987cd014617c0b +Subproject commit fdcb4c14ef0375b5dc61d48ca4f59bd6c2561708