files.com 1.0.318 → 1.0.320

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/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.318
1
+ 1.0.320
@@ -0,0 +1,129 @@
1
+ # GpgKey
2
+
3
+ ## Example GpgKey Object
4
+
5
+ ```
6
+ {
7
+ "id": 1,
8
+ "expires_at": "2000-01-01T01:00:00Z",
9
+ "name": "key name",
10
+ "user_id": 1,
11
+ "public_key": "7f8bc1210b09b9ddf469e6b6b8920e76",
12
+ "private_key": "ab236cfe4a195f0226bc2e674afdd6b0",
13
+ "private_key_password": "[your GPG private key password]"
14
+ }
15
+ ```
16
+
17
+ * `id` (int64): Your GPG key ID.
18
+ * `expires_at` (date-time): Your GPG key expiration date.
19
+ * `name` (string): Your GPG key name.
20
+ * `user_id` (int64): GPG owner's user id
21
+ * `public_key` (string): Your GPG public key
22
+ * `private_key` (string): Your GPG private key.
23
+ * `private_key_password` (string): Your GPG private key password. Only required for password protected keys.
24
+
25
+ ---
26
+
27
+ ## List Gpg Keys
28
+
29
+ ```
30
+ await GpgKey.list({
31
+ 'user_id': 1,
32
+ 'per_page': 1,
33
+ })
34
+ ```
35
+
36
+
37
+ ### Parameters
38
+
39
+ * `user_id` (int64): User ID. Provide a value of `0` to operate the current session's user.
40
+ * `cursor` (string): Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
41
+ * `per_page` (int64): Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
42
+
43
+ ---
44
+
45
+ ## Show Gpg Key
46
+
47
+ ```
48
+ await GpgKey.find(id)
49
+ ```
50
+
51
+
52
+ ### Parameters
53
+
54
+ * `id` (int64): Required - Gpg Key ID.
55
+
56
+ ---
57
+
58
+ ## Create Gpg Key
59
+
60
+ ```
61
+ await GpgKey.create({
62
+ 'user_id': 1,
63
+ 'name': "key name",
64
+ 'public_key': "7f8bc1210b09b9ddf469e6b6b8920e76",
65
+ 'private_key': "ab236cfe4a195f0226bc2e674afdd6b0",
66
+ 'private_key_password': "[your GPG private key password]",
67
+ })
68
+ ```
69
+
70
+
71
+ ### Parameters
72
+
73
+ * `user_id` (int64): User ID. Provide a value of `0` to operate the current session's user.
74
+ * `name` (string): Required - Your GPG key name.
75
+ * `public_key` (string): Your GPG public key
76
+ * `private_key` (string): Your GPG private key.
77
+ * `private_key_password` (string): Your GPG private key password. Only required for password protected keys.
78
+
79
+ ---
80
+
81
+ ## Update Gpg Key
82
+
83
+ ```
84
+ const [gpg_key] = await GpgKey.list()
85
+
86
+ await gpg_key.update({
87
+ 'name': "key name",
88
+ 'public_key': "7f8bc1210b09b9ddf469e6b6b8920e76",
89
+ 'private_key': "ab236cfe4a195f0226bc2e674afdd6b0",
90
+ 'private_key_password': "[your GPG private key password]",
91
+ })
92
+ ```
93
+
94
+ ### Parameters
95
+
96
+ * `id` (int64): Required - Gpg Key ID.
97
+ * `name` (string): Required - Your GPG key name.
98
+ * `public_key` (string): Your GPG public key
99
+ * `private_key` (string): Your GPG private key.
100
+ * `private_key_password` (string): Your GPG private key password. Only required for password protected keys.
101
+
102
+ ### Example Response
103
+
104
+ ```json
105
+ {
106
+ "id": 1,
107
+ "expires_at": "2000-01-01T01:00:00Z",
108
+ "name": "key name",
109
+ "user_id": 1,
110
+ "public_key": "7f8bc1210b09b9ddf469e6b6b8920e76",
111
+ "private_key": "ab236cfe4a195f0226bc2e674afdd6b0",
112
+ "private_key_password": "[your GPG private key password]"
113
+ }
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Delete Gpg Key
119
+
120
+ ```
121
+ const [gpg_key] = await GpgKey.list()
122
+
123
+ await gpg_key.delete()
124
+ ```
125
+
126
+ ### Parameters
127
+
128
+ * `id` (int64): Required - Gpg Key ID.
129
+
package/lib/Files.js CHANGED
@@ -11,7 +11,7 @@ var endpointPrefix = '/api/rest/v1';
11
11
  var apiKey;
12
12
  var baseUrl = 'https://app.files.com';
13
13
  var sessionId = null;
14
- var version = "1.0.318";
14
+ var version = "1.0.320";
15
15
  var userAgent = "Files.com JavaScript SDK v".concat(version);
16
16
  var logLevel = _Logger.LogLevel.INFO;
17
17
  var debugRequest = false;
@@ -0,0 +1,427 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ exports.__esModule = true;
6
+ exports.default = void 0;
7
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _Api = _interopRequireDefault(require("../Api"));
14
+ var errors = _interopRequireWildcard(require("../Errors"));
15
+ var _Logger = _interopRequireDefault(require("../Logger"));
16
+ var _utils = require("../utils");
17
+ var _class;
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
22
+ /**
23
+ * Class GpgKey
24
+ */
25
+ var GpgKey = /*#__PURE__*/(0, _createClass2.default)(function GpgKey() {
26
+ var _this = this;
27
+ var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
28
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
29
+ (0, _classCallCheck2.default)(this, GpgKey);
30
+ (0, _defineProperty2.default)(this, "attributes", {});
31
+ (0, _defineProperty2.default)(this, "options", {});
32
+ (0, _defineProperty2.default)(this, "isLoaded", function () {
33
+ return !!_this.attributes.id;
34
+ });
35
+ // int64 # Your GPG key ID.
36
+ (0, _defineProperty2.default)(this, "getId", function () {
37
+ return _this.attributes.id;
38
+ });
39
+ (0, _defineProperty2.default)(this, "setId", function (value) {
40
+ _this.attributes.id = value;
41
+ });
42
+ // date-time # Your GPG key expiration date.
43
+ (0, _defineProperty2.default)(this, "getExpiresAt", function () {
44
+ return _this.attributes.expires_at;
45
+ });
46
+ (0, _defineProperty2.default)(this, "setExpiresAt", function (value) {
47
+ _this.attributes.expires_at = value;
48
+ });
49
+ // string # Your GPG key name.
50
+ (0, _defineProperty2.default)(this, "getName", function () {
51
+ return _this.attributes.name;
52
+ });
53
+ (0, _defineProperty2.default)(this, "setName", function (value) {
54
+ _this.attributes.name = value;
55
+ });
56
+ // int64 # GPG owner's user id
57
+ (0, _defineProperty2.default)(this, "getUserId", function () {
58
+ return _this.attributes.user_id;
59
+ });
60
+ (0, _defineProperty2.default)(this, "setUserId", function (value) {
61
+ _this.attributes.user_id = value;
62
+ });
63
+ // string # Your GPG public key
64
+ (0, _defineProperty2.default)(this, "getPublicKey", function () {
65
+ return _this.attributes.public_key;
66
+ });
67
+ (0, _defineProperty2.default)(this, "setPublicKey", function (value) {
68
+ _this.attributes.public_key = value;
69
+ });
70
+ // string # Your GPG private key.
71
+ (0, _defineProperty2.default)(this, "getPrivateKey", function () {
72
+ return _this.attributes.private_key;
73
+ });
74
+ (0, _defineProperty2.default)(this, "setPrivateKey", function (value) {
75
+ _this.attributes.private_key = value;
76
+ });
77
+ // string # Your GPG private key password. Only required for password protected keys.
78
+ (0, _defineProperty2.default)(this, "getPrivateKeyPassword", function () {
79
+ return _this.attributes.private_key_password;
80
+ });
81
+ (0, _defineProperty2.default)(this, "setPrivateKeyPassword", function (value) {
82
+ _this.attributes.private_key_password = value;
83
+ });
84
+ // Parameters:
85
+ // name (required) - string - Your GPG key name.
86
+ // public_key - string - Your GPG public key
87
+ // private_key - string - Your GPG private key.
88
+ // private_key_password - string - Your GPG private key password. Only required for password protected keys.
89
+ (0, _defineProperty2.default)(this, "update", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
90
+ var params,
91
+ response,
92
+ _args = arguments;
93
+ return _regenerator.default.wrap(function _callee$(_context) {
94
+ while (1) switch (_context.prev = _context.next) {
95
+ case 0:
96
+ params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
97
+ if (_this.attributes.id) {
98
+ _context.next = 3;
99
+ break;
100
+ }
101
+ throw new errors.EmptyPropertyError('Current object has no id');
102
+ case 3:
103
+ if ((0, _utils.isObject)(params)) {
104
+ _context.next = 5;
105
+ break;
106
+ }
107
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
108
+ case 5:
109
+ params.id = _this.attributes.id;
110
+ if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
111
+ _context.next = 8;
112
+ break;
113
+ }
114
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
115
+ case 8:
116
+ if (!(params['name'] && !(0, _utils.isString)(params['name']))) {
117
+ _context.next = 10;
118
+ break;
119
+ }
120
+ throw new errors.InvalidParameterError("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(name)));
121
+ case 10:
122
+ if (!(params['public_key'] && !(0, _utils.isString)(params['public_key']))) {
123
+ _context.next = 12;
124
+ break;
125
+ }
126
+ throw new errors.InvalidParameterError("Bad parameter: public_key must be of type String, received ".concat((0, _utils.getType)(public_key)));
127
+ case 12:
128
+ if (!(params['private_key'] && !(0, _utils.isString)(params['private_key']))) {
129
+ _context.next = 14;
130
+ break;
131
+ }
132
+ throw new errors.InvalidParameterError("Bad parameter: private_key must be of type String, received ".concat((0, _utils.getType)(private_key)));
133
+ case 14:
134
+ if (!(params['private_key_password'] && !(0, _utils.isString)(params['private_key_password']))) {
135
+ _context.next = 16;
136
+ break;
137
+ }
138
+ throw new errors.InvalidParameterError("Bad parameter: private_key_password must be of type String, received ".concat((0, _utils.getType)(private_key_password)));
139
+ case 16:
140
+ if (params['id']) {
141
+ _context.next = 22;
142
+ break;
143
+ }
144
+ if (!_this.attributes.id) {
145
+ _context.next = 21;
146
+ break;
147
+ }
148
+ params['id'] = _this.id;
149
+ _context.next = 22;
150
+ break;
151
+ case 21:
152
+ throw new errors.MissingParameterError('Parameter missing: id');
153
+ case 22:
154
+ if (params['name']) {
155
+ _context.next = 28;
156
+ break;
157
+ }
158
+ if (!_this.attributes.name) {
159
+ _context.next = 27;
160
+ break;
161
+ }
162
+ params['name'] = _this.name;
163
+ _context.next = 28;
164
+ break;
165
+ case 27:
166
+ throw new errors.MissingParameterError('Parameter missing: name');
167
+ case 28:
168
+ _context.next = 30;
169
+ return _Api.default.sendRequest("/gpg_keys/".concat(encodeURIComponent(params['id'])), 'PATCH', params, _this.options);
170
+ case 30:
171
+ response = _context.sent;
172
+ return _context.abrupt("return", new GpgKey(response === null || response === void 0 ? void 0 : response.data, _this.options));
173
+ case 32:
174
+ case "end":
175
+ return _context.stop();
176
+ }
177
+ }, _callee);
178
+ })));
179
+ (0, _defineProperty2.default)(this, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
180
+ var params,
181
+ response,
182
+ _args2 = arguments;
183
+ return _regenerator.default.wrap(function _callee2$(_context2) {
184
+ while (1) switch (_context2.prev = _context2.next) {
185
+ case 0:
186
+ params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
187
+ if (_this.attributes.id) {
188
+ _context2.next = 3;
189
+ break;
190
+ }
191
+ throw new errors.EmptyPropertyError('Current object has no id');
192
+ case 3:
193
+ if ((0, _utils.isObject)(params)) {
194
+ _context2.next = 5;
195
+ break;
196
+ }
197
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
198
+ case 5:
199
+ params.id = _this.attributes.id;
200
+ if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
201
+ _context2.next = 8;
202
+ break;
203
+ }
204
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
205
+ case 8:
206
+ if (params['id']) {
207
+ _context2.next = 14;
208
+ break;
209
+ }
210
+ if (!_this.attributes.id) {
211
+ _context2.next = 13;
212
+ break;
213
+ }
214
+ params['id'] = _this.id;
215
+ _context2.next = 14;
216
+ break;
217
+ case 13:
218
+ throw new errors.MissingParameterError('Parameter missing: id');
219
+ case 14:
220
+ _context2.next = 16;
221
+ return _Api.default.sendRequest("/gpg_keys/".concat(encodeURIComponent(params['id'])), 'DELETE', params, _this.options);
222
+ case 16:
223
+ response = _context2.sent;
224
+ return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
225
+ case 18:
226
+ case "end":
227
+ return _context2.stop();
228
+ }
229
+ }, _callee2);
230
+ })));
231
+ (0, _defineProperty2.default)(this, "destroy", function () {
232
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
233
+ return _this.delete(params);
234
+ });
235
+ (0, _defineProperty2.default)(this, "save", function () {
236
+ if (_this.attributes['id']) {
237
+ return _this.update(_this.attributes);
238
+ } else {
239
+ var newObject = GpgKey.create(_this.attributes, _this.options);
240
+ _this.attributes = _objectSpread({}, newObject.attributes);
241
+ return true;
242
+ }
243
+ });
244
+ Object.entries(attributes).forEach(function (_ref3) {
245
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
246
+ key = _ref4[0],
247
+ value = _ref4[1];
248
+ var normalizedKey = key.replace('?', '');
249
+ _this.attributes[normalizedKey] = value;
250
+ Object.defineProperty(_this, normalizedKey, {
251
+ value: value,
252
+ writable: false
253
+ });
254
+ });
255
+ this.options = _objectSpread({}, options);
256
+ });
257
+ _class = GpgKey;
258
+ // Parameters:
259
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
260
+ // cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
261
+ // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
262
+ (0, _defineProperty2.default)(GpgKey, "list", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
263
+ var _response$data;
264
+ var params,
265
+ options,
266
+ response,
267
+ _args3 = arguments;
268
+ return _regenerator.default.wrap(function _callee3$(_context3) {
269
+ while (1) switch (_context3.prev = _context3.next) {
270
+ case 0:
271
+ params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
272
+ options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
273
+ if (!(params['user_id'] && !(0, _utils.isInt)(params['user_id']))) {
274
+ _context3.next = 4;
275
+ break;
276
+ }
277
+ throw new errors.InvalidParameterError("Bad parameter: user_id must be of type Int, received ".concat((0, _utils.getType)(params['user_id'])));
278
+ case 4:
279
+ if (!(params['cursor'] && !(0, _utils.isString)(params['cursor']))) {
280
+ _context3.next = 6;
281
+ break;
282
+ }
283
+ throw new errors.InvalidParameterError("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(params['cursor'])));
284
+ case 6:
285
+ if (!(params['per_page'] && !(0, _utils.isInt)(params['per_page']))) {
286
+ _context3.next = 8;
287
+ break;
288
+ }
289
+ throw new errors.InvalidParameterError("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(params['per_page'])));
290
+ case 8:
291
+ _context3.next = 10;
292
+ return _Api.default.sendRequest("/gpg_keys", 'GET', params, options);
293
+ case 10:
294
+ response = _context3.sent;
295
+ return _context3.abrupt("return", (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.map(function (obj) {
296
+ return new _class(obj, options);
297
+ })) || []);
298
+ case 12:
299
+ case "end":
300
+ return _context3.stop();
301
+ }
302
+ }, _callee3);
303
+ })));
304
+ (0, _defineProperty2.default)(GpgKey, "all", function () {
305
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
306
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
307
+ return _class.list(params, options);
308
+ });
309
+ // Parameters:
310
+ // id (required) - int64 - Gpg Key ID.
311
+ (0, _defineProperty2.default)(GpgKey, "find", /*#__PURE__*/function () {
312
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id) {
313
+ var params,
314
+ options,
315
+ response,
316
+ _args4 = arguments;
317
+ return _regenerator.default.wrap(function _callee4$(_context4) {
318
+ while (1) switch (_context4.prev = _context4.next) {
319
+ case 0:
320
+ params = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
321
+ options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
322
+ if ((0, _utils.isObject)(params)) {
323
+ _context4.next = 4;
324
+ break;
325
+ }
326
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
327
+ case 4:
328
+ params['id'] = id;
329
+ if (params['id']) {
330
+ _context4.next = 7;
331
+ break;
332
+ }
333
+ throw new errors.MissingParameterError('Parameter missing: id');
334
+ case 7:
335
+ if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
336
+ _context4.next = 9;
337
+ break;
338
+ }
339
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(params['id'])));
340
+ case 9:
341
+ _context4.next = 11;
342
+ return _Api.default.sendRequest("/gpg_keys/".concat(encodeURIComponent(params['id'])), 'GET', params, options);
343
+ case 11:
344
+ response = _context4.sent;
345
+ return _context4.abrupt("return", new _class(response === null || response === void 0 ? void 0 : response.data, options));
346
+ case 13:
347
+ case "end":
348
+ return _context4.stop();
349
+ }
350
+ }, _callee4);
351
+ }));
352
+ return function (_x) {
353
+ return _ref6.apply(this, arguments);
354
+ };
355
+ }());
356
+ (0, _defineProperty2.default)(GpgKey, "get", function (id) {
357
+ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
358
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
359
+ return _class.find(id, params, options);
360
+ });
361
+ // Parameters:
362
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
363
+ // name (required) - string - Your GPG key name.
364
+ // public_key - string - Your GPG public key
365
+ // private_key - string - Your GPG private key.
366
+ // private_key_password - string - Your GPG private key password. Only required for password protected keys.
367
+ (0, _defineProperty2.default)(GpgKey, "create", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
368
+ var params,
369
+ options,
370
+ response,
371
+ _args5 = arguments;
372
+ return _regenerator.default.wrap(function _callee5$(_context5) {
373
+ while (1) switch (_context5.prev = _context5.next) {
374
+ case 0:
375
+ params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
376
+ options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
377
+ if (params['name']) {
378
+ _context5.next = 4;
379
+ break;
380
+ }
381
+ throw new errors.MissingParameterError('Parameter missing: name');
382
+ case 4:
383
+ if (!(params['user_id'] && !(0, _utils.isInt)(params['user_id']))) {
384
+ _context5.next = 6;
385
+ break;
386
+ }
387
+ throw new errors.InvalidParameterError("Bad parameter: user_id must be of type Int, received ".concat((0, _utils.getType)(params['user_id'])));
388
+ case 6:
389
+ if (!(params['name'] && !(0, _utils.isString)(params['name']))) {
390
+ _context5.next = 8;
391
+ break;
392
+ }
393
+ throw new errors.InvalidParameterError("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(params['name'])));
394
+ case 8:
395
+ if (!(params['public_key'] && !(0, _utils.isString)(params['public_key']))) {
396
+ _context5.next = 10;
397
+ break;
398
+ }
399
+ throw new errors.InvalidParameterError("Bad parameter: public_key must be of type String, received ".concat((0, _utils.getType)(params['public_key'])));
400
+ case 10:
401
+ if (!(params['private_key'] && !(0, _utils.isString)(params['private_key']))) {
402
+ _context5.next = 12;
403
+ break;
404
+ }
405
+ throw new errors.InvalidParameterError("Bad parameter: private_key must be of type String, received ".concat((0, _utils.getType)(params['private_key'])));
406
+ case 12:
407
+ if (!(params['private_key_password'] && !(0, _utils.isString)(params['private_key_password']))) {
408
+ _context5.next = 14;
409
+ break;
410
+ }
411
+ throw new errors.InvalidParameterError("Bad parameter: private_key_password must be of type String, received ".concat((0, _utils.getType)(params['private_key_password'])));
412
+ case 14:
413
+ _context5.next = 16;
414
+ return _Api.default.sendRequest("/gpg_keys", 'POST', params, options);
415
+ case 16:
416
+ response = _context5.sent;
417
+ return _context5.abrupt("return", new _class(response === null || response === void 0 ? void 0 : response.data, options));
418
+ case 18:
419
+ case "end":
420
+ return _context5.stop();
421
+ }
422
+ }, _callee5);
423
+ })));
424
+ var _default = GpgKey;
425
+ exports.default = _default;
426
+ module.exports = GpgKey;
427
+ module.exports.default = GpgKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.0.318",
3
+ "version": "1.0.320",
4
4
  "description": "Files.com SDK for JavaScript",
5
5
  "keywords": [
6
6
  "files.com",
package/src/Files.js CHANGED
@@ -5,7 +5,7 @@ const endpointPrefix = '/api/rest/v1'
5
5
  let apiKey
6
6
  let baseUrl = 'https://app.files.com'
7
7
  let sessionId = null
8
- let version = "1.0.318"
8
+ let version = "1.0.320"
9
9
  let userAgent = `Files.com JavaScript SDK v${version}`
10
10
 
11
11
  let logLevel = LogLevel.INFO
@@ -0,0 +1,258 @@
1
+ import Api from '../Api'
2
+ import * as errors from '../Errors'
3
+ import Logger from '../Logger'
4
+ import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
5
+
6
+ /**
7
+ * Class GpgKey
8
+ */
9
+ class GpgKey {
10
+ attributes = {}
11
+ options = {}
12
+
13
+ constructor(attributes = {}, options = {}) {
14
+ Object.entries(attributes).forEach(([key, value]) => {
15
+ const normalizedKey = key.replace('?', '')
16
+
17
+ this.attributes[normalizedKey] = value
18
+
19
+ Object.defineProperty(this, normalizedKey, { value, writable: false })
20
+ })
21
+
22
+ this.options = { ...options }
23
+ }
24
+
25
+ isLoaded = () => !!this.attributes.id
26
+ // int64 # Your GPG key ID.
27
+ getId = () => this.attributes.id
28
+
29
+ setId = value => {
30
+ this.attributes.id = value
31
+ }
32
+
33
+ // date-time # Your GPG key expiration date.
34
+ getExpiresAt = () => this.attributes.expires_at
35
+
36
+ setExpiresAt = value => {
37
+ this.attributes.expires_at = value
38
+ }
39
+
40
+ // string # Your GPG key name.
41
+ getName = () => this.attributes.name
42
+
43
+ setName = value => {
44
+ this.attributes.name = value
45
+ }
46
+
47
+ // int64 # GPG owner's user id
48
+ getUserId = () => this.attributes.user_id
49
+
50
+ setUserId = value => {
51
+ this.attributes.user_id = value
52
+ }
53
+
54
+ // string # Your GPG public key
55
+ getPublicKey = () => this.attributes.public_key
56
+
57
+ setPublicKey = value => {
58
+ this.attributes.public_key = value
59
+ }
60
+
61
+ // string # Your GPG private key.
62
+ getPrivateKey = () => this.attributes.private_key
63
+
64
+ setPrivateKey = value => {
65
+ this.attributes.private_key = value
66
+ }
67
+
68
+ // string # Your GPG private key password. Only required for password protected keys.
69
+ getPrivateKeyPassword = () => this.attributes.private_key_password
70
+
71
+ setPrivateKeyPassword = value => {
72
+ this.attributes.private_key_password = value
73
+ }
74
+
75
+
76
+ // Parameters:
77
+ // name (required) - string - Your GPG key name.
78
+ // public_key - string - Your GPG public key
79
+ // private_key - string - Your GPG private key.
80
+ // private_key_password - string - Your GPG private key password. Only required for password protected keys.
81
+ update = async (params = {}) => {
82
+ if (!this.attributes.id) {
83
+ throw new errors.EmptyPropertyError('Current object has no id')
84
+ }
85
+
86
+ if (!isObject(params)) {
87
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
88
+ }
89
+
90
+ params.id = this.attributes.id
91
+ if (params['id'] && !isInt(params['id'])) {
92
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
93
+ }
94
+ if (params['name'] && !isString(params['name'])) {
95
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(name)}`)
96
+ }
97
+ if (params['public_key'] && !isString(params['public_key'])) {
98
+ throw new errors.InvalidParameterError(`Bad parameter: public_key must be of type String, received ${getType(public_key)}`)
99
+ }
100
+ if (params['private_key'] && !isString(params['private_key'])) {
101
+ throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(private_key)}`)
102
+ }
103
+ if (params['private_key_password'] && !isString(params['private_key_password'])) {
104
+ throw new errors.InvalidParameterError(`Bad parameter: private_key_password must be of type String, received ${getType(private_key_password)}`)
105
+ }
106
+
107
+ if (!params['id']) {
108
+ if (this.attributes.id) {
109
+ params['id'] = this.id
110
+ } else {
111
+ throw new errors.MissingParameterError('Parameter missing: id')
112
+ }
113
+ }
114
+
115
+ if (!params['name']) {
116
+ if (this.attributes.name) {
117
+ params['name'] = this.name
118
+ } else {
119
+ throw new errors.MissingParameterError('Parameter missing: name')
120
+ }
121
+ }
122
+
123
+ const response = await Api.sendRequest(`/gpg_keys/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
124
+
125
+ return new GpgKey(response?.data, this.options)
126
+ }
127
+
128
+ delete = async (params = {}) => {
129
+ if (!this.attributes.id) {
130
+ throw new errors.EmptyPropertyError('Current object has no id')
131
+ }
132
+
133
+ if (!isObject(params)) {
134
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
135
+ }
136
+
137
+ params.id = this.attributes.id
138
+ if (params['id'] && !isInt(params['id'])) {
139
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
140
+ }
141
+
142
+ if (!params['id']) {
143
+ if (this.attributes.id) {
144
+ params['id'] = this.id
145
+ } else {
146
+ throw new errors.MissingParameterError('Parameter missing: id')
147
+ }
148
+ }
149
+
150
+ const response = await Api.sendRequest(`/gpg_keys/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
151
+
152
+ return response?.data
153
+ }
154
+
155
+ destroy = (params = {}) =>
156
+ this.delete(params)
157
+
158
+ save = () => {
159
+ if (this.attributes['id']) {
160
+ return this.update(this.attributes)
161
+ } else {
162
+ const newObject = GpgKey.create(this.attributes, this.options)
163
+ this.attributes = { ...newObject.attributes }
164
+ return true
165
+ }
166
+ }
167
+
168
+ // Parameters:
169
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
170
+ // cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
171
+ // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
172
+ static list = async (params = {}, options = {}) => {
173
+ if (params['user_id'] && !isInt(params['user_id'])) {
174
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
175
+ }
176
+
177
+ if (params['cursor'] && !isString(params['cursor'])) {
178
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
179
+ }
180
+
181
+ if (params['per_page'] && !isInt(params['per_page'])) {
182
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
183
+ }
184
+
185
+ const response = await Api.sendRequest(`/gpg_keys`, 'GET', params, options)
186
+
187
+ return response?.data?.map(obj => new GpgKey(obj, options)) || []
188
+ }
189
+
190
+ static all = (params = {}, options = {}) =>
191
+ GpgKey.list(params, options)
192
+
193
+ // Parameters:
194
+ // id (required) - int64 - Gpg Key ID.
195
+ static find = async (id, params = {}, options = {}) => {
196
+ if (!isObject(params)) {
197
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
198
+ }
199
+
200
+ params['id'] = id
201
+
202
+ if (!params['id']) {
203
+ throw new errors.MissingParameterError('Parameter missing: id')
204
+ }
205
+
206
+ if (params['id'] && !isInt(params['id'])) {
207
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
208
+ }
209
+
210
+ const response = await Api.sendRequest(`/gpg_keys/${encodeURIComponent(params['id'])}`, 'GET', params, options)
211
+
212
+ return new GpgKey(response?.data, options)
213
+ }
214
+
215
+ static get = (id, params = {}, options = {}) =>
216
+ GpgKey.find(id, params, options)
217
+
218
+ // Parameters:
219
+ // user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
220
+ // name (required) - string - Your GPG key name.
221
+ // public_key - string - Your GPG public key
222
+ // private_key - string - Your GPG private key.
223
+ // private_key_password - string - Your GPG private key password. Only required for password protected keys.
224
+ static create = async (params = {}, options = {}) => {
225
+ if (!params['name']) {
226
+ throw new errors.MissingParameterError('Parameter missing: name')
227
+ }
228
+
229
+ if (params['user_id'] && !isInt(params['user_id'])) {
230
+ throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params['user_id'])}`)
231
+ }
232
+
233
+ if (params['name'] && !isString(params['name'])) {
234
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
235
+ }
236
+
237
+ if (params['public_key'] && !isString(params['public_key'])) {
238
+ throw new errors.InvalidParameterError(`Bad parameter: public_key must be of type String, received ${getType(params['public_key'])}`)
239
+ }
240
+
241
+ if (params['private_key'] && !isString(params['private_key'])) {
242
+ throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(params['private_key'])}`)
243
+ }
244
+
245
+ if (params['private_key_password'] && !isString(params['private_key_password'])) {
246
+ throw new errors.InvalidParameterError(`Bad parameter: private_key_password must be of type String, received ${getType(params['private_key_password'])}`)
247
+ }
248
+
249
+ const response = await Api.sendRequest(`/gpg_keys`, 'POST', params, options)
250
+
251
+ return new GpgKey(response?.data, options)
252
+ }
253
+ }
254
+
255
+ export default GpgKey
256
+
257
+ module.exports = GpgKey
258
+ module.exports.default = GpgKey