Files
Tom Moor d8667e4b19 fix: Record passkey, OAuth client and invite events in the audit log (#14485)
* fix: Record passkey, OAuth client and invite events in the audit log

- Add passkeys.*, oauthClients.*, documents.unpublish,
  webhookSubscriptions.update and users.invite_accepted to AUDIT_EVENTS.
- users.invite_accepted was never emitted: the invited check ran after
  sign-in had set lastActiveAt, and email sign-in did not emit it at all.
  It also had no actor or team. Invited users signing in with SSO receive
  their welcome email again, and webhooks for this event start firing.
- passkeys.create had no actor or team as auth routes have no API context.
- Record the name on update and delete events where it is otherwise lost,
  the title on documents.unpublish, and mark OAuth client secret rotations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: Attribute invite_accepted to the invitee, not the browser session

Auth routes parse an optional cookie session, and createFromContext prefers
that user over the provided defaults, so accepting an invite in a browser
with another session recorded the wrong actor and team.
2026-11-06 08:05:18 -05:00

88 lines
2.1 KiB
TypeScript

export class EventHelper {
public static ACTIVITY_EVENTS = [
"collections.create",
"collections.delete",
"collections.move",
"collections.permission_changed",
"collections.add_user",
"collections.remove_user",
"documents.publish",
"documents.unpublish",
"documents.archive",
"documents.unarchive",
"documents.move",
"documents.delete",
"documents.permanent_delete",
"documents.restore",
"documents.add_user",
"documents.remove_user",
"revisions.create",
"users.create",
"users.demote",
"userMemberships.update",
] as const;
public static AUDIT_EVENTS = [
"api_keys.create",
"api_keys.delete",
"authenticationProviders.update",
"collections.create",
"collections.update",
"collections.permission_changed",
"collections.move",
"collections.add_user",
"collections.remove_user",
"collections.add_group",
"collections.remove_group",
"collections.delete",
"documents.create",
"documents.publish",
"documents.unpublish",
"documents.update",
"documents.archive",
"documents.unarchive",
"documents.move",
"documents.delete",
"documents.permanent_delete",
"documents.restore",
"documents.add_user",
"documents.remove_user",
"documents.add_group",
"documents.remove_group",
"groups.create",
"groups.update",
"groups.delete",
"oauthClients.create",
"oauthClients.update",
"oauthClients.delete",
"passkeys.create",
"passkeys.update",
"passkeys.delete",
"pins.create",
"pins.update",
"pins.delete",
"revisions.create",
"revisions.delete",
"shares.create",
"shares.update",
"shares.revoke",
"teams.update",
"users.create",
"users.update",
"users.signin",
"users.signout",
"users.promote",
"users.demote",
"users.invite",
"users.invite_accepted",
"users.suspend",
"users.activate",
"users.delete",
"fileOperations.create",
"fileOperations.delete",
"webhookSubscriptions.create",
"webhookSubscriptions.update",
"webhookSubscriptions.delete",
] as const;
}