@contentstack/marketplace-sdk 1.2.6 → 1.2.8

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.
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env sh
2
+ # Pre-commit hook to run Snyk and Talisman scans, completing both before deciding to commit
3
+
4
+ # Function to check if a command exists
5
+ command_exists() {
6
+ command -v "$1" >/dev/null 2>&1
7
+ }
8
+
9
+ # Check if Snyk is installed
10
+ if ! command_exists snyk; then
11
+ echo "Error: Snyk is not installed. Please install it and try again."
12
+ exit 1
13
+ fi
14
+
15
+ # Check if Talisman is installed
16
+ if ! command_exists talisman; then
17
+ echo "Error: Talisman is not installed. Please install it and try again."
18
+ exit 1
19
+ fi
20
+
21
+ # Allow bypassing the hook with an environment variable
22
+ if [ "$SKIP_HOOK" = "1" ]; then
23
+ echo "Skipping Snyk and Talisman scans (SKIP_HOOK=1)."
24
+ exit 0
25
+ fi
26
+
27
+ # Initialize variables to track scan results
28
+ snyk_failed=false
29
+ talisman_failed=false
30
+
31
+ # Run Snyk vulnerability scan
32
+ echo "Running Snyk vulnerability scan..."
33
+ snyk test --all-projects > snyk_output.log 2>&1
34
+ snyk_exit_code=$?
35
+
36
+ if [ $snyk_exit_code -eq 0 ]; then
37
+ echo "Snyk scan passed: No vulnerabilities found."
38
+ elif [ $snyk_exit_code -eq 1 ]; then
39
+ echo "Snyk found vulnerabilities. See snyk_output.log for details."
40
+ snyk_failed=true
41
+ else
42
+ echo "Snyk scan failed with error (exit code $snyk_exit_code). See snyk_output.log for details."
43
+ snyk_failed=true
44
+ fi
45
+
46
+ # Run Talisman secret scan (continues even if Snyk failed)
47
+ echo "Running Talisman secret scan..."
48
+ talisman --githook pre-commit > talisman_output.log 2>&1
49
+ talisman_exit_code=$?
50
+
51
+ if [ $talisman_exit_code -eq 0 ]; then
52
+ echo "Talisman scan passed: No secrets found."
53
+ else
54
+ echo "Talisman scan failed (exit code $talisman_exit_code). See talisman_output.log for details."
55
+ talisman_failed=true
56
+ fi
57
+
58
+ # Evaluate results after both scans
59
+ if [ "$snyk_failed" = true ] || [ "$talisman_failed" = true ]; then
60
+ echo "Commit aborted due to issues found in one or both scans."
61
+ [ "$snyk_failed" = true ] && echo "- Snyk issues: Check snyk_output.log"
62
+ [ "$talisman_failed" = true ] && echo "- Talisman issues: Check talisman_output.log"
63
+ exit 1
64
+ fi
65
+
66
+ # If both scans pass, allow the commit
67
+ echo "All scans passed. Proceeding with commit.cd ."
68
+ rm -f snyk_output.log talisman_output.log
69
+ exit 0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
1
  # Changelog
2
+ ## [v1.2.8](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.2.6) (2024-05-26)
3
+ - Fix: Added params support to getInstalledApps method for enhanced flexibility
4
+
5
+ ## [v1.2.7](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.2.6) (2024-05-15)
6
+ - Fixed base URL path logic in contentstackClient to handle when region and host not provided
7
+
2
8
  ## [v1.2.6](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.2.6) (2024-03-03)
3
9
  - Update sanity tests
4
10
 
@@ -6,6 +6,7 @@ import error from './core/contentstackError';
6
6
  import { Marketplace } from './marketplace/index.js';
7
7
  import { Region } from './contentstack.js';
8
8
  export default function contentstackClient(_ref) {
9
+ var _http$defaults;
9
10
  var http = _ref.http;
10
11
  /**
11
12
  * @description The login call is used to sign in to your Contentstack account and obtain the authtoken.
@@ -30,6 +31,10 @@ export default function contentstackClient(_ref) {
30
31
  var baseUrlPath = "/user-session";
31
32
  if (region && region !== Region.NA) {
32
33
  baseUrlPath = "https://".concat(region, "-api.contentstack.com:443/v3/user-session");
34
+ } else if (!region && http !== null && http !== void 0 && (_http$defaults = http.defaults) !== null && _http$defaults !== void 0 && _http$defaults.host) {
35
+ baseUrlPath = "https://".concat(http.defaults.host, ":443/v3/user-session");
36
+ } else {
37
+ baseUrlPath = "https://api.contentstack.io:443/v3/user-session";
33
38
  }
34
39
  function login(requestBody) {
35
40
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -439,37 +439,42 @@ export function Installation(http, data) {
439
439
  *
440
440
  */
441
441
  this.getInstalledApps = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
442
- var headers, response;
442
+ var param,
443
+ headers,
444
+ response,
445
+ _args7 = arguments;
443
446
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
444
447
  while (1) switch (_context7.prev = _context7.next) {
445
448
  case 0:
446
- _context7.prev = 0;
449
+ param = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
450
+ _context7.prev = 1;
447
451
  headers = {
448
- headers: _objectSpread({}, cloneDeep(params))
449
- } || {};
450
- _context7.next = 4;
452
+ headers: _objectSpread({}, cloneDeep(params)),
453
+ params: _objectSpread({}, cloneDeep(param))
454
+ };
455
+ _context7.next = 5;
451
456
  return http.get("".concat(_this.urlPath, "/view/apps"), headers);
452
- case 4:
457
+ case 5:
453
458
  response = _context7.sent;
454
459
  if (!response.data) {
455
- _context7.next = 9;
460
+ _context7.next = 10;
456
461
  break;
457
462
  }
458
463
  return _context7.abrupt("return", response.data);
459
- case 9:
460
- throw error(response);
461
464
  case 10:
462
- _context7.next = 15;
465
+ throw error(response);
466
+ case 11:
467
+ _context7.next = 16;
463
468
  break;
464
- case 12:
465
- _context7.prev = 12;
466
- _context7.t0 = _context7["catch"](0);
469
+ case 13:
470
+ _context7.prev = 13;
471
+ _context7.t0 = _context7["catch"](1);
467
472
  throw error(_context7.t0);
468
- case 15:
473
+ case 16:
469
474
  case "end":
470
475
  return _context7.stop();
471
476
  }
472
- }, _callee7, null, [[0, 12]]);
477
+ }, _callee7, null, [[1, 13]]);
473
478
  }));
474
479
 
475
480
  /**
@@ -15,6 +15,7 @@ var _contentstack = require("./contentstack.js");
15
15
  */
16
16
 
17
17
  function contentstackClient(_ref) {
18
+ var _http$defaults;
18
19
  var http = _ref.http;
19
20
  /**
20
21
  * @description The login call is used to sign in to your Contentstack account and obtain the authtoken.
@@ -39,6 +40,10 @@ function contentstackClient(_ref) {
39
40
  var baseUrlPath = "/user-session";
40
41
  if (region && region !== _contentstack.Region.NA) {
41
42
  baseUrlPath = "https://".concat(region, "-api.contentstack.com:443/v3/user-session");
43
+ } else if (!region && http !== null && http !== void 0 && (_http$defaults = http.defaults) !== null && _http$defaults !== void 0 && _http$defaults.host) {
44
+ baseUrlPath = "https://".concat(http.defaults.host, ":443/v3/user-session");
45
+ } else {
46
+ baseUrlPath = "https://api.contentstack.io:443/v3/user-session";
42
47
  }
43
48
  function login(requestBody) {
44
49
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -452,37 +452,42 @@ function Installation(http, data) {
452
452
  *
453
453
  */
454
454
  this.getInstalledApps = /*#__PURE__*/(0, _asyncToGenerator3["default"])(/*#__PURE__*/_regenerator2["default"].mark(function _callee7() {
455
- var headers, response;
455
+ var param,
456
+ headers,
457
+ response,
458
+ _args7 = arguments;
456
459
  return _regenerator2["default"].wrap(function _callee7$(_context7) {
457
460
  while (1) switch (_context7.prev = _context7.next) {
458
461
  case 0:
459
- _context7.prev = 0;
462
+ param = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
463
+ _context7.prev = 1;
460
464
  headers = {
461
- headers: _objectSpread({}, (0, _cloneDeep2["default"])(params))
462
- } || {};
463
- _context7.next = 4;
465
+ headers: _objectSpread({}, (0, _cloneDeep2["default"])(params)),
466
+ params: _objectSpread({}, (0, _cloneDeep2["default"])(param))
467
+ };
468
+ _context7.next = 5;
464
469
  return http.get("".concat(_this.urlPath, "/view/apps"), headers);
465
- case 4:
470
+ case 5:
466
471
  response = _context7.sent;
467
472
  if (!response.data) {
468
- _context7.next = 9;
473
+ _context7.next = 10;
469
474
  break;
470
475
  }
471
476
  return _context7.abrupt("return", response.data);
472
- case 9:
473
- throw (0, _contentstackError2["default"])(response);
474
477
  case 10:
475
- _context7.next = 15;
478
+ throw (0, _contentstackError2["default"])(response);
479
+ case 11:
480
+ _context7.next = 16;
476
481
  break;
477
- case 12:
478
- _context7.prev = 12;
479
- _context7.t0 = _context7["catch"](0);
482
+ case 13:
483
+ _context7.prev = 13;
484
+ _context7.t0 = _context7["catch"](1);
480
485
  throw (0, _contentstackError2["default"])(_context7.t0);
481
- case 15:
486
+ case 16:
482
487
  case "end":
483
488
  return _context7.stop();
484
489
  }
485
- }, _callee7, null, [[0, 12]]);
490
+ }, _callee7, null, [[1, 13]]);
486
491
  }));
487
492
 
488
493
  /**