From 6934595053ee17b01c47ce48cd1f7673b9b6c88c Mon Sep 17 00:00:00 2001 From: Naz Date: Tue, 10 May 2022 17:44:48 +0800 Subject: [PATCH] Added Integration Name in version mismatch emails refs https://github.com/TryGhost/Toolbox/issues/292 - Providing user-defined Integration name instead of API client's UserAgent gives a lot more control to instance administrators identifying which integration is being used incorrectly. - It's best practice to create an Integration with a set of API keys per API client - which should be enough to identify an outdated one. --- .../api-version-compatibility/index.js | 1 + package.json | 4 +-- yarn.lock | 35 ++++++++++++------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/core/server/services/api-version-compatibility/index.js b/core/server/services/api-version-compatibility/index.js index f33319683e..f6f3539fe6 100644 --- a/core/server/services/api-version-compatibility/index.js +++ b/core/server/services/api-version-compatibility/index.js @@ -14,6 +14,7 @@ const init = () => { serviceInstance = new APIVersionCompatibilityService({ UserModel: models.User, + ApiKeyModel: models.ApiKey, settingsService: settingsService.getSettingsBREADServiceInstance(), sendEmail: (options) => { // NOTE: not using bind here because mockMailer is having trouble mocking bound methods diff --git a/package.json b/package.json index e06f5b3cd9..1f08d79ee6 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@sentry/node": "6.19.7", "@tryghost/adapter-manager": "0.2.30", "@tryghost/admin-api-schema": "2.16.0", - "@tryghost/api-version-compatibility-service": "0.3.1", + "@tryghost/api-version-compatibility-service": "0.4.0", "@tryghost/bookshelf-plugins": "0.4.1", "@tryghost/bootstrap-socket": "0.2.19", "@tryghost/color-utils": "0.1.16", @@ -93,7 +93,7 @@ "@tryghost/members-stripe-service": "0.10.3", "@tryghost/metrics": "1.0.11", "@tryghost/minifier": "0.1.14", - "@tryghost/mw-api-version-mismatch": "0.1.4", + "@tryghost/mw-api-version-mismatch": "0.2.0", "@tryghost/mw-error-handler": "1.0.0", "@tryghost/mw-session-from-token": "0.1.31", "@tryghost/nodemailer": "0.3.22", diff --git a/yarn.lock b/yarn.lock index 3f80071848..2fe2428002 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1727,13 +1727,13 @@ "@tryghost/errors" "^1.0.0" lodash "^4.17.11" -"@tryghost/api-version-compatibility-service@0.3.1": - version "0.3.1" - resolved "https://registry.yarnpkg.com/@tryghost/api-version-compatibility-service/-/api-version-compatibility-service-0.3.1.tgz#b7a656c18fdd31131f74d450aa70897f9ed47742" - integrity sha512-LioWdzPbouxHQ+btLz+XpbLvTonF31x2EkbDmjxqoe2V751RMdJHG226HlqQP5vnrC0Jew7gKLMmQzsUSrLkEA== +"@tryghost/api-version-compatibility-service@0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@tryghost/api-version-compatibility-service/-/api-version-compatibility-service-0.4.0.tgz#336585ec9a368e9192dd1c6d990d9bfb4dd72d38" + integrity sha512-YSABkGY9vaTxlX7WmfV6q+xqlnYST0qwJICKVPkhQHiBA7CQwvcGE/PAzHZ3K7azuAGo3Oa0+FnkwI0bp9WeRA== dependencies: "@tryghost/email-content-generator" "^0.1.2" - "@tryghost/version-notifications-data-service" "^0.1.2" + "@tryghost/version-notifications-data-service" "^0.2.0" "@tryghost/bookshelf-collision@^0.1.22": version "0.1.22" @@ -1979,6 +1979,13 @@ cookiejar "^2.1.3" reqresnext "^1.7.0" +"@tryghost/extract-api-key@^0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@tryghost/extract-api-key/-/extract-api-key-0.1.0.tgz#d54963bc1836b582db735b01105807a6d2b90619" + integrity sha512-MkVfY/GmIEPuNDaNrKQupK2yW0TV6Vd9v43ZloXAE/PPIAS2K/w/ImmI1CGNxpVJi1fGzXJY5cU7T+C1UK0fWQ== + dependencies: + jsonwebtoken "^8.5.1" + "@tryghost/helpers@1.1.67": version "1.1.67" resolved "https://registry.yarnpkg.com/@tryghost/helpers/-/helpers-1.1.67.tgz#cbfcf2d6b2c1d0a64b18d859992c3a98f591a441" @@ -2306,10 +2313,12 @@ dependencies: lodash "^4.17.11" -"@tryghost/mw-api-version-mismatch@0.1.4": - version "0.1.4" - resolved "https://registry.yarnpkg.com/@tryghost/mw-api-version-mismatch/-/mw-api-version-mismatch-0.1.4.tgz#0a8cd94572a6fd45bc327d7bc871b1f8de02c8ec" - integrity sha512-V50d2nP3Z+HUialKef9of8UIKEjmTo8ogszgqDy2DH08aNYWUYDRFEWWjUiqdcTXGJMhhPzYlR6cAaYhPj8YwA== +"@tryghost/mw-api-version-mismatch@0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@tryghost/mw-api-version-mismatch/-/mw-api-version-mismatch-0.2.0.tgz#d4e3a757200c0c949c79766e30a5871e00d2f948" + integrity sha512-xu45flNJgpPzLWi1I5nrDsmnPHjkPwAamuaVHKB14pkr4WsDDfQm8q8M6HCHDMo4dt5VJWZ87Xtbk1CXiWp7zA== + dependencies: + "@tryghost/extract-api-key" "^0.1.0" "@tryghost/mw-error-handler@1.0.0": version "1.0.0" @@ -2539,10 +2548,10 @@ "@tryghost/domain-events" "^0.1.12" "@tryghost/member-events" "^0.4.4" -"@tryghost/version-notifications-data-service@^0.1.2": - version "0.1.2" - resolved "https://registry.yarnpkg.com/@tryghost/version-notifications-data-service/-/version-notifications-data-service-0.1.2.tgz#2a99315a721b74a945fc88615f57db1f54483dfb" - integrity sha512-NjGqYYsZUrT82GAmvGWPWWQ2Z2XJDuFDz0Ep8j1jk/xxhty0Qas6uweQFn9HvbTOF3W7kvbVSEvmevyBWiQfJQ== +"@tryghost/version-notifications-data-service@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@tryghost/version-notifications-data-service/-/version-notifications-data-service-0.2.0.tgz#e528ce7450b4cd31c035fa5a47f131cc6e8925d9" + integrity sha512-Yz9e98kYaW7pb+QnaY0IONTSa4QjiZqGdnawkkCmECuHWIXx2cRnwCrGvhJ0+g3SxZGv5IB9ZBJQzAVrsHxjNA== "@tryghost/version@0.1.14", "@tryghost/version@^0.1.14": version "0.1.14"