From 59c00b81ce740b76b70e4bf51176a6922f74b6c8 Mon Sep 17 00:00:00 2001 From: Heitor Ramon Ribeiro <1626923+bloodf@users.noreply.github.com> Date: Thu, 26 Nov 2026 05:42:20 +0000 Subject: [PATCH 1/5] fix(integrations): move emergency_stop into the control:emergency scope emergency_stop now needs a separate owner grant. control:extended no longer covers it, so existing grants lose it. Migration 0128 adds the scope and tightens the action guard, the server and the printer list require it, and the Connector refuses an emergency stop under any other scope. Closes #937 --- apps/farm/app/pages/integracoes.vue | 12 + apps/farm/app/utils/integration-scopes.ts | 1 + .../server/services/integration-actions.ts | 5 +- .../server/services/integration-delivery.ts | 1 + .../server/utils/integration-auth-http.ts | 29 +- apps/farm/server/utils/integration-auth.ts | 2 + .../farm/server/utils/integration-printers.ts | 23 +- docs/COMMAND-SECURITY.md | 9 + docs/INTEGRATION-API.md | 25 +- docs/api/openapi-v1.yaml | 9 +- .../0128_integration_emergency_scope.down.sql | 58 +++ .../0128_integration_emergency_scope.up.sql | 45 +++ packages/connector/src/runtime/api-command.ts | 31 +- packages/farm-protocol/src/api-envelope.ts | 10 +- ...stgres-integration-approval-integration.ts | 8 +- tests/node/api-envelope.test.ts | 2 +- tests/node/connector-idle-gate-parity.test.ts | 7 +- tests/node/fix-934.test.ts | 4 +- tests/node/fix-937-connector.test.ts | 163 ++++++++ tests/node/integration-actions.test.ts | 15 +- tests/node/integration-apps-store.test.ts | 2 +- tests/unit/fix-937.test.ts | 351 ++++++++++++++++++ .../integration-scopes-cofre3d-batch2.test.ts | 12 +- tests/unit/integration-scopes-cofre3d.test.ts | 1 + tests/unit/openapi-spec.test.ts | 1 + 25 files changed, 788 insertions(+), 38 deletions(-) create mode 100644 infra/db/migrations/0128_integration_emergency_scope.down.sql create mode 100644 infra/db/migrations/0128_integration_emergency_scope.up.sql create mode 100644 tests/node/fix-937-connector.test.ts create mode 100644 tests/unit/fix-937.test.ts diff --git a/apps/farm/app/pages/integracoes.vue b/apps/farm/app/pages/integracoes.vue index 177016373..4d4598ab3 100644 --- a/apps/farm/app/pages/integracoes.vue +++ b/apps/farm/app/pages/integracoes.vue @@ -81,6 +81,7 @@ const scopeLabels: Record = { 'inventory:write': 'Registrar e retirar carretéis', 'environment:control': 'Controlar ambiente', 'alerts:manage': 'Gerenciar regras de alerta e testar notificações', + 'control:emergency': 'Parada de emergência', } const scopeOptions = INTEGRATION_SCOPES.map( (scope) => [scope, scopeLabels[scope]] as const, @@ -527,10 +528,21 @@ function grantDraft(appId: string) { v-model="grantDraft(app.id).scopes" type="checkbox" :value="scope" + :aria-describedby=" + scope === 'control:emergency' + ? `emergency-consent-${app.id}` + : undefined + " /> {{ label }} ({{ scope }}) +

+ Ao conceder “Parada de emergência”, o aplicativo poderá parar a + impressora imediatamente. A API não consegue recuperar a + impressora: depois da parada, será preciso agir na própria + impressora ou no OpenFarm pelo navegador (reiniciar o firmware). +