@themodcraft/nextramice-core
v0.1.0
Published
Framework-neutral Nextramice BFF client and authentication store.
Readme
@themodcraft/nextramice-core
Framework-neutral HTTP client, backend-service contract, DTOs, and observable authentication store for a Nextramice Spring application.
Install
npm install @themodcraft/nextramice-coreUse the BFF client
import { NextramiceAuthStore, NextramiceClient } from "@themodcraft/nextramice-core";
const backend = new NextramiceClient({ baseUrl: "/nextramice" });
const auth = new NextramiceAuthStore(backend);
await auth.loadSession();
console.log(auth.user, auth.authorities);
await auth.login({ username: "[email protected]", password: "secret" });
await auth.logout();NextramiceClient sends cookies with requests and automatically obtains and
reuses the Spring CSRF token for login, registration, and logout.
Supply a custom backend service
Framework stores consume NextramiceBackendService, so another transport can
replace the HTTP client:
import type { NextramiceBackendService } from "@themodcraft/nextramice-core";
class InstrumentedBackend implements NextramiceBackendService {
// Implement the session, provider, CSRF, login, registration, and logout API.
}Use BFF mode when OAuth tokens should remain on the Spring server. Use a framework-specific direct-OIDC adapter only when the browser is intentionally the OAuth client.
