diff --git a/docsfera.json b/docsfera.json index 21192d1..0f4a23e 100644 --- a/docsfera.json +++ b/docsfera.json @@ -3339,7 +3339,7 @@ } }, "info": { - "title": "Maestro - feature/download-logs", + "title": "Maestro - feat/update-connection", "description": "Documentation for Maestro gateway", "version": "1.0.0", "contact": {} diff --git a/package-lock.json b/package-lock.json index 1ceae1f..bef9f5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "dotenv": "^14.3.2", "elastic-apm-node": "^3.36.0", "helmet": "^5.1.0", - "jsonwebtoken": "^8.5.1", + "jsonwebtoken": "^9.0.0", "jwk-to-pem": "^2.0.5", "mixpanel": "^0.17.0", "passport": "^0.6.0", @@ -7786,30 +7786,18 @@ } }, "node_modules/jsonwebtoken": { - "version": "8.5.1", - "license": "MIT", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz", + "integrity": "sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw==", "dependencies": { "jws": "^3.2.2", - "lodash.includes": "^4.3.0", - "lodash.isboolean": "^3.0.3", - "lodash.isinteger": "^4.0.4", - "lodash.isnumber": "^3.0.3", - "lodash.isplainobject": "^4.0.6", - "lodash.isstring": "^4.0.1", - "lodash.once": "^4.0.0", + "lodash": "^4.17.21", "ms": "^2.1.1", - "semver": "^5.6.0" + "semver": "^7.3.8" }, "engines": { - "node": ">=4", - "npm": ">=1.4.28" - } - }, - "node_modules/jsonwebtoken/node_modules/semver": { - "version": "5.7.1", - "license": "ISC", - "bin": { - "semver": "bin/semver" + "node": ">=12", + "npm": ">=6" } }, "node_modules/jwa": { @@ -7908,30 +7896,6 @@ "version": "4.3.0", "license": "MIT" }, - "node_modules/lodash.includes": { - "version": "4.3.0", - "license": "MIT" - }, - "node_modules/lodash.isboolean": { - "version": "3.0.3", - "license": "MIT" - }, - "node_modules/lodash.isinteger": { - "version": "4.0.4", - "license": "MIT" - }, - "node_modules/lodash.isnumber": { - "version": "3.0.3", - "license": "MIT" - }, - "node_modules/lodash.isplainobject": { - "version": "4.0.6", - "license": "MIT" - }, - "node_modules/lodash.isstring": { - "version": "4.0.1", - "license": "MIT" - }, "node_modules/lodash.memoize": { "version": "4.1.2", "dev": true, @@ -7942,10 +7906,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.once": { - "version": "4.1.1", - "license": "MIT" - }, "node_modules/lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", @@ -9484,9 +9444,9 @@ "license": "MIT" }, "node_modules/semver": { - "version": "7.3.7", - "dev": true, - "license": "ISC", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -16455,23 +16415,14 @@ } }, "jsonwebtoken": { - "version": "8.5.1", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz", + "integrity": "sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw==", "requires": { "jws": "^3.2.2", - "lodash.includes": "^4.3.0", - "lodash.isboolean": "^3.0.3", - "lodash.isinteger": "^4.0.4", - "lodash.isnumber": "^3.0.3", - "lodash.isplainobject": "^4.0.6", - "lodash.isstring": "^4.0.1", - "lodash.once": "^4.0.0", + "lodash": "^4.17.21", "ms": "^2.1.1", - "semver": "^5.6.0" - }, - "dependencies": { - "semver": { - "version": "5.7.1" - } + "semver": "^7.3.8" } }, "jwa": { @@ -16544,24 +16495,6 @@ "lodash.camelcase": { "version": "4.3.0" }, - "lodash.includes": { - "version": "4.3.0" - }, - "lodash.isboolean": { - "version": "3.0.3" - }, - "lodash.isinteger": { - "version": "4.0.4" - }, - "lodash.isnumber": { - "version": "3.0.3" - }, - "lodash.isplainobject": { - "version": "4.0.6" - }, - "lodash.isstring": { - "version": "4.0.1" - }, "lodash.memoize": { "version": "4.1.2", "dev": true @@ -16570,9 +16503,6 @@ "version": "4.6.2", "dev": true }, - "lodash.once": { - "version": "4.1.1" - }, "lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", @@ -17584,8 +17514,9 @@ } }, "semver": { - "version": "7.3.7", - "dev": true, + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "requires": { "lru-cache": "^6.0.0" } diff --git a/package.json b/package.json index 6a5d446..3cdd2ff 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "dotenv": "^14.3.2", "elastic-apm-node": "^3.36.0", "helmet": "^5.1.0", - "jsonwebtoken": "^8.5.1", + "jsonwebtoken": "^9.0.0", "jwk-to-pem": "^2.0.5", "mixpanel": "^0.17.0", "passport": "^0.6.0", diff --git a/src/modules/oauth/oauth.controller.ts b/src/modules/oauth/oauth.controller.ts index 6ad2da7..518dd24 100644 --- a/src/modules/oauth/oauth.controller.ts +++ b/src/modules/oauth/oauth.controller.ts @@ -148,10 +148,16 @@ export class OauthController { const { customer_id, customer_name, user_id } = connectionInfo; try { - const response = await this.connectionService.createConnection( - connectionInfo, - PackTheMetadata({ customer_id, customer_name, user_id }), - ); + const response = connectionInfo.id + ? await this.connectionService.updateConnection( + connectionInfo.id, + connectionInfo, + PackTheMetadata({ customer_id, customer_name, user_id }), + ) + : await this.connectionService.createConnection( + connectionInfo, + PackTheMetadata({ customer_id, customer_name, user_id }), + ); url.searchParams.set('connection_id', response.connection.id); return { url: url.href }; } catch (error) { diff --git a/src/modules/oauth/oauth.service.ts b/src/modules/oauth/oauth.service.ts index 9da56b5..e9f6b3e 100644 --- a/src/modules/oauth/oauth.service.ts +++ b/src/modules/oauth/oauth.service.ts @@ -23,6 +23,7 @@ export class OauthService { user_id, customer_id, customer_name, + id, } = query; const properties = { plugin, credentials_type: 'oauth' }; @@ -45,6 +46,7 @@ export class OauthService { type, properties, plugin, + id, }; return jwt.sign({ ...newConnection }, process.env.JWT_PRIVATE_KEY); }