@qodalis/cli-core 2.0.0-beta.13 → 2.0.0-beta.14
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/package.json +1 -1
- package/public-api.d.mts +551 -9
- package/public-api.d.ts +551 -9
- package/public-api.js +226 -3
- package/public-api.js.map +1 -1
- package/public-api.mjs +200 -4
- package/public-api.mjs.map +1 -1
package/public-api.mjs
CHANGED
|
@@ -665,7 +665,7 @@ var require_compare_build = __commonJS({
|
|
|
665
665
|
var require_sort = __commonJS({
|
|
666
666
|
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/sort.js"(exports$1, module) {
|
|
667
667
|
var compareBuild = require_compare_build();
|
|
668
|
-
var sort = (
|
|
668
|
+
var sort = (list2, loose) => list2.sort((a, b) => compareBuild(a, b, loose));
|
|
669
669
|
module.exports = sort;
|
|
670
670
|
}
|
|
671
671
|
});
|
|
@@ -674,7 +674,7 @@ var require_sort = __commonJS({
|
|
|
674
674
|
var require_rsort = __commonJS({
|
|
675
675
|
"../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/rsort.js"(exports$1, module) {
|
|
676
676
|
var compareBuild = require_compare_build();
|
|
677
|
-
var rsort = (
|
|
677
|
+
var rsort = (list2, loose) => list2.sort((a, b) => compareBuild(b, a, loose));
|
|
678
678
|
module.exports = rsort;
|
|
679
679
|
}
|
|
680
680
|
});
|
|
@@ -2065,10 +2065,17 @@ var ICliTranslationService_TOKEN = "cli-translation-service";
|
|
|
2065
2065
|
var ICliPermissionService_TOKEN = "cli-permission-service";
|
|
2066
2066
|
var ICliFilePickerProvider_TOKEN = "cli-file-picker-provider";
|
|
2067
2067
|
var ICliHttpClient_TOKEN = "cli-http-client";
|
|
2068
|
+
var ICliUserEventService_TOKEN = "cli-user-event-service";
|
|
2069
|
+
var ICliAuditService_TOKEN = "cli-audit-service";
|
|
2070
|
+
var ICliAuthorizationService_TOKEN = "cli-authorization-service";
|
|
2071
|
+
var ICliPermissionRegistry_TOKEN = "cli-permission-registry";
|
|
2072
|
+
var ICliSessionsService_TOKEN = "cli-sessions-service";
|
|
2073
|
+
var ICliKeyValueStore_TOKEN = "cli-key-value-store";
|
|
2068
2074
|
|
|
2069
2075
|
// src/lib/interfaces/services.ts
|
|
2070
2076
|
var ICliServerAuthTokenProvider_TOKEN = "cli-server-auth-token-provider";
|
|
2071
2077
|
var ICliServerAuthService_TOKEN = "cli-server-auth-service";
|
|
2078
|
+
var ICliServerManager_TOKEN = "cli-server-manager";
|
|
2072
2079
|
|
|
2073
2080
|
// src/lib/models/server.ts
|
|
2074
2081
|
function resolveHeaders(provider) {
|
|
@@ -2110,6 +2117,113 @@ var enums = {
|
|
|
2110
2117
|
CliLogLevel
|
|
2111
2118
|
};
|
|
2112
2119
|
|
|
2120
|
+
// src/lib/interfaces/command-guards.ts
|
|
2121
|
+
var ICliCommandGuard_TOKEN = "cli-command-guard";
|
|
2122
|
+
|
|
2123
|
+
// src/lib/utils/permissions.ts
|
|
2124
|
+
function cliPermissionMatches(granted, required) {
|
|
2125
|
+
const g = granted.trim().toLowerCase().split(":");
|
|
2126
|
+
const r = required.trim().toLowerCase().split(":");
|
|
2127
|
+
for (let i = 0; i < g.length; i++) {
|
|
2128
|
+
if (g[i] === "*" && i === g.length - 1) return true;
|
|
2129
|
+
if (i >= r.length || g[i] !== "*" && g[i] !== r[i]) return false;
|
|
2130
|
+
}
|
|
2131
|
+
return g.length === r.length;
|
|
2132
|
+
}
|
|
2133
|
+
function cliHasPermission(granted, required) {
|
|
2134
|
+
return !!granted?.some((p) => cliPermissionMatches(p, required));
|
|
2135
|
+
}
|
|
2136
|
+
function cliMissingPermissions(granted, required) {
|
|
2137
|
+
return required.filter((r) => !cliHasPermission(granted, r));
|
|
2138
|
+
}
|
|
2139
|
+
function cliMergePermissions(...lists) {
|
|
2140
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2141
|
+
const out = [];
|
|
2142
|
+
for (const list2 of lists) {
|
|
2143
|
+
for (const p of list2 ?? []) {
|
|
2144
|
+
const key = p.trim();
|
|
2145
|
+
if (key && !seen.has(key.toLowerCase())) {
|
|
2146
|
+
seen.add(key.toLowerCase());
|
|
2147
|
+
out.push(key);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
return out;
|
|
2152
|
+
}
|
|
2153
|
+
var CliServerPermissions = {
|
|
2154
|
+
/** Open a remote shell on a server (`ssh`) */
|
|
2155
|
+
ShellExecute: "shell:execute"
|
|
2156
|
+
};
|
|
2157
|
+
var CliUsersPermissions = {
|
|
2158
|
+
UsersRead: "users:read",
|
|
2159
|
+
UsersCreate: "users:create",
|
|
2160
|
+
UsersUpdate: "users:update",
|
|
2161
|
+
UsersDelete: "users:delete",
|
|
2162
|
+
GroupsRead: "groups:read",
|
|
2163
|
+
GroupsCreate: "groups:create",
|
|
2164
|
+
GroupsUpdate: "groups:update",
|
|
2165
|
+
GroupsDelete: "groups:delete",
|
|
2166
|
+
SessionsRead: "sessions:read",
|
|
2167
|
+
SessionsRevoke: "sessions:revoke",
|
|
2168
|
+
AuditRead: "audit:read",
|
|
2169
|
+
AuditClear: "audit:clear"
|
|
2170
|
+
};
|
|
2171
|
+
|
|
2172
|
+
// src/lib/interfaces/authorization.ts
|
|
2173
|
+
var CliAccessDeniedError = class _CliAccessDeniedError extends Error {
|
|
2174
|
+
constructor(message = "permission denied") {
|
|
2175
|
+
super(message);
|
|
2176
|
+
this.code = "EACCES";
|
|
2177
|
+
this.name = "CliAccessDeniedError";
|
|
2178
|
+
Object.setPrototypeOf(this, _CliAccessDeniedError.prototype);
|
|
2179
|
+
}
|
|
2180
|
+
};
|
|
2181
|
+
function isCliAccessDeniedError(error) {
|
|
2182
|
+
return error instanceof CliAccessDeniedError || !!error && typeof error === "object" && error.name === "CliAccessDeniedError";
|
|
2183
|
+
}
|
|
2184
|
+
function authorizationService(context) {
|
|
2185
|
+
try {
|
|
2186
|
+
return context.services.get(ICliAuthorizationService_TOKEN);
|
|
2187
|
+
} catch {
|
|
2188
|
+
return void 0;
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
function cliAuthorize(context, permission) {
|
|
2192
|
+
const auth = authorizationService(context);
|
|
2193
|
+
return auth ? auth.can(permission) : true;
|
|
2194
|
+
}
|
|
2195
|
+
function cliCanAccess(context, resource, action, bypassPermissions) {
|
|
2196
|
+
const auth = authorizationService(context);
|
|
2197
|
+
return auth ? auth.canAccess(resource, action, bypassPermissions) : true;
|
|
2198
|
+
}
|
|
2199
|
+
function cliEvaluateAccess(principal, resource, action, bypassPermissions = []) {
|
|
2200
|
+
const mode = resource.permissions;
|
|
2201
|
+
const owner = resource.ownership;
|
|
2202
|
+
if (!mode || mode.length < 9 || !owner) return true;
|
|
2203
|
+
if (principal && (cliHasPermission(principal.permissions, "*") || bypassPermissions.some((p) => cliHasPermission(principal.permissions, p)))) {
|
|
2204
|
+
return true;
|
|
2205
|
+
}
|
|
2206
|
+
let offset = 6;
|
|
2207
|
+
if (principal) {
|
|
2208
|
+
if (owner.uid === principal.name || owner.uid === principal.id) offset = 0;
|
|
2209
|
+
else if (principal.groups.some((g) => g.toLowerCase() === owner.gid.toLowerCase())) offset = 3;
|
|
2210
|
+
}
|
|
2211
|
+
const index = offset + (action === "read" ? 0 : action === "write" ? 1 : 2);
|
|
2212
|
+
return mode.charAt(index) !== "-";
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
// src/lib/interfaces/http-client.ts
|
|
2216
|
+
var CliHttpError = class _CliHttpError extends Error {
|
|
2217
|
+
constructor(message, status, statusText = "", body) {
|
|
2218
|
+
super(message);
|
|
2219
|
+
this.status = status;
|
|
2220
|
+
this.statusText = statusText;
|
|
2221
|
+
this.body = body;
|
|
2222
|
+
this.name = "CliHttpError";
|
|
2223
|
+
Object.setPrototypeOf(this, _CliHttpError.prototype);
|
|
2224
|
+
}
|
|
2225
|
+
};
|
|
2226
|
+
|
|
2113
2227
|
// src/lib/constants/index.ts
|
|
2114
2228
|
var DefaultLibraryAuthor = {
|
|
2115
2229
|
name: "Nicolae Lupei",
|
|
@@ -2337,7 +2451,7 @@ function satisfiesVersionRange(installed, range) {
|
|
|
2337
2451
|
}
|
|
2338
2452
|
|
|
2339
2453
|
// src/lib/version.ts
|
|
2340
|
-
var LIBRARY_VERSION = "2.0.0-beta.
|
|
2454
|
+
var LIBRARY_VERSION = "2.0.0-beta.14";
|
|
2341
2455
|
var API_VERSION = 2;
|
|
2342
2456
|
|
|
2343
2457
|
// src/lib/utils/server-version-negotiator.ts
|
|
@@ -2393,6 +2507,20 @@ function buildAuthenticatedWebSocketUrl(wsUrl, headers) {
|
|
|
2393
2507
|
).join("&");
|
|
2394
2508
|
return `${wsUrl}${separator}${params}`;
|
|
2395
2509
|
}
|
|
2510
|
+
async function resolveServerWebSocketUrl(services, serverName, wsUrl, configHeaders) {
|
|
2511
|
+
const authService = services?.get(ICliServerAuthService_TOKEN);
|
|
2512
|
+
const params = await authService?.getWebSocketParams?.(serverName);
|
|
2513
|
+
if (params) {
|
|
2514
|
+
return appendQueryParams(wsUrl, params);
|
|
2515
|
+
}
|
|
2516
|
+
return buildAuthenticatedWebSocketUrl(wsUrl, () => resolveServerHeaders(services, serverName, configHeaders));
|
|
2517
|
+
}
|
|
2518
|
+
function appendQueryParams(url, params) {
|
|
2519
|
+
const entries = Object.entries(params);
|
|
2520
|
+
if (!entries.length) return url;
|
|
2521
|
+
const query = entries.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join("&");
|
|
2522
|
+
return `${url}${url.includes("?") ? "&" : "?"}${query}`;
|
|
2523
|
+
}
|
|
2396
2524
|
|
|
2397
2525
|
// src/lib/utils/panel-theme-sync.ts
|
|
2398
2526
|
function hexToRgb(hex) {
|
|
@@ -2494,6 +2622,74 @@ function isWideCharacter(cp) {
|
|
|
2494
2622
|
return false;
|
|
2495
2623
|
}
|
|
2496
2624
|
|
|
2625
|
+
// src/lib/utils/access-guards.ts
|
|
2626
|
+
var list = (value) => Array.isArray(value) ? value.filter((v) => typeof v === "string" && v.trim()) : [];
|
|
2627
|
+
var authorization = (context) => {
|
|
2628
|
+
try {
|
|
2629
|
+
return context.services.get(ICliAuthorizationService_TOKEN);
|
|
2630
|
+
} catch {
|
|
2631
|
+
return void 0;
|
|
2632
|
+
}
|
|
2633
|
+
};
|
|
2634
|
+
function chain(processor) {
|
|
2635
|
+
const out = [];
|
|
2636
|
+
let current = processor;
|
|
2637
|
+
while (current && out.length < 32 && !out.includes(current)) {
|
|
2638
|
+
out.push(current);
|
|
2639
|
+
current = current.parent;
|
|
2640
|
+
}
|
|
2641
|
+
return out;
|
|
2642
|
+
}
|
|
2643
|
+
var requiredPermissionsOf = (p) => [...new Set(chain(p).flatMap((x) => list(x.metadata?.requiredPermissions)))];
|
|
2644
|
+
var requiredGroupLevels = (p) => chain(p).map((x) => list(x.metadata?.requiredGroups)).filter((g) => g.length > 0);
|
|
2645
|
+
var needsAuth = (p) => chain(p).some((x) => x.metadata?.requireAuth === true) || requiredGroupLevels(p).length > 0 || requiredPermissionsOf(p).length > 0;
|
|
2646
|
+
var cliRequireAuthGuard = {
|
|
2647
|
+
name: "access:require-auth",
|
|
2648
|
+
priority: -100,
|
|
2649
|
+
appliesTo: (processor, _command, context) => needsAuth(processor) && !!authorization(context),
|
|
2650
|
+
canActivate: (_command, processor, context) => authorization(context).getPrincipal() ? true : `${processor.command}: login required`
|
|
2651
|
+
};
|
|
2652
|
+
var cliRequiredGroupsGuard = {
|
|
2653
|
+
name: "access:required-groups",
|
|
2654
|
+
priority: -90,
|
|
2655
|
+
appliesTo: (processor, _command, context) => requiredGroupLevels(processor).length > 0 && !!authorization(context),
|
|
2656
|
+
canActivate: (_command, processor, context) => {
|
|
2657
|
+
const auth = authorization(context);
|
|
2658
|
+
const principal = auth.getPrincipal();
|
|
2659
|
+
if (!principal) return `${processor.command}: login required`;
|
|
2660
|
+
if (auth.can("*")) return true;
|
|
2661
|
+
for (const required of requiredGroupLevels(processor)) {
|
|
2662
|
+
const member = required.some((g) => principal.groups.some((pg) => pg.toLowerCase() === g.toLowerCase()));
|
|
2663
|
+
if (!member) return `${processor.command}: permission denied (requires group: ${required.join(" or ")})`;
|
|
2664
|
+
}
|
|
2665
|
+
return true;
|
|
2666
|
+
}
|
|
2667
|
+
};
|
|
2668
|
+
var cliRequiredPermissionsGuard = {
|
|
2669
|
+
name: "access:required-permissions",
|
|
2670
|
+
priority: -80,
|
|
2671
|
+
appliesTo: (processor, _command, context) => requiredPermissionsOf(processor).length > 0 && !!authorization(context),
|
|
2672
|
+
canActivate: (_command, processor, context) => {
|
|
2673
|
+
const principal = authorization(context).getPrincipal();
|
|
2674
|
+
if (!principal) return `${processor.command}: login required`;
|
|
2675
|
+
const missing = cliMissingPermissions(principal.permissions, requiredPermissionsOf(processor));
|
|
2676
|
+
return missing.length === 0 ? true : `${processor.command}: permission denied (requires ${missing.join(", ")})`;
|
|
2677
|
+
}
|
|
2678
|
+
};
|
|
2679
|
+
var cliAccessMetadataGuards = [
|
|
2680
|
+
cliRequireAuthGuard,
|
|
2681
|
+
cliRequiredGroupsGuard,
|
|
2682
|
+
cliRequiredPermissionsGuard
|
|
2683
|
+
];
|
|
2684
|
+
|
|
2685
|
+
// src/lib/utils/server-target.ts
|
|
2686
|
+
function cliDefaultServer(context) {
|
|
2687
|
+
const servers = context.options?.servers ?? [];
|
|
2688
|
+
const manager = context.services?.get(ICliServerManager_TOKEN);
|
|
2689
|
+
const preferred = manager?.preferredServer?.();
|
|
2690
|
+
return (preferred ? servers.find((s) => s.name === preferred) : void 0) ?? servers[0];
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2497
2693
|
// src/lib/utils/index.ts
|
|
2498
2694
|
var getParameterValue = (p, args) => {
|
|
2499
2695
|
if (args[p.name] !== void 0) {
|
|
@@ -3693,6 +3889,6 @@ var BrowserFileTransferService = class {
|
|
|
3693
3889
|
}
|
|
3694
3890
|
};
|
|
3695
3891
|
|
|
3696
|
-
export { API_VERSION, BrowserFileTransferService, CANCELLATION_ERROR_MESSAGE, CLI_CONFIGURE_STORE_NAME, CancellablePromise, CliBackgroundColor, CliForegroundColor, CliIcon, CliLogLevel, CliModuleRegistry, DEFAULT_DIR_PERMISSIONS, DEFAULT_FILE_PERMISSIONS, DefaultLibraryAuthor, DefaultThemeInfos, DefaultThemes, ICliAuthService_TOKEN, ICliCompletionProvider_TOKEN, ICliDragDropService_TOKEN, ICliFilePickerProvider_TOKEN, ICliFileTransferService_TOKEN, ICliGroupsStoreService_TOKEN, ICliHttpClient_TOKEN, ICliPermissionService_TOKEN, ICliServerAuthService_TOKEN, ICliServerAuthTokenProvider_TOKEN, ICliTranslationService_TOKEN, ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN, LIBRARY_VERSION, ObjectDescriber, ServerVersionNegotiator, bootCliModule, bootUmdModule, buildAuthenticatedWebSocketUrl, clearTerminalLine, colorFirstWord, colorizeJson, compareVersions, constants, createWorkerService, delay, derivePanelThemeStyles, enums, formatJson, getConfigValue, getParameterValue, getPluginConfigValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, resolveHeaders, resolveServerHeaders, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, stripAnsi, toQueryString, utils, visibleLength };
|
|
3892
|
+
export { API_VERSION, BrowserFileTransferService, CANCELLATION_ERROR_MESSAGE, CLI_CONFIGURE_STORE_NAME, CancellablePromise, CliAccessDeniedError, CliBackgroundColor, CliForegroundColor, CliHttpError, CliIcon, CliLogLevel, CliModuleRegistry, CliServerPermissions, CliUsersPermissions, DEFAULT_DIR_PERMISSIONS, DEFAULT_FILE_PERMISSIONS, DefaultLibraryAuthor, DefaultThemeInfos, DefaultThemes, ICliAuditService_TOKEN, ICliAuthService_TOKEN, ICliAuthorizationService_TOKEN, ICliCommandGuard_TOKEN, ICliCompletionProvider_TOKEN, ICliDragDropService_TOKEN, ICliFilePickerProvider_TOKEN, ICliFileTransferService_TOKEN, ICliGroupsStoreService_TOKEN, ICliHttpClient_TOKEN, ICliKeyValueStore_TOKEN, ICliPermissionRegistry_TOKEN, ICliPermissionService_TOKEN, ICliServerAuthService_TOKEN, ICliServerAuthTokenProvider_TOKEN, ICliServerManager_TOKEN, ICliSessionsService_TOKEN, ICliTranslationService_TOKEN, ICliUserEventService_TOKEN, ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN, LIBRARY_VERSION, ObjectDescriber, ServerVersionNegotiator, appendQueryParams, bootCliModule, bootUmdModule, buildAuthenticatedWebSocketUrl, clearTerminalLine, cliAccessMetadataGuards, cliAuthorize, cliCanAccess, cliDefaultServer, cliEvaluateAccess, cliHasPermission, cliMergePermissions, cliMissingPermissions, cliPermissionMatches, cliRequireAuthGuard, cliRequiredGroupsGuard, cliRequiredPermissionsGuard, colorFirstWord, colorizeJson, compareVersions, constants, createWorkerService, delay, derivePanelThemeStyles, enums, formatJson, getConfigValue, getParameterValue, getPluginConfigValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, isCliAccessDeniedError, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, resolveHeaders, resolveServerHeaders, resolveServerWebSocketUrl, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, stripAnsi, toQueryString, utils, visibleLength };
|
|
3697
3893
|
//# sourceMappingURL=public-api.mjs.map
|
|
3698
3894
|
//# sourceMappingURL=public-api.mjs.map
|