Skip to content
Sarj Workspace Sync

identity-provisioning/contracts

@sarj-ai/workspace-sync/identity-provisioning/contracts ยท Source

import { z } from "zod";
import type { AuthorityIdentity, DesiredProvisioningPlan, ProvisioningProviderId } from "../catalog/identity-authority.ts";
import type { EmployeeEntitlementAuthority } from "./employee-entitlement-policy.ts";
declare const Sha256Schema: z.core.$ZodBranded<z.ZodString, "IdentityProvisioningSha256", "out">;
export type IdentityProvisioningSha256 = z.output<typeof Sha256Schema>;
export declare const ProviderObservationSchema: z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
account: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">;
githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">;
providerId: z.ZodLiteral<"github">;
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
accountId: z.core.$ZodBranded<z.ZodString, "ProviderAccountId", "out">;
providerId: z.ZodEnum<{
ashby: "ashby";
attio: "attio";
linear: "linear";
pagerduty: "pagerduty";
slack: "slack";
}>;
}, z.core.$strict>>]>;
kind: z.ZodLiteral<"present">;
providerId: z.ZodEnum<{
ashby: "ashby";
attio: "attio";
github: "github";
linear: "linear";
pagerduty: "pagerduty";
slack: "slack";
}>;
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
candidates: z.ZodReadonly<z.ZodTuple<[z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">;
githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">;
providerId: z.ZodLiteral<"github">;
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
accountId: z.core.$ZodBranded<z.ZodString, "ProviderAccountId", "out">;
providerId: z.ZodEnum<{
ashby: "ashby";
attio: "attio";
linear: "linear";
pagerduty: "pagerduty";
slack: "slack";
}>;
}, z.core.$strict>>]>], z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">;
githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">;
providerId: z.ZodLiteral<"github">;
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
accountId: z.core.$ZodBranded<z.ZodString, "ProviderAccountId", "out">;
providerId: z.ZodEnum<{
ashby: "ashby";
attio: "attio";
linear: "linear";
pagerduty: "pagerduty";
slack: "slack";
}>;
}, z.core.$strict>>]>>>;
kind: z.ZodLiteral<"ambiguous">;
providerId: z.ZodEnum<{
ashby: "ashby";
attio: "attio";
github: "github";
linear: "linear";
pagerduty: "pagerduty";
slack: "slack";
}>;
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
detail: z.ZodString;
kind: z.ZodLiteral<"unsupported">;
providerId: z.ZodEnum<{
ashby: "ashby";
attio: "attio";
github: "github";
linear: "linear";
pagerduty: "pagerduty";
slack: "slack";
}>;
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
kind: z.ZodLiteral<"absent">;
providerId: z.ZodEnum<{
ashby: "ashby";
attio: "attio";
github: "github";
linear: "linear";
pagerduty: "pagerduty";
slack: "slack";
}>;
}, z.core.$strict>>], "kind">>;
export type ProviderObservation = z.output<typeof ProviderObservationSchema>;
export type ProviderPlanningDecision = {
readonly kind: "satisfied";
readonly providerId: ProvisioningProviderId;
readonly subject: AuthorityIdentity;
} | DesiredProvisioningPlan;
export declare const ProviderApplyReceiptSchema: z.ZodReadonly<z.ZodObject<{
idempotencyKey: z.core.$ZodBranded<z.ZodString, "ProvisioningIdempotencyKey", "out">;
providerReceiptId: z.core.$ZodBranded<z.ZodString, "ProviderReceiptId", "out">;
}, z.core.$strict>>;
export type ProviderApplyReceipt = z.output<typeof ProviderApplyReceiptSchema>;
export declare const ProviderVerificationSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
errorCode: z.ZodString;
kind: z.ZodLiteral<"mismatch">;
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
kind: z.ZodLiteral<"verified">;
resultHash: z.core.$ZodBranded<z.ZodString, "IdentityProvisioningSha256", "out">;
}, z.core.$strict>>], "kind">;
export type ProviderVerification = z.output<typeof ProviderVerificationSchema>;
export declare const ProviderLifecycleActionSchema: z.ZodEnum<{
deprovision: "deprovision";
provision: "provision";
}>;
export type ProviderLifecycleAction = z.output<typeof ProviderLifecycleActionSchema>;
export declare const ProviderLifecycleProtocolSchema: z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodObject<{
authority: z.ZodLiteral<"google-workspace">;
providerId: z.ZodEnum<{
ashby: "ashby";
attio: "attio";
github: "github";
linear: "linear";
pagerduty: "pagerduty";
slack: "slack";
}>;
verification: z.ZodLiteral<"authoritative-readback">;
execution: z.ZodLiteral<"audit-only">;
managedActions: z.ZodReadonly<z.ZodTuple<[], null>>;
}, z.core.$strict>, z.ZodObject<{
authority: z.ZodLiteral<"google-workspace">;
providerId: z.ZodEnum<{
ashby: "ashby";
attio: "attio";
github: "github";
linear: "linear";
pagerduty: "pagerduty";
slack: "slack";
}>;
verification: z.ZodLiteral<"authoritative-readback">;
execution: z.ZodLiteral<"managed">;
managedActions: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
deprovision: "deprovision";
provision: "provision";
}>>>;
}, z.core.$strict>], "execution">>;
export type ProviderLifecycleProtocol = z.output<typeof ProviderLifecycleProtocolSchema>;
export interface IdentityProviderObserver {
observe(subject: AuthorityIdentity): Promise<ProviderObservation>;
}
export interface IdentityProviderPlanner {
plan(subject: AuthorityIdentity, observation: ProviderObservation, context?: IdentityProviderPlanningContext): Promise<ProviderPlanningDecision>;
}
export interface IdentityProviderPlanningContext {
readonly employeeEntitlementAuthority: EmployeeEntitlementAuthority;
}
export interface IdentityProviderApplier {
apply(plan: Exclude<DesiredProvisioningPlan, {
kind: "blocked";
}>, beforeDispatch: () => Promise<void>): Promise<ProviderApplyReceipt>;
}
export interface IdentityProviderVerifier {
verify(plan: Exclude<DesiredProvisioningPlan, {
kind: "blocked";
}>, receipt: ProviderApplyReceipt): Promise<ProviderVerification>;
}
interface IdentityProviderConnectorBase extends IdentityProviderObserver, IdentityProviderPlanner, IdentityProviderVerifier {
readonly protocol: ProviderLifecycleProtocol;
readonly providerId: ProvisioningProviderId;
}
export interface AuditOnlyIdentityProviderConnector extends IdentityProviderConnectorBase {
readonly execution: "audit-only";
}
export interface ManagedIdentityProviderConnector extends IdentityProviderConnectorBase, IdentityProviderApplier {
readonly execution: "managed";
recover(plan: Exclude<DesiredProvisioningPlan, {
kind: "blocked";
}>): Promise<ProviderVerification>;
}
export type IdentityProviderConnector = AuditOnlyIdentityProviderConnector | ManagedIdentityProviderConnector;
export declare function providerLifecycleProtocol(input: ProviderLifecycleProtocol): ProviderLifecycleProtocol;
export declare const IdentityProvisioningExecutionPolicySchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
kind: z.ZodLiteral<"bounded-automatic-deprovision">;
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
kind: z.ZodLiteral<"audit-only">;
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
kind: z.ZodLiteral<"kill-switch-engaged">;
reason: z.ZodString;
}, z.core.$strict>>], "kind">;
export type IdentityProvisioningExecutionPolicy = z.output<typeof IdentityProvisioningExecutionPolicySchema>;
export declare function identityProvisioningSha256(value: string): IdentityProvisioningSha256;
export {};