AuthService
katanakit-js / AuthService
Class: AuthService
Section titled “Class: AuthService”Defined in: core/services/auth.service.ts:91
Holds the providers a deployment has configured and routes a request to one.
A registry rather than a single global provider because “which one” is configuration: a municipality may resolve a national identity number while a SaaS resolves an OAuth session, and both ship as the same kit. Nothing here reaches the network — providers are injected, so the core stays pure and testable with a stub.
Methods
Section titled “Methods”useHas()
Section titled “useHas()”useHas(provider): boolean;Defined in: core/services/auth.service.ts:117
Whether a provider id is registered.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
provider |
string |
Returns
Section titled “Returns”boolean
useProviders()
Section titled “useProviders()”useProviders(): string[];Defined in: core/services/auth.service.ts:122
Registered provider ids, in registration order.
Returns
Section titled “Returns”string[]
useRegister()
Section titled “useRegister()”useRegister(provider): void;Defined in: core/services/auth.service.ts:112
Registers a provider, replacing any previous one with the same id.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
provider |
IAuthProvider |
Returns
Section titled “Returns”void
useResolve()
Section titled “useResolve()”useResolve(provider, input): Promise<AuthResult< | { claims?: Record<string, unknown>; email?: string; emailVerified?: boolean; method: string; provider: string; subject: string;}| null>>;Defined in: core/services/auth.service.ts:138
Resolves the caller through the named provider.
An unknown provider id is a configuration failure, not an anonymous
visitor — it returns ok: false so a typo cannot quietly turn a guarded
route into a public one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
provider |
string |
input |
AuthRequestLike |
Returns
Section titled “Returns”Promise<AuthResult<
| {
claims?: Record<string, unknown>;
email?: string;
emailVerified?: boolean;
method: string;
provider: string;
subject: string;
}
| null>>
useUnregister()
Section titled “useUnregister()”useUnregister(provider): boolean;Defined in: core/services/auth.service.ts:127
Removes a provider. Returns whether it was there.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
provider |
string |
Returns
Section titled “Returns”boolean
create()
Section titled “create()”static create(): AuthService;Defined in: core/services/auth.service.ts:107
A non-singleton instance, for tests or for isolating two deployments.
Returns
Section titled “Returns”AuthService
getInstance()
Section titled “getInstance()”static getInstance(): AuthService;Defined in: core/services/auth.service.ts:101
The shared instance.
Returns
Section titled “Returns”AuthService