@fayz-ai/plugin-automations 0.15.3 → 0.15.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
@@ -3089,9 +3089,41 @@ CREATE OR REPLACE VIEW public.v_automations_flow_steps WITH (security_invoker='t
3089
3089
  GRANT SELECT ON public.v_automations_flow_steps TO authenticated;
3090
3090
  GRANT SELECT ON public.v_automations_flow_steps TO service_role;
3091
3091
  `;
3092
+ var MIGRATION_002_THE_ENGINE_IS_SERVER_ONLY = `-- 002_the_engine_is_server_only.sql
3093
+ --
3094
+ -- 001 meant the cadence engine to be service_role only, and wrote
3095
+ -- \`REVOKE ALL ... FROM PUBLIC\`. That does not undo the pool's default
3096
+ -- privileges, which grant EXECUTE to \`authenticated\` on every new function in
3097
+ -- public \u2014 so on the live pool any logged-in user of any tenant could enrol a
3098
+ -- person into another tenant's flow, exit them, or advance every tenant's
3099
+ -- cadences at once, all SECURITY DEFINER with no caller check.
3100
+ --
3101
+ -- Callers are all server-side: \`event_runner_tick\` (pg_cron, as postgres)
3102
+ -- calls \`automations_flows_run_due\`, the event log calls the two handlers, and
3103
+ -- the handlers call enrol/exit. No screen, edge function or agent tool does.
3104
+ -- \`automations_flow_exit\` was granted to \`authenticated\` for a manual
3105
+ -- "take this person out" that was never built; it goes too, and comes back
3106
+ -- behind a tenant + permission check when a screen needs it.
3107
+
3108
+ REVOKE ALL ON FUNCTION public.automations_flow_enroll(uuid, uuid, uuid, text, uuid) FROM PUBLIC, anon, authenticated;
3109
+ GRANT EXECUTE ON FUNCTION public.automations_flow_enroll(uuid, uuid, uuid, text, uuid) TO service_role;
3110
+
3111
+ REVOKE ALL ON FUNCTION public.automations_flow_exit(uuid, uuid, text, uuid[]) FROM PUBLIC, anon, authenticated;
3112
+ GRANT EXECUTE ON FUNCTION public.automations_flow_exit(uuid, uuid, text, uuid[]) TO service_role;
3113
+
3114
+ REVOKE ALL ON FUNCTION public.automations_flows_run_due(integer) FROM PUBLIC, anon, authenticated;
3115
+ GRANT EXECUTE ON FUNCTION public.automations_flows_run_due(integer) TO service_role;
3116
+
3117
+ REVOKE ALL ON FUNCTION public.plg_automations_on_entry_event(jsonb) FROM PUBLIC, anon, authenticated;
3118
+ GRANT EXECUTE ON FUNCTION public.plg_automations_on_entry_event(jsonb) TO service_role;
3119
+
3120
+ REVOKE ALL ON FUNCTION public.plg_automations_on_exit_event(jsonb) FROM PUBLIC, anon, authenticated;
3121
+ GRANT EXECUTE ON FUNCTION public.plg_automations_on_exit_event(jsonb) TO service_role;
3122
+ `;
3092
3123
  var MIGRATIONS = [
3093
3124
  { id: "000_baseline", sql: MIGRATION_000_BASELINE },
3094
- { id: "001_the_flow_has_steps", sql: MIGRATION_001_THE_FLOW_HAS_STEPS }
3125
+ { id: "001_the_flow_has_steps", sql: MIGRATION_001_THE_FLOW_HAS_STEPS },
3126
+ { id: "002_the_engine_is_server_only", sql: MIGRATION_002_THE_ENGINE_IS_SERVER_ONLY }
3095
3127
  ];
3096
3128
 
3097
3129
  // src/index.ts