@m8t-stack/cli 0.2.73 → 0.2.74

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/cli.js CHANGED
@@ -81,6 +81,17 @@ var init_reasons = __esm({
81
81
  }
82
82
  });
83
83
 
84
+ // ../../packages/api-contract/dist/esm/delegated-identity.js
85
+ var SERVICE_APP_ROLE, END_USER_KEY_MAX_LENGTH, END_USER_KEY_PATTERN;
86
+ var init_delegated_identity = __esm({
87
+ "../../packages/api-contract/dist/esm/delegated-identity.js"() {
88
+ "use strict";
89
+ SERVICE_APP_ROLE = "Agents.Invoke";
90
+ END_USER_KEY_MAX_LENGTH = 200;
91
+ END_USER_KEY_PATTERN = new RegExp(`^[A-Za-z0-9._-]{1,${String(END_USER_KEY_MAX_LENGTH)}}$`);
92
+ }
93
+ });
94
+
84
95
  // ../../packages/api-contract/dist/esm/team.js
85
96
  var init_team = __esm({
86
97
  "../../packages/api-contract/dist/esm/team.js"() {
@@ -224,6 +235,7 @@ var init_esm = __esm({
224
235
  init_response();
225
236
  init_errors2();
226
237
  init_reasons();
238
+ init_delegated_identity();
227
239
  init_team();
228
240
  init_me();
229
241
  init_binding();
@@ -1370,7 +1382,7 @@ var init_enable_hosted_brain = __esm({
1370
1382
  import { Builtins, Cli } from "clipanion";
1371
1383
 
1372
1384
  // src/lib/package-version.ts
1373
- var CLI_VERSION = "0.2.73";
1385
+ var CLI_VERSION = "0.2.74";
1374
1386
 
1375
1387
  // src/lib/render-error.ts
1376
1388
  init_errors();
@@ -23333,6 +23345,7 @@ var PlatformEnableAutoUpdateCommand = class extends M8tCommand {
23333
23345
  import { Command as Command42, Option as Option39 } from "clipanion";
23334
23346
 
23335
23347
  // src/lib/app-reg.ts
23348
+ init_esm();
23336
23349
  init_errors();
23337
23350
  var APP_NAME = "m8t-webapp";
23338
23351
  var AZURE_CLI_FIRST_PARTY_APP_ID = "04b07795-8ddb-461a-bbee-02f9e1bf7b46";
@@ -23433,6 +23446,52 @@ async function ensureExposeAnApi(appId, appObjectId) {
23433
23446
  ]);
23434
23447
  }
23435
23448
  }
23449
+ async function ensureServiceAppRole(appId, appObjectId) {
23450
+ const existingRoles = await azJson([
23451
+ "ad",
23452
+ "app",
23453
+ "show",
23454
+ "--id",
23455
+ appId,
23456
+ "--query",
23457
+ "appRoles",
23458
+ "--output",
23459
+ "json"
23460
+ ]);
23461
+ if (!Array.isArray(existingRoles)) {
23462
+ throw new LocalCliError({
23463
+ code: "APP_REG_ROLES_UNREADABLE",
23464
+ message: `Could not read the existing app roles on app registration ${appId}.`,
23465
+ hint: "Re-run once you can read the app registration; writing the role now would risk replacing roles we cannot see."
23466
+ });
23467
+ }
23468
+ const already = existingRoles.find((r) => r.value === SERVICE_APP_ROLE);
23469
+ if (already && already.isEnabled !== false) return;
23470
+ const appRoles = already ? existingRoles.map((r) => r.value === SERVICE_APP_ROLE ? { ...r, isEnabled: true } : r) : [
23471
+ ...existingRoles,
23472
+ {
23473
+ id: globalThis.crypto.randomUUID(),
23474
+ displayName: "Invoke agents",
23475
+ description: "Allows a service principal to call the gateway agent API.",
23476
+ value: SERVICE_APP_ROLE,
23477
+ allowedMemberTypes: ["Application"],
23478
+ isEnabled: true
23479
+ }
23480
+ ];
23481
+ await runAz([
23482
+ "rest",
23483
+ "--method",
23484
+ "PATCH",
23485
+ // The OBJECT id, not the app id: Graph's /applications/{id} addresses the
23486
+ // object id, and an appId here is a 404.
23487
+ "--url",
23488
+ `https://graph.microsoft.com/v1.0/applications/${appObjectId}`,
23489
+ "--headers",
23490
+ "Content-Type=application/json",
23491
+ "--body",
23492
+ JSON.stringify({ appRoles })
23493
+ ]);
23494
+ }
23436
23495
  async function ensureAppReg(opts) {
23437
23496
  if (opts.clientId) {
23438
23497
  return { tenantId: opts.tenantId, clientId: opts.clientId, appObjectId: null };
@@ -23452,6 +23511,7 @@ async function ensureAppReg(opts) {
23452
23511
  });
23453
23512
  }
23454
23513
  await ensureExposeAnApi(app.appId, objId);
23514
+ await ensureServiceAppRole(app.appId, objId);
23455
23515
  return { tenantId: opts.tenantId, clientId: app.appId, appObjectId: objId };
23456
23516
  }
23457
23517
  const me = await azJson(
@@ -23563,6 +23623,7 @@ async function ensureAppReg(opts) {
23563
23623
  })
23564
23624
  ]);
23565
23625
  await ensureExposeAnApi(created.appId, created.id);
23626
+ await ensureServiceAppRole(created.appId, created.id);
23566
23627
  return { tenantId: opts.tenantId, clientId: created.appId, appObjectId: created.id };
23567
23628
  }
23568
23629
  async function ensureGatewayRedirectUri(gatewayClientId, fqdn) {