> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khanhng.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 4.5 Platform services

> Reference for DemoAuthService, ConsoleLogger, and InMemoryNotificationService in @kcode/services.

`@kcode/services` exports implementations of the SDK service interfaces.

## 4.5.1 DemoAuthService

A development-only implementation of `MutableAuthService`. Replace either boundary for production.

```ts theme={"system"}
import { DemoAuthService, AuthenticationError } from "@kcode/services";

const auth = new DemoAuthService({ validator, sessions });
try {
  const { user } = await auth.signIn({ username, password, rememberMe: true });
} catch (error) {
  if (error instanceof AuthenticationError) console.warn(error.code);
}
```

| Member | Description |
| - | - |
| `new DemoAuthService(options?)` | `options.validator` is a `CredentialValidator`. `options.sessions` is an `AuthSessionStore`. |
| `signIn({ username, password, rememberMe? })` | Returns `{ user }`. Throws `AuthenticationError`. |
| `signOut()` | Clears the session store. |
| `getCurrentUser()`, `isAuthenticated()`, `hasPermission(id)` | `hasPermission` is true for `platform.admin` or an exact match. |

| `AuthenticationError.code` | Cause |
| - | - |
| `INVALID_REQUEST` | Empty username or password. |
| `INVALID_CREDENTIALS` | The validator returned no user. |

The default validator accepts only `admin` / `admin` and returns the user `demo-admin` with the `platform.admin` permission. The default session store is `InMemoryAuthSessionStore`.

## 4.5.2 ConsoleLogger

Implements the SDK `Logger` and writes to the console.

## 4.5.3 InMemoryNotificationService

Implements `NotificationService`. It assigns IDs of the form `notification-<n>`, keeps notifications in memory, and notifies listeners when the list changes. `dismiss(id)` returns `false` for an unknown ID, and `clear()` removes all notifications.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.