Skip to content
API reference

tenant

Import
import * as api from "@fungi.computer/oyster/tenant";
Kind Export Description
type alias TenantId A validated host-selected tenant identity.
type alias TenantPrincipal A canonical host actor with a tenant role only when the actor is a member.
type alias TenantResolver Resolves a request before authentication; null means refuse, never fallback.
type alias TenantScope The only source of durable names for a standalone Oyster tenant.
type alias ResolvedTenant A host-selected scope paired with its existing authentication port.
type alias OysterTenancy Resolve an origin-scoped host; null refuses the request without a fallback.
constant tenantIdSchema A host-minted tenant slug: 2–40 lowercase ASCII letters or digits, with single interior hyphens. The repository separator -- is forbidden. Hosts resolve it before authentication; App-controlled inputs never select it.
constant defaultTenant The single-tenant Oyster identity whose durable names remain unchanged.
function tenantScope() Name tenant-owned stores without changing any default-tenant name. The t. repository namespace cannot be a default installation slug, which forbids dots. Hub supplies its own Team-scoped ports and does not use this naming contract.
function singleTenant() Admit defaultTenant only at the configured origin. Scheme, host and port must match after URL canonicalization; unknown origins never fall back to default.
function implicitTenancy() Preserve the default tenant’s names and auth only at the configured origin.
Signature
type TenantId = typeof tenantIdSchema.Type;

A validated host-selected tenant identity.


TenantPrincipaltype alias

Section titled “TenantPrincipal”
Signature
type TenantPrincipal =
| Readonly<{
actor: Extract<
HostActor,
{
kind: "member";
}
>;
role: "owner" | "member";
soleMember?: true;
}>
| Readonly<{
actor: Exclude<
HostActor,
{
kind: "member";
}
>;
}>;

A canonical host actor with a tenant role only when the actor is a member.


TenantResolvertype alias

Section titled “TenantResolver”
Signature
type TenantResolver = Readonly<{
resolve: Promise<Readonly<{
tenantId: TenantId;
origin: string;
}> | null>;
}>;

Resolves a request before authentication; null means refuse, never fallback.


TenantScopetype alias

Section titled “TenantScope”
Signature
type TenantScope = Readonly<{
tenantId: TenantId;
origin: string;
durableName: string;
computerName: string;
workspacePrefix: string;
repositoryPrefix: string;
}>;

The only source of durable names for a standalone Oyster tenant.


ResolvedTenanttype alias

Section titled “ResolvedTenant”
Signature
type ResolvedTenant = Readonly<{
scope: TenantScope;
auth: OysterAuth;
}>;

A host-selected scope paired with its existing authentication port.


OysterTenancytype alias

Section titled “OysterTenancy”
Signature
type OysterTenancy = Readonly<{
resolve: Promise<Readonly<{
scope: TenantScope;
auth: OysterAuth;
}> | null>;
}>;

Resolve an origin-scoped host; null refuses the request without a fallback.

tenantIdSchemaconstant

Section titled “tenantIdSchema”
Signature
const tenantIdSchema: brand<String, "OysterTenantId">;

A host-minted tenant slug: 2–40 lowercase ASCII letters or digits, with single interior hyphens. The repository separator -- is forbidden. Hosts resolve it before authentication; App-controlled inputs never select it.


defaultTenantconstant

Section titled “defaultTenant”
Signature
const defaultTenant: TenantId;

The single-tenant Oyster identity whose durable names remain unchanged.

tenantScope()function

Section titled “tenantScope()”
Signature
function tenantScope(tenantId, origin): TenantScope;

Name tenant-owned stores without changing any default-tenant name. The t. repository namespace cannot be a default installation slug, which forbids dots. Hub supplies its own Team-scoped ports and does not use this naming contract.

Parameter Type
tenantId string & Brand<"OysterTenantId">
origin string

TenantScope


singleTenant()function

Section titled “singleTenant()”
Signature
function singleTenant(origin): TenantResolver;

Admit defaultTenant only at the configured origin. Scheme, host and port must match after URL canonicalization; unknown origins never fall back to default.

Parameter Type
origin string

TenantResolver


implicitTenancy()function

Section titled “implicitTenancy()”
Signature
function implicitTenancy(origin, auth): OysterTenancy;

Preserve the default tenant’s names and auth only at the configured origin.

Parameter Type
origin string
auth OysterAuth

OysterTenancy