From fc767d80a02aafc93d1ca5c876f0cfe1d3ba8a62 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 20:36:44 +0000 Subject: [PATCH 01/11] wip(plugin-auth): environment-user outbox and remove-sso-user door Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF Co-authored-by: Claude --- .../utils/organization-ownership-inventory.ts | 8 + .../scripts/i18n-extract.config.ts | 2 + .../translations/bundle-ownership.test.ts | 2 + .../deployment-level-no-tenant-column.test.ts | 3 + .../platform-objects/src/identity/index.ts | 2 + .../sys-environment-user-outbox.object.ts | 235 ++++++++ .../plugin-auth/src/admin-ban-endpoints.ts | 103 +++- .../plugins/plugin-auth/src/auth-plugin.ts | 52 ++ .../plugin-auth/src/environment-user-host.ts | 65 ++- .../src/environment-user-outbox.ts | 531 ++++++++++++++++++ packages/plugins/plugin-auth/src/manifest.ts | 4 + .../plugin-auth/src/pending-sso-marker.ts | 10 + .../plugin-auth/src/pending-sso-users.ts | 275 ++++++++- .../system/constants/platform-object-names.ts | 1 + 14 files changed, 1246 insertions(+), 47 deletions(-) create mode 100644 packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts create mode 100644 packages/plugins/plugin-auth/src/environment-user-outbox.ts diff --git a/packages/cli/src/utils/organization-ownership-inventory.ts b/packages/cli/src/utils/organization-ownership-inventory.ts index 953ac18b4ce..1c4b595fdfd 100644 --- a/packages/cli/src/utils/organization-ownership-inventory.ts +++ b/packages/cli/src/utils/organization-ownership-inventory.ts @@ -767,6 +767,14 @@ export const ORGANIZATION_OWNERSHIP_INVENTORY: readonly InventoryEntry[] = [ `${CENSUS_MAIN}: systemFields.tenant: false; ${D7}: the environment's trusted plugin-publisher keys, ` + 'read by key id under the system context, never by organization', }, + { + object: 'sys_environment_user_outbox', + census: PMAIN, + fate: 'column-drop', + citation: + `${CENSUS_MAIN}: systemFields.tenant: false; ${D7}: the record of each call to the environment-user host about ` + + 'one person, who is the environment\'s and not an organization\'s, written and drained under the system context', + }, { object: 'sys_lifecycle_state', census: PMAIN, diff --git a/packages/platform-objects/scripts/i18n-extract.config.ts b/packages/platform-objects/scripts/i18n-extract.config.ts index 3d59bc05744..7c1054a899a 100644 --- a/packages/platform-objects/scripts/i18n-extract.config.ts +++ b/packages/platform-objects/scripts/i18n-extract.config.ts @@ -146,6 +146,7 @@ import { SysScimSubject, SysScimUser, SysIdpGroupMapping, + SysEnvironmentUserOutbox, } from '../src/identity/index.js'; // ── Security ────────────────────────────────────────────────────────────── @@ -327,6 +328,7 @@ const config: ObjectStackDefinition = defineStack({ SysScimSubject, SysScimUser, SysIdpGroupMapping, + SysEnvironmentUserOutbox, // Security: RBAC moved to @objectstack/plugin-security, sharing to // @objectstack/plugin-sharing (ADR-0029 K2 / D8). diff --git a/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts b/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts index 648ef7e731a..db7b2bf75d8 100644 --- a/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts +++ b/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts @@ -48,6 +48,8 @@ const OWNED_OBJECTS = new Set([ 'sys_scim_subject', 'sys_scim_user', // identity — IdP group → permission set mapping (#30959; SCIM now, SSO group claims later) 'sys_idp_group_mapping', + // identity — the record of each call to the environment-user host + 'sys_environment_user_outbox', // audit / messaging-adjacent (still owned here) 'sys_notification', 'sys_attachment', 'sys_email', 'sys_email_template', // (sys_saved_report / sys_report_schedule retired with the saved-report stack, #20102) diff --git a/packages/platform-objects/src/deployment-level-no-tenant-column.test.ts b/packages/platform-objects/src/deployment-level-no-tenant-column.test.ts index a7233f9a531..b3e37084479 100644 --- a/packages/platform-objects/src/deployment-level-no-tenant-column.test.ts +++ b/packages/platform-objects/src/deployment-level-no-tenant-column.test.ts @@ -13,6 +13,7 @@ import { SysSettingAudit, SysTrustedKey, } from './system/index.js'; +import { SysEnvironmentUserOutbox } from './identity/index.js'; /** * [ADR-0131 D7] The deployment-level plumbing this package declares carries no @@ -51,6 +52,8 @@ const DEPLOYMENT_LEVEL = [ ['sys_trusted_key', SysTrustedKey], // [ADR-0057] The lifecycle sweeper's clock state: one row per datastore. ['sys_lifecycle_state', SysLifecycleState], + // The record of each call to the environment-user host (pending people's invitations). + ['sys_environment_user_outbox', SysEnvironmentUserOutbox], ] as const; describe('[ADR-0131 D7] deployment-level plumbing: no tenant column, platform-only reads', () => { diff --git a/packages/platform-objects/src/identity/index.ts b/packages/platform-objects/src/identity/index.ts index 872a519756d..0336030d8cb 100644 --- a/packages/platform-objects/src/identity/index.ts +++ b/packages/platform-objects/src/identity/index.ts @@ -57,3 +57,5 @@ export { SysScimSubject } from './sys-scim-subject.object.js'; export { SysScimUser } from './sys-scim-user.object.js'; // The identity-provider group → permission-set mapping the SCIM projection reads. export { SysIdpGroupMapping } from './sys-idp-group-mapping.object.js'; +// The record of each call to the environment-user host (invitations sent and cancelled). +export { SysEnvironmentUserOutbox } from './sys-environment-user-outbox.object.js'; diff --git a/packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts b/packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts new file mode 100644 index 00000000000..d5ff62eaa86 --- /dev/null +++ b/packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts @@ -0,0 +1,235 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import { ObjectSchema, Field } from '@objectstack/spec/data'; + +/** + * sys_environment_user_outbox — the durable record of every call the + * environment makes to its environment-user host (the cloud, on a hosted + * environment) about one person: an invitation sent when a pending person is + * added or re-added, cancelled when one is deactivated or removed, and + * re-sent when a person is reactivated. + * + * Why it exists: the execution terms of the hosting rulings (relayed on the + * pending-people card) ask for "a durable outbox with retry … with per-row + * invitation status in Setup → Users". The door that acts still makes the + * first call itself, outside any database transaction, so a host's typed + * refusal (the developer member cap, an organization owner or admin) reaches + * the administrator on that request, row by row. This object is what makes + * the call durable: a call the host did not take stays `pending` here and + * plugin-auth's worker (`environment-user-outbox.ts`) retries it with backoff + * until the host takes it or the attempts run out (`failed`). + * + * One row per call, never updated into another call: a re-send writes a new + * row and marks the older unsent one `superseded`. The newest row of a person + * is their invitation status: + * + * - `added` + `pending` / `in_flight`: the invitation is being sent; + * - `added` + `sent`: invited, not signed in yet; + * - `added` + `accepted`: the person's first platform sign-in cleared the + * pending marker; + * - any kind + `failed`: the host refused it (`refusal_code`) or the + * attempts ran out (`last_error`); + * - `deactivated` / `removed` + `sent`: the invitation was cancelled. + * + * `user_id` is text, not a lookup: the row outlives a removed person, which + * is exactly when the cancellation it records matters. + * + * Writers: plugin-auth only, as the system (`managedBy: 'engine-owned'`, no + * data-API writes). Readers: platform administrators, through the data API + * (`get` / `list`), which is what Setup → Users reads. + * + * Lifecycle: no `lifecycle` block on purpose. A pending person who never + * accepts keeps a status for as long as they are pending, and a person's + * rows are one per administrator action, so there is nothing to reap. + * + * @namespace sys + */ +export const SysEnvironmentUserOutbox = ObjectSchema.create({ + name: 'sys_environment_user_outbox', + label: 'Environment User Invitation', + pluralLabel: 'Environment User Invitations', + icon: 'send', + isSystem: true, + managedBy: 'engine-owned', + // [ADR-0131 D7] Deployment-level: people are the environment's, not an + // organization's, and the worker drains every row under the system + // context, so there is no organization to stamp. Who may read is object + // permission: the platform-only capability below. + systemFields: { tenant: false }, + requiredPermissions: ['manage_platform_settings'], + protection: { + lock: 'full', + reason: 'Written only by plugin-auth: the record of each call to the environment-user host.', + docsUrl: 'https://objectstack.ai/docs/references/shared/protection', + }, + userActions: { create: false, edit: false, delete: false, import: false }, + description: + "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + nameField: 'email', // [ADR-0079] canonical primary-title pointer + displayNameField: 'email', + highlightFields: ['email', 'kind', 'status', 'attempts', 'last_error'], + + listViews: { + recent: { + type: 'grid', + name: 'recent', + label: 'Recent', + data: { provider: 'object', object: 'sys_environment_user_outbox' }, + columns: ['email', 'kind', 'status', 'attempts', 'last_error', 'updated_at'], + sort: [{ field: 'updated_at', order: 'desc' }], + pagination: { pageSize: 50 }, + }, + failed: { + type: 'grid', + name: 'failed', + label: 'Failed', + data: { provider: 'object', object: 'sys_environment_user_outbox' }, + columns: ['email', 'kind', 'attempts', 'refusal_code', 'last_error', 'updated_at'], + filter: [{ field: 'status', operator: 'equals', value: 'failed' }], + sort: [{ field: 'updated_at', order: 'desc' }], + pagination: { pageSize: 50 }, + }, + }, + + fields: { + id: Field.text({ + label: 'ID', + required: true, + readonly: true, + description: 'Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call.', + }), + + user_id: Field.text({ + label: 'User ID', + required: true, + readonly: true, + maxLength: 255, + description: 'The person the call is about. Text, not a lookup: the row outlives a removed person.', + }), + + email: Field.text({ + label: 'Email', + required: true, + readonly: true, + maxLength: 320, + description: "The person's email address when the call was made.", + }), + + kind: Field.select({ + label: 'Kind', + required: true, + readonly: true, + description: 'What the host is told: an invitation sent, cancelled or re-sent.', + options: [ + { value: 'added', label: 'Invited' }, + { value: 'deactivated', label: 'Deactivated' }, + { value: 'reactivated', label: 'Reactivated' }, + { value: 'removed', label: 'Removed' }, + ], + }), + + status: Field.select({ + label: 'Status', + required: true, + readonly: true, + defaultValue: 'pending', + description: + 'Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. ' + + 'Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a ' + + 'later call about the same person replaced it.', + options: [ + { value: 'pending', label: 'Pending' }, + { value: 'in_flight', label: 'Sending' }, + { value: 'sent', label: 'Sent' }, + { value: 'accepted', label: 'Accepted' }, + { value: 'failed', label: 'Failed' }, + { value: 'superseded', label: 'Superseded' }, + ], + }), + + attempts: Field.number({ + label: 'Attempts', + required: true, + readonly: true, + defaultValue: 0, + description: 'How many times the host has been called for this row.', + }), + + next_attempt_at: Field.number({ + label: 'Next Attempt At (ms)', + required: false, + readonly: true, + description: 'When a pending row is next tried, in epoch milliseconds.', + }), + + claimed_until: Field.number({ + label: 'Claimed Until (ms)', + required: false, + readonly: true, + description: 'While a call is in flight: when the claim lapses and another worker may try the row again.', + }), + + claim_token: Field.text({ + label: 'Claim Token', + required: false, + readonly: true, + maxLength: 64, + description: 'Names the one claim that holds an in-flight row.', + }), + + last_attempt_at: Field.datetime({ + label: 'Last Attempt At', + required: false, + readonly: true, + }), + + last_error: Field.textarea({ + label: 'Last Error', + required: false, + readonly: true, + description: "Why the last call did not land: the host's own sentence for a refusal, else what failed.", + }), + + refusal_code: Field.text({ + label: 'Refusal Code', + required: false, + readonly: true, + maxLength: 128, + description: "The host's machine code when it refused the call.", + }), + + event_json: Field.textarea({ + label: 'Event', + required: true, + readonly: true, + description: + 'The event the host is told, as built when the administrator acted: the person, the administrator and ' + + 'their cloud user id. A retry sends it unchanged.', + }), + + sent_at: Field.datetime({ + label: 'Sent At', + required: false, + readonly: true, + }), + + accepted_at: Field.datetime({ + label: 'Accepted At', + required: false, + readonly: true, + }), + }, + + indexes: [ + { fields: ['status', 'next_attempt_at'] }, + { fields: ['user_id'] }, + ], + + enable: { + trackHistory: false, + searchable: false, + apiEnabled: true, + // Read-only over the data API: plugin-auth is the only writer. + apiMethods: ['get', 'list'], + }, +}); diff --git a/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts b/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts index 6cd92af3e3d..6c9de3e1709 100644 --- a/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts +++ b/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts @@ -110,7 +110,17 @@ import { type EnvironmentUserHostAccessor, type EnvironmentUserHostOutcome, type EnvironmentUserHostRefused, + type EnvironmentUserEvent, } from './environment-user-host.js'; +import { + insertOutboxRow, + newOutboxId, + outboxDoc, + outboxNextAttemptAt, + supersedeOpenOutboxRows, + type OutboxBirth, +} from './environment-user-outbox.js'; +import { isPendingSsoSource } from './pending-sso-marker.js'; /** * Minimal better-auth `$context` surface these two routes touch. Mirrors what @@ -137,13 +147,22 @@ export interface AdminBanEndpointDeps { host?: EnvironmentUserHostAccessor; /** Reads the row's `source` and the administrator's linked cloud account for the host event. */ getDataEngine?(): any; - logger?: { warn(msg: string): void }; + /** Wakes the outbox worker for a reactivation queued for retry (`environment-user-outbox.ts`). */ + wakeOutbox?(atMs: number): void; + logger?: { warn(msg: string): void; error?(msg: string, err?: Error): void }; } async function banWriterFor(deps: AdminBanEndpointDeps, ctx: AuthBanContextLike): Promise { return (await deps.getBanWriter?.()) ?? ctx.internalAdapter; } +/** One ask of the host: its answer, and the event and delivery id it was asked with. */ +interface HostAsk { + outcome: EnvironmentUserHostOutcome | EnvironmentUserHostRefused; + event: EnvironmentUserEvent; + deliveryId: string; +} + /** * Ask the host, when one is wired; `undefined` leaves the answer as it was. * A typed refusal comes back as `{ refused }` for the door to answer. @@ -154,25 +173,64 @@ async function askHost( user: unknown, userId: string, actor: AdminActor & EnvironmentUserActor, -): Promise { +): Promise { if (!deps.host) return undefined; const row = (user && typeof user === 'object' ? user : {}) as { email?: unknown; name?: unknown }; const engine = deps.getDataEngine?.(); const source = engine ? await readUserSource(engine, userId) : undefined; const attribution = await environmentUserAttribution(engine, actor, deps.logger); - return notifyEnvironmentUserHost( - deps.host, - kind, - { - userId, - email: typeof row.email === 'string' ? row.email : '', - name: typeof row.name === 'string' ? row.name : '', - source: source?.ok && typeof source.value === 'string' ? source.value : null, - ...attribution, - occurredAt: new Date().toISOString(), - }, - deps.logger, - ); + const event: EnvironmentUserEvent = { + userId, + email: typeof row.email === 'string' ? row.email : '', + name: typeof row.name === 'string' ? row.name : '', + source: source?.ok && typeof source.value === 'string' ? source.value : null, + ...attribution, + occurredAt: new Date().toISOString(), + }; + const deliveryId = newOutboxId(); + const outcome = await notifyEnvironmentUserHost(deps.host, kind, { ...event, deliveryId }, deps.logger); + return { outcome, event, deliveryId }; +} + +/** + * Record an ask in the outbox after the door's write + * (`environment-user-outbox.ts`): a deactivation of a pending person as the + * cancelled invitation (and every invitation or reactivation still waiting + * for them stops), a reactivation as sent, or queued for the worker when the + * host could not be reached. A failure to record is logged at `error`: the + * door's write stands, and a queued reactivation would not be retried. + */ +async function recordAsk( + deps: AdminBanEndpointDeps, + kind: 'deactivated' | 'reactivated', + ask: HostAsk, +): Promise<{ id: string; status: 'sent' | 'pending' } | undefined> { + const engine = deps.getDataEngine?.(); + if (!engine || 'refused' in ask.outcome) return undefined; + const outcome = ask.outcome; + if (!outcome.notified && outcome.reason === 'no_host') return undefined; + try { + if (kind === 'deactivated') { + await supersedeOpenOutboxRows(engine, ask.event.userId, ['added', 'reactivated']); + if (!outcome.notified || !isPendingSsoSource(ask.event.source)) return undefined; + } else { + await supersedeOpenOutboxRows(engine, ask.event.userId, ['reactivated']); + } + const birth: OutboxBirth = outcome.notified + ? { status: 'sent' } + : { status: 'pending', lastError: 'The hosting organisation could not be reached, or failed to take the call.' }; + await insertOutboxRow(engine, outboxDoc(ask.deliveryId, kind, ask.event, birth)); + if (birth.status === 'pending') deps.wakeOutbox?.(outboxNextAttemptAt(1, Date.now())); + return { id: ask.deliveryId, status: birth.status }; + } catch (error) { + const message = + `[AuthPlugin] user ${ask.event.userId} was ${kind}, but the record of telling the environment-user host could ` + + `not be written to the outbox${outcome.notified ? '' : ', so the call the host did not take will not be retried'}. ` + + `Repeat the action to tell the host again. Cause: ${error instanceof Error ? error.message : String(error)}`; + if (deps.logger?.error) deps.logger.error(message); + else deps.logger?.warn(message); + return undefined; + } } /** The door's answer for a host's typed refusal: its status, code and sentence; nothing was written. */ @@ -279,7 +337,8 @@ export async function runAdminBanUser( } // The host first: an organization owner or admin it refuses is not deactivated at all. - const host = await askHost(deps, 'deactivated', target, userId, actor); + const ask = await askHost(deps, 'deactivated', target, userId, actor); + const host = ask?.outcome; if (isRefused(host)) return hostRefusal(host); // A wired host that did not answer: the owner / admin question is open, so // the deactivation does not happen (ruling 5). @@ -291,6 +350,7 @@ export async function runAdminBanUser( }); // Sign the banned user out everywhere, exactly as the vendor handler does. await ctx.internalAdapter.deleteUserSessions(userId); + const invitation = ask ? await recordAsk(deps, 'deactivated', ask) : undefined; return { status: 200, @@ -302,6 +362,7 @@ export async function runAdminBanUser( banReason, ...(banExpires ? { banExpires: banExpires.toISOString() } : {}), ...(host ? { host } : {}), + ...(invitation ? { invitation } : {}), }, }, }; @@ -323,10 +384,16 @@ export async function runAdminUnbanUser( if (!target) return notFound(); // The host first: a reactivation it refuses (the member cap) leaves the person deactivated. - const host = await askHost(deps, 'reactivated', target, userId, actor); + const ask = await askHost(deps, 'reactivated', target, userId, actor); + const host = ask?.outcome; if (isRefused(host)) return hostRefusal(host); await applyUserUnban(await banWriterFor(deps, ctx), userId); + // A reactivation the host did not take is queued and retried (ruling 5: it re-sends the invitation). + const invitation = ask ? await recordAsk(deps, 'reactivated', ask) : undefined; - return { status: 200, body: { success: true, data: { userId, banned: false, ...(host ? { host } : {}) } } }; + return { + status: 200, + body: { success: true, data: { userId, banned: false, ...(host ? { host } : {}), ...(invitation ? { invitation } : {}) } }, + }; } diff --git a/packages/plugins/plugin-auth/src/auth-plugin.ts b/packages/plugins/plugin-auth/src/auth-plugin.ts index 060a788664d..6f091765bd8 100644 --- a/packages/plugins/plugin-auth/src/auth-plugin.ts +++ b/packages/plugins/plugin-auth/src/auth-plugin.ts @@ -191,6 +191,13 @@ import { } from './admin-ban-endpoints.js'; import { engineUserBanWriter, type UserBanEngine } from './user-ban-write.js'; import type { EnvironmentUserHostAccessor } from './environment-user-host.js'; +import { + registerOutboxAcceptedTrigger, + startEnvironmentUserOutboxWorker, + type EnvironmentUserOutboxEngine, + type EnvironmentUserOutboxWorker, + type OutboxHookEngine, +} from './environment-user-outbox.js'; /** @@ -672,6 +679,8 @@ export class AuthPlugin implements Plugin { private options: AuthPluginOptions; private authManager: AuthManager | null = null; + /** The environment-user outbox worker: running only on a cloud-managed kernel with a host wired. */ + private environmentUserOutbox: EnvironmentUserOutboxWorker | null = null; /** * Whether a route registration mounted direct sign-in's start door. The * door is mounted from the manager's setting and `/auth/config` advertises @@ -2284,6 +2293,20 @@ export class AuthPlugin implements Plugin { packageId: IDP_GROUP_MAPPING_MATCH_PACKAGE_ID, logger: ctx.logger, }); + // The environment-user outbox (`environment-user-outbox.ts`): on a + // cloud-managed kernel with a host wired, a pending person's + // invitation reads `accepted` once they sign in, and the worker + // retries every call the host did not take. Elsewhere no outbox row + // is ever written, so neither runs. + const environmentUserHost = this.options.environmentUserHost; + if (environmentUserHost && isCloudManaged() && !this.environmentUserOutbox) { + registerOutboxAcceptedTrigger(engine as unknown as OutboxHookEngine, { logger: ctx.logger }); + this.environmentUserOutbox = startEnvironmentUserOutboxWorker({ + getDataEngine: () => engine as unknown as EnvironmentUserOutboxEngine, + host: environmentUserHost, + logger: ctx.logger, + }); + } try { await refreshAllMappingMatches(engine); } catch (e) { @@ -3114,9 +3137,17 @@ export class AuthPlugin implements Plugin { async destroy(): Promise { // Cleanup if needed + const outbox = this.environmentUserOutbox; + this.environmentUserOutbox = null; + await outbox?.stop(); this.authManager = null; } + /** Wake the outbox worker for a call due at `atMs`; nothing when it is not running. */ + private wakeEnvironmentUserOutbox = (atMs: number): void => { + this.environmentUserOutbox?.wakeAt(atMs); + }; + /** * Provision the stack's `demoStaff` (`demo-staff.ts` holds the three gates * and the argument for each). Answers what happened — nothing when no entry @@ -4923,6 +4954,7 @@ export class AuthPlugin implements Plugin { }, ...(this.options.environmentUserHost ? { host: this.options.environmentUserHost } : {}), getDataEngine: () => this.authManager!.getDataEngine(), + wakeOutbox: this.wakeEnvironmentUserOutbox, logger: ctx.logger, }); @@ -5207,6 +5239,7 @@ export class AuthPlugin implements Plugin { return session?.session?.activeOrganizationId ?? null; }, ...(this.options.environmentUserHost ? { host: this.options.environmentUserHost } : {}), + wakeOutbox: this.wakeEnvironmentUserOutbox, logger: ctx.logger, }); @@ -5241,6 +5274,25 @@ export class AuthPlugin implements Plugin { return c.json({ success: false, error: { code: 'INTERNAL_ERROR', message: INTERNAL_ERROR_MESSAGE } }, 500); } }); + + // Remove a person who is still pending (the email-typo case) and cancel + // their invitation at the host. Same gate and attribution as the two + // doors above; logic in `pending-sso-users.ts` (`runRemoveSsoUser`). + rawApp.post(`${basePath}/admin/remove-sso-user`, async (c: any) => { + try { + const actor = await gateAdmin(c); + if (actor instanceof Response) return actor; + const { runRemoveSsoUser } = await import('./pending-sso-users.js'); + const { status, body } = await runAttributedToUser(actor, () => + runRemoveSsoUser(pendingSsoUserDeps(c), actor, c.req.raw), + ); + return c.json(body, status as any); + } catch (error) { + const err = error instanceof Error ? error : new Error(String(error)); + ctx.logger.error('[AuthPlugin] admin/remove-sso-user failed', err); + return c.json({ success: false, error: { code: 'INTERNAL_ERROR', message: INTERNAL_ERROR_MESSAGE } }, 500); + } + }); } // ──────────────────────────────────────────────────────────────────── diff --git a/packages/plugins/plugin-auth/src/environment-user-host.ts b/packages/plugins/plugin-auth/src/environment-user-host.ts index f65f38f2b6f..56d93235e9b 100644 --- a/packages/plugins/plugin-auth/src/environment-user-host.ts +++ b/packages/plugins/plugin-auth/src/environment-user-host.ts @@ -2,10 +2,13 @@ /** * The host seam for environment users: a host (the cloud, on a hosted - * environment) is told when a person is added, deactivated or reactivated, so - * it can forward an invitation or a removal. See `pending-sso-users.ts` for - * the add half and `admin-ban-endpoints.ts` for the deactivate / reactivate - * half. + * environment) is told when a person is added, deactivated, reactivated or, + * while still pending, removed, so it can forward an invitation or cancel + * one. See `pending-sso-users.ts` for the add and remove halves and + * `admin-ban-endpoints.ts` for the deactivate / reactivate half. Every call + * is recorded, and retried when the host did not take it, by the outbox + * (`environment-user-outbox.ts`): delivery is at least once, and the event's + * `deliveryId` lets a host drop a repeat. * * Two kinds of host failure are told apart: * @@ -61,15 +64,23 @@ export interface EnvironmentUserEvent { * reactivation. */ occurredAt: string; + /** + * The outbox row this call is recorded in (`sys_environment_user_outbox`). + * A call the host did not take is sent again under the same id, so a host + * can drop a repeat of a call it already took. Absent only on a call made + * outside the outbox. + */ + deliveryId?: string; } /** * The host's side of the seam. `userAdded` is called after the person is - * written; `userDeactivated` and `userReactivated` before the ban or unban is - * written. A member that throws {@link EnvironmentUserHostRefusal} refuses - * the operation. Any other throw refuses a deactivation (`503`) and is - * reported on the answer for an add or a reactivation, which it never undoes - * or blocks. + * written; `userDeactivated`, `userReactivated` and `userRemoved` before the + * ban, unban or removal is written. A member that throws + * {@link EnvironmentUserHostRefusal} refuses the operation. Any other throw + * refuses a deactivation (`503`) and is reported on the answer for an add, a + * reactivation or a removal, which it never undoes or blocks; the outbox + * retries those. */ export interface EnvironmentUserHost { /** A person was added (or re-added while still pending) to this environment. */ @@ -78,6 +89,14 @@ export interface EnvironmentUserHost { userDeactivated(event: EnvironmentUserEvent): void | Promise; /** A person was reactivated (`admin/unban-user`). */ userReactivated(event: EnvironmentUserEvent): void | Promise; + /** + * A pending person was removed (`admin/remove-sso-user`): cancel their + * invitation. Optional: a host without it is called on `userDeactivated` + * for the pending person instead, which the hosting rulings make the same + * thing ("deleting or deactivating a pending row cancels its cloud + * invitation"). A host should implement it. + */ + userRemoved?(event: EnvironmentUserEvent): void | Promise; } /** @@ -132,14 +151,30 @@ export interface EnvironmentUserHostRefused { refused: { status: EnvironmentUserHostRefusalStatus; code: string; message: string }; } -export type EnvironmentUserEventKind = 'added' | 'deactivated' | 'reactivated'; +export type EnvironmentUserEventKind = 'added' | 'deactivated' | 'reactivated' | 'removed'; const HOST_MEMBER: Record = { added: 'userAdded', deactivated: 'userDeactivated', reactivated: 'userReactivated', + removed: 'userRemoved', }; +/** + * The member `kind` calls on `host`: its own, or for a removal on a host + * without `userRemoved`, `userDeactivated` (a pending person's deactivation + * cancels the invitation by ruling, which is what a removal asks). + */ +function hostMember( + host: EnvironmentUserHost | undefined, + kind: EnvironmentUserEventKind, +): ((event: EnvironmentUserEvent) => void | Promise) | undefined { + const own = host?.[HOST_MEMBER[kind]]; + if (typeof own === 'function') return own; + if (kind === 'removed' && typeof host?.userDeactivated === 'function') return host.userDeactivated; + return undefined; +} + /** The engine slice the actor's cloud id is read through. */ export interface ActorCloudIdReader { find(objectName: string, query?: unknown): Promise; @@ -219,8 +254,8 @@ export async function notifyEnvironmentUserHost( ); return { notified: false, reason: 'host_failed' }; } - const member = host?.[HOST_MEMBER[kind]]; - if (typeof member !== 'function') return { notified: false, reason: 'no_host' }; + const member = hostMember(host, kind); + if (!member) return { notified: false, reason: 'no_host' }; try { await member.call(host, event); return { notified: true }; @@ -231,7 +266,7 @@ export async function notifyEnvironmentUserHost( logger?.warn( `[AuthPlugin] the environment-user host refused or failed to take the news that user ${event.userId} was ` + `${kind}. ${goesAhead(kind)} The answer says so. ` - + (kind === 'added' ? 'Adding the person again while they are still pending tells the host again. ' : '') + + (kind === 'deactivated' ? '' : 'The call is retried. ') + `Cause: ${describe(error)}`, ); return { notified: false, reason: 'host_failed' }; @@ -243,6 +278,8 @@ const goesAhead = (kind: EnvironmentUserEventKind): string => ? 'The addition itself stands.' : kind === 'deactivated' ? 'The deactivation is refused: only the host can say whether this person may be removed.' - : 'The change goes ahead.'; + : kind === 'removed' + ? 'The removal goes ahead.' + : 'The change goes ahead.'; const describe = (error: unknown): string => (error instanceof Error ? error.message : String(error)); diff --git a/packages/plugins/plugin-auth/src/environment-user-outbox.ts b/packages/plugins/plugin-auth/src/environment-user-outbox.ts new file mode 100644 index 00000000000..2bc55933c16 --- /dev/null +++ b/packages/plugins/plugin-auth/src/environment-user-outbox.ts @@ -0,0 +1,531 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The durable outbox of the environment-user host seam + * (`environment-user-host.ts`): every call the environment makes to its host + * about one person is a row of `sys_environment_user_outbox`, and a call the + * host did not take is retried here until it does or the attempts run out. + * + * ## Why the door still calls first + * + * The hosting rulings (relayed on the pending-people card) ask for "a durable + * outbox with retry … with per-row invitation status in Setup → Users", and + * their edge paths say a CSV row or a reactivation at the developer member + * cap is refused with `403 DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED`, + * shown per row. A refusal the administrator must read on the request cannot + * come from a worker that runs later, so each door keeps making the first + * call itself, and the outbox only makes that call durable: + * + * - **add / re-add** writes its row INSIDE the person's unit of work, born + * `in_flight` and claimed by the door ({@link outboxDoc}), so no worker + * can call the host for it at the same time. After the commit the door + * calls the host and settles the row ({@link settleOutboxAttempt}). A + * process that dies in between leaves a claim that lapses, and the worker + * sends it. + * - **deactivate, reactivate and remove** ask the host BEFORE their write + * (a deactivation or reactivation refused by the host must not happen), + * so the row is written after the call, with the call's outcome, under a + * delivery id chosen before it. + * + * No database transaction is held across any host call (ruling term). + * + * ## Rows and statuses + * + * One row per call. `pending` / `in_flight`: not taken yet; `sent`: taken; + * `accepted`: an `added` row whose person signed in + * ({@link registerOutboxAcceptedTrigger}); `failed`: refused by the host + * (`refusal_code` + its sentence) or out of attempts; `superseded`: a later + * call about the same person replaced it (a re-send, or a deactivation or + * removal, which must never be followed by an invitation sent from a stale + * retry). The newest row of a person is their invitation status. + * + * ## The worker + * + * {@link startEnvironmentUserOutboxWorker}: one `DispatchLoop` + * (`@objectstack/core`), started only on a cloud-managed kernel with a host + * wired. A tick claims due rows one by one with a compare-and-set (a fresh + * claim token, read back) under a lease, so two workers never call the host + * for the same row. Backoff: {@link OUTBOX_BACKOFF_MS}; after + * {@link OUTBOX_MAX_ATTEMPTS} attempts the row is `failed` and an `error` is + * logged. A typed refusal on a retry is terminal `failed` with the host's + * code and sentence, and the person is left as they are: the worker never + * deletes or changes a person. + * + * Delivery is at least once: a call that landed but timed out is sent again. + * The event carries the row id as `deliveryId` so a host can drop a repeat, + * as a re-add already re-tells it today. + */ + +import { randomUUID } from 'node:crypto'; +import { DispatchLoop } from '@objectstack/core'; +import { isPendingSsoSource } from './pending-sso-marker.js'; +import { + notifyEnvironmentUserHost, + type EnvironmentUserEvent, + type EnvironmentUserEventKind, + type EnvironmentUserHostAccessor, + type EnvironmentUserHostOutcome, + type EnvironmentUserHostRefused, +} from './environment-user-host.js'; + +/** The object every call is recorded in. */ +export const ENVIRONMENT_USER_OUTBOX_OBJECT = 'sys_environment_user_outbox'; + +/** The statuses a row moves through. */ +export type EnvironmentUserOutboxStatus = 'pending' | 'in_flight' | 'sent' | 'accepted' | 'failed' | 'superseded'; + +/** + * The wait before attempt N+1, by the number of attempts made so far (index + * 0 = after the first failed attempt). Past the end the last entry repeats. + */ +export const OUTBOX_BACKOFF_MS: readonly number[] = [ + 60_000, // 1 min + 5 * 60_000, // 5 min + 15 * 60_000, // 15 min + 60 * 60_000, // 1 h + 3 * 60 * 60_000, // 3 h + 6 * 60 * 60_000, // 6 h + 12 * 60 * 60_000, // 12 h +]; + +/** After this many attempts a row that never landed is `failed`. */ +export const OUTBOX_MAX_ATTEMPTS = 12; + +/** How long a claim holds a row before another worker may try it. */ +export const OUTBOX_LEASE_MS = 2 * 60_000; + +/** The most rows one worker tick claims. */ +export const OUTBOX_TICK_LIMIT = 25; + +/** When the next attempt is due, after `attempts` attempts. */ +export function outboxNextAttemptAt(attempts: number, now: number): number { + const index = Math.min(Math.max(attempts, 1), OUTBOX_BACKOFF_MS.length) - 1; + return now + OUTBOX_BACKOFF_MS[index]!; +} + +/** The engine slice the outbox uses. */ +export interface EnvironmentUserOutboxEngine { + find(objectName: string, query?: unknown): Promise; + insert(objectName: string, doc: Record, opts?: unknown): Promise; + update(objectName: string, data: Record, opts?: unknown): Promise; +} + +interface OutboxLogger { + warn(msg: string): void; + error?(msg: string, err?: Error): void; +} + +const SYSTEM_CTX = { isSystem: true, positions: [], permissions: [] }; + +/** One row as the worker reads it. */ +export interface EnvironmentUserOutboxRow { + id: string; + user_id: string; + email: string; + kind: EnvironmentUserEventKind; + status: EnvironmentUserOutboxStatus; + attempts: number; + claim_token?: string | null; + event_json: string; +} + +/** The row's state when it is written. */ +export type OutboxBirth = + /** The door holds it and calls the host now (add / re-add). */ + | { status: 'in_flight'; claimToken: string } + /** The host already took the call (an ask-first door). */ + | { status: 'sent' } + /** The host could not be reached (an ask-first door): the worker retries. */ + | { status: 'pending'; lastError: string } + /** Not called yet: the worker sends it at once. */ + | { status: 'queued' }; + +/** A new row: its id is the delivery id the host is (or was) sent. */ +export function outboxDoc( + id: string, + kind: EnvironmentUserEventKind, + event: EnvironmentUserEvent, + birth: OutboxBirth, + now: number = Date.now(), +): Record { + const base: Record = { + id, + user_id: event.userId, + email: event.email, + kind, + status: birth.status === 'queued' ? 'pending' : birth.status, + event_json: JSON.stringify(event), + }; + if (birth.status === 'queued') return { ...base, attempts: 0, next_attempt_at: now }; + if (birth.status === 'in_flight') { + return { ...base, attempts: 0, claim_token: birth.claimToken, claimed_until: now + OUTBOX_LEASE_MS }; + } + const attempted = { attempts: 1, last_attempt_at: new Date(now).toISOString() }; + if (birth.status === 'sent') return { ...base, ...attempted, sent_at: new Date(now).toISOString() }; + return { ...base, ...attempted, last_error: birth.lastError, next_attempt_at: outboxNextAttemptAt(1, now) }; +} + +/** A fresh delivery id and claim token. */ +export const newOutboxId = (): string => randomUUID(); + +/** Write one row, as the system. */ +export async function insertOutboxRow( + engine: EnvironmentUserOutboxEngine, + doc: Record, + context: unknown = SYSTEM_CTX, +): Promise { + await engine.insert(ENVIRONMENT_USER_OUTBOX_OBJECT, doc, { context }); +} + +/** + * Mark a person's unsent rows of `kinds` `superseded`: a re-send replaces an + * older invitation still waiting, and a deactivation or removal stops every + * invitation still waiting, so no stale retry is sent after it. + */ +export async function supersedeOpenOutboxRows( + engine: EnvironmentUserOutboxEngine, + userId: string, + kinds: readonly EnvironmentUserEventKind[], +): Promise { + await engine.update( + ENVIRONMENT_USER_OUTBOX_OBJECT, + { status: 'superseded', next_attempt_at: null }, + { where: { user_id: userId, kind: { $in: [...kinds] }, status: 'pending' }, multi: true, context: SYSTEM_CTX }, + ); +} + +/** What one attempt's outcome makes of the row. */ +export function outboxSettlement( + outcome: EnvironmentUserHostOutcome | EnvironmentUserHostRefused, + attemptsBefore: number, + now: number, +): { status: EnvironmentUserOutboxStatus; data: Record; exhausted: boolean } { + const attempts = attemptsBefore + 1; + const common = { + attempts, + last_attempt_at: new Date(now).toISOString(), + claim_token: null, + claimed_until: null, + }; + if ('refused' in outcome) { + return { + status: 'failed', + exhausted: false, + data: { + ...common, + status: 'failed', + next_attempt_at: null, + refusal_code: outcome.refused.code, + last_error: outcome.refused.message, + }, + }; + } + if (outcome.notified) { + return { + status: 'sent', + exhausted: false, + data: { ...common, status: 'sent', next_attempt_at: null, sent_at: new Date(now).toISOString(), last_error: null }, + }; + } + const lastError = + outcome.reason === 'no_host' + ? 'No environment-user host answered, so the call was not made.' + : 'The hosting organisation could not be reached, or failed to take the call.'; + if (attempts >= OUTBOX_MAX_ATTEMPTS) { + return { + status: 'failed', + exhausted: true, + data: { ...common, status: 'failed', next_attempt_at: null, last_error: `${lastError} No attempts are left.` }, + }; + } + return { + status: 'pending', + exhausted: false, + data: { ...common, status: 'pending', next_attempt_at: outboxNextAttemptAt(attempts, now), last_error: lastError }, + }; +} + +/** + * Record one attempt's outcome on the row the caller holds (`claimToken`). + * A write that finds the claim gone (lapsed and taken by another worker) + * changes nothing. Answers the status written. + */ +export async function settleOutboxAttempt( + engine: EnvironmentUserOutboxEngine, + row: { id: string; email: string; kind: EnvironmentUserEventKind; attempts: number }, + claimToken: string, + outcome: EnvironmentUserHostOutcome | EnvironmentUserHostRefused, + logger?: OutboxLogger, + now: number = Date.now(), +): Promise { + const settled = outboxSettlement(outcome, row.attempts, now); + await engine.update(ENVIRONMENT_USER_OUTBOX_OBJECT, settled.data, { + where: { id: row.id, claim_token: claimToken }, + multi: true, + context: SYSTEM_CTX, + }); + if (settled.exhausted) { + const message = + `[AuthPlugin] the environment-user host never took the call that ${row.email} was ${row.kind} ` + + `(outbox row ${row.id}, ${OUTBOX_MAX_ATTEMPTS} attempts), so the hosting organisation was not told and ` + + 'nothing will retry it. Setup → Users shows the row as failed; add the person again to re-send an ' + + 'invitation, or repeat the action once the host is reachable.'; + if (logger?.error) logger.error(message); + else logger?.warn(message); + } + return settled.status; +} + +const text = (value: unknown): string => (typeof value === 'string' ? value : ''); + +function readRow(raw: unknown): EnvironmentUserOutboxRow | undefined { + if (!raw || typeof raw !== 'object') return undefined; + const r = raw as Record; + if (!text(r.id) || !text(r.event_json)) return undefined; + return { + id: text(r.id), + user_id: text(r.user_id), + email: text(r.email), + kind: text(r.kind) as EnvironmentUserEventKind, + status: text(r.status) as EnvironmentUserOutboxStatus, + attempts: typeof r.attempts === 'number' ? r.attempts : Number(r.attempts) || 0, + claim_token: typeof r.claim_token === 'string' ? r.claim_token : null, + event_json: text(r.event_json), + }; +} + +/** + * Claim one row: a compare-and-set from the state the tick read (`pending`, + * or `in_flight` under a lapsed claim) to `in_flight` under a fresh token, + * then a read-back of that token. Answers the token when this caller holds + * the row, `undefined` when another claim won. + */ +export async function claimOutboxRow( + engine: EnvironmentUserOutboxEngine, + row: EnvironmentUserOutboxRow, + now: number = Date.now(), +): Promise { + const token = newOutboxId(); + const from = + row.status === 'in_flight' && row.claim_token + ? { id: row.id, status: 'in_flight', claim_token: row.claim_token } + : { id: row.id, status: 'pending' }; + await engine.update( + ENVIRONMENT_USER_OUTBOX_OBJECT, + { status: 'in_flight', claim_token: token, claimed_until: now + OUTBOX_LEASE_MS }, + { where: from, multi: true, context: SYSTEM_CTX }, + ); + const held = await engine.find(ENVIRONMENT_USER_OUTBOX_OBJECT, { + where: { id: row.id, claim_token: token }, + fields: ['id'], + limit: 1, + context: SYSTEM_CTX, + }); + return Array.isArray(held) && held.length > 0 ? token : undefined; +} + +/** What the worker needs. */ +export interface EnvironmentUserOutboxDeps { + getDataEngine(): EnvironmentUserOutboxEngine | undefined; + host: EnvironmentUserHostAccessor; + logger?: OutboxLogger; + now?(): number; +} + +/** Whether a row still has a reason to be sent, read from the person as they are now. */ +async function stillOwed( + engine: EnvironmentUserOutboxEngine, + row: EnvironmentUserOutboxRow, +): Promise<'send' | 'accepted' | 'superseded'> { + if (row.kind !== 'added' && row.kind !== 'reactivated') return 'send'; + const users = await engine.find('sys_user', { + where: { id: row.user_id }, + fields: ['id', 'source', 'banned'], + limit: 1, + context: SYSTEM_CTX, + }); + const user = (Array.isArray(users) ? users[0] : undefined) as { source?: unknown; banned?: unknown } | undefined; + if (!user) return 'superseded'; + if (row.kind === 'added') return isPendingSsoSource(user.source) ? 'send' : 'accepted'; + // A reactivation still owed only while the person is still active. + return user.banned === true || user.banned === 1 ? 'superseded' : 'send'; +} + +/** Send one claimed row. Answers the status written. */ +export async function deliverOutboxRow( + deps: EnvironmentUserOutboxDeps, + engine: EnvironmentUserOutboxEngine, + row: EnvironmentUserOutboxRow, + claimToken: string, +): Promise { + const now = deps.now?.() ?? Date.now(); + const owed = await stillOwed(engine, row); + if (owed !== 'send') { + await engine.update( + ENVIRONMENT_USER_OUTBOX_OBJECT, + { + status: owed, + claim_token: null, + claimed_until: null, + next_attempt_at: null, + ...(owed === 'accepted' ? { accepted_at: new Date(now).toISOString() } : {}), + }, + { where: { id: row.id, claim_token: claimToken }, multi: true, context: SYSTEM_CTX }, + ); + return owed; + } + let event: EnvironmentUserEvent; + try { + event = JSON.parse(row.event_json) as EnvironmentUserEvent; + } catch { + await engine.update( + ENVIRONMENT_USER_OUTBOX_OBJECT, + { + status: 'failed', + claim_token: null, + claimed_until: null, + next_attempt_at: null, + last_error: 'The stored event could not be read, so the call was not made.', + }, + { where: { id: row.id, claim_token: claimToken }, multi: true, context: SYSTEM_CTX }, + ); + deps.logger?.warn(`[AuthPlugin] environment-user outbox row ${row.id} holds an unreadable event; it is failed.`); + return 'failed'; + } + const outcome = await notifyEnvironmentUserHost(deps.host, row.kind, { ...event, deliveryId: row.id }, deps.logger); + if ('refused' in outcome) { + deps.logger?.warn( + `[AuthPlugin] the environment-user host refused a retried call that ${row.email} was ${row.kind} ` + + `(${outcome.refused.status} ${outcome.refused.code}). The row is failed; the person is left as they are.`, + ); + } + return settleOutboxAttempt(engine, row, claimToken, outcome, deps.logger, now); +} + +/** One worker pass: claim and send every due row, up to {@link OUTBOX_TICK_LIMIT}. Answers the rows it held. */ +export async function runEnvironmentUserOutboxTick(deps: EnvironmentUserOutboxDeps): Promise { + const engine = deps.getDataEngine(); + if (!engine) return 0; + const now = deps.now?.() ?? Date.now(); + const due = await engine.find(ENVIRONMENT_USER_OUTBOX_OBJECT, { + where: { + $or: [ + { status: 'pending', next_attempt_at: { $lte: now } }, + { status: 'in_flight', claimed_until: { $lt: now } }, + ], + }, + orderBy: [{ field: 'next_attempt_at', order: 'asc' }], + limit: OUTBOX_TICK_LIMIT, + context: SYSTEM_CTX, + }); + let held = 0; + for (const raw of Array.isArray(due) ? due : []) { + const row = readRow(raw); + if (!row) continue; + const token = await claimOutboxRow(engine, row, now); + if (!token) continue; + held++; + await deliverOutboxRow(deps, engine, row, token); + } + return held; +} + +/** The earliest instant a row becomes due, for the loop's sleep. */ +export async function environmentUserOutboxNextDueAt(deps: EnvironmentUserOutboxDeps): Promise { + const engine = deps.getDataEngine(); + if (!engine) return null; + const read = async (where: Record, field: string): Promise => { + const rows = await engine.find(ENVIRONMENT_USER_OUTBOX_OBJECT, { + where, + fields: [field], + orderBy: [{ field, order: 'asc' }], + limit: 1, + context: SYSTEM_CTX, + }); + const value = Array.isArray(rows) ? (rows[0] as Record | undefined)?.[field] : undefined; + return typeof value === 'number' && Number.isFinite(value) ? value : null; + }; + const candidates = [ + await read({ status: 'pending' }, 'next_attempt_at'), + await read({ status: 'in_flight' }, 'claimed_until'), + ].filter((v): v is number => v !== null); + return candidates.length > 0 ? Math.min(...candidates) : null; +} + +/** The running worker. */ +export interface EnvironmentUserOutboxWorker { + /** A row was written that is due at `atMs`. */ + wakeAt(atMs: number): void; + stop(): Promise; +} + +/** + * Start the worker. The caller starts it only on a cloud-managed kernel with + * a host wired: elsewhere no row is ever written. + */ +export function startEnvironmentUserOutboxWorker(deps: EnvironmentUserOutboxDeps): EnvironmentUserOutboxWorker { + const loop = new DispatchLoop({ + intervalMs: 60_000, + maxIdleIntervalMs: 10 * 60_000, + nextDueAt: () => environmentUserOutboxNextDueAt(deps), + runTick: () => runEnvironmentUserOutboxTick(deps), + onTickError: (err) => + deps.logger?.warn( + `[AuthPlugin] a pass over the environment-user outbox failed; its rows wait for the next pass. Cause: ` + + `${err instanceof Error ? err.message : String(err)}`, + ), + }); + loop.start(); + return { wakeAt: (atMs) => loop.wakeAt(atMs), stop: () => loop.stop() }; +} + +/** The package id the accepted trigger registers its hook under. */ +export const OUTBOX_ACCEPTED_PACKAGE_ID = 'com.objectstack.plugin-auth.environment-user-outbox-accepted'; + +/** The engine slice the accepted trigger needs. */ +export interface OutboxHookEngine extends EnvironmentUserOutboxEngine { + registerHook(event: string, handler: (ctx: any) => Promise | void, options?: { object?: string; packageId?: string }): void; + unregisterHooksByPackage?(packageId: string): number; +} + +/** + * When a person's `source` leaves the pending marker (their first platform + * sign-in, at either site that clears it), their invitation rows read + * `accepted` and any retry still waiting stops. Best effort: a failure is + * logged at `warn` and never fails the sign-in; the worker re-reads the + * person before every retry, so a missed mark never sends an invitation to + * someone who already accepted. + */ +export function registerOutboxAcceptedTrigger(engine: OutboxHookEngine, opts: { logger?: OutboxLogger } = {}): void { + const onUpdate = async (ctx: any): Promise => { + const data = (ctx?.input?.data ?? {}) as Record; + if (!('source' in data) || isPendingSsoSource(data.source)) return; + const userId = text(ctx?.input?.id) || text(data.id); + if (!userId) return; + try { + await engine.update( + ENVIRONMENT_USER_OUTBOX_OBJECT, + { status: 'accepted', accepted_at: new Date().toISOString(), next_attempt_at: null }, + { + where: { user_id: userId, kind: 'added', status: { $in: ['pending', 'sent', 'failed'] } }, + multi: true, + context: SYSTEM_CTX, + }, + ); + } catch (error) { + opts.logger?.warn( + `[AuthPlugin] user ${userId} signed in for the first time, but their invitation could not be marked ` + + `accepted; Setup → Users shows its earlier status until a retry reads the person. Cause: ` + + `${error instanceof Error ? error.message : String(error)}`, + ); + } + }; + if (typeof engine.unregisterHooksByPackage === 'function') { + try { + engine.unregisterHooksByPackage(OUTBOX_ACCEPTED_PACKAGE_ID); + } catch { + /* first bind: nothing registered yet */ + } + } + engine.registerHook('afterUpdate', onUpdate, { object: 'sys_user', packageId: OUTBOX_ACCEPTED_PACKAGE_ID }); +} diff --git a/packages/plugins/plugin-auth/src/manifest.ts b/packages/plugins/plugin-auth/src/manifest.ts index 2f907775e53..dbb825e58ca 100644 --- a/packages/plugins/plugin-auth/src/manifest.ts +++ b/packages/plugins/plugin-auth/src/manifest.ts @@ -12,6 +12,7 @@ import { SysAccount, SysApiKey, SysDeviceCode, + SysEnvironmentUserOutbox, SysIdpGroupMapping, SysInvitation, SysMember, @@ -93,6 +94,9 @@ export const authIdentityObjects: any[] = [ // The group → permission-set mapping the SCIM projection reads // (`scim-group-projection.ts`); written only by the platform-admin door. SysIdpGroupMapping, + // The record of each call to the environment-user host: invitations sent, + // cancelled and re-sent, retried by `environment-user-outbox.ts`. + SysEnvironmentUserOutbox, ]; /** diff --git a/packages/plugins/plugin-auth/src/pending-sso-marker.ts b/packages/plugins/plugin-auth/src/pending-sso-marker.ts index 3f4595b7286..5451286e96b 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-marker.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-marker.ts @@ -35,6 +35,16 @@ export const PENDING_SSO_MESSAGES = { "This environment is not cloud-managed, so there is no hosting organisation's sign-in for a pending person to " + 'arrive through. Create the user with a password or an invitation instead (admin/create-user, ' + 'admin/import-users). No user was added.', + notManagedRemove: + 'This environment is not cloud-managed, so it holds no pending people whose invitation could be cancelled. ' + + 'Deactivate the user instead (admin/ban-user). No one was removed.', + removeNotPending: + 'This person is not pending: they have signed in, or were not added to sign in through the hosting ' + + "organisation's identity provider, so they cannot be removed here. Deactivate them instead. No one was removed.", + removeRefused: 'This person could not be removed, and no one was removed.', + removeRefusedReinvited: + 'Their invitation had already been cancelled at the hosting organisation, so it is being sent again and they ' + + 'stay pending as before.', alreadyExists: 'A user with this email address already exists in this environment, so no one was added. Change the existing ' + "user's positions, permission sets or manager on their record instead.", diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.ts b/packages/plugins/plugin-auth/src/pending-sso-users.ts index ac139776d3c..99cdf480a67 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.ts @@ -117,6 +117,16 @@ import { type EnvironmentUserHostOutcome, type EnvironmentUserHostRefused, } from './environment-user-host.js'; +import { + insertOutboxRow, + newOutboxId, + outboxDoc, + outboxNextAttemptAt, + settleOutboxAttempt, + supersedeOpenOutboxRows, + type EnvironmentUserOutboxEngine, + type EnvironmentUserOutboxStatus, +} from './environment-user-outbox.js'; /** The most rows one import request may carry, the identity import's own bound. */ export const IMPORT_SSO_USERS_MAX_ROWS = 500; @@ -144,6 +154,8 @@ export interface PendingSsoUserDeps /** better-auth's `addMember`, for the multi-organization join; absent when the organization plugin is off. */ getAddMember?(): Promise; host?: EnvironmentUserHostAccessor; + /** Wakes the outbox worker for a call that is due again at `atMs` (`environment-user-outbox.ts`). */ + wakeOutbox?(atMs: number): void; logger?: { warn(msg: string): void }; } @@ -179,9 +191,16 @@ type AddOutcome = manager?: ManagerOutcome; managerError?: string; host: EnvironmentUserHostOutcome; + invitation?: InvitationOutcome; } | { ok: false; result: EndpointResult }; +/** The outbox row a call was recorded in, as an answer names it. */ +interface InvitationOutcome { + id: string; + status: EnvironmentUserOutboxStatus; +} + const ADD_KEYS = new Set(['email', 'name', 'positions', 'permissionSets', 'manager']); const ADD_FIELD_NAMES = { positions: 'positions', permissionSets: 'permissionSets', manager: 'manager' } as const; const IMPORT_FIELD_NAMES = { positions: 'positions', permissionSets: 'permission_sets', manager: 'manager_id' } as const; @@ -338,17 +357,25 @@ async function addOnePendingPerson( if (!isPendingSsoSource(existing.source)) { return { ok: false, result: fail(PENDING_SSO_REFUSAL_STATUS, PENDING_SSO_REFUSAL_CODE, PENDING_SSO_MESSAGES.alreadyExists) }; } - const host = await notifyEnvironmentUserHost( - deps.host, - 'added', - eventFor(existing.id, person.email, existing.name ?? person.name, actor, settlement), - deps.logger, - ); + // The re-send: a fresh outbox row replaces any older invitation still waiting. + const event = eventFor(existing.id, person.email, existing.name ?? person.name, actor, settlement); + let claim: { id: string; token: string } | undefined; + if (deps.host) { + claim = { id: newOutboxId(), token: newOutboxId() }; + await supersedeOpenOutboxRows(outboxEngine(engine), existing.id, ['added']); + await insertOutboxRow(outboxEngine(engine), outboxDoc(claim.id, 'added', event, { status: 'in_flight', claimToken: claim.token })); + } + const sent = await sendAdded(deps, engine, event, claim); // A refused re-add leaves the existing pending row as it was: this request did not write it. - if ('refused' in host) return { ok: false, result: hostRefusal(host) }; - return { ok: true, userId: existing.id, alreadyPending: true, host }; + if ('refused' in sent.host) return { ok: false, result: hostRefusal(sent.host) }; + return { ok: true, userId: existing.id, alreadyPending: true, host: sent.host, ...(sent.invitation ? { invitation: sent.invitation } : {}) }; } + // The outbox row is written inside the person's unit of work, held by this + // door (`in_flight`), so the person and the record of their invitation + // land together and no worker calls the host for it meanwhile. + const claim = deps.host ? { id: newOutboxId(), token: newOutboxId() } : undefined; + const work = async (): Promise<{ userId: string; organizationId: string | null }> => { const inserted: unknown = await engine.insert( 'sys_user', @@ -380,6 +407,16 @@ async function addOnePendingPerson( } } } + if (claim) { + await insertOutboxRow( + outboxEngine(engine), + outboxDoc(claim.id, 'added', eventFor(userId, person.email, person.name, actor, settlement), { + status: 'in_flight', + claimToken: claim.token, + }), + await authSystemWriteContext(), + ); + } return { userId, organizationId: membership.organizationId }; }; @@ -393,12 +430,8 @@ async function addOnePendingPerson( } // The host, outside the unit of work. A typed refusal takes this person back out. - const host = await notifyEnvironmentUserHost( - deps.host, - 'added', - eventFor(written.userId, person.email, person.name, actor, settlement), - deps.logger, - ); + const sent = await sendAdded(deps, engine, eventFor(written.userId, person.email, person.name, actor, settlement), claim); + const host = sent.host; if ('refused' in host) { await takeBackPerson(deps, engine, written.userId, settlement); return { ok: false, result: hostRefusal(host) }; @@ -414,7 +447,71 @@ async function addOnePendingPerson( ...(written.organizationId ? { organizationId: written.organizationId } : {}), }, }); - return { ok: true, userId: written.userId, alreadyPending: false, organizationId: written.organizationId, host }; + return { + ok: true, + userId: written.userId, + alreadyPending: false, + organizationId: written.organizationId, + host, + ...(sent.invitation ? { invitation: sent.invitation } : {}), + }; +} + +/** The outbox's view of the doors' engine. */ +const outboxEngine = (engine: PendingSsoUserEngine): EnvironmentUserOutboxEngine => engine as EnvironmentUserOutboxEngine; + +/** + * Tell the host a person was added, under the outbox row this door holds + * (`claim`), and record the outcome on that row: `sent`, `failed` for a + * typed refusal, or `pending` for the worker to retry. Without a host wired + * no row exists and the host is not called. + */ +async function sendAdded( + deps: PendingSsoUserDeps, + engine: PendingSsoUserEngine, + event: EnvironmentUserEvent, + claim: { id: string; token: string } | undefined, +): Promise<{ host: EnvironmentUserHostOutcome | EnvironmentUserHostRefused; invitation?: InvitationOutcome }> { + const host = await notifyEnvironmentUserHost( + deps.host, + 'added', + claim ? { ...event, deliveryId: claim.id } : event, + deps.logger, + ); + if (!claim) return { host }; + return { host, invitation: await settleHeld(deps, engine, claim, event, host) }; +} + +/** + * Record a held row's first attempt. A failure to record is logged: the + * claim then lapses and the worker sends the call again (the host can drop + * the repeat by its delivery id). + */ +async function settleHeld( + deps: PendingSsoUserDeps, + engine: PendingSsoUserEngine, + claim: { id: string; token: string }, + event: EnvironmentUserEvent, + host: EnvironmentUserHostOutcome | EnvironmentUserHostRefused, +): Promise { + try { + const status = await settleOutboxAttempt( + outboxEngine(engine), + { id: claim.id, email: event.email, kind: 'added', attempts: 0 }, + claim.token, + host, + deps.logger, + ); + if (status === 'pending') deps.wakeOutbox?.(outboxNextAttemptAt(1, Date.now())); + return { id: claim.id, status }; + } catch (error) { + deps.logger?.warn( + `[AuthPlugin] the outcome of telling the environment-user host that ${event.email} was added could not be ` + + `recorded on outbox row ${claim.id}; the worker sends it again once its claim lapses. Cause: ` + + `${error instanceof Error ? error.message : String(error)}`, + ); + return { id: claim.id, status: 'in_flight' }; + } } /** @@ -467,6 +564,7 @@ async function takeBackPerson( engine: PendingSsoUserEngine, userId: string, settlement: RequestSettlement, + alongside?: () => Promise, ): Promise { if (typeof engine.delete !== 'function') { throw new Error(`The host refused user ${userId}, and this data engine cannot take the row back out`); @@ -478,6 +576,7 @@ async function takeBackPerson( await remove(object, { where: { user_id: userId }, multi: true, context }); } await remove('sys_user', { where: { id: userId }, context }); + if (alongside) await alongside(); }; const unit = settlement.grant?.seam ?? deps.createGrant; await (unit ? unit.runAtomically(work) : work()); @@ -544,6 +643,7 @@ export async function runAddSsoUser( ...(outcome.organizationId ? { organizationId: outcome.organizationId } : {}), ...(manager ? manager : {}), host: outcome.host, + ...(outcome.invitation ? { invitation: outcome.invitation } : {}), }, }, }; @@ -566,6 +666,8 @@ export interface ImportSsoUserRowResult { manager?: ManagerOutcome; managerError?: string; host?: EnvironmentUserHostOutcome; + /** The outbox row the invitation was recorded in, and its status. */ + invitation?: InvitationOutcome; } /** @@ -659,6 +761,7 @@ export async function runImportSsoUsers( alreadyPending: outcome.alreadyPending, ...(notApplied.length > 0 ? { notApplied } : {}), host: outcome.host, + ...(outcome.invitation ? { invitation: outcome.invitation } : {}), }); } @@ -683,3 +786,145 @@ export async function runImportSsoUsers( }, }; } + +const REMOVE_KEYS = new Set(['userId']); + +/** + * `POST /api/v1/auth/admin/remove-sso-user` — `{ userId }`. Removes a person + * who is still pending (the email-typo case) and cancels their invitation: + * the hosting rulings' "a pending row that never accepts … can be deleted, + * which cancels the invitation". The caller already passed the platform-admin + * gate. + * + * Refused for any row that is not pending (`409`): a person who has signed in + * is deactivated instead. The host is asked first, outside any transaction + * (`userRemoved`, or `userDeactivated` on a host without it), so its typed + * refusal leaves the person where they are. Then the person's positions, + * permission sets, membership and row are removed as the system, with the + * outbox row recording the cancellation, in one unit of work, through the + * engine's delete, so a record that points at the person follows its lookup's + * `deleteBehavior`: a `restrict` refuses the removal with the engine's own + * answer and nothing is removed. A host that could not be reached does not + * block the removal: the cancellation is queued and retried. With no host + * wired nothing is called and no row is written. + */ +export async function runRemoveSsoUser( + deps: PendingSsoUserDeps, + actor: AdminActor & EnvironmentUserActor, + request: Request, +): Promise { + if (!deps.isCloudManaged()) { + return fail(PENDING_SSO_REFUSAL_STATUS, PENDING_SSO_REFUSAL_CODE, PENDING_SSO_MESSAGES.notManagedRemove); + } + const reading = await readJsonRequestBody(request); + if (!reading.ok) return badRequest(reading.message); + const body = (reading.body && typeof reading.body === 'object' ? reading.body : {}) as Record; + const unknownKeys = Object.keys(body).filter((key) => !REMOVE_KEYS.has(key)); + if (unknownKeys.length > 0) return badRequest(`Unknown field(s): ${unknownKeys.join(', ')}. This door takes userId.`); + const userId = typeof body.userId === 'string' ? body.userId.trim() : ''; + if (!userId) return badRequest('userId is required'); + + const engine = deps.getDataEngine(); + if (!engine) return fail(503, 'SERVICE_UNAVAILABLE', 'Data engine unavailable, so no one was removed.'); + const rows = await engine.find('sys_user', { + where: { id: userId }, + fields: ['id', 'email', 'name', 'source'], + limit: 1, + context: SYSTEM_CTX, + }); + const target = (Array.isArray(rows) ? rows[0] : undefined) as + | { id?: unknown; email?: unknown; name?: unknown; source?: unknown } + | undefined; + if (!target) return fail(404, 'RESOURCE_NOT_FOUND', 'User not found'); + if (!isPendingSsoSource(target.source)) { + return fail(PENDING_SSO_REFUSAL_STATUS, PENDING_SSO_REFUSAL_CODE, PENDING_SSO_MESSAGES.removeNotPending); + } + const email = typeof target.email === 'string' ? target.email : ''; + const name = typeof target.name === 'string' ? target.name : ''; + + // The host first, outside any transaction: a refusal leaves the person as they are. + let host: EnvironmentUserHostOutcome | undefined; + let event: EnvironmentUserEvent | undefined; + const deliveryId = newOutboxId(); + if (deps.host) { + event = { + userId, + email, + name, + source: PENDING_SSO_SOURCE, + ...(await environmentUserAttribution(engine, actor, deps.logger)), + occurredAt: new Date().toISOString(), + }; + const answer = await notifyEnvironmentUserHost(deps.host, 'removed', { ...event, deliveryId }, deps.logger); + if ('refused' in answer) return hostRefusal(answer); + host = answer; + } + // A row records the call whenever the host was called; `no_host` means it was not. + const recorded = event && host && !(!host.notified && host.reason === 'no_host') ? event : undefined; + const birth = host?.notified + ? ({ status: 'sent' } as const) + : ({ status: 'pending', lastError: 'The hosting organisation could not be reached, or failed to take the call.' } as const); + + try { + await takeBackPerson(deps, engine, userId, {}, async () => { + if (!recorded) return; + const context = await authSystemWriteContext(); + await supersedeOpenOutboxRows(outboxEngine(engine), userId, ['added', 'reactivated']); + await insertOutboxRow(outboxEngine(engine), outboxDoc(deliveryId, 'removed', recorded, birth), context); + }); + } catch (error) { + // The removal did not happen. If the host was already told to cancel the + // invitation, the person is pending without one: send it again. + const reinvited = recorded ? await reinvite(deps, engine, recorded) : false; + const thrown = resolveThrownHttpError(error, 500); + const cause = thrown.status >= 500 ? INTERNAL_ERROR_MESSAGE : thrown.message; + return fail( + thrown.status, + thrown.code, + [PENDING_SSO_MESSAGES.removeRefused, cause, reinvited ? PENDING_SSO_MESSAGES.removeRefusedReinvited : ''] + .filter(Boolean) + .join(' '), + ); + } + if (recorded && birth.status === 'pending') deps.wakeOutbox?.(outboxNextAttemptAt(1, Date.now())); + + return { + status: 200, + body: { + success: true, + data: { + userId, + email, + removed: true, + ...(host ? { host } : {}), + ...(recorded ? { invitation: { id: deliveryId, status: birth.status } } : {}), + }, + }, + }; +} + +/** + * Queue a fresh invitation for a pending person whose removal failed after + * the host was told to cancel theirs. Answers whether it was queued; a + * failure is logged at `error`: the person stays pending with no invitation. + */ +async function reinvite(deps: PendingSsoUserDeps, engine: PendingSsoUserEngine, event: EnvironmentUserEvent): Promise { + const now = Date.now(); + try { + await insertOutboxRow( + outboxEngine(engine), + outboxDoc(newOutboxId(), 'added', { ...event, occurredAt: new Date(now).toISOString() }, { status: 'queued' }, now), + ); + deps.wakeOutbox?.(now); + return true; + } catch (error) { + const message = + `[AuthPlugin] removing pending user ${event.userId} failed after the hosting organisation was told to cancel ` + + 'their invitation, and a new invitation could not be queued, so they stay pending with no invitation. ' + + `Add them again to send one. Cause: ${error instanceof Error ? error.message : String(error)}`; + const logger = deps.logger as { warn(msg: string): void; error?(msg: string): void } | undefined; + if (logger?.error) logger.error(message); + else logger?.warn(message); + return false; + } +} diff --git a/packages/spec/src/system/constants/platform-object-names.ts b/packages/spec/src/system/constants/platform-object-names.ts index b66cf6552ab..a0e6bf51197 100644 --- a/packages/spec/src/system/constants/platform-object-names.ts +++ b/packages/spec/src/system/constants/platform-object-names.ts @@ -54,6 +54,7 @@ export const PLATFORM_OBJECTS_BY_PACKAGE: Readonly Date: Sun, 15 Nov 2026 20:49:41 +0000 Subject: [PATCH 02/11] feat(plugin-auth): remove door, outbox worker tests, docs and admin sweeps Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF --- content/docs/permissions/authentication.mdx | 41 ++- .../src/auth-route-ledger.conformance.test.ts | 4 + .../plugin-auth/src/auth-route-ledger.ts | 1 + .../src/environment-user-outbox.test.ts | 283 +++++++++++++++++ .../src/environment-user-outbox.ts | 28 +- .../plugin-auth/src/pending-sso-users.test.ts | 296 ++++++++++++++++++ .../plugin-auth/src/pending-sso-users.ts | 10 +- ...in-platform-admin-standing.dogfood.test.ts | 7 + ...min-route-nonadmin-refusal.dogfood.test.ts | 8 + 9 files changed, 658 insertions(+), 20 deletions(-) create mode 100644 packages/plugins/plugin-auth/src/environment-user-outbox.test.ts diff --git a/content/docs/permissions/authentication.mdx b/content/docs/permissions/authentication.mdx index 0ec63634653..f0f2df99636 100644 --- a/content/docs/permissions/authentication.mdx +++ b/content/docs/permissions/authentication.mdx @@ -1308,7 +1308,8 @@ in the directory. A host can be told about people as they come and go: the `environmentUserHost` option of the auth plugin is called after a person is added, and before a -person is deactivated (`admin/ban-user`) or reactivated (`admin/unban-user`). +person is deactivated (`admin/ban-user`), reactivated (`admin/unban-user`) or, +while still pending, removed (`admin/remove-sso-user`). It is never called inside a database transaction. Each event names the administrator who acted, the administrator at the keyboard when the session is an impersonation (`impersonatedBy`), and, when the acting administrator @@ -1324,9 +1325,41 @@ reactivation writes nothing, and a refused add takes that person back out deactivation with `503` and writes nothing, since only the host can say whether the person is an organization owner or admin. It never undoes or blocks an add or a reactivation: the answer carries `host: { notified: false, -reason }`. Adding a person who is still pending again tells the host again -and changes nothing else: positions, permission sets or a manager sent with -it are listed on the answer as `notApplied`; set them on the person's record. +reason }`. Adding a person who is still pending again re-sends their +invitation and changes nothing else: positions, permission sets or a manager +sent with it are listed on the answer as `notApplied`; set them on the +person's record. + +A pending person who never signs in, for example one added with a mistyped +address, can be removed: `POST /api/v1/auth/admin/remove-sso-user` takes +`{ userId }`, removes the person with their positions, permission sets and +membership, and cancels their invitation at the host. The host is asked +first, through its `userRemoved` member; a host without that member is asked +through `userDeactivated` for the pending person instead, which means the same +thing, but a host should implement `userRemoved`. A host's refusal leaves the +person as they are. A person who is not pending (they have signed in, or were +not added this way) is refused with `409`: deactivate them instead. A record +that still points at the person through a lookup that restricts deletes +refuses the removal with that lookup's own answer, and nothing is removed. +Like the add doors, it is platform-admin gated and answers `409` off a managed +environment. + +Every call to the host about a person is recorded in +`sys_environment_user_outbox`, one row per call, readable by platform +administrators. The door still makes the first call itself, so a refusal +reaches the administrator on that request, row by row. A call the host did not +take stays `pending` and is retried in the background with a growing wait (one +minute at first, up to twelve hours), and after twelve attempts it is +`failed`; a refusal that arrives on a retry is `failed` too, with the host's +code and sentence, and the person is left as they are. A failed reactivation +and a failed removal are retried the same way; a deactivation is never +retried, because a deactivation the host did not answer does not happen. The +newest row of a person is their invitation status: `sent`, `accepted` once +their first sign-in clears the pending state, `failed`, or, for a deactivation +or removal, the cancelled invitation. A call can reach the host more than +once, so each carries the row's id as `deliveryId` for the host to drop a +repeat. The add, deactivate, reactivate and remove answers name the row as +`invitation: { id, status }`. `admin/ban-user` and `admin/unban-user` work without the admin plugin: on a deployment without it the ban is written by the platform, and a banned user is diff --git a/packages/plugins/plugin-auth/src/auth-route-ledger.conformance.test.ts b/packages/plugins/plugin-auth/src/auth-route-ledger.conformance.test.ts index 6278391c6d9..9bf3e7c9190 100644 --- a/packages/plugins/plugin-auth/src/auth-route-ledger.conformance.test.ts +++ b/packages/plugins/plugin-auth/src/auth-route-ledger.conformance.test.ts @@ -288,6 +288,10 @@ describe('auth route ledger hygiene', () => { // below holds it to the same proof — better-auth serves no roster. 'POST /api/v1/auth/admin/list-platform-admins', 'POST /api/v1/auth/admin/oauth2/toggle-disabled', + // The pending-person remove door, on the same terms as the two above: + // `auth-plugin.ts` mounts it itself (a `rawApp.post` on the + // `${basePath}/admin/remove-sso-user` template); better-auth serves none. + 'POST /api/v1/auth/admin/remove-sso-user', // [#30958] On this pin's own terms: `auth-plugin.ts` mounts both itself // (`rawApp.post` on the `${basePath}/admin/scim/mint-credential` and // `${basePath}/admin/scim/revoke-credential` templates, ahead of the diff --git a/packages/plugins/plugin-auth/src/auth-route-ledger.ts b/packages/plugins/plugin-auth/src/auth-route-ledger.ts index 3e1d13fe2b4..13aaafdde5b 100644 --- a/packages/plugins/plugin-auth/src/auth-route-ledger.ts +++ b/packages/plugins/plugin-auth/src/auth-route-ledger.ts @@ -260,6 +260,7 @@ export const AUTH_ROUTE_LEDGER: readonly AuthRouteLedgerEntry[] = [ // #16678 note below. { route: 'POST /api/v1/auth/admin/add-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; adds one person who signs in only through the hosting organisation identity provider: a sys_user row marked idp_pending (no password, refused a session) with optional positions, permission sets and manager, joined to the organization; 201, or 200 alreadyPending for a person already pending (the host is told again); 409 RESOURCE_CONFLICT off a managed environment or for an address already in use; closed body key set; the environment-user host is told after the write commits, and its answer rides host; platform-admin gated (ADR-0068)' }, { route: 'POST /api/v1/auth/admin/import-sso-users', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; the CSV or JSON twin of admin/add-sso-user (columns email, name, positions, permission_sets, manager_id), at most 500 rows, each judged and written on its own so a bad row fails alone; answers a summary and one result per row; 409 RESOURCE_CONFLICT off a managed environment; platform-admin gated (ADR-0068)' }, + { route: 'POST /api/v1/auth/admin/remove-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; removes a person who is still pending (sys_user.source idp_pending: the email-typo case) with their positions, permission sets and membership, and cancels their invitation at the environment-user host (userRemoved, else userDeactivated), which is asked first so its typed refusal leaves the person as they are; a host that cannot be reached does not block it and the cancellation is retried through sys_environment_user_outbox; body { userId }; 404 RESOURCE_NOT_FOUND for an unknown id; 409 RESOURCE_CONFLICT off a managed environment or for a person who is not pending; a lookup that restricts the delete refuses it with the engine answer; platform-admin gated (ADR-0068)' }, { route: 'POST /api/v1/auth/admin/list-platform-admins', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — the sys_user list_platform_admins action posts it directly from the Users list; answers who holds platform-admin standing (the last-admin guard\'s enumerator, each id confirmed by hasPlatformAdminStanding), served only to a caller who holds that standing; reads no body. ADR-0095 D3' }, { route: 'POST /api/v1/auth/admin/oauth2/toggle-disabled', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — the sys_oauth_application disable/enable actions post it directly; ObjectStack mount closing a vendor gap (better-auth\'s /admin/oauth2/update-client strips `disabled` from its body schema), platform-admin gated (ADR-0068)' }, // #30958 — the tracker id stays HERE and never in the `note` string, per the diff --git a/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts b/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts new file mode 100644 index 00000000000..710a15b4c21 --- /dev/null +++ b/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts @@ -0,0 +1,283 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. +// +// The environment-user outbox (`environment-user-outbox.ts`) on its own: what +// one attempt makes of a row, the claim that keeps two workers off one row, +// the worker's pass (retry, backoff, the last attempt, a refusal on a retry, +// a person who accepted or went away meanwhile), and the trigger that marks +// an invitation accepted. The doors that write the rows are pinned end to end +// in `pending-sso-users.test.ts`. + +import { describe, it, expect, vi } from 'vitest'; +import { + claimOutboxRow, + ENVIRONMENT_USER_OUTBOX_OBJECT, + environmentUserOutboxNextDueAt, + outboxDoc, + outboxSettlement, + OUTBOX_BACKOFF_MS, + OUTBOX_LEASE_MS, + OUTBOX_MAX_ATTEMPTS, + registerOutboxAcceptedTrigger, + runEnvironmentUserOutboxTick, + type EnvironmentUserOutboxRow, +} from './environment-user-outbox'; +import { EnvironmentUserHostRefusal, type EnvironmentUserEvent, type EnvironmentUserHost } from './environment-user-host'; +import { PENDING_SSO_SOURCE } from './pending-sso-marker'; +import { createMemoryEngine } from './impersonation-bearer-rotation.test'; + +const NOW = Date.parse('2026-11-15T12:00:00.000Z'); + +const EVENT: EnvironmentUserEvent = { + userId: 'usr_p', + email: 'pending@example.com', + name: 'Pending', + source: PENDING_SSO_SOURCE, + actorId: 'usr_admin', + actorCloudUserId: 'cloud_admin', + occurredAt: '2026-11-15T11:00:00.000Z', +}; + +function harness(opts: { user?: Record | null; host?: Partial } = {}) { + const engine = createMemoryEngine(); + if (opts.user !== null) { + engine.tables.set('sys_user', [{ id: 'usr_p', email: EVENT.email, source: PENDING_SSO_SOURCE, banned: 0, ...opts.user }]); + } + const calls: Array<{ member: string; event: EnvironmentUserEvent }> = []; + const host: EnvironmentUserHost = { + userAdded: (event) => void calls.push({ member: 'userAdded', event }), + userDeactivated: (event) => void calls.push({ member: 'userDeactivated', event }), + userReactivated: (event) => void calls.push({ member: 'userReactivated', event }), + ...opts.host, + }; + const logger = { warn: vi.fn(), error: vi.fn() }; + const deps = { getDataEngine: () => engine as any, host: () => host, logger, now: () => NOW }; + const rows = () => (engine.tables.get(ENVIRONMENT_USER_OUTBOX_OBJECT) ?? []) as any[]; + const seed = (doc: Record) => engine.tables.set(ENVIRONMENT_USER_OUTBOX_OBJECT, [...rows(), doc]); + const pendingRow = (over: Record = {}) => ({ + ...outboxDoc('row_1', 'added', EVENT, { status: 'pending', lastError: 'down' }, NOW - 120_000), + next_attempt_at: NOW - 1, + ...over, + }); + return { engine, calls, logger, deps, rows, seed, pendingRow }; +} + +describe('what one attempt makes of a row', () => { + it('a call the host took is sent', () => { + const settled = outboxSettlement({ notified: true }, 0, NOW); + expect(settled.status).toBe('sent'); + expect(settled.data).toMatchObject({ attempts: 1, status: 'sent', next_attempt_at: null, claim_token: null }); + }); + + it('a typed refusal is failed at once, with the host\'s code and sentence', () => { + const settled = outboxSettlement({ refused: { status: 403, code: 'DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED', message: 'Cap.' } }, 3, NOW); + expect(settled).toMatchObject({ status: 'failed', exhausted: false }); + expect(settled.data).toMatchObject({ attempts: 4, refusal_code: 'DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED', last_error: 'Cap.' }); + }); + + it('a host that failed is pending again, due after the backoff for its attempt count', () => { + expect(outboxSettlement({ notified: false, reason: 'host_failed' }, 0, NOW).data).toMatchObject({ + status: 'pending', + attempts: 1, + next_attempt_at: NOW + OUTBOX_BACKOFF_MS[0]!, + }); + expect(outboxSettlement({ notified: false, reason: 'host_failed' }, 1, NOW).data.next_attempt_at).toBe(NOW + OUTBOX_BACKOFF_MS[1]!); + // Past the schedule the last wait repeats. + expect(outboxSettlement({ notified: false, reason: 'host_failed' }, 9, NOW).data.next_attempt_at).toBe( + NOW + OUTBOX_BACKOFF_MS[OUTBOX_BACKOFF_MS.length - 1]!, + ); + }); + + it('the last attempt that fails is failed, and says no attempts are left', () => { + const settled = outboxSettlement({ notified: false, reason: 'host_failed' }, OUTBOX_MAX_ATTEMPTS - 1, NOW); + expect(settled).toMatchObject({ status: 'failed', exhausted: true }); + expect(String(settled.data.last_error)).toContain('No attempts are left.'); + }); +}); + +describe('the claim keeps two workers off one row', () => { + it('two workers that both read the row pending: exactly one holds it', async () => { + const h = harness(); + h.seed(h.pendingRow()); + const snapshot = { ...h.rows()[0] } as EnvironmentUserOutboxRow; + + const first = await claimOutboxRow(h.engine as any, snapshot, NOW); + const second = await claimOutboxRow(h.engine as any, snapshot, NOW); + + expect(first).toEqual(expect.any(String)); + expect(second).toBeUndefined(); + expect(h.rows()[0]).toMatchObject({ status: 'in_flight', claim_token: first, claimed_until: NOW + OUTBOX_LEASE_MS }); + }); + + it('two passes over the same due row call the host once', async () => { + const h = harness(); + h.seed(h.pendingRow()); + const [a, b] = await Promise.all([runEnvironmentUserOutboxTick(h.deps), runEnvironmentUserOutboxTick(h.deps)]); + expect(a + b).toBe(1); + expect(h.calls).toHaveLength(1); + expect(h.rows()[0]).toMatchObject({ status: 'sent', attempts: 2 }); + }); + + it('a claim that lapsed is taken again; one still held is left alone', async () => { + const held = harness(); + held.seed(held.pendingRow({ status: 'in_flight', claim_token: 'tok_live', claimed_until: NOW + 60_000 })); + expect(await runEnvironmentUserOutboxTick(held.deps)).toBe(0); + expect(held.calls).toHaveLength(0); + + const lapsed = harness(); + lapsed.seed(lapsed.pendingRow({ status: 'in_flight', claim_token: 'tok_dead', claimed_until: NOW - 1 })); + expect(await runEnvironmentUserOutboxTick(lapsed.deps)).toBe(1); + expect(lapsed.calls).toHaveLength(1); + expect(lapsed.rows()[0]).toMatchObject({ status: 'sent' }); + }); +}); + +describe('the worker\'s pass', () => { + it('sends a due row with the stored event unchanged and the row id as the delivery id', async () => { + const h = harness(); + h.seed(h.pendingRow()); + await runEnvironmentUserOutboxTick(h.deps); + expect(h.calls).toEqual([{ member: 'userAdded', event: { ...EVENT, deliveryId: 'row_1' } }]); + expect(h.rows()[0]).toMatchObject({ status: 'sent', attempts: 2, last_error: null, claim_token: null }); + }); + + it('leaves a row that is not due yet', async () => { + const h = harness(); + h.seed(h.pendingRow({ next_attempt_at: NOW + 1 })); + expect(await runEnvironmentUserOutboxTick(h.deps)).toBe(0); + expect(h.calls).toHaveLength(0); + }); + + it('a host that still fails pushes the row back by the next wait', async () => { + const h = harness({ host: { userAdded: () => Promise.reject(new Error('cloud down')) } }); + h.seed(h.pendingRow()); + await runEnvironmentUserOutboxTick(h.deps); + expect(h.rows()[0]).toMatchObject({ status: 'pending', attempts: 2, next_attempt_at: NOW + OUTBOX_BACKOFF_MS[1]! }); + }); + + it('the last attempt that fails is failed and logged at error, once', async () => { + const h = harness({ host: { userAdded: () => Promise.reject(new Error('cloud down')) } }); + h.seed(h.pendingRow({ attempts: OUTBOX_MAX_ATTEMPTS - 1 })); + await runEnvironmentUserOutboxTick(h.deps); + expect(h.rows()[0]).toMatchObject({ status: 'failed', attempts: OUTBOX_MAX_ATTEMPTS, next_attempt_at: null }); + expect(h.logger.error).toHaveBeenCalledOnce(); + expect(String(h.logger.error.mock.calls[0]![0])).toContain('nothing will retry it'); + }); + + it('a typed refusal on a retry is failed with the host\'s answer, and the person is left as they are', async () => { + const h = harness({ + host: { + userAdded: () => { + throw new EnvironmentUserHostRefusal(403, 'DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED', 'The member cap is reached.'); + }, + }, + }); + h.seed(h.pendingRow()); + await runEnvironmentUserOutboxTick(h.deps); + expect(h.rows()[0]).toMatchObject({ + status: 'failed', + refusal_code: 'DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED', + last_error: 'The member cap is reached.', + }); + expect(h.engine.tables.get('sys_user')).toEqual([expect.objectContaining({ id: 'usr_p', source: PENDING_SSO_SOURCE })]); + }); + + it('an invitation for a person who signed in meanwhile is accepted, and the host is not called', async () => { + const h = harness({ user: { source: 'idp_provisioned' } }); + h.seed(h.pendingRow()); + await runEnvironmentUserOutboxTick(h.deps); + expect(h.calls).toHaveLength(0); + expect(h.rows()[0]).toMatchObject({ status: 'accepted', accepted_at: new Date(NOW).toISOString() }); + }); + + it('an invitation for a person who is gone is superseded, and the host is not called', async () => { + const h = harness({ user: null }); + h.seed(h.pendingRow()); + await runEnvironmentUserOutboxTick(h.deps); + expect(h.calls).toHaveLength(0); + expect(h.rows()[0]).toMatchObject({ status: 'superseded' }); + }); + + it('a reactivation for a person deactivated again meanwhile is superseded; CONTROL: an active one is sent', async () => { + const banned = harness({ user: { banned: 1 } }); + banned.seed(banned.pendingRow({ kind: 'reactivated' })); + await runEnvironmentUserOutboxTick(banned.deps); + expect(banned.calls).toHaveLength(0); + expect(banned.rows()[0]).toMatchObject({ status: 'superseded' }); + + const active = harness({ user: { banned: 0, source: 'idp_provisioned' } }); + active.seed(active.pendingRow({ kind: 'reactivated' })); + await runEnvironmentUserOutboxTick(active.deps); + expect(active.calls.map((c) => c.member)).toEqual(['userReactivated']); + }); + + it('a removal is sent on userRemoved, or on userDeactivated by a host without it', async () => { + const removed = vi.fn(); + const own = harness({ user: null, host: { userRemoved: removed } }); + own.seed(own.pendingRow({ kind: 'removed' })); + await runEnvironmentUserOutboxTick(own.deps); + expect(removed).toHaveBeenCalledOnce(); + expect(own.calls).toHaveLength(0); + + const fallback = harness({ user: null }); + fallback.seed(fallback.pendingRow({ kind: 'removed' })); + await runEnvironmentUserOutboxTick(fallback.deps); + expect(fallback.calls.map((c) => c.member)).toEqual(['userDeactivated']); + expect(fallback.calls[0]!.event.source).toBe(PENDING_SSO_SOURCE); + expect(fallback.rows()[0]).toMatchObject({ status: 'sent' }); + }); + + it('the next due time is the earliest pending row or lapsing claim; none answers null', async () => { + const h = harness(); + expect(await environmentUserOutboxNextDueAt(h.deps)).toBeNull(); + h.seed(h.pendingRow({ id: 'a', next_attempt_at: NOW + 50_000 })); + h.seed(h.pendingRow({ id: 'b', status: 'in_flight', next_attempt_at: null, claim_token: 't', claimed_until: NOW + 20_000 })); + expect(await environmentUserOutboxNextDueAt(h.deps)).toBe(NOW + 20_000); + }); +}); + +describe('an invitation reads accepted once the person signs in', () => { + function hookHarness() { + const engine = createMemoryEngine() as any; + const hooks: Array<{ event: string; handler: (ctx: any) => Promise; object?: string }> = []; + engine.registerHook = (event: string, handler: any, options?: { object?: string }) => + void hooks.push({ event, handler, object: options?.object }); + const logger = { warn: vi.fn() }; + registerOutboxAcceptedTrigger(engine, { logger }); + const fire = (input: unknown) => hooks.find((h) => h.event === 'afterUpdate' && h.object === 'sys_user')!.handler({ input }); + const rows = () => (engine.tables.get(ENVIRONMENT_USER_OUTBOX_OBJECT) ?? []) as any[]; + return { engine, fire, rows, logger }; + } + + it('the stamp that clears the pending marker marks the person\'s invitation rows accepted and stops a retry', async () => { + const h = hookHarness(); + h.engine.tables.set(ENVIRONMENT_USER_OUTBOX_OBJECT, [ + { id: 'sent', user_id: 'usr_p', kind: 'added', status: 'sent' }, + { id: 'retry', user_id: 'usr_p', kind: 'added', status: 'pending', next_attempt_at: NOW }, + { id: 'old', user_id: 'usr_p', kind: 'added', status: 'superseded' }, + { id: 'other', user_id: 'usr_q', kind: 'added', status: 'sent' }, + ]); + await h.fire({ id: 'usr_p', data: { id: 'usr_p', source: 'idp_provisioned' } }); + expect(Object.fromEntries(h.rows().map((r) => [r.id, r.status]))).toEqual({ + sent: 'accepted', + retry: 'accepted', + old: 'superseded', + other: 'sent', + }); + expect(h.rows().find((r) => r.id === 'retry').next_attempt_at).toBeNull(); + }); + + it('CONTROL: an update that leaves the marker, or does not touch source, changes nothing', async () => { + const h = hookHarness(); + h.engine.tables.set(ENVIRONMENT_USER_OUTBOX_OBJECT, [{ id: 'sent', user_id: 'usr_p', kind: 'added', status: 'sent' }]); + await h.fire({ id: 'usr_p', data: { source: PENDING_SSO_SOURCE } }); + await h.fire({ id: 'usr_p', data: { name: 'Renamed' } }); + expect(h.rows()[0].status).toBe('sent'); + }); + + it('a mark that fails is logged and never fails the sign-in', async () => { + const h = hookHarness(); + h.engine.update = () => Promise.reject(new Error('store down')); + await expect(h.fire({ id: 'usr_p', data: { source: 'idp_provisioned' } })).resolves.toBeUndefined(); + expect(h.logger.warn).toHaveBeenCalledOnce(); + }); +}); diff --git a/packages/plugins/plugin-auth/src/environment-user-outbox.ts b/packages/plugins/plugin-auth/src/environment-user-outbox.ts index 2bc55933c16..d6b30ff2767 100644 --- a/packages/plugins/plugin-auth/src/environment-user-outbox.ts +++ b/packages/plugins/plugin-auth/src/environment-user-outbox.ts @@ -407,19 +407,23 @@ export async function runEnvironmentUserOutboxTick(deps: EnvironmentUserOutboxDe const engine = deps.getDataEngine(); if (!engine) return 0; const now = deps.now?.() ?? Date.now(); - const due = await engine.find(ENVIRONMENT_USER_OUTBOX_OBJECT, { - where: { - $or: [ - { status: 'pending', next_attempt_at: { $lte: now } }, - { status: 'in_flight', claimed_until: { $lt: now } }, - ], - }, - orderBy: [{ field: 'next_attempt_at', order: 'asc' }], - limit: OUTBOX_TICK_LIMIT, - context: SYSTEM_CTX, - }); + // Two reads, not one `$or`: rows that came due, then rows whose claim lapsed + // (a process that died mid-call). + const read = async (where: Record, field: string): Promise => { + const rows = await engine.find(ENVIRONMENT_USER_OUTBOX_OBJECT, { + where, + orderBy: [{ field, order: 'asc' }], + limit: OUTBOX_TICK_LIMIT, + context: SYSTEM_CTX, + }); + return Array.isArray(rows) ? rows : []; + }; + const due = [ + ...(await read({ status: 'pending', next_attempt_at: { $lte: now } }, 'next_attempt_at')), + ...(await read({ status: 'in_flight', claimed_until: { $lt: now } }, 'claimed_until')), + ].slice(0, OUTBOX_TICK_LIMIT); let held = 0; - for (const raw of Array.isArray(due) ? due : []) { + for (const raw of due) { const row = readRow(raw); if (!row) continue; const token = await claimOutboxRow(engine, row, now); diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.test.ts b/packages/plugins/plugin-auth/src/pending-sso-users.test.ts index 102a652d1e8..3a445e03c50 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.test.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.test.ts @@ -1160,3 +1160,299 @@ describe('[#33759] Ban / Unban are offered and work without the admin plugin', ( expect(offeredOn(on, 'impersonate_user', on.row(EMAILS.member)!)).toBe(true); }); }); + +// ───────────────────────────────────────────────────────────────────────────── +// Removing a pending person, and the outbox every host call is recorded in +// ───────────────────────────────────────────────────────────────────────────── + +const outboxRows = (s: Awaited>) => + ((s.engine.tables.get('sys_environment_user_outbox') ?? []) as any[]); + +/** A recording host with a `userRemoved` member, unless `withRemoved` is false. */ +function removingHost(opts: { withRemoved?: boolean; removed?: () => void } = {}) { + const told: Array<{ kind: string; event: EnvironmentUserEvent }> = []; + const host: EnvironmentUserHost = { + userAdded: (event) => void told.push({ kind: 'added', event }), + userDeactivated: (event) => void told.push({ kind: 'deactivated', event }), + userReactivated: (event) => void told.push({ kind: 'reactivated', event }), + ...(opts.withRemoved === false + ? {} + : { + userRemoved: (event: EnvironmentUserEvent) => { + told.push({ kind: 'removed', event }); + opts.removed?.(); + }, + }), + }; + return { host, told }; +} + +/** Add one pending person with a position, a permission set and a membership; answers their id. */ +async function addPending(s: Awaited>, email: string): Promise { + const res = await s.fire( + '/admin/add-sso-user', + { email, name: 'Typo', positions: ['sales_rep'], permissionSets: ['crm_user'] }, + s.bearers.admin, + ); + expect(res.status, await res.clone().text()).toBe(201); + return String(s.row(email)!.id); +} + +describe('[#33228] every host call about a person is recorded in the outbox', () => { + it('an add records its invitation sent, under the delivery id the host was told', async () => { + const s = await managedStage(); + const res = await s.fire('/admin/add-sso-user', { email: 'outbox.add@example.com', name: 'Outbox' }, s.bearers.admin); + const body: any = await res.json(); + expect(res.status).toBe(201); + const [row] = outboxRows(s); + expect(row).toMatchObject({ kind: 'added', status: 'sent', attempts: 1, user_id: body.data.userId, email: 'outbox.add@example.com' }); + expect(body.data.invitation).toEqual({ id: row.id, status: 'sent' }); + expect(s.told[0]!.event.deliveryId).toBe(row.id); + expect(JSON.parse(row.event_json)).toMatchObject({ userId: body.data.userId, actorId: s.ids.admin, source: PENDING_SSO_SOURCE }); + }); + + it('a host that fails leaves the invitation pending for the worker, due after the first wait', async () => { + const s = await managedStage({ + host: { + userAdded: () => { + throw new Error('host down'); + }, + userDeactivated: () => {}, + userReactivated: () => {}, + }, + }); + const before = Date.now(); + const body: any = await (await s.fire('/admin/add-sso-user', { email: 'outbox.retry@example.com', name: 'Retry' }, s.bearers.admin)).json(); + expect(body.data.host).toEqual({ notified: false, reason: 'host_failed' }); + const [row] = outboxRows(s); + expect(row).toMatchObject({ status: 'pending', attempts: 1, claim_token: null }); + expect(row.next_attempt_at).toBeGreaterThanOrEqual(before + 60_000); + expect(body.data.invitation).toEqual({ id: row.id, status: 'pending' }); + }); + + it('a member-cap 403 on an add records the refusal; the person is taken back out as before', async () => { + const { host } = refusingHost(MEMBER_CAP, { added: () => true }); + const s = await managedStage({ host }); + await s.fire('/admin/add-sso-user', { email: 'outbox.cap@example.com', name: 'Cap' }, s.bearers.admin); + expect(s.row('outbox.cap@example.com')).toBeUndefined(); + expect(outboxRows(s)).toEqual([expect.objectContaining({ status: 'failed', refusal_code: MEMBER_CAP.code, last_error: MEMBER_CAP.message })]); + }); + + it('a re-add is the re-send: an older invitation still waiting is superseded by a fresh row', async () => { + let fail = true; + const s = await managedStage({ + host: { + userAdded: () => { + if (fail) throw new Error('host down'); + }, + userDeactivated: () => {}, + userReactivated: () => {}, + }, + }); + const email = 'outbox.resend@example.com'; + await s.fire('/admin/add-sso-user', { email, name: 'Resend' }, s.bearers.admin); + fail = false; + const body: any = await (await s.fire('/admin/add-sso-user', { email, name: 'Resend' }, s.bearers.admin)).json(); + expect(body.data.alreadyPending).toBe(true); + expect(outboxRows(s).map((r) => r.status)).toEqual(['superseded', 'sent']); + expect(body.data.invitation).toEqual({ id: outboxRows(s)[1].id, status: 'sent' }); + }); + + it('deactivating a pending person records the cancelled invitation and stops a retry still waiting', async () => { + let fail = true; + const s = await managedStage({ + host: { + userAdded: () => { + if (fail) throw new Error('host down'); + }, + userDeactivated: () => {}, + userReactivated: () => {}, + }, + }); + const id = await addPending(s, 'outbox.deact@example.com'); + fail = false; + const res = await s.fire('/admin/ban-user', { userId: id }, s.bearers.admin); + const body: any = await res.json(); + expect(res.status, JSON.stringify(body)).toBe(200); + expect(outboxRows(s).map((r) => [r.kind, r.status])).toEqual([ + ['added', 'superseded'], + ['deactivated', 'sent'], + ]); + expect(body.data.invitation).toEqual({ id: outboxRows(s)[1].id, status: 'sent' }); + }); + + it('CONTROL: deactivating a person who is not pending records no row', async () => { + const s = await managedStage(); + expect((await s.fire('/admin/ban-user', { userId: s.ids.member }, s.bearers.admin)).status).toBe(200); + expect(outboxRows(s)).toEqual([]); + }); + + it('a reactivation the host did not take goes ahead and is queued for the worker', async () => { + const s = await managedStage({ + host: { + userAdded: () => {}, + userDeactivated: () => {}, + userReactivated: () => { + throw new Error('host down'); + }, + }, + }); + expect((await s.fire('/admin/ban-user', { userId: s.ids.member }, s.bearers.admin)).status).toBe(200); + const body: any = await (await s.fire('/admin/unban-user', { userId: s.ids.member }, s.bearers.admin)).json(); + expect(body.data).toMatchObject({ banned: false, host: { notified: false, reason: 'host_failed' } }); + expect(outboxRows(s)).toEqual([expect.objectContaining({ kind: 'reactivated', status: 'pending', attempts: 1, user_id: s.ids.member })]); + expect(body.data.invitation).toEqual({ id: outboxRows(s)[0].id, status: 'pending' }); + }); + + it('CONTROL: with no host wired nothing is recorded', async () => { + const s = await managedStage({ host: 'none' }); + await s.fire('/admin/add-sso-user', { email: 'outbox.nohost@example.com', name: 'No Host' }, s.bearers.admin); + expect((await s.fire('/admin/ban-user', { userId: s.ids.member }, s.bearers.admin)).status).toBe(200); + expect((await s.fire('/admin/unban-user', { userId: s.ids.member }, s.bearers.admin)).status).toBe(200); + expect(outboxRows(s)).toEqual([]); + }); +}); + +describe('[#33228] admin/remove-sso-user removes a pending person and cancels their invitation', () => { + it('removes the row, its grants and membership, tells the host userRemoved first, and records it', async () => { + const { host, told } = removingHost(); + const s = await managedStage({ host }); + const id = await addPending(s, 'typo@exmaple.com'); + + const res = await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin); + const body: any = await res.json(); + + expect(res.status, JSON.stringify(body)).toBe(200); + expect(body.data).toMatchObject({ userId: id, email: 'typo@exmaple.com', removed: true, host: { notified: true } }); + expect(s.row('typo@exmaple.com')).toBeUndefined(); + for (const table of ['sys_user_position', 'sys_user_permission_set', 'sys_member']) { + expect(s.rowsOf(table, id), table).toHaveLength(0); + } + const removal = told.find((t) => t.kind === 'removed')!; + expect(removal.event).toMatchObject({ userId: id, email: 'typo@exmaple.com', source: PENDING_SSO_SOURCE, actorId: s.ids.admin }); + const row = outboxRows(s).find((r) => r.kind === 'removed'); + expect(row).toMatchObject({ status: 'sent', user_id: id, id: removal.event.deliveryId }); + expect(body.data.invitation).toEqual({ id: row.id, status: 'sent' }); + }); + + it('a host without userRemoved is told userDeactivated for the pending person instead', async () => { + const { host, told } = removingHost({ withRemoved: false }); + const s = await managedStage({ host }); + const id = await addPending(s, 'fallback@example.com'); + + expect((await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)).status).toBe(200); + + expect(told.map((t) => t.kind)).toEqual(['added', 'deactivated']); + expect(told[1]!.event).toMatchObject({ userId: id, source: PENDING_SSO_SOURCE }); + expect(outboxRows(s).find((r) => r.user_id === id && r.kind === 'removed')).toMatchObject({ status: 'sent' }); + }); + + it('refuses a person who is not pending with 409, calls no host and removes no one', async () => { + const { host, told } = removingHost(); + const s = await managedStage({ host }); + for (const userId of [s.ids.member, s.ids.idp]) { + const v = await verdict(await s.fire('/admin/remove-sso-user', { userId }, s.bearers.admin)); + expect(v.status, v.text).toBe(409); + expect(v.code).toBe('RESOURCE_CONFLICT'); + expect(v.message?.split('. ')[0]).toBe(PENDING_SSO_MESSAGES.removeNotPending.split('. ')[0]); + } + expect(s.row(EMAILS.member)).toBeDefined(); + expect(s.row(EMAILS.idp)).toBeDefined(); + expect(told).toEqual([]); + }); + + it('a host\'s typed refusal leaves the person as they are: nothing removed, nothing recorded', async () => { + const { host } = removingHost({ + removed: () => { + throw new EnvironmentUserHostRefusal(409, OWNER_CONFLICT.code, OWNER_CONFLICT.message); + }, + }); + const s = await managedStage({ host }); + const id = await addPending(s, 'refused.remove@example.com'); + + const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)); + + expect(v.status, v.text).toBe(409); + expect(v.code).toBe(OWNER_CONFLICT.code); + expect(v.message).toBe(OWNER_CONFLICT.message); + expect(s.row('refused.remove@example.com')).toBeDefined(); + expect(outboxRows(s).filter((r) => r.kind === 'removed')).toEqual([]); + }); + + it('a host that cannot be reached does not block the removal; the cancellation is queued', async () => { + const { host } = removingHost({ + removed: () => { + throw new Error('host down'); + }, + }); + const s = await managedStage({ host }); + const id = await addPending(s, 'queued.remove@example.com'); + + const body: any = await (await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)).json(); + + expect(body.data).toMatchObject({ removed: true, host: { notified: false, reason: 'host_failed' } }); + expect(s.row('queued.remove@example.com')).toBeUndefined(); + expect(outboxRows(s).find((r) => r.kind === 'removed')).toMatchObject({ status: 'pending', attempts: 1 }); + }); + + it('with no host wired the person is removed, the answer says no_host and nothing is recorded', async () => { + const s = await managedStage({ host: 'none' }); + const id = await addPending(s, 'nohost.remove@example.com'); + const body: any = await (await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)).json(); + expect(body.data).toMatchObject({ removed: true, host: { notified: false, reason: 'no_host' } }); + expect(body.data.invitation).toBeUndefined(); + expect(s.row('nohost.remove@example.com')).toBeUndefined(); + expect(outboxRows(s)).toEqual([]); + }); + + it('a record that restricts the delete refuses it with the engine\'s answer; the person stays and is re-invited', async () => { + const { host } = removingHost(); + const s = await managedStage({ host }); + const id = await addPending(s, 'held@example.com'); + // The engine's delete walk refuses a person a `restrict` lookup still + // points at (`DELETE_RESTRICTED`, 409); this double answers the same. + const realDelete = s.engine.delete.bind(s.engine); + s.engine.delete = async (name: string, q: any = {}) => { + if (name === 'sys_user') { + throw Object.assign(new Error('This User cannot be deleted because an Approval Rule still refers to it.'), { + code: 'DELETE_RESTRICTED', + status: 409, + }); + } + return realDelete(name, q); + }; + + const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)); + + expect(v.status, v.text).toBe(409); + expect(v.code).toBe('DELETE_RESTRICTED'); + expect(v.message).toBe( + `${PENDING_SSO_MESSAGES.removeRefused} This User cannot be deleted because an Approval Rule still refers to it. ` + + PENDING_SSO_MESSAGES.removeRefusedReinvited, + ); + expect(s.row('held@example.com')).toMatchObject({ source: PENDING_SSO_SOURCE }); + expect(outboxRows(s).filter((r) => r.kind === 'removed')).toEqual([]); + expect(outboxRows(s).filter((r) => r.kind === 'added').map((r) => r.status)).toEqual(['sent', 'pending']); + }); + + it('refuses an unknown id 404, a missing id or an unknown key 400, and a non-admin 403', async () => { + const s = await managedStage(); + const unknown = await verdict(await s.fire('/admin/remove-sso-user', { userId: 'usr_nobody' }, s.bearers.admin)); + expect([unknown.status, unknown.code]).toEqual([404, 'RESOURCE_NOT_FOUND']); + const missing = await verdict(await s.fire('/admin/remove-sso-user', {}, s.bearers.admin)); + expect([missing.status, missing.code]).toEqual([400, 'INVALID_REQUEST']); + const extra = await verdict(await s.fire('/admin/remove-sso-user', { userId: s.ids.member, email: 'x@example.com' }, s.bearers.admin)); + expect([extra.status, extra.code]).toEqual([400, 'INVALID_REQUEST']); + const id = await addPending(s, 'guarded@example.com'); + const member = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.member)); + expect([member.status, member.code]).toEqual([403, 'PERMISSION_DENIED']); + expect(s.row('guarded@example.com')).toBeDefined(); + }); + + it('CONTROL: off a managed environment it answers 409 and removes no one', async () => { + const s = await stage(); + const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: s.ids.member }, s.bearers.admin)); + expect([v.status, v.code, v.message]).toEqual([409, 'RESOURCE_CONFLICT', PENDING_SSO_MESSAGES.notManagedRemove]); + expect(s.row(EMAILS.member)).toBeDefined(); + }); +}); diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.ts b/packages/plugins/plugin-auth/src/pending-sso-users.ts index 99cdf480a67..0e131debb84 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.ts @@ -843,7 +843,7 @@ export async function runRemoveSsoUser( const name = typeof target.name === 'string' ? target.name : ''; // The host first, outside any transaction: a refusal leaves the person as they are. - let host: EnvironmentUserHostOutcome | undefined; + let host: EnvironmentUserHostOutcome; let event: EnvironmentUserEvent | undefined; const deliveryId = newOutboxId(); if (deps.host) { @@ -858,10 +858,12 @@ export async function runRemoveSsoUser( const answer = await notifyEnvironmentUserHost(deps.host, 'removed', { ...event, deliveryId }, deps.logger); if ('refused' in answer) return hostRefusal(answer); host = answer; + } else { + host = { notified: false, reason: 'no_host' }; } // A row records the call whenever the host was called; `no_host` means it was not. - const recorded = event && host && !(!host.notified && host.reason === 'no_host') ? event : undefined; - const birth = host?.notified + const recorded = event && !(!host.notified && host.reason === 'no_host') ? event : undefined; + const birth = host.notified ? ({ status: 'sent' } as const) : ({ status: 'pending', lastError: 'The hosting organisation could not be reached, or failed to take the call.' } as const); @@ -896,7 +898,7 @@ export async function runRemoveSsoUser( userId, email, removed: true, - ...(host ? { host } : {}), + host, ...(recorded ? { invitation: { id: deliveryId, status: birth.status } } : {}), }, }, diff --git a/packages/qa/dogfood/test/admin-platform-admin-standing.dogfood.test.ts b/packages/qa/dogfood/test/admin-platform-admin-standing.dogfood.test.ts index f8a0e33d20b..fe7099979b2 100644 --- a/packages/qa/dogfood/test/admin-platform-admin-standing.dogfood.test.ts +++ b/packages/qa/dogfood/test/admin-platform-admin-standing.dogfood.test.ts @@ -263,6 +263,10 @@ const ADMITTED = [ // `pending-sso-users.test.ts`. 'POST /api/v1/auth/admin/add-sso-user', 'POST /api/v1/auth/admin/import-sso-users', + // Remove a pending person (cancels their invitation): the same gate first, + // and off a managed environment the same `409 RESOURCE_CONFLICT`; its effect + // is pinned in plugin-auth's `pending-sso-users.test.ts`. + 'POST /api/v1/auth/admin/remove-sso-user', 'POST /api/v1/auth/admin/oauth2/toggle-disabled', 'POST /api/v1/auth/admin/impersonate-user', 'POST /api/v1/auth/admin/sso/register', @@ -760,6 +764,9 @@ describe('#9482: what an ObjectStack platform admin gets from every /admin/ rout 'POST /api/v1/auth/admin/import-sso-users': { body: { rows: [{ email: 'standing.sweep.pending.import@example.com', name: 'Sweep Pending Import' }] }, }, + // A valid remove body naming a person who is not pending, so even a + // managed boot would refuse it 409 and remove no one. + 'POST /api/v1/auth/admin/remove-sso-user': { body: { userId: targetUserId } }, // #16678. The CLEAR, not a set: it is idempotent, so the sweep leaves // `manager_id` as it found it, and it still reaches a 2xx rather than a // semantic error — measured 200 `{"success":true,...,"managerId":null}`. diff --git a/packages/qa/dogfood/test/admin-route-nonadmin-refusal.dogfood.test.ts b/packages/qa/dogfood/test/admin-route-nonadmin-refusal.dogfood.test.ts index e1bdf3b750e..7a533ec8db2 100644 --- a/packages/qa/dogfood/test/admin-route-nonadmin-refusal.dogfood.test.ts +++ b/packages/qa/dogfood/test/admin-route-nonadmin-refusal.dogfood.test.ts @@ -287,6 +287,14 @@ function expectationsFor(targetUserId: string): Record body: { rows: [{ email: 'refusal.probe.pending.import@example.com', name: 'Pending Import Probe' }] }, note: 'the gate runs first; off a managed environment the admin gets 409 RESOURCE_CONFLICT and no one is imported', }, + // The pending-person remove door: the same gate first, the same 409 off a + // managed environment. The probe names a person who is not pending, so a + // managed boot would refuse it 409 too and remove no one. + 'POST /api/v1/auth/admin/remove-sso-user': { + bucket: 'objectstack-gate', + body: { userId: targetUserId }, + note: 'the gate runs first; off a managed environment the admin gets 409 RESOURCE_CONFLICT and no one is removed', + }, // ── ADR-0095 D3 — the platform-admin roster (a read; no body is read) ─── 'POST /api/v1/auth/admin/list-platform-admins': { bucket: 'objectstack-gate', From 67b5beb0f24cdb85eb10bb2490987c7963a91a72 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 20:56:44 +0000 Subject: [PATCH 03/11] chore(changeset): remove pending person and environment-user outbox Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF --- .changeset/33228-remove-pending-outbox.md | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .changeset/33228-remove-pending-outbox.md diff --git a/.changeset/33228-remove-pending-outbox.md b/.changeset/33228-remove-pending-outbox.md new file mode 100644 index 00000000000..e0207d00bd4 --- /dev/null +++ b/.changeset/33228-remove-pending-outbox.md @@ -0,0 +1,26 @@ +--- +'@objectstack/plugin-auth': patch +'@objectstack/platform-objects': patch +'@objectstack/spec': patch +'@objectstack/cli': patch +--- + +feat(auth): a cloud-managed environment can remove a pending person, cancelling their invitation, and every call to the environment-user host is retried from a durable outbox + +Clause-②: yes (widening) — added: `POST /api/v1/auth/admin/remove-sso-user` (platform administrators, cloud-managed environments only) removes a person who is still pending (`sys_user.source = 'idp_pending'`) and cancels their invitation at the host; the environment-user host contract gains an optional `userRemoved` member and an optional `deliveryId` on every event; the add, import, ban and unban answers gain an optional `invitation: { id, status }`; a new read-only system object `sys_environment_user_outbox` records each call. Nothing that was accepted is refused, and no existing answer field changes. +Metadata-protocol: none + +On a cloud-managed environment, a person added to sign in through the hosting organisation's identity provider stays pending until their first sign-in. Before this change a pending person with a typo in their email could only be deactivated, and a host call that failed (a network error, a host outage) was logged and lost. + +**Removing a pending person.** `POST /api/v1/auth/admin/remove-sso-user` with `{ "userId": "…" }` asks the host first, then removes the person in one unit of work: + +- The host is told through `userRemoved`. A host without it is told through `userDeactivated` with `source: 'idp_pending'`, which already means "cancel the invitation". A host should implement `userRemoved`. +- A host refusal (403/409) answers with the host's sentence, and no one is removed. +- A host that cannot be reached does not block the removal. The cancellation is queued and retried. +- With no host wired, the person is removed and the answer says `host: { notified: false, reason: 'no_host' }`. +- A person who is not pending answers `409`: deactivate them instead. A person that other records still point at (`deleteBehavior: 'restrict'`) answers the engine's refusal, and nothing is removed. If the host had already cancelled the invitation, a re-send is queued so they stay pending as before. +- On an environment that is not cloud-managed the door answers `409` and removes no one. + +**Outbox.** Every call to the host about a person (invited, deactivated while pending, re-sent on reactivation, removed) writes a row to `sys_environment_user_outbox`. The door that acts still makes the first call itself, outside any database transaction, so a typed refusal (such as the developer member cap) still reaches the administrator on that request. A call the host did not take stays `pending` and a worker retries it, backing off from one minute to twelve hours, until the host takes it or twelve attempts fail (`failed`, logged as an error). A typed refusal on a retry ends the row as `failed` with the host's code and sentence, and the person stays pending. The worker starts only on a cloud-managed environment with a host wired. Each call carries the row id as `deliveryId`, so a host can drop a repeat. The newest row of a person is their invitation status, which Setup → Users reads through the data API (`get` / `list`, platform administrators only). An `added` row becomes `accepted` when the person first signs in. + +Nothing to migrate. A host that ignores `deliveryId` keeps working: repeats of the same call already happen today when a person is re-added. From e1f116425c2cef5480bf5abf1620f0e2467429f0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 20:56:44 +0000 Subject: [PATCH 04/11] chore(platform-objects): regenerate translation bundles for the environment-user outbox object Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF --- .../apps/translations/ar.objects.generated.ts | 86 +++++++++++++++++++ .../ar.source-hashes.generated.ts | 42 +++++++++ .../apps/translations/de.objects.generated.ts | 86 +++++++++++++++++++ .../de.source-hashes.generated.ts | 42 +++++++++ .../apps/translations/en.objects.generated.ts | 86 +++++++++++++++++++ .../translations/es-ES.objects.generated.ts | 86 +++++++++++++++++++ .../es-ES.source-hashes.generated.ts | 42 +++++++++ .../apps/translations/fr.objects.generated.ts | 86 +++++++++++++++++++ .../fr.source-hashes.generated.ts | 42 +++++++++ .../translations/ja-JP.objects.generated.ts | 86 +++++++++++++++++++ .../ja-JP.source-hashes.generated.ts | 42 +++++++++ .../apps/translations/ko.objects.generated.ts | 86 +++++++++++++++++++ .../ko.source-hashes.generated.ts | 42 +++++++++ .../translations/pt-BR.objects.generated.ts | 86 +++++++++++++++++++ .../pt-BR.source-hashes.generated.ts | 42 +++++++++ .../apps/translations/ru.objects.generated.ts | 86 +++++++++++++++++++ .../ru.source-hashes.generated.ts | 42 +++++++++ .../translations/zh-CN.objects.generated.ts | 86 +++++++++++++++++++ .../zh-CN.source-hashes.generated.ts | 42 +++++++++ .../translations/zh-Hant.objects.generated.ts | 86 +++++++++++++++++++ .../zh-Hant.source-hashes.generated.ts | 42 +++++++++ 21 files changed, 1366 insertions(+) diff --git a/packages/platform-objects/src/apps/translations/ar.objects.generated.ts b/packages/platform-objects/src/apps/translations/ar.objects.generated.ts index 55e6d0fcdcf..55805199c4f 100644 --- a/packages/platform-objects/src/apps/translations/ar.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.objects.generated.ts @@ -3098,6 +3098,92 @@ export const arObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "حدث الإشعار", pluralLabel: "أحداث الإشعارات", diff --git a/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts index 95fadcc230d..8e99de2eb71 100644 --- a/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts @@ -27,6 +27,48 @@ export const arGeneratedSourceHashes: Readonly> = { "objects.sys_email.fields.message_id.label": "14cd089a4062f4b1", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", + "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", + "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", + "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", + "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", + "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", + "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", + "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", + "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", + "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", + "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", + "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", + "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", + "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", + "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", + "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", + "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", + "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", + "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", + "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", + "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", + "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", + "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", + "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", + "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", + "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", + "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", + "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", + "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", + "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", + "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", + "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", + "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", + "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", + "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", + "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", + "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", + "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", + "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", + "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_job.fields.schedule_type.options.cron": "fd48d0e2cd59cab2", "objects.sys_metadata_commit.description": "6a8e29c0ce6345a2", diff --git a/packages/platform-objects/src/apps/translations/de.objects.generated.ts b/packages/platform-objects/src/apps/translations/de.objects.generated.ts index ff148fd61b1..d82faaf65be 100644 --- a/packages/platform-objects/src/apps/translations/de.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.objects.generated.ts @@ -3098,6 +3098,92 @@ export const deObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "Benachrichtigungsereignis", pluralLabel: "Benachrichtigungsereignisse", diff --git a/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts index cf91687b0df..d791c436f79 100644 --- a/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts @@ -90,6 +90,48 @@ export const deGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.name.label": "5274417ff1ccaf01", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", + "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", + "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", + "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", + "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", + "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", + "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", + "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", + "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", + "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", + "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", + "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", + "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", + "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", + "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", + "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", + "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", + "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", + "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", + "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", + "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", + "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", + "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", + "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", + "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", + "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", + "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", + "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", + "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", + "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", + "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", + "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", + "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", + "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", + "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", + "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", + "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", + "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", + "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", + "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_exchange_rate.fields.source.options.app": "0c4630a782d594ab", "objects.sys_exchange_rate.fields.source.options.import": "05c80d3a61ec3290", diff --git a/packages/platform-objects/src/apps/translations/en.objects.generated.ts b/packages/platform-objects/src/apps/translations/en.objects.generated.ts index 01dacfa65d8..c678db82dbf 100644 --- a/packages/platform-objects/src/apps/translations/en.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/en.objects.generated.ts @@ -3098,6 +3098,92 @@ export const enObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "Notification Event", pluralLabel: "Notification Events", diff --git a/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts index d3aaa149e99..4b9ade871b1 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts @@ -3098,6 +3098,92 @@ export const esESObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "Notificación", pluralLabel: "Notificaciones", diff --git a/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts index 99c0176fec9..4fe515e110f 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts @@ -25,6 +25,48 @@ export const esESGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", "objects.sys_email_template.fields.variables_json.label": "c2cfff50e8151e3d", + "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", + "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", + "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", + "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", + "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", + "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", + "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", + "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", + "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", + "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", + "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", + "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", + "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", + "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", + "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", + "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", + "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", + "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", + "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", + "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", + "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", + "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", + "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", + "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", + "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", + "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", + "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", + "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", + "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", + "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", + "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", + "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", + "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", + "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", + "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", + "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", + "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", + "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", + "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_exchange_rate.fields.source.options.manual": "c2e7a98c066bec4a", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", diff --git a/packages/platform-objects/src/apps/translations/fr.objects.generated.ts b/packages/platform-objects/src/apps/translations/fr.objects.generated.ts index 06778c96beb..fb20186854e 100644 --- a/packages/platform-objects/src/apps/translations/fr.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.objects.generated.ts @@ -3098,6 +3098,92 @@ export const frObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "Événement de notification", pluralLabel: "Événements de notification", diff --git a/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts index 052e7f2ba4d..676f019077e 100644 --- a/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts @@ -129,6 +129,48 @@ export const frGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", "objects.sys_email_template.fields.reply_to.label": "90ad8f2ca791a95a", "objects.sys_email_template.fields.variables_json.label": "c2cfff50e8151e3d", + "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", + "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", + "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", + "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", + "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", + "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", + "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", + "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", + "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", + "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", + "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", + "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", + "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", + "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", + "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", + "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", + "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", + "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", + "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", + "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", + "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", + "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", + "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", + "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", + "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", + "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", + "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", + "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", + "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", + "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", + "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", + "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", + "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", + "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", + "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", + "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", + "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", + "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", + "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_exchange_rate.fields.source.label": "8fe786e8e29c8cec", "objects.sys_exchange_rate.fields.source.options.import": "05c80d3a61ec3290", diff --git a/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts index bc466437933..9fb50093252 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts @@ -3098,6 +3098,92 @@ export const jaJPObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "通知", pluralLabel: "通知", diff --git a/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts index c539c773da5..e0c7c30a117 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts @@ -24,6 +24,48 @@ export const jaJPGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.id.label": "00b0385c9c152888", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", + "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", + "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", + "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", + "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", + "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", + "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", + "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", + "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", + "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", + "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", + "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", + "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", + "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", + "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", + "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", + "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", + "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", + "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", + "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", + "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", + "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", + "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", + "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", + "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", + "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", + "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", + "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", + "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", + "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", + "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", + "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", + "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", + "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", + "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", + "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", + "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", + "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", + "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", + "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_metadata.fields.bundle_member.help": "6912852b7523f266", diff --git a/packages/platform-objects/src/apps/translations/ko.objects.generated.ts b/packages/platform-objects/src/apps/translations/ko.objects.generated.ts index 44d1c702a5f..784c09a9dac 100644 --- a/packages/platform-objects/src/apps/translations/ko.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.objects.generated.ts @@ -3098,6 +3098,92 @@ export const koObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "알림 이벤트", pluralLabel: "알림 이벤트", diff --git a/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts index f4542414298..bf2fa31b1c2 100644 --- a/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts @@ -28,6 +28,48 @@ export const koGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.id.label": "00b0385c9c152888", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", + "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", + "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", + "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", + "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", + "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", + "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", + "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", + "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", + "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", + "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", + "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", + "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", + "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", + "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", + "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", + "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", + "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", + "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", + "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", + "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", + "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", + "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", + "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", + "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", + "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", + "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", + "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", + "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", + "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", + "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", + "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", + "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", + "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", + "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", + "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", + "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", + "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", + "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", + "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_job.fields.schedule_type.options.cron": "fd48d0e2cd59cab2", diff --git a/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts index 954330ca772..e9405eda7fc 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts @@ -3098,6 +3098,92 @@ export const ptBRObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "Evento de notificação", pluralLabel: "Eventos de notificação", diff --git a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts index dc8b3f44160..c5555ea79dc 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts @@ -53,6 +53,48 @@ export const ptBRGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", "objects.sys_email_template.fields.reply_to.label": "90ad8f2ca791a95a", + "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", + "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", + "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", + "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", + "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", + "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", + "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", + "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", + "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", + "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", + "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", + "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", + "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", + "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", + "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", + "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", + "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", + "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", + "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", + "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", + "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", + "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", + "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", + "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", + "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", + "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", + "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", + "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", + "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", + "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", + "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", + "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", + "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", + "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", + "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", + "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", + "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", + "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", + "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_exchange_rate.fields.source.options.app": "0c4630a782d594ab", "objects.sys_exchange_rate.fields.source.options.manual": "c2e7a98c066bec4a", diff --git a/packages/platform-objects/src/apps/translations/ru.objects.generated.ts b/packages/platform-objects/src/apps/translations/ru.objects.generated.ts index 95f841a0f57..f0dc71b0cc1 100644 --- a/packages/platform-objects/src/apps/translations/ru.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.objects.generated.ts @@ -3098,6 +3098,92 @@ export const ruObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "Событие уведомления", pluralLabel: "События уведомлений", diff --git a/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts index 803c7a5c745..6ee810204a3 100644 --- a/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts @@ -28,6 +28,48 @@ export const ruGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.id.label": "00b0385c9c152888", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", + "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", + "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", + "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", + "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", + "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", + "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", + "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", + "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", + "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", + "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", + "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", + "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", + "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", + "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", + "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", + "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", + "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", + "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", + "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", + "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", + "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", + "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", + "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", + "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", + "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", + "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", + "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", + "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", + "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", + "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", + "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", + "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", + "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", + "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", + "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", + "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", + "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", + "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", + "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_job.fields.schedule_type.options.cron": "fd48d0e2cd59cab2", diff --git a/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts index 713e40bab25..7dbbc10d534 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts @@ -3098,6 +3098,92 @@ export const zhCNObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "通知", pluralLabel: "通知", diff --git a/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts index 5fc27e139ad..e050ab64c84 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts @@ -20,6 +20,48 @@ export const zhCNGeneratedSourceHashes: Readonly> = { "objects.sys_email.fields.message_id.label": "14cd089a4062f4b1", "objects.sys_email_template.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", + "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", + "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", + "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", + "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", + "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", + "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", + "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", + "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", + "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", + "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", + "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", + "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", + "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", + "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", + "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", + "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", + "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", + "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", + "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", + "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", + "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", + "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", + "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", + "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", + "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", + "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", + "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", + "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", + "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", + "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", + "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", + "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", + "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", + "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", + "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", + "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", + "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", + "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_metadata.fields.bundle_member.help": "6912852b7523f266", diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts index b1b707dea97..43df4eab98a 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts @@ -3098,6 +3098,92 @@ export const zhHantObjects: NonNullable = { } } }, + sys_environment_user_outbox: { + label: "Environment User Invitation", + pluralLabel: "Environment User Invitations", + description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", + fields: { + id: { + label: "ID", + help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." + }, + user_id: { + label: "User ID", + help: "The person the call is about. Text, not a lookup: the row outlives a removed person." + }, + email: { + label: "Email", + help: "The person's email address when the call was made." + }, + kind: { + label: "Kind", + help: "What the host is told: an invitation sent, cancelled or re-sent.", + options: { + added: "Invited", + deactivated: "Deactivated", + reactivated: "Reactivated", + removed: "Removed" + } + }, + status: { + label: "Status", + help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", + options: { + pending: "Pending", + in_flight: "Sending", + sent: "Sent", + accepted: "Accepted", + failed: "Failed", + superseded: "Superseded" + } + }, + attempts: { + label: "Attempts", + help: "How many times the host has been called for this row." + }, + next_attempt_at: { + label: "Next Attempt At (ms)", + help: "When a pending row is next tried, in epoch milliseconds." + }, + claimed_until: { + label: "Claimed Until (ms)", + help: "While a call is in flight: when the claim lapses and another worker may try the row again." + }, + claim_token: { + label: "Claim Token", + help: "Names the one claim that holds an in-flight row." + }, + last_attempt_at: { + label: "Last Attempt At" + }, + last_error: { + label: "Last Error", + help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." + }, + refusal_code: { + label: "Refusal Code", + help: "The host's machine code when it refused the call." + }, + event_json: { + label: "Event", + help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." + }, + sent_at: { + label: "Sent At" + }, + accepted_at: { + label: "Accepted At" + } + }, + _views: { + recent: { + label: "Recent" + }, + failed: { + label: "Failed" + } + } + }, sys_notification: { label: "通知", pluralLabel: "通知", diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts index e9a90d643c2..0250e281bc7 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts @@ -20,6 +20,48 @@ export const zhHantGeneratedSourceHashes: Readonly> = { "objects.sys_email.fields.message_id.label": "14cd089a4062f4b1", "objects.sys_email_template.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", + "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", + "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", + "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", + "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", + "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", + "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", + "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", + "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", + "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", + "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", + "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", + "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", + "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", + "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", + "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", + "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", + "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", + "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", + "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", + "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", + "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", + "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", + "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", + "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", + "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", + "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", + "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", + "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", + "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", + "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", + "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", + "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", + "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", + "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", + "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", + "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", + "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", + "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", + "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", + "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_metadata.fields.bundle_member.help": "6912852b7523f266", From f51a0c4fc1e72e5efe70c2095e5836e14894ef8d Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 21:00:27 +0000 Subject: [PATCH 05/11] feat(plugin-auth): boot the environment-user outbox through one gated function Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF --- .../plugins/plugin-auth/src/auth-plugin.ts | 14 ++++----- .../src/environment-user-outbox.test.ts | 30 +++++++++++++++++++ .../src/environment-user-outbox.ts | 17 +++++++++++ 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/packages/plugins/plugin-auth/src/auth-plugin.ts b/packages/plugins/plugin-auth/src/auth-plugin.ts index 6f091765bd8..7f6beed240b 100644 --- a/packages/plugins/plugin-auth/src/auth-plugin.ts +++ b/packages/plugins/plugin-auth/src/auth-plugin.ts @@ -192,9 +192,7 @@ import { import { engineUserBanWriter, type UserBanEngine } from './user-ban-write.js'; import type { EnvironmentUserHostAccessor } from './environment-user-host.js'; import { - registerOutboxAcceptedTrigger, - startEnvironmentUserOutboxWorker, - type EnvironmentUserOutboxEngine, + bootEnvironmentUserOutbox, type EnvironmentUserOutboxWorker, type OutboxHookEngine, } from './environment-user-outbox.js'; @@ -2298,12 +2296,10 @@ export class AuthPlugin implements Plugin { // invitation reads `accepted` once they sign in, and the worker // retries every call the host did not take. Elsewhere no outbox row // is ever written, so neither runs. - const environmentUserHost = this.options.environmentUserHost; - if (environmentUserHost && isCloudManaged() && !this.environmentUserOutbox) { - registerOutboxAcceptedTrigger(engine as unknown as OutboxHookEngine, { logger: ctx.logger }); - this.environmentUserOutbox = startEnvironmentUserOutboxWorker({ - getDataEngine: () => engine as unknown as EnvironmentUserOutboxEngine, - host: environmentUserHost, + if (!this.environmentUserOutbox) { + this.environmentUserOutbox = bootEnvironmentUserOutbox(engine as unknown as OutboxHookEngine, { + host: this.options.environmentUserHost, + isCloudManaged, logger: ctx.logger, }); } diff --git a/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts b/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts index 710a15b4c21..cb1a8f89d46 100644 --- a/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts +++ b/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts @@ -9,6 +9,7 @@ import { describe, it, expect, vi } from 'vitest'; import { + bootEnvironmentUserOutbox, claimOutboxRow, ENVIRONMENT_USER_OUTBOX_OBJECT, environmentUserOutboxNextDueAt, @@ -281,3 +282,32 @@ describe('an invitation reads accepted once the person signs in', () => { expect(h.logger.warn).toHaveBeenCalledOnce(); }); }); + +describe('the outbox boots only on a cloud-managed kernel with a host wired', () => { + function bootHarness() { + const engine = createMemoryEngine() as any; + const hooks: string[] = []; + engine.registerHook = (event: string, _handler: unknown, options?: { object?: string }) => + void hooks.push(`${event}:${options?.object}`); + const host: EnvironmentUserHost = { userAdded: () => {}, userDeactivated: () => {}, userReactivated: () => {} }; + return { engine, hooks, host }; + } + + it('starts the worker and registers the accepted trigger when the kernel is cloud-managed and a host is wired', async () => { + const h = bootHarness(); + const worker = bootEnvironmentUserOutbox(h.engine, { host: () => h.host, isCloudManaged: () => true }); + try { + expect(worker).toBeDefined(); + expect(h.hooks).toEqual(['afterUpdate:sys_user']); + } finally { + await worker?.stop(); + } + }); + + it('does nothing off a cloud-managed kernel, even with a host wired, or with no host', () => { + const h = bootHarness(); + expect(bootEnvironmentUserOutbox(h.engine, { host: () => h.host, isCloudManaged: () => false })).toBeUndefined(); + expect(bootEnvironmentUserOutbox(h.engine, { host: undefined, isCloudManaged: () => true })).toBeUndefined(); + expect(h.hooks).toEqual([]); + }); +}); diff --git a/packages/plugins/plugin-auth/src/environment-user-outbox.ts b/packages/plugins/plugin-auth/src/environment-user-outbox.ts index d6b30ff2767..96729d064e6 100644 --- a/packages/plugins/plugin-auth/src/environment-user-outbox.ts +++ b/packages/plugins/plugin-auth/src/environment-user-outbox.ts @@ -533,3 +533,20 @@ export function registerOutboxAcceptedTrigger(engine: OutboxHookEngine, opts: { } engine.registerHook('afterUpdate', onUpdate, { object: 'sys_user', packageId: OUTBOX_ACCEPTED_PACKAGE_ID }); } + +/** + * Boot the outbox at `kernel:ready`: the accepted trigger and the worker, + * both only on a cloud-managed kernel with a host wired. Elsewhere no door + * writes a row (the doors answer `no_host`, or refuse off a managed + * environment), so there is nothing to mark or retry, and this answers + * `undefined` without touching the engine. + */ +export function bootEnvironmentUserOutbox( + engine: OutboxHookEngine, + opts: { host: EnvironmentUserHostAccessor | undefined; isCloudManaged(): boolean; logger?: OutboxLogger }, +): EnvironmentUserOutboxWorker | undefined { + const host = opts.host; + if (!host || !opts.isCloudManaged()) return undefined; + registerOutboxAcceptedTrigger(engine, { logger: opts.logger }); + return startEnvironmentUserOutboxWorker({ getDataEngine: () => engine, host, logger: opts.logger }); +} From c6435dbe1f288ca55d5c5e0f92a24929feef87ef Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 21:30:52 +0000 Subject: [PATCH 06/11] fix(plugin-auth): keep the outbox field null when the outbox does not boot; refresh the tenancy censuses Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF --- .../docs/permissions/tenant-audit-census.mdx | 40 +++++++++---------- ...08-tenant-audit-write-call-sites.counts.md | 24 ++++++----- .../plugins/plugin-auth/src/auth-plugin.ts | 2 +- scripts/platform-object-tenancy-census.json | 15 +++++-- 4 files changed, 46 insertions(+), 35 deletions(-) diff --git a/content/docs/permissions/tenant-audit-census.mdx b/content/docs/permissions/tenant-audit-census.mdx index 793cd0dfda7..8304192fffb 100644 --- a/content/docs/permissions/tenant-audit-census.mdx +++ b/content/docs/permissions/tenant-audit-census.mdx @@ -132,7 +132,7 @@ are reported as `undecidable` rather than assumed either way. The same holds twice over for the context. An options argument spelled as a literal can be read; one spelled `options`, `{ ...opts }`, or handed through a -forwarding shim cannot, and **59 of the 321 sites are spelled that way**. A +forwarding shim cannot, and **59 of the 328 sites are spelled that way**. A context resolved from an inline literal or a local `const` can be tested for `isSystem`; one arriving from a helper call cannot. @@ -197,10 +197,10 @@ reproduce them. Where it disagrees, it disagrees on the page: | carried figure | where it survives | this census | | :--- | :--- | ---: | -| 175 write call sites | quoted in the merged changeset | **321** | +| 175 write call sites | quoted in the merged changeset | **328** | | 24 carrying no tenant context | quoted in the merged changeset | **3** provable and tenancy-enabled; **32** more whose options argument is unreadable | -| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **226 of 321** decidable, **95** undecidable | -| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 181 decidably elevated, 0 decidably not, 128 undecidable | +| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **233 of 328** decidable, **95** undecidable | +| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 187 decidably elevated, 0 decidably not, 129 undecidable | | 141 and 132, two independent re-derivations | the card that filed this work | — | **The differences are not reconciled, and deliberately so.** The old census's @@ -211,17 +211,17 @@ at any commit. Two structural facts do plausibly widen this reading against any hand or regex one, and both are counted in the generated tables below: the 66 sites reached -through an erased (`any`) receiver, and the 86 that name their object through a +through an erased (`any`) receiver, and the 93 that name their object through a `const` rather than inline. An instrument that read either the way a person does would report a smaller number and would not say so. The fourth row is the one worth flagging to anyone citing it. **The 135 / 77% figure has no surviving corroboration anywhere in the tree.** This census reads -181 of 321 (56%) as decidably elevated, with 128 more whose elevation is a +187 of 328 (57%) as decidably elevated, with 129 more whose elevation is a run-time fact — so the claim is neither confirmed nor refuted, and the honest answer is that a static reading cannot settle it. -⇒ **Cite `3 / 321`, and say what it is**: the sites whose options argument was +⇒ **Cite `3 / 328`, and say what it is**: the sites whose options argument was READ and holds no tenant context, against a decidably tenancy-enabled object. That is the control's provable yield surface. ⛔ Do not cite it as "the sites without tenant context" — **32 further sites** have an options argument this @@ -233,29 +233,29 @@ cannot read, and they are neither in nor out. | what | count | | :--- | ---: | -| write call sites on the application surface | **321** | -| …whose object name is statically decidable | 226 | +| write call sites on the application surface | **328** | +| …whose object name is statically decidable | 233 | | …whose object name is chosen at run time | 95 | -| …against an object with tenancy ENABLED | 219 | +| …against an object with tenancy ENABLED | 226 | | …against an object that declares tenancy off | 7 | -| threading a tenant context | 250 | +| threading a tenant context | 257 | | PROVABLY carrying none (options read, no context key) | **12** | | …of those, against a decidably tenancy-enabled object | **3** | | options argument UNREADABLE — may or may not carry one | 59 | | …of those, against a decidably tenancy-enabled object | 32 | -| threading a decidably ELEVATED (`isSystem`) context | 181 | +| threading a decidably ELEVATED (`isSystem`) context | 187 | | threading a context that is decidably NOT elevated | 0 | -| threading a context whose elevation is a run-time fact | 128 | +| threading a context whose elevation is a run-time fact | 129 | | how the instrument reached the site | count | | :--- | ---: | -| receiver carried a readable engine type | 255 | +| receiver carried a readable engine type | 262 | | receiver erased, placed by the object NAME | 56 | | receiver erased, placed by an `object: string` PARAMETER | 5 | | receiver erased, placed by an `UNTYPED_RECEIVERS` row | 5 | | object name spelled inline | 140 | -| object name spelled through a `const` | 86 | +| object name spelled through a `const` | 93 | | object name is an `object: string` parameter | 10 | | object name is some other run-time expression | 85 | @@ -307,13 +307,13 @@ holds still. They are required to be HERE and to say WHEN they were true; their values are not compared. The reasoning, and the measurement behind it, are in `scripts/check-tenant-audit-census.mjs`. -Measured on 2026-11-15 at `2ab05f460`. +Measured on 2026-11-15 at `f51a0c4fc`. | corpus scale (not enforced) | count | | :--- | ---: | -| tracked non-test sources scanned | 1176 | -| engine-shaped types recognised | 141 | -| declared objects in the registry | 137 | -| same-named calls subtracted as non-engine | 311 | +| tracked non-test sources scanned | 1177 | +| engine-shaped types recognised | 143 | +| declared objects in the registry | 138 | +| same-named calls subtracted as non-engine | 313 | {/* END GENERATED: tenant-audit-census */} diff --git a/docs/audits/2026-08-tenant-audit-write-call-sites.counts.md b/docs/audits/2026-08-tenant-audit-write-call-sites.counts.md index d9225ca889b..9db8157d803 100644 --- a/docs/audits/2026-08-tenant-audit-write-call-sites.counts.md +++ b/docs/audits/2026-08-tenant-audit-write-call-sites.counts.md @@ -33,19 +33,19 @@ silent, and `node scripts/tenant-audit-census.mjs --write` is the resolution. | Measure | Value | |---|---:| -| Write call sites | 321 | -| Object name statically decidable | 226 | +| Write call sites | 328 | +| Object name statically decidable | 233 | | Object name chosen at run time | 95 | -| Against a tenancy-enabled object | 219 | +| Against a tenancy-enabled object | 226 | | Against an object declaring tenancy off | 7 | -| Threading a tenant context | 250 | +| Threading a tenant context | 257 | | Provably carrying none | 12 | | …and decidably tenancy-enabled | 3 | | Options argument unreadable | 59 | | …and decidably tenancy-enabled | 32 | -| Threading a decidably elevated context | 181 | +| Threading a decidably elevated context | 187 | | Threading a decidably non-elevated context | 0 | -| Threading a context of undecidable elevation | 128 | +| Threading a context of undecidable elevation | 129 | ## Subtractions the census could NOT defend — enforced @@ -90,14 +90,14 @@ holds still. They are required to be HERE and to say WHEN they were true; their values are not compared. The reasoning, and the measurement behind it, are in `scripts/check-tenant-audit-census.mjs`. -Measured on 2026-11-15 at `2ab05f460`. +Measured on 2026-11-15 at `f51a0c4fc`. | corpus scale (not enforced) | count | | :--- | ---: | -| tracked non-test sources scanned | 1176 | -| engine-shaped types recognised | 141 | -| declared objects in the registry | 137 | -| same-named calls subtracted as non-engine | 311 | +| tracked non-test sources scanned | 1177 | +| engine-shaped types recognised | 143 | +| declared objects in the registry | 138 | +| same-named calls subtracted as non-engine | 313 | ## Every site @@ -163,6 +163,8 @@ Measured on 2026-11-15 at `2ab05f460`. | `packages/plugins/plugin-auth/src/demo-staff.ts` | `insert` | `sys_user_position` | enabled | elevated | 1 | | `packages/plugins/plugin-auth/src/ensure-default-organization.ts` | `insert` | `object` | undecidable | elevated | 1 | | `packages/plugins/plugin-auth/src/ensure-default-organization.ts` | `update` | `sys_member` | enabled | elevated | 1 | +| `packages/plugins/plugin-auth/src/environment-user-outbox.ts` | `insert` | `sys_environment_user_outbox` | enabled | context, elevation undecidable | 1 | +| `packages/plugins/plugin-auth/src/environment-user-outbox.ts` | `update` | `sys_environment_user_outbox` | enabled | elevated | 6 | | `packages/plugins/plugin-auth/src/forced-reset-revocation.ts` | `update` | `SystemObjectName.API_KEY` | undecidable | elevated | 1 | | `packages/plugins/plugin-auth/src/forced-reset-revocation.ts` | `update` | `SystemObjectName.SESSION` | undecidable | elevated | 1 | | `packages/plugins/plugin-auth/src/idp-group-mapping-admin.ts` | `delete` | `IDP_GROUP_MAPPING_OBJECT` | undecidable | PROVABLY NONE | 1 | diff --git a/packages/plugins/plugin-auth/src/auth-plugin.ts b/packages/plugins/plugin-auth/src/auth-plugin.ts index 7f6beed240b..41dd6fa3e6f 100644 --- a/packages/plugins/plugin-auth/src/auth-plugin.ts +++ b/packages/plugins/plugin-auth/src/auth-plugin.ts @@ -2301,7 +2301,7 @@ export class AuthPlugin implements Plugin { host: this.options.environmentUserHost, isCloudManaged, logger: ctx.logger, - }); + }) ?? null; } try { await refreshAllMappingMatches(engine); diff --git a/scripts/platform-object-tenancy-census.json b/scripts/platform-object-tenancy-census.json index 1342fb8979b..b83c750f5dc 100644 --- a/scripts/platform-object-tenancy-census.json +++ b/scripts/platform-object-tenancy-census.json @@ -26,13 +26,13 @@ "predicate": "resolveTenantFieldName(registered schema) !== null, where the registered schema is the authored schema plus the columns resolveInjectedSystemColumns says the registration injects (the applySystemFields pass). Both functions are loaded from source and executed; neither is re-spelled here.", "population": "every object registered by a tracked packages/**/*.object.ts module whose name carries a platform prefix (sys_ / cloud_ / ai_). The cloud repository's own cloud_ objects are not in this tree and so not in this census.", "totals": { - "registered": 103, + "registered": 104, "inReach": 52, - "outOfReach": 51 + "outOfReach": 52 }, "reasonTotals": { "managedBy: 'better-auth'": 25, - "systemFields.tenant: false": 25, + "systemFields.tenant: false": 26, "tenancy.enabled: false": 3 }, "unexplained": [], @@ -245,6 +245,15 @@ "tenantField": "organization_id", "reasons": [] }, + { + "name": "sys_environment_user_outbox", + "file": "packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts", + "reach": "out", + "tenantField": null, + "reasons": [ + "systemFields.tenant: false" + ] + }, { "name": "sys_exchange_rate", "file": "packages/platform-objects/src/system/sys-exchange-rate.object.ts", From 9bb42bbd4b7d24a192ee77ff4781e7fa87e8a990 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 22:52:29 +0000 Subject: [PATCH 07/11] fix(plugin-auth): hold the environment-user outbox to the invitation rules No invitation is sent to a deactivated person; a removal holds to pending people at the write; calls are recorded only on a cloud-managed kernel, where the worker drains them. Prose says which calls are recorded. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF --- .changeset/33228-remove-pending-outbox.md | 8 +- content/docs/permissions/authentication.mdx | 17 ++- .../sys-environment-user-outbox.object.ts | 11 +- .../plugin-auth/src/admin-ban-endpoints.ts | 14 +- .../plugins/plugin-auth/src/auth-plugin.ts | 40 +++-- .../plugin-auth/src/environment-user-host.ts | 7 +- .../src/environment-user-outbox.test.ts | 22 +++ .../src/environment-user-outbox.ts | 49 ++++-- .../plugin-auth/src/pending-sso-marker.ts | 8 + .../plugin-auth/src/pending-sso-users.test.ts | 101 +++++++++++- .../plugin-auth/src/pending-sso-users.ts | 144 +++++++++++++++--- 11 files changed, 352 insertions(+), 69 deletions(-) diff --git a/.changeset/33228-remove-pending-outbox.md b/.changeset/33228-remove-pending-outbox.md index e0207d00bd4..1f7cb504bff 100644 --- a/.changeset/33228-remove-pending-outbox.md +++ b/.changeset/33228-remove-pending-outbox.md @@ -5,9 +5,9 @@ '@objectstack/cli': patch --- -feat(auth): a cloud-managed environment can remove a pending person, cancelling their invitation, and every call to the environment-user host is retried from a durable outbox +feat(auth): a cloud-managed environment can remove a pending person, cancelling their invitation, and every invitation call to the environment-user host is retried from a durable outbox -Clause-②: yes (widening) — added: `POST /api/v1/auth/admin/remove-sso-user` (platform administrators, cloud-managed environments only) removes a person who is still pending (`sys_user.source = 'idp_pending'`) and cancels their invitation at the host; the environment-user host contract gains an optional `userRemoved` member and an optional `deliveryId` on every event; the add, import, ban and unban answers gain an optional `invitation: { id, status }`; a new read-only system object `sys_environment_user_outbox` records each call. Nothing that was accepted is refused, and no existing answer field changes. +Clause-②: yes (widening) — added: `POST /api/v1/auth/admin/remove-sso-user` (platform administrators, cloud-managed environments only) removes a person who is still pending (`sys_user.source = 'idp_pending'`) and cancels their invitation at the host; the environment-user host contract gains an optional `userRemoved` member and an optional `deliveryId` on every event; the add, import, ban and unban answers gain an optional `invitation: { id, status }`; a new read-only system object `sys_environment_user_outbox` records each invitation call on a cloud-managed environment. Nothing that was accepted is refused, and no existing answer field changes. Metadata-protocol: none On a cloud-managed environment, a person added to sign in through the hosting organisation's identity provider stays pending until their first sign-in. Before this change a pending person with a typo in their email could only be deactivated, and a host call that failed (a network error, a host outage) was logged and lost. @@ -18,9 +18,9 @@ On a cloud-managed environment, a person added to sign in through the hosting or - A host refusal (403/409) answers with the host's sentence, and no one is removed. - A host that cannot be reached does not block the removal. The cancellation is queued and retried. - With no host wired, the person is removed and the answer says `host: { notified: false, reason: 'no_host' }`. -- A person who is not pending answers `409`: deactivate them instead. A person that other records still point at (`deleteBehavior: 'restrict'`) answers the engine's refusal, and nothing is removed. If the host had already cancelled the invitation, a re-send is queued so they stay pending as before. +- A person who is not pending answers `409`: deactivate them instead. This holds at the removal itself, so a person who signs in while the host is asked is not removed. A person that other records still point at (`deleteBehavior: 'restrict'`) answers the engine's refusal, and nothing is removed. The answer says what the host was told. If the host had already taken the cancellation, a re-send is queued for a person who is still pending and not deactivated. A deactivated person is never sent an invitation. - On an environment that is not cloud-managed the door answers `409` and removes no one. -**Outbox.** Every call to the host about a person (invited, deactivated while pending, re-sent on reactivation, removed) writes a row to `sys_environment_user_outbox`. The door that acts still makes the first call itself, outside any database transaction, so a typed refusal (such as the developer member cap) still reaches the administrator on that request. A call the host did not take stays `pending` and a worker retries it, backing off from one minute to twelve hours, until the host takes it or twelve attempts fail (`failed`, logged as an error). A typed refusal on a retry ends the row as `failed` with the host's code and sentence, and the person stays pending. The worker starts only on a cloud-managed environment with a host wired. Each call carries the row id as `deliveryId`, so a host can drop a repeat. The newest row of a person is their invitation status, which Setup → Users reads through the data API (`get` / `list`, platform administrators only). An `added` row becomes `accepted` when the person first signs in. +**Outbox.** On a cloud-managed environment, every invitation call to the host about a person (invited, deactivated while pending, re-sent on reactivation, removed) writes a row to `sys_environment_user_outbox`; the deactivation of a person who has signed in is asked of the host but not recorded, and off a cloud-managed environment nothing is recorded. The door that acts still makes the first call itself, outside any database transaction, so a typed refusal (such as the developer member cap) still reaches the administrator on that request. A call the host did not take stays `pending` and a worker retries it, backing off from one minute to twelve hours, until the host takes it or twelve attempts fail (`failed`, logged as an error). A typed refusal on a retry ends the row as `failed` with the host's code and sentence, and the person stays pending. The worker starts only on a cloud-managed environment with a host wired. Each call carries the row id as `deliveryId`, so a host can drop a repeat; a host cancels by `userId` or `deliveryId`, never by email address. The newest row of a person is their invitation status, which Setup → Users reads through the data API (`get` / `list`, platform administrators only). An `added` row becomes `accepted` when the person first signs in. Nothing to migrate. A host that ignores `deliveryId` keeps working: repeats of the same call already happen today when a person is re-added. diff --git a/content/docs/permissions/authentication.mdx b/content/docs/permissions/authentication.mdx index f0f2df99636..f23172df7f9 100644 --- a/content/docs/permissions/authentication.mdx +++ b/content/docs/permissions/authentication.mdx @@ -1338,15 +1338,20 @@ first, through its `userRemoved` member; a host without that member is asked through `userDeactivated` for the pending person instead, which means the same thing, but a host should implement `userRemoved`. A host's refusal leaves the person as they are. A person who is not pending (they have signed in, or were -not added this way) is refused with `409`: deactivate them instead. A record +not added this way) is refused with `409`: deactivate them instead. That holds +at the removal itself, so a person who signs in while the host is asked is not +removed either, and the answer says the host was already told. A record that still points at the person through a lookup that restricts deletes refuses the removal with that lookup's own answer, and nothing is removed. Like the add doors, it is platform-admin gated and answers `409` off a managed environment. -Every call to the host about a person is recorded in +On a cloud-managed environment these calls are recorded in `sys_environment_user_outbox`, one row per call, readable by platform -administrators. The door still makes the first call itself, so a refusal +administrators: every invitation sent (an add or re-add), every re-send (a +reactivation), and every cancellation (a removal, or the deactivation of a +person still pending). The deactivation of a person who has signed in is asked +of the host but not recorded. The door still makes the first call itself, so a refusal reaches the administrator on that request, row by row. A call the host did not take stays `pending` and is retried in the background with a growing wait (one minute at first, up to twelve hours), and after twelve attempts it is @@ -1358,8 +1363,10 @@ newest row of a person is their invitation status: `sent`, `accepted` once their first sign-in clears the pending state, `failed`, or, for a deactivation or removal, the cancelled invitation. A call can reach the host more than once, so each carries the row's id as `deliveryId` for the host to drop a -repeat. The add, deactivate, reactivate and remove answers name the row as -`invitation: { id, status }`. +repeat. A host cancels an invitation by the event's `userId` or `deliveryId`, never by +its email address, which an administrator may have typed wrong and may type +again for someone else. The add, deactivate, reactivate and remove answers +name the row as `invitation: { id, status }`. `admin/ban-user` and `admin/unban-user` work without the admin plugin: on a deployment without it the ban is written by the platform, and a banned user is diff --git a/packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts b/packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts index d5ff62eaa86..68fe7f1ebdd 100644 --- a/packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts +++ b/packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts @@ -3,11 +3,12 @@ import { ObjectSchema, Field } from '@objectstack/spec/data'; /** - * sys_environment_user_outbox — the durable record of every call the - * environment makes to its environment-user host (the cloud, on a hosted - * environment) about one person: an invitation sent when a pending person is - * added or re-added, cancelled when one is deactivated or removed, and - * re-sent when a person is reactivated. + * sys_environment_user_outbox — on a cloud-managed environment, the durable + * record of the calls the environment makes to its environment-user host (the + * cloud) about one person's invitation: sent when a pending person is added or + * re-added, cancelled when a pending person is deactivated or removed, and + * re-sent when a person is reactivated. The deactivation of a person who has + * signed in is asked of the host but not recorded here. * * Why it exists: the execution terms of the hosting rulings (relayed on the * pending-people card) ask for "a durable outbox with retry … with per-row diff --git a/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts b/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts index 6c9de3e1709..fdaa469f14e 100644 --- a/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts +++ b/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts @@ -117,6 +117,7 @@ import { newOutboxId, outboxDoc, outboxNextAttemptAt, + OUTBOX_UNSENT_STATUSES, supersedeOpenOutboxRows, type OutboxBirth, } from './environment-user-outbox.js'; @@ -149,6 +150,11 @@ export interface AdminBanEndpointDeps { getDataEngine?(): any; /** Wakes the outbox worker for a reactivation queued for retry (`environment-user-outbox.ts`). */ wakeOutbox?(atMs: number): void; + /** + * Whether the kernel is cloud-managed. Only there does the outbox worker + * run, so only there is a call recorded; absent reads as not managed. + */ + isCloudManaged?(): boolean; logger?: { warn(msg: string): void; error?(msg: string, err?: Error): void }; } @@ -188,7 +194,9 @@ async function askHost( occurredAt: new Date().toISOString(), }; const deliveryId = newOutboxId(); - const outcome = await notifyEnvironmentUserHost(deps.host, kind, { ...event, deliveryId }, deps.logger); + const outcome = await notifyEnvironmentUserHost(deps.host, kind, { ...event, deliveryId }, deps.logger, { + retried: deps.isCloudManaged?.() === true, + }); return { outcome, event, deliveryId }; } @@ -205,13 +213,15 @@ async function recordAsk( kind: 'deactivated' | 'reactivated', ask: HostAsk, ): Promise<{ id: string; status: 'sent' | 'pending' } | undefined> { + // Off a cloud-managed kernel no worker drains the outbox, so nothing is recorded. + if (deps.isCloudManaged?.() !== true) return undefined; const engine = deps.getDataEngine?.(); if (!engine || 'refused' in ask.outcome) return undefined; const outcome = ask.outcome; if (!outcome.notified && outcome.reason === 'no_host') return undefined; try { if (kind === 'deactivated') { - await supersedeOpenOutboxRows(engine, ask.event.userId, ['added', 'reactivated']); + await supersedeOpenOutboxRows(engine, ask.event.userId, ['added', 'reactivated'], OUTBOX_UNSENT_STATUSES); if (!outcome.notified || !isPendingSsoSource(ask.event.source)) return undefined; } else { await supersedeOpenOutboxRows(engine, ask.event.userId, ['reactivated']); diff --git a/packages/plugins/plugin-auth/src/auth-plugin.ts b/packages/plugins/plugin-auth/src/auth-plugin.ts index 41dd6fa3e6f..977427036f9 100644 --- a/packages/plugins/plugin-auth/src/auth-plugin.ts +++ b/packages/plugins/plugin-auth/src/auth-plugin.ts @@ -394,12 +394,15 @@ export interface AuthPluginOptions extends Partial { * [#33181] The environment-user host (`environment-user-host.ts`): told * after a person is added through `admin/add-sso-user` or * `admin/import-sso-users`, and asked before a person is deactivated - * through `admin/ban-user` or reactivated through `admin/unban-user`. Read - * per call, so a host wired after boot is still found. A typed - * `EnvironmentUserHostRefusal` refuses the operation (a refused add is - * taken back out); any other failure refuses a deactivation (`503`) and is - * reported on an add or a reactivation as `host: { notified: false, - * reason }`, which it never undoes. + * through `admin/ban-user`, reactivated through `admin/unban-user`, or a + * pending person is removed through `admin/remove-sso-user` (`userRemoved`, + * else `userDeactivated`). Read per call, so a host wired after boot is + * still found. A typed `EnvironmentUserHostRefusal` refuses the operation + * (a refused add is taken back out); any other failure refuses a + * deactivation (`503`) and is reported on an add, a reactivation or a + * removal as `host: { notified: false, reason }`, which it never undoes. + * On a cloud-managed kernel those calls are recorded in the + * environment-user outbox and retried (`environment-user-outbox.ts`). */ environmentUserHost?: EnvironmentUserHostAccessor; @@ -2294,14 +2297,24 @@ export class AuthPlugin implements Plugin { // The environment-user outbox (`environment-user-outbox.ts`): on a // cloud-managed kernel with a host wired, a pending person's // invitation reads `accepted` once they sign in, and the worker - // retries every call the host did not take. Elsewhere no outbox row - // is ever written, so neither runs. + // retries every recorded call the host did not take. The doors + // record only on a cloud-managed kernel, so elsewhere neither runs. + // A boot that fails is logged here, never left to the catch below: + // the rows it would drain wait for the next boot. if (!this.environmentUserOutbox) { - this.environmentUserOutbox = bootEnvironmentUserOutbox(engine as unknown as OutboxHookEngine, { - host: this.options.environmentUserHost, - isCloudManaged, - logger: ctx.logger, - }) ?? null; + try { + this.environmentUserOutbox = bootEnvironmentUserOutbox(engine as unknown as OutboxHookEngine, { + host: this.options.environmentUserHost, + isCloudManaged, + logger: ctx.logger, + }) ?? null; + } catch (e) { + ctx.logger.error( + '[AuthPlugin] the environment-user outbox worker did not start, so invitations and cancellations ' + + 'the hosting organisation did not take are not retried until the next boot. Cause: ' + + `${e instanceof Error ? e.message : String(e)}`, + ); + } } try { await refreshAllMappingMatches(engine); @@ -4951,6 +4964,7 @@ export class AuthPlugin implements Plugin { ...(this.options.environmentUserHost ? { host: this.options.environmentUserHost } : {}), getDataEngine: () => this.authManager!.getDataEngine(), wakeOutbox: this.wakeEnvironmentUserOutbox, + isCloudManaged: () => isCloudManaged(), logger: ctx.logger, }); diff --git a/packages/plugins/plugin-auth/src/environment-user-host.ts b/packages/plugins/plugin-auth/src/environment-user-host.ts index 56d93235e9b..d9a9c7466e0 100644 --- a/packages/plugins/plugin-auth/src/environment-user-host.ts +++ b/packages/plugins/plugin-auth/src/environment-user-host.ts @@ -236,13 +236,16 @@ export async function environmentUserAttribution( /** * Tell the host, once. Never throws. A typed refusal is answered as * `{ refused }` for the door to return; any other failure as `host_failed` - * on the caller's row, logged at `warn` with its message. + * on the caller's row, logged at `warn` with its message. `opts.retried` + * says the caller records the call in the outbox, so the log may say it is + * retried; a caller that records nothing leaves it unset. */ export async function notifyEnvironmentUserHost( accessor: EnvironmentUserHostAccessor | undefined, kind: EnvironmentUserEventKind, event: EnvironmentUserEvent, logger?: { warn(msg: string): void }, + opts: { retried?: boolean } = {}, ): Promise { let host: EnvironmentUserHost | undefined; try { @@ -266,7 +269,7 @@ export async function notifyEnvironmentUserHost( logger?.warn( `[AuthPlugin] the environment-user host refused or failed to take the news that user ${event.userId} was ` + `${kind}. ${goesAhead(kind)} The answer says so. ` - + (kind === 'deactivated' ? '' : 'The call is retried. ') + + (opts.retried && kind !== 'deactivated' ? 'The call is retried. ' : '') + `Cause: ${describe(error)}`, ); return { notified: false, reason: 'host_failed' }; diff --git a/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts b/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts index cb1a8f89d46..1444c1964cc 100644 --- a/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts +++ b/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts @@ -211,6 +211,28 @@ describe('the worker\'s pass', () => { expect(active.calls.map((c) => c.member)).toEqual(['userReactivated']); }); + it('an invitation for a pending person who was deactivated is superseded, waiting or stranded in flight; the host is not called', async () => { + const h = harness({ user: { banned: 1 } }); + h.seed(h.pendingRow()); + h.seed(h.pendingRow({ id: 'row_2', status: 'in_flight', claim_token: 'dead', claimed_until: NOW - 1 })); + await runEnvironmentUserOutboxTick(h.deps); + expect(h.calls).toHaveLength(0); + expect(h.rows().map((r) => r.status)).toEqual(['superseded', 'superseded']); + }); + + it('a cancellation for a person who signed in meanwhile is superseded; CONTROL: one for a person still pending is sent', async () => { + const signedIn = harness({ user: { source: 'idp_provisioned' } }); + signedIn.seed(signedIn.pendingRow({ kind: 'removed' })); + await runEnvironmentUserOutboxTick(signedIn.deps); + expect(signedIn.calls).toHaveLength(0); + expect(signedIn.rows()[0]).toMatchObject({ status: 'superseded' }); + + const pending = harness(); + pending.seed(pending.pendingRow({ kind: 'removed' })); + await runEnvironmentUserOutboxTick(pending.deps); + expect(pending.calls.map((c) => c.member)).toEqual(['userDeactivated']); + }); + it('a removal is sent on userRemoved, or on userDeactivated by a host without it', async () => { const removed = vi.fn(); const own = harness({ user: null, host: { userRemoved: removed } }); diff --git a/packages/plugins/plugin-auth/src/environment-user-outbox.ts b/packages/plugins/plugin-auth/src/environment-user-outbox.ts index 96729d064e6..c45af120919 100644 --- a/packages/plugins/plugin-auth/src/environment-user-outbox.ts +++ b/packages/plugins/plugin-auth/src/environment-user-outbox.ts @@ -2,9 +2,14 @@ /** * The durable outbox of the environment-user host seam - * (`environment-user-host.ts`): every call the environment makes to its host - * about one person is a row of `sys_environment_user_outbox`, and a call the - * host did not take is retried here until it does or the attempts run out. + * (`environment-user-host.ts`). On a cloud-managed kernel these calls about + * one person are rows of `sys_environment_user_outbox`: every invitation sent + * (an add or re-add), every re-send (a reactivation), every cancellation + * (a removal, and the deactivation of a person still pending). A call the host + * did not take is retried here until it does or the attempts run out. The + * deactivation of a person who has signed in is asked of the host but not + * recorded: there is no invitation to show, and a refused deactivation is + * never retried. Off a cloud-managed kernel nothing is recorded. * * ## Why the door still calls first * @@ -68,7 +73,7 @@ import { type EnvironmentUserHostRefused, } from './environment-user-host.js'; -/** The object every call is recorded in. */ +/** The object the recorded calls are kept in (see the module header for which calls). */ export const ENVIRONMENT_USER_OUTBOX_OBJECT = 'sys_environment_user_outbox'; /** The statuses a row moves through. */ @@ -180,20 +185,30 @@ export async function insertOutboxRow( /** * Mark a person's unsent rows of `kinds` `superseded`: a re-send replaces an * older invitation still waiting, and a deactivation or removal stops every - * invitation still waiting, so no stale retry is sent after it. + * invitation still waiting, so no stale retry is sent after it. A + * deactivation or removal also passes `in_flight`: a row whose sender died + * holds a claim that lapses, and it must not be sent once it does. */ export async function supersedeOpenOutboxRows( engine: EnvironmentUserOutboxEngine, userId: string, kinds: readonly EnvironmentUserEventKind[], + statuses: readonly ('pending' | 'in_flight')[] = ['pending'], ): Promise { await engine.update( ENVIRONMENT_USER_OUTBOX_OBJECT, { status: 'superseded', next_attempt_at: null }, - { where: { user_id: userId, kind: { $in: [...kinds] }, status: 'pending' }, multi: true, context: SYSTEM_CTX }, + { + where: { user_id: userId, kind: { $in: [...kinds] }, status: { $in: [...statuses] } }, + multi: true, + context: SYSTEM_CTX, + }, ); } +/** The statuses a deactivation or removal stops: every invitation not yet taken. */ +export const OUTBOX_UNSENT_STATUSES = ['pending', 'in_flight'] as const; + /** What one attempt's outcome makes of the row. */ export function outboxSettlement( outcome: EnvironmentUserHostOutcome | EnvironmentUserHostRefused, @@ -332,12 +347,15 @@ export interface EnvironmentUserOutboxDeps { now?(): number; } +/** Whether a `sys_user` row is deactivated (the memory engine stores `banned` as `0` / `1`). */ +export const isDeactivated = (user: { banned?: unknown }): boolean => user.banned === true || user.banned === 1; + /** Whether a row still has a reason to be sent, read from the person as they are now. */ async function stillOwed( engine: EnvironmentUserOutboxEngine, row: EnvironmentUserOutboxRow, ): Promise<'send' | 'accepted' | 'superseded'> { - if (row.kind !== 'added' && row.kind !== 'reactivated') return 'send'; + if (row.kind === 'deactivated') return 'send'; const users = await engine.find('sys_user', { where: { id: row.user_id }, fields: ['id', 'source', 'banned'], @@ -345,10 +363,13 @@ async function stillOwed( context: SYSTEM_CTX, }); const user = (Array.isArray(users) ? users[0] : undefined) as { source?: unknown; banned?: unknown } | undefined; + // A cancellation is owed while the person is gone, or still pending. + if (row.kind === 'removed') return !user || isPendingSsoSource(user.source) ? 'send' : 'superseded'; if (!user) return 'superseded'; + // An invitation or a re-send is never sent to a deactivated person. + if (isDeactivated(user)) return 'superseded'; if (row.kind === 'added') return isPendingSsoSource(user.source) ? 'send' : 'accepted'; - // A reactivation still owed only while the person is still active. - return user.banned === true || user.banned === 1 ? 'superseded' : 'send'; + return 'send'; } /** Send one claimed row. Answers the status written. */ @@ -392,7 +413,9 @@ export async function deliverOutboxRow( deps.logger?.warn(`[AuthPlugin] environment-user outbox row ${row.id} holds an unreadable event; it is failed.`); return 'failed'; } - const outcome = await notifyEnvironmentUserHost(deps.host, row.kind, { ...event, deliveryId: row.id }, deps.logger); + const outcome = await notifyEnvironmentUserHost(deps.host, row.kind, { ...event, deliveryId: row.id }, deps.logger, { + retried: true, + }); if ('refused' in outcome) { deps.logger?.warn( `[AuthPlugin] the environment-user host refused a retried call that ${row.email} was ${row.kind} ` @@ -537,9 +560,9 @@ export function registerOutboxAcceptedTrigger(engine: OutboxHookEngine, opts: { /** * Boot the outbox at `kernel:ready`: the accepted trigger and the worker, * both only on a cloud-managed kernel with a host wired. Elsewhere no door - * writes a row (the doors answer `no_host`, or refuse off a managed - * environment), so there is nothing to mark or retry, and this answers - * `undefined` without touching the engine. + * writes a row (the doors record only on a cloud-managed kernel, and answer + * `no_host` without a host), so there is nothing to mark or retry, and this + * answers `undefined` without touching the engine. */ export function bootEnvironmentUserOutbox( engine: OutboxHookEngine, diff --git a/packages/plugins/plugin-auth/src/pending-sso-marker.ts b/packages/plugins/plugin-auth/src/pending-sso-marker.ts index 5451286e96b..fbd500ec961 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-marker.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-marker.ts @@ -45,6 +45,14 @@ export const PENDING_SSO_MESSAGES = { removeRefusedReinvited: 'Their invitation had already been cancelled at the hosting organisation, so it is being sent again and they ' + 'stay pending as before.', + removeRefusedNotReinvited: + 'Their invitation had already been cancelled at the hosting organisation, and a new one could not be queued: ' + + 'add them again to send it.', + removeHostCancelled: + 'The hosting organisation had already been told to cancel their invitation, and it is not sent again.', + removeHostUnconfirmed: + 'The hosting organisation was asked to cancel their invitation but did not confirm it, and the request is not ' + + 'retried.', alreadyExists: 'A user with this email address already exists in this environment, so no one was added. Change the existing ' + "user's positions, permission sets or manager on their record instead.", diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.test.ts b/packages/plugins/plugin-auth/src/pending-sso-users.test.ts index 3a445e03c50..e39921850bb 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.test.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.test.ts @@ -1162,7 +1162,7 @@ describe('[#33759] Ban / Unban are offered and work without the admin plugin', ( }); // ───────────────────────────────────────────────────────────────────────────── -// Removing a pending person, and the outbox every host call is recorded in +// Removing a pending person, and the outbox the invitation calls are recorded in // ───────────────────────────────────────────────────────────────────────────── const outboxRows = (s: Awaited>) => @@ -1198,7 +1198,7 @@ async function addPending(s: Awaited>, email: string): return String(s.row(email)!.id); } -describe('[#33228] every host call about a person is recorded in the outbox', () => { +describe('[#33228] every invitation call about a person is recorded in the outbox', () => { it('an add records its invitation sent, under the delivery id the host was told', async () => { const s = await managedStage(); const res = await s.fire('/admin/add-sso-user', { email: 'outbox.add@example.com', name: 'Outbox' }, s.bearers.admin); @@ -1456,3 +1456,100 @@ describe('[#33228] admin/remove-sso-user removes a pending person and cancels th expect(s.row(EMAILS.member)).toBeDefined(); }); }); + +describe('[#33228] a deactivated person is never sent an invitation, and a removal is held to pending people', () => { + /** Make the delete of `sys_user` answer a `restrict` refusal, as the engine's delete walk does. */ + const restrictDelete = (s: Awaited>) => { + const realDelete = s.engine.delete.bind(s.engine); + s.engine.delete = async (name: string, q: any = {}) => { + if (name === 'sys_user') { + throw Object.assign(new Error('This User cannot be deleted because an Approval Rule still refers to it.'), { + code: 'DELETE_RESTRICTED', + status: 409, + }); + } + return realDelete(name, q); + }; + }; + const RESTRICTED = 'This User cannot be deleted because an Approval Rule still refers to it.'; + + it('a refused removal of a deactivated pending person sends no new invitation, and says the old one is cancelled', async () => { + const { host } = removingHost(); + const s = await managedStage({ host }); + const id = await addPending(s, 'held.banned@example.com'); + expect((await s.fire('/admin/ban-user', { userId: id }, s.bearers.admin)).status).toBe(200); + restrictDelete(s); + + const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)); + + expect(v.status, v.text).toBe(409); + expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeRefused} ${RESTRICTED} ${PENDING_SSO_MESSAGES.removeHostCancelled}`); + expect(outboxRows(s).filter((r) => r.kind === 'added' && r.status === 'pending')).toEqual([]); + expect(outboxRows(s).find((r) => r.kind === 'removed')).toMatchObject({ status: 'sent', user_id: id }); + }); + + it('a refused removal the host never took sends no new invitation, and says the cancellation was not confirmed', async () => { + const { host } = removingHost({ + removed: () => { + throw new Error('host down'); + }, + }); + const s = await managedStage({ host }); + const id = await addPending(s, 'held.unreached@example.com'); + restrictDelete(s); + + const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)); + + expect(v.status, v.text).toBe(409); + expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeRefused} ${RESTRICTED} ${PENDING_SSO_MESSAGES.removeHostUnconfirmed}`); + expect(outboxRows(s).map((r) => [r.kind, r.status])).toEqual([['added', 'sent']]); + }); + + it('deactivating a pending person stops an invitation whose sender died mid-call, so it is not sent when its claim lapses', async () => { + const s = await managedStage(); + const id = await addPending(s, 'stranded@example.com'); + const [sent] = outboxRows(s); + outboxRows(s).push({ ...sent, id: 'stranded_row', status: 'in_flight', claim_token: 'dead', claimed_until: Date.now() + 60_000 }); + + expect((await s.fire('/admin/ban-user', { userId: id }, s.bearers.admin)).status).toBe(200); + + expect(outboxRows(s).find((r) => r.id === 'stranded_row')).toMatchObject({ status: 'superseded' }); + expect(outboxRows(s).find((r) => r.id === sent.id)).toMatchObject({ status: 'sent' }); + }); + + it('a person who signs in while the host is asked is not removed: 409, and the call the host took is recorded', async () => { + const email = 'signs.in@example.com'; + let s!: Awaited>; + const { host } = removingHost({ + removed: () => { + s.row(email)!.source = 'idp_provisioned'; + }, + }); + s = await managedStage({ host }); + const id = await addPending(s, email); + + const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)); + + expect(v.status, v.text).toBe(409); + expect(v.code).toBe('RESOURCE_CONFLICT'); + expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeNotPending} ${PENDING_SSO_MESSAGES.removeHostCancelled}`); + expect(s.row(email)).toMatchObject({ id, source: 'idp_provisioned' }); + expect(s.rowsOf('sys_member', id).length).toBeGreaterThan(0); + expect(outboxRows(s).find((r) => r.kind === 'removed')).toMatchObject({ status: 'sent', user_id: id }); + }); + + it('off a cloud-managed kernel a wired host is still asked, but nothing is recorded and no retry is claimed', async () => { + const { host, told } = removingHost(); + host.userReactivated = () => { + throw new Error('host down'); + }; + const s = await stage({ host }); + expect((await s.fire('/admin/ban-user', { userId: s.ids.member }, s.bearers.admin)).status).toBe(200); + const body: any = await (await s.fire('/admin/unban-user', { userId: s.ids.member }, s.bearers.admin)).json(); + + expect(told.map((t) => t.kind)).toEqual(['deactivated']); + expect(body.data).toMatchObject({ banned: false, host: { notified: false, reason: 'host_failed' } }); + expect(body.data.invitation).toBeUndefined(); + expect(outboxRows(s)).toEqual([]); + }); +}); diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.ts b/packages/plugins/plugin-auth/src/pending-sso-users.ts index 0e131debb84..a75b1d61fcb 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.ts @@ -121,7 +121,9 @@ import { insertOutboxRow, newOutboxId, outboxDoc, + isDeactivated, outboxNextAttemptAt, + OUTBOX_UNSENT_STATUSES, settleOutboxAttempt, supersedeOpenOutboxRows, type EnvironmentUserOutboxEngine, @@ -477,6 +479,7 @@ async function sendAdded( 'added', claim ? { ...event, deliveryId: claim.id } : event, deps.logger, + { retried: claim !== undefined }, ); if (!claim) return { host }; return { host, invitation: await settleHeld(deps, engine, claim, event, host) }; @@ -565,12 +568,14 @@ async function takeBackPerson( userId: string, settlement: RequestSettlement, alongside?: () => Promise, + first?: () => Promise, ): Promise { if (typeof engine.delete !== 'function') { throw new Error(`The host refused user ${userId}, and this data engine cannot take the row back out`); } const remove = engine.delete.bind(engine); const work = async (): Promise => { + if (first) await first(); const context = await authSystemWriteContext(); for (const object of TAKE_BACK_OBJECTS) { await remove(object, { where: { user_id: userId }, multi: true, context }); @@ -804,9 +809,11 @@ const REMOVE_KEYS = new Set(['userId']); * outbox row recording the cancellation, in one unit of work, through the * engine's delete, so a record that points at the person follows its lookup's * `deleteBehavior`: a `restrict` refuses the removal with the engine's own - * answer and nothing is removed. A host that could not be reached does not - * block the removal: the cancellation is queued and retried. With no host - * wired nothing is called and no row is written. + * answer and nothing is removed. "Pending only" is held at the removal too: a + * person who signs in while the host is asked is answered `409` and kept. A + * host that could not be reached does not block the removal: the + * cancellation is queued and retried. With no host wired nothing is called + * and no row is written. */ export async function runRemoveSsoUser( deps: PendingSsoUserDeps, @@ -855,7 +862,9 @@ export async function runRemoveSsoUser( ...(await environmentUserAttribution(engine, actor, deps.logger)), occurredAt: new Date().toISOString(), }; - const answer = await notifyEnvironmentUserHost(deps.host, 'removed', { ...event, deliveryId }, deps.logger); + const answer = await notifyEnvironmentUserHost(deps.host, 'removed', { ...event, deliveryId }, deps.logger, { + retried: true, + }); if ('refused' in answer) return hostRefusal(answer); host = answer; } else { @@ -867,26 +876,29 @@ export async function runRemoveSsoUser( ? ({ status: 'sent' } as const) : ({ status: 'pending', lastError: 'The hosting organisation could not be reached, or failed to take the call.' } as const); + // Pending only, held at the write: the person may have signed in while the + // host was asked, and then they are not removed. + const stillPending = async (): Promise => { + const now = await engine.find('sys_user', { where: { id: userId }, fields: ['id', 'source'], limit: 1, context: SYSTEM_CTX }); + const row = (Array.isArray(now) ? now[0] : undefined) as { source?: unknown } | undefined; + if (!row || !isPendingSsoSource(row.source)) throw new NoLongerPending(); + }; try { - await takeBackPerson(deps, engine, userId, {}, async () => { - if (!recorded) return; - const context = await authSystemWriteContext(); - await supersedeOpenOutboxRows(outboxEngine(engine), userId, ['added', 'reactivated']); - await insertOutboxRow(outboxEngine(engine), outboxDoc(deliveryId, 'removed', recorded, birth), context); - }); - } catch (error) { - // The removal did not happen. If the host was already told to cancel the - // invitation, the person is pending without one: send it again. - const reinvited = recorded ? await reinvite(deps, engine, recorded) : false; - const thrown = resolveThrownHttpError(error, 500); - const cause = thrown.status >= 500 ? INTERNAL_ERROR_MESSAGE : thrown.message; - return fail( - thrown.status, - thrown.code, - [PENDING_SSO_MESSAGES.removeRefused, cause, reinvited ? PENDING_SSO_MESSAGES.removeRefusedReinvited : ''] - .filter(Boolean) - .join(' '), + await takeBackPerson( + deps, + engine, + userId, + {}, + async () => { + if (!recorded) return; + const context = await authSystemWriteContext(); + await supersedeOpenOutboxRows(outboxEngine(engine), userId, ['added', 'reactivated'], OUTBOX_UNSENT_STATUSES); + await insertOutboxRow(outboxEngine(engine), outboxDoc(deliveryId, 'removed', recorded, birth), context); + }, + stillPending, ); + } catch (error) { + return removalNotDone(deps, engine, error, { host, recorded, deliveryId }); } if (recorded && birth.status === 'pending') deps.wakeOutbox?.(outboxNextAttemptAt(1, Date.now())); @@ -905,9 +917,95 @@ export async function runRemoveSsoUser( }; } +/** Thrown inside the removal's unit of work when the person is no longer pending there. */ +class NoLongerPending extends Error { + constructor() { + super('The person is no longer pending'); + } +} + +/** + * The answer when the removal's unit of work did not commit: no one was + * removed. What the host was told is said as it happened, and an invitation + * is sent again only when the host took the cancellation and the person is + * still pending and not deactivated. + */ +async function removalNotDone( + deps: PendingSsoUserDeps, + engine: PendingSsoUserEngine, + error: unknown, + call: { host: EnvironmentUserHostOutcome; recorded: EnvironmentUserEvent | undefined; deliveryId: string }, +): Promise { + const { host, recorded, deliveryId } = call; + const told = recorded !== undefined && host.notified; + // The cancellation the host took is recorded, so the person's status says so. + const recordCancellation = async (): Promise => { + if (!told) return; + try { + await insertOutboxRow(outboxEngine(engine), outboxDoc(deliveryId, 'removed', recorded!, { status: 'sent' })); + } catch (e) { + deps.logger?.warn( + `[AuthPlugin] the hosting organisation cancelled the invitation of user ${recorded!.userId}, but the record ` + + `of it could not be written. Cause: ${e instanceof Error ? e.message : String(e)}`, + ); + } + }; + const hostSentence = told + ? PENDING_SSO_MESSAGES.removeHostCancelled + : recorded + ? PENDING_SSO_MESSAGES.removeHostUnconfirmed + : ''; + + if (error instanceof NoLongerPending) { + await recordCancellation(); + return fail( + PENDING_SSO_REFUSAL_STATUS, + PENDING_SSO_REFUSAL_CODE, + [PENDING_SSO_MESSAGES.removeNotPending, hostSentence].filter(Boolean).join(' '), + ); + } + + const thrown = resolveThrownHttpError(error, 500); + const cause = thrown.status >= 500 ? INTERNAL_ERROR_MESSAGE : thrown.message; + let after = hostSentence; + if (told) { + const person = await readPersonState(engine, recorded!.userId); + if (person.pending && !person.deactivated) { + // The re-send is the person's newest row, so the cancellation is not recorded beside it. + after = (await reinvite(deps, engine, recorded!)) + ? PENDING_SSO_MESSAGES.removeRefusedReinvited + : PENDING_SSO_MESSAGES.removeRefusedNotReinvited; + } else { + await recordCancellation(); + after = PENDING_SSO_MESSAGES.removeHostCancelled; + } + } + return fail(thrown.status, thrown.code, [PENDING_SSO_MESSAGES.removeRefused, cause, after].filter(Boolean).join(' ')); +} + +/** Whether the person is pending and whether they are deactivated, read now; unreadable reads as neither safe. */ +async function readPersonState( + engine: PendingSsoUserEngine, + userId: string, +): Promise<{ pending: boolean; deactivated: boolean }> { + try { + const rows = await engine.find('sys_user', { + where: { id: userId }, + fields: ['id', 'source', 'banned'], + limit: 1, + context: SYSTEM_CTX, + }); + const row = (Array.isArray(rows) ? rows[0] : undefined) as { source?: unknown; banned?: unknown } | undefined; + if (!row) return { pending: false, deactivated: false }; + return { pending: isPendingSsoSource(row.source), deactivated: isDeactivated(row) }; + } catch { + return { pending: false, deactivated: true }; + } +} + /** * Queue a fresh invitation for a pending person whose removal failed after - * the host was told to cancel theirs. Answers whether it was queued; a + * the host took the cancellation of theirs. Answers whether it was queued; a * failure is logged at `error`: the person stays pending with no invitation. */ async function reinvite(deps: PendingSsoUserDeps, engine: PendingSsoUserEngine, event: EnvironmentUserEvent): Promise { From b2af63e6c29dd27cfdba02c66c4853f9e791932e Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 08:07:50 +0000 Subject: [PATCH 08/11] refactor(auth): reshape the pending-person remove door to ruling A, without the framework outbox Ruling A on the card: the remove door and the optional `userRemoved` host member stay; durable retry and per-person invitation status are the host's job. Drops `sys_environment_user_outbox`, its worker, boot and accepted trigger, every outbox write in add/import/ban/unban/remove, `deliveryId`, the `invitation` answer fields, the translation bundles and the census/inventory/registry rows, so main is unchanged outside the door. A removal that fails after the host took the cancellation sends the invitation again once through `userAdded` and says whether it worked. A deactivated pending person who is re-added is not invited: the answer says `host: { notified: false, reason: 'deactivated' }`. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9 --- .changeset/33228-remove-pending-outbox.md | 26 - .changeset/33228-remove-pending-sso-user.md | 24 + content/docs/permissions/authentication.mdx | 57 +- .../docs/permissions/tenant-audit-census.mdx | 40 +- ...08-tenant-audit-write-call-sites.counts.md | 24 +- .../utils/organization-ownership-inventory.ts | 8 - .../scripts/i18n-extract.config.ts | 2 - .../apps/translations/ar.objects.generated.ts | 86 --- .../ar.source-hashes.generated.ts | 42 -- .../translations/bundle-ownership.test.ts | 2 - .../apps/translations/de.objects.generated.ts | 86 --- .../de.source-hashes.generated.ts | 42 -- .../apps/translations/en.objects.generated.ts | 86 --- .../translations/es-ES.objects.generated.ts | 86 --- .../es-ES.source-hashes.generated.ts | 42 -- .../apps/translations/fr.objects.generated.ts | 86 --- .../fr.source-hashes.generated.ts | 42 -- .../translations/ja-JP.objects.generated.ts | 86 --- .../ja-JP.source-hashes.generated.ts | 42 -- .../apps/translations/ko.objects.generated.ts | 86 --- .../ko.source-hashes.generated.ts | 42 -- .../translations/pt-BR.objects.generated.ts | 86 --- .../pt-BR.source-hashes.generated.ts | 42 -- .../apps/translations/ru.objects.generated.ts | 86 --- .../ru.source-hashes.generated.ts | 42 -- .../translations/zh-CN.objects.generated.ts | 86 --- .../zh-CN.source-hashes.generated.ts | 42 -- .../translations/zh-Hant.objects.generated.ts | 86 --- .../zh-Hant.source-hashes.generated.ts | 42 -- .../deployment-level-no-tenant-column.test.ts | 3 - .../platform-objects/src/identity/index.ts | 2 - .../sys-environment-user-outbox.object.ts | 236 ------- .../plugin-auth/src/admin-ban-endpoints.ts | 113 +--- .../plugins/plugin-auth/src/auth-plugin.ts | 42 -- .../plugin-auth/src/auth-route-ledger.ts | 4 +- .../plugin-auth/src/environment-user-host.ts | 33 +- .../src/environment-user-outbox.test.ts | 335 ---------- .../src/environment-user-outbox.ts | 575 ------------------ packages/plugins/plugin-auth/src/manifest.ts | 4 - .../plugin-auth/src/pending-sso-marker.ts | 8 +- .../plugin-auth/src/pending-sso-users.test.ts | 298 +++------ .../plugin-auth/src/pending-sso-users.ts | 296 +++------ .../system/constants/platform-object-names.ts | 1 - scripts/platform-object-tenancy-census.json | 15 +- 44 files changed, 287 insertions(+), 3227 deletions(-) delete mode 100644 .changeset/33228-remove-pending-outbox.md create mode 100644 .changeset/33228-remove-pending-sso-user.md delete mode 100644 packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts delete mode 100644 packages/plugins/plugin-auth/src/environment-user-outbox.test.ts delete mode 100644 packages/plugins/plugin-auth/src/environment-user-outbox.ts diff --git a/.changeset/33228-remove-pending-outbox.md b/.changeset/33228-remove-pending-outbox.md deleted file mode 100644 index 1f7cb504bff..00000000000 --- a/.changeset/33228-remove-pending-outbox.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -'@objectstack/plugin-auth': patch -'@objectstack/platform-objects': patch -'@objectstack/spec': patch -'@objectstack/cli': patch ---- - -feat(auth): a cloud-managed environment can remove a pending person, cancelling their invitation, and every invitation call to the environment-user host is retried from a durable outbox - -Clause-②: yes (widening) — added: `POST /api/v1/auth/admin/remove-sso-user` (platform administrators, cloud-managed environments only) removes a person who is still pending (`sys_user.source = 'idp_pending'`) and cancels their invitation at the host; the environment-user host contract gains an optional `userRemoved` member and an optional `deliveryId` on every event; the add, import, ban and unban answers gain an optional `invitation: { id, status }`; a new read-only system object `sys_environment_user_outbox` records each invitation call on a cloud-managed environment. Nothing that was accepted is refused, and no existing answer field changes. -Metadata-protocol: none - -On a cloud-managed environment, a person added to sign in through the hosting organisation's identity provider stays pending until their first sign-in. Before this change a pending person with a typo in their email could only be deactivated, and a host call that failed (a network error, a host outage) was logged and lost. - -**Removing a pending person.** `POST /api/v1/auth/admin/remove-sso-user` with `{ "userId": "…" }` asks the host first, then removes the person in one unit of work: - -- The host is told through `userRemoved`. A host without it is told through `userDeactivated` with `source: 'idp_pending'`, which already means "cancel the invitation". A host should implement `userRemoved`. -- A host refusal (403/409) answers with the host's sentence, and no one is removed. -- A host that cannot be reached does not block the removal. The cancellation is queued and retried. -- With no host wired, the person is removed and the answer says `host: { notified: false, reason: 'no_host' }`. -- A person who is not pending answers `409`: deactivate them instead. This holds at the removal itself, so a person who signs in while the host is asked is not removed. A person that other records still point at (`deleteBehavior: 'restrict'`) answers the engine's refusal, and nothing is removed. The answer says what the host was told. If the host had already taken the cancellation, a re-send is queued for a person who is still pending and not deactivated. A deactivated person is never sent an invitation. -- On an environment that is not cloud-managed the door answers `409` and removes no one. - -**Outbox.** On a cloud-managed environment, every invitation call to the host about a person (invited, deactivated while pending, re-sent on reactivation, removed) writes a row to `sys_environment_user_outbox`; the deactivation of a person who has signed in is asked of the host but not recorded, and off a cloud-managed environment nothing is recorded. The door that acts still makes the first call itself, outside any database transaction, so a typed refusal (such as the developer member cap) still reaches the administrator on that request. A call the host did not take stays `pending` and a worker retries it, backing off from one minute to twelve hours, until the host takes it or twelve attempts fail (`failed`, logged as an error). A typed refusal on a retry ends the row as `failed` with the host's code and sentence, and the person stays pending. The worker starts only on a cloud-managed environment with a host wired. Each call carries the row id as `deliveryId`, so a host can drop a repeat; a host cancels by `userId` or `deliveryId`, never by email address. The newest row of a person is their invitation status, which Setup → Users reads through the data API (`get` / `list`, platform administrators only). An `added` row becomes `accepted` when the person first signs in. - -Nothing to migrate. A host that ignores `deliveryId` keeps working: repeats of the same call already happen today when a person is re-added. diff --git a/.changeset/33228-remove-pending-sso-user.md b/.changeset/33228-remove-pending-sso-user.md new file mode 100644 index 00000000000..4e7fe3b28d9 --- /dev/null +++ b/.changeset/33228-remove-pending-sso-user.md @@ -0,0 +1,24 @@ +--- +'@objectstack/plugin-auth': patch +--- + +feat(auth): a cloud-managed environment can remove a pending person, cancelling their invitation at the host + +Clause-②: yes (widening) — added: `POST /api/v1/auth/admin/remove-sso-user` (platform administrators, cloud-managed environments only); an optional `userRemoved` member on the environment-user host contract and the `'removed'` event kind; the `'deactivated'` value of the host outcome's `reason`. Nothing that was accepted is refused. +Metadata-protocol: none + +On a cloud-managed environment, a person added to sign in through the hosting organisation's identity provider stays pending until their first sign-in. Before this change a pending person with a typo in their email could only be deactivated. + +**Removing a pending person.** `POST /api/v1/auth/admin/remove-sso-user` with `{ "userId": "…" }` asks the host first, outside any transaction, then removes the person with their positions, permission sets and membership in one unit of work: + +- The host is told through `userRemoved`. A host without it is told through `userDeactivated` with `source: 'idp_pending'`, which already means "cancel the invitation". A host should implement `userRemoved`. +- A host refusal (403/409) answers with the host's sentence, and no one is removed. +- A host that cannot be reached does not block the removal; the answer says `host: { notified: false, reason: 'host_failed' }`. The door calls the host once: durable retry is the host's job. +- With no host wired, the person is removed and the answer says `host: { notified: false, reason: 'no_host' }`. +- A person who is not pending answers `409`: deactivate them instead. This holds at the removal itself, so a person who signs in while the host is asked is not removed. +- A person that other records still point at (`deleteBehavior: 'restrict'`) answers the engine's refusal, and nothing is removed. If the host had already cancelled the invitation of a person who is still pending and not deactivated, the door sends it again through `userAdded`, once, and the answer says whether that worked. +- An unknown id answers `404`; a body with any key but `userId` answers `400`. Off a cloud-managed environment the door answers `409` and removes no one. + +**A deactivated person is never sent an invitation.** Adding a deactivated pending person again no longer calls `userAdded`; the answer says `host: { notified: false, reason: 'deactivated' }`. Reactivating them (`admin/unban-user`) is what tells the host again. + +Nothing to migrate. diff --git a/content/docs/permissions/authentication.mdx b/content/docs/permissions/authentication.mdx index 66a13f96705..97489438289 100644 --- a/content/docs/permissions/authentication.mdx +++ b/content/docs/permissions/authentication.mdx @@ -1333,10 +1333,9 @@ reactivation writes nothing, and a refused add takes that person back out deactivation with `503` and writes nothing, since only the host can say whether the person is an organization owner or admin. It never undoes or blocks an add or a reactivation: the answer carries `host: { notified: false, -reason }`. Adding a person who is still pending again re-sends their -invitation and changes nothing else: positions, permission sets or a manager -sent with it are listed on the answer as `notApplied`; set them on the -person's record. +reason }`. Adding a person who is still pending again tells the host again +and changes nothing else: positions, permission sets or a manager sent with +it are listed on the answer as `notApplied`; set them on the person's record. A pending person who never signs in, for example one added with a mistyped address, can be removed: `POST /api/v1/auth/admin/remove-sso-user` takes @@ -1345,36 +1344,30 @@ membership, and cancels their invitation at the host. The host is asked first, through its `userRemoved` member; a host without that member is asked through `userDeactivated` for the pending person instead, which means the same thing, but a host should implement `userRemoved`. A host's refusal leaves the -person as they are. A person who is not pending (they have signed in, or were +person as they are. A host that cannot be reached does not block the removal: +the person is removed and the answer says `host: { notified: false, reason: +'host_failed' }`. A person who is not pending (they have signed in, or were not added this way) is refused with `409`: deactivate them instead. That holds at the removal itself, so a person who signs in while the host is asked is not -removed either, and the answer says the host was already told. A record -that still points at the person through a lookup that restricts deletes -refuses the removal with that lookup's own answer, and nothing is removed. -Like the add doors, it is platform-admin gated and answers `409` off a managed -environment. - -On a cloud-managed environment these calls are recorded in -`sys_environment_user_outbox`, one row per call, readable by platform -administrators: every invitation sent (an add or re-add), every re-send (a -reactivation), and every cancellation (a removal, or the deactivation of a -person still pending). The deactivation of a person who has signed in is asked -of the host but not recorded. The door still makes the first call itself, so a refusal -reaches the administrator on that request, row by row. A call the host did not -take stays `pending` and is retried in the background with a growing wait (one -minute at first, up to twelve hours), and after twelve attempts it is -`failed`; a refusal that arrives on a retry is `failed` too, with the host's -code and sentence, and the person is left as they are. A failed reactivation -and a failed removal are retried the same way; a deactivation is never -retried, because a deactivation the host did not answer does not happen. The -newest row of a person is their invitation status: `sent`, `accepted` once -their first sign-in clears the pending state, `failed`, or, for a deactivation -or removal, the cancelled invitation. A call can reach the host more than -once, so each carries the row's id as `deliveryId` for the host to drop a -repeat. A host cancels an invitation by the event's `userId` or `deliveryId`, never by -its email address, which an administrator may have typed wrong and may type -again for someone else. The add, deactivate, reactivate and remove answers -name the row as `invitation: { id, status }`. +removed either, and the answer says the host was already told. A record that +still points at the person through a lookup that restricts deletes refuses the +removal with that lookup's own answer, and nothing is removed; when the host +had already cancelled the invitation of a person who is still pending and not +deactivated, the door sends the invitation again through `userAdded`, once, +and the answer says whether that worked. Like the add doors, it is +platform-admin gated and answers `409` off a managed environment. + +A deactivated person is never sent an invitation: adding a deactivated pending +person again calls no host and answers `host: { notified: false, reason: +'deactivated' }`; reactivating them is what tells the host again. + +Each door calls the host once and keeps no record of the call. Delivering it +durably, and keeping each person's invitation status, is the host's job: a +host may queue and retry a call it could not complete. A call can reach a host +more than once (adding a person who is still pending again tells the host +again), so a host should treat a repeat as harmless, and should cancel an +invitation by the event's `userId`, never by its email address, which an +administrator may have typed wrong and may type again for someone else. `admin/ban-user` and `admin/unban-user` work without the admin plugin: on a deployment without it the ban is written by the platform, and a banned user is diff --git a/content/docs/permissions/tenant-audit-census.mdx b/content/docs/permissions/tenant-audit-census.mdx index 8304192fffb..793cd0dfda7 100644 --- a/content/docs/permissions/tenant-audit-census.mdx +++ b/content/docs/permissions/tenant-audit-census.mdx @@ -132,7 +132,7 @@ are reported as `undecidable` rather than assumed either way. The same holds twice over for the context. An options argument spelled as a literal can be read; one spelled `options`, `{ ...opts }`, or handed through a -forwarding shim cannot, and **59 of the 328 sites are spelled that way**. A +forwarding shim cannot, and **59 of the 321 sites are spelled that way**. A context resolved from an inline literal or a local `const` can be tested for `isSystem`; one arriving from a helper call cannot. @@ -197,10 +197,10 @@ reproduce them. Where it disagrees, it disagrees on the page: | carried figure | where it survives | this census | | :--- | :--- | ---: | -| 175 write call sites | quoted in the merged changeset | **328** | +| 175 write call sites | quoted in the merged changeset | **321** | | 24 carrying no tenant context | quoted in the merged changeset | **3** provable and tenancy-enabled; **32** more whose options argument is unreadable | -| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **233 of 328** decidable, **95** undecidable | -| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 187 decidably elevated, 0 decidably not, 129 undecidable | +| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **226 of 321** decidable, **95** undecidable | +| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 181 decidably elevated, 0 decidably not, 128 undecidable | | 141 and 132, two independent re-derivations | the card that filed this work | — | **The differences are not reconciled, and deliberately so.** The old census's @@ -211,17 +211,17 @@ at any commit. Two structural facts do plausibly widen this reading against any hand or regex one, and both are counted in the generated tables below: the 66 sites reached -through an erased (`any`) receiver, and the 93 that name their object through a +through an erased (`any`) receiver, and the 86 that name their object through a `const` rather than inline. An instrument that read either the way a person does would report a smaller number and would not say so. The fourth row is the one worth flagging to anyone citing it. **The 135 / 77% figure has no surviving corroboration anywhere in the tree.** This census reads -187 of 328 (57%) as decidably elevated, with 129 more whose elevation is a +181 of 321 (56%) as decidably elevated, with 128 more whose elevation is a run-time fact — so the claim is neither confirmed nor refuted, and the honest answer is that a static reading cannot settle it. -⇒ **Cite `3 / 328`, and say what it is**: the sites whose options argument was +⇒ **Cite `3 / 321`, and say what it is**: the sites whose options argument was READ and holds no tenant context, against a decidably tenancy-enabled object. That is the control's provable yield surface. ⛔ Do not cite it as "the sites without tenant context" — **32 further sites** have an options argument this @@ -233,29 +233,29 @@ cannot read, and they are neither in nor out. | what | count | | :--- | ---: | -| write call sites on the application surface | **328** | -| …whose object name is statically decidable | 233 | +| write call sites on the application surface | **321** | +| …whose object name is statically decidable | 226 | | …whose object name is chosen at run time | 95 | -| …against an object with tenancy ENABLED | 226 | +| …against an object with tenancy ENABLED | 219 | | …against an object that declares tenancy off | 7 | -| threading a tenant context | 257 | +| threading a tenant context | 250 | | PROVABLY carrying none (options read, no context key) | **12** | | …of those, against a decidably tenancy-enabled object | **3** | | options argument UNREADABLE — may or may not carry one | 59 | | …of those, against a decidably tenancy-enabled object | 32 | -| threading a decidably ELEVATED (`isSystem`) context | 187 | +| threading a decidably ELEVATED (`isSystem`) context | 181 | | threading a context that is decidably NOT elevated | 0 | -| threading a context whose elevation is a run-time fact | 129 | +| threading a context whose elevation is a run-time fact | 128 | | how the instrument reached the site | count | | :--- | ---: | -| receiver carried a readable engine type | 262 | +| receiver carried a readable engine type | 255 | | receiver erased, placed by the object NAME | 56 | | receiver erased, placed by an `object: string` PARAMETER | 5 | | receiver erased, placed by an `UNTYPED_RECEIVERS` row | 5 | | object name spelled inline | 140 | -| object name spelled through a `const` | 93 | +| object name spelled through a `const` | 86 | | object name is an `object: string` parameter | 10 | | object name is some other run-time expression | 85 | @@ -307,13 +307,13 @@ holds still. They are required to be HERE and to say WHEN they were true; their values are not compared. The reasoning, and the measurement behind it, are in `scripts/check-tenant-audit-census.mjs`. -Measured on 2026-11-15 at `f51a0c4fc`. +Measured on 2026-11-15 at `2ab05f460`. | corpus scale (not enforced) | count | | :--- | ---: | -| tracked non-test sources scanned | 1177 | -| engine-shaped types recognised | 143 | -| declared objects in the registry | 138 | -| same-named calls subtracted as non-engine | 313 | +| tracked non-test sources scanned | 1176 | +| engine-shaped types recognised | 141 | +| declared objects in the registry | 137 | +| same-named calls subtracted as non-engine | 311 | {/* END GENERATED: tenant-audit-census */} diff --git a/docs/audits/2026-08-tenant-audit-write-call-sites.counts.md b/docs/audits/2026-08-tenant-audit-write-call-sites.counts.md index 9db8157d803..d9225ca889b 100644 --- a/docs/audits/2026-08-tenant-audit-write-call-sites.counts.md +++ b/docs/audits/2026-08-tenant-audit-write-call-sites.counts.md @@ -33,19 +33,19 @@ silent, and `node scripts/tenant-audit-census.mjs --write` is the resolution. | Measure | Value | |---|---:| -| Write call sites | 328 | -| Object name statically decidable | 233 | +| Write call sites | 321 | +| Object name statically decidable | 226 | | Object name chosen at run time | 95 | -| Against a tenancy-enabled object | 226 | +| Against a tenancy-enabled object | 219 | | Against an object declaring tenancy off | 7 | -| Threading a tenant context | 257 | +| Threading a tenant context | 250 | | Provably carrying none | 12 | | …and decidably tenancy-enabled | 3 | | Options argument unreadable | 59 | | …and decidably tenancy-enabled | 32 | -| Threading a decidably elevated context | 187 | +| Threading a decidably elevated context | 181 | | Threading a decidably non-elevated context | 0 | -| Threading a context of undecidable elevation | 129 | +| Threading a context of undecidable elevation | 128 | ## Subtractions the census could NOT defend — enforced @@ -90,14 +90,14 @@ holds still. They are required to be HERE and to say WHEN they were true; their values are not compared. The reasoning, and the measurement behind it, are in `scripts/check-tenant-audit-census.mjs`. -Measured on 2026-11-15 at `f51a0c4fc`. +Measured on 2026-11-15 at `2ab05f460`. | corpus scale (not enforced) | count | | :--- | ---: | -| tracked non-test sources scanned | 1177 | -| engine-shaped types recognised | 143 | -| declared objects in the registry | 138 | -| same-named calls subtracted as non-engine | 313 | +| tracked non-test sources scanned | 1176 | +| engine-shaped types recognised | 141 | +| declared objects in the registry | 137 | +| same-named calls subtracted as non-engine | 311 | ## Every site @@ -163,8 +163,6 @@ Measured on 2026-11-15 at `f51a0c4fc`. | `packages/plugins/plugin-auth/src/demo-staff.ts` | `insert` | `sys_user_position` | enabled | elevated | 1 | | `packages/plugins/plugin-auth/src/ensure-default-organization.ts` | `insert` | `object` | undecidable | elevated | 1 | | `packages/plugins/plugin-auth/src/ensure-default-organization.ts` | `update` | `sys_member` | enabled | elevated | 1 | -| `packages/plugins/plugin-auth/src/environment-user-outbox.ts` | `insert` | `sys_environment_user_outbox` | enabled | context, elevation undecidable | 1 | -| `packages/plugins/plugin-auth/src/environment-user-outbox.ts` | `update` | `sys_environment_user_outbox` | enabled | elevated | 6 | | `packages/plugins/plugin-auth/src/forced-reset-revocation.ts` | `update` | `SystemObjectName.API_KEY` | undecidable | elevated | 1 | | `packages/plugins/plugin-auth/src/forced-reset-revocation.ts` | `update` | `SystemObjectName.SESSION` | undecidable | elevated | 1 | | `packages/plugins/plugin-auth/src/idp-group-mapping-admin.ts` | `delete` | `IDP_GROUP_MAPPING_OBJECT` | undecidable | PROVABLY NONE | 1 | diff --git a/packages/cli/src/utils/organization-ownership-inventory.ts b/packages/cli/src/utils/organization-ownership-inventory.ts index 1c4b595fdfd..953ac18b4ce 100644 --- a/packages/cli/src/utils/organization-ownership-inventory.ts +++ b/packages/cli/src/utils/organization-ownership-inventory.ts @@ -767,14 +767,6 @@ export const ORGANIZATION_OWNERSHIP_INVENTORY: readonly InventoryEntry[] = [ `${CENSUS_MAIN}: systemFields.tenant: false; ${D7}: the environment's trusted plugin-publisher keys, ` + 'read by key id under the system context, never by organization', }, - { - object: 'sys_environment_user_outbox', - census: PMAIN, - fate: 'column-drop', - citation: - `${CENSUS_MAIN}: systemFields.tenant: false; ${D7}: the record of each call to the environment-user host about ` + - 'one person, who is the environment\'s and not an organization\'s, written and drained under the system context', - }, { object: 'sys_lifecycle_state', census: PMAIN, diff --git a/packages/platform-objects/scripts/i18n-extract.config.ts b/packages/platform-objects/scripts/i18n-extract.config.ts index 7c1054a899a..3d59bc05744 100644 --- a/packages/platform-objects/scripts/i18n-extract.config.ts +++ b/packages/platform-objects/scripts/i18n-extract.config.ts @@ -146,7 +146,6 @@ import { SysScimSubject, SysScimUser, SysIdpGroupMapping, - SysEnvironmentUserOutbox, } from '../src/identity/index.js'; // ── Security ────────────────────────────────────────────────────────────── @@ -328,7 +327,6 @@ const config: ObjectStackDefinition = defineStack({ SysScimSubject, SysScimUser, SysIdpGroupMapping, - SysEnvironmentUserOutbox, // Security: RBAC moved to @objectstack/plugin-security, sharing to // @objectstack/plugin-sharing (ADR-0029 K2 / D8). diff --git a/packages/platform-objects/src/apps/translations/ar.objects.generated.ts b/packages/platform-objects/src/apps/translations/ar.objects.generated.ts index 55805199c4f..55e6d0fcdcf 100644 --- a/packages/platform-objects/src/apps/translations/ar.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.objects.generated.ts @@ -3098,92 +3098,6 @@ export const arObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "حدث الإشعار", pluralLabel: "أحداث الإشعارات", diff --git a/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts index 8e99de2eb71..95fadcc230d 100644 --- a/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts @@ -27,48 +27,6 @@ export const arGeneratedSourceHashes: Readonly> = { "objects.sys_email.fields.message_id.label": "14cd089a4062f4b1", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", - "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", - "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", - "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", - "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", - "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", - "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", - "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", - "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", - "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", - "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", - "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", - "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", - "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", - "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", - "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", - "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", - "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", - "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", - "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", - "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", - "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", - "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", - "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", - "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", - "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", - "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", - "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", - "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", - "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", - "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", - "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", - "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", - "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", - "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", - "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", - "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", - "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", - "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", - "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_job.fields.schedule_type.options.cron": "fd48d0e2cd59cab2", "objects.sys_metadata_commit.description": "6a8e29c0ce6345a2", diff --git a/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts b/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts index db7b2bf75d8..648ef7e731a 100644 --- a/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts +++ b/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts @@ -48,8 +48,6 @@ const OWNED_OBJECTS = new Set([ 'sys_scim_subject', 'sys_scim_user', // identity — IdP group → permission set mapping (#30959; SCIM now, SSO group claims later) 'sys_idp_group_mapping', - // identity — the record of each call to the environment-user host - 'sys_environment_user_outbox', // audit / messaging-adjacent (still owned here) 'sys_notification', 'sys_attachment', 'sys_email', 'sys_email_template', // (sys_saved_report / sys_report_schedule retired with the saved-report stack, #20102) diff --git a/packages/platform-objects/src/apps/translations/de.objects.generated.ts b/packages/platform-objects/src/apps/translations/de.objects.generated.ts index d82faaf65be..ff148fd61b1 100644 --- a/packages/platform-objects/src/apps/translations/de.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.objects.generated.ts @@ -3098,92 +3098,6 @@ export const deObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "Benachrichtigungsereignis", pluralLabel: "Benachrichtigungsereignisse", diff --git a/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts index d791c436f79..cf91687b0df 100644 --- a/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts @@ -90,48 +90,6 @@ export const deGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.name.label": "5274417ff1ccaf01", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", - "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", - "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", - "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", - "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", - "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", - "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", - "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", - "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", - "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", - "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", - "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", - "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", - "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", - "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", - "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", - "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", - "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", - "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", - "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", - "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", - "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", - "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", - "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", - "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", - "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", - "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", - "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", - "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", - "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", - "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", - "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", - "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", - "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", - "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", - "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", - "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", - "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", - "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", - "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_exchange_rate.fields.source.options.app": "0c4630a782d594ab", "objects.sys_exchange_rate.fields.source.options.import": "05c80d3a61ec3290", diff --git a/packages/platform-objects/src/apps/translations/en.objects.generated.ts b/packages/platform-objects/src/apps/translations/en.objects.generated.ts index c678db82dbf..01dacfa65d8 100644 --- a/packages/platform-objects/src/apps/translations/en.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/en.objects.generated.ts @@ -3098,92 +3098,6 @@ export const enObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "Notification Event", pluralLabel: "Notification Events", diff --git a/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts index 4b9ade871b1..d3aaa149e99 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts @@ -3098,92 +3098,6 @@ export const esESObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "Notificación", pluralLabel: "Notificaciones", diff --git a/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts index 4fe515e110f..99c0176fec9 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts @@ -25,48 +25,6 @@ export const esESGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", "objects.sys_email_template.fields.variables_json.label": "c2cfff50e8151e3d", - "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", - "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", - "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", - "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", - "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", - "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", - "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", - "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", - "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", - "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", - "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", - "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", - "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", - "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", - "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", - "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", - "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", - "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", - "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", - "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", - "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", - "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", - "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", - "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", - "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", - "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", - "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", - "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", - "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", - "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", - "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", - "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", - "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", - "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", - "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", - "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", - "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", - "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", - "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_exchange_rate.fields.source.options.manual": "c2e7a98c066bec4a", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", diff --git a/packages/platform-objects/src/apps/translations/fr.objects.generated.ts b/packages/platform-objects/src/apps/translations/fr.objects.generated.ts index fb20186854e..06778c96beb 100644 --- a/packages/platform-objects/src/apps/translations/fr.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.objects.generated.ts @@ -3098,92 +3098,6 @@ export const frObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "Événement de notification", pluralLabel: "Événements de notification", diff --git a/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts index 676f019077e..052e7f2ba4d 100644 --- a/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts @@ -129,48 +129,6 @@ export const frGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", "objects.sys_email_template.fields.reply_to.label": "90ad8f2ca791a95a", "objects.sys_email_template.fields.variables_json.label": "c2cfff50e8151e3d", - "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", - "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", - "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", - "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", - "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", - "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", - "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", - "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", - "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", - "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", - "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", - "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", - "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", - "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", - "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", - "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", - "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", - "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", - "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", - "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", - "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", - "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", - "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", - "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", - "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", - "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", - "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", - "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", - "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", - "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", - "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", - "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", - "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", - "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", - "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", - "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", - "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", - "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", - "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_exchange_rate.fields.source.label": "8fe786e8e29c8cec", "objects.sys_exchange_rate.fields.source.options.import": "05c80d3a61ec3290", diff --git a/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts index 9fb50093252..bc466437933 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts @@ -3098,92 +3098,6 @@ export const jaJPObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "通知", pluralLabel: "通知", diff --git a/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts index e0c7c30a117..c539c773da5 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts @@ -24,48 +24,6 @@ export const jaJPGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.id.label": "00b0385c9c152888", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", - "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", - "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", - "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", - "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", - "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", - "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", - "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", - "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", - "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", - "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", - "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", - "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", - "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", - "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", - "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", - "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", - "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", - "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", - "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", - "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", - "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", - "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", - "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", - "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", - "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", - "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", - "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", - "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", - "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", - "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", - "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", - "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", - "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", - "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", - "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", - "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", - "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", - "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", - "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_metadata.fields.bundle_member.help": "6912852b7523f266", diff --git a/packages/platform-objects/src/apps/translations/ko.objects.generated.ts b/packages/platform-objects/src/apps/translations/ko.objects.generated.ts index 784c09a9dac..44d1c702a5f 100644 --- a/packages/platform-objects/src/apps/translations/ko.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.objects.generated.ts @@ -3098,92 +3098,6 @@ export const koObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "알림 이벤트", pluralLabel: "알림 이벤트", diff --git a/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts index bf2fa31b1c2..f4542414298 100644 --- a/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts @@ -28,48 +28,6 @@ export const koGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.id.label": "00b0385c9c152888", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", - "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", - "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", - "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", - "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", - "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", - "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", - "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", - "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", - "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", - "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", - "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", - "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", - "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", - "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", - "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", - "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", - "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", - "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", - "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", - "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", - "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", - "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", - "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", - "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", - "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", - "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", - "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", - "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", - "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", - "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", - "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", - "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", - "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", - "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", - "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", - "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", - "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", - "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", - "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_job.fields.schedule_type.options.cron": "fd48d0e2cd59cab2", diff --git a/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts index e9405eda7fc..954330ca772 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts @@ -3098,92 +3098,6 @@ export const ptBRObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "Evento de notificação", pluralLabel: "Eventos de notificação", diff --git a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts index c5555ea79dc..dc8b3f44160 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts @@ -53,48 +53,6 @@ export const ptBRGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", "objects.sys_email_template.fields.reply_to.label": "90ad8f2ca791a95a", - "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", - "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", - "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", - "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", - "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", - "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", - "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", - "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", - "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", - "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", - "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", - "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", - "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", - "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", - "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", - "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", - "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", - "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", - "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", - "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", - "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", - "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", - "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", - "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", - "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", - "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", - "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", - "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", - "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", - "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", - "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", - "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", - "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", - "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", - "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", - "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", - "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", - "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", - "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_exchange_rate.fields.source.options.app": "0c4630a782d594ab", "objects.sys_exchange_rate.fields.source.options.manual": "c2e7a98c066bec4a", diff --git a/packages/platform-objects/src/apps/translations/ru.objects.generated.ts b/packages/platform-objects/src/apps/translations/ru.objects.generated.ts index f0dc71b0cc1..95f841a0f57 100644 --- a/packages/platform-objects/src/apps/translations/ru.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.objects.generated.ts @@ -3098,92 +3098,6 @@ export const ruObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "Событие уведомления", pluralLabel: "События уведомлений", diff --git a/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts index 6ee810204a3..803c7a5c745 100644 --- a/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts @@ -28,48 +28,6 @@ export const ruGeneratedSourceHashes: Readonly> = { "objects.sys_email_template.fields.id.label": "00b0385c9c152888", "objects.sys_email_template.fields.package_id.help": "e1f8cc4d0105cedc", "objects.sys_email_template.fields.package_id.label": "aacf5e74a8641b2b", - "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", - "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", - "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", - "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", - "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", - "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", - "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", - "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", - "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", - "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", - "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", - "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", - "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", - "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", - "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", - "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", - "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", - "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", - "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", - "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", - "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", - "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", - "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", - "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", - "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", - "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", - "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", - "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", - "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", - "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", - "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", - "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", - "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", - "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", - "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", - "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", - "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", - "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", - "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_job.fields.schedule_type.options.cron": "fd48d0e2cd59cab2", diff --git a/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts index 7dbbc10d534..713e40bab25 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts @@ -3098,92 +3098,6 @@ export const zhCNObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "通知", pluralLabel: "通知", diff --git a/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts index e050ab64c84..5fc27e139ad 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts @@ -20,48 +20,6 @@ export const zhCNGeneratedSourceHashes: Readonly> = { "objects.sys_email.fields.message_id.label": "14cd089a4062f4b1", "objects.sys_email_template.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", - "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", - "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", - "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", - "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", - "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", - "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", - "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", - "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", - "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", - "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", - "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", - "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", - "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", - "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", - "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", - "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", - "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", - "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", - "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", - "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", - "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", - "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", - "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", - "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", - "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", - "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", - "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", - "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", - "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", - "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", - "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", - "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", - "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", - "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", - "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", - "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", - "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", - "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_metadata.fields.bundle_member.help": "6912852b7523f266", diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts index 43df4eab98a..b1b707dea97 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts @@ -3098,92 +3098,6 @@ export const zhHantObjects: NonNullable = { } } }, - sys_environment_user_outbox: { - label: "Environment User Invitation", - pluralLabel: "Environment User Invitations", - description: "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - fields: { - id: { - label: "ID", - help: "Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call." - }, - user_id: { - label: "User ID", - help: "The person the call is about. Text, not a lookup: the row outlives a removed person." - }, - email: { - label: "Email", - help: "The person's email address when the call was made." - }, - kind: { - label: "Kind", - help: "What the host is told: an invitation sent, cancelled or re-sent.", - options: { - added: "Invited", - deactivated: "Deactivated", - reactivated: "Reactivated", - removed: "Removed" - } - }, - status: { - label: "Status", - help: "Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a later call about the same person replaced it.", - options: { - pending: "Pending", - in_flight: "Sending", - sent: "Sent", - accepted: "Accepted", - failed: "Failed", - superseded: "Superseded" - } - }, - attempts: { - label: "Attempts", - help: "How many times the host has been called for this row." - }, - next_attempt_at: { - label: "Next Attempt At (ms)", - help: "When a pending row is next tried, in epoch milliseconds." - }, - claimed_until: { - label: "Claimed Until (ms)", - help: "While a call is in flight: when the claim lapses and another worker may try the row again." - }, - claim_token: { - label: "Claim Token", - help: "Names the one claim that holds an in-flight row." - }, - last_attempt_at: { - label: "Last Attempt At" - }, - last_error: { - label: "Last Error", - help: "Why the last call did not land: the host's own sentence for a refusal, else what failed." - }, - refusal_code: { - label: "Refusal Code", - help: "The host's machine code when it refused the call." - }, - event_json: { - label: "Event", - help: "The event the host is told, as built when the administrator acted: the person, the administrator and their cloud user id. A retry sends it unchanged." - }, - sent_at: { - label: "Sent At" - }, - accepted_at: { - label: "Accepted At" - } - }, - _views: { - recent: { - label: "Recent" - }, - failed: { - label: "Failed" - } - } - }, sys_notification: { label: "通知", pluralLabel: "通知", diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts index 0250e281bc7..e9a90d643c2 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts @@ -20,48 +20,6 @@ export const zhHantGeneratedSourceHashes: Readonly> = { "objects.sys_email.fields.message_id.label": "14cd089a4062f4b1", "objects.sys_email_template.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox._views.failed.label": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox._views.recent.label": "62d27bb9d0349c99", - "objects.sys_environment_user_outbox.description": "db4dc831fcfbe5a7", - "objects.sys_environment_user_outbox.fields.accepted_at.label": "107d1cf9d40e5627", - "objects.sys_environment_user_outbox.fields.attempts.help": "8b6a962d4edaa335", - "objects.sys_environment_user_outbox.fields.attempts.label": "096d2dbc7038a926", - "objects.sys_environment_user_outbox.fields.claim_token.help": "6c47f050402899cc", - "objects.sys_environment_user_outbox.fields.claim_token.label": "b7818931ec93399d", - "objects.sys_environment_user_outbox.fields.claimed_until.help": "c65df71d59794679", - "objects.sys_environment_user_outbox.fields.claimed_until.label": "aec40396cfb275f9", - "objects.sys_environment_user_outbox.fields.email.help": "eb420fc145b169ad", - "objects.sys_environment_user_outbox.fields.email.label": "632647764b8dff5d", - "objects.sys_environment_user_outbox.fields.event_json.help": "4bcaf93a1cc82697", - "objects.sys_environment_user_outbox.fields.event_json.label": "6492ff42adf979a0", - "objects.sys_environment_user_outbox.fields.id.help": "548acde5dbb9eabc", - "objects.sys_environment_user_outbox.fields.id.label": "00b0385c9c152888", - "objects.sys_environment_user_outbox.fields.kind.help": "8a5fa88cf8eeb18a", - "objects.sys_environment_user_outbox.fields.kind.label": "3acd2ee4b0e7f2cf", - "objects.sys_environment_user_outbox.fields.kind.options.added": "be2435b6a6729bc2", - "objects.sys_environment_user_outbox.fields.kind.options.deactivated": "32bf2f4f14c19f6d", - "objects.sys_environment_user_outbox.fields.kind.options.reactivated": "69b4f76dc8f15aa2", - "objects.sys_environment_user_outbox.fields.kind.options.removed": "3c4a5f1d1eb92c37", - "objects.sys_environment_user_outbox.fields.last_attempt_at.label": "8ec78ed43700ceb6", - "objects.sys_environment_user_outbox.fields.last_error.help": "43e22456106e6f01", - "objects.sys_environment_user_outbox.fields.last_error.label": "1ef7bb6721dbe1d6", - "objects.sys_environment_user_outbox.fields.next_attempt_at.help": "0e431451a2c0dd35", - "objects.sys_environment_user_outbox.fields.next_attempt_at.label": "d73e994fb1cd8d97", - "objects.sys_environment_user_outbox.fields.refusal_code.help": "4d1421c3a601e784", - "objects.sys_environment_user_outbox.fields.refusal_code.label": "498c38e99b73163f", - "objects.sys_environment_user_outbox.fields.sent_at.label": "ca422134f296762c", - "objects.sys_environment_user_outbox.fields.status.help": "e57509544f61e22a", - "objects.sys_environment_user_outbox.fields.status.label": "64a420165247654b", - "objects.sys_environment_user_outbox.fields.status.options.accepted": "1eda1123cd5c074e", - "objects.sys_environment_user_outbox.fields.status.options.failed": "d65a52ee2fab1cc9", - "objects.sys_environment_user_outbox.fields.status.options.in_flight": "ef97f2b7a2975194", - "objects.sys_environment_user_outbox.fields.status.options.pending": "23b532305c06373f", - "objects.sys_environment_user_outbox.fields.status.options.sent": "e9ded569a511bea8", - "objects.sys_environment_user_outbox.fields.status.options.superseded": "6bc088c207bceb1a", - "objects.sys_environment_user_outbox.fields.user_id.help": "aab44fc9e6894ba6", - "objects.sys_environment_user_outbox.fields.user_id.label": "63332374301a9820", - "objects.sys_environment_user_outbox.label": "936e9f4bc2d384f8", - "objects.sys_environment_user_outbox.pluralLabel": "2f21a2e4033de523", "objects.sys_exchange_rate.fields.id.label": "00b0385c9c152888", "objects.sys_idp_group_mapping.fields.id.label": "00b0385c9c152888", "objects.sys_metadata.fields.bundle_member.help": "6912852b7523f266", diff --git a/packages/platform-objects/src/deployment-level-no-tenant-column.test.ts b/packages/platform-objects/src/deployment-level-no-tenant-column.test.ts index b3e37084479..a7233f9a531 100644 --- a/packages/platform-objects/src/deployment-level-no-tenant-column.test.ts +++ b/packages/platform-objects/src/deployment-level-no-tenant-column.test.ts @@ -13,7 +13,6 @@ import { SysSettingAudit, SysTrustedKey, } from './system/index.js'; -import { SysEnvironmentUserOutbox } from './identity/index.js'; /** * [ADR-0131 D7] The deployment-level plumbing this package declares carries no @@ -52,8 +51,6 @@ const DEPLOYMENT_LEVEL = [ ['sys_trusted_key', SysTrustedKey], // [ADR-0057] The lifecycle sweeper's clock state: one row per datastore. ['sys_lifecycle_state', SysLifecycleState], - // The record of each call to the environment-user host (pending people's invitations). - ['sys_environment_user_outbox', SysEnvironmentUserOutbox], ] as const; describe('[ADR-0131 D7] deployment-level plumbing: no tenant column, platform-only reads', () => { diff --git a/packages/platform-objects/src/identity/index.ts b/packages/platform-objects/src/identity/index.ts index 0336030d8cb..872a519756d 100644 --- a/packages/platform-objects/src/identity/index.ts +++ b/packages/platform-objects/src/identity/index.ts @@ -57,5 +57,3 @@ export { SysScimSubject } from './sys-scim-subject.object.js'; export { SysScimUser } from './sys-scim-user.object.js'; // The identity-provider group → permission-set mapping the SCIM projection reads. export { SysIdpGroupMapping } from './sys-idp-group-mapping.object.js'; -// The record of each call to the environment-user host (invitations sent and cancelled). -export { SysEnvironmentUserOutbox } from './sys-environment-user-outbox.object.js'; diff --git a/packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts b/packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts deleted file mode 100644 index 68fe7f1ebdd..00000000000 --- a/packages/platform-objects/src/identity/sys-environment-user-outbox.object.ts +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -import { ObjectSchema, Field } from '@objectstack/spec/data'; - -/** - * sys_environment_user_outbox — on a cloud-managed environment, the durable - * record of the calls the environment makes to its environment-user host (the - * cloud) about one person's invitation: sent when a pending person is added or - * re-added, cancelled when a pending person is deactivated or removed, and - * re-sent when a person is reactivated. The deactivation of a person who has - * signed in is asked of the host but not recorded here. - * - * Why it exists: the execution terms of the hosting rulings (relayed on the - * pending-people card) ask for "a durable outbox with retry … with per-row - * invitation status in Setup → Users". The door that acts still makes the - * first call itself, outside any database transaction, so a host's typed - * refusal (the developer member cap, an organization owner or admin) reaches - * the administrator on that request, row by row. This object is what makes - * the call durable: a call the host did not take stays `pending` here and - * plugin-auth's worker (`environment-user-outbox.ts`) retries it with backoff - * until the host takes it or the attempts run out (`failed`). - * - * One row per call, never updated into another call: a re-send writes a new - * row and marks the older unsent one `superseded`. The newest row of a person - * is their invitation status: - * - * - `added` + `pending` / `in_flight`: the invitation is being sent; - * - `added` + `sent`: invited, not signed in yet; - * - `added` + `accepted`: the person's first platform sign-in cleared the - * pending marker; - * - any kind + `failed`: the host refused it (`refusal_code`) or the - * attempts ran out (`last_error`); - * - `deactivated` / `removed` + `sent`: the invitation was cancelled. - * - * `user_id` is text, not a lookup: the row outlives a removed person, which - * is exactly when the cancellation it records matters. - * - * Writers: plugin-auth only, as the system (`managedBy: 'engine-owned'`, no - * data-API writes). Readers: platform administrators, through the data API - * (`get` / `list`), which is what Setup → Users reads. - * - * Lifecycle: no `lifecycle` block on purpose. A pending person who never - * accepts keeps a status for as long as they are pending, and a person's - * rows are one per administrator action, so there is nothing to reap. - * - * @namespace sys - */ -export const SysEnvironmentUserOutbox = ObjectSchema.create({ - name: 'sys_environment_user_outbox', - label: 'Environment User Invitation', - pluralLabel: 'Environment User Invitations', - icon: 'send', - isSystem: true, - managedBy: 'engine-owned', - // [ADR-0131 D7] Deployment-level: people are the environment's, not an - // organization's, and the worker drains every row under the system - // context, so there is no organization to stamp. Who may read is object - // permission: the platform-only capability below. - systemFields: { tenant: false }, - requiredPermissions: ['manage_platform_settings'], - protection: { - lock: 'full', - reason: 'Written only by plugin-auth: the record of each call to the environment-user host.', - docsUrl: 'https://objectstack.ai/docs/references/shared/protection', - }, - userActions: { create: false, edit: false, delete: false, import: false }, - description: - "Invitations sent to and cancelled at the hosting organisation for this environment's people, one row per call, with its delivery status.", - nameField: 'email', // [ADR-0079] canonical primary-title pointer - displayNameField: 'email', - highlightFields: ['email', 'kind', 'status', 'attempts', 'last_error'], - - listViews: { - recent: { - type: 'grid', - name: 'recent', - label: 'Recent', - data: { provider: 'object', object: 'sys_environment_user_outbox' }, - columns: ['email', 'kind', 'status', 'attempts', 'last_error', 'updated_at'], - sort: [{ field: 'updated_at', order: 'desc' }], - pagination: { pageSize: 50 }, - }, - failed: { - type: 'grid', - name: 'failed', - label: 'Failed', - data: { provider: 'object', object: 'sys_environment_user_outbox' }, - columns: ['email', 'kind', 'attempts', 'refusal_code', 'last_error', 'updated_at'], - filter: [{ field: 'status', operator: 'equals', value: 'failed' }], - sort: [{ field: 'updated_at', order: 'desc' }], - pagination: { pageSize: 50 }, - }, - }, - - fields: { - id: Field.text({ - label: 'ID', - required: true, - readonly: true, - description: 'Row id. Sent to the host as the delivery id, so it can drop a repeat of the same call.', - }), - - user_id: Field.text({ - label: 'User ID', - required: true, - readonly: true, - maxLength: 255, - description: 'The person the call is about. Text, not a lookup: the row outlives a removed person.', - }), - - email: Field.text({ - label: 'Email', - required: true, - readonly: true, - maxLength: 320, - description: "The person's email address when the call was made.", - }), - - kind: Field.select({ - label: 'Kind', - required: true, - readonly: true, - description: 'What the host is told: an invitation sent, cancelled or re-sent.', - options: [ - { value: 'added', label: 'Invited' }, - { value: 'deactivated', label: 'Deactivated' }, - { value: 'reactivated', label: 'Reactivated' }, - { value: 'removed', label: 'Removed' }, - ], - }), - - status: Field.select({ - label: 'Status', - required: true, - readonly: true, - defaultValue: 'pending', - description: - 'Pending and Sending: the host has not taken the call yet and it is retried. Sent: the host took it. ' - + 'Accepted: the person signed in. Failed: the host refused it or the retries ran out. Superseded: a ' - + 'later call about the same person replaced it.', - options: [ - { value: 'pending', label: 'Pending' }, - { value: 'in_flight', label: 'Sending' }, - { value: 'sent', label: 'Sent' }, - { value: 'accepted', label: 'Accepted' }, - { value: 'failed', label: 'Failed' }, - { value: 'superseded', label: 'Superseded' }, - ], - }), - - attempts: Field.number({ - label: 'Attempts', - required: true, - readonly: true, - defaultValue: 0, - description: 'How many times the host has been called for this row.', - }), - - next_attempt_at: Field.number({ - label: 'Next Attempt At (ms)', - required: false, - readonly: true, - description: 'When a pending row is next tried, in epoch milliseconds.', - }), - - claimed_until: Field.number({ - label: 'Claimed Until (ms)', - required: false, - readonly: true, - description: 'While a call is in flight: when the claim lapses and another worker may try the row again.', - }), - - claim_token: Field.text({ - label: 'Claim Token', - required: false, - readonly: true, - maxLength: 64, - description: 'Names the one claim that holds an in-flight row.', - }), - - last_attempt_at: Field.datetime({ - label: 'Last Attempt At', - required: false, - readonly: true, - }), - - last_error: Field.textarea({ - label: 'Last Error', - required: false, - readonly: true, - description: "Why the last call did not land: the host's own sentence for a refusal, else what failed.", - }), - - refusal_code: Field.text({ - label: 'Refusal Code', - required: false, - readonly: true, - maxLength: 128, - description: "The host's machine code when it refused the call.", - }), - - event_json: Field.textarea({ - label: 'Event', - required: true, - readonly: true, - description: - 'The event the host is told, as built when the administrator acted: the person, the administrator and ' - + 'their cloud user id. A retry sends it unchanged.', - }), - - sent_at: Field.datetime({ - label: 'Sent At', - required: false, - readonly: true, - }), - - accepted_at: Field.datetime({ - label: 'Accepted At', - required: false, - readonly: true, - }), - }, - - indexes: [ - { fields: ['status', 'next_attempt_at'] }, - { fields: ['user_id'] }, - ], - - enable: { - trackHistory: false, - searchable: false, - apiEnabled: true, - // Read-only over the data API: plugin-auth is the only writer. - apiMethods: ['get', 'list'], - }, -}); diff --git a/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts b/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts index fdaa469f14e..6cd92af3e3d 100644 --- a/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts +++ b/packages/plugins/plugin-auth/src/admin-ban-endpoints.ts @@ -110,18 +110,7 @@ import { type EnvironmentUserHostAccessor, type EnvironmentUserHostOutcome, type EnvironmentUserHostRefused, - type EnvironmentUserEvent, } from './environment-user-host.js'; -import { - insertOutboxRow, - newOutboxId, - outboxDoc, - outboxNextAttemptAt, - OUTBOX_UNSENT_STATUSES, - supersedeOpenOutboxRows, - type OutboxBirth, -} from './environment-user-outbox.js'; -import { isPendingSsoSource } from './pending-sso-marker.js'; /** * Minimal better-auth `$context` surface these two routes touch. Mirrors what @@ -148,27 +137,13 @@ export interface AdminBanEndpointDeps { host?: EnvironmentUserHostAccessor; /** Reads the row's `source` and the administrator's linked cloud account for the host event. */ getDataEngine?(): any; - /** Wakes the outbox worker for a reactivation queued for retry (`environment-user-outbox.ts`). */ - wakeOutbox?(atMs: number): void; - /** - * Whether the kernel is cloud-managed. Only there does the outbox worker - * run, so only there is a call recorded; absent reads as not managed. - */ - isCloudManaged?(): boolean; - logger?: { warn(msg: string): void; error?(msg: string, err?: Error): void }; + logger?: { warn(msg: string): void }; } async function banWriterFor(deps: AdminBanEndpointDeps, ctx: AuthBanContextLike): Promise { return (await deps.getBanWriter?.()) ?? ctx.internalAdapter; } -/** One ask of the host: its answer, and the event and delivery id it was asked with. */ -interface HostAsk { - outcome: EnvironmentUserHostOutcome | EnvironmentUserHostRefused; - event: EnvironmentUserEvent; - deliveryId: string; -} - /** * Ask the host, when one is wired; `undefined` leaves the answer as it was. * A typed refusal comes back as `{ refused }` for the door to answer. @@ -179,68 +154,25 @@ async function askHost( user: unknown, userId: string, actor: AdminActor & EnvironmentUserActor, -): Promise { +): Promise { if (!deps.host) return undefined; const row = (user && typeof user === 'object' ? user : {}) as { email?: unknown; name?: unknown }; const engine = deps.getDataEngine?.(); const source = engine ? await readUserSource(engine, userId) : undefined; const attribution = await environmentUserAttribution(engine, actor, deps.logger); - const event: EnvironmentUserEvent = { - userId, - email: typeof row.email === 'string' ? row.email : '', - name: typeof row.name === 'string' ? row.name : '', - source: source?.ok && typeof source.value === 'string' ? source.value : null, - ...attribution, - occurredAt: new Date().toISOString(), - }; - const deliveryId = newOutboxId(); - const outcome = await notifyEnvironmentUserHost(deps.host, kind, { ...event, deliveryId }, deps.logger, { - retried: deps.isCloudManaged?.() === true, - }); - return { outcome, event, deliveryId }; -} - -/** - * Record an ask in the outbox after the door's write - * (`environment-user-outbox.ts`): a deactivation of a pending person as the - * cancelled invitation (and every invitation or reactivation still waiting - * for them stops), a reactivation as sent, or queued for the worker when the - * host could not be reached. A failure to record is logged at `error`: the - * door's write stands, and a queued reactivation would not be retried. - */ -async function recordAsk( - deps: AdminBanEndpointDeps, - kind: 'deactivated' | 'reactivated', - ask: HostAsk, -): Promise<{ id: string; status: 'sent' | 'pending' } | undefined> { - // Off a cloud-managed kernel no worker drains the outbox, so nothing is recorded. - if (deps.isCloudManaged?.() !== true) return undefined; - const engine = deps.getDataEngine?.(); - if (!engine || 'refused' in ask.outcome) return undefined; - const outcome = ask.outcome; - if (!outcome.notified && outcome.reason === 'no_host') return undefined; - try { - if (kind === 'deactivated') { - await supersedeOpenOutboxRows(engine, ask.event.userId, ['added', 'reactivated'], OUTBOX_UNSENT_STATUSES); - if (!outcome.notified || !isPendingSsoSource(ask.event.source)) return undefined; - } else { - await supersedeOpenOutboxRows(engine, ask.event.userId, ['reactivated']); - } - const birth: OutboxBirth = outcome.notified - ? { status: 'sent' } - : { status: 'pending', lastError: 'The hosting organisation could not be reached, or failed to take the call.' }; - await insertOutboxRow(engine, outboxDoc(ask.deliveryId, kind, ask.event, birth)); - if (birth.status === 'pending') deps.wakeOutbox?.(outboxNextAttemptAt(1, Date.now())); - return { id: ask.deliveryId, status: birth.status }; - } catch (error) { - const message = - `[AuthPlugin] user ${ask.event.userId} was ${kind}, but the record of telling the environment-user host could ` - + `not be written to the outbox${outcome.notified ? '' : ', so the call the host did not take will not be retried'}. ` - + `Repeat the action to tell the host again. Cause: ${error instanceof Error ? error.message : String(error)}`; - if (deps.logger?.error) deps.logger.error(message); - else deps.logger?.warn(message); - return undefined; - } + return notifyEnvironmentUserHost( + deps.host, + kind, + { + userId, + email: typeof row.email === 'string' ? row.email : '', + name: typeof row.name === 'string' ? row.name : '', + source: source?.ok && typeof source.value === 'string' ? source.value : null, + ...attribution, + occurredAt: new Date().toISOString(), + }, + deps.logger, + ); } /** The door's answer for a host's typed refusal: its status, code and sentence; nothing was written. */ @@ -347,8 +279,7 @@ export async function runAdminBanUser( } // The host first: an organization owner or admin it refuses is not deactivated at all. - const ask = await askHost(deps, 'deactivated', target, userId, actor); - const host = ask?.outcome; + const host = await askHost(deps, 'deactivated', target, userId, actor); if (isRefused(host)) return hostRefusal(host); // A wired host that did not answer: the owner / admin question is open, so // the deactivation does not happen (ruling 5). @@ -360,7 +291,6 @@ export async function runAdminBanUser( }); // Sign the banned user out everywhere, exactly as the vendor handler does. await ctx.internalAdapter.deleteUserSessions(userId); - const invitation = ask ? await recordAsk(deps, 'deactivated', ask) : undefined; return { status: 200, @@ -372,7 +302,6 @@ export async function runAdminBanUser( banReason, ...(banExpires ? { banExpires: banExpires.toISOString() } : {}), ...(host ? { host } : {}), - ...(invitation ? { invitation } : {}), }, }, }; @@ -394,16 +323,10 @@ export async function runAdminUnbanUser( if (!target) return notFound(); // The host first: a reactivation it refuses (the member cap) leaves the person deactivated. - const ask = await askHost(deps, 'reactivated', target, userId, actor); - const host = ask?.outcome; + const host = await askHost(deps, 'reactivated', target, userId, actor); if (isRefused(host)) return hostRefusal(host); await applyUserUnban(await banWriterFor(deps, ctx), userId); - // A reactivation the host did not take is queued and retried (ruling 5: it re-sends the invitation). - const invitation = ask ? await recordAsk(deps, 'reactivated', ask) : undefined; - return { - status: 200, - body: { success: true, data: { userId, banned: false, ...(host ? { host } : {}), ...(invitation ? { invitation } : {}) } }, - }; + return { status: 200, body: { success: true, data: { userId, banned: false, ...(host ? { host } : {}) } } }; } diff --git a/packages/plugins/plugin-auth/src/auth-plugin.ts b/packages/plugins/plugin-auth/src/auth-plugin.ts index aaab39d5314..c4b287f7ef1 100644 --- a/packages/plugins/plugin-auth/src/auth-plugin.ts +++ b/packages/plugins/plugin-auth/src/auth-plugin.ts @@ -191,11 +191,6 @@ import { } from './admin-ban-endpoints.js'; import { engineUserBanWriter, type UserBanEngine } from './user-ban-write.js'; import type { EnvironmentUserHostAccessor } from './environment-user-host.js'; -import { - bootEnvironmentUserOutbox, - type EnvironmentUserOutboxWorker, - type OutboxHookEngine, -} from './environment-user-outbox.js'; /** @@ -401,8 +396,6 @@ export interface AuthPluginOptions extends Partial { * (a refused add is taken back out); any other failure refuses a * deactivation (`503`) and is reported on an add, a reactivation or a * removal as `host: { notified: false, reason }`, which it never undoes. - * On a cloud-managed kernel those calls are recorded in the - * environment-user outbox and retried (`environment-user-outbox.ts`). */ environmentUserHost?: EnvironmentUserHostAccessor; @@ -680,8 +673,6 @@ export class AuthPlugin implements Plugin { private options: AuthPluginOptions; private authManager: AuthManager | null = null; - /** The environment-user outbox worker: running only on a cloud-managed kernel with a host wired. */ - private environmentUserOutbox: EnvironmentUserOutboxWorker | null = null; /** * Whether a route registration mounted direct sign-in's start door. The * door is mounted from the manager's setting and `/auth/config` advertises @@ -2294,28 +2285,6 @@ export class AuthPlugin implements Plugin { packageId: IDP_GROUP_MAPPING_MATCH_PACKAGE_ID, logger: ctx.logger, }); - // The environment-user outbox (`environment-user-outbox.ts`): on a - // cloud-managed kernel with a host wired, a pending person's - // invitation reads `accepted` once they sign in, and the worker - // retries every recorded call the host did not take. The doors - // record only on a cloud-managed kernel, so elsewhere neither runs. - // A boot that fails is logged here, never left to the catch below: - // the rows it would drain wait for the next boot. - if (!this.environmentUserOutbox) { - try { - this.environmentUserOutbox = bootEnvironmentUserOutbox(engine as unknown as OutboxHookEngine, { - host: this.options.environmentUserHost, - isCloudManaged, - logger: ctx.logger, - }) ?? null; - } catch (e) { - ctx.logger.error( - '[AuthPlugin] the environment-user outbox worker did not start, so invitations and cancellations ' - + 'the hosting organisation did not take are not retried until the next boot. Cause: ' - + `${e instanceof Error ? e.message : String(e)}`, - ); - } - } try { await refreshAllMappingMatches(engine); } catch (e) { @@ -3146,17 +3115,9 @@ export class AuthPlugin implements Plugin { async destroy(): Promise { // Cleanup if needed - const outbox = this.environmentUserOutbox; - this.environmentUserOutbox = null; - await outbox?.stop(); this.authManager = null; } - /** Wake the outbox worker for a call due at `atMs`; nothing when it is not running. */ - private wakeEnvironmentUserOutbox = (atMs: number): void => { - this.environmentUserOutbox?.wakeAt(atMs); - }; - /** * Provision the stack's `demoStaff` (`demo-staff.ts` holds the three gates * and the argument for each). Answers what happened — nothing when no entry @@ -4965,8 +4926,6 @@ export class AuthPlugin implements Plugin { }, ...(this.options.environmentUserHost ? { host: this.options.environmentUserHost } : {}), getDataEngine: () => this.authManager!.getDataEngine(), - wakeOutbox: this.wakeEnvironmentUserOutbox, - isCloudManaged: () => isCloudManaged(), logger: ctx.logger, }); @@ -5251,7 +5210,6 @@ export class AuthPlugin implements Plugin { return session?.session?.activeOrganizationId ?? null; }, ...(this.options.environmentUserHost ? { host: this.options.environmentUserHost } : {}), - wakeOutbox: this.wakeEnvironmentUserOutbox, logger: ctx.logger, }); diff --git a/packages/plugins/plugin-auth/src/auth-route-ledger.ts b/packages/plugins/plugin-auth/src/auth-route-ledger.ts index 13aaafdde5b..f216b134784 100644 --- a/packages/plugins/plugin-auth/src/auth-route-ledger.ts +++ b/packages/plugins/plugin-auth/src/auth-route-ledger.ts @@ -258,9 +258,9 @@ export const AUTH_ROUTE_LEDGER: readonly AuthRouteLedgerEntry[] = [ { route: 'POST /api/v1/auth/admin/import-users', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — objectui app-shell\'s identity-import wizard (views/identityImport.ts) posts it directly from the Users list; platform-admin gated (ADR-0068). A dedicated identity-import door rather than the generic sys_user import, because a direct ObjectQL write would bypass better-auth\'s password hashing and mint no sys_account credential' }, // #33181 — the tracker id stays HERE and never in the `note` string, per the // #16678 note below. - { route: 'POST /api/v1/auth/admin/add-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; adds one person who signs in only through the hosting organisation identity provider: a sys_user row marked idp_pending (no password, refused a session) with optional positions, permission sets and manager, joined to the organization; 201, or 200 alreadyPending for a person already pending (the host is told again); 409 RESOURCE_CONFLICT off a managed environment or for an address already in use; closed body key set; the environment-user host is told after the write commits, and its answer rides host; platform-admin gated (ADR-0068)' }, + { route: 'POST /api/v1/auth/admin/add-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; adds one person who signs in only through the hosting organisation identity provider: a sys_user row marked idp_pending (no password, refused a session) with optional positions, permission sets and manager, joined to the organization; 201, or 200 alreadyPending for a person already pending (the host is told again, unless the person is deactivated: then host reads deactivated and nothing is sent); 409 RESOURCE_CONFLICT off a managed environment or for an address already in use; closed body key set; the environment-user host is told after the write commits, and its answer rides host; platform-admin gated (ADR-0068)' }, { route: 'POST /api/v1/auth/admin/import-sso-users', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; the CSV or JSON twin of admin/add-sso-user (columns email, name, positions, permission_sets, manager_id), at most 500 rows, each judged and written on its own so a bad row fails alone; answers a summary and one result per row; 409 RESOURCE_CONFLICT off a managed environment; platform-admin gated (ADR-0068)' }, - { route: 'POST /api/v1/auth/admin/remove-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; removes a person who is still pending (sys_user.source idp_pending: the email-typo case) with their positions, permission sets and membership, and cancels their invitation at the environment-user host (userRemoved, else userDeactivated), which is asked first so its typed refusal leaves the person as they are; a host that cannot be reached does not block it and the cancellation is retried through sys_environment_user_outbox; body { userId }; 404 RESOURCE_NOT_FOUND for an unknown id; 409 RESOURCE_CONFLICT off a managed environment or for a person who is not pending; a lookup that restricts the delete refuses it with the engine answer; platform-admin gated (ADR-0068)' }, + { route: 'POST /api/v1/auth/admin/remove-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; removes a person who is still pending (sys_user.source idp_pending: the email-typo case) with their positions, permission sets and membership, and cancels their invitation at the environment-user host (userRemoved, else userDeactivated), which is asked first so its typed refusal leaves the person as they are; a host that cannot be reached does not block it and the answer says host_failed (the door calls the host once; retrying is the host's own business); a removal that fails after the host took the cancellation sends the invitation again once through userAdded and says so; body { userId }; 404 RESOURCE_NOT_FOUND for an unknown id; 409 RESOURCE_CONFLICT off a managed environment or for a person who is not pending; a lookup that restricts the delete refuses it with the engine answer; platform-admin gated (ADR-0068)' }, { route: 'POST /api/v1/auth/admin/list-platform-admins', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — the sys_user list_platform_admins action posts it directly from the Users list; answers who holds platform-admin standing (the last-admin guard\'s enumerator, each id confirmed by hasPlatformAdminStanding), served only to a caller who holds that standing; reads no body. ADR-0095 D3' }, { route: 'POST /api/v1/auth/admin/oauth2/toggle-disabled', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — the sys_oauth_application disable/enable actions post it directly; ObjectStack mount closing a vendor gap (better-auth\'s /admin/oauth2/update-client strips `disabled` from its body schema), platform-admin gated (ADR-0068)' }, // #30958 — the tracker id stays HERE and never in the `note` string, per the diff --git a/packages/plugins/plugin-auth/src/environment-user-host.ts b/packages/plugins/plugin-auth/src/environment-user-host.ts index d9a9c7466e0..076335cfbc6 100644 --- a/packages/plugins/plugin-auth/src/environment-user-host.ts +++ b/packages/plugins/plugin-auth/src/environment-user-host.ts @@ -5,10 +5,9 @@ * environment) is told when a person is added, deactivated, reactivated or, * while still pending, removed, so it can forward an invitation or cancel * one. See `pending-sso-users.ts` for the add and remove halves and - * `admin-ban-endpoints.ts` for the deactivate / reactivate half. Every call - * is recorded, and retried when the host did not take it, by the outbox - * (`environment-user-outbox.ts`): delivery is at least once, and the event's - * `deliveryId` lets a host drop a repeat. + * `admin-ban-endpoints.ts` for the deactivate / reactivate half. Each door + * calls the host once: a host that must not lose a call (an unreachable + * mail relay, an outage of its own) queues and retries it on its side. * * Two kinds of host failure are told apart: * @@ -64,13 +63,6 @@ export interface EnvironmentUserEvent { * reactivation. */ occurredAt: string; - /** - * The outbox row this call is recorded in (`sys_environment_user_outbox`). - * A call the host did not take is sent again under the same id, so a host - * can drop a repeat of a call it already took. Absent only on a call made - * outside the outbox. - */ - deliveryId?: string; } /** @@ -79,8 +71,7 @@ export interface EnvironmentUserEvent { * ban, unban or removal is written. A member that throws * {@link EnvironmentUserHostRefusal} refuses the operation. Any other throw * refuses a deactivation (`503`) and is reported on the answer for an add, a - * reactivation or a removal, which it never undoes or blocks; the outbox - * retries those. + * reactivation or a removal, which it never undoes or blocks. */ export interface EnvironmentUserHost { /** A person was added (or re-added while still pending) to this environment. */ @@ -141,10 +132,15 @@ export function isEnvironmentUserHostRefusal(error: unknown): error is Environme return (status === 403 || status === 409) && typeof code === 'string' && code.length > 0 && typeof message === 'string'; } -/** What a door answers about the host call, on the row it concerns. */ +/** + * What a door answers about the host call, on the row it concerns. + * `deactivated`: the person is deactivated, so the host was not asked to + * invite them (a re-add of a deactivated pending person); reactivating them + * is what sends the invitation again. + */ export type EnvironmentUserHostOutcome = | { notified: true } - | { notified: false; reason: 'no_host' | 'host_failed' }; + | { notified: false; reason: 'no_host' | 'host_failed' | 'deactivated' }; /** A host's typed refusal, as the door answers it. */ export interface EnvironmentUserHostRefused { @@ -236,16 +232,13 @@ export async function environmentUserAttribution( /** * Tell the host, once. Never throws. A typed refusal is answered as * `{ refused }` for the door to return; any other failure as `host_failed` - * on the caller's row, logged at `warn` with its message. `opts.retried` - * says the caller records the call in the outbox, so the log may say it is - * retried; a caller that records nothing leaves it unset. + * on the caller's row, logged at `warn` with its message. */ export async function notifyEnvironmentUserHost( accessor: EnvironmentUserHostAccessor | undefined, kind: EnvironmentUserEventKind, event: EnvironmentUserEvent, logger?: { warn(msg: string): void }, - opts: { retried?: boolean } = {}, ): Promise { let host: EnvironmentUserHost | undefined; try { @@ -269,7 +262,7 @@ export async function notifyEnvironmentUserHost( logger?.warn( `[AuthPlugin] the environment-user host refused or failed to take the news that user ${event.userId} was ` + `${kind}. ${goesAhead(kind)} The answer says so. ` - + (opts.retried && kind !== 'deactivated' ? 'The call is retried. ' : '') + + (kind === 'added' ? 'Adding the person again while they are still pending tells the host again. ' : '') + `Cause: ${describe(error)}`, ); return { notified: false, reason: 'host_failed' }; diff --git a/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts b/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts deleted file mode 100644 index 1444c1964cc..00000000000 --- a/packages/plugins/plugin-auth/src/environment-user-outbox.test.ts +++ /dev/null @@ -1,335 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. -// -// The environment-user outbox (`environment-user-outbox.ts`) on its own: what -// one attempt makes of a row, the claim that keeps two workers off one row, -// the worker's pass (retry, backoff, the last attempt, a refusal on a retry, -// a person who accepted or went away meanwhile), and the trigger that marks -// an invitation accepted. The doors that write the rows are pinned end to end -// in `pending-sso-users.test.ts`. - -import { describe, it, expect, vi } from 'vitest'; -import { - bootEnvironmentUserOutbox, - claimOutboxRow, - ENVIRONMENT_USER_OUTBOX_OBJECT, - environmentUserOutboxNextDueAt, - outboxDoc, - outboxSettlement, - OUTBOX_BACKOFF_MS, - OUTBOX_LEASE_MS, - OUTBOX_MAX_ATTEMPTS, - registerOutboxAcceptedTrigger, - runEnvironmentUserOutboxTick, - type EnvironmentUserOutboxRow, -} from './environment-user-outbox'; -import { EnvironmentUserHostRefusal, type EnvironmentUserEvent, type EnvironmentUserHost } from './environment-user-host'; -import { PENDING_SSO_SOURCE } from './pending-sso-marker'; -import { createMemoryEngine } from './impersonation-bearer-rotation.test'; - -const NOW = Date.parse('2026-11-15T12:00:00.000Z'); - -const EVENT: EnvironmentUserEvent = { - userId: 'usr_p', - email: 'pending@example.com', - name: 'Pending', - source: PENDING_SSO_SOURCE, - actorId: 'usr_admin', - actorCloudUserId: 'cloud_admin', - occurredAt: '2026-11-15T11:00:00.000Z', -}; - -function harness(opts: { user?: Record | null; host?: Partial } = {}) { - const engine = createMemoryEngine(); - if (opts.user !== null) { - engine.tables.set('sys_user', [{ id: 'usr_p', email: EVENT.email, source: PENDING_SSO_SOURCE, banned: 0, ...opts.user }]); - } - const calls: Array<{ member: string; event: EnvironmentUserEvent }> = []; - const host: EnvironmentUserHost = { - userAdded: (event) => void calls.push({ member: 'userAdded', event }), - userDeactivated: (event) => void calls.push({ member: 'userDeactivated', event }), - userReactivated: (event) => void calls.push({ member: 'userReactivated', event }), - ...opts.host, - }; - const logger = { warn: vi.fn(), error: vi.fn() }; - const deps = { getDataEngine: () => engine as any, host: () => host, logger, now: () => NOW }; - const rows = () => (engine.tables.get(ENVIRONMENT_USER_OUTBOX_OBJECT) ?? []) as any[]; - const seed = (doc: Record) => engine.tables.set(ENVIRONMENT_USER_OUTBOX_OBJECT, [...rows(), doc]); - const pendingRow = (over: Record = {}) => ({ - ...outboxDoc('row_1', 'added', EVENT, { status: 'pending', lastError: 'down' }, NOW - 120_000), - next_attempt_at: NOW - 1, - ...over, - }); - return { engine, calls, logger, deps, rows, seed, pendingRow }; -} - -describe('what one attempt makes of a row', () => { - it('a call the host took is sent', () => { - const settled = outboxSettlement({ notified: true }, 0, NOW); - expect(settled.status).toBe('sent'); - expect(settled.data).toMatchObject({ attempts: 1, status: 'sent', next_attempt_at: null, claim_token: null }); - }); - - it('a typed refusal is failed at once, with the host\'s code and sentence', () => { - const settled = outboxSettlement({ refused: { status: 403, code: 'DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED', message: 'Cap.' } }, 3, NOW); - expect(settled).toMatchObject({ status: 'failed', exhausted: false }); - expect(settled.data).toMatchObject({ attempts: 4, refusal_code: 'DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED', last_error: 'Cap.' }); - }); - - it('a host that failed is pending again, due after the backoff for its attempt count', () => { - expect(outboxSettlement({ notified: false, reason: 'host_failed' }, 0, NOW).data).toMatchObject({ - status: 'pending', - attempts: 1, - next_attempt_at: NOW + OUTBOX_BACKOFF_MS[0]!, - }); - expect(outboxSettlement({ notified: false, reason: 'host_failed' }, 1, NOW).data.next_attempt_at).toBe(NOW + OUTBOX_BACKOFF_MS[1]!); - // Past the schedule the last wait repeats. - expect(outboxSettlement({ notified: false, reason: 'host_failed' }, 9, NOW).data.next_attempt_at).toBe( - NOW + OUTBOX_BACKOFF_MS[OUTBOX_BACKOFF_MS.length - 1]!, - ); - }); - - it('the last attempt that fails is failed, and says no attempts are left', () => { - const settled = outboxSettlement({ notified: false, reason: 'host_failed' }, OUTBOX_MAX_ATTEMPTS - 1, NOW); - expect(settled).toMatchObject({ status: 'failed', exhausted: true }); - expect(String(settled.data.last_error)).toContain('No attempts are left.'); - }); -}); - -describe('the claim keeps two workers off one row', () => { - it('two workers that both read the row pending: exactly one holds it', async () => { - const h = harness(); - h.seed(h.pendingRow()); - const snapshot = { ...h.rows()[0] } as EnvironmentUserOutboxRow; - - const first = await claimOutboxRow(h.engine as any, snapshot, NOW); - const second = await claimOutboxRow(h.engine as any, snapshot, NOW); - - expect(first).toEqual(expect.any(String)); - expect(second).toBeUndefined(); - expect(h.rows()[0]).toMatchObject({ status: 'in_flight', claim_token: first, claimed_until: NOW + OUTBOX_LEASE_MS }); - }); - - it('two passes over the same due row call the host once', async () => { - const h = harness(); - h.seed(h.pendingRow()); - const [a, b] = await Promise.all([runEnvironmentUserOutboxTick(h.deps), runEnvironmentUserOutboxTick(h.deps)]); - expect(a + b).toBe(1); - expect(h.calls).toHaveLength(1); - expect(h.rows()[0]).toMatchObject({ status: 'sent', attempts: 2 }); - }); - - it('a claim that lapsed is taken again; one still held is left alone', async () => { - const held = harness(); - held.seed(held.pendingRow({ status: 'in_flight', claim_token: 'tok_live', claimed_until: NOW + 60_000 })); - expect(await runEnvironmentUserOutboxTick(held.deps)).toBe(0); - expect(held.calls).toHaveLength(0); - - const lapsed = harness(); - lapsed.seed(lapsed.pendingRow({ status: 'in_flight', claim_token: 'tok_dead', claimed_until: NOW - 1 })); - expect(await runEnvironmentUserOutboxTick(lapsed.deps)).toBe(1); - expect(lapsed.calls).toHaveLength(1); - expect(lapsed.rows()[0]).toMatchObject({ status: 'sent' }); - }); -}); - -describe('the worker\'s pass', () => { - it('sends a due row with the stored event unchanged and the row id as the delivery id', async () => { - const h = harness(); - h.seed(h.pendingRow()); - await runEnvironmentUserOutboxTick(h.deps); - expect(h.calls).toEqual([{ member: 'userAdded', event: { ...EVENT, deliveryId: 'row_1' } }]); - expect(h.rows()[0]).toMatchObject({ status: 'sent', attempts: 2, last_error: null, claim_token: null }); - }); - - it('leaves a row that is not due yet', async () => { - const h = harness(); - h.seed(h.pendingRow({ next_attempt_at: NOW + 1 })); - expect(await runEnvironmentUserOutboxTick(h.deps)).toBe(0); - expect(h.calls).toHaveLength(0); - }); - - it('a host that still fails pushes the row back by the next wait', async () => { - const h = harness({ host: { userAdded: () => Promise.reject(new Error('cloud down')) } }); - h.seed(h.pendingRow()); - await runEnvironmentUserOutboxTick(h.deps); - expect(h.rows()[0]).toMatchObject({ status: 'pending', attempts: 2, next_attempt_at: NOW + OUTBOX_BACKOFF_MS[1]! }); - }); - - it('the last attempt that fails is failed and logged at error, once', async () => { - const h = harness({ host: { userAdded: () => Promise.reject(new Error('cloud down')) } }); - h.seed(h.pendingRow({ attempts: OUTBOX_MAX_ATTEMPTS - 1 })); - await runEnvironmentUserOutboxTick(h.deps); - expect(h.rows()[0]).toMatchObject({ status: 'failed', attempts: OUTBOX_MAX_ATTEMPTS, next_attempt_at: null }); - expect(h.logger.error).toHaveBeenCalledOnce(); - expect(String(h.logger.error.mock.calls[0]![0])).toContain('nothing will retry it'); - }); - - it('a typed refusal on a retry is failed with the host\'s answer, and the person is left as they are', async () => { - const h = harness({ - host: { - userAdded: () => { - throw new EnvironmentUserHostRefusal(403, 'DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED', 'The member cap is reached.'); - }, - }, - }); - h.seed(h.pendingRow()); - await runEnvironmentUserOutboxTick(h.deps); - expect(h.rows()[0]).toMatchObject({ - status: 'failed', - refusal_code: 'DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED', - last_error: 'The member cap is reached.', - }); - expect(h.engine.tables.get('sys_user')).toEqual([expect.objectContaining({ id: 'usr_p', source: PENDING_SSO_SOURCE })]); - }); - - it('an invitation for a person who signed in meanwhile is accepted, and the host is not called', async () => { - const h = harness({ user: { source: 'idp_provisioned' } }); - h.seed(h.pendingRow()); - await runEnvironmentUserOutboxTick(h.deps); - expect(h.calls).toHaveLength(0); - expect(h.rows()[0]).toMatchObject({ status: 'accepted', accepted_at: new Date(NOW).toISOString() }); - }); - - it('an invitation for a person who is gone is superseded, and the host is not called', async () => { - const h = harness({ user: null }); - h.seed(h.pendingRow()); - await runEnvironmentUserOutboxTick(h.deps); - expect(h.calls).toHaveLength(0); - expect(h.rows()[0]).toMatchObject({ status: 'superseded' }); - }); - - it('a reactivation for a person deactivated again meanwhile is superseded; CONTROL: an active one is sent', async () => { - const banned = harness({ user: { banned: 1 } }); - banned.seed(banned.pendingRow({ kind: 'reactivated' })); - await runEnvironmentUserOutboxTick(banned.deps); - expect(banned.calls).toHaveLength(0); - expect(banned.rows()[0]).toMatchObject({ status: 'superseded' }); - - const active = harness({ user: { banned: 0, source: 'idp_provisioned' } }); - active.seed(active.pendingRow({ kind: 'reactivated' })); - await runEnvironmentUserOutboxTick(active.deps); - expect(active.calls.map((c) => c.member)).toEqual(['userReactivated']); - }); - - it('an invitation for a pending person who was deactivated is superseded, waiting or stranded in flight; the host is not called', async () => { - const h = harness({ user: { banned: 1 } }); - h.seed(h.pendingRow()); - h.seed(h.pendingRow({ id: 'row_2', status: 'in_flight', claim_token: 'dead', claimed_until: NOW - 1 })); - await runEnvironmentUserOutboxTick(h.deps); - expect(h.calls).toHaveLength(0); - expect(h.rows().map((r) => r.status)).toEqual(['superseded', 'superseded']); - }); - - it('a cancellation for a person who signed in meanwhile is superseded; CONTROL: one for a person still pending is sent', async () => { - const signedIn = harness({ user: { source: 'idp_provisioned' } }); - signedIn.seed(signedIn.pendingRow({ kind: 'removed' })); - await runEnvironmentUserOutboxTick(signedIn.deps); - expect(signedIn.calls).toHaveLength(0); - expect(signedIn.rows()[0]).toMatchObject({ status: 'superseded' }); - - const pending = harness(); - pending.seed(pending.pendingRow({ kind: 'removed' })); - await runEnvironmentUserOutboxTick(pending.deps); - expect(pending.calls.map((c) => c.member)).toEqual(['userDeactivated']); - }); - - it('a removal is sent on userRemoved, or on userDeactivated by a host without it', async () => { - const removed = vi.fn(); - const own = harness({ user: null, host: { userRemoved: removed } }); - own.seed(own.pendingRow({ kind: 'removed' })); - await runEnvironmentUserOutboxTick(own.deps); - expect(removed).toHaveBeenCalledOnce(); - expect(own.calls).toHaveLength(0); - - const fallback = harness({ user: null }); - fallback.seed(fallback.pendingRow({ kind: 'removed' })); - await runEnvironmentUserOutboxTick(fallback.deps); - expect(fallback.calls.map((c) => c.member)).toEqual(['userDeactivated']); - expect(fallback.calls[0]!.event.source).toBe(PENDING_SSO_SOURCE); - expect(fallback.rows()[0]).toMatchObject({ status: 'sent' }); - }); - - it('the next due time is the earliest pending row or lapsing claim; none answers null', async () => { - const h = harness(); - expect(await environmentUserOutboxNextDueAt(h.deps)).toBeNull(); - h.seed(h.pendingRow({ id: 'a', next_attempt_at: NOW + 50_000 })); - h.seed(h.pendingRow({ id: 'b', status: 'in_flight', next_attempt_at: null, claim_token: 't', claimed_until: NOW + 20_000 })); - expect(await environmentUserOutboxNextDueAt(h.deps)).toBe(NOW + 20_000); - }); -}); - -describe('an invitation reads accepted once the person signs in', () => { - function hookHarness() { - const engine = createMemoryEngine() as any; - const hooks: Array<{ event: string; handler: (ctx: any) => Promise; object?: string }> = []; - engine.registerHook = (event: string, handler: any, options?: { object?: string }) => - void hooks.push({ event, handler, object: options?.object }); - const logger = { warn: vi.fn() }; - registerOutboxAcceptedTrigger(engine, { logger }); - const fire = (input: unknown) => hooks.find((h) => h.event === 'afterUpdate' && h.object === 'sys_user')!.handler({ input }); - const rows = () => (engine.tables.get(ENVIRONMENT_USER_OUTBOX_OBJECT) ?? []) as any[]; - return { engine, fire, rows, logger }; - } - - it('the stamp that clears the pending marker marks the person\'s invitation rows accepted and stops a retry', async () => { - const h = hookHarness(); - h.engine.tables.set(ENVIRONMENT_USER_OUTBOX_OBJECT, [ - { id: 'sent', user_id: 'usr_p', kind: 'added', status: 'sent' }, - { id: 'retry', user_id: 'usr_p', kind: 'added', status: 'pending', next_attempt_at: NOW }, - { id: 'old', user_id: 'usr_p', kind: 'added', status: 'superseded' }, - { id: 'other', user_id: 'usr_q', kind: 'added', status: 'sent' }, - ]); - await h.fire({ id: 'usr_p', data: { id: 'usr_p', source: 'idp_provisioned' } }); - expect(Object.fromEntries(h.rows().map((r) => [r.id, r.status]))).toEqual({ - sent: 'accepted', - retry: 'accepted', - old: 'superseded', - other: 'sent', - }); - expect(h.rows().find((r) => r.id === 'retry').next_attempt_at).toBeNull(); - }); - - it('CONTROL: an update that leaves the marker, or does not touch source, changes nothing', async () => { - const h = hookHarness(); - h.engine.tables.set(ENVIRONMENT_USER_OUTBOX_OBJECT, [{ id: 'sent', user_id: 'usr_p', kind: 'added', status: 'sent' }]); - await h.fire({ id: 'usr_p', data: { source: PENDING_SSO_SOURCE } }); - await h.fire({ id: 'usr_p', data: { name: 'Renamed' } }); - expect(h.rows()[0].status).toBe('sent'); - }); - - it('a mark that fails is logged and never fails the sign-in', async () => { - const h = hookHarness(); - h.engine.update = () => Promise.reject(new Error('store down')); - await expect(h.fire({ id: 'usr_p', data: { source: 'idp_provisioned' } })).resolves.toBeUndefined(); - expect(h.logger.warn).toHaveBeenCalledOnce(); - }); -}); - -describe('the outbox boots only on a cloud-managed kernel with a host wired', () => { - function bootHarness() { - const engine = createMemoryEngine() as any; - const hooks: string[] = []; - engine.registerHook = (event: string, _handler: unknown, options?: { object?: string }) => - void hooks.push(`${event}:${options?.object}`); - const host: EnvironmentUserHost = { userAdded: () => {}, userDeactivated: () => {}, userReactivated: () => {} }; - return { engine, hooks, host }; - } - - it('starts the worker and registers the accepted trigger when the kernel is cloud-managed and a host is wired', async () => { - const h = bootHarness(); - const worker = bootEnvironmentUserOutbox(h.engine, { host: () => h.host, isCloudManaged: () => true }); - try { - expect(worker).toBeDefined(); - expect(h.hooks).toEqual(['afterUpdate:sys_user']); - } finally { - await worker?.stop(); - } - }); - - it('does nothing off a cloud-managed kernel, even with a host wired, or with no host', () => { - const h = bootHarness(); - expect(bootEnvironmentUserOutbox(h.engine, { host: () => h.host, isCloudManaged: () => false })).toBeUndefined(); - expect(bootEnvironmentUserOutbox(h.engine, { host: undefined, isCloudManaged: () => true })).toBeUndefined(); - expect(h.hooks).toEqual([]); - }); -}); diff --git a/packages/plugins/plugin-auth/src/environment-user-outbox.ts b/packages/plugins/plugin-auth/src/environment-user-outbox.ts deleted file mode 100644 index c45af120919..00000000000 --- a/packages/plugins/plugin-auth/src/environment-user-outbox.ts +++ /dev/null @@ -1,575 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * The durable outbox of the environment-user host seam - * (`environment-user-host.ts`). On a cloud-managed kernel these calls about - * one person are rows of `sys_environment_user_outbox`: every invitation sent - * (an add or re-add), every re-send (a reactivation), every cancellation - * (a removal, and the deactivation of a person still pending). A call the host - * did not take is retried here until it does or the attempts run out. The - * deactivation of a person who has signed in is asked of the host but not - * recorded: there is no invitation to show, and a refused deactivation is - * never retried. Off a cloud-managed kernel nothing is recorded. - * - * ## Why the door still calls first - * - * The hosting rulings (relayed on the pending-people card) ask for "a durable - * outbox with retry … with per-row invitation status in Setup → Users", and - * their edge paths say a CSV row or a reactivation at the developer member - * cap is refused with `403 DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED`, - * shown per row. A refusal the administrator must read on the request cannot - * come from a worker that runs later, so each door keeps making the first - * call itself, and the outbox only makes that call durable: - * - * - **add / re-add** writes its row INSIDE the person's unit of work, born - * `in_flight` and claimed by the door ({@link outboxDoc}), so no worker - * can call the host for it at the same time. After the commit the door - * calls the host and settles the row ({@link settleOutboxAttempt}). A - * process that dies in between leaves a claim that lapses, and the worker - * sends it. - * - **deactivate, reactivate and remove** ask the host BEFORE their write - * (a deactivation or reactivation refused by the host must not happen), - * so the row is written after the call, with the call's outcome, under a - * delivery id chosen before it. - * - * No database transaction is held across any host call (ruling term). - * - * ## Rows and statuses - * - * One row per call. `pending` / `in_flight`: not taken yet; `sent`: taken; - * `accepted`: an `added` row whose person signed in - * ({@link registerOutboxAcceptedTrigger}); `failed`: refused by the host - * (`refusal_code` + its sentence) or out of attempts; `superseded`: a later - * call about the same person replaced it (a re-send, or a deactivation or - * removal, which must never be followed by an invitation sent from a stale - * retry). The newest row of a person is their invitation status. - * - * ## The worker - * - * {@link startEnvironmentUserOutboxWorker}: one `DispatchLoop` - * (`@objectstack/core`), started only on a cloud-managed kernel with a host - * wired. A tick claims due rows one by one with a compare-and-set (a fresh - * claim token, read back) under a lease, so two workers never call the host - * for the same row. Backoff: {@link OUTBOX_BACKOFF_MS}; after - * {@link OUTBOX_MAX_ATTEMPTS} attempts the row is `failed` and an `error` is - * logged. A typed refusal on a retry is terminal `failed` with the host's - * code and sentence, and the person is left as they are: the worker never - * deletes or changes a person. - * - * Delivery is at least once: a call that landed but timed out is sent again. - * The event carries the row id as `deliveryId` so a host can drop a repeat, - * as a re-add already re-tells it today. - */ - -import { randomUUID } from 'node:crypto'; -import { DispatchLoop } from '@objectstack/core'; -import { isPendingSsoSource } from './pending-sso-marker.js'; -import { - notifyEnvironmentUserHost, - type EnvironmentUserEvent, - type EnvironmentUserEventKind, - type EnvironmentUserHostAccessor, - type EnvironmentUserHostOutcome, - type EnvironmentUserHostRefused, -} from './environment-user-host.js'; - -/** The object the recorded calls are kept in (see the module header for which calls). */ -export const ENVIRONMENT_USER_OUTBOX_OBJECT = 'sys_environment_user_outbox'; - -/** The statuses a row moves through. */ -export type EnvironmentUserOutboxStatus = 'pending' | 'in_flight' | 'sent' | 'accepted' | 'failed' | 'superseded'; - -/** - * The wait before attempt N+1, by the number of attempts made so far (index - * 0 = after the first failed attempt). Past the end the last entry repeats. - */ -export const OUTBOX_BACKOFF_MS: readonly number[] = [ - 60_000, // 1 min - 5 * 60_000, // 5 min - 15 * 60_000, // 15 min - 60 * 60_000, // 1 h - 3 * 60 * 60_000, // 3 h - 6 * 60 * 60_000, // 6 h - 12 * 60 * 60_000, // 12 h -]; - -/** After this many attempts a row that never landed is `failed`. */ -export const OUTBOX_MAX_ATTEMPTS = 12; - -/** How long a claim holds a row before another worker may try it. */ -export const OUTBOX_LEASE_MS = 2 * 60_000; - -/** The most rows one worker tick claims. */ -export const OUTBOX_TICK_LIMIT = 25; - -/** When the next attempt is due, after `attempts` attempts. */ -export function outboxNextAttemptAt(attempts: number, now: number): number { - const index = Math.min(Math.max(attempts, 1), OUTBOX_BACKOFF_MS.length) - 1; - return now + OUTBOX_BACKOFF_MS[index]!; -} - -/** The engine slice the outbox uses. */ -export interface EnvironmentUserOutboxEngine { - find(objectName: string, query?: unknown): Promise; - insert(objectName: string, doc: Record, opts?: unknown): Promise; - update(objectName: string, data: Record, opts?: unknown): Promise; -} - -interface OutboxLogger { - warn(msg: string): void; - error?(msg: string, err?: Error): void; -} - -const SYSTEM_CTX = { isSystem: true, positions: [], permissions: [] }; - -/** One row as the worker reads it. */ -export interface EnvironmentUserOutboxRow { - id: string; - user_id: string; - email: string; - kind: EnvironmentUserEventKind; - status: EnvironmentUserOutboxStatus; - attempts: number; - claim_token?: string | null; - event_json: string; -} - -/** The row's state when it is written. */ -export type OutboxBirth = - /** The door holds it and calls the host now (add / re-add). */ - | { status: 'in_flight'; claimToken: string } - /** The host already took the call (an ask-first door). */ - | { status: 'sent' } - /** The host could not be reached (an ask-first door): the worker retries. */ - | { status: 'pending'; lastError: string } - /** Not called yet: the worker sends it at once. */ - | { status: 'queued' }; - -/** A new row: its id is the delivery id the host is (or was) sent. */ -export function outboxDoc( - id: string, - kind: EnvironmentUserEventKind, - event: EnvironmentUserEvent, - birth: OutboxBirth, - now: number = Date.now(), -): Record { - const base: Record = { - id, - user_id: event.userId, - email: event.email, - kind, - status: birth.status === 'queued' ? 'pending' : birth.status, - event_json: JSON.stringify(event), - }; - if (birth.status === 'queued') return { ...base, attempts: 0, next_attempt_at: now }; - if (birth.status === 'in_flight') { - return { ...base, attempts: 0, claim_token: birth.claimToken, claimed_until: now + OUTBOX_LEASE_MS }; - } - const attempted = { attempts: 1, last_attempt_at: new Date(now).toISOString() }; - if (birth.status === 'sent') return { ...base, ...attempted, sent_at: new Date(now).toISOString() }; - return { ...base, ...attempted, last_error: birth.lastError, next_attempt_at: outboxNextAttemptAt(1, now) }; -} - -/** A fresh delivery id and claim token. */ -export const newOutboxId = (): string => randomUUID(); - -/** Write one row, as the system. */ -export async function insertOutboxRow( - engine: EnvironmentUserOutboxEngine, - doc: Record, - context: unknown = SYSTEM_CTX, -): Promise { - await engine.insert(ENVIRONMENT_USER_OUTBOX_OBJECT, doc, { context }); -} - -/** - * Mark a person's unsent rows of `kinds` `superseded`: a re-send replaces an - * older invitation still waiting, and a deactivation or removal stops every - * invitation still waiting, so no stale retry is sent after it. A - * deactivation or removal also passes `in_flight`: a row whose sender died - * holds a claim that lapses, and it must not be sent once it does. - */ -export async function supersedeOpenOutboxRows( - engine: EnvironmentUserOutboxEngine, - userId: string, - kinds: readonly EnvironmentUserEventKind[], - statuses: readonly ('pending' | 'in_flight')[] = ['pending'], -): Promise { - await engine.update( - ENVIRONMENT_USER_OUTBOX_OBJECT, - { status: 'superseded', next_attempt_at: null }, - { - where: { user_id: userId, kind: { $in: [...kinds] }, status: { $in: [...statuses] } }, - multi: true, - context: SYSTEM_CTX, - }, - ); -} - -/** The statuses a deactivation or removal stops: every invitation not yet taken. */ -export const OUTBOX_UNSENT_STATUSES = ['pending', 'in_flight'] as const; - -/** What one attempt's outcome makes of the row. */ -export function outboxSettlement( - outcome: EnvironmentUserHostOutcome | EnvironmentUserHostRefused, - attemptsBefore: number, - now: number, -): { status: EnvironmentUserOutboxStatus; data: Record; exhausted: boolean } { - const attempts = attemptsBefore + 1; - const common = { - attempts, - last_attempt_at: new Date(now).toISOString(), - claim_token: null, - claimed_until: null, - }; - if ('refused' in outcome) { - return { - status: 'failed', - exhausted: false, - data: { - ...common, - status: 'failed', - next_attempt_at: null, - refusal_code: outcome.refused.code, - last_error: outcome.refused.message, - }, - }; - } - if (outcome.notified) { - return { - status: 'sent', - exhausted: false, - data: { ...common, status: 'sent', next_attempt_at: null, sent_at: new Date(now).toISOString(), last_error: null }, - }; - } - const lastError = - outcome.reason === 'no_host' - ? 'No environment-user host answered, so the call was not made.' - : 'The hosting organisation could not be reached, or failed to take the call.'; - if (attempts >= OUTBOX_MAX_ATTEMPTS) { - return { - status: 'failed', - exhausted: true, - data: { ...common, status: 'failed', next_attempt_at: null, last_error: `${lastError} No attempts are left.` }, - }; - } - return { - status: 'pending', - exhausted: false, - data: { ...common, status: 'pending', next_attempt_at: outboxNextAttemptAt(attempts, now), last_error: lastError }, - }; -} - -/** - * Record one attempt's outcome on the row the caller holds (`claimToken`). - * A write that finds the claim gone (lapsed and taken by another worker) - * changes nothing. Answers the status written. - */ -export async function settleOutboxAttempt( - engine: EnvironmentUserOutboxEngine, - row: { id: string; email: string; kind: EnvironmentUserEventKind; attempts: number }, - claimToken: string, - outcome: EnvironmentUserHostOutcome | EnvironmentUserHostRefused, - logger?: OutboxLogger, - now: number = Date.now(), -): Promise { - const settled = outboxSettlement(outcome, row.attempts, now); - await engine.update(ENVIRONMENT_USER_OUTBOX_OBJECT, settled.data, { - where: { id: row.id, claim_token: claimToken }, - multi: true, - context: SYSTEM_CTX, - }); - if (settled.exhausted) { - const message = - `[AuthPlugin] the environment-user host never took the call that ${row.email} was ${row.kind} ` - + `(outbox row ${row.id}, ${OUTBOX_MAX_ATTEMPTS} attempts), so the hosting organisation was not told and ` - + 'nothing will retry it. Setup → Users shows the row as failed; add the person again to re-send an ' - + 'invitation, or repeat the action once the host is reachable.'; - if (logger?.error) logger.error(message); - else logger?.warn(message); - } - return settled.status; -} - -const text = (value: unknown): string => (typeof value === 'string' ? value : ''); - -function readRow(raw: unknown): EnvironmentUserOutboxRow | undefined { - if (!raw || typeof raw !== 'object') return undefined; - const r = raw as Record; - if (!text(r.id) || !text(r.event_json)) return undefined; - return { - id: text(r.id), - user_id: text(r.user_id), - email: text(r.email), - kind: text(r.kind) as EnvironmentUserEventKind, - status: text(r.status) as EnvironmentUserOutboxStatus, - attempts: typeof r.attempts === 'number' ? r.attempts : Number(r.attempts) || 0, - claim_token: typeof r.claim_token === 'string' ? r.claim_token : null, - event_json: text(r.event_json), - }; -} - -/** - * Claim one row: a compare-and-set from the state the tick read (`pending`, - * or `in_flight` under a lapsed claim) to `in_flight` under a fresh token, - * then a read-back of that token. Answers the token when this caller holds - * the row, `undefined` when another claim won. - */ -export async function claimOutboxRow( - engine: EnvironmentUserOutboxEngine, - row: EnvironmentUserOutboxRow, - now: number = Date.now(), -): Promise { - const token = newOutboxId(); - const from = - row.status === 'in_flight' && row.claim_token - ? { id: row.id, status: 'in_flight', claim_token: row.claim_token } - : { id: row.id, status: 'pending' }; - await engine.update( - ENVIRONMENT_USER_OUTBOX_OBJECT, - { status: 'in_flight', claim_token: token, claimed_until: now + OUTBOX_LEASE_MS }, - { where: from, multi: true, context: SYSTEM_CTX }, - ); - const held = await engine.find(ENVIRONMENT_USER_OUTBOX_OBJECT, { - where: { id: row.id, claim_token: token }, - fields: ['id'], - limit: 1, - context: SYSTEM_CTX, - }); - return Array.isArray(held) && held.length > 0 ? token : undefined; -} - -/** What the worker needs. */ -export interface EnvironmentUserOutboxDeps { - getDataEngine(): EnvironmentUserOutboxEngine | undefined; - host: EnvironmentUserHostAccessor; - logger?: OutboxLogger; - now?(): number; -} - -/** Whether a `sys_user` row is deactivated (the memory engine stores `banned` as `0` / `1`). */ -export const isDeactivated = (user: { banned?: unknown }): boolean => user.banned === true || user.banned === 1; - -/** Whether a row still has a reason to be sent, read from the person as they are now. */ -async function stillOwed( - engine: EnvironmentUserOutboxEngine, - row: EnvironmentUserOutboxRow, -): Promise<'send' | 'accepted' | 'superseded'> { - if (row.kind === 'deactivated') return 'send'; - const users = await engine.find('sys_user', { - where: { id: row.user_id }, - fields: ['id', 'source', 'banned'], - limit: 1, - context: SYSTEM_CTX, - }); - const user = (Array.isArray(users) ? users[0] : undefined) as { source?: unknown; banned?: unknown } | undefined; - // A cancellation is owed while the person is gone, or still pending. - if (row.kind === 'removed') return !user || isPendingSsoSource(user.source) ? 'send' : 'superseded'; - if (!user) return 'superseded'; - // An invitation or a re-send is never sent to a deactivated person. - if (isDeactivated(user)) return 'superseded'; - if (row.kind === 'added') return isPendingSsoSource(user.source) ? 'send' : 'accepted'; - return 'send'; -} - -/** Send one claimed row. Answers the status written. */ -export async function deliverOutboxRow( - deps: EnvironmentUserOutboxDeps, - engine: EnvironmentUserOutboxEngine, - row: EnvironmentUserOutboxRow, - claimToken: string, -): Promise { - const now = deps.now?.() ?? Date.now(); - const owed = await stillOwed(engine, row); - if (owed !== 'send') { - await engine.update( - ENVIRONMENT_USER_OUTBOX_OBJECT, - { - status: owed, - claim_token: null, - claimed_until: null, - next_attempt_at: null, - ...(owed === 'accepted' ? { accepted_at: new Date(now).toISOString() } : {}), - }, - { where: { id: row.id, claim_token: claimToken }, multi: true, context: SYSTEM_CTX }, - ); - return owed; - } - let event: EnvironmentUserEvent; - try { - event = JSON.parse(row.event_json) as EnvironmentUserEvent; - } catch { - await engine.update( - ENVIRONMENT_USER_OUTBOX_OBJECT, - { - status: 'failed', - claim_token: null, - claimed_until: null, - next_attempt_at: null, - last_error: 'The stored event could not be read, so the call was not made.', - }, - { where: { id: row.id, claim_token: claimToken }, multi: true, context: SYSTEM_CTX }, - ); - deps.logger?.warn(`[AuthPlugin] environment-user outbox row ${row.id} holds an unreadable event; it is failed.`); - return 'failed'; - } - const outcome = await notifyEnvironmentUserHost(deps.host, row.kind, { ...event, deliveryId: row.id }, deps.logger, { - retried: true, - }); - if ('refused' in outcome) { - deps.logger?.warn( - `[AuthPlugin] the environment-user host refused a retried call that ${row.email} was ${row.kind} ` - + `(${outcome.refused.status} ${outcome.refused.code}). The row is failed; the person is left as they are.`, - ); - } - return settleOutboxAttempt(engine, row, claimToken, outcome, deps.logger, now); -} - -/** One worker pass: claim and send every due row, up to {@link OUTBOX_TICK_LIMIT}. Answers the rows it held. */ -export async function runEnvironmentUserOutboxTick(deps: EnvironmentUserOutboxDeps): Promise { - const engine = deps.getDataEngine(); - if (!engine) return 0; - const now = deps.now?.() ?? Date.now(); - // Two reads, not one `$or`: rows that came due, then rows whose claim lapsed - // (a process that died mid-call). - const read = async (where: Record, field: string): Promise => { - const rows = await engine.find(ENVIRONMENT_USER_OUTBOX_OBJECT, { - where, - orderBy: [{ field, order: 'asc' }], - limit: OUTBOX_TICK_LIMIT, - context: SYSTEM_CTX, - }); - return Array.isArray(rows) ? rows : []; - }; - const due = [ - ...(await read({ status: 'pending', next_attempt_at: { $lte: now } }, 'next_attempt_at')), - ...(await read({ status: 'in_flight', claimed_until: { $lt: now } }, 'claimed_until')), - ].slice(0, OUTBOX_TICK_LIMIT); - let held = 0; - for (const raw of due) { - const row = readRow(raw); - if (!row) continue; - const token = await claimOutboxRow(engine, row, now); - if (!token) continue; - held++; - await deliverOutboxRow(deps, engine, row, token); - } - return held; -} - -/** The earliest instant a row becomes due, for the loop's sleep. */ -export async function environmentUserOutboxNextDueAt(deps: EnvironmentUserOutboxDeps): Promise { - const engine = deps.getDataEngine(); - if (!engine) return null; - const read = async (where: Record, field: string): Promise => { - const rows = await engine.find(ENVIRONMENT_USER_OUTBOX_OBJECT, { - where, - fields: [field], - orderBy: [{ field, order: 'asc' }], - limit: 1, - context: SYSTEM_CTX, - }); - const value = Array.isArray(rows) ? (rows[0] as Record | undefined)?.[field] : undefined; - return typeof value === 'number' && Number.isFinite(value) ? value : null; - }; - const candidates = [ - await read({ status: 'pending' }, 'next_attempt_at'), - await read({ status: 'in_flight' }, 'claimed_until'), - ].filter((v): v is number => v !== null); - return candidates.length > 0 ? Math.min(...candidates) : null; -} - -/** The running worker. */ -export interface EnvironmentUserOutboxWorker { - /** A row was written that is due at `atMs`. */ - wakeAt(atMs: number): void; - stop(): Promise; -} - -/** - * Start the worker. The caller starts it only on a cloud-managed kernel with - * a host wired: elsewhere no row is ever written. - */ -export function startEnvironmentUserOutboxWorker(deps: EnvironmentUserOutboxDeps): EnvironmentUserOutboxWorker { - const loop = new DispatchLoop({ - intervalMs: 60_000, - maxIdleIntervalMs: 10 * 60_000, - nextDueAt: () => environmentUserOutboxNextDueAt(deps), - runTick: () => runEnvironmentUserOutboxTick(deps), - onTickError: (err) => - deps.logger?.warn( - `[AuthPlugin] a pass over the environment-user outbox failed; its rows wait for the next pass. Cause: ` - + `${err instanceof Error ? err.message : String(err)}`, - ), - }); - loop.start(); - return { wakeAt: (atMs) => loop.wakeAt(atMs), stop: () => loop.stop() }; -} - -/** The package id the accepted trigger registers its hook under. */ -export const OUTBOX_ACCEPTED_PACKAGE_ID = 'com.objectstack.plugin-auth.environment-user-outbox-accepted'; - -/** The engine slice the accepted trigger needs. */ -export interface OutboxHookEngine extends EnvironmentUserOutboxEngine { - registerHook(event: string, handler: (ctx: any) => Promise | void, options?: { object?: string; packageId?: string }): void; - unregisterHooksByPackage?(packageId: string): number; -} - -/** - * When a person's `source` leaves the pending marker (their first platform - * sign-in, at either site that clears it), their invitation rows read - * `accepted` and any retry still waiting stops. Best effort: a failure is - * logged at `warn` and never fails the sign-in; the worker re-reads the - * person before every retry, so a missed mark never sends an invitation to - * someone who already accepted. - */ -export function registerOutboxAcceptedTrigger(engine: OutboxHookEngine, opts: { logger?: OutboxLogger } = {}): void { - const onUpdate = async (ctx: any): Promise => { - const data = (ctx?.input?.data ?? {}) as Record; - if (!('source' in data) || isPendingSsoSource(data.source)) return; - const userId = text(ctx?.input?.id) || text(data.id); - if (!userId) return; - try { - await engine.update( - ENVIRONMENT_USER_OUTBOX_OBJECT, - { status: 'accepted', accepted_at: new Date().toISOString(), next_attempt_at: null }, - { - where: { user_id: userId, kind: 'added', status: { $in: ['pending', 'sent', 'failed'] } }, - multi: true, - context: SYSTEM_CTX, - }, - ); - } catch (error) { - opts.logger?.warn( - `[AuthPlugin] user ${userId} signed in for the first time, but their invitation could not be marked ` - + `accepted; Setup → Users shows its earlier status until a retry reads the person. Cause: ` - + `${error instanceof Error ? error.message : String(error)}`, - ); - } - }; - if (typeof engine.unregisterHooksByPackage === 'function') { - try { - engine.unregisterHooksByPackage(OUTBOX_ACCEPTED_PACKAGE_ID); - } catch { - /* first bind: nothing registered yet */ - } - } - engine.registerHook('afterUpdate', onUpdate, { object: 'sys_user', packageId: OUTBOX_ACCEPTED_PACKAGE_ID }); -} - -/** - * Boot the outbox at `kernel:ready`: the accepted trigger and the worker, - * both only on a cloud-managed kernel with a host wired. Elsewhere no door - * writes a row (the doors record only on a cloud-managed kernel, and answer - * `no_host` without a host), so there is nothing to mark or retry, and this - * answers `undefined` without touching the engine. - */ -export function bootEnvironmentUserOutbox( - engine: OutboxHookEngine, - opts: { host: EnvironmentUserHostAccessor | undefined; isCloudManaged(): boolean; logger?: OutboxLogger }, -): EnvironmentUserOutboxWorker | undefined { - const host = opts.host; - if (!host || !opts.isCloudManaged()) return undefined; - registerOutboxAcceptedTrigger(engine, { logger: opts.logger }); - return startEnvironmentUserOutboxWorker({ getDataEngine: () => engine, host, logger: opts.logger }); -} diff --git a/packages/plugins/plugin-auth/src/manifest.ts b/packages/plugins/plugin-auth/src/manifest.ts index dbb825e58ca..2f907775e53 100644 --- a/packages/plugins/plugin-auth/src/manifest.ts +++ b/packages/plugins/plugin-auth/src/manifest.ts @@ -12,7 +12,6 @@ import { SysAccount, SysApiKey, SysDeviceCode, - SysEnvironmentUserOutbox, SysIdpGroupMapping, SysInvitation, SysMember, @@ -94,9 +93,6 @@ export const authIdentityObjects: any[] = [ // The group → permission-set mapping the SCIM projection reads // (`scim-group-projection.ts`); written only by the platform-admin door. SysIdpGroupMapping, - // The record of each call to the environment-user host: invitations sent, - // cancelled and re-sent, retried by `environment-user-outbox.ts`. - SysEnvironmentUserOutbox, ]; /** diff --git a/packages/plugins/plugin-auth/src/pending-sso-marker.ts b/packages/plugins/plugin-auth/src/pending-sso-marker.ts index fbd500ec961..127cd37b11a 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-marker.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-marker.ts @@ -43,11 +43,11 @@ export const PENDING_SSO_MESSAGES = { + "organisation's identity provider, so they cannot be removed here. Deactivate them instead. No one was removed.", removeRefused: 'This person could not be removed, and no one was removed.', removeRefusedReinvited: - 'Their invitation had already been cancelled at the hosting organisation, so it is being sent again and they ' - + 'stay pending as before.', + 'Their invitation had already been cancelled at the hosting organisation, so it was sent again and they stay ' + + 'pending as before.', removeRefusedNotReinvited: - 'Their invitation had already been cancelled at the hosting organisation, and a new one could not be queued: ' - + 'add them again to send it.', + 'Their invitation had already been cancelled at the hosting organisation, and sending it again did not ' + + 'succeed, so they stay pending with no invitation: add them again to send one.', removeHostCancelled: 'The hosting organisation had already been told to cancel their invitation, and it is not sent again.', removeHostUnconfirmed: diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.test.ts b/packages/plugins/plugin-auth/src/pending-sso-users.test.ts index 1c6a437854e..1f17f798c73 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.test.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.test.ts @@ -1174,17 +1174,17 @@ describe('[#33759] Ban / Unban are offered and work without the admin plugin', ( }); // ───────────────────────────────────────────────────────────────────────────── -// Removing a pending person, and the outbox the invitation calls are recorded in +// Removing a pending person, which cancels their invitation at the host // ───────────────────────────────────────────────────────────────────────────── -const outboxRows = (s: Awaited>) => - ((s.engine.tables.get('sys_environment_user_outbox') ?? []) as any[]); - /** A recording host with a `userRemoved` member, unless `withRemoved` is false. */ -function removingHost(opts: { withRemoved?: boolean; removed?: () => void } = {}) { +function removingHost(opts: { withRemoved?: boolean; removed?: () => void; added?: () => void } = {}) { const told: Array<{ kind: string; event: EnvironmentUserEvent }> = []; const host: EnvironmentUserHost = { - userAdded: (event) => void told.push({ kind: 'added', event }), + userAdded: (event) => { + told.push({ kind: 'added', event }); + opts.added?.(); + }, userDeactivated: (event) => void told.push({ kind: 'deactivated', event }), userReactivated: (event) => void told.push({ kind: 'reactivated', event }), ...(opts.withRemoved === false @@ -1210,123 +1210,18 @@ async function addPending(s: Awaited>, email: string): return String(s.row(email)!.id); } -describe('[#33228] every invitation call about a person is recorded in the outbox', () => { - it('an add records its invitation sent, under the delivery id the host was told', async () => { - const s = await managedStage(); - const res = await s.fire('/admin/add-sso-user', { email: 'outbox.add@example.com', name: 'Outbox' }, s.bearers.admin); - const body: any = await res.json(); - expect(res.status).toBe(201); - const [row] = outboxRows(s); - expect(row).toMatchObject({ kind: 'added', status: 'sent', attempts: 1, user_id: body.data.userId, email: 'outbox.add@example.com' }); - expect(body.data.invitation).toEqual({ id: row.id, status: 'sent' }); - expect(s.told[0]!.event.deliveryId).toBe(row.id); - expect(JSON.parse(row.event_json)).toMatchObject({ userId: body.data.userId, actorId: s.ids.admin, source: PENDING_SSO_SOURCE }); - }); - - it('a host that fails leaves the invitation pending for the worker, due after the first wait', async () => { - const s = await managedStage({ - host: { - userAdded: () => { - throw new Error('host down'); - }, - userDeactivated: () => {}, - userReactivated: () => {}, - }, - }); - const before = Date.now(); - const body: any = await (await s.fire('/admin/add-sso-user', { email: 'outbox.retry@example.com', name: 'Retry' }, s.bearers.admin)).json(); - expect(body.data.host).toEqual({ notified: false, reason: 'host_failed' }); - const [row] = outboxRows(s); - expect(row).toMatchObject({ status: 'pending', attempts: 1, claim_token: null }); - expect(row.next_attempt_at).toBeGreaterThanOrEqual(before + 60_000); - expect(body.data.invitation).toEqual({ id: row.id, status: 'pending' }); - }); - - it('a member-cap 403 on an add records the refusal; the person is taken back out as before', async () => { - const { host } = refusingHost(MEMBER_CAP, { added: () => true }); - const s = await managedStage({ host }); - await s.fire('/admin/add-sso-user', { email: 'outbox.cap@example.com', name: 'Cap' }, s.bearers.admin); - expect(s.row('outbox.cap@example.com')).toBeUndefined(); - expect(outboxRows(s)).toEqual([expect.objectContaining({ status: 'failed', refusal_code: MEMBER_CAP.code, last_error: MEMBER_CAP.message })]); - }); - - it('a re-add is the re-send: an older invitation still waiting is superseded by a fresh row', async () => { - let fail = true; - const s = await managedStage({ - host: { - userAdded: () => { - if (fail) throw new Error('host down'); - }, - userDeactivated: () => {}, - userReactivated: () => {}, - }, - }); - const email = 'outbox.resend@example.com'; - await s.fire('/admin/add-sso-user', { email, name: 'Resend' }, s.bearers.admin); - fail = false; - const body: any = await (await s.fire('/admin/add-sso-user', { email, name: 'Resend' }, s.bearers.admin)).json(); - expect(body.data.alreadyPending).toBe(true); - expect(outboxRows(s).map((r) => r.status)).toEqual(['superseded', 'sent']); - expect(body.data.invitation).toEqual({ id: outboxRows(s)[1].id, status: 'sent' }); - }); - - it('deactivating a pending person records the cancelled invitation and stops a retry still waiting', async () => { - let fail = true; - const s = await managedStage({ - host: { - userAdded: () => { - if (fail) throw new Error('host down'); - }, - userDeactivated: () => {}, - userReactivated: () => {}, - }, - }); - const id = await addPending(s, 'outbox.deact@example.com'); - fail = false; - const res = await s.fire('/admin/ban-user', { userId: id }, s.bearers.admin); - const body: any = await res.json(); - expect(res.status, JSON.stringify(body)).toBe(200); - expect(outboxRows(s).map((r) => [r.kind, r.status])).toEqual([ - ['added', 'superseded'], - ['deactivated', 'sent'], - ]); - expect(body.data.invitation).toEqual({ id: outboxRows(s)[1].id, status: 'sent' }); - }); - - it('CONTROL: deactivating a person who is not pending records no row', async () => { - const s = await managedStage(); - expect((await s.fire('/admin/ban-user', { userId: s.ids.member }, s.bearers.admin)).status).toBe(200); - expect(outboxRows(s)).toEqual([]); - }); - - it('a reactivation the host did not take goes ahead and is queued for the worker', async () => { - const s = await managedStage({ - host: { - userAdded: () => {}, - userDeactivated: () => {}, - userReactivated: () => { - throw new Error('host down'); - }, - }, - }); - expect((await s.fire('/admin/ban-user', { userId: s.ids.member }, s.bearers.admin)).status).toBe(200); - const body: any = await (await s.fire('/admin/unban-user', { userId: s.ids.member }, s.bearers.admin)).json(); - expect(body.data).toMatchObject({ banned: false, host: { notified: false, reason: 'host_failed' } }); - expect(outboxRows(s)).toEqual([expect.objectContaining({ kind: 'reactivated', status: 'pending', attempts: 1, user_id: s.ids.member })]); - expect(body.data.invitation).toEqual({ id: outboxRows(s)[0].id, status: 'pending' }); - }); - - it('CONTROL: with no host wired nothing is recorded', async () => { - const s = await managedStage({ host: 'none' }); - await s.fire('/admin/add-sso-user', { email: 'outbox.nohost@example.com', name: 'No Host' }, s.bearers.admin); - expect((await s.fire('/admin/ban-user', { userId: s.ids.member }, s.bearers.admin)).status).toBe(200); - expect((await s.fire('/admin/unban-user', { userId: s.ids.member }, s.bearers.admin)).status).toBe(200); - expect(outboxRows(s)).toEqual([]); - }); -}); +/** Make the delete of `sys_user` answer a `restrict` refusal, as the engine's delete walk does (`DELETE_RESTRICTED`, 409). */ +const RESTRICTED = 'This User cannot be deleted because an Approval Rule still refers to it.'; +function restrictDelete(s: Awaited>): void { + const realDelete = s.engine.delete.bind(s.engine); + s.engine.delete = async (name: string, q: any = {}) => { + if (name === 'sys_user') throw Object.assign(new Error(RESTRICTED), { code: 'DELETE_RESTRICTED', status: 409 }); + return realDelete(name, q); + }; +} describe('[#33228] admin/remove-sso-user removes a pending person and cancels their invitation', () => { - it('removes the row, its grants and membership, tells the host userRemoved first, and records it', async () => { + it('removes the row, its grants and membership, and tells the host userRemoved first', async () => { const { host, told } = removingHost(); const s = await managedStage({ host }); const id = await addPending(s, 'typo@exmaple.com'); @@ -1335,16 +1230,13 @@ describe('[#33228] admin/remove-sso-user removes a pending person and cancels th const body: any = await res.json(); expect(res.status, JSON.stringify(body)).toBe(200); - expect(body.data).toMatchObject({ userId: id, email: 'typo@exmaple.com', removed: true, host: { notified: true } }); + expect(body.data).toEqual({ userId: id, email: 'typo@exmaple.com', removed: true, host: { notified: true } }); expect(s.row('typo@exmaple.com')).toBeUndefined(); for (const table of ['sys_user_position', 'sys_user_permission_set', 'sys_member']) { expect(s.rowsOf(table, id), table).toHaveLength(0); } - const removal = told.find((t) => t.kind === 'removed')!; - expect(removal.event).toMatchObject({ userId: id, email: 'typo@exmaple.com', source: PENDING_SSO_SOURCE, actorId: s.ids.admin }); - const row = outboxRows(s).find((r) => r.kind === 'removed'); - expect(row).toMatchObject({ status: 'sent', user_id: id, id: removal.event.deliveryId }); - expect(body.data.invitation).toEqual({ id: row.id, status: 'sent' }); + expect(told.map((t) => t.kind)).toEqual(['added', 'removed']); + expect(told[1]!.event).toMatchObject({ userId: id, email: 'typo@exmaple.com', source: PENDING_SSO_SOURCE, actorId: s.ids.admin }); }); it('a host without userRemoved is told userDeactivated for the pending person instead', async () => { @@ -1356,7 +1248,7 @@ describe('[#33228] admin/remove-sso-user removes a pending person and cancels th expect(told.map((t) => t.kind)).toEqual(['added', 'deactivated']); expect(told[1]!.event).toMatchObject({ userId: id, source: PENDING_SSO_SOURCE }); - expect(outboxRows(s).find((r) => r.user_id === id && r.kind === 'removed')).toMatchObject({ status: 'sent' }); + expect(s.row('fallback@example.com')).toBeUndefined(); }); it('refuses a person who is not pending with 409, calls no host and removes no one', async () => { @@ -1373,7 +1265,7 @@ describe('[#33228] admin/remove-sso-user removes a pending person and cancels th expect(told).toEqual([]); }); - it('a host\'s typed refusal leaves the person as they are: nothing removed, nothing recorded', async () => { + it('a host\'s typed refusal leaves the person as they are: nothing removed', async () => { const { host } = removingHost({ removed: () => { throw new EnvironmentUserHostRefusal(409, OWNER_CONFLICT.code, OWNER_CONFLICT.message); @@ -1387,64 +1279,69 @@ describe('[#33228] admin/remove-sso-user removes a pending person and cancels th expect(v.status, v.text).toBe(409); expect(v.code).toBe(OWNER_CONFLICT.code); expect(v.message).toBe(OWNER_CONFLICT.message); - expect(s.row('refused.remove@example.com')).toBeDefined(); - expect(outboxRows(s).filter((r) => r.kind === 'removed')).toEqual([]); + expect(s.row('refused.remove@example.com')).toMatchObject({ source: PENDING_SSO_SOURCE }); + expect(s.rowsOf('sys_member', id).length).toBeGreaterThan(0); }); - it('a host that cannot be reached does not block the removal; the cancellation is queued', async () => { - const { host } = removingHost({ + it('a host that cannot be reached does not block the removal, and the answer says host_failed', async () => { + const { host, told } = removingHost({ removed: () => { throw new Error('host down'); }, }); const s = await managedStage({ host }); - const id = await addPending(s, 'queued.remove@example.com'); + const id = await addPending(s, 'unreached.remove@example.com'); const body: any = await (await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)).json(); - expect(body.data).toMatchObject({ removed: true, host: { notified: false, reason: 'host_failed' } }); - expect(s.row('queued.remove@example.com')).toBeUndefined(); - expect(outboxRows(s).find((r) => r.kind === 'removed')).toMatchObject({ status: 'pending', attempts: 1 }); + expect(body.data).toEqual({ userId: id, email: 'unreached.remove@example.com', removed: true, host: { notified: false, reason: 'host_failed' } }); + expect(s.row('unreached.remove@example.com')).toBeUndefined(); + // Asked once: the door retries nothing. + expect(told.map((t) => t.kind)).toEqual(['added', 'removed']); }); - it('with no host wired the person is removed, the answer says no_host and nothing is recorded', async () => { + it('with no host wired the person is removed and the answer says no_host', async () => { const s = await managedStage({ host: 'none' }); const id = await addPending(s, 'nohost.remove@example.com'); const body: any = await (await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)).json(); - expect(body.data).toMatchObject({ removed: true, host: { notified: false, reason: 'no_host' } }); - expect(body.data.invitation).toBeUndefined(); + expect(body.data).toEqual({ userId: id, email: 'nohost.remove@example.com', removed: true, host: { notified: false, reason: 'no_host' } }); expect(s.row('nohost.remove@example.com')).toBeUndefined(); - expect(outboxRows(s)).toEqual([]); }); - it('a record that restricts the delete refuses it with the engine\'s answer; the person stays and is re-invited', async () => { - const { host } = removingHost(); + it('a record that restricts the delete refuses it with the engine\'s answer; the person stays and is re-invited inline', async () => { + const { host, told } = removingHost(); const s = await managedStage({ host }); const id = await addPending(s, 'held@example.com'); - // The engine's delete walk refuses a person a `restrict` lookup still - // points at (`DELETE_RESTRICTED`, 409); this double answers the same. - const realDelete = s.engine.delete.bind(s.engine); - s.engine.delete = async (name: string, q: any = {}) => { - if (name === 'sys_user') { - throw Object.assign(new Error('This User cannot be deleted because an Approval Rule still refers to it.'), { - code: 'DELETE_RESTRICTED', - status: 409, - }); - } - return realDelete(name, q); - }; + restrictDelete(s); const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)); expect(v.status, v.text).toBe(409); expect(v.code).toBe('DELETE_RESTRICTED'); - expect(v.message).toBe( - `${PENDING_SSO_MESSAGES.removeRefused} This User cannot be deleted because an Approval Rule still refers to it. ` - + PENDING_SSO_MESSAGES.removeRefusedReinvited, - ); + expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeRefused} ${RESTRICTED} ${PENDING_SSO_MESSAGES.removeRefusedReinvited}`); expect(s.row('held@example.com')).toMatchObject({ source: PENDING_SSO_SOURCE }); - expect(outboxRows(s).filter((r) => r.kind === 'removed')).toEqual([]); - expect(outboxRows(s).filter((r) => r.kind === 'added').map((r) => r.status)).toEqual(['sent', 'pending']); + expect(told.map((t) => t.kind)).toEqual(['added', 'removed', 'added']); + expect(told[2]!.event).toMatchObject({ userId: id, email: 'held@example.com', source: PENDING_SSO_SOURCE }); + }); + + it('a re-invite the host does not take is said truthfully: the person stays pending with no invitation', async () => { + let calls = 0; + const { host } = removingHost({ + added: () => { + calls += 1; + if (calls > 1) throw new Error('host down'); + }, + }); + const s = await managedStage({ host }); + const id = await addPending(s, 'held.unsent@example.com'); + restrictDelete(s); + + const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)); + + expect(v.status, v.text).toBe(409); + expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeRefused} ${RESTRICTED} ${PENDING_SSO_MESSAGES.removeRefusedNotReinvited}`); + expect(s.row('held.unsent@example.com')).toMatchObject({ source: PENDING_SSO_SOURCE }); + expect(calls).toBe(2); }); it('refuses an unknown id 404, a missing id or an unknown key 400, and a non-admin 403', async () => { @@ -1470,23 +1367,35 @@ describe('[#33228] admin/remove-sso-user removes a pending person and cancels th }); describe('[#33228] a deactivated person is never sent an invitation, and a removal is held to pending people', () => { - /** Make the delete of `sys_user` answer a `restrict` refusal, as the engine's delete walk does. */ - const restrictDelete = (s: Awaited>) => { - const realDelete = s.engine.delete.bind(s.engine); - s.engine.delete = async (name: string, q: any = {}) => { - if (name === 'sys_user') { - throw Object.assign(new Error('This User cannot be deleted because an Approval Rule still refers to it.'), { - code: 'DELETE_RESTRICTED', - status: 409, - }); - } - return realDelete(name, q); - }; - }; - const RESTRICTED = 'This User cannot be deleted because an Approval Rule still refers to it.'; + it('re-adding a deactivated pending person does not invite them: host reads deactivated', async () => { + const { host, told } = removingHost(); + const s = await managedStage({ host }); + const email = 'readd.banned@example.com'; + const id = await addPending(s, email); + expect((await s.fire('/admin/ban-user', { userId: id }, s.bearers.admin)).status).toBe(200); + + const res = await s.fire('/admin/add-sso-user', { email, name: 'Typo' }, s.bearers.admin); + const body: any = await res.json(); + + expect(res.status, JSON.stringify(body)).toBe(200); + expect(body.data).toMatchObject({ userId: id, alreadyPending: true, host: { notified: false, reason: 'deactivated' } }); + expect(told.map((t) => t.kind)).toEqual(['added', 'deactivated']); + }); + + it('CONTROL: re-adding a pending person who is not deactivated invites them again', async () => { + const { host, told } = removingHost(); + const s = await managedStage({ host }); + const email = 'readd.active@example.com'; + const id = await addPending(s, email); + + const body: any = await (await s.fire('/admin/add-sso-user', { email, name: 'Typo' }, s.bearers.admin)).json(); + + expect(body.data).toMatchObject({ userId: id, alreadyPending: true, host: { notified: true } }); + expect(told.map((t) => t.kind)).toEqual(['added', 'added']); + }); it('a refused removal of a deactivated pending person sends no new invitation, and says the old one is cancelled', async () => { - const { host } = removingHost(); + const { host, told } = removingHost(); const s = await managedStage({ host }); const id = await addPending(s, 'held.banned@example.com'); expect((await s.fire('/admin/ban-user', { userId: id }, s.bearers.admin)).status).toBe(200); @@ -1496,12 +1405,11 @@ describe('[#33228] a deactivated person is never sent an invitation, and a remov expect(v.status, v.text).toBe(409); expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeRefused} ${RESTRICTED} ${PENDING_SSO_MESSAGES.removeHostCancelled}`); - expect(outboxRows(s).filter((r) => r.kind === 'added' && r.status === 'pending')).toEqual([]); - expect(outboxRows(s).find((r) => r.kind === 'removed')).toMatchObject({ status: 'sent', user_id: id }); + expect(told.map((t) => t.kind)).toEqual(['added', 'deactivated', 'removed']); }); it('a refused removal the host never took sends no new invitation, and says the cancellation was not confirmed', async () => { - const { host } = removingHost({ + const { host, told } = removingHost({ removed: () => { throw new Error('host down'); }, @@ -1514,22 +1422,10 @@ describe('[#33228] a deactivated person is never sent an invitation, and a remov expect(v.status, v.text).toBe(409); expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeRefused} ${RESTRICTED} ${PENDING_SSO_MESSAGES.removeHostUnconfirmed}`); - expect(outboxRows(s).map((r) => [r.kind, r.status])).toEqual([['added', 'sent']]); - }); - - it('deactivating a pending person stops an invitation whose sender died mid-call, so it is not sent when its claim lapses', async () => { - const s = await managedStage(); - const id = await addPending(s, 'stranded@example.com'); - const [sent] = outboxRows(s); - outboxRows(s).push({ ...sent, id: 'stranded_row', status: 'in_flight', claim_token: 'dead', claimed_until: Date.now() + 60_000 }); - - expect((await s.fire('/admin/ban-user', { userId: id }, s.bearers.admin)).status).toBe(200); - - expect(outboxRows(s).find((r) => r.id === 'stranded_row')).toMatchObject({ status: 'superseded' }); - expect(outboxRows(s).find((r) => r.id === sent.id)).toMatchObject({ status: 'sent' }); + expect(told.map((t) => t.kind)).toEqual(['added', 'removed']); }); - it('a person who signs in while the host is asked is not removed: 409, and the call the host took is recorded', async () => { + it('a person who signs in while the host is asked is not removed: 409, and the answer says the host was told', async () => { const email = 'signs.in@example.com'; let s!: Awaited>; const { host } = removingHost({ @@ -1547,22 +1443,6 @@ describe('[#33228] a deactivated person is never sent an invitation, and a remov expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeNotPending} ${PENDING_SSO_MESSAGES.removeHostCancelled}`); expect(s.row(email)).toMatchObject({ id, source: 'idp_provisioned' }); expect(s.rowsOf('sys_member', id).length).toBeGreaterThan(0); - expect(outboxRows(s).find((r) => r.kind === 'removed')).toMatchObject({ status: 'sent', user_id: id }); - }); - - it('off a cloud-managed kernel a wired host is still asked, but nothing is recorded and no retry is claimed', async () => { - const { host, told } = removingHost(); - host.userReactivated = () => { - throw new Error('host down'); - }; - const s = await stage({ host }); - expect((await s.fire('/admin/ban-user', { userId: s.ids.member }, s.bearers.admin)).status).toBe(200); - const body: any = await (await s.fire('/admin/unban-user', { userId: s.ids.member }, s.bearers.admin)).json(); - - expect(told.map((t) => t.kind)).toEqual(['deactivated']); - expect(body.data).toMatchObject({ banned: false, host: { notified: false, reason: 'host_failed' } }); - expect(body.data.invitation).toBeUndefined(); - expect(outboxRows(s)).toEqual([]); }); }); diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.ts b/packages/plugins/plugin-auth/src/pending-sso-users.ts index c40f38d5413..75be1e4fc6b 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.ts @@ -117,18 +117,6 @@ import { type EnvironmentUserHostOutcome, type EnvironmentUserHostRefused, } from './environment-user-host.js'; -import { - insertOutboxRow, - newOutboxId, - outboxDoc, - isDeactivated, - outboxNextAttemptAt, - OUTBOX_UNSENT_STATUSES, - settleOutboxAttempt, - supersedeOpenOutboxRows, - type EnvironmentUserOutboxEngine, - type EnvironmentUserOutboxStatus, -} from './environment-user-outbox.js'; /** The most rows one import request may carry, the identity import's own bound. */ export const IMPORT_SSO_USERS_MAX_ROWS = 500; @@ -156,8 +144,6 @@ export interface PendingSsoUserDeps /** better-auth's `addMember`, for the multi-organization join; absent when the organization plugin is off. */ getAddMember?(): Promise; host?: EnvironmentUserHostAccessor; - /** Wakes the outbox worker for a call that is due again at `atMs` (`environment-user-outbox.ts`). */ - wakeOutbox?(atMs: number): void; /** `error` receives, once, a membership failure answered with the generic message (`mapAuthApiError`). */ logger?: { warn(msg: string): void; error?(message: string, error?: Error): void }; } @@ -194,16 +180,9 @@ type AddOutcome = manager?: ManagerOutcome; managerError?: string; host: EnvironmentUserHostOutcome; - invitation?: InvitationOutcome; } | { ok: false; result: EndpointResult }; -/** The outbox row a call was recorded in, as an answer names it. */ -interface InvitationOutcome { - id: string; - status: EnvironmentUserOutboxStatus; -} - const ADD_KEYS = new Set(['email', 'name', 'positions', 'permissionSets', 'manager']); const ADD_FIELD_NAMES = { positions: 'positions', permissionSets: 'permissionSets', manager: 'manager' } as const; const IMPORT_FIELD_NAMES = { positions: 'positions', permissionSets: 'permission_sets', manager: 'manager_id' } as const; @@ -248,19 +227,29 @@ function readPerson( async function findUserByEmail( engine: PendingSsoUserEngine, email: string, -): Promise<{ id: string; name?: string; source?: string | null } | undefined> { +): Promise<{ id: string; name?: string; source?: string | null; deactivated: boolean } | undefined> { const rows = await engine.find('sys_user', { where: { email }, - fields: ['id', 'name', 'source'], + fields: ['id', 'name', 'source', 'banned'], limit: 1, context: SYSTEM_CTX, }); - const row = Array.isArray(rows) ? (rows[0] as { id?: unknown; name?: unknown; source?: unknown } | undefined) : undefined; + const row = Array.isArray(rows) + ? (rows[0] as { id?: unknown; name?: unknown; source?: unknown; banned?: unknown } | undefined) + : undefined; return row && typeof row.id === 'string' - ? { id: row.id, name: typeof row.name === 'string' ? row.name : undefined, source: typeof row.source === 'string' ? row.source : null } + ? { + id: row.id, + name: typeof row.name === 'string' ? row.name : undefined, + source: typeof row.source === 'string' ? row.source : null, + deactivated: isDeactivated(row), + } : undefined; } +/** Whether a `sys_user` row is deactivated (the memory engine stores `banned` as `0` / `1`). */ +const isDeactivated = (user: { banned?: unknown }): boolean => user.banned === true || user.banned === 1; + /** The answer for a grant the security service refused: its own status and code, and that no one was added. */ function grantRefused(what: string, error: unknown): EndpointResult { const thrown = resolveThrownHttpError(error, 500); @@ -360,25 +349,22 @@ async function addOnePendingPerson( if (!isPendingSsoSource(existing.source)) { return { ok: false, result: fail(PENDING_SSO_REFUSAL_STATUS, PENDING_SSO_REFUSAL_CODE, PENDING_SSO_MESSAGES.alreadyExists) }; } - // The re-send: a fresh outbox row replaces any older invitation still waiting. - const event = eventFor(existing.id, person.email, existing.name ?? person.name, actor, settlement); - let claim: { id: string; token: string } | undefined; - if (deps.host) { - claim = { id: newOutboxId(), token: newOutboxId() }; - await supersedeOpenOutboxRows(outboxEngine(engine), existing.id, ['added']); - await insertOutboxRow(outboxEngine(engine), outboxDoc(claim.id, 'added', event, { status: 'in_flight', claimToken: claim.token })); + // A deactivated person is never sent an invitation: reactivating them + // (`admin/unban-user`) is what sends it again. + if (existing.deactivated) { + return { ok: true, userId: existing.id, alreadyPending: true, host: { notified: false, reason: 'deactivated' } }; } - const sent = await sendAdded(deps, engine, event, claim); + const host = await notifyEnvironmentUserHost( + deps.host, + 'added', + eventFor(existing.id, person.email, existing.name ?? person.name, actor, settlement), + deps.logger, + ); // A refused re-add leaves the existing pending row as it was: this request did not write it. - if ('refused' in sent.host) return { ok: false, result: hostRefusal(sent.host) }; - return { ok: true, userId: existing.id, alreadyPending: true, host: sent.host, ...(sent.invitation ? { invitation: sent.invitation } : {}) }; + if ('refused' in host) return { ok: false, result: hostRefusal(host) }; + return { ok: true, userId: existing.id, alreadyPending: true, host }; } - // The outbox row is written inside the person's unit of work, held by this - // door (`in_flight`), so the person and the record of their invitation - // land together and no worker calls the host for it meanwhile. - const claim = deps.host ? { id: newOutboxId(), token: newOutboxId() } : undefined; - const work = async (): Promise<{ userId: string; organizationId: string | null }> => { const inserted: unknown = await engine.insert( 'sys_user', @@ -410,16 +396,6 @@ async function addOnePendingPerson( } } } - if (claim) { - await insertOutboxRow( - outboxEngine(engine), - outboxDoc(claim.id, 'added', eventFor(userId, person.email, person.name, actor, settlement), { - status: 'in_flight', - claimToken: claim.token, - }), - await authSystemWriteContext(), - ); - } return { userId, organizationId: membership.organizationId }; }; @@ -433,8 +409,12 @@ async function addOnePendingPerson( } // The host, outside the unit of work. A typed refusal takes this person back out. - const sent = await sendAdded(deps, engine, eventFor(written.userId, person.email, person.name, actor, settlement), claim); - const host = sent.host; + const host = await notifyEnvironmentUserHost( + deps.host, + 'added', + eventFor(written.userId, person.email, person.name, actor, settlement), + deps.logger, + ); if ('refused' in host) { await takeBackPerson(deps, engine, written.userId, settlement); return { ok: false, result: hostRefusal(host) }; @@ -450,72 +430,7 @@ async function addOnePendingPerson( ...(written.organizationId ? { organizationId: written.organizationId } : {}), }, }); - return { - ok: true, - userId: written.userId, - alreadyPending: false, - organizationId: written.organizationId, - host, - ...(sent.invitation ? { invitation: sent.invitation } : {}), - }; -} - -/** The outbox's view of the doors' engine. */ -const outboxEngine = (engine: PendingSsoUserEngine): EnvironmentUserOutboxEngine => engine as EnvironmentUserOutboxEngine; - -/** - * Tell the host a person was added, under the outbox row this door holds - * (`claim`), and record the outcome on that row: `sent`, `failed` for a - * typed refusal, or `pending` for the worker to retry. Without a host wired - * no row exists and the host is not called. - */ -async function sendAdded( - deps: PendingSsoUserDeps, - engine: PendingSsoUserEngine, - event: EnvironmentUserEvent, - claim: { id: string; token: string } | undefined, -): Promise<{ host: EnvironmentUserHostOutcome | EnvironmentUserHostRefused; invitation?: InvitationOutcome }> { - const host = await notifyEnvironmentUserHost( - deps.host, - 'added', - claim ? { ...event, deliveryId: claim.id } : event, - deps.logger, - { retried: claim !== undefined }, - ); - if (!claim) return { host }; - return { host, invitation: await settleHeld(deps, engine, claim, event, host) }; -} - -/** - * Record a held row's first attempt. A failure to record is logged: the - * claim then lapses and the worker sends the call again (the host can drop - * the repeat by its delivery id). - */ -async function settleHeld( - deps: PendingSsoUserDeps, - engine: PendingSsoUserEngine, - claim: { id: string; token: string }, - event: EnvironmentUserEvent, - host: EnvironmentUserHostOutcome | EnvironmentUserHostRefused, -): Promise { - try { - const status = await settleOutboxAttempt( - outboxEngine(engine), - { id: claim.id, email: event.email, kind: 'added', attempts: 0 }, - claim.token, - host, - deps.logger, - ); - if (status === 'pending') deps.wakeOutbox?.(outboxNextAttemptAt(1, Date.now())); - return { id: claim.id, status }; - } catch (error) { - deps.logger?.warn( - `[AuthPlugin] the outcome of telling the environment-user host that ${event.email} was added could not be ` - + `recorded on outbox row ${claim.id}; the worker sends it again once its claim lapses. Cause: ` - + `${error instanceof Error ? error.message : String(error)}`, - ); - return { id: claim.id, status: 'in_flight' }; - } + return { ok: true, userId: written.userId, alreadyPending: false, organizationId: written.organizationId, host }; } /** @@ -568,7 +483,6 @@ async function takeBackPerson( engine: PendingSsoUserEngine, userId: string, settlement: RequestSettlement, - alongside?: () => Promise, first?: () => Promise, ): Promise { if (typeof engine.delete !== 'function') { @@ -582,7 +496,6 @@ async function takeBackPerson( await remove(object, { where: { user_id: userId }, multi: true, context }); } await remove('sys_user', { where: { id: userId }, context }); - if (alongside) await alongside(); }; const unit = settlement.grant?.seam ?? deps.createGrant; await (unit ? unit.runAtomically(work) : work()); @@ -649,7 +562,6 @@ export async function runAddSsoUser( ...(outcome.organizationId ? { organizationId: outcome.organizationId } : {}), ...(manager ? manager : {}), host: outcome.host, - ...(outcome.invitation ? { invitation: outcome.invitation } : {}), }, }, }; @@ -672,8 +584,6 @@ export interface ImportSsoUserRowResult { manager?: ManagerOutcome; managerError?: string; host?: EnvironmentUserHostOutcome; - /** The outbox row the invitation was recorded in, and its status. */ - invitation?: InvitationOutcome; } /** @@ -767,7 +677,6 @@ export async function runImportSsoUsers( alreadyPending: outcome.alreadyPending, ...(notApplied.length > 0 ? { notApplied } : {}), host: outcome.host, - ...(outcome.invitation ? { invitation: outcome.invitation } : {}), }); } @@ -806,15 +715,15 @@ const REMOVE_KEYS = new Set(['userId']); * is deactivated instead. The host is asked first, outside any transaction * (`userRemoved`, or `userDeactivated` on a host without it), so its typed * refusal leaves the person where they are. Then the person's positions, - * permission sets, membership and row are removed as the system, with the - * outbox row recording the cancellation, in one unit of work, through the - * engine's delete, so a record that points at the person follows its lookup's - * `deleteBehavior`: a `restrict` refuses the removal with the engine's own - * answer and nothing is removed. "Pending only" is held at the removal too: a - * person who signs in while the host is asked is answered `409` and kept. A - * host that could not be reached does not block the removal: the - * cancellation is queued and retried. With no host wired nothing is called - * and no row is written. + * permission sets, membership and row are removed as the system, in one unit + * of work, through the engine's delete, so a record that points at the person + * follows its lookup's `deleteBehavior`: a `restrict` refuses the removal with + * the engine's own answer and nothing is removed. "Pending only" is held at + * the removal too: a person who signs in while the host is asked is answered + * `409` and kept. A host that could not be reached does not block the + * removal, and the answer says `host_failed`: the door calls the host once, + * and retrying a call is the host's own business. With no host wired nothing + * is called. */ export async function runRemoveSsoUser( deps: PendingSsoUserDeps, @@ -853,7 +762,6 @@ export async function runRemoveSsoUser( // The host first, outside any transaction: a refusal leaves the person as they are. let host: EnvironmentUserHostOutcome; let event: EnvironmentUserEvent | undefined; - const deliveryId = newOutboxId(); if (deps.host) { event = { userId, @@ -863,19 +771,12 @@ export async function runRemoveSsoUser( ...(await environmentUserAttribution(engine, actor, deps.logger)), occurredAt: new Date().toISOString(), }; - const answer = await notifyEnvironmentUserHost(deps.host, 'removed', { ...event, deliveryId }, deps.logger, { - retried: true, - }); + const answer = await notifyEnvironmentUserHost(deps.host, 'removed', event, deps.logger); if ('refused' in answer) return hostRefusal(answer); host = answer; } else { host = { notified: false, reason: 'no_host' }; } - // A row records the call whenever the host was called; `no_host` means it was not. - const recorded = event && !(!host.notified && host.reason === 'no_host') ? event : undefined; - const birth = host.notified - ? ({ status: 'sent' } as const) - : ({ status: 'pending', lastError: 'The hosting organisation could not be reached, or failed to take the call.' } as const); // Pending only, held at the write: the person may have signed in while the // host was asked, and then they are not removed. @@ -885,37 +786,12 @@ export async function runRemoveSsoUser( if (!row || !isPendingSsoSource(row.source)) throw new NoLongerPending(); }; try { - await takeBackPerson( - deps, - engine, - userId, - {}, - async () => { - if (!recorded) return; - const context = await authSystemWriteContext(); - await supersedeOpenOutboxRows(outboxEngine(engine), userId, ['added', 'reactivated'], OUTBOX_UNSENT_STATUSES); - await insertOutboxRow(outboxEngine(engine), outboxDoc(deliveryId, 'removed', recorded, birth), context); - }, - stillPending, - ); + await takeBackPerson(deps, engine, userId, {}, stillPending); } catch (error) { - return removalNotDone(deps, engine, error, { userId, host, recorded, deliveryId }); + return removalNotDone(deps, engine, error, { userId, host, event }); } - if (recorded && birth.status === 'pending') deps.wakeOutbox?.(outboxNextAttemptAt(1, Date.now())); - return { - status: 200, - body: { - success: true, - data: { - userId, - email, - removed: true, - host, - ...(recorded ? { invitation: { id: deliveryId, status: birth.status } } : {}), - }, - }, - }; + return { status: 200, body: { success: true, data: { userId, email, removed: true, host } } }; } /** Thrown inside the removal's unit of work when the person is no longer pending there. */ @@ -927,38 +803,27 @@ class NoLongerPending extends Error { /** * The answer when the removal's unit of work did not commit: no one was - * removed. What the host was told is said as it happened, and an invitation - * is sent again only when the host took the cancellation and the person is - * still pending and not deactivated. + * removed. What the host was told is said as it happened. When the host had + * taken the cancellation and the person is still pending and not + * deactivated, their invitation is sent again here, once, through + * `userAdded`, and the answer says whether that worked; nothing is retried + * later. */ async function removalNotDone( deps: PendingSsoUserDeps, engine: PendingSsoUserEngine, error: unknown, - call: { userId: string; host: EnvironmentUserHostOutcome; recorded: EnvironmentUserEvent | undefined; deliveryId: string }, + call: { userId: string; host: EnvironmentUserHostOutcome; event: EnvironmentUserEvent | undefined }, ): Promise { - const { userId, host, recorded, deliveryId } = call; - const told = recorded !== undefined && host.notified; - // The cancellation the host took is recorded, so the person's status says so. - const recordCancellation = async (): Promise => { - if (!told) return; - try { - await insertOutboxRow(outboxEngine(engine), outboxDoc(deliveryId, 'removed', recorded!, { status: 'sent' })); - } catch (e) { - deps.logger?.warn( - `[AuthPlugin] the hosting organisation cancelled the invitation of user ${recorded!.userId}, but the record ` - + `of it could not be written. Cause: ${e instanceof Error ? e.message : String(e)}`, - ); - } - }; + const { userId, host, event } = call; + const told = event !== undefined && host.notified; const hostSentence = told ? PENDING_SSO_MESSAGES.removeHostCancelled - : recorded + : event && !(!host.notified && host.reason === 'no_host') ? PENDING_SSO_MESSAGES.removeHostUnconfirmed : ''; if (error instanceof NoLongerPending) { - await recordCancellation(); return fail( PENDING_SSO_REFUSAL_STATUS, PENDING_SSO_REFUSAL_CODE, @@ -975,15 +840,11 @@ async function removalNotDone( } let after = hostSentence; if (told) { - const person = await readPersonState(engine, recorded!.userId); + const person = await readPersonState(engine, userId); if (person.pending && !person.deactivated) { - // The re-send is the person's newest row, so the cancellation is not recorded beside it. - after = (await reinvite(deps, engine, recorded!)) + after = (await reinvite(deps, event!)) ? PENDING_SSO_MESSAGES.removeRefusedReinvited : PENDING_SSO_MESSAGES.removeRefusedNotReinvited; - } else { - await recordCancellation(); - after = PENDING_SSO_MESSAGES.removeHostCancelled; } } return fail(thrown.status, thrown.code, [PENDING_SSO_MESSAGES.removeRefused, cause, after].filter(Boolean).join(' ')); @@ -1010,27 +871,26 @@ async function readPersonState( } /** - * Queue a fresh invitation for a pending person whose removal failed after - * the host took the cancellation of theirs. Answers whether it was queued; a - * failure is logged at `error`: the person stays pending with no invitation. + * Send the invitation again, once, to a pending person whose removal failed + * after the host took the cancellation of theirs (`userAdded`). Answers + * whether the host took it; a refusal or failure is logged at `error`: the + * person stays pending with no invitation until they are added again. */ -async function reinvite(deps: PendingSsoUserDeps, engine: PendingSsoUserEngine, event: EnvironmentUserEvent): Promise { - const now = Date.now(); - try { - await insertOutboxRow( - outboxEngine(engine), - outboxDoc(newOutboxId(), 'added', { ...event, occurredAt: new Date(now).toISOString() }, { status: 'queued' }, now), - ); - deps.wakeOutbox?.(now); - return true; - } catch (error) { - const message = - `[AuthPlugin] removing pending user ${event.userId} failed after the hosting organisation was told to cancel ` - + 'their invitation, and a new invitation could not be queued, so they stay pending with no invitation. ' - + `Add them again to send one. Cause: ${error instanceof Error ? error.message : String(error)}`; - const logger = deps.logger as { warn(msg: string): void; error?(msg: string): void } | undefined; - if (logger?.error) logger.error(message); - else logger?.warn(message); - return false; - } +async function reinvite(deps: PendingSsoUserDeps, event: EnvironmentUserEvent): Promise { + const answer = await notifyEnvironmentUserHost( + deps.host, + 'added', + { ...event, occurredAt: new Date().toISOString() }, + deps.logger, + ); + if (!('refused' in answer) && answer.notified) return true; + const cause = 'refused' in answer ? `${answer.refused.code}: ${answer.refused.message}` : answer.reason; + const message = + `[AuthPlugin] removing pending user ${event.userId} failed after the hosting organisation was told to cancel ` + + 'their invitation, and sending it again did not succeed, so they stay pending with no invitation. ' + + `Add them again to send one. Cause: ${cause}`; + const logger = deps.logger as { warn(msg: string): void; error?(msg: string): void } | undefined; + if (logger?.error) logger.error(message); + else logger?.warn(message); + return false; } diff --git a/packages/spec/src/system/constants/platform-object-names.ts b/packages/spec/src/system/constants/platform-object-names.ts index a0e6bf51197..b66cf6552ab 100644 --- a/packages/spec/src/system/constants/platform-object-names.ts +++ b/packages/spec/src/system/constants/platform-object-names.ts @@ -54,7 +54,6 @@ export const PLATFORM_OBJECTS_BY_PACKAGE: Readonly Date: Mon, 16 Nov 2026 08:28:15 +0000 Subject: [PATCH 09/11] fix(auth): keep the remove door's ledger note a valid string literal Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9 --- packages/plugins/plugin-auth/src/auth-route-ledger.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/plugin-auth/src/auth-route-ledger.ts b/packages/plugins/plugin-auth/src/auth-route-ledger.ts index f216b134784..97b99c42875 100644 --- a/packages/plugins/plugin-auth/src/auth-route-ledger.ts +++ b/packages/plugins/plugin-auth/src/auth-route-ledger.ts @@ -260,7 +260,7 @@ export const AUTH_ROUTE_LEDGER: readonly AuthRouteLedgerEntry[] = [ // #16678 note below. { route: 'POST /api/v1/auth/admin/add-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; adds one person who signs in only through the hosting organisation identity provider: a sys_user row marked idp_pending (no password, refused a session) with optional positions, permission sets and manager, joined to the organization; 201, or 200 alreadyPending for a person already pending (the host is told again, unless the person is deactivated: then host reads deactivated and nothing is sent); 409 RESOURCE_CONFLICT off a managed environment or for an address already in use; closed body key set; the environment-user host is told after the write commits, and its answer rides host; platform-admin gated (ADR-0068)' }, { route: 'POST /api/v1/auth/admin/import-sso-users', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; the CSV or JSON twin of admin/add-sso-user (columns email, name, positions, permission_sets, manager_id), at most 500 rows, each judged and written on its own so a bad row fails alone; answers a summary and one result per row; 409 RESOURCE_CONFLICT off a managed environment; platform-admin gated (ADR-0068)' }, - { route: 'POST /api/v1/auth/admin/remove-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; removes a person who is still pending (sys_user.source idp_pending: the email-typo case) with their positions, permission sets and membership, and cancels their invitation at the environment-user host (userRemoved, else userDeactivated), which is asked first so its typed refusal leaves the person as they are; a host that cannot be reached does not block it and the answer says host_failed (the door calls the host once; retrying is the host's own business); a removal that fails after the host took the cancellation sends the invitation again once through userAdded and says so; body { userId }; 404 RESOURCE_NOT_FOUND for an unknown id; 409 RESOURCE_CONFLICT off a managed environment or for a person who is not pending; a lookup that restricts the delete refuses it with the engine answer; platform-admin gated (ADR-0068)' }, + { route: 'POST /api/v1/auth/admin/remove-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; removes a person who is still pending (sys_user.source idp_pending: the email-typo case) with their positions, permission sets and membership, and cancels their invitation at the environment-user host (userRemoved, else userDeactivated), which is asked first so its typed refusal leaves the person as they are; a host that cannot be reached does not block it and the answer says host_failed (the door calls the host once; retrying belongs to the host); a removal that fails after the host took the cancellation sends the invitation again once through userAdded and says so; body { userId }; 404 RESOURCE_NOT_FOUND for an unknown id; 409 RESOURCE_CONFLICT off a managed environment or for a person who is not pending; a lookup that restricts the delete refuses it with the engine answer; platform-admin gated (ADR-0068)' }, { route: 'POST /api/v1/auth/admin/list-platform-admins', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — the sys_user list_platform_admins action posts it directly from the Users list; answers who holds platform-admin standing (the last-admin guard\'s enumerator, each id confirmed by hasPlatformAdminStanding), served only to a caller who holds that standing; reads no body. ADR-0095 D3' }, { route: 'POST /api/v1/auth/admin/oauth2/toggle-disabled', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — the sys_oauth_application disable/enable actions post it directly; ObjectStack mount closing a vendor gap (better-auth\'s /admin/oauth2/update-client strips `disabled` from its body schema), platform-admin gated (ADR-0068)' }, // #30958 — the tracker id stays HERE and never in the `note` string, per the From 1f9b39d26061ec57bcfcd04c30b02f975113f772 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 09:27:08 +0000 Subject: [PATCH 10/11] fix(auth): hold the remove door to pending people at the row delete, and refuse it when the host is unreachable Delta review round on the reshaped door: - The sys_user delete carries `source: idp_pending` (a predicate delete, which honours deleteBehavior like the by-id one); a zero-row delete throws NoLongerPending, so a first sign-in committing inside the unit of work is answered 409 and the child deletes roll back. - A host that cannot be reached refuses the removal with 503 and nothing removed, as it refuses a deactivation: with no framework record nothing could ask the host again. The "not confirmed" sentence is gone with the path that produced it. - takeBackPerson's doc and throw text now hold for both callers. - A banned column read back as '1' or 'true' counts as deactivated. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9 --- .changeset/33228-remove-pending-sso-user.md | 4 +- content/docs/permissions/authentication.mdx | 14 ++-- .../plugin-auth/src/auth-route-ledger.ts | 2 +- .../plugin-auth/src/pending-sso-marker.ts | 6 +- .../plugin-auth/src/pending-sso-users.test.ts | 56 +++++++++----- .../plugin-auth/src/pending-sso-users.ts | 74 ++++++++++++------- 6 files changed, 98 insertions(+), 58 deletions(-) diff --git a/.changeset/33228-remove-pending-sso-user.md b/.changeset/33228-remove-pending-sso-user.md index 4e7fe3b28d9..2d8b330f093 100644 --- a/.changeset/33228-remove-pending-sso-user.md +++ b/.changeset/33228-remove-pending-sso-user.md @@ -13,9 +13,9 @@ On a cloud-managed environment, a person added to sign in through the hosting or - The host is told through `userRemoved`. A host without it is told through `userDeactivated` with `source: 'idp_pending'`, which already means "cancel the invitation". A host should implement `userRemoved`. - A host refusal (403/409) answers with the host's sentence, and no one is removed. -- A host that cannot be reached does not block the removal; the answer says `host: { notified: false, reason: 'host_failed' }`. The door calls the host once: durable retry is the host's job. +- A host that cannot be reached refuses the removal with `503 SERVICE_UNAVAILABLE`, and no one is removed: the door calls the host once and keeps no record to ask again from, so try again. Durable retry is the host's job. - With no host wired, the person is removed and the answer says `host: { notified: false, reason: 'no_host' }`. -- A person who is not pending answers `409`: deactivate them instead. This holds at the removal itself, so a person who signs in while the host is asked is not removed. +- A person who is not pending answers `409`: deactivate them instead. This holds at the removal itself (the row's delete carries the pending marker), so a person whose first sign-in lands while the host is asked or while the removal is written is not removed. - A person that other records still point at (`deleteBehavior: 'restrict'`) answers the engine's refusal, and nothing is removed. If the host had already cancelled the invitation of a person who is still pending and not deactivated, the door sends it again through `userAdded`, once, and the answer says whether that worked. - An unknown id answers `404`; a body with any key but `userId` answers `400`. Off a cloud-managed environment the door answers `409` and removes no one. diff --git a/content/docs/permissions/authentication.mdx b/content/docs/permissions/authentication.mdx index 97489438289..63d4d00ab4b 100644 --- a/content/docs/permissions/authentication.mdx +++ b/content/docs/permissions/authentication.mdx @@ -1344,12 +1344,14 @@ membership, and cancels their invitation at the host. The host is asked first, through its `userRemoved` member; a host without that member is asked through `userDeactivated` for the pending person instead, which means the same thing, but a host should implement `userRemoved`. A host's refusal leaves the -person as they are. A host that cannot be reached does not block the removal: -the person is removed and the answer says `host: { notified: false, reason: -'host_failed' }`. A person who is not pending (they have signed in, or were -not added this way) is refused with `409`: deactivate them instead. That holds -at the removal itself, so a person who signs in while the host is asked is not -removed either, and the answer says the host was already told. A record that +person as they are. A host that cannot be reached refuses the removal too, +with `503` and nothing removed, as it refuses a deactivation: the door calls +the host once and keeps no record to ask again from, so try again once the +host is back. A person who is not pending (they have signed in, or were not +added this way) is refused with `409`: deactivate them instead. That holds at +the removal itself, so a person whose first sign-in lands while the host is +asked, or while the removal is being written, is not removed either, and the +answer says the host was already told. A record that still points at the person through a lookup that restricts deletes refuses the removal with that lookup's own answer, and nothing is removed; when the host had already cancelled the invitation of a person who is still pending and not diff --git a/packages/plugins/plugin-auth/src/auth-route-ledger.ts b/packages/plugins/plugin-auth/src/auth-route-ledger.ts index 97b99c42875..c5a03de554b 100644 --- a/packages/plugins/plugin-auth/src/auth-route-ledger.ts +++ b/packages/plugins/plugin-auth/src/auth-route-ledger.ts @@ -260,7 +260,7 @@ export const AUTH_ROUTE_LEDGER: readonly AuthRouteLedgerEntry[] = [ // #16678 note below. { route: 'POST /api/v1/auth/admin/add-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; adds one person who signs in only through the hosting organisation identity provider: a sys_user row marked idp_pending (no password, refused a session) with optional positions, permission sets and manager, joined to the organization; 201, or 200 alreadyPending for a person already pending (the host is told again, unless the person is deactivated: then host reads deactivated and nothing is sent); 409 RESOURCE_CONFLICT off a managed environment or for an address already in use; closed body key set; the environment-user host is told after the write commits, and its answer rides host; platform-admin gated (ADR-0068)' }, { route: 'POST /api/v1/auth/admin/import-sso-users', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; the CSV or JSON twin of admin/add-sso-user (columns email, name, positions, permission_sets, manager_id), at most 500 rows, each judged and written on its own so a bad row fails alone; answers a summary and one result per row; 409 RESOURCE_CONFLICT off a managed environment; platform-admin gated (ADR-0068)' }, - { route: 'POST /api/v1/auth/admin/remove-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; removes a person who is still pending (sys_user.source idp_pending: the email-typo case) with their positions, permission sets and membership, and cancels their invitation at the environment-user host (userRemoved, else userDeactivated), which is asked first so its typed refusal leaves the person as they are; a host that cannot be reached does not block it and the answer says host_failed (the door calls the host once; retrying belongs to the host); a removal that fails after the host took the cancellation sends the invitation again once through userAdded and says so; body { userId }; 404 RESOURCE_NOT_FOUND for an unknown id; 409 RESOURCE_CONFLICT off a managed environment or for a person who is not pending; a lookup that restricts the delete refuses it with the engine answer; platform-admin gated (ADR-0068)' }, + { route: 'POST /api/v1/auth/admin/remove-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; removes a person who is still pending (sys_user.source idp_pending: the email-typo case) with their positions, permission sets and membership, and cancels their invitation at the environment-user host (userRemoved, else userDeactivated), which is asked first so its typed refusal leaves the person as they are; a host that cannot be reached refuses it with 503 SERVICE_UNAVAILABLE and nothing is removed (the door calls the host once and keeps no record to retry from); the row delete carries the pending marker, so a person who signs in meanwhile is kept with 409; a removal that fails after the host took the cancellation sends the invitation again once through userAdded and says so; body { userId }; 404 RESOURCE_NOT_FOUND for an unknown id; 409 RESOURCE_CONFLICT off a managed environment or for a person who is not pending; a lookup that restricts the delete refuses it with the engine answer; platform-admin gated (ADR-0068)' }, { route: 'POST /api/v1/auth/admin/list-platform-admins', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — the sys_user list_platform_admins action posts it directly from the Users list; answers who holds platform-admin standing (the last-admin guard\'s enumerator, each id confirmed by hasPlatformAdminStanding), served only to a caller who holds that standing; reads no body. ADR-0095 D3' }, { route: 'POST /api/v1/auth/admin/oauth2/toggle-disabled', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — the sys_oauth_application disable/enable actions post it directly; ObjectStack mount closing a vendor gap (better-auth\'s /admin/oauth2/update-client strips `disabled` from its body schema), platform-admin gated (ADR-0068)' }, // #30958 — the tracker id stays HERE and never in the `note` string, per the diff --git a/packages/plugins/plugin-auth/src/pending-sso-marker.ts b/packages/plugins/plugin-auth/src/pending-sso-marker.ts index 127cd37b11a..350faf1d549 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-marker.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-marker.ts @@ -50,9 +50,9 @@ export const PENDING_SSO_MESSAGES = { + 'succeed, so they stay pending with no invitation: add them again to send one.', removeHostCancelled: 'The hosting organisation had already been told to cancel their invitation, and it is not sent again.', - removeHostUnconfirmed: - 'The hosting organisation was asked to cancel their invitation but did not confirm it, and the request is not ' - + 'retried.', + removeHostUnreachable: + "The hosting organisation could not be reached to cancel this person's invitation, so they were not removed. " + + 'Nothing was changed; try again.', alreadyExists: 'A user with this email address already exists in this environment, so no one was added. Change the existing ' + "user's positions, permission sets or manager on their record instead.", diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.test.ts b/packages/plugins/plugin-auth/src/pending-sso-users.test.ts index 1f17f798c73..51b4466ca44 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.test.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.test.ts @@ -1283,7 +1283,7 @@ describe('[#33228] admin/remove-sso-user removes a pending person and cancels th expect(s.rowsOf('sys_member', id).length).toBeGreaterThan(0); }); - it('a host that cannot be reached does not block the removal, and the answer says host_failed', async () => { + it('a host that cannot be reached refuses the removal: 503, the person is kept and nothing is re-sent', async () => { const { host, told } = removingHost({ removed: () => { throw new Error('host down'); @@ -1292,11 +1292,12 @@ describe('[#33228] admin/remove-sso-user removes a pending person and cancels th const s = await managedStage({ host }); const id = await addPending(s, 'unreached.remove@example.com'); - const body: any = await (await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)).json(); + const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)); - expect(body.data).toEqual({ userId: id, email: 'unreached.remove@example.com', removed: true, host: { notified: false, reason: 'host_failed' } }); - expect(s.row('unreached.remove@example.com')).toBeUndefined(); - // Asked once: the door retries nothing. + expect([v.status, v.code, v.message]).toEqual([503, 'SERVICE_UNAVAILABLE', PENDING_SSO_MESSAGES.removeHostUnreachable]); + expect(s.row('unreached.remove@example.com')).toMatchObject({ id, source: PENDING_SSO_SOURCE }); + expect(s.rowsOf('sys_member', id).length).toBeGreaterThan(0); + // Asked once, and no invitation is sent again. expect(told.map((t) => t.kind)).toEqual(['added', 'removed']); }); @@ -1408,21 +1409,17 @@ describe('[#33228] a deactivated person is never sent an invitation, and a remov expect(told.map((t) => t.kind)).toEqual(['added', 'deactivated', 'removed']); }); - it('a refused removal the host never took sends no new invitation, and says the cancellation was not confirmed', async () => { - const { host, told } = removingHost({ - removed: () => { - throw new Error('host down'); - }, - }); + it('a deactivated pending person whose banned column reads back as a string is not invited on a re-add', async () => { + const { host, told } = removingHost(); const s = await managedStage({ host }); - const id = await addPending(s, 'held.unreached@example.com'); - restrictDelete(s); - - const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)); - - expect(v.status, v.text).toBe(409); - expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeRefused} ${RESTRICTED} ${PENDING_SSO_MESSAGES.removeHostUnconfirmed}`); - expect(told.map((t) => t.kind)).toEqual(['added', 'removed']); + const email = 'readd.banned.string@example.com'; + const id = await addPending(s, email); + for (const stored of ['1', 'true']) { + s.row(email)!.banned = stored; + const body: any = await (await s.fire('/admin/add-sso-user', { email, name: 'Typo' }, s.bearers.admin)).json(); + expect(body.data, stored).toMatchObject({ userId: id, alreadyPending: true, host: { notified: false, reason: 'deactivated' } }); + } + expect(told.map((t) => t.kind)).toEqual(['added']); }); it('a person who signs in while the host is asked is not removed: 409, and the answer says the host was told', async () => { @@ -1444,6 +1441,27 @@ describe('[#33228] a deactivated person is never sent an invitation, and a remov expect(s.row(email)).toMatchObject({ id, source: 'idp_provisioned' }); expect(s.rowsOf('sys_member', id).length).toBeGreaterThan(0); }); + + it('a person whose first sign-in commits inside the unit of work, after the pending read, is not removed: 409', async () => { + const email = 'signs.in.late@example.com'; + const { host } = removingHost(); + const s = await managedStage({ host }); + const id = await addPending(s, email); + // The first sign-in lands between the in-unit pending read and the row's + // delete: the first child delete is the moment after that read. + const realDelete = s.engine.delete.bind(s.engine); + s.engine.delete = async (name: string, q: any = {}) => { + if (name === 'sys_user_position') s.row(email)!.source = 'idp_provisioned'; + return realDelete(name, q); + }; + + const v = await verdict(await s.fire('/admin/remove-sso-user', { userId: id }, s.bearers.admin)); + + expect(v.status, v.text).toBe(409); + expect(v.code).toBe('RESOURCE_CONFLICT'); + expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeNotPending} ${PENDING_SSO_MESSAGES.removeHostCancelled}`); + expect(s.row(email)).toMatchObject({ id, source: 'idp_provisioned' }); + }); }); // ───────────────────────────────────────────────────────────────────────────── diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.ts b/packages/plugins/plugin-auth/src/pending-sso-users.ts index 75be1e4fc6b..149f1acb82a 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.ts @@ -247,8 +247,12 @@ async function findUserByEmail( : undefined; } -/** Whether a `sys_user` row is deactivated (the memory engine stores `banned` as `0` / `1`). */ -const isDeactivated = (user: { banned?: unknown }): boolean => user.banned === true || user.banned === 1; +/** + * Whether a `sys_user` row is deactivated. A boolean column reads back as + * `true`, `1`, or a string form (`'1'`, `'true'`) depending on the driver. + */ +const isDeactivated = (user: { banned?: unknown }): boolean => + user.banned === true || user.banned === 1 || user.banned === '1' || user.banned === 'true'; /** The answer for a grant the security service refused: its own status and code, and that no one was added. */ function grantRefused(what: string, error: unknown): EndpointResult { @@ -472,30 +476,41 @@ const hostRefusal = ({ refused }: EnvironmentUserHostRefused): EndpointResult => const TAKE_BACK_OBJECTS = ['sys_user_position', 'sys_user_permission_set', 'sys_member'] as const; /** - * Take a person the host refused back out: their grants, their membership - * and their row, as the system, in one unit of work. The person was never - * told anything and never signed in, so nothing else points at them. A - * failure here is thrown: the person would stay without the host's consent, - * and the caller must hear that rather than a clean refusal. + * Take a pending person back out: their grants, their membership and their + * row, as the system, in one unit of work, through the engine's delete, so a + * record that points at the person follows its lookup's `deleteBehavior`. + * Two callers: an add the host refused (the person was just written and + * never told anything), and `admin/remove-sso-user`, which passes + * `pendingOnly`. Then the person is read inside the unit of work before + * anything is deleted, and the row's delete carries the pending marker in + * its `where`, so a person whose first sign-in commits at any point before + * that delete is not removed: {@link NoLongerPending} is thrown and the unit + * of work rolls the child deletes back. A failure here is thrown: the caller + * must hear it rather than a clean answer. */ async function takeBackPerson( deps: PendingSsoUserDeps, engine: PendingSsoUserEngine, userId: string, settlement: RequestSettlement, - first?: () => Promise, + opts: { pendingOnly?: boolean } = {}, ): Promise { if (typeof engine.delete !== 'function') { - throw new Error(`The host refused user ${userId}, and this data engine cannot take the row back out`); + throw new Error(`This data engine cannot delete, so user ${userId} could not be taken back out`); } const remove = engine.delete.bind(engine); const work = async (): Promise => { - if (first) await first(); + if (opts.pendingOnly) await assertStillPending(engine, userId); const context = await authSystemWriteContext(); for (const object of TAKE_BACK_OBJECTS) { await remove(object, { where: { user_id: userId }, multi: true, context }); } - await remove('sys_user', { where: { id: userId }, context }); + if (!opts.pendingOnly) { + await remove('sys_user', { where: { id: userId }, context }); + return; + } + const removed = await remove('sys_user', { where: { id: userId, source: PENDING_SSO_SOURCE }, multi: true, context }); + if (removed === 0 || removed === false || removed == null) throw new NoLongerPending(); }; const unit = settlement.grant?.seam ?? deps.createGrant; await (unit ? unit.runAtomically(work) : work()); @@ -719,11 +734,13 @@ const REMOVE_KEYS = new Set(['userId']); * of work, through the engine's delete, so a record that points at the person * follows its lookup's `deleteBehavior`: a `restrict` refuses the removal with * the engine's own answer and nothing is removed. "Pending only" is held at - * the removal too: a person who signs in while the host is asked is answered - * `409` and kept. A host that could not be reached does not block the - * removal, and the answer says `host_failed`: the door calls the host once, - * and retrying a call is the host's own business. With no host wired nothing - * is called. + * the removal too: the row's delete carries the pending marker, so a person + * who signs in while the host is asked, or inside the unit of work, is + * answered `409` and kept. A host that could not be reached refuses the + * removal (`503`, nothing removed), as it refuses a deactivation: the door + * calls the host once and keeps no record to ask again from, so removing the + * person would leave an invitation nothing can cancel. With no host wired + * nothing is called. */ export async function runRemoveSsoUser( deps: PendingSsoUserDeps, @@ -773,6 +790,9 @@ export async function runRemoveSsoUser( }; const answer = await notifyEnvironmentUserHost(deps.host, 'removed', event, deps.logger); if ('refused' in answer) return hostRefusal(answer); + if (!answer.notified && answer.reason === 'host_failed') { + return fail(503, 'SERVICE_UNAVAILABLE', PENDING_SSO_MESSAGES.removeHostUnreachable); + } host = answer; } else { host = { notified: false, reason: 'no_host' }; @@ -780,13 +800,8 @@ export async function runRemoveSsoUser( // Pending only, held at the write: the person may have signed in while the // host was asked, and then they are not removed. - const stillPending = async (): Promise => { - const now = await engine.find('sys_user', { where: { id: userId }, fields: ['id', 'source'], limit: 1, context: SYSTEM_CTX }); - const row = (Array.isArray(now) ? now[0] : undefined) as { source?: unknown } | undefined; - if (!row || !isPendingSsoSource(row.source)) throw new NoLongerPending(); - }; try { - await takeBackPerson(deps, engine, userId, {}, stillPending); + await takeBackPerson(deps, engine, userId, {}, { pendingOnly: true }); } catch (error) { return removalNotDone(deps, engine, error, { userId, host, event }); } @@ -794,6 +809,13 @@ export async function runRemoveSsoUser( return { status: 200, body: { success: true, data: { userId, email, removed: true, host } } }; } +/** Throws {@link NoLongerPending} unless the person is still pending, read now. */ +async function assertStillPending(engine: PendingSsoUserEngine, userId: string): Promise { + const now = await engine.find('sys_user', { where: { id: userId }, fields: ['id', 'source'], limit: 1, context: SYSTEM_CTX }); + const row = (Array.isArray(now) ? now[0] : undefined) as { source?: unknown } | undefined; + if (!row || !isPendingSsoSource(row.source)) throw new NoLongerPending(); +} + /** Thrown inside the removal's unit of work when the person is no longer pending there. */ class NoLongerPending extends Error { constructor() { @@ -816,12 +838,10 @@ async function removalNotDone( call: { userId: string; host: EnvironmentUserHostOutcome; event: EnvironmentUserEvent | undefined }, ): Promise { const { userId, host, event } = call; + // A host that could not be reached refused the removal before this, so the + // host was either told (and took the cancellation) or not called at all. const told = event !== undefined && host.notified; - const hostSentence = told - ? PENDING_SSO_MESSAGES.removeHostCancelled - : event && !(!host.notified && host.reason === 'no_host') - ? PENDING_SSO_MESSAGES.removeHostUnconfirmed - : ''; + const hostSentence = told ? PENDING_SSO_MESSAGES.removeHostCancelled : ''; if (error instanceof NoLongerPending) { return fail( From 2e868fa7e24849da3062c3616ba80594c206de7d Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 10:20:06 +0000 Subject: [PATCH 11/11] fix(auth): state the remove door's pending check as the engine delivers it, and prove the in-unit rollback The row delete carries `source: 'idp_pending'`, but on an object with cascading lookups the engine re-deletes by id after the cascade walk, so a first sign-in committing in that window is not yet refused (#34373, an engine defect). The docblocks, ledger note, docs and changeset now say so instead of claiming the window is closed. The in-unit sign-in test now runs the removal through the plugin's transactional seam (a snapshot transaction on the memory engine) and asserts the positions, permission sets and membership survive. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9 --- .changeset/33228-remove-pending-sso-user.md | 2 +- content/docs/permissions/authentication.mdx | 9 +++++--- .../plugin-auth/src/auth-route-ledger.ts | 2 +- .../plugin-auth/src/pending-sso-users.test.ts | 22 +++++++++++++++++- .../plugin-auth/src/pending-sso-users.ts | 23 +++++++++++-------- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/.changeset/33228-remove-pending-sso-user.md b/.changeset/33228-remove-pending-sso-user.md index 2d8b330f093..d8a83ae3daa 100644 --- a/.changeset/33228-remove-pending-sso-user.md +++ b/.changeset/33228-remove-pending-sso-user.md @@ -15,7 +15,7 @@ On a cloud-managed environment, a person added to sign in through the hosting or - A host refusal (403/409) answers with the host's sentence, and no one is removed. - A host that cannot be reached refuses the removal with `503 SERVICE_UNAVAILABLE`, and no one is removed: the door calls the host once and keeps no record to ask again from, so try again. Durable retry is the host's job. - With no host wired, the person is removed and the answer says `host: { notified: false, reason: 'no_host' }`. -- A person who is not pending answers `409`: deactivate them instead. This holds at the removal itself (the row's delete carries the pending marker), so a person whose first sign-in lands while the host is asked or while the removal is written is not removed. +- A person who is not pending answers `409`: deactivate them instead. This holds at the removal itself: the person is re-checked inside the unit of work and the delete carries `source: 'idp_pending'`, so a person whose first sign-in lands while the host is asked is not removed. On an object with cascading lookups (such as `sys_user`) the engine re-deletes by id after the cascade, so a first sign-in committing in that narrow window is not yet refused. - A person that other records still point at (`deleteBehavior: 'restrict'`) answers the engine's refusal, and nothing is removed. If the host had already cancelled the invitation of a person who is still pending and not deactivated, the door sends it again through `userAdded`, once, and the answer says whether that worked. - An unknown id answers `404`; a body with any key but `userId` answers `400`. Off a cloud-managed environment the door answers `409` and removes no one. diff --git a/content/docs/permissions/authentication.mdx b/content/docs/permissions/authentication.mdx index 63d4d00ab4b..4dec7b45a89 100644 --- a/content/docs/permissions/authentication.mdx +++ b/content/docs/permissions/authentication.mdx @@ -1349,9 +1349,12 @@ with `503` and nothing removed, as it refuses a deactivation: the door calls the host once and keeps no record to ask again from, so try again once the host is back. A person who is not pending (they have signed in, or were not added this way) is refused with `409`: deactivate them instead. That holds at -the removal itself, so a person whose first sign-in lands while the host is -asked, or while the removal is being written, is not removed either, and the -answer says the host was already told. A record that +the removal itself: the person is checked again inside the removal's unit of +work and the delete carries `source: 'idp_pending'`, so a person whose first +sign-in lands while the host is asked is not removed either, and the answer +says the host was already told. Because `sys_user` has cascading lookups, the +engine deletes the row by id after walking them, so a first sign-in that +commits in that narrow window is not yet refused. A record that still points at the person through a lookup that restricts deletes refuses the removal with that lookup's own answer, and nothing is removed; when the host had already cancelled the invitation of a person who is still pending and not diff --git a/packages/plugins/plugin-auth/src/auth-route-ledger.ts b/packages/plugins/plugin-auth/src/auth-route-ledger.ts index c5a03de554b..0e62e1afc54 100644 --- a/packages/plugins/plugin-auth/src/auth-route-ledger.ts +++ b/packages/plugins/plugin-auth/src/auth-route-ledger.ts @@ -260,7 +260,7 @@ export const AUTH_ROUTE_LEDGER: readonly AuthRouteLedgerEntry[] = [ // #16678 note below. { route: 'POST /api/v1/auth/admin/add-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; adds one person who signs in only through the hosting organisation identity provider: a sys_user row marked idp_pending (no password, refused a session) with optional positions, permission sets and manager, joined to the organization; 201, or 200 alreadyPending for a person already pending (the host is told again, unless the person is deactivated: then host reads deactivated and nothing is sent); 409 RESOURCE_CONFLICT off a managed environment or for an address already in use; closed body key set; the environment-user host is told after the write commits, and its answer rides host; platform-admin gated (ADR-0068)' }, { route: 'POST /api/v1/auth/admin/import-sso-users', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; the CSV or JSON twin of admin/add-sso-user (columns email, name, positions, permission_sets, manager_id), at most 500 rows, each judged and written on its own so a bad row fails alone; answers a summary and one result per row; 409 RESOURCE_CONFLICT off a managed environment; platform-admin gated (ADR-0068)' }, - { route: 'POST /api/v1/auth/admin/remove-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; removes a person who is still pending (sys_user.source idp_pending: the email-typo case) with their positions, permission sets and membership, and cancels their invitation at the environment-user host (userRemoved, else userDeactivated), which is asked first so its typed refusal leaves the person as they are; a host that cannot be reached refuses it with 503 SERVICE_UNAVAILABLE and nothing is removed (the door calls the host once and keeps no record to retry from); the row delete carries the pending marker, so a person who signs in meanwhile is kept with 409; a removal that fails after the host took the cancellation sends the invitation again once through userAdded and says so; body { userId }; 404 RESOURCE_NOT_FOUND for an unknown id; 409 RESOURCE_CONFLICT off a managed environment or for a person who is not pending; a lookup that restricts the delete refuses it with the engine answer; platform-admin gated (ADR-0068)' }, + { route: 'POST /api/v1/auth/admin/remove-sso-user', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — Setup → Users on a cloud-managed environment posts it; removes a person who is still pending (sys_user.source idp_pending: the email-typo case) with their positions, permission sets and membership, and cancels their invitation at the environment-user host (userRemoved, else userDeactivated), which is asked first so its typed refusal leaves the person as they are; a host that cannot be reached refuses it with 503 SERVICE_UNAVAILABLE and nothing is removed (the door calls the host once and keeps no record to retry from); the person is re-checked inside the unit of work and the row delete carries source idp_pending, so a person who signs in while the host is asked is kept with 409 (on an object with cascading lookups the engine re-deletes by id, so a first sign-in committing in that narrow window is not yet refused); a removal that fails after the host took the cancellation sends the invitation again once through userAdded and says so; body { userId }; 404 RESOURCE_NOT_FOUND for an unknown id; 409 RESOURCE_CONFLICT off a managed environment or for a person who is not pending; a lookup that restricts the delete refuses it with the engine answer; platform-admin gated (ADR-0068)' }, { route: 'POST /api/v1/auth/admin/list-platform-admins', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — the sys_user list_platform_admins action posts it directly from the Users list; answers who holds platform-admin standing (the last-admin guard\'s enumerator, each id confirmed by hasPlatformAdminStanding), served only to a caller who holds that standing; reads no body. ADR-0095 D3' }, { route: 'POST /api/v1/auth/admin/oauth2/toggle-disabled', family: 'objectstack-mount', source: 'objectstack', disposition: 'server-only', note: 'no SDK method builds this URL — the sys_oauth_application disable/enable actions post it directly; ObjectStack mount closing a vendor gap (better-auth\'s /admin/oauth2/update-client strips `disabled` from its body schema), platform-admin gated (ADR-0068)' }, // #30958 — the tracker id stays HERE and never in the `note` string, per the diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.test.ts b/packages/plugins/plugin-auth/src/pending-sso-users.test.ts index 51b4466ca44..d85a0161601 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.test.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.test.ts @@ -1442,11 +1442,29 @@ describe('[#33228] a deactivated person is never sent an invitation, and a remov expect(s.rowsOf('sys_member', id).length).toBeGreaterThan(0); }); - it('a person whose first sign-in commits inside the unit of work, after the pending read, is not removed: 409', async () => { + it('a person whose first sign-in commits inside the unit of work, after the pending read, is not removed: 409, and the child deletes roll back', async () => { const email = 'signs.in.late@example.com'; const { host } = removingHost(); const s = await managedStage({ host }); const id = await addPending(s, email); + const CHILDREN = ['sys_user_position', 'sys_user_permission_set', 'sys_member'] as const; + for (const table of CHILDREN) expect(s.rowsOf(table, id).length, table).toBeGreaterThan(0); + // The memory engine has no transaction, so the plugin's `runAtomically` + // would run the removal unatomically. Give it one: the seam calls + // `engine.transaction`, and a throw out of it restores every table this + // unit of work wrote. `sys_user` is left as it is, because its change is + // the concurrent sign-in's commit, not this unit of work's write. + let units = 0; + (s.engine as any).transaction = async (work: (trx: unknown, info: unknown) => Promise) => { + units += 1; + const before = new Map([...s.engine.tables].filter(([name]) => name !== 'sys_user').map(([name, rows]) => [name, structuredClone(rows)])); + try { + return await work({}, {}); + } catch (error) { + for (const [name, rows] of before) s.engine.tables.set(name, rows); + throw error; + } + }; // The first sign-in lands between the in-unit pending read and the row's // delete: the first child delete is the moment after that read. const realDelete = s.engine.delete.bind(s.engine); @@ -1461,6 +1479,8 @@ describe('[#33228] a deactivated person is never sent an invitation, and a remov expect(v.code).toBe('RESOURCE_CONFLICT'); expect(v.message).toBe(`${PENDING_SSO_MESSAGES.removeNotPending} ${PENDING_SSO_MESSAGES.removeHostCancelled}`); expect(s.row(email)).toMatchObject({ id, source: 'idp_provisioned' }); + expect(units, 'the removal ran inside the transactional seam').toBe(1); + for (const table of CHILDREN) expect(s.rowsOf(table, id).length, `${table} rolled back`).toBeGreaterThan(0); }); }); diff --git a/packages/plugins/plugin-auth/src/pending-sso-users.ts b/packages/plugins/plugin-auth/src/pending-sso-users.ts index 149f1acb82a..d2608bc280f 100644 --- a/packages/plugins/plugin-auth/src/pending-sso-users.ts +++ b/packages/plugins/plugin-auth/src/pending-sso-users.ts @@ -481,12 +481,16 @@ const TAKE_BACK_OBJECTS = ['sys_user_position', 'sys_user_permission_set', 'sys_ * record that points at the person follows its lookup's `deleteBehavior`. * Two callers: an add the host refused (the person was just written and * never told anything), and `admin/remove-sso-user`, which passes - * `pendingOnly`. Then the person is read inside the unit of work before - * anything is deleted, and the row's delete carries the pending marker in - * its `where`, so a person whose first sign-in commits at any point before - * that delete is not removed: {@link NoLongerPending} is thrown and the unit - * of work rolls the child deletes back. A failure here is thrown: the caller - * must hear it rather than a clean answer. + * `pendingOnly`. Then the person is re-checked inside the unit of work + * before anything is deleted, and the row's delete carries + * `source: 'idp_pending'` in its `where`: when it removes no row, + * {@link NoLongerPending} is thrown and the unit of work rolls the child + * deletes back. One window stays open: `sys_user` has cascading lookups, so + * the engine reads the matching ids, walks the cascade and then deletes by + * id alone, with no row lock, and a first sign-in committing between that + * read and that delete is not yet refused (#34373, an engine defect). A + * failure here is thrown: the caller must hear it rather than a clean + * answer. */ async function takeBackPerson( deps: PendingSsoUserDeps, @@ -734,9 +738,10 @@ const REMOVE_KEYS = new Set(['userId']); * of work, through the engine's delete, so a record that points at the person * follows its lookup's `deleteBehavior`: a `restrict` refuses the removal with * the engine's own answer and nothing is removed. "Pending only" is held at - * the removal too: the row's delete carries the pending marker, so a person - * who signs in while the host is asked, or inside the unit of work, is - * answered `409` and kept. A host that could not be reached refuses the + * the removal too: the person is re-checked inside the unit of work and the + * row's delete carries `source: 'idp_pending'`, so a person who signs in + * while the host is asked is answered `409` and kept (the narrow window the + * engine's delete leaves is in {@link takeBackPerson}). A host that could not be reached refuses the * removal (`503`, nothing removed), as it refuses a deactivation: the door * calls the host once and keeps no record to ask again from, so removing the * person would leave an invitation nothing can cancel. With no host wired