feat(api): answer a person's export and deletion requests, and report person links

Merged
EV
3d ago
+1702-20

Builds on #623 (its commit is the first one here until #623 merges).

What

All of this runs only with the Ever Platform connection loaded (TR_EVER_CONNECT_ENABLED=true, still off by default) and an operator connected. No new switch: person links also need an organization's ever_id_login consent in app.ever.co, and TR_EVER_CONNECT_INTEGRATIONS_DENY=ever_id_login stops them.

A person is matched by the hash of their Ever ID (sha256(issuer#subject), SDK subjectHash) against user_identity only. E-mail is never used, and no account is created or changed for a request or a link.

Export request (ever.registry.person.export_requested)

  • One export per matched account: profile (name, e-mail, created, last sign-in), the matched Ever ID, projects with the user's role, number of translation changes. Nothing about other people.
  • Stored AES-256-GCM encrypted (key derived from TR_SECRET, bound to the request and the account) in ever_connect_person_export. Deleted after 7 days.
  • Download for the signed-in account only: GET /api/v1/ever-connect/me/exports and GET /api/v1/ever-connect/me/exports/:jobId. Anyone else gets 404, including an API client of the same project and the operator.
  • The answer is exported or no_account. The export itself never goes to Ever Platform.

Deletion request (ever.registry.person.deletion_requested)

  • The matched Ever IDs are removed from their accounts and the Ever ID sessions of those accounts end, in one transaction with the decided answer.
  • The account, its projects, its password and its other sign-in methods stay.
  • The answer is anonymised (identity_unlinked) or no_account. The person link is then removed.

Receipts (ever_connect_person_request, request id and answer only, kept 90 days)

  • Each answer is decided once and kept, so a request read again gets the same answer.
  • An answer the platform already holds (409), a request it never sent here (404), or one it refuses as it stands is not sent again.
  • A network failure, 401, 429 or 5xx leaves the feed page unacknowledged, so it is read again.

Person links (ever_connect_person_link)

  • What is reported: the Ever IDs users linked themselves (explicit) or confirmed when their account was made (jit → confirmed), and only those that name an Ever person id. Identities of other OpenID Connect issuers and provisioned links are never reported.
  • When: while ever_id_login is enabled by a consent and not denied here. Every 5 minutes, or at once after a consent or person event. At most 100 calls per pass.
  • Body: ids only (user id, issuer, subject, link method, the installation's tenant *, its tenant link and name).
  • A removed identity removes its link. Disconnecting or a revocation forgets every link.

Audit rows: person.export, person.deletion, person_link.sync, with counts only (no e-mail, no id of a person).

Docs: connection.md (new section "A person's Ever ID"), outbound-calls.md (person link and answer rows, inbound me/exports), changelog.

Tests

  • ever-connect-person.service.spec.ts (real migrations on in-memory SQLite) covers:
    • deletion: removal, sessions, account kept, answer
    • no_account
    • re-read gives the same answer, sent only once
    • 409 not resent
    • bad request id ignored
    • export: encrypted, owner only, 7 days, swept
    • person links: gated by connection and consent, only Ever IDs, link-method mapping, no e-mail sent, once only, removal and retry, deny switch, batch limit, cleared on disconnect
    • feed answer and ack, and no ack on 503
  • ever-connect-person.e2e-spec.ts: connect, consent event, link report, export request and download (owner 200; another user, an API client, the operator 404; signed-out 401), deletion request (identity gone, session revoked, password sign-in still works, link removed), audit without e-mail.
  • Review fixes (2ba185c): the receipt is locked and re-read in the transaction that decides the answer; a person link stores the tenant link it named and is re-reported when that changes; a failed link call waits an hour (retry_at) so others go first. Tests cover the last two.
  • ever-connect-off.e2e-spec.ts: me/exports does not exist with the module off.
  • Run locally on SQLite: full API e2e suite 26/26 suites; src/ever-connect and src/ever-platform unit suites green; tslint and prettier clean. The three-database ci matrix will run in-cluster on this branch.

🤖 Generated with Claude Code


Summary by cubic

With the Ever Platform connection enabled and connected, answers a person's export and deletion requests and reports the person links that route those requests to the right accounts. Anonymous usage statistics are now on by default; TR_EVER_STATS_ENABLED=false turns them off (previously they were off unless set to true).

Person requests and links

  • Matching uses the Ever ID hash only, never e-mail; no account is created or changed for a request or a link.
  • Exports hold the account's own profile, Ever ID, projects and roles, encrypted under TR_SECRET; only that account can download them, for 7 days.
  • Deletion removes the Ever ID and ends its sessions; the account, its password, projects, and other sign-in methods stay.
  • Each answer is decided once, in the same transaction as what it changes (so concurrent API processes never decide twice), and kept 90 days from the answer; a failed answer leaves the feed unacknowledged so the request is retried.
  • Ever IDs users signed in with are reported as person links (ids only) while ever_id_login is consented and not denied; a refused or failed link waits an hour before its next attempt, a changed tenant link is reported again, and a link is recorded only while its connection is active, so a disconnect in between can't leave a stale marker.

Rollout

  • The migration adds three new tables only; existing tables are unchanged.
  • Existing installs that never set TR_EVER_STATS_ENABLED will start sending statistics after upgrade.