From faa420753f0d16c8d2e45d7457503d0ab6fb7cbc Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Thu, 9 Jan 2020 13:31:30 -0500 Subject: [PATCH 01/33] Added argument and typelink components for GraphQL --- components/graphql/argument.vue | 44 +++++++++++++++++++++++++++++++++ components/graphql/typelink.vue | 33 +++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 components/graphql/argument.vue create mode 100644 components/graphql/typelink.vue diff --git a/components/graphql/argument.vue b/components/graphql/argument.vue new file mode 100644 index 000000000..335381a41 --- /dev/null +++ b/components/graphql/argument.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/components/graphql/typelink.vue b/components/graphql/typelink.vue new file mode 100644 index 000000000..b451d7f93 --- /dev/null +++ b/components/graphql/typelink.vue @@ -0,0 +1,33 @@ + + + + + + From cc396aecd3fe7201802ecb6e390840d16f1ebbe9 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Thu, 9 Jan 2020 13:32:38 -0500 Subject: [PATCH 02/33] Updated field, type and graphql page to use the new argument and typelink components --- components/graphql/field.vue | 33 +++++++++++++++++++++++++++++++-- components/graphql/type.vue | 6 ++++-- pages/graphql.vue | 28 +++++++++++++++++++++++----- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/components/graphql/field.vue b/components/graphql/field.vue index b5acb1b54..e717cca2c 100644 --- a/components/graphql/field.vue +++ b/components/graphql/field.vue @@ -1,6 +1,18 @@ @@ -36,9 +49,17 @@ diff --git a/pages/graphql.vue b/pages/graphql.vue index f6c201d94..2ebd97f0c 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -288,7 +288,7 @@
- +
@@ -304,7 +304,7 @@
- +
@@ -320,7 +320,7 @@
- +
@@ -335,8 +335,8 @@ {{ $t("types") }}
-
- +
+
@@ -563,6 +563,24 @@ export default { } }, methods: { + handleJumpToType(type) { + const typesTab = document.getElementById("gqltypes-tab"); + typesTab.checked = true; + + const rootTypeName = this.resolveRootType(type).name; + + const target = document.getElementById(`type_${rootTypeName}`); + if (target) { + target.scrollIntoView({ + behavior: 'smooth' + }); + } + }, + resolveRootType(type) { + let t = type; + while (t.ofType != null) t = t.ofType; + return t; + }, copySchema() { this.$refs.copySchemaCode.innerHTML = this.doneButton; const aux = document.createElement("textarea"); From bf1a143f0327bf12f33697329c0c71b702512bd2 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Fri, 10 Jan 2020 05:30:38 +0530 Subject: [PATCH 03/33] :art: Minor stylings --- components/autocomplete.vue | 1 + components/graphql/argument.vue | 16 +++++----------- components/graphql/field.vue | 24 +++++++++++++----------- components/graphql/type.vue | 2 +- components/graphql/typelink.vue | 13 +++++++------ components/history.vue | 1 + 6 files changed, 28 insertions(+), 29 deletions(-) diff --git a/components/autocomplete.vue b/components/autocomplete.vue index 3a0a936d8..6a32c306b 100644 --- a/components/autocomplete.vue +++ b/components/autocomplete.vue @@ -58,6 +58,7 @@ padding: 8px 16px; font-size: 16px; font-family: "Roboto Mono", monospace; + font-weight: 400; &:last-child { border-radius: 0 0 8px 8px; diff --git a/components/graphql/argument.vue b/components/graphql/argument.vue index 335381a41..d70f0d01c 100644 --- a/components/graphql/argument.vue +++ b/components/graphql/argument.vue @@ -4,18 +4,14 @@ {{ argName }} : - + - + diff --git a/components/graphql/field.vue b/components/graphql/field.vue index e717cca2c..b0fc403e5 100644 --- a/components/graphql/field.vue +++ b/components/graphql/field.vue @@ -4,14 +4,19 @@ {{ fieldName }} ( - - {{ field.name }}: - - , - + + {{ field.name }}: + + + , - ) - : + + ) : +
{{ gqlField.description }} @@ -20,7 +25,6 @@
DEPRECATED
-
@@ -49,7 +53,7 @@ - diff --git a/components/history.vue b/components/history.vue index 2b1acbfac..ad248c56f 100644 --- a/components/history.vue +++ b/components/history.vue @@ -298,6 +298,7 @@ ol li { top: 10px; right: 10px; font-family: "Roboto Mono", monospace; + font-weight: 400; background-color: transparent; padding: 2px 6px; border-radius: 8px; From 57f7621567d6182790142fd472e31e4fb9392297 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Fri, 10 Jan 2020 06:27:48 +0530 Subject: [PATCH 04/33] :recycle: Refactoring code --- assets/js/oauth.js | 150 +++++++++++++++++++++++--------------------- layouts/default.vue | 4 +- pages/graphql.vue | 30 ++++++--- store/postwoman.js | 2 +- 4 files changed, 106 insertions(+), 80 deletions(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 8bd7b0423..10f584ef1 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -1,89 +1,95 @@ -const redirectUri = `${ window.location.origin }/`; +const redirectUri = `${window.location.origin}/`; ////////////////////////////////////////////////////////////////////// // GENERAL HELPER FUNCTIONS // Make a POST request and parse the response as JSON -const sendPostRequest = async(url, params) => { - let body = Object.keys(params).map(key => key + '=' + params[key]).join('&'); +const sendPostRequest = async (url, params) => { + let body = Object.keys(params) + .map(key => `${key}=${params[key]}`) + .join("&"); const options = { - method: 'post', + method: "post", headers: { - 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8' + "Content-type": "application/x-www-form-urlencoded; charset=UTF-8" }, body - } + }; try { const response = await fetch(url, options); const data = await response.json(); return data; } catch (err) { - console.error('Request failed', err); + console.error("Request failed", err); throw err; } -} +}; // Parse a query string into an object const parseQueryString = string => { - if(string == "") { return {}; } - let segments = string.split("&").map(s => s.split("=") ); + if (string === "") { + return {}; + } + let segments = string.split("&").map(s => s.split("=")); let queryString = {}; - segments.forEach(s => queryString[s[0]] = s[1]); + segments.forEach(s => (queryString[s[0]] = s[1])); return queryString; -} +}; // Get OAuth configuration from OpenID Discovery endpoint const getTokenConfiguration = async endpoint => { const options = { - method: 'GET', + method: "GET", headers: { - 'Content-type': 'application/json' + "Content-type": "application/json" } - } + }; try { const response = await fetch(endpoint, options); const config = await response.json(); return config; } catch (err) { - console.error('Request failed', err); + console.error("Request failed", err); throw err; } -} +}; ////////////////////////////////////////////////////////////////////// // PKCE HELPER FUNCTIONS // Generate a secure random string using the browser crypto functions const generateRandomString = () => { - var array = new Uint32Array(28); + const array = new Uint32Array(28); window.crypto.getRandomValues(array); - return Array.from(array, dec => ('0' + dec.toString(16)).substr(-2)).join(''); -} + return Array.from(array, dec => `0${dec.toString(16)}`.substr(-2)).join(""); +}; // Calculate the SHA256 hash of the input text. // Returns a promise that resolves to an ArrayBuffer const sha256 = plain => { const encoder = new TextEncoder(); const data = encoder.encode(plain); - return window.crypto.subtle.digest('SHA-256', data); -} + return window.crypto.subtle.digest("SHA-256", data); +}; // Base64-urlencodes the input string -const base64urlencode = str => { - // Convert the ArrayBuffer to string using Uint8 array to conver to what btoa accepts. +const base64urlencode = ( + str // Convert the ArrayBuffer to string using Uint8 array to conver to what btoa accepts. +) => // btoa accepts chars only within ascii 0-255 and base64 encodes them. // Then convert the base64 encoded to base64url encoded // (replace + with -, replace / with _, trim trailing =) - return btoa(String.fromCharCode.apply(null, new Uint8Array(str))) - .replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); -} + btoa(String.fromCharCode.apply(null, new Uint8Array(str))) + .replace(/\+/g, "-") + .replace(/\//g, "_") + .replace(/=+$/, ""); // Return the base64-urlencoded sha256 hash for the PKCE challenge -const pkceChallengeFromVerifier = async(v) => { +const pkceChallengeFromVerifier = async v => { let hashed = await sha256(v); return base64urlencode(hashed); -} +}; ////////////////////////////////////////////////////////////////////// // OAUTH REQUEST // Initiate PKCE Auth Code flow when requested -const tokenRequest = async({ +const tokenRequest = async ({ oidcDiscoveryUrl, grantType, authUrl, @@ -91,85 +97,89 @@ const tokenRequest = async({ clientId, scope }) => { - // Check oauth configuration - if (oidcDiscoveryUrl !== '') { - const { authorization_endpoint, token_endpoint } = await getTokenConfiguration(oidcDiscoveryUrl); + if (oidcDiscoveryUrl !== "") { + const { + authorization_endpoint, + token_endpoint + } = await getTokenConfiguration(oidcDiscoveryUrl); authUrl = authorization_endpoint; accessTokenUrl = token_endpoint; } // Store oauth information - localStorage.setItem('token_endpoint', accessTokenUrl); - localStorage.setItem('client_id', clientId); + localStorage.setItem("token_endpoint", accessTokenUrl); + localStorage.setItem("client_id", clientId); // Create and store a random state value const state = generateRandomString(); - localStorage.setItem('pkce_state', state); + localStorage.setItem("pkce_state", state); // Create and store a new PKCE code_verifier (the plaintext random secret) const code_verifier = generateRandomString(); - localStorage.setItem('pkce_code_verifier', code_verifier); + localStorage.setItem("pkce_code_verifier", code_verifier); // Hash and base64-urlencode the secret to use as the challenge const code_challenge = await pkceChallengeFromVerifier(code_verifier); // Build the authorization URL - const buildUrl = () => { - return authUrl - + `?response_type=${grantType}` - + '&client_id='+encodeURIComponent(clientId) - + '&state='+encodeURIComponent(state) - + '&scope='+encodeURIComponent(scope) - + '&redirect_uri='+encodeURIComponent(redirectUri) - + '&code_challenge='+encodeURIComponent(code_challenge) - + '&code_challenge_method=S256' - ; - } + const buildUrl = () => + `${authUrl + `?response_type=${grantType}`}&client_id=${encodeURIComponent( + clientId + )}&state=${encodeURIComponent(state)}&scope=${encodeURIComponent( + scope + )}&redirect_uri=${encodeURIComponent( + redirectUri + )}&code_challenge=${encodeURIComponent( + code_challenge + )}&code_challenge_method=S256`; // Redirect to the authorization server window.location = buildUrl(); -} +}; ////////////////////////////////////////////////////////////////////// // OAUTH REDIRECT HANDLING // Handle the redirect back from the authorization server and // get an access token from the token endpoint -const oauthRedirect = async() => { - let tokenResponse = ''; +const oauthRedirect = async () => { + let tokenResponse = ""; let q = parseQueryString(window.location.search.substring(1)); // Check if the server returned an error string - if(q.error) { - alert('Error returned from authorization server: '+q.error); + if (q.error) { + alert(`Error returned from authorization server: ${q.error}`); } // If the server returned an authorization code, attempt to exchange it for an access token - if(q.code) { + if (q.code) { // Verify state matches what we set at the beginning - if(localStorage.getItem('pkce_state') != q.state) { - alert('Invalid state'); + if (localStorage.getItem("pkce_state") != q.state) { + alert("Invalid state"); } else { try { // Exchange the authorization code for an access token - tokenResponse = await sendPostRequest(localStorage.getItem('token_endpoint'), { - grant_type: 'authorization_code', - code: q.code, - client_id: localStorage.getItem('client_id'), - redirect_uri: redirectUri, - code_verifier: localStorage.getItem('pkce_code_verifier') - }); + tokenResponse = await sendPostRequest( + localStorage.getItem("token_endpoint"), + { + grant_type: "authorization_code", + code: q.code, + client_id: localStorage.getItem("client_id"), + redirect_uri: redirectUri, + code_verifier: localStorage.getItem("pkce_code_verifier") + } + ); } catch (err) { - console.log(error.error+'\n\n'+error.error_description); + console.log(`${error.error}\n\n${error.error_description}`); } } // Clean these up since we don't need them anymore - localStorage.removeItem('pkce_state'); - localStorage.removeItem('pkce_code_verifier'); - localStorage.removeItem('token_endpoint'); - localStorage.removeItem('client_id'); + localStorage.removeItem("pkce_state"); + localStorage.removeItem("pkce_code_verifier"); + localStorage.removeItem("token_endpoint"); + localStorage.removeItem("client_id"); return tokenResponse; } return tokenResponse; -} +}; -export { tokenRequest, oauthRedirect } +export { tokenRequest, oauthRedirect }; diff --git a/layouts/default.vue b/layouts/default.vue index 7587f416b..30e0d494b 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -549,8 +549,8 @@ export default { this.$store.state.postwoman.settings.THEME_CLASS || ""; // Load theme color data from settings, or use default color. let color = this.$store.state.postwoman.settings.THEME_COLOR || "#50fa7b"; - let vibrant = this.$store.state.postwoman.settings.THEME_COLOR_VIBRANT; - if (vibrant == null) vibrant = true; + let vibrant = + this.$store.state.postwoman.settings.THEME_COLOR_VIBRANT || true; document.documentElement.style.setProperty("--ac-color", color); document.documentElement.style.setProperty( "--act-color", diff --git a/pages/graphql.vue b/pages/graphql.vue index 2ebd97f0c..fd0919f26 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -288,7 +288,10 @@
- +
@@ -304,7 +307,10 @@
- +
@@ -320,7 +326,10 @@
- +
@@ -335,8 +344,15 @@ {{ $t("types") }}
-
- +
+
@@ -572,13 +588,13 @@ export default { const target = document.getElementById(`type_${rootTypeName}`); if (target) { target.scrollIntoView({ - behavior: 'smooth' + behavior: "smooth" }); } }, resolveRootType(type) { let t = type; - while (t.ofType != null) t = t.ofType; + while (t.ofType !== null) t = t.ofType; return t; }, copySchema() { diff --git a/store/postwoman.js b/store/postwoman.js index 787e93e62..bf5881268 100644 --- a/store/postwoman.js +++ b/store/postwoman.js @@ -75,7 +75,7 @@ export const state = () => ({ export const mutations = { applySetting({ settings }, setting) { if ( - setting == null || + setting === null || !(setting instanceof Array) || setting.length !== 2 ) { From 35a0d509183d7f259ae318c05c8ca77c45c8730e Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Fri, 10 Jan 2020 09:06:08 +0530 Subject: [PATCH 05/33] :bug: Fixed a broken function --- pages/graphql.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/graphql.vue b/pages/graphql.vue index fd0919f26..4f21ba2d8 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -594,7 +594,7 @@ export default { }, resolveRootType(type) { let t = type; - while (t.ofType !== null) t = t.ofType; + while (t.ofType != null) t = t.ofType; return t; }, copySchema() { From bb9db3b1cae00f76b9be5c3aba07f0b37d01bdad Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 11 Jan 2020 00:12:49 +0000 Subject: [PATCH 06/33] :arrow_up: Bump @nuxtjs/google-analytics from 2.2.2 to 2.2.3 Bumps [@nuxtjs/google-analytics](https://github.com/nuxt-community/analytics-module) from 2.2.2 to 2.2.3. - [Release notes](https://github.com/nuxt-community/analytics-module/releases) - [Changelog](https://github.com/nuxt-community/analytics-module/blob/master/CHANGELOG.md) - [Commits](https://github.com/nuxt-community/analytics-module/compare/v2.2.2...v2.2.3) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2b47598bf..65b15a7b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1437,11 +1437,11 @@ } }, "@nuxtjs/google-analytics": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@nuxtjs/google-analytics/-/google-analytics-2.2.2.tgz", - "integrity": "sha512-uzjdj9GEvPa1jB2soPAeTH75u8qbEAMV36i9PLfkv23emfUIPF1PcgsRFJOBT1x19Zeg9ywC4U8q76li912vEQ==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@nuxtjs/google-analytics/-/google-analytics-2.2.3.tgz", + "integrity": "sha512-dPwgsRNECtZqHdmnbJRFy3T4DDVakrpeN7vM1DwAIV1FXYlIBMKvdi8nt1v8TPU4IZdaoXrQodfeNMCooPo/7g==", "requires": { - "vue-analytics": "^5.18.0" + "vue-analytics": "^5.22.1" } }, "@nuxtjs/google-tag-manager": { @@ -10972,9 +10972,9 @@ "integrity": "sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ==" }, "vue-analytics": { - "version": "5.19.1", - "resolved": "https://registry.npmjs.org/vue-analytics/-/vue-analytics-5.19.1.tgz", - "integrity": "sha512-vNMgKJn85sHw+7Q/iat+yVcUnHLd3sgXiFJvm7+NuyN3Wa+6TQY8G0yK/pUCJFW0bA+3QNAe6tPtUvq8mapG7A==" + "version": "5.22.1", + "resolved": "https://registry.npmjs.org/vue-analytics/-/vue-analytics-5.22.1.tgz", + "integrity": "sha512-HPKQMN7gfcUqS5SxoO0VxqLRRSPkG1H1FqglsHccz6BatBatNtm/Vyy8brApktZxNCfnAkrSVDpxg3/FNDeOgQ==" }, "vue-client-only": { "version": "2.0.0", diff --git a/package.json b/package.json index 884352b2f..9008a84b3 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@nuxtjs/axios": "^5.9.2", - "@nuxtjs/google-analytics": "^2.2.2", + "@nuxtjs/google-analytics": "^2.2.3", "@nuxtjs/google-tag-manager": "^2.3.1", "@nuxtjs/pwa": "^3.0.0-beta.19", "@nuxtjs/robots": "^2.4.2", From 72968735620008a8ddc719563f84d946ad9b301e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 11 Jan 2020 00:32:24 +0000 Subject: [PATCH 07/33] :arrow_up: Bump sass-loader from 8.0.0 to 8.0.1 Bumps [sass-loader](https://github.com/webpack-contrib/sass-loader) from 8.0.0 to 8.0.1. - [Release notes](https://github.com/webpack-contrib/sass-loader/releases) - [Changelog](https://github.com/webpack-contrib/sass-loader/blob/master/CHANGELOG.md) - [Commits](https://github.com/webpack-contrib/sass-loader/compare/v8.0.0...v8.0.1) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 65b15a7b9..6adfda0da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9352,22 +9352,22 @@ } }, "sass-loader": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-8.0.0.tgz", - "integrity": "sha512-+qeMu563PN7rPdit2+n5uuYVR0SSVwm0JsOUsaJXzgYcClWSlmX0iHDnmeOobPkf5kUglVot3QS6SyLyaQoJ4w==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-8.0.1.tgz", + "integrity": "sha512-ANR2JHuoxzCI+OPDA0hJBv1Y16A2021hucu0S3DOGgpukKzq9W+4vX9jhIqs4qibT5E7RIRsHMMrN0kdF5nUig==", "dev": true, "requires": { "clone-deep": "^4.0.1", "loader-utils": "^1.2.3", "neo-async": "^2.6.1", - "schema-utils": "^2.1.0", - "semver": "^6.3.0" + "schema-utils": "^2.6.1", + "semver": "^7.1.1" }, "dependencies": { "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.1.1.tgz", + "integrity": "sha512-WfuG+fl6eh3eZ2qAf6goB7nhiCd7NPXhmyFxigB/TOkQyeLP8w8GsVehvtGNtnNmyboz4TgeK40B1Kbql/8c5A==", "dev": true } } diff --git a/package.json b/package.json index 9008a84b3..bae0f6231 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "devDependencies": { "cypress": "^3.8.1", "node-sass": "^4.13.0", - "sass-loader": "^8.0.0", + "sass-loader": "^8.0.1", "start-server-and-test": "^1.10.6" } } From de480c457a0892f2e2960f0df21ffe09f7baec21 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 11 Jan 2020 00:48:14 +0000 Subject: [PATCH 08/33] :arrow_up: Bump cypress from 3.8.1 to 3.8.2 Bumps [cypress](https://github.com/cypress-io/cypress) from 3.8.1 to 3.8.2. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Commits](https://github.com/cypress-io/cypress/compare/v3.8.1...v3.8.2) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 13 ++++++++++--- package.json | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6adfda0da..43d04f543 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3721,9 +3721,9 @@ "integrity": "sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=" }, "cypress": { - "version": "3.8.1", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-3.8.1.tgz", - "integrity": "sha512-eLk5OpL/ZMDfQx9t7ZaDUAGVcvSOPTi7CG1tiUnu9BGk7caBiDhuFi3Tz/D5vWqH/Dl6Uh4X+Au4W+zh0xzbXw==", + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-3.8.2.tgz", + "integrity": "sha512-aTs0u3+dfEuLe0Ct0FVO5jD1ULqxbuqWUZwzBm0rxdLgLxIAOI/A9f/WkgY5Cfy1TEXe8pKC6Wal0ZpnkdGRSw==", "dev": true, "requires": { "@cypress/listr-verbose-renderer": "0.4.1", @@ -3737,6 +3737,7 @@ "commander": "2.15.1", "common-tags": "1.8.0", "debug": "3.2.6", + "eventemitter2": "4.1.2", "execa": "0.10.0", "executable": "4.1.1", "extract-zip": "1.6.7", @@ -4302,6 +4303,12 @@ "through": "~2.3.1" } }, + "eventemitter2": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-4.1.2.tgz", + "integrity": "sha1-DhqEd6+CGm7zmVsxG/dMI6UkfxU=", + "dev": true + }, "eventemitter3": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz", diff --git a/package.json b/package.json index bae0f6231..df2b5d471 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "yargs-parser": "^16.1.0" }, "devDependencies": { - "cypress": "^3.8.1", + "cypress": "^3.8.2", "node-sass": "^4.13.0", "sass-loader": "^8.0.1", "start-server-and-test": "^1.10.6" From 908d672cf23dceb8f6e09bd9dc20c84e05e63c25 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 10:42:08 +0530 Subject: [PATCH 09/33] refactor: use const --- assets/js/oauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 10f584ef1..927f6d0a4 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -5,7 +5,7 @@ const redirectUri = `${window.location.origin}/`; // Make a POST request and parse the response as JSON const sendPostRequest = async (url, params) => { - let body = Object.keys(params) + const body = Object.keys(params) .map(key => `${key}=${params[key]}`) .join("&"); const options = { From 086b2de5059890dd19050ef7cea6d9ddfe64ffb9 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 10:44:07 +0530 Subject: [PATCH 10/33] refactor: use const --- assets/js/oauth.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 927f6d0a4..9c57bfd34 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -29,8 +29,8 @@ const parseQueryString = string => { if (string === "") { return {}; } - let segments = string.split("&").map(s => s.split("=")); - let queryString = {}; + const segments = string.split("&").map(s => s.split("=")); + const queryString = {}; segments.forEach(s => (queryString[s[0]] = s[1])); return queryString; }; From 46d5ffc05b5dde9b85914f700fe012821f21c968 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 10:47:57 +0530 Subject: [PATCH 11/33] fix: typo --- assets/js/oauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 9c57bfd34..0f2c866ed 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -70,7 +70,7 @@ const sha256 = plain => { }; // Base64-urlencodes the input string const base64urlencode = ( - str // Convert the ArrayBuffer to string using Uint8 array to conver to what btoa accepts. + str // Convert the ArrayBuffer to string using Uint8 array to convert to what btoa accepts. ) => // btoa accepts chars only within ascii 0-255 and base64 encodes them. // Then convert the base64 encoded to base64url encoded From caf33ba87e88d253fd5e65f290ae7e1db2f95c11 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 10:48:12 +0530 Subject: [PATCH 12/33] refactor: use const --- assets/js/oauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 0f2c866ed..022c33627 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -81,7 +81,7 @@ const base64urlencode = ( .replace(/=+$/, ""); // Return the base64-urlencoded sha256 hash for the PKCE challenge const pkceChallengeFromVerifier = async v => { - let hashed = await sha256(v); + const hashed = await sha256(v); return base64urlencode(hashed); }; From bf08883f1556e4c618caef6a87acb591f96bff67 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:07:26 +0530 Subject: [PATCH 13/33] chore: method signatures for sendPostRequest method --- assets/js/oauth.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 022c33627..0c7a1a651 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -3,7 +3,15 @@ const redirectUri = `${window.location.origin}/`; ////////////////////////////////////////////////////////////////////// // GENERAL HELPER FUNCTIONS -// Make a POST request and parse the response as JSON +/** + * Makes a POST request and parses the response as JSON + * + * @param {String} url - The resource + * @param {Object} params - Configuration options + * @returns {Object} + */ + +// const sendPostRequest = async (url, params) => { const body = Object.keys(params) .map(key => `${key}=${params[key]}`) From 14f03e61ef21593739a015f23f5c20114638f19e Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:07:53 +0530 Subject: [PATCH 14/33] fix: minor tweak --- assets/js/oauth.js | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 0c7a1a651..63bc004c8 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -1,6 +1,5 @@ const redirectUri = `${window.location.origin}/`; -////////////////////////////////////////////////////////////////////// // GENERAL HELPER FUNCTIONS /** From 7f8b49dd1d4391db531336515e8031a2af587635 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:08:05 +0530 Subject: [PATCH 15/33] fix: minor tweak --- assets/js/oauth.js | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 63bc004c8..bb93cd0cd 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -10,7 +10,6 @@ const redirectUri = `${window.location.origin}/`; * @returns {Object} */ -// const sendPostRequest = async (url, params) => { const body = Object.keys(params) .map(key => `${key}=${params[key]}`) From 2f3c3aeba93013fc5791711bd151c7ba3cb0a281 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:10:11 +0530 Subject: [PATCH 16/33] chore: method signatures for parseQueryString method --- assets/js/oauth.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index bb93cd0cd..b83965418 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -30,7 +30,14 @@ const sendPostRequest = async (url, params) => { throw err; } }; -// Parse a query string into an object + +/** + * Parse a query string into an object + * + * @param {String} string - The query string + * @returns {Object} + */ + const parseQueryString = string => { if (string === "") { return {}; From 5dab781fbe022d9c70f2825c074185d139d98b24 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:11:02 +0530 Subject: [PATCH 17/33] fix: minor tweak --- assets/js/oauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index b83965418..c5c09da1d 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -3,7 +3,7 @@ const redirectUri = `${window.location.origin}/`; // GENERAL HELPER FUNCTIONS /** - * Makes a POST request and parses the response as JSON + * Makes a POST request and parse the response as JSON * * @param {String} url - The resource * @param {Object} params - Configuration options From bbb559ad2c6c4c28d31e183094d40a404e2f590c Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:13:12 +0530 Subject: [PATCH 18/33] chore: change var name --- assets/js/oauth.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index c5c09da1d..813aa12a7 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -38,11 +38,11 @@ const sendPostRequest = async (url, params) => { * @returns {Object} */ -const parseQueryString = string => { - if (string === "") { +const parseQueryString = searchQuery => { + if (searchQuery === "") { return {}; } - const segments = string.split("&").map(s => s.split("=")); + const segments = searchQuery.split("&").map(s => s.split("=")); const queryString = {}; segments.forEach(s => (queryString[s[0]] = s[1])); return queryString; From ee49f8d26c47f9ae26c67f515b32492d64e3d3fa Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:13:53 +0530 Subject: [PATCH 19/33] fix: minor tweak --- assets/js/oauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 813aa12a7..774da6d59 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -34,7 +34,7 @@ const sendPostRequest = async (url, params) => { /** * Parse a query string into an object * - * @param {String} string - The query string + * @param {String} searchQuery - The search query params * @returns {Object} */ From 1a04d79fb9f4f1cbf897ffad8345e49c26e4763b Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:15:09 +0530 Subject: [PATCH 20/33] chore: method signatures for getTokenConfiguration method --- assets/js/oauth.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 774da6d59..a1a32c6d0 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -47,7 +47,13 @@ const parseQueryString = searchQuery => { segments.forEach(s => (queryString[s[0]] = s[1])); return queryString; }; -// Get OAuth configuration from OpenID Discovery endpoint + +/** + * Get OAuth configuration from OpenID Discovery endpoint + * + * @returns {Object} + */ + const getTokenConfiguration = async endpoint => { const options = { method: "GET", From 80f7d3120ace2bdf7166dc33894ac6b42434996b Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:15:41 +0530 Subject: [PATCH 21/33] fix: minor tweak --- assets/js/oauth.js | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index a1a32c6d0..0316d374f 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -71,7 +71,6 @@ const getTokenConfiguration = async endpoint => { } }; -////////////////////////////////////////////////////////////////////// // PKCE HELPER FUNCTIONS // Generate a secure random string using the browser crypto functions From 4ce673acfd527b2b9a0f1a38adf3541b61f049fb Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:16:57 +0530 Subject: [PATCH 22/33] chore: method signatures for getRandomString method --- assets/js/oauth.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 0316d374f..5c26832b3 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -73,7 +73,12 @@ const getTokenConfiguration = async endpoint => { // PKCE HELPER FUNCTIONS -// Generate a secure random string using the browser crypto functions +/** + * Generate a secure random string using the browser crypto functions + * + * @returns {Object} + */ + const generateRandomString = () => { const array = new Uint32Array(28); window.crypto.getRandomValues(array); From 12ef2f4465d2346885898748bb831929ce3245f0 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:17:24 +0530 Subject: [PATCH 23/33] fix: minor tweak --- assets/js/oauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 5c26832b3..f9a58bdba 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -74,7 +74,7 @@ const getTokenConfiguration = async endpoint => { // PKCE HELPER FUNCTIONS /** - * Generate a secure random string using the browser crypto functions + * Generates a secure random string using the browser crypto functions * * @returns {Object} */ From 836bd9ab3c1298fd96fdb4150f346ab40f006ef2 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:19:31 +0530 Subject: [PATCH 24/33] chore: method signatures for sha256 method --- assets/js/oauth.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index f9a58bdba..d9cabff26 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -84,8 +84,13 @@ const generateRandomString = () => { window.crypto.getRandomValues(array); return Array.from(array, dec => `0${dec.toString(16)}`.substr(-2)).join(""); }; -// Calculate the SHA256 hash of the input text. -// Returns a promise that resolves to an ArrayBuffer + +/** + * Calculate the SHA256 hash of the input text + * + * @returns {Promise} + */ + const sha256 = plain => { const encoder = new TextEncoder(); const data = encoder.encode(plain); From 3ba279c81b6c57578c5cae45296739ffb64a0d84 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:24:04 +0530 Subject: [PATCH 25/33] chore: method signatures for base64urlencode method --- assets/js/oauth.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index d9cabff26..e2a64fe29 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -96,7 +96,14 @@ const sha256 = plain => { const data = encoder.encode(plain); return window.crypto.subtle.digest("SHA-256", data); }; -// Base64-urlencodes the input string + +/** + * Base64-urlencodes the input string + * + * @param {String} str - The string to be converted + * @returns {Promise} + */ + const base64urlencode = ( str // Convert the ArrayBuffer to string using Uint8 array to convert to what btoa accepts. ) => From 9e5a162d74adf42a01150d98c18f0223f1c48621 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:25:01 +0530 Subject: [PATCH 26/33] fix: minor tweak --- assets/js/oauth.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index e2a64fe29..9b50a0952 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -98,14 +98,14 @@ const sha256 = plain => { }; /** - * Base64-urlencodes the input string + * Encodes the input string into Base64 format * * @param {String} str - The string to be converted * @returns {Promise} */ const base64urlencode = ( - str // Convert the ArrayBuffer to string using Uint8 array to convert to what btoa accepts. + str // Converts the ArrayBuffer to string using Uint8 array to convert to what btoa accepts. ) => // btoa accepts chars only within ascii 0-255 and base64 encodes them. // Then convert the base64 encoded to base64url encoded From a4b89a2152da3478237c86ca80054ad46ec42451 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:26:56 +0530 Subject: [PATCH 27/33] chore: method signatures for pkceChallengeFromVerifier method --- assets/js/oauth.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 9b50a0952..fdbe1c7f7 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -114,7 +114,14 @@ const base64urlencode = ( .replace(/\+/g, "-") .replace(/\//g, "_") .replace(/=+$/, ""); -// Return the base64-urlencoded sha256 hash for the PKCE challenge + +/** + * Return the base64-urlencoded sha256 hash for the PKCE challenge + * + * @param {String} v - The randomly generated string + * @returns {String} + */ + const pkceChallengeFromVerifier = async v => { const hashed = await sha256(v); return base64urlencode(hashed); From daf214275b723da34b5edae0e6a140502d850179 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:29:57 +0530 Subject: [PATCH 28/33] chore: method signatures for tokenRequest method --- assets/js/oauth.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index fdbe1c7f7..784f6baea 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -127,10 +127,15 @@ const pkceChallengeFromVerifier = async v => { return base64urlencode(hashed); }; -////////////////////////////////////////////////////////////////////// // OAUTH REQUEST -// Initiate PKCE Auth Code flow when requested +/** + * Initiate PKCE Auth Code flow when requested + * + * @param {Object} - The necessary params + * @returns {Void} + */ + const tokenRequest = async ({ oidcDiscoveryUrl, grantType, From dcd148e43b1a0d2581e281df238919217628b5de Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:30:03 +0530 Subject: [PATCH 29/33] fix: minor tweak --- assets/js/oauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 784f6baea..6e00a21c6 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -130,7 +130,7 @@ const pkceChallengeFromVerifier = async v => { // OAUTH REQUEST /** - * Initiate PKCE Auth Code flow when requested + * Initiates PKCE Auth Code flow when requested * * @param {Object} - The necessary params * @returns {Void} From e1423033a6ee04050a4a8c438ebbdfff576128a1 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 13:31:49 +0530 Subject: [PATCH 30/33] chore: method signatures for oauthRedirect method --- assets/js/oauth.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index 6e00a21c6..cfe3d5d15 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -185,11 +185,15 @@ const tokenRequest = async ({ window.location = buildUrl(); }; -////////////////////////////////////////////////////////////////////// // OAUTH REDIRECT HANDLING -// Handle the redirect back from the authorization server and -// get an access token from the token endpoint +/** + * Handle the redirect back from the authorization server and + * get an access token from the token endpoint + * + * @returns {Object} + */ + const oauthRedirect = async () => { let tokenResponse = ""; let q = parseQueryString(window.location.search.substring(1)); From 64222327c96abcf089a4e268d16c8481723a6bfd Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 16:36:37 +0530 Subject: [PATCH 31/33] refactor: prefer reduce --- assets/js/oauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index cfe3d5d15..c324dfa05 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -44,7 +44,7 @@ const parseQueryString = searchQuery => { } const segments = searchQuery.split("&").map(s => s.split("=")); const queryString = {}; - segments.forEach(s => (queryString[s[0]] = s[1])); + const queryString = segments.reduce((obj, el) => ({ ...obj, [el[0]]: el[1] }), {}); return queryString; }; From 9838a68ff7744f14ee35de45591ae765314489ee Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 16:37:58 +0530 Subject: [PATCH 32/33] fix: remove redundant declaration --- assets/js/oauth.js | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index c324dfa05..f09358ac9 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -43,7 +43,6 @@ const parseQueryString = searchQuery => { return {}; } const segments = searchQuery.split("&").map(s => s.split("=")); - const queryString = {}; const queryString = segments.reduce((obj, el) => ({ ...obj, [el[0]]: el[1] }), {}); return queryString; }; From 5fffc5d29e9f5e801b0926aa9525374740e14dee Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 11 Jan 2020 16:38:54 +0530 Subject: [PATCH 33/33] fix: lint --- assets/js/oauth.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/js/oauth.js b/assets/js/oauth.js index f09358ac9..447fe5334 100644 --- a/assets/js/oauth.js +++ b/assets/js/oauth.js @@ -43,7 +43,10 @@ const parseQueryString = searchQuery => { return {}; } const segments = searchQuery.split("&").map(s => s.split("=")); - const queryString = segments.reduce((obj, el) => ({ ...obj, [el[0]]: el[1] }), {}); + const queryString = segments.reduce( + (obj, el) => ({ ...obj, [el[0]]: el[1] }), + {} + ); return queryString; };