Identity.Base Docs

Angular SDK

`@identity-base/angular-client` is the official Angular SDK layer for Identity Base. It wraps `@identity-base/client-core` with Angular DI services, guards, and optional token-attachment behavior.

bash
npm install @identity-base/angular-client
typescript
import { provideIdentityClient } from '@identity-base/angular-client';

export const appConfig = {
  providers: [
    ...provideIdentityClient({
      apiBase: 'https://identity.example.com',
      clientId: 'spa-client',
      redirectUri: 'https://app.example.com/auth/callback',
      scope: 'openid profile email identity.api',
      tokenStorage: 'sessionStorage',
      autoRefresh: true,
      loginPath: '/login'
    })
  ]
}
typescript
import { inject } from '@angular/core';
import { IDENTITY_AUTH_MANAGER } from '@identity-base/angular-client';

const manager = inject(IDENTITY_AUTH_MANAGER);
const principals = await manager.admin.servicePrincipals.list({ page: 1 });

What the Angular package adds

  • `provideIdentityClient(...)` registers the SDK once at the app root.
  • `IdentityAuthService` wraps the underlying auth manager and exposes observable auth state.
  • `IdentityRequireAuthGuard` protects routes and redirects unauthenticated users to the configured login path.
  • `IdentityAuthInterceptor` can attach bearer tokens to requests targeting your configured API base.
  • `IDENTITY_AUTH_MANAGER` provides the complete client-core surface, including admin.servicePrincipals.

Organizations add-on

typescript
npm install @identity-base/angular-organizations

import { provideIdentityOrganizations } from '@identity-base/angular-organizations';

export const appConfig = {
  providers: [
    ...provideIdentityOrganizations({
      apiBase: 'https://identity.example.com',
    }),
  ],
};

const page = await organizations.user.organizations.list({
  page: 1,
  pageSize: 25,
});
const roles = await organizations.user.roles.list(
  page.items[0].organizationId,
);
const adminPage = await organizations.admin.organizations.list({
  search: 'acme',
});
  • OrganizationsService separates public invitations from explicit user and admin namespaces for organizations, members, roles, and invitations.
  • ActiveOrganizationService and OrganizationContextInterceptor attach X-Organization-Id according to configurable include/exclude rules.
  • Requests include cookies, attach a bearer token when available, accept empty 204 responses, and normalize Problem Details or plain text into the shared client error type.