@agentconnect.md/setup 1.40.0 → 1.41.0-rc.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/index.js CHANGED
@@ -61168,6 +61168,16 @@ const MANAGED_APP_TAG_VALUE = {
61168
61168
  version: 1,
61169
61169
  resource: "browser"
61170
61170
  };
61171
+ /**
61172
+ * Logto Cloud seeds new tenants with demo connectors that sit on real social targets such as
61173
+ * `github` and `google`. Logto treats them as read-only fixtures: `GET` and `PATCH
61174
+ * /api/connectors/:id` both answer 404, the listing hides their config, and creating the real
61175
+ * connector fails with 422 `connector.multiple_target_with_same_platform` while one still holds
61176
+ * the target. So a demo connector is never a connector we can adopt — it is an obstacle to remove
61177
+ * before the managed one is created. `isDemo` is Logto's own flag; the id list is the fallback for
61178
+ * deployments whose Logto predates it.
61179
+ */
61180
+ const DEMO_CONNECTOR_IDS = ["logto-social-demo", "logto-sms"];
61171
61181
  function isManagedConnectorTarget(target) {
61172
61182
  return target === "github" || target === "google" || target === "slack";
61173
61183
  }
@@ -61230,6 +61240,7 @@ function parseConnector(value) {
61230
61240
  connectorId: row.connectorId,
61231
61241
  target,
61232
61242
  name: typeof name === "string" ? name : null,
61243
+ isDemo: row.isDemo === true || DEMO_CONNECTOR_IDS.includes(row.connectorId),
61233
61244
  config: asRecord(row.config)
61234
61245
  };
61235
61246
  }
@@ -61264,16 +61275,20 @@ function connectorMatches(connector, desired) {
61264
61275
  return connector.connectorId === desired.connectorId && connector.config.clientId === desired.config.clientId && (desired.connectorId !== "slack-universal" || connector.config.scope === desired.config.scope);
61265
61276
  }
61266
61277
  function selectConnector(connectors, target) {
61267
- const matches = connectors.filter((connector) => connector.target === target);
61278
+ const matches = connectors.filter((connector) => !connector.isDemo && connector.target === target);
61268
61279
  if (matches.length <= 1) return matches[0];
61269
61280
  throw new LogtoManagementError("SOCIAL_CONNECTOR_AMBIGUOUS", `Logto has more than one social connector for target ${target}`);
61270
61281
  }
61271
61282
  function selectConnectorByName(connectors, name) {
61272
61283
  const normalized = name.trim().toLocaleLowerCase("en-US");
61273
- const matches = connectors.filter((connector) => connector.name?.trim().toLocaleLowerCase("en-US") === normalized);
61284
+ const matches = connectors.filter((connector) => !connector.isDemo && connector.name?.trim().toLocaleLowerCase("en-US") === normalized);
61274
61285
  if (matches.length <= 1) return matches[0];
61275
61286
  throw new LogtoManagementError("SOCIAL_CONNECTOR_AMBIGUOUS", `Logto has more than one social connector named ${name}`);
61276
61287
  }
61288
+ /** Demo connectors holding a social target we need. They block creation and cannot be patched. */
61289
+ function selectDemoConnectors(connectors, target) {
61290
+ return connectors.filter((connector) => connector.isDemo && connector.target === target);
61291
+ }
61277
61292
  var LogtoAdminClaimClient = class {
61278
61293
  config;
61279
61294
  fetchImpl;
@@ -61368,6 +61383,11 @@ var LogtoAdminClaimClient = class {
61368
61383
  diff: applicationDiff
61369
61384
  },
61370
61385
  connectors: desired.socialProviders.map((target) => {
61386
+ const demos = selectDemoConnectors(connectors, target).map((demo) => ({
61387
+ field: `${target} demo connector`,
61388
+ current: demo.name ?? demo.connectorId,
61389
+ expected: "Removed"
61390
+ }));
61371
61391
  if (!isManagedConnectorTarget(target)) {
61372
61392
  const connector = selectConnector(connectors, target);
61373
61393
  return {
@@ -61375,7 +61395,7 @@ var LogtoAdminClaimClient = class {
61375
61395
  id: connector?.id ?? null,
61376
61396
  exists: connector !== void 0,
61377
61397
  matches: connector !== void 0,
61378
- diff: connector ? [] : [{
61398
+ diff: connector ? demos : [...demos, {
61379
61399
  field: `${target} connector`,
61380
61400
  current: "Missing",
61381
61401
  expected: "Configured"
@@ -61384,7 +61404,7 @@ var LogtoAdminClaimClient = class {
61384
61404
  }
61385
61405
  const expected = desiredConnector(target, desired);
61386
61406
  const connector = selectConnector(connectors, target);
61387
- const diff = [];
61407
+ const diff = [...demos];
61388
61408
  if (!connector) diff.push({
61389
61409
  field: `${target} connector`,
61390
61410
  current: "Missing",
@@ -61394,7 +61414,7 @@ var LogtoAdminClaimClient = class {
61394
61414
  addDiff(diff, `${target} connector type`, connector.connectorId, expected.connectorId);
61395
61415
  addDiff(diff, `${target} client ID`, connector.config.clientId ?? null, expected.config.clientId ?? null);
61396
61416
  if (target === "slack") addDiff(diff, "Slack OIDC scope", connector.config.scope ?? null, expected.config.scope ?? null);
61397
- if (!connectorMatches(connector, expected) && diff.length === 0) diff.push({
61417
+ if (!connectorMatches(connector, expected) && diff.length === demos.length) diff.push({
61398
61418
  field: `${target} OAuth client settings`,
61399
61419
  current: "*** (different)",
61400
61420
  expected: "***"
@@ -61539,7 +61559,7 @@ var LogtoAdminClaimClient = class {
61539
61559
  for (const target of desired.socialProviders) {
61540
61560
  if (!isManagedConnectorTarget(target)) {
61541
61561
  const connector = selectConnector(existing, target);
61542
- if (!connector) throw new LogtoManagementError("SOCIAL_CONNECTOR_UNSUPPORTED", `automatic creation is not supported for the missing Logto social connector ${target}`);
61562
+ if (!connector) throw new LogtoManagementError("SOCIAL_CONNECTOR_UNSUPPORTED", selectDemoConnectors(existing, target).length > 0 ? `a Logto demo connector occupies the ${target} social target; delete it in Logto, then create the real ${target} connector` : `automatic creation is not supported for the missing Logto social connector ${target}`);
61543
61563
  result.push({
61544
61564
  target,
61545
61565
  id: connector.id,
@@ -61549,6 +61569,7 @@ var LogtoAdminClaimClient = class {
61549
61569
  continue;
61550
61570
  }
61551
61571
  const expected = desiredConnector(target, desired);
61572
+ await this.deleteDemoConnectors(existing, target);
61552
61573
  const connector = selectConnector(existing, target);
61553
61574
  if (connector && connectorMatches(connector, expected) && !refreshSecrets) {
61554
61575
  result.push({
@@ -61600,6 +61621,16 @@ var LogtoAdminClaimClient = class {
61600
61621
  }
61601
61622
  return result;
61602
61623
  }
61624
+ /**
61625
+ * Drop the Logto Cloud demo connectors parked on a managed target. Logto rejects creating the
61626
+ * real connector while one holds the same target and platform, and rejects patching the demo one.
61627
+ */
61628
+ async deleteDemoConnectors(existing, target) {
61629
+ for (const demo of selectDemoConnectors(existing, target)) {
61630
+ await this.request(`/api/connectors/${encodeURIComponent(demo.id)}`, { method: "DELETE" });
61631
+ existing.splice(existing.indexOf(demo), 1);
61632
+ }
61633
+ }
61603
61634
  async listConnectors() {
61604
61635
  const rows = await this.getJson("/api/connectors");
61605
61636
  if (!Array.isArray(rows)) throw new LogtoManagementError("LOGTO_UNAVAILABLE", "Logto returned invalid connectors");