@tryghost/admin-api 1.10.0 → 1.11.2
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.
- package/lib/index.js +9 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -3,6 +3,9 @@ const FormData = require('form-data');
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const token = require('./token');
|
|
5
5
|
|
|
6
|
+
const packageInfo = require('../package.json');
|
|
7
|
+
const packageVersion = packageInfo.version;
|
|
8
|
+
|
|
6
9
|
// NOTE: bump this default when Ghost v5 is released
|
|
7
10
|
const defaultAcceptVersionHeader = 'v4.0';
|
|
8
11
|
const supportedVersions = ['v2', 'v3', 'v4', 'v5', 'canary'];
|
|
@@ -21,6 +24,9 @@ const resolveAPIPrefix = (version) => {
|
|
|
21
24
|
// NOTE: the "version.match(/^v5\.\d+/)" expression should be changed to "version.match(/^v\d+\.\d+/)" once Ghost v5 is out
|
|
22
25
|
if (version === 'v5' || version === undefined || version.match(/^v5\.\d+/)) {
|
|
23
26
|
prefix = `/admin/`;
|
|
27
|
+
} else if (version.match(/^v\d+\.\d+/)) {
|
|
28
|
+
const versionPrefix = /^(v\d+)\.\d+/.exec(version)[1];
|
|
29
|
+
prefix = `/${versionPrefix}/admin/`;
|
|
24
30
|
} else {
|
|
25
31
|
prefix = `/${version}/admin/`;
|
|
26
32
|
}
|
|
@@ -54,6 +60,7 @@ module.exports = function GhostAdminAPI(options) {
|
|
|
54
60
|
data,
|
|
55
61
|
headers,
|
|
56
62
|
maxContentLength: Infinity,
|
|
63
|
+
maxBodyLength: Infinity,
|
|
57
64
|
paramsSerializer(parameters) {
|
|
58
65
|
return Object.keys(parameters).reduce((parts, key) => {
|
|
59
66
|
const val = encodeURIComponent([].concat(parameters[key]).join(','));
|
|
@@ -417,7 +424,8 @@ module.exports = function GhostAdminAPI(options) {
|
|
|
417
424
|
authorizationHeader = `Ghost ${config.generateToken(key, audience)}`;
|
|
418
425
|
|
|
419
426
|
const ghostHeaders = {
|
|
420
|
-
Authorization: authorizationHeader
|
|
427
|
+
Authorization: authorizationHeader,
|
|
428
|
+
'User-Agent': `GhostAdminSDK/${packageVersion}`
|
|
421
429
|
};
|
|
422
430
|
|
|
423
431
|
if (config.acceptVersionHeader) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/admin-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"repository": "https://github.com/TryGhost/SDK/tree/master/packages/admin-api",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"form-data": "^4.0.0",
|
|
32
32
|
"jsonwebtoken": "^8.4.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "6c0165f2588537f0e00e76567c2ed2f526f7faff"
|
|
35
35
|
}
|