Skip to content
0

katanakit-js / AuthService

Class: AuthService ​

Defined in: src/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 ​

useHas() ​

ts
useHas(provider): boolean;

Defined in: src/core/services/auth.service.ts:117

Whether a provider id is registered.

Parameters ​

ParameterType
providerstring

Returns ​

boolean


useProviders() ​

ts
useProviders(): string[];

Defined in: src/core/services/auth.service.ts:122

Registered provider ids, in registration order.

Returns ​

string[]


useRegister() ​

ts
useRegister(provider): void;

Defined in: src/core/services/auth.service.ts:112

Registers a provider, replacing any previous one with the same id.

Parameters ​

ParameterType
providerIAuthProvider

Returns ​

void


useResolve() ​

ts
useResolve(provider, input): Promise<AuthResult<
  | {
  claims?: Record<string, unknown>;
  email?: string;
  emailVerified?: boolean;
  method: string;
  provider: string;
  subject: string;
}
| null>>;

Defined in: src/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 ​

ParameterType
providerstring
inputAuthRequestLike

Returns ​

Promise<AuthResult< | { claims?: Record<string, unknown>; email?: string; emailVerified?: boolean; method: string; provider: string; subject: string; } | null>>


useUnregister() ​

ts
useUnregister(provider): boolean;

Defined in: src/core/services/auth.service.ts:127

Removes a provider. Returns whether it was there.

Parameters ​

ParameterType
providerstring

Returns ​

boolean


create() ​

ts
static create(): AuthService;

Defined in: src/core/services/auth.service.ts:107

A non-singleton instance, for tests or for isolating two deployments.

Returns ​

AuthService


getInstance() ​

ts
static getInstance(): AuthService;

Defined in: src/core/services/auth.service.ts:101

The shared instance.

Returns ​

AuthService

Released under the MIT License.