@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 +6 -0
- package/dist/api/handlers/status.handler.js +28 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -68,26 +68,38 @@ exports.statusHandler = statusHandler;
|
|
|
68
68
|
* @returns
|
|
69
69
|
*/
|
|
70
70
|
const healthCheckCommercetoolsPermissions = (opts) => async () => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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: '
|
|
76
|
-
status: '
|
|
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
|
-
|
|
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;
|