@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.
@@ -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
- // Fetch permissions for the session role using API key
85
- // (Bearer tokens are not accepted by /api/auth/whoami)
86
- const url = new URL(`/api/auth/permissions/${encodeURIComponent(config.sessionRole)}`, config.apiUrl);
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonfestl/husky-cli",
3
- "version": "1.29.0",
3
+ "version": "1.29.2",
4
4
  "description": "CLI for Huskyv0 Task Orchestration with Claude Agent SDK",
5
5
  "type": "module",
6
6
  "bin": {