@tinycloud/cli 0.7.7-beta.3 → 0.7.7-beta.4

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/index.js CHANGED
@@ -43176,7 +43176,6 @@ async function parseCapSpec(spec, profile) {
43176
43176
  const actionsCsv = spec.slice(lastColon + 1);
43177
43177
  const spaceAndPath = spec.slice(firstColon + 1, lastColon);
43178
43178
  const { space, path } = splitSpaceAndPath(spaceAndPath);
43179
- const resolvedSpace = await resolveSpaceUri(space, profile) ?? space;
43180
43179
  const actions = expandActionShortNames(
43181
43180
  service,
43182
43181
  actionsCsv.split(",").map((action) => action.trim()).filter(Boolean)
@@ -43184,7 +43183,9 @@ async function parseCapSpec(spec, profile) {
43184
43183
  if (actions.length === 0) {
43185
43184
  throw new CLIError("INVALID_CAP", `Capability "${spec}" has no actions.`, ExitCode.USAGE_ERROR);
43186
43185
  }
43187
- return { service, space: resolvedSpace, path, actions };
43186
+ return (await resolvePermissionSpaces([
43187
+ { service, space, path, actions }
43188
+ ], profile))[0];
43188
43189
  }
43189
43190
  async function loadPermissionRequest(source, profile) {
43190
43191
  const raw = JSON.parse(await readFile2(source, "utf8"));
@@ -43292,13 +43293,24 @@ function compactPermission(permission) {
43292
43293
  return `${service}:${space}:${permission.path}:${actions}`;
43293
43294
  }
43294
43295
  async function resolvePermissionSpaces(entries, profile) {
43296
+ const profileConfig = await ProfileManager.getProfile(profile);
43297
+ const allowLogicalSpaces = resolveProfilePosture(profileConfig) === "delegate-session";
43295
43298
  const resolved = [];
43296
43299
  for (const entry of entries) {
43297
43300
  const service = normalizeService(entry.service);
43301
+ let space;
43302
+ try {
43303
+ space = await resolveSpaceUri(entry.space, profile) ?? entry.space;
43304
+ } catch (error) {
43305
+ if (!allowLogicalSpaces || entry.space.startsWith("tinycloud:") || !(error instanceof CLIError) || error.code !== "ADDRESS_UNKNOWN") {
43306
+ throw error;
43307
+ }
43308
+ space = entry.space;
43309
+ }
43298
43310
  resolved.push({
43299
43311
  ...entry,
43300
43312
  service,
43301
- space: await resolveSpaceUri(entry.space, profile) ?? entry.space,
43313
+ space,
43302
43314
  actions: expandActionShortNames(service, entry.actions)
43303
43315
  });
43304
43316
  }
@@ -43836,17 +43848,19 @@ function registerAuthCommand(program2) {
43836
43848
  ExitCode.USAGE_ERROR
43837
43849
  );
43838
43850
  }
43851
+ const requested = await resolvePermissionSpaces(parsed.requested, ctx.profile);
43852
+ const resolvedRequest = { ...parsed, requested };
43839
43853
  const node = await ensureAuthenticated(ctx);
43840
43854
  await ensureDelegationAuthority({
43841
43855
  ctx,
43842
43856
  profile,
43843
43857
  node,
43844
- requested: parsed.requested,
43858
+ requested,
43845
43859
  expiryOption: parsed.requestedExpiry,
43846
43860
  reason: "Grant permissions requested by a TinyCloud auth request artifact.",
43847
43861
  yes: options.yes === true
43848
43862
  });
43849
- const grant = await grantAuthRequest(node, parsed);
43863
+ const grant = await grantAuthRequest(node, resolvedRequest);
43850
43864
  outputJson(grant);
43851
43865
  } catch (error) {
43852
43866
  handleError(error);