Use X-Auth as a standard Angular service. Inject it where you need it; call advice() from a click handler; ship the bearer to your backend.
The Angular SDK ships an injectable XAuth service plus a provideXAuth() helper for standalone-API apps.
npm install @xentranet/x-auth-angularXAuth at the app rootRegister the SDK with your tenant id in app.config.ts alongside the rest of your providers.
import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideHttpClient } from '@angular/common/http';
import { provideXAuth } from '@xentranet/x-auth-angular';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideHttpClient(),
provideXAuth({ tenantId: 'your-app' }),
],
};XAuth and call advice()From any component, inject the service and bind a sensitive action. The SDK transparently runs OIDC step-up if your risk policy demands it.
import { Component, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { XAuth } from '@xentranet/x-auth-angular';
@Component({
selector: 'app-transfer',
template: `<button (click)="transfer()">Transfer</button>`,
standalone: true,
})
export class TransferComponent {
private xauth = inject(XAuth);
private http = inject(HttpClient);
async transfer() {
const { decision, access_token } = await this.xauth.advice({
action: 'transfer', amount: 2999, currency: 'USD',
});
if (decision !== 'ALLOW') return;
this.http.post('/api/transfer', { amount: 2999 }, {
headers: { Authorization: `Bearer ${access_token}` },
}).subscribe();
}
}The bearer your Angular app sends is transaction-bound. Your API verifies it matches the requested action — or rejects with 401.
const { transaction_ctx } = await xauth.verify(bearer, {
expect: { action: 'transfer', amount: req.body.amount },
});
await ledger.transfer(transaction_ctx);Pair with a backend quickstart: Express, Go, Spring Boot, ASP.NET.
Add an HTTP interceptor that auto-binds advice() before sensitive routes — coming in v1.1.