contentful-management 11.4.0 → 11.5.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.
@@ -3531,12 +3531,15 @@ __webpack_require__.r(__webpack_exports__);
3531
3531
  /* harmony export */ create: () => (/* binding */ create),
3532
3532
  /* harmony export */ createWithId: () => (/* binding */ createWithId),
3533
3533
  /* harmony export */ del: () => (/* binding */ del),
3534
+ /* harmony export */ deleteSigningSecret: () => (/* binding */ deleteSigningSecret),
3534
3535
  /* harmony export */ get: () => (/* binding */ get),
3535
3536
  /* harmony export */ getCallDetails: () => (/* binding */ getCallDetails),
3536
3537
  /* harmony export */ getHealthStatus: () => (/* binding */ getHealthStatus),
3537
3538
  /* harmony export */ getMany: () => (/* binding */ getMany),
3538
3539
  /* harmony export */ getManyCallDetails: () => (/* binding */ getManyCallDetails),
3539
- /* harmony export */ update: () => (/* binding */ update)
3540
+ /* harmony export */ getSigningSecret: () => (/* binding */ getSigningSecret),
3541
+ /* harmony export */ update: () => (/* binding */ update),
3542
+ /* harmony export */ upsertSigningSecret: () => (/* binding */ upsertSigningSecret)
3540
3543
  /* harmony export */ });
3541
3544
  /* harmony import */ var fast_copy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fast-copy */ "../node_modules/fast-copy/dist/esm/index.mjs");
3542
3545
  /* harmony import */ var _raw__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./raw */ "./adapters/REST/endpoints/raw.ts");
@@ -3571,6 +3574,12 @@ var getWebhookCallDetailsUrl = function getWebhookCallDetailsUrl(params) {
3571
3574
  var getWebhookHealthUrl = function getWebhookHealthUrl(params) {
3572
3575
  return "".concat(getWebhookCallBaseUrl(params), "/").concat(params.webhookDefinitionId, "/health");
3573
3576
  };
3577
+ var getWebhookSettingsUrl = function getWebhookSettingsUrl(params) {
3578
+ return "/spaces/".concat(params.spaceId, "/webhook_settings");
3579
+ };
3580
+ var getWebhookSigningSecretUrl = function getWebhookSigningSecretUrl(params) {
3581
+ return "".concat(getWebhookSettingsUrl(params), "/signing_secret");
3582
+ };
3574
3583
  var get = function get(http, params) {
3575
3584
  return _raw__WEBPACK_IMPORTED_MODULE_1__.get(http, getWebhookUrl(params));
3576
3585
  };
@@ -3590,6 +3599,9 @@ var getMany = function getMany(http, params) {
3590
3599
  params: (0,_utils__WEBPACK_IMPORTED_MODULE_2__.normalizeSelect)(params.query)
3591
3600
  });
3592
3601
  };
3602
+ var getSigningSecret = function getSigningSecret(http, params) {
3603
+ return _raw__WEBPACK_IMPORTED_MODULE_1__.get(http, getWebhookSigningSecretUrl(params));
3604
+ };
3593
3605
  var create = function create(http, params, rawData, headers) {
3594
3606
  var data = (0,fast_copy__WEBPACK_IMPORTED_MODULE_0__["default"])(rawData);
3595
3607
  return _raw__WEBPACK_IMPORTED_MODULE_1__.post(http, getBaseUrl(params), data, {
@@ -3626,9 +3638,43 @@ var update = /*#__PURE__*/function () {
3626
3638
  return _ref.apply(this, arguments);
3627
3639
  };
3628
3640
  }();
3641
+ var upsertSigningSecret = /*#__PURE__*/function () {
3642
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(http, params, rawData) {
3643
+ var data;
3644
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3645
+ while (1) switch (_context2.prev = _context2.next) {
3646
+ case 0:
3647
+ data = (0,fast_copy__WEBPACK_IMPORTED_MODULE_0__["default"])(rawData);
3648
+ return _context2.abrupt("return", _raw__WEBPACK_IMPORTED_MODULE_1__.put(http, getWebhookSigningSecretUrl(params), data));
3649
+ case 2:
3650
+ case "end":
3651
+ return _context2.stop();
3652
+ }
3653
+ }, _callee2);
3654
+ }));
3655
+ return function upsertSigningSecret(_x5, _x6, _x7) {
3656
+ return _ref2.apply(this, arguments);
3657
+ };
3658
+ }();
3629
3659
  var del = function del(http, params) {
3630
3660
  return _raw__WEBPACK_IMPORTED_MODULE_1__.del(http, getWebhookUrl(params));
3631
3661
  };
3662
+ var deleteSigningSecret = /*#__PURE__*/function () {
3663
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(http, params) {
3664
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3665
+ while (1) switch (_context3.prev = _context3.next) {
3666
+ case 0:
3667
+ return _context3.abrupt("return", _raw__WEBPACK_IMPORTED_MODULE_1__.del(http, getWebhookSigningSecretUrl(params)));
3668
+ case 1:
3669
+ case "end":
3670
+ return _context3.stop();
3671
+ }
3672
+ }, _callee3);
3673
+ }));
3674
+ return function deleteSigningSecret(_x8, _x9) {
3675
+ return _ref3.apply(this, arguments);
3676
+ };
3677
+ }();
3632
3678
 
3633
3679
  /***/ }),
3634
3680
 
@@ -10198,6 +10244,32 @@ function createSpaceApi(makeRequest) {
10198
10244
  return wrapWebhookCollection(makeRequest, data);
10199
10245
  });
10200
10246
  },
10247
+ /**
10248
+ * Fetch a webhook signing secret
10249
+ * @returns Promise for the redacted webhook signing secret in this space
10250
+ * @example ```javascript
10251
+ * const contentful = require('contentful-management')
10252
+ *
10253
+ * const client = contentful.createClient({
10254
+ * accessToken: '<content_management_api_key>'
10255
+ * })
10256
+ *
10257
+ * client.getSpace('<space_id>')
10258
+ * .then((space) => space.getWebhookSigningSecret())
10259
+ * .then((response) => console.log(response.redactedValue))
10260
+ * .catch(console.error)
10261
+ * ```
10262
+ */
10263
+ getWebhookSigningSecret: function getSigningSecret() {
10264
+ var raw = this.toPlainObject();
10265
+ return makeRequest({
10266
+ entityType: 'Webhook',
10267
+ action: 'getSigningSecret',
10268
+ params: {
10269
+ spaceId: raw.sys.id
10270
+ }
10271
+ });
10272
+ },
10201
10273
  /**
10202
10274
  * Creates a Webhook
10203
10275
  * @param data - Object representation of the Webhook to be created
@@ -10270,6 +10342,63 @@ function createSpaceApi(makeRequest) {
10270
10342
  return wrapWebhook(makeRequest, data);
10271
10343
  });
10272
10344
  },
10345
+ /**
10346
+ * Create or update the webhook signing secret for this space
10347
+ * @param data 64 character string that will be used to sign the webhook calls
10348
+ * @returns Promise for the redacted webhook signing secret that was created or updated
10349
+ * @example ```javascript
10350
+ * const contentful = require('contentful-management')
10351
+ * const crypto = require('crypto')
10352
+ *
10353
+ * const client = contentful.createClient({
10354
+ * accessToken: '<content_management_api_key>'
10355
+ * })
10356
+ *
10357
+ * const signingSecret = client.getSpace('<space_id>')
10358
+ * .then((space) => space.upsertWebhookSigningSecret({
10359
+ * value: crypto.randomBytes(32).toString('hex')
10360
+ * }))
10361
+ * .then((response) => console.log(response.redactedValue))
10362
+ * .catch(console.error)
10363
+ * ```
10364
+ */
10365
+ upsertWebhookSigningSecret: function getSigningSecret(data) {
10366
+ var raw = this.toPlainObject();
10367
+ return makeRequest({
10368
+ entityType: 'Webhook',
10369
+ action: 'upsertSigningSecret',
10370
+ params: {
10371
+ spaceId: raw.sys.id
10372
+ },
10373
+ payload: data
10374
+ });
10375
+ },
10376
+ /**
10377
+ * Delete the webhook signing secret for this space
10378
+ * @returns Promise<void>
10379
+ * @example ```javascript
10380
+ * const contentful = require('contentful-management')
10381
+ *
10382
+ * const client = contentful.createClient({
10383
+ * accessToken: '<content_management_api_key>'
10384
+ * })
10385
+ *
10386
+ * client.getSpace('<space_id>')
10387
+ * .then((space) => space.deleteWebhookSigningSecret())
10388
+ * .then(() => console.log("success"))
10389
+ * .catch(console.error)
10390
+ * ```
10391
+ */
10392
+ deleteWebhookSigningSecret: function getSigningSecret() {
10393
+ var raw = this.toPlainObject();
10394
+ return makeRequest({
10395
+ entityType: 'Webhook',
10396
+ action: 'deleteSigningSecret',
10397
+ params: {
10398
+ spaceId: raw.sys.id
10399
+ }
10400
+ });
10401
+ },
10273
10402
  /**
10274
10403
  * Gets a Role
10275
10404
  * @param id - Role ID
@@ -16252,10 +16381,13 @@ var createPlainClient = function createPlainClient(makeRequest, defaults) {
16252
16381
  getMany: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'getMany'),
16253
16382
  getHealthStatus: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'getHealthStatus'),
16254
16383
  getCallDetails: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'getCallDetails'),
16384
+ getSigningSecret: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'getSigningSecret'),
16255
16385
  getManyCallDetails: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'getManyCallDetails'),
16256
16386
  create: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'create'),
16257
16387
  update: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'update'),
16258
- delete: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'delete')
16388
+ upsertSigningSecret: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'upsertSigningSecret'),
16389
+ delete: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'delete'),
16390
+ deleteSigningSecret: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Webhook', 'deleteSigningSecret')
16259
16391
  },
16260
16392
  snapshot: {
16261
16393
  getManyForEntry: (0,_wrappers_wrap__WEBPACK_IMPORTED_MODULE_1__.wrap)(wrapParams, 'Snapshot', 'getManyForEntry'),