Scim.ts overview

SCIM 2.0 provisioning (RFC 7643 / RFC 7644): an organization’s identity provider creates, updates and deactivates users, and manages groups as teams. Each ScimConnection is scoped to one organization, and deactivation is a soft disable. See docs/guides/scim.md.


Exports Grouped by Category


utils

SCIM_DEACTIVATED_ATTRIBUTE

Signature

declare const SCIM_DEACTIVATED_ATTRIBUTE: "scimDeactivated"

Source

SCIM_EXTERNAL_ID_ATTRIBUTE

User.attributes key holding the IdP’s own identifier for the user.

Signature

declare const SCIM_EXTERNAL_ID_ATTRIBUTE: "scimExternalId"

Source

SCIM_USERNAME_ATTRIBUTE

User.attributes key holding the SCIM-authoritative userName.

userName is the user’s primary email identifier. Which identifier that is has to survive renames — after a PATCH of userName, the newly claimed address is younger than the user’s other emails, so “earliest verified email” would silently hand userName back to a secondary address. Pinning it here keeps the answer stable; when the key is absent (a user created outside SCIM) the service falls back to primaryEmail.

Signature

declare const SCIM_USERNAME_ATTRIBUTE: "scimUserName"

Source

ScimConfig (interface)

Configuration for ScimService.

Signature

export interface ScimConfig {
  /**
   * Organization role granted to users provisioned through SCIM, for every
   * connection. Unset, the provisioned organization's own `defaultRole`
   * decides (itself defaulting to `"member"`), which is what a tenant that
   * changed its default expects.
   */
  readonly defaultRole?: string
  /**
   * Base path (or absolute URL) the SCIM endpoints are served under, used to
   * build each resource's `meta.location`. Default `"/scim/v2"`; set it to the
   * externally-visible URL (e.g. `"https://app.example.com/api/auth/scim/v2"`)
   * so an IdP can follow the locations it is handed.
   */
  readonly baseUrl?: string
  /**
   * Largest page a list request may return, and the default page size.
   * Default `100`.
   */
  readonly maxPageSize?: number
}

Source

ScimConnection (interface)

A tenant’s SCIM connection: the provisioning credential one organization’s IdP presents, and the scope of everything it may do.

Signature

export interface ScimConnection {
  readonly id: string
  /** The only organization this connection can read or write. */
  readonly organizationId: string
  /** SHA-256 hex digest of the bearer provisioning token; the raw token is never stored. */
  readonly tokenHash: string
  /** Epoch milliseconds. */
  readonly createdAt: number
  /** Epoch milliseconds; refreshed on each authenticated request. */
  readonly lastUsedAt?: number
}

Source

ScimConnectionStore (class)

Persistent registry of SCIM connections.

getByTokenHash is the authentication path, so index the tokenHash column: it is looked up on every SCIM request. Conventions match the rest of the library — None on a miss, no-op deletes, AuthError for infrastructure failures.

Signature

declare class ScimConnectionStore

Source

ScimDeactivatedPlugin

A no-op, kept so existing hook stacks still compose: SessionService refuses a SCIM-deactivated user’s sessions itself.

Signature

declare const ScimDeactivatedPlugin: Layer.Layer<Hooks.Hooks, never, Hooks.Hooks>

Source

ScimEmail (interface)

One entry of a SCIM User.emails[] multi-valued attribute.

Signature

export interface ScimEmail {
  readonly value: string
  /** `true` for the address that is also the `userName`. */
  readonly primary?: boolean
  readonly type?: string
}

Source

ScimError (class)

A SCIM protocol failure, carrying the HTTP status and the RFC 7644 §3.12 scimType detail code the wire response must report.

The status lives on the error rather than being inferred at the HTTP layer because SCIM’s status codes are part of its semantics: 409 with scimType: "uniqueness" is how an IdP learns to reconcile rather than retry, and 400 with invalidPath is how it learns to stop sending an operation.

Signature

declare class ScimError

Source

ScimGroupInput (interface)

The writable attributes of a SCIM Group.

Signature

export interface ScimGroupInput {
  readonly displayName: string
  readonly members?: ReadonlyArray<{ readonly value: string }>
}

Source

ScimGroupResource (interface)

A SCIM Group resource — an organization team.

members[].value is a core user id. The optional display and $ref members of RFC 7643 §4.2 are omitted: both are conveniences an IdP can resolve itself, and populating them would cost a user read per member on every list.

Signature

export interface ScimGroupResource {
  readonly id: string
  readonly displayName: string
  readonly members: ReadonlyArray<{ readonly value: string }>
  /** Epoch milliseconds. */
  readonly createdAt: number
  /** Epoch milliseconds. */
  readonly updatedAt: number
}

Source

ScimListQuery (interface)

Query parameters of a SCIM list request.

Signature

export interface ScimListQuery {
  /** A `eq` filter, e.g. `userName eq "ada@acme.test"`. Nothing else is supported. */
  readonly filter?: string
  /** 1-based; defaults to 1. */
  readonly startIndex?: number
  /** Page size; defaults to (and is capped at) the configured maximum. */
  readonly count?: number
}

Source

ScimListResult (interface)

A page of resources, shaped for the SCIM ListResponse envelope.

Signature

export interface ScimListResult<A> {
  /** Matches *before* pagination. */
  readonly totalResults: number
  /** 1-based index of the first returned resource. */
  readonly startIndex: number
  readonly itemsPerPage: number
  readonly resources: ReadonlyArray<A>
}

Source

ScimPatchOperation (interface)

One entry of an RFC 7644 §3.5.2 PATCH request’s Operations array.

path admits an explicit undefined because that is what a decoded JSON body hands over for an absent optional member, and the path-less form is a dialect this service supports rather than an error.

Signature

export interface ScimPatchOperation {
  /** `add`, `remove` or `replace` (case-insensitive). */
  readonly op: string
  readonly path?: string
  readonly value?: unknown
}

Source

ScimService (class)

SCIM 2.0 provisioning: per-organization bearer connections, and Users and Groups mapped onto users, identifiers and organization teams.

Requires ScimConnectionStore, ScimUserStore, OrganizationStore, IdentifierStore and SessionService.

Signature

declare class ScimService

Source

ScimUserInput (interface)

The writable attributes of a SCIM User, as sent on POST or PUT.

Signature

export interface ScimUserInput {
  readonly userName: string
  readonly displayName?: string
  readonly externalId?: string
  readonly emails?: ReadonlyArray<ScimEmail>
  readonly active?: boolean
}

Source

ScimUserResource (interface)

A SCIM User resource, in domain terms — the JSON envelope (schemas, meta) is added at the HTTP layer.

Signature

export interface ScimUserResource {
  /** The core user id; SCIM's `id` is this library's surrogate key verbatim. */
  readonly id: string
  readonly userName: string
  readonly displayName?: string
  /** The IdP's own identifier, when it sent one. */
  readonly externalId?: string
  readonly emails: ReadonlyArray<ScimEmail>
  readonly active: boolean
  /** Epoch milliseconds. */
  readonly createdAt: number
  /** Epoch milliseconds. */
  readonly updatedAt: number
}

Source

ScimUserStore (class)

The slice of user persistence SCIM needs: create a user, read one back, and write one whose profile or attributes changed.

A dedicated tag rather than a reused one, following the same module-declares-what-it-needs convention as OAuthUserStore, MagicLinkUserStore and AdminUserStore. Back it with the same table as the rest — it is the same User record.

Signature

declare class ScimUserStore

Source

isScimDeactivated

Signature

declare const isScimDeactivated: (user: Types.User) => boolean

Source

make

Signature

declare const make: (
  config?: ScimConfig
) => Effect.Effect<
  typeof ScimService.Service,
  never,
  | ScimConnectionStore
  | ScimUserStore
  | Identifier.IdentifierStore
  | OrganizationStore
  | SessionService
  | SecureRandom.SecureRandom
  | Digest.Digest
>

Source

memoryScimConnectionStore

In-memory ScimConnectionStore, keyed by connection id. Single-process only — good for tests and single-instance deployments.

Pass your own MutableHashMap to inspect or pre-seed state in tests.

Signature

declare const memoryScimConnectionStore: (
  records?: MutableHashMap.MutableHashMap<string, ScimConnection>
) => typeof ScimConnectionStore.Service

Source


This site uses Just the Docs, a documentation theme for Jekyll.