import { Permission } from "@opengeni/contracts"; import { ExternalIdentity } from "@opengeni/contracts/external-identities"; import { type Database } from "./database.js"; export * from "./external-membership-operations.js"; /** Pass an open transaction to retain the key lock through the protected write. */ export declare function lockActiveExternalOrganizationKey(tx: Database, accountId: string, keyId: string, workspaceId?: string): Promise; /** Mode travels with the locked authority so explicit workspace:admin never * becomes a wildcard when callers evaluate a fresh policy. */ export declare function lockActiveExternalOrganizationKeyAuthority(tx: Database, accountId: string, keyId: string, workspaceId?: string): Promise<{ permissions: Permission[]; permissionMode: "legacy" | "explicit"; } | null>; /** * Read-only twin of `lockActiveExternalOrganizationKeyAuthority` for a live * request fence: the same key predicates and workspace scope in one statement, * so the key row and its scope rows come from one snapshot. It takes no row * lock and writes nothing (no `last_used_at`); a revocation, expiry, narrowing * or scope change committed before the statement starts is always observed. */ export declare function readActiveExternalOrganizationKeyAuthority(db: Database, accountId: string, keyId: string, workspaceId: string): Promise<{ permissions: Permission[]; permissionMode: "legacy" | "explicit"; } | null>; /** Transaction-local fence shared with organization member lifecycle writers. * Caller must pass an open transaction, not a pool-level database handle. */ export declare function lockExternalWorkspaceMembershipLifecycle(tx: Database, accountId: string): Promise; /** The same fence in shared mode: ordered against every lifecycle writer * (they take it exclusively) but not against other readers, so concurrent * requests of one organization do not queue behind each other. Take it before * any other lock in the transaction, never after holding it shared and then * wanting it exclusively. Caller must pass an open transaction. */ export declare function lockExternalWorkspaceMembershipLifecycleShared(tx: Database, accountId: string): Promise; /** * Whether the runtime may call the lock-free external identity read yet. 1172 * creates it withheld: a release that does not know it rejects a runtime * EXECUTE grant on it, so a later migration grants it once this release is the * previous one. Until then authentication takes the fence exclusively, as * before. A separate statement: EXECUTE is checked when a statement starts. */ export declare function externalIdentityReadGranted(db: Pick): Promise; /** An existing external identity, read without locking or changing it, or * null when it does not exist yet (provision it with ensureExternalIdentity * under the exclusive fence). An inactive identity is refused with 42501, as * ensureExternalIdentity refuses it. Caller holds the membership fence, at * least shared, in the same transaction and the account's RLS scope, and has * checked externalIdentityReadGranted. */ export declare function readExternalIdentity(tx: Database, input: { accountId: string; externalId: string; source?: string; }): Promise; /** Internal lifecycle seam. Caller must authenticate an organization key and * establish its exact account before invoking; this does not admit HTTP users. * It never creates shared-workspace membership or reactivates removed users. */ export declare function ensureExternalIdentity(db: Database, input: { accountId: string; externalId: string; source?: string; }): Promise;