ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications.
Some checks failed
Build, Lint & Test Lib / Build, Lint and Test Library (push) Has been cancelled
|
||
---|---|---|
.github | ||
.vscode | ||
assets | ||
examples/react-tanstack-router | ||
licenses | ||
scripts | ||
src | ||
tests | ||
.editorconfig | ||
.gitignore | ||
biome.jsonc | ||
LICENSE | ||
package.json | ||
playwright.config.ts | ||
pnpm-lock.yaml | ||
pnpm-workspace.yaml | ||
README.md | ||
rslib.config.ts | ||
tsconfig.base.json | ||
tsconfig.json | ||
tsconfig.lib.json | ||
tsconfig.scripts.json | ||
tsconfig.spec.json | ||
vitest.config.ts |
OIDC-CLIENT-RX
ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications.
Quick Start
@TODO Add More Details
Install
pnpm add oidc-client-rx @outposts/injection-js @abraham/reflection
# npm install oidc-client-rx @outposts/injection-js @abraham/reflection
# yarn add oidc-client-rx @outposts/injection-js @abraham/reflection
Basic Usage
import '@abraham/reflection'; // or 'reflect-metadata' | 'core-js/es7/reflect'
import { type Injector, ReflectiveInjector } from '@outposts/injection-js';
import { LogLevel, OidcSecurityService, provideAuth, withDefaultFeatures } from 'oidc-client-rx';
const injector = ReflectiveInjector.resolveAndCreate(
provideAuth(
{
config: {
authority: '<your-authority>',
redirectUrl: `${window.location.origin}/auth/callback`,
postLogoutRedirectUri: window.location.origin,
clientId: '<your-client-id>',
scope: 'openid profile email offline_access',
responseType: 'code',
silentRenew: true,
useRefreshToken: true,
logLevel: LogLevel.Debug,
...
},
},
withDefaultFeatures()
)
) as Injector;
const oidcSecurityService = injector.get(OidcSecurityService);
oidcSecurityService.checkAuth().subscribe((result) => {
console.debug('checkAuth result: ', result);
});
const isAuthenticated$ = oidcSecurityService.isAuthenticated$;