import { type Permission, type SlackUserLinkAccessRequest } from "@opengeni/contracts"; import { type Database } from "./database.js"; export declare class SlackUserLinkAccessPersistenceError extends Error { readonly code: "not_found" | "subject_mismatch" | "claim_mismatch" | "version_conflict" | "state_conflict" | "idempotency_conflict" | "slack_identity_conflict"; constructor(code: "not_found" | "subject_mismatch" | "claim_mismatch" | "version_conflict" | "state_conflict" | "idempotency_conflict" | "slack_identity_conflict"); } export type PrepareSlackUserLinkAccessInput = { accountId: string; workspaceId: string; tokenDigest: string; connectionId: string; slackTeamId: string; slackUserId: string; subjectId: string; subjectLabel?: string | null; expiresAt: Date; }; export type SlackUserLinkAccessMutationInput = { workspaceId: string; requestId: string; actorSubjectId: string; expectedVersion: number; idempotencyKey: string; }; /** * The Slack team one access request was raised from. * * The public request shape deliberately omits it, but an approver has to * resolve the installation binding to know where the identity link belongs, and * for a routed request that is not the workspace being granted. */ export declare function slackUserLinkAccessRequestTeam(db: Database, input: { workspaceId: string; requestId: string; }): Promise<{ slackTeamId: string; connectionId: string; slackUserId: string; } | null>; /** * The tenancy an identity link belongs to. See `withSlackIdentityHomeScope`. */ export type SlackIdentityHome = { accountId: string; workspaceId: string; }; export type ApproveSlackUserLinkAccessInput = SlackUserLinkAccessMutationInput & { role?: string; permissions: Permission[]; /** The installation's tenancy, when it differs from the routed request's. */ identityHome?: SlackIdentityHome; }; /** * Persist one verified Slack bearer as token-free, subject-bound state. A * second fresh bearer for the same exact subject/provider principal supersedes * only that subject's older active intent; another subject's row is untouched. */ export declare function prepareSlackUserLinkAccessRequest(db: Database, input: PrepareSlackUserLinkAccessInput, now?: Date): Promise; export declare function getSlackUserLinkAccessRequestForSubject(db: Database, input: { workspaceId: string; requestId: string; subjectId: string; /** The installation's tenancy, when it differs from the routed request's. */ identityHome?: SlackIdentityHome; }, now?: Date): Promise; export declare function requestSlackUserLinkWorkspaceAccess(db: Database, input: SlackUserLinkAccessMutationInput, now?: Date): Promise; export declare function cancelSlackUserLinkAccessRequest(db: Database, input: SlackUserLinkAccessMutationInput, now?: Date): Promise; export declare function denySlackUserLinkAccessRequest(db: Database, input: SlackUserLinkAccessMutationInput, now?: Date): Promise; export declare function approveSlackUserLinkAccessRequest(db: Database, input: ApproveSlackUserLinkAccessInput, now?: Date): Promise; /** * How confirming a request would link its Slack identity, judged live, or null * when confirming would not link it. * * `workspace_membership`: the subject's membership grants sessions:create (or * workspace:admin), or it is their own personal workspace. * * `organization_membership`: an active, full member of the organization * linking a Slack identity that is not linked yet, from a link for the * installation's own workspace (`identityHome`). That only records who the * Slack person is; it grants no workspace membership or permission. A link for * another (routed) workspace, or for an identity that is already linked, is an * access request and keeps the ordinary path. */ export type SlackUserLinkVia = "workspace_membership" | "organization_membership"; /** * Complete a link request once the person linking has confirmed it. * * Opening a link never links anything: the signed link proves only the Slack * side, so a link someone else sent must not attach the sender's Slack account * to whoever opens it. A `prepared` request therefore completes only with * `confirmed`, naming the version the person saw, and only when * `slackUserLinkVia` allows it. A `pending` request was confirmed when the * person asked for access, so it completes once a separate member grant gives * their live membership sessions:create (or workspace:admin). */ export declare function completeSlackUserLinkAccessIfGranted(db: Database, input: { workspaceId: string; requestId: string; subjectId: string; /** The installation's tenancy, when it differs from the routed request's. */ identityHome?: SlackIdentityHome; /** * The person confirmed linking this Slack account, at this version of the * request. Never implied by opening or preparing the link. */ confirmed?: { expectedVersion: number; }; }, now?: Date): Promise; /** * How confirming this prepared request would link the Slack account for this * person (`completeSlackUserLinkAccessIfGranted` with `confirmed`), or null * when it would not, so the person is asked to confirm only when confirming * links, and is offered an access request otherwise. */ export declare function slackUserLinkConfirmationVia(db: Database, input: { workspaceId: string; requestId: string; subjectId: string; identityHome: SlackIdentityHome; }, now?: Date): Promise; export declare function listPendingSlackUserLinkAccessRequests(db: Database, workspaceId: string, now?: Date): Promise; export declare function workspaceMembershipPermissionsAllowSlackLink(value: unknown): boolean;