@simonfestl/husky-cli 1.29.0 → 1.29.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/dist/commands/config.js +10 -4
- package/package.json +1 -1
package/dist/commands/config.js
CHANGED
|
@@ -81,12 +81,18 @@ export async function fetchAndCacheRole() {
|
|
|
81
81
|
const needsPermissionsFetch = !config.roleLastChecked || !config.permissions;
|
|
82
82
|
if (needsPermissionsFetch && config.apiUrl && config.apiKey) {
|
|
83
83
|
try {
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const res = await fetch(url.toString(), {
|
|
84
|
+
// First try the role-specific permissions endpoint
|
|
85
|
+
let url = new URL(`/api/auth/permissions/${encodeURIComponent(config.sessionRole)}`, config.apiUrl);
|
|
86
|
+
let res = await fetch(url.toString(), {
|
|
88
87
|
headers: { "x-api-key": config.apiKey },
|
|
89
88
|
});
|
|
89
|
+
// If role-specific endpoint fails, fall back to whoami
|
|
90
|
+
if (!res.ok) {
|
|
91
|
+
url = new URL("/api/auth/whoami", config.apiUrl);
|
|
92
|
+
res = await fetch(url.toString(), {
|
|
93
|
+
headers: { "x-api-key": config.apiKey },
|
|
94
|
+
});
|
|
95
|
+
}
|
|
90
96
|
if (res.ok) {
|
|
91
97
|
const data = await res.json();
|
|
92
98
|
// Update permissions cache (keep sessionRole as source of truth for role)
|