tenant
Import
Section titled “Import”import * as api from "@fungi.computer/oyster/tenant";Exports
Section titled “Exports”| 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. |
TenantIdtype alias
Section titled “TenantId”type TenantId = typeof tenantIdSchema.Type;A validated host-selected tenant identity.
TenantPrincipaltype alias
Section titled “TenantPrincipal”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”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”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”type ResolvedTenant = Readonly<{ scope: TenantScope; auth: OysterAuth;}>;A host-selected scope paired with its existing authentication port.
OysterTenancytype alias
Section titled “OysterTenancy”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”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”const defaultTenant: TenantId;The single-tenant Oyster identity whose durable names remain unchanged.
tenantScope()function
Section titled “tenantScope()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
tenantId |
string & Brand<"OysterTenantId"> |
origin |
string |
Returns
Section titled “Returns”singleTenant()function
Section titled “singleTenant()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
origin |
string |
Returns
Section titled “Returns”implicitTenancy()function
Section titled “implicitTenancy()”function implicitTenancy(origin, auth): OysterTenancy;Preserve the default tenant’s names and auth only at the configured origin.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
origin |
string |
auth |
OysterAuth |