@commercetools/connect-payments-sdk 0.8.1 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @commercetools/connect-payments-sdk
2
2
 
3
+ ## 0.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - c10522b: - Do not crash the commercetools permissions health check if the config is incorrect. Instead return a proper health check status.
8
+
3
9
  ## 0.8.1
4
10
 
5
11
  ### Patch Changes
@@ -68,26 +68,38 @@ exports.statusHandler = statusHandler;
68
68
  * @returns
69
69
  */
70
70
  const healthCheckCommercetoolsPermissions = (opts) => async () => {
71
- const token = await opts.ctAuthorizationService.getAccessToken();
72
- const foundAll = opts.requiredPermissions.every((currentScope) => token.scope.split(' ').some((scopeInToken) => scopeInToken === `${currentScope}:${opts.projectKey}`));
73
- if (foundAll) {
71
+ try {
72
+ const token = await opts.ctAuthorizationService.getAccessToken();
73
+ const foundAll = opts.requiredPermissions.every((currentScope) => token.scope.split(' ').some((scopeInToken) => scopeInToken === `${currentScope}:${opts.projectKey}`));
74
+ if (foundAll) {
75
+ return {
76
+ name: 'commercetools permissions',
77
+ status: 'UP',
78
+ details: {
79
+ scope: token.scope,
80
+ },
81
+ };
82
+ }
74
83
  return {
75
- name: 'CoCo Permissions',
76
- status: 'UP',
84
+ name: 'commercetools permissions',
85
+ status: 'DOWN',
86
+ message: `commercetools permissions are not correct, expected scopes: ${opts.requiredPermissions.join(' ')}, actual scopes: ${token.scope}`,
77
87
  details: {
78
- scope: token.scope,
88
+ expectedScopes: opts.requiredPermissions,
89
+ actualScopes: token.scope,
90
+ reason: 'scopes not available',
91
+ },
92
+ };
93
+ }
94
+ catch (error) {
95
+ return {
96
+ name: 'commercetools permissions',
97
+ status: 'DOWN',
98
+ message: `Not able to talk with commercetools API`,
99
+ details: {
100
+ error,
79
101
  },
80
102
  };
81
103
  }
82
- return {
83
- name: 'CoCo Permissions',
84
- status: 'DOWN',
85
- message: `CoCo permissions are not correct, expected scopes: ${opts.requiredPermissions.join(' ')}, actual scopes: ${token.scope}`,
86
- details: {
87
- expectedScopes: opts.requiredPermissions,
88
- actualScopes: token.scope,
89
- reason: 'scopes not available',
90
- },
91
- };
92
104
  };
93
105
  exports.healthCheckCommercetoolsPermissions = healthCheckCommercetoolsPermissions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/connect-payments-sdk",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "Payment SDK for commercetools payment connectors",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",