diff --git a/api/auth_data.js b/api/auth_data.js index c33c827..393dd9e 100644 --- a/api/auth_data.js +++ b/api/auth_data.js @@ -1,31 +1,34 @@ const crypto = require("crypto"); -const cookie = require("cookie") -const signature = require("cookie-signature") +const cookie = require("cookie"); +const signature = require("cookie-signature"); export default function handler(req, res) { - const secret = process.env.JWT_SECRET - const cookies = cookie.parse(req.headers.cookie || '') - const refresh = cookies.refresh?.startsWith('s:') ? signature.unsign(cookies.refresh.slice(2), secret) : null - const authCode = cookies.authCode?.startsWith('s:') ? signature.unsign(cookies.authCode.slice(2), secret) : null - let code = null; - if (refresh === "false" && authCode) { - code = authCode; - res.setHeader("Set-Cookie", [ - cookie.serialize("refresh", "true", { - httpOnly: true, - secure: true, - path: "/", - sameSite: "Lax" - }) - ]); - } - const state = crypto.randomBytes(20).toString("hex") - res.status(200).json({ - redirect_uri: process.env.REDIRECT_URI, - clientId: process.env.CLIENT_ID, - clientSecret: process.env.CLIENT_SECRET, - state, - code - }) - -} \ No newline at end of file + const secret = process.env.JWT_SECRET; + const cookies = cookie.parse(req.headers.cookie || ""); + const refresh = cookies.refresh?.startsWith("s:") + ? signature.unsign(cookies.refresh.slice(2), secret) + : null; + const authCode = cookies.authCode?.startsWith("s:") + ? signature.unsign(cookies.authCode.slice(2), secret) + : null; + let code = null; + if (refresh === "false" && authCode) { + code = authCode; + res.setHeader("Set-Cookie", [ + cookie.serialize("refresh", "true", { + httpOnly: true, + secure: true, + path: "/", + sameSite: "Lax", + }), + ]); + } + const state = crypto.randomBytes(20).toString("hex"); + res.status(200).json({ + redirect_uri: process.env.REDIRECT_URI, + clientId: process.env.CLIENT_ID, + clientSecret: process.env.CLIENT_SECRET, + state, + code, + }); +} diff --git a/api/callback.js b/api/callback.js index 40d6a0a..14d7220 100644 --- a/api/callback.js +++ b/api/callback.js @@ -1,33 +1,33 @@ -const cookie = require('cookie') -const signature = require('cookie-signature') +const cookie = require("cookie"); +const signature = require("cookie-signature"); -export default function handler(req,res) { - if(req.method === "GET") { - const { code } = req.query - if(code) { - const secret = process.env.JWT_SECRET - const signedRefresh = 's:' + signature.sign('false', secret) - const signedAuthCode = 's:' + signature.sign(code, secret) - res.setHeader("Set-Cookie", [ - cookie.serialize("authCode", signedAuthCode, { - httpOnly: true, - secure: true, - path: "/", - sameSite: "Lax" - }), - cookie.serialize("refresh", signedRefresh, { - httpOnly: true, - secure: true, - path: "/", - sameSite: "Lax" - }) - ]); - res.writeHead(302, { Location: "/"}) - res.end() - } else { - res.status(400).send("Missing Code") - } +export default function handler(req, res) { + if (req.method === "GET") { + const { code } = req.query; + if (code) { + const secret = process.env.JWT_SECRET; + const signedRefresh = "s:" + signature.sign("false", secret); + const signedAuthCode = "s:" + signature.sign(code, secret); + res.setHeader("Set-Cookie", [ + cookie.serialize("authCode", signedAuthCode, { + httpOnly: true, + secure: true, + path: "/", + sameSite: "Lax", + }), + cookie.serialize("refresh", signedRefresh, { + httpOnly: true, + secure: true, + path: "/", + sameSite: "Lax", + }), + ]); + res.writeHead(302, { Location: "/" }); + res.end(); } else { - res.status(405).send("Method not allowed") + res.status(400).send("Missing Code"); } -} \ No newline at end of file + } else { + res.status(405).send("Method not allowed"); + } +} diff --git a/api/code_to_token.js b/api/code_to_token.js index ed91f88..a740d04 100644 --- a/api/code_to_token.js +++ b/api/code_to_token.js @@ -1,31 +1,48 @@ -const request = require("request"); -const jwt = require("jsonwebtoken"); +import jwt from "jsonwebtoken"; -export default function handler(req,res) { - if(req.method === "POST") { - const result = {}; - const reqData = { - code: req.body.code, - client_id: req.body.clientID, - client_secret: req.body.clientSecret, - grant_type: "authorization_code", - redirect_uri: process.env.REDIRECT_URI, - }; - - request.post( - req.body.tokenEndpoint, - { - form: reqData, - }, - (err, response, body) => { - result.body = body; - result.response = response; - // and add the decoded token - result.decodedToken = JSON.stringify( - jwt.decode(result.id_token, { complete: true }), - ); - res.json(result); - }, - ); +export default async function handler(req, res) { + if (req.method === "POST") { + try { + const reqData = { + code: req.body.code, + client_id: req.body.clientID, + client_secret: req.body.clientSecret, + grant_type: "authorization_code", + redirect_uri: process.env.REDIRECT_URI, + }; + + const response = await fetch(req.body.tokenEndpoint, { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + body: new URLSearchParams(reqData), + }); + + if (!response.ok) { + throw new Error(`HTTP error! Status: ${response.status}`); + } + + const tokenData = await response.json(); + + const result = { + body: tokenData, + response: { + statusCode: response.status, + headers: response.headers, + }, + decodedToken: JSON.stringify( + jwt.decode(tokenData.id_token, { complete: true }) + ), + }; + + res.status(200).json(result); + } catch (error) { + console.error("Error fetching token:", error); + res.status(500).json({ error: "Failed to retrieve token" }); } + } else { + res.setHeader("Allow", ["POST"]); + res.status(405).end(`Method ${req.method} Not Allowed`); + } } \ No newline at end of file diff --git a/api/discover.js b/api/discover.js index cc4d2c8..caace11 100644 --- a/api/discover.js +++ b/api/discover.js @@ -1,5 +1,5 @@ -const Validator = require("jsonschema").Validator; -const request = require("request") +import { Validator } from "jsonschema"; + const valid = new Validator(); const discoverySchema = { @@ -27,39 +27,50 @@ const isJson = (str) => { return true; }; +export default async function handler(req, res) { + if (req.method !== "GET") { + res.setHeader("Allow", ["GET"]); + return res.status(405).end(`Method ${req.method} Not Allowed`); + } -export default function handler(req, res) { - if (req.method === "GET") { - request.get(req.query.url, (err, resp, body) => { - if (err) { - return res.status(400).json({ - message: err.message || "Couldn't get a discovery document", - }); - } else { - if (isJson(body)) { - const jsonBody = JSON.parse(body); - const isValid = valid.validate(jsonBody, discoverySchema); - if (isValid.errors.length < 1) { - return res.json({ - authorization_endpoint: jsonBody.authorization_endpoint, - token_endpoint: jsonBody.token_endpoint, - userinfo_endpoint: jsonBody.userinfo_endpoint, - jwks_uri: jsonBody.jwks_uri, - }); - } else { - return res.status(400).json({ - message: "Discovery document is not valid", - errors: isValid.errors.map( - (e) => `The ${e.property.replace("instance.", "")} ${e.message}`, - ), - }); - } - } else { - return res - .status(400) - .json({ message: "Discovery document is not a JSON file." }); - } - } - }) + try { + const response = await fetch(req.query.url); + + if (!response.ok) { + throw new Error( + `Failed to fetch discovery document: ${response.status} ${response.statusText}` + ); } -} \ No newline at end of file + + const body = await response.text(); + + if (isJson(body)) { + const jsonBody = JSON.parse(body); + const validationResult = valid.validate(jsonBody, discoverySchema); + + if (validationResult.valid) { + return res.status(200).json({ + authorization_endpoint: jsonBody.authorization_endpoint, + token_endpoint: jsonBody.token_endpoint, + userinfo_endpoint: jsonBody.userinfo_endpoint, + jwks_uri: jsonBody.jwks_uri, + }); + } else { + return res.status(400).json({ + message: "Discovery document is not valid.", + errors: validationResult.errors.map( + (e) => `The ${e.property.replace("instance.", "")} ${e.message}` + ), + }); + } + } else { + return res + .status(400) + .json({ message: "Discovery document is not a JSON file." }); + } + } catch (error) { + return res.status(500).json({ + message: error.message || "An unexpected error occurred.", + }); + } +} diff --git a/api/fallback.js b/api/fallback.js index d7546da..afe502f 100644 --- a/api/fallback.js +++ b/api/fallback.js @@ -1,14 +1,14 @@ -const cookie = require("cookie") +const cookie = require("cookie"); module.exports = (req, res) => { - const cookies = cookie.parse(req.headers.cookie || "") - let code = null; - const { authCode, refresh } = cookies - if(!refresh && authCode) { - code = authCode - res.setHeader("Set-Cookie", "refresh=true; Path=/; HttpOnly") - } + const cookies = cookie.parse(req.headers.cookie || ""); + let code = null; + const { authCode, refresh } = cookies; + if (!refresh && authCode) { + code = authCode; + res.setHeader("Set-Cookie", "refresh=true; Path=/; HttpOnly"); + } - res.writeHead(302, { Location: "/"}) - res.end(); -} + res.writeHead(302, { Location: "/" }); + res.end(); +}; diff --git a/api/index.js b/api/index.js index d9feb24..7223c90 100644 --- a/api/index.js +++ b/api/index.js @@ -1,38 +1,30 @@ const express = require("express"); - -const path = require("path") -const serverless = require("serverless-http") - +const path = require("path"); +const serverless = require("serverless-http"); require("dotenv").config({ silent: true }); - const app = express(); - app.use(require("body-parser").json()); - - app.use((req, res, next) => { - const proto = req.headers["x-forwarded-proto"]; - if (proto && proto !== "https") { - return res.redirect(302, `https://${req.hostname}${req.originalUrl}`); - } - + const proto = req.headers["x-forwarded-proto"]; + if (proto && proto !== "https") { + return res.redirect(302, `https://${req.hostname}${req.originalUrl}`); + } - return next(); + return next(); }); - app.use((req, res, next) => { - res.setHeader("X-Frame-Options", "DENY"); - next(); + res.setHeader("X-Frame-Options", "DENY"); + next(); }); - -app.listen(process.env.PORT || 3000, () => console.log("server started on port 3000")) - +app.listen(process.env.PORT || 3000, () => + console.log("server started on port 3000") +); module.exports = serverless(app); diff --git a/api/validate.js b/api/validate.js index b59596c..911c964 100644 --- a/api/validate.js +++ b/api/validate.js @@ -1,91 +1,103 @@ -const jose = require('node-jose') -const jwt = require('jsonwebtoken') -const request = require('request') +const jose = require("node-jose"); +const jwt = require("jsonwebtoken"); async function convertJwkToPem(jwk) { - const keyStore = jose.JWK.createKeyStore(); - const key = await keyStore.add(jwk, 'json') - return key.toPEM(); + const keyStore = jose.JWK.createKeyStore(); + const key = await keyStore.add(jwk, "json"); + return key.toPEM(); } -module.exports = (req, res) => { - if (req.method === "POST") { - if (!req.body.idToken) { - return res.status(400).send("Missing idToken param."); - } +module.exports = async (req, res) => { + if (req.method !== "POST") { + res.setHeader("Allow", ["POST"]); + return res.status(405).end(`Method ${req.method} Not Allowed`); + } - const tokenHeader = jwt.decode(req.body.idToken, { complete: true }).header; + if (!req.body.idToken) { + return res.status(400).send("Missing idToken param."); + } - // RS256 = validation with public key - if (tokenHeader.alg === "RS256") { - if (!req.body.tokenKeysEndpoint) { - return res - .status(400) - .send( - `idToken algorithm is ${tokenHeader.alg} but tokenKeysEndpoint param is missing.`, - ); - } - if (!tokenHeader.kid) { - return res - .status(400) - .send( - `idToken algorithm is ${tokenHeader.alg} but kid header is missing.`, - ); - } + // A nested function to handle the final verification step + function verify(secret) { + jwt.verify(req.body.idToken, secret, (err, decoded) => { + if (err) { + return res.status(400).send(err.message); + } + return res.status(200).json(decoded); + }); + } - // fetch public key - return request.get( - { - url: req.body.tokenKeysEndpoint, - json: true, - }, - (err, resp, body) => { - // find key with matching kid - if (!body || !body.keys || !Array.isArray(body.keys)) { - return res - .status(400) - .send(`No public key found with matching kid '${tokenHeader.kid}'`); - } + try { + const tokenHeader = jwt.decode(req.body.idToken, { complete: true }).header; + if (!tokenHeader || !tokenHeader.alg) { + return res.status(400).send("Invalid token header."); + } - const key = body.keys.find((k) => k.kid === tokenHeader.kid); - if (!key) { - return res - .status(400) - .send(`No public key found with matching kid '${tokenHeader.kid}'`); - } + // RS256 = validation with public key fetched from an endpoint + if (tokenHeader.alg === "RS256") { + if (!req.body.tokenKeysEndpoint) { + return res + .status(400) + .send( + `idToken algorithm is ${tokenHeader.alg} but tokenKeysEndpoint param is missing.` + ); + } + if (!tokenHeader.kid) { + return res + .status(400) + .send( + `idToken algorithm is ${tokenHeader.alg} but kid header is missing.` + ); + } - return convertJwkToPem(key).then(secret => verify(secret)).catch(err => res.status(400).send("Error verifying key", err)) - - }, - ); - // HS256 = validation with client secret - } else if (tokenHeader.alg === "HS256") { - if (!req.body.clientSecret) { - return res - .status(400) - .send( - `idToken algorithm is ${tokenHeader.alg} but clientSecret param is missing.`, - ); - } + // Fetch public keys using the fetch API + const response = await fetch(req.body.tokenKeysEndpoint); + if (!response.ok) { + throw new Error(`Failed to fetch keys: ${response.statusText}`); + } - const secret = - req.body.server === "Auth0" - ? new Buffer(req.body.clientSecret, "base64") - : req.body.clientSecret; - return verify(secret); - } + const jwks = await response.json(); // Automatically parses the JSON body + + if (!jwks || !jwks.keys || !Array.isArray(jwks.keys)) { return res - .status(400) - .send(`Unsupported idToken algorithm: ${tokenHeader.alg}`); + .status(400) + .send("Invalid key set returned from the endpoint."); + } - function verify(secret) { - jwt.verify(req.body.idToken, secret, (err, decoded) => { - if (err) { - return res.status(400).send(err); - } + // Find the key with the matching 'kid' + const key = jwks.keys.find((k) => k.kid === tokenHeader.kid); + if (!key) { + return res + .status(400) + .send(`No public key found with matching kid '${tokenHeader.kid}'`); + } - return res.json(decoded); - }); - } + const pem = await convertJwkToPem(key); + return verify(pem); + + // HS256 = validation with client secret + } else if (tokenHeader.alg === "HS256") { + if (!req.body.clientSecret) { + return res + .status(400) + .send( + `idToken algorithm is ${tokenHeader.alg} but clientSecret param is missing.` + ); + } + + const secret = + req.body.server === "Auth0" + ? Buffer.from(req.body.clientSecret, "base64") + : req.body.clientSecret; + return verify(secret); } -} \ No newline at end of file + + return res + .status(400) + .send(`Unsupported idToken algorithm: ${tokenHeader.alg}`); + } catch (error) { + return res + .status(500) + .send(error.message || "An unexpected error occurred."); + } +}; diff --git a/package-lock.json b/package-lock.json index aa7df01..9406c67 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,6 @@ "react": "^16.4.2", "react-dom": "^16.4.2", "react-router-dom": "^6.2.1", - "request": "^2.72.0", "serverless-http": "^3.2.0", "sha1": "^1.1.1", "simple-ajax": "^2.5.0", @@ -2564,6 +2563,7 @@ "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", @@ -2842,24 +2842,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/asn1": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", - "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", - "license": "MIT", - "dependencies": { - "safer-buffer": "~2.1.0" - } - }, - "node_modules/assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==", - "license": "MIT", - "engines": { - "node": ">=0.8" - } - }, "node_modules/ast-types-flow": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.8.tgz", @@ -2877,12 +2859,6 @@ "node": ">= 0.4" } }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "license": "MIT" - }, "node_modules/atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", @@ -2912,21 +2888,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==", - "license": "Apache-2.0", - "engines": { - "node": "*" - } - }, - "node_modules/aws4": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz", - "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==", - "license": "MIT" - }, "node_modules/axe-core": { "version": "4.10.3", "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.10.3.tgz", @@ -3050,15 +3011,6 @@ "dev": true, "license": "MIT" }, - "node_modules/bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==", - "license": "BSD-3-Clause", - "dependencies": { - "tweetnacl": "^0.14.3" - } - }, "node_modules/big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", @@ -3330,12 +3282,6 @@ ], "license": "CC-BY-4.0" }, - "node_modules/caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", - "license": "Apache-2.0" - }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -3452,18 +3398,6 @@ "dev": true, "license": "MIT" }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "license": "MIT", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", @@ -3618,6 +3552,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", + "dev": true, "license": "MIT" }, "node_modules/cross-spawn": { @@ -3746,18 +3681,6 @@ "dev": true, "license": "BSD-2-Clause" }, - "node_modules/dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", - "license": "MIT", - "dependencies": { - "assert-plus": "^1.0.0" - }, - "engines": { - "node": ">=0.10" - } - }, "node_modules/data-view-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", @@ -3926,15 +3849,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -4037,16 +3951,6 @@ "node": ">= 0.4" } }, - "node_modules/ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", - "license": "MIT", - "dependencies": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } - }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", @@ -4723,31 +4627,18 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, - "node_modules/extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "license": "MIT" - }, - "node_modules/extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", - "engines": [ - "node >=0.6.0" - ], - "license": "MIT" - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, "license": "MIT" }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, "license": "MIT" }, "node_modules/fast-levenshtein": { @@ -4958,29 +4849,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", - "license": "Apache-2.0", - "engines": { - "node": "*" - } - }, - "node_modules/form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "license": "MIT", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 0.12" - } - }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -5131,15 +4999,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", - "license": "MIT", - "dependencies": { - "assert-plus": "^1.0.0" - } - }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -5242,29 +5101,6 @@ "dev": true, "license": "MIT" }, - "node_modules/har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", - "license": "ISC", - "engines": { - "node": ">=4" - } - }, - "node_modules/har-validator": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", - "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", - "deprecated": "this library is no longer supported", - "license": "MIT", - "dependencies": { - "ajv": "^6.12.3", - "har-schema": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/has-bigints": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz", @@ -5480,21 +5316,6 @@ } } }, - "node_modules/http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", - "license": "MIT", - "dependencies": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - }, - "engines": { - "node": ">=0.8", - "npm": ">=1.3.7" - } - }, "node_modules/hyperdyperid": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/hyperdyperid/-/hyperdyperid-1.2.0.tgz", @@ -6173,12 +5994,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", - "license": "MIT" - }, "node_modules/is-weakmap": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", @@ -6265,12 +6080,6 @@ "node": ">=0.10.0" } }, - "node_modules/isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==", - "license": "MIT" - }, "node_modules/iterator.prototype": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.5.tgz", @@ -6339,12 +6148,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==", - "license": "MIT" - }, "node_modules/jsesc": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", @@ -6372,16 +6175,11 @@ "dev": true, "license": "MIT" }, - "node_modules/json-schema": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", - "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", - "license": "(AFL-2.1 OR BSD-3-Clause)" - }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, "license": "MIT" }, "node_modules/json-stable-stringify-without-jsonify": { @@ -6391,12 +6189,6 @@ "dev": true, "license": "MIT" }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", - "license": "ISC" - }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -6453,21 +6245,6 @@ "node": ">=10" } }, - "node_modules/jsprim": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", - "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", - "license": "MIT", - "dependencies": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.4.0", - "verror": "1.10.0" - }, - "engines": { - "node": ">=0.6.0" - } - }, "node_modules/jsx-ast-utils": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", @@ -7134,15 +6911,6 @@ "node": ">=0.10.0" } }, - "node_modules/oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "license": "Apache-2.0", - "engines": { - "node": "*" - } - }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -7484,12 +7252,6 @@ "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", "license": "MIT" }, - "node_modules/performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", - "license": "MIT" - }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -7787,18 +7549,6 @@ "node": ">= 0.10" } }, - "node_modules/psl": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.15.0.tgz", - "integrity": "sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==", - "license": "MIT", - "dependencies": { - "punycode": "^2.3.1" - }, - "funding": { - "url": "https://github.com/sponsors/lupomontero" - } - }, "node_modules/pstree.remy": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", @@ -7828,6 +7578,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -8128,47 +7879,6 @@ "node": ">=6" } }, - "node_modules/request": { - "version": "2.88.2", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", - "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", - "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", - "license": "Apache-2.0", - "dependencies": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/request/node_modules/qs": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", - "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.6" - } - }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -8964,31 +8674,6 @@ "wbuf": "^1.7.3" } }, - "node_modules/sshpk": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz", - "integrity": "sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ==", - "license": "MIT", - "dependencies": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - }, - "bin": { - "sshpk-conv": "bin/sshpk-conv", - "sshpk-sign": "bin/sshpk-sign", - "sshpk-verify": "bin/sshpk-verify" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -9375,19 +9060,6 @@ "nodetouch": "bin/nodetouch.js" } }, - "node_modules/tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "license": "BSD-3-Clause", - "dependencies": { - "psl": "^1.1.28", - "punycode": "^2.1.1" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/tree-dump": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/tree-dump/-/tree-dump-1.0.3.tgz", @@ -9412,24 +9084,6 @@ "dev": true, "license": "0BSD" }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "license": "Apache-2.0", - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, - "node_modules/tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==", - "license": "Unlicense" - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -9667,6 +9321,7 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" @@ -9777,16 +9432,6 @@ "node": ">= 0.4.0" } }, - "node_modules/uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", - "license": "MIT", - "bin": { - "uuid": "bin/uuid" - } - }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -9796,20 +9441,6 @@ "node": ">= 0.8" } }, - "node_modules/verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", - "engines": [ - "node >=0.6.0" - ], - "license": "MIT", - "dependencies": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - }, "node_modules/watchpack": { "version": "2.4.4", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.4.tgz", diff --git a/package.json b/package.json index f8b94a4..2ecb58f 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "react": "^16.4.2", "react-dom": "^16.4.2", "react-router-dom": "^6.2.1", - "request": "^2.72.0", "serverless-http": "^3.2.0", "sha1": "^1.1.1", "simple-ajax": "^2.5.0", diff --git a/src/components/step-two.js b/src/components/step-two.js index 16ab4cb..4d7ea66 100644 --- a/src/components/step-two.js +++ b/src/components/step-two.js @@ -43,6 +43,8 @@ class StepTwo extends React.Component { body: result }; + console.log(exchangeResult); + this.setState({ exchangeResult: exchangeResult }); if(result.error_description) { @@ -76,6 +78,7 @@ class StepTwo extends React.Component { serviceDiscovery.send() } goToNextStep() { + console.log("goToNextStep"); window.dispatchEvent(new CustomEvent('configChange', { detail: { currentStep: 3