@tryghost/admin-api 1.12.2 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/admin-api.js +11 -2
  2. package/package.json +2 -2
package/lib/admin-api.js CHANGED
@@ -41,6 +41,7 @@ const resolveAPIPrefix = (version) => {
41
41
  * @param {String} options.url
42
42
  * @param {String} [options.ghostPath]
43
43
  * @param {String|Boolean} options.version - a version string like v3.2, v4.1, v5.8 or boolean value identifying presence of Accept-Version header
44
+ * @param {String|Boolean} [options.userAgent] - flag controlling if the 'User-Agent' header should be sent with a request
44
45
  * @param {Function} [options.makeRequest]
45
46
  * @param {Function} [options.generateToken]
46
47
  * @param {String} [options.host] Deprecated
@@ -52,6 +53,7 @@ module.exports = function GhostAdminAPI(options) {
52
53
 
53
54
  const defaultConfig = {
54
55
  ghostPath: 'ghost',
56
+ userAgent: true,
55
57
  generateToken: token,
56
58
  makeRequest({url, method, data, params = {}, headers = {}}) {
57
59
  return axios({
@@ -426,10 +428,17 @@ module.exports = function GhostAdminAPI(options) {
426
428
  authorizationHeader = `Ghost ${config.generateToken(key, audience)}`;
427
429
 
428
430
  const ghostHeaders = {
429
- Authorization: authorizationHeader,
430
- 'User-Agent': `GhostAdminSDK/${packageVersion}`
431
+ Authorization: authorizationHeader
431
432
  };
432
433
 
434
+ if (config.userAgent) {
435
+ if (typeof config.userAgent === 'boolean') {
436
+ ghostHeaders['User-Agent'] = `GhostAdminSDK/${packageVersion}`;
437
+ } else {
438
+ headers['User-Agent'] = config.userAgent;
439
+ }
440
+ }
441
+
433
442
  if (config.acceptVersionHeader) {
434
443
  ghostHeaders['Accept-Version'] = config.acceptVersionHeader;
435
444
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/admin-api",
3
- "version": "1.12.2",
3
+ "version": "1.13.0",
4
4
  "repository": "https://github.com/TryGhost/SDK/tree/master/packages/admin-api",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -32,5 +32,5 @@
32
32
  "form-data": "^4.0.0",
33
33
  "jsonwebtoken": "^8.4.0"
34
34
  },
35
- "gitHead": "ce790579ad1f191b24c05733d8a0a56f0b9f96d2"
35
+ "gitHead": "a1f560e288bf67886483f9b5d483eecd749c09cc"
36
36
  }