geoserver-node-client 1.2.4 → 1.4.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.
- package/README.md +5 -2
- package/dist/geoserver-rest-client.js +4 -25
- package/dist/package.json +15 -16
- package/dist/src/about.js +42 -70
- package/dist/src/datastore.js +513 -654
- package/dist/src/imagemosaic.js +112 -164
- package/dist/src/layer.js +591 -797
- package/dist/src/layergroup.js +275 -0
- package/dist/src/namespace.js +126 -186
- package/dist/src/reset-reload.js +49 -78
- package/dist/src/security.js +117 -169
- package/dist/src/settings.js +137 -198
- package/dist/src/style.js +260 -376
- package/dist/src/util/geoserver.js +12 -36
- package/dist/src/workspace.js +133 -190
- package/geoserver-rest-client.js +3 -0
- package/package.json +15 -16
- package/src/datastore.js +22 -1
- package/src/layergroup.js +176 -0
- package/src/workspace.js +4 -3
package/dist/src/security.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
12
|
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
19
|
-
|
|
20
13
|
var _geoserver = require("./util/geoserver.js");
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* Client for GeoServer security.
|
|
24
16
|
*
|
|
@@ -36,6 +28,7 @@ var SecurityClient = /*#__PURE__*/function () {
|
|
|
36
28
|
this.url = url;
|
|
37
29
|
this.auth = auth;
|
|
38
30
|
}
|
|
31
|
+
|
|
39
32
|
/**
|
|
40
33
|
* Returns all users registered in GeoServer.
|
|
41
34
|
*
|
|
@@ -43,56 +36,44 @@ var SecurityClient = /*#__PURE__*/function () {
|
|
|
43
36
|
*
|
|
44
37
|
* @returns {Object} An object with all users
|
|
45
38
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
39
|
(0, _createClass2["default"])(SecurityClient, [{
|
|
49
40
|
key: "getAllUsers",
|
|
50
41
|
value: function () {
|
|
51
42
|
var _getAllUsers = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
52
43
|
var response, geoServerResponse;
|
|
53
44
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
54
|
-
while (1) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
Authorization: this.auth
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
case 2:
|
|
67
|
-
response = _context.sent;
|
|
68
|
-
|
|
69
|
-
if (response.ok) {
|
|
70
|
-
_context.next = 8;
|
|
71
|
-
break;
|
|
45
|
+
while (1) switch (_context.prev = _context.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
_context.next = 2;
|
|
48
|
+
return (0, _nodeFetch["default"])(this.url + 'security/usergroup/users.json', {
|
|
49
|
+
credentials: 'include',
|
|
50
|
+
method: 'GET',
|
|
51
|
+
headers: {
|
|
52
|
+
Authorization: this.auth
|
|
72
53
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
});
|
|
55
|
+
case 2:
|
|
56
|
+
response = _context.sent;
|
|
57
|
+
if (response.ok) {
|
|
58
|
+
_context.next = 8;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
_context.next = 6;
|
|
62
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
63
|
+
case 6:
|
|
64
|
+
geoServerResponse = _context.sent;
|
|
65
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
66
|
+
case 8:
|
|
67
|
+
return _context.abrupt("return", response.json());
|
|
68
|
+
case 9:
|
|
69
|
+
case "end":
|
|
70
|
+
return _context.stop();
|
|
88
71
|
}
|
|
89
72
|
}, _callee, this);
|
|
90
73
|
}));
|
|
91
|
-
|
|
92
74
|
function getAllUsers() {
|
|
93
75
|
return _getAllUsers.apply(this, arguments);
|
|
94
76
|
}
|
|
95
|
-
|
|
96
77
|
return getAllUsers;
|
|
97
78
|
}()
|
|
98
79
|
/**
|
|
@@ -103,69 +84,57 @@ var SecurityClient = /*#__PURE__*/function () {
|
|
|
103
84
|
*
|
|
104
85
|
* @throws Error if request fails
|
|
105
86
|
*/
|
|
106
|
-
|
|
107
87
|
}, {
|
|
108
88
|
key: "createUser",
|
|
109
89
|
value: function () {
|
|
110
90
|
var _createUser = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(username, password) {
|
|
111
91
|
var body, response, geoServerResponse;
|
|
112
92
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
113
|
-
while (1) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
enabled: true
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
_context2.next = 3;
|
|
124
|
-
return (0, _nodeFetch["default"])(this.url + 'security/usergroup/users.json', {
|
|
125
|
-
credentials: 'include',
|
|
126
|
-
method: 'POST',
|
|
127
|
-
headers: {
|
|
128
|
-
Authorization: this.auth,
|
|
129
|
-
'Content-Type': 'application/json'
|
|
130
|
-
},
|
|
131
|
-
body: JSON.stringify(body)
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
case 3:
|
|
135
|
-
response = _context2.sent;
|
|
136
|
-
|
|
137
|
-
if (response.ok) {
|
|
138
|
-
_context2.next = 13;
|
|
139
|
-
break;
|
|
93
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
body = {
|
|
96
|
+
user: {
|
|
97
|
+
userName: username,
|
|
98
|
+
password: password,
|
|
99
|
+
enabled: true
|
|
140
100
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
101
|
+
};
|
|
102
|
+
_context2.next = 3;
|
|
103
|
+
return (0, _nodeFetch["default"])(this.url + 'security/usergroup/users.json', {
|
|
104
|
+
credentials: 'include',
|
|
105
|
+
method: 'POST',
|
|
106
|
+
headers: {
|
|
107
|
+
Authorization: this.auth,
|
|
108
|
+
'Content-Type': 'application/json'
|
|
109
|
+
},
|
|
110
|
+
body: JSON.stringify(body)
|
|
111
|
+
});
|
|
112
|
+
case 3:
|
|
113
|
+
response = _context2.sent;
|
|
114
|
+
if (response.ok) {
|
|
115
|
+
_context2.next = 13;
|
|
149
116
|
break;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
117
|
+
}
|
|
118
|
+
_context2.next = 7;
|
|
119
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
120
|
+
case 7:
|
|
121
|
+
geoServerResponse = _context2.sent;
|
|
122
|
+
_context2.t0 = response.status;
|
|
123
|
+
_context2.next = _context2.t0 === 404 ? 11 : 12;
|
|
124
|
+
break;
|
|
125
|
+
case 11:
|
|
126
|
+
throw new _geoserver.GeoServerResponseError("User ".concat(username, " might already exists."), geoServerResponse);
|
|
127
|
+
case 12:
|
|
128
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
129
|
+
case 13:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context2.stop();
|
|
161
132
|
}
|
|
162
133
|
}, _callee2, this);
|
|
163
134
|
}));
|
|
164
|
-
|
|
165
135
|
function createUser(_x, _x2) {
|
|
166
136
|
return _createUser.apply(this, arguments);
|
|
167
137
|
}
|
|
168
|
-
|
|
169
138
|
return createUser;
|
|
170
139
|
}()
|
|
171
140
|
/**
|
|
@@ -178,60 +147,50 @@ var SecurityClient = /*#__PURE__*/function () {
|
|
|
178
147
|
*
|
|
179
148
|
* @throws Error if request fails
|
|
180
149
|
*/
|
|
181
|
-
|
|
182
150
|
}, {
|
|
183
151
|
key: "updateUser",
|
|
184
152
|
value: function () {
|
|
185
153
|
var _updateUser = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(username, password, enabled) {
|
|
186
154
|
var body, response, geoServerResponse;
|
|
187
155
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
188
|
-
while (1) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
enabled: enabled
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
_context3.next = 3;
|
|
198
|
-
return (0, _nodeFetch["default"])(this.url + 'security/usergroup/user/' + username, {
|
|
199
|
-
credentials: 'include',
|
|
200
|
-
method: 'POST',
|
|
201
|
-
headers: {
|
|
202
|
-
Authorization: this.auth,
|
|
203
|
-
'Content-Type': 'application/json'
|
|
204
|
-
},
|
|
205
|
-
body: JSON.stringify(body)
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
case 3:
|
|
209
|
-
response = _context3.sent;
|
|
210
|
-
|
|
211
|
-
if (response.ok) {
|
|
212
|
-
_context3.next = 9;
|
|
213
|
-
break;
|
|
156
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
157
|
+
case 0:
|
|
158
|
+
body = {
|
|
159
|
+
user: {
|
|
160
|
+
password: password,
|
|
161
|
+
enabled: enabled
|
|
214
162
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
163
|
+
};
|
|
164
|
+
_context3.next = 3;
|
|
165
|
+
return (0, _nodeFetch["default"])(this.url + 'security/usergroup/user/' + username, {
|
|
166
|
+
credentials: 'include',
|
|
167
|
+
method: 'POST',
|
|
168
|
+
headers: {
|
|
169
|
+
Authorization: this.auth,
|
|
170
|
+
'Content-Type': 'application/json'
|
|
171
|
+
},
|
|
172
|
+
body: JSON.stringify(body)
|
|
173
|
+
});
|
|
174
|
+
case 3:
|
|
175
|
+
response = _context3.sent;
|
|
176
|
+
if (response.ok) {
|
|
177
|
+
_context3.next = 9;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
_context3.next = 7;
|
|
181
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
182
|
+
case 7:
|
|
183
|
+
geoServerResponse = _context3.sent;
|
|
184
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
185
|
+
case 9:
|
|
186
|
+
case "end":
|
|
187
|
+
return _context3.stop();
|
|
227
188
|
}
|
|
228
189
|
}, _callee3, this);
|
|
229
190
|
}));
|
|
230
|
-
|
|
231
191
|
function updateUser(_x3, _x4, _x5) {
|
|
232
192
|
return _updateUser.apply(this, arguments);
|
|
233
193
|
}
|
|
234
|
-
|
|
235
194
|
return updateUser;
|
|
236
195
|
}()
|
|
237
196
|
/**
|
|
@@ -242,56 +201,45 @@ var SecurityClient = /*#__PURE__*/function () {
|
|
|
242
201
|
*
|
|
243
202
|
* @throws Error if request fails
|
|
244
203
|
*/
|
|
245
|
-
|
|
246
204
|
}, {
|
|
247
205
|
key: "associateUserRole",
|
|
248
206
|
value: function () {
|
|
249
207
|
var _associateUserRole = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(username, role) {
|
|
250
208
|
var response, geoServerResponse;
|
|
251
209
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
252
|
-
while (1) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
Authorization: this.auth
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
case 2:
|
|
265
|
-
response = _context4.sent;
|
|
266
|
-
|
|
267
|
-
if (response.ok) {
|
|
268
|
-
_context4.next = 8;
|
|
269
|
-
break;
|
|
210
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
211
|
+
case 0:
|
|
212
|
+
_context4.next = 2;
|
|
213
|
+
return (0, _nodeFetch["default"])("".concat(this.url, "security/roles/role/").concat(role, "/user/").concat(username), {
|
|
214
|
+
credentials: 'include',
|
|
215
|
+
method: 'POST',
|
|
216
|
+
headers: {
|
|
217
|
+
Authorization: this.auth
|
|
270
218
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
219
|
+
});
|
|
220
|
+
case 2:
|
|
221
|
+
response = _context4.sent;
|
|
222
|
+
if (response.ok) {
|
|
223
|
+
_context4.next = 8;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
_context4.next = 6;
|
|
227
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
228
|
+
case 6:
|
|
229
|
+
geoServerResponse = _context4.sent;
|
|
230
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
231
|
+
case 8:
|
|
232
|
+
case "end":
|
|
233
|
+
return _context4.stop();
|
|
283
234
|
}
|
|
284
235
|
}, _callee4, this);
|
|
285
236
|
}));
|
|
286
|
-
|
|
287
237
|
function associateUserRole(_x6, _x7) {
|
|
288
238
|
return _associateUserRole.apply(this, arguments);
|
|
289
239
|
}
|
|
290
|
-
|
|
291
240
|
return associateUserRole;
|
|
292
241
|
}()
|
|
293
242
|
}]);
|
|
294
243
|
return SecurityClient;
|
|
295
244
|
}();
|
|
296
|
-
|
|
297
245
|
exports["default"] = SecurityClient;
|